Merge "Add a gap in the ordering for phone numbers." into qt-dev
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index 5149b9c..603900c 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -183,6 +183,7 @@
<intent-filter android:priority="1">
<action android:name="android.settings.WIRELESS_SETTINGS" />
<action android:name="android.settings.AIRPLANE_MODE_SETTINGS" />
+ <action android:name="com.android.settings.sim.SIM_SUB_INFO_SETTINGS" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
<intent-filter>
@@ -2624,27 +2625,6 @@
android:resource="@xml/file_paths" />
</provider>
- <activity
- android:name="Settings$SimSettingsActivity"
- android:label="@string/sim_settings_title"
- android:icon="@drawable/ic_settings_sim"
- android:parentActivityName="Settings">
- <intent-filter android:priority="1">
- <action android:name="com.android.settings.sim.SIM_SUB_INFO_SETTINGS" />
- <category android:name="android.intent.category.DEFAULT" />
- </intent-filter>
- <intent-filter>
- <action android:name="com.android.settings.action.SETTINGS" />
- </intent-filter>
- <meta-data android:name="com.android.settings.order" android:value="-2"/>
- <meta-data android:name="com.android.settings.category"
- android:value="com.android.settings.category.ia.wireless" />
- <meta-data android:name="com.android.settings.summary"
- android:resource="@string/summary_empty"/>
- <meta-data android:name="com.android.settings.FRAGMENT_CLASS"
- android:value="com.android.settings.sim.SimSettings" />
- </activity>
-
<activity android:name=".sim.SimPreferenceDialog"
android:theme="@style/Theme.AlertDialog"
android:excludeFromRecents="true" />
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 57d56ad..00feb17 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -7331,6 +7331,8 @@
<string name="keywords_notification_vibration">haptics, vibrate, sensitivity</string>
<!-- Battery Saver: Search terms for sticky battery saver preference [CHAR_LIMIT=NONE] -->
<string name="keywords_battery_saver_sticky">battery saver, sticky, persist, power saver, battery</string>
+ <!-- Battery Saver: Search terms for battery saver schedule preference. Feel free to add additional terms when translating if appropriate [CHAR_LIMIT=NONE] -->
+ <string name="keywords_battery_saver_schedule">routine, schedule, battery saver, power saver, battery, automatic, percent</string>
<!-- Option title for the default sound, context based on screen -->
<string name="default_sound">Default sound</string>
diff --git a/res/xml/battery_saver_settings.xml b/res/xml/battery_saver_settings.xml
index 528e648..fa02bff 100644
--- a/res/xml/battery_saver_settings.xml
+++ b/res/xml/battery_saver_settings.xml
@@ -24,6 +24,7 @@
android:key="battery_saver_schedule"
android:fragment="com.android.settings.fuelgauge.batterysaver.BatterySaverScheduleSettings"
android:title="@string/battery_saver_schedule_settings_title"
+ settings:keywords="@string/keywords_battery_saver_schedule"
settings:controller="com.android.settings.fuelgauge.batterysaver.BatterySaverSchedulePreferenceController"/>
<SwitchPreference
diff --git a/src/com/android/settings/SettingsActivity.java b/src/com/android/settings/SettingsActivity.java
index 8077ee3..4ac4be4 100644
--- a/src/com/android/settings/SettingsActivity.java
+++ b/src/com/android/settings/SettingsActivity.java
@@ -613,11 +613,6 @@
isAdmin) || somethingChanged;
somethingChanged = setTileEnabled(changedList, new ComponentName(packageName,
- Settings.SimSettingsActivity.class.getName()),
- Utils.showSimCardTile(this), isAdmin)
- || somethingChanged;
-
- somethingChanged = setTileEnabled(changedList, new ComponentName(packageName,
Settings.PowerUsageSummaryActivity.class.getName()),
mBatteryPresent, isAdmin) || somethingChanged;
@@ -639,9 +634,8 @@
showDev, isAdmin)
|| somethingChanged;
- boolean enableBackupTile = new BackupSettingsHelper(this).showBackupSettingsForUser();
somethingChanged = setTileEnabled(changedList, new ComponentName(packageName,
- UserBackupSettingsActivity.class.getName()), enableBackupTile, isAdmin)
+ UserBackupSettingsActivity.class.getName()), true, isAdmin)
|| somethingChanged;
somethingChanged = setTileEnabled(changedList, new ComponentName(packageName,
diff --git a/src/com/android/settings/backup/BackupInactivePreferenceController.java b/src/com/android/settings/backup/BackupInactivePreferenceController.java
index 92a9487..86e1220 100644
--- a/src/com/android/settings/backup/BackupInactivePreferenceController.java
+++ b/src/com/android/settings/backup/BackupInactivePreferenceController.java
@@ -28,7 +28,7 @@
@Override
public int getAvailabilityStatus() {
- if (!new BackupSettingsHelper(mContext).showBackupSettingsForUser()) {
+ if (!new BackupSettingsHelper(mContext).isBackupServiceActive()) {
return AVAILABLE_UNSEARCHABLE;
}
if (PrivacySettingsUtils.isInvisibleKey(mContext, PrivacySettingsUtils.BACKUP_INACTIVE)) {
diff --git a/src/com/android/settings/backup/BackupSettingsHelper.java b/src/com/android/settings/backup/BackupSettingsHelper.java
index ff4b0b5..1d3455b 100644
--- a/src/com/android/settings/backup/BackupSettingsHelper.java
+++ b/src/com/android/settings/backup/BackupSettingsHelper.java
@@ -50,14 +50,6 @@
mContext = context;
}
- public boolean showBackupSettingsForUser() {
- // For profiles, we want them to be included in the profile select dialog even if
- // backup is not activated.
- // For other users, enable/disable backup settings depending on whether backup is activated
- // for the user.
- return UserManager.get(mContext).isManagedProfile() || isBackupServiceActive();
- }
-
/**
* If there is only one profile, show whether the backup is on or off.
* Otherwise, show nothing.
diff --git a/src/com/android/settings/backup/UserBackupSettingsActivity.java b/src/com/android/settings/backup/UserBackupSettingsActivity.java
index dbbb135..c2bcd07 100644
--- a/src/com/android/settings/backup/UserBackupSettingsActivity.java
+++ b/src/com/android/settings/backup/UserBackupSettingsActivity.java
@@ -123,7 +123,7 @@
@Override
public List<String> getNonIndexableKeys(Context context) {
final List<String> keys = super.getNonIndexableKeys(context);
- if (!new BackupSettingsHelper(context).showBackupSettingsForUser()) {
+ if (!new BackupSettingsHelper(context).isBackupServiceActive()) {
keys.add(BACKUP_SEARCH_INDEX_KEY);
}
return keys;
diff --git a/src/com/android/settings/biometrics/face/FaceSettingsAppPreferenceController.java b/src/com/android/settings/biometrics/face/FaceSettingsAppPreferenceController.java
index 1ffcb4c..70c00e5 100644
--- a/src/com/android/settings/biometrics/face/FaceSettingsAppPreferenceController.java
+++ b/src/com/android/settings/biometrics/face/FaceSettingsAppPreferenceController.java
@@ -22,6 +22,8 @@
import android.hardware.face.FaceManager;
import android.provider.Settings;
+import com.android.settings.Utils;
+
import androidx.preference.Preference;
/**
@@ -40,7 +42,7 @@
public FaceSettingsAppPreferenceController(Context context, String preferenceKey) {
super(context, preferenceKey);
- mFaceManager = context.getSystemService(FaceManager.class);
+ mFaceManager = Utils.getFaceManagerOrNull(context);
}
public FaceSettingsAppPreferenceController(Context context) {
diff --git a/src/com/android/settings/biometrics/face/FaceSettingsConfirmPreferenceController.java b/src/com/android/settings/biometrics/face/FaceSettingsConfirmPreferenceController.java
index 7dbe557..c65cd23 100644
--- a/src/com/android/settings/biometrics/face/FaceSettingsConfirmPreferenceController.java
+++ b/src/com/android/settings/biometrics/face/FaceSettingsConfirmPreferenceController.java
@@ -24,6 +24,7 @@
import androidx.preference.Preference;
+import com.android.settings.Utils;
import com.android.settings.core.TogglePreferenceController;
/**
@@ -46,7 +47,7 @@
public FaceSettingsConfirmPreferenceController(Context context,
String preferenceKey) {
super(context, preferenceKey);
- mFaceManager = context.getSystemService(FaceManager.class);
+ mFaceManager = Utils.getFaceManagerOrNull(context);
}
@Override
diff --git a/src/com/android/settings/biometrics/face/FaceSettingsKeyguardPreferenceController.java b/src/com/android/settings/biometrics/face/FaceSettingsKeyguardPreferenceController.java
index 92eab85..c64455a 100644
--- a/src/com/android/settings/biometrics/face/FaceSettingsKeyguardPreferenceController.java
+++ b/src/com/android/settings/biometrics/face/FaceSettingsKeyguardPreferenceController.java
@@ -26,6 +26,7 @@
import androidx.preference.Preference;
+import com.android.settings.Utils;
import com.android.settings.core.TogglePreferenceController;
/**
@@ -44,7 +45,7 @@
public FaceSettingsKeyguardPreferenceController(Context context, String preferenceKey) {
super(context, preferenceKey);
- mFaceManager = context.getSystemService(FaceManager.class);
+ mFaceManager = Utils.getFaceManagerOrNull(context);
}
public FaceSettingsKeyguardPreferenceController(Context context) {
diff --git a/src/com/android/settings/biometrics/face/FaceSettingsRemoveButtonPreferenceController.java b/src/com/android/settings/biometrics/face/FaceSettingsRemoveButtonPreferenceController.java
index 68ca259..990e68d 100644
--- a/src/com/android/settings/biometrics/face/FaceSettingsRemoveButtonPreferenceController.java
+++ b/src/com/android/settings/biometrics/face/FaceSettingsRemoveButtonPreferenceController.java
@@ -117,6 +117,7 @@
@Override
public void onClick(DialogInterface dialog, int which) {
if (which == DialogInterface.BUTTON_POSITIVE) {
+ mButton.setEnabled(false);
final List<Face> faces = mFaceManager.getEnrolledFaces(mUserId);
if (faces.isEmpty()) {
Log.e(TAG, "No faces");
@@ -177,7 +178,6 @@
public void onClick(View v) {
if (v == mButton) {
mRemoving = true;
- mButton.setEnabled(false);
ConfirmRemoveDialog dialog = new ConfirmRemoveDialog();
dialog.setOnClickListener(mOnClickListener);
dialog.show(mActivity.getSupportFragmentManager(), ConfirmRemoveDialog.class.getName());
diff --git a/src/com/android/settings/core/gateway/SettingsGateway.java b/src/com/android/settings/core/gateway/SettingsGateway.java
index 19843a6..24fccef 100644
--- a/src/com/android/settings/core/gateway/SettingsGateway.java
+++ b/src/com/android/settings/core/gateway/SettingsGateway.java
@@ -300,7 +300,6 @@
// Home page > Network & Internet
Settings.WifiSettingsActivity.class.getName(),
Settings.DataUsageSummaryActivity.class.getName(),
- Settings.SimSettingsActivity.class.getName(),
// Home page > Connected devices
Settings.BluetoothSettingsActivity.class.getName(),
Settings.WifiDisplaySettingsActivity.class.getName(),
diff --git a/src/com/android/settings/datausage/DataUsageSummary.java b/src/com/android/settings/datausage/DataUsageSummary.java
index ad4e1e2..c3ffdae 100644
--- a/src/com/android/settings/datausage/DataUsageSummary.java
+++ b/src/com/android/settings/datausage/DataUsageSummary.java
@@ -50,7 +50,6 @@
/**
* Settings preference fragment that displays data usage summary.
*/
-@SearchIndexable(forTarget = SearchIndexable.ALL & ~SearchIndexable.ARC)
public class DataUsageSummary extends DataUsageBaseFragment implements DataUsageEditController {
private static final String TAG = "DataUsageSummary";
@@ -334,55 +333,4 @@
public static final SummaryLoader.SummaryProviderFactory SUMMARY_PROVIDER_FACTORY
= SummaryProvider::new;
-
- /**
- * For search
- */
- public static final Indexable.SearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
- new BaseSearchIndexProvider() {
-
- @Override
- public List<SearchIndexableResource> getXmlResourcesToIndex(Context context,
- boolean enabled) {
- List<SearchIndexableResource> resources = new ArrayList<>();
- SearchIndexableResource resource = new SearchIndexableResource(context);
- resource.xmlResId = R.xml.data_usage;
- resources.add(resource);
-
- resource = new SearchIndexableResource(context);
- resource.xmlResId = R.xml.data_usage_cellular;
- resources.add(resource);
-
- resource = new SearchIndexableResource(context);
- resource.xmlResId = R.xml.data_usage_wifi;
- resources.add(resource);
-
- return resources;
- }
-
- @Override
- public List<String> getNonIndexableKeys(Context context) {
- List<String> keys = super.getNonIndexableKeys(context);
-
- if (!DataUsageUtils.hasMobileData(context)) {
- keys.add(KEY_MOBILE_USAGE_TITLE);
- keys.add(KEY_MOBILE_DATA_USAGE_TOGGLE);
- keys.add(KEY_MOBILE_DATA_USAGE);
- }
-
- if (!DataUsageUtils.hasWifiRadio(context)) {
- keys.add(KEY_WIFI_DATA_USAGE);
- }
-
- // This title is named Wifi, and will confuse users.
- keys.add(KEY_WIFI_USAGE_TITLE);
-
- // Duplicate entry for "Data saver"
- keys.add(KEY_RESTRICT_BACKGROUND);
- // Duplicate entry for "Data warning & limit"
- keys.add(KEY_MOBILE_BILLING_CYCLE);
-
- return keys;
- }
- };
}
diff --git a/src/com/android/settings/deviceinfo/imei/ImeiInfoDialogController.java b/src/com/android/settings/deviceinfo/imei/ImeiInfoDialogController.java
index 33d7a8a..4b2f50d 100644
--- a/src/com/android/settings/deviceinfo/imei/ImeiInfoDialogController.java
+++ b/src/com/android/settings/deviceinfo/imei/ImeiInfoDialogController.java
@@ -26,6 +26,7 @@
import android.text.Spanned;
import android.text.TextUtils;
import android.text.style.TtsSpan;
+import android.util.Log;
import androidx.annotation.NonNull;
import androidx.annotation.VisibleForTesting;
@@ -33,10 +34,10 @@
import com.android.internal.telephony.PhoneConstants;
import com.android.settings.R;
-import java.util.List;
-
public class ImeiInfoDialogController {
+ private static final String TAG = "ImeiInfoDialog";
+
@VisibleForTesting
static final int ID_PRL_VERSION_VALUE = R.id.prl_version_value;
private static final int ID_MIN_NUMBER_LABEL = R.id.min_number_label;
@@ -75,15 +76,24 @@
mDialog = dialog;
mSlotId = slotId;
final Context context = dialog.getContext();
- mTelephonyManager = (TelephonyManager) context.getSystemService(
- Context.TELEPHONY_SERVICE);
- mSubscriptionInfo = getSubscriptionInfo(context, slotId);
+ mSubscriptionInfo = context.getSystemService(SubscriptionManager.class)
+ .getActiveSubscriptionInfoForSimSlotIndex(slotId);
+ if (mSubscriptionInfo != null) {
+ mTelephonyManager = context.getSystemService(TelephonyManager.class)
+ .createForSubscriptionId(mSubscriptionInfo.getSubscriptionId());
+ } else {
+ mTelephonyManager = null;
+ }
}
/**
* Sets IMEI/MEID information based on whether the device is CDMA or GSM.
*/
public void populateImeiInfo() {
+ if (mTelephonyManager == null) {
+ Log.w(TAG, "TelephonyManager for this slot is null. Invalid slot? id=" + mSlotId);
+ return;
+ }
if (mTelephonyManager.getPhoneType() == TelephonyManager.PHONE_TYPE_CDMA) {
updateDialogForCdmaPhone();
} else {
@@ -94,9 +104,9 @@
private void updateDialogForCdmaPhone() {
final Resources res = mDialog.getContext().getResources();
mDialog.setText(ID_MEID_NUMBER_VALUE, getMeid());
- mDialog.setText(ID_MIN_NUMBER_VALUE,
- mSubscriptionInfo != null ? mTelephonyManager.getCdmaMin(
- mSubscriptionInfo.getSubscriptionId()) : "");
+ mDialog.setText(ID_MIN_NUMBER_VALUE, mSubscriptionInfo != null
+ ? mTelephonyManager.getCdmaMin(mSubscriptionInfo.getSubscriptionId())
+ : "");
if (res.getBoolean(R.bool.config_msid_enable)) {
mDialog.setText(ID_MIN_NUMBER_LABEL,
@@ -125,16 +135,6 @@
mDialog.removeViewFromScreen(ID_CDMA_SETTINGS);
}
- private SubscriptionInfo getSubscriptionInfo(Context context, int slotId) {
- final List<SubscriptionInfo> subscriptionInfoList = SubscriptionManager.from(context)
- .getActiveSubscriptionInfoList(true);
- if (subscriptionInfoList == null || subscriptionInfoList.isEmpty()) {
- return null;
- }
-
- return subscriptionInfoList.get(slotId);
- }
-
@VisibleForTesting
String getCdmaPrlVersion() {
return mTelephonyManager.getCdmaPrlVersion();
diff --git a/src/com/android/settings/deviceinfo/imei/ImeiInfoPreferenceController.java b/src/com/android/settings/deviceinfo/imei/ImeiInfoPreferenceController.java
index 68c9588..3459b5c 100644
--- a/src/com/android/settings/deviceinfo/imei/ImeiInfoPreferenceController.java
+++ b/src/com/android/settings/deviceinfo/imei/ImeiInfoPreferenceController.java
@@ -20,6 +20,8 @@
import android.content.Context;
import android.os.UserManager;
+import android.telephony.SubscriptionInfo;
+import android.telephony.SubscriptionManager;
import android.telephony.TelephonyManager;
import androidx.annotation.VisibleForTesting;
@@ -77,10 +79,26 @@
}
@Override
+ public void updateState(Preference preference) {
+ if (preference == null) {
+ return;
+ }
+ int size = mPreferenceList.size();
+ for (int i = 0; i < size; i++) {
+ Preference pref = mPreferenceList.get(i);
+ updatePreference(pref, i);
+ }
+ }
+
+ @Override
public CharSequence getSummary() {
- final int phoneType = mTelephonyManager.getPhoneType();
- return phoneType == PHONE_TYPE_CDMA ? mTelephonyManager.getMeid()
- : mTelephonyManager.getImei();
+ return getSummary(0);
+ }
+
+ private CharSequence getSummary(int simSlot) {
+ final int phoneType = getPhoneType(simSlot);
+ return phoneType == PHONE_TYPE_CDMA ? mTelephonyManager.getMeid(simSlot)
+ : mTelephonyManager.getImei(simSlot);
}
@Override
@@ -117,19 +135,12 @@
@Override
public void copy() {
- Sliceable.setCopyContent(mContext, getSummary(), mContext.getText(R.string.status_imei));
+ Sliceable.setCopyContent(mContext, getSummary(0), getTitle(0));
}
private void updatePreference(Preference preference, int simSlot) {
- final int phoneType = mTelephonyManager.getPhoneType();
- if (phoneType == PHONE_TYPE_CDMA) {
- preference.setTitle(getTitleForCdmaPhone(simSlot));
- preference.setSummary(getMeid(simSlot));
- } else {
- // GSM phone
- preference.setTitle(getTitleForGsmPhone(simSlot));
- preference.setSummary(mTelephonyManager.getImei(simSlot));
- }
+ preference.setTitle(getTitle(simSlot));
+ preference.setSummary(getSummary(simSlot));
}
private CharSequence getTitleForGsmPhone(int simSlot) {
@@ -142,9 +153,17 @@
: mContext.getString(R.string.status_meid_number);
}
- @VisibleForTesting
- String getMeid(int simSlot) {
- return mTelephonyManager.getMeid(simSlot);
+ private CharSequence getTitle(int simSlot) {
+ final int phoneType = getPhoneType(simSlot);
+ return phoneType == PHONE_TYPE_CDMA ? getTitleForCdmaPhone(simSlot)
+ : getTitleForGsmPhone(simSlot);
+ }
+
+ private int getPhoneType(int slotIndex) {
+ SubscriptionInfo subInfo = SubscriptionManager.from(mContext)
+ .getActiveSubscriptionInfoForSimSlotIndex(slotIndex);
+ return mTelephonyManager.getCurrentPhoneType(subInfo != null ? subInfo.getSubscriptionId()
+ : SubscriptionManager.DEFAULT_SUBSCRIPTION_ID);
}
@VisibleForTesting
diff --git a/src/com/android/settings/display/DarkUIInfoDialogFragment.java b/src/com/android/settings/display/DarkUIInfoDialogFragment.java
index 8fca679..7e17480 100644
--- a/src/com/android/settings/display/DarkUIInfoDialogFragment.java
+++ b/src/com/android/settings/display/DarkUIInfoDialogFragment.java
@@ -16,9 +16,6 @@
package com.android.settings.display;
-import static com.android.settings.display.DarkUIPreferenceController.DARK_MODE_PREFS;
-import static com.android.settings.display.DarkUIPreferenceController.PREF_DARK_MODE_DIALOG_SEEN;
-
import android.app.Dialog;
import android.app.UiModeManager;
import android.content.Context;
diff --git a/src/com/android/settings/fuelgauge/BatteryInfo.java b/src/com/android/settings/fuelgauge/BatteryInfo.java
index 33f2553..34a8b91 100644
--- a/src/com/android/settings/fuelgauge/BatteryInfo.java
+++ b/src/com/android/settings/fuelgauge/BatteryInfo.java
@@ -193,6 +193,7 @@
&& provider.isEnhancedBatteryPredictionEnabled(context)) {
Estimate estimate = provider.getEnhancedBatteryPrediction(context);
if (estimate != null) {
+ Estimate.storeCachedEstimate(context, estimate);
BatteryUtils
.logRuntime(LOG_TAG, "time for enhanced BatteryInfo", startTime);
return BatteryInfo.getBatteryInfo(context, batteryBroadcast, stats,
diff --git a/src/com/android/settings/fuelgauge/BatteryMeterView.java b/src/com/android/settings/fuelgauge/BatteryMeterView.java
index 27923ef..dc30c28 100644
--- a/src/com/android/settings/fuelgauge/BatteryMeterView.java
+++ b/src/com/android/settings/fuelgauge/BatteryMeterView.java
@@ -18,7 +18,6 @@
import android.annotation.Nullable;
import android.content.Context;
-import android.graphics.Color;
import android.graphics.ColorFilter;
import android.graphics.PorterDuff;
import android.graphics.PorterDuffColorFilter;
@@ -38,7 +37,8 @@
ColorFilter mErrorColorFilter;
@VisibleForTesting
ColorFilter mAccentColorFilter;
- private boolean mPowerSaveEnabled;
+ @VisibleForTesting
+ ColorFilter mForegroundColorFilter;
public BatteryMeterView(Context context) {
this(context, null, 0);
@@ -57,7 +57,9 @@
PorterDuff.Mode.SRC);
mErrorColorFilter = new PorterDuffColorFilter(
context.getColor(R.color.battery_icon_color_error), PorterDuff.Mode.SRC_IN);
-
+ mForegroundColorFilter =new PorterDuffColorFilter(
+ Utils.getColorAttrDefaultColor(context, android.R.attr.colorForeground),
+ PorterDuff.Mode.SRC);
mDrawable = new BatteryMeterDrawable(context, frameColor);
mDrawable.setColorFilter(mAccentColorFilter);
setImageDrawable(mDrawable);
@@ -65,20 +67,16 @@
public void setBatteryLevel(int level) {
mDrawable.setBatteryLevel(level);
- if (level < mDrawable.getCriticalLevel()) {
- mDrawable.setColorFilter(mErrorColorFilter);
- } else {
- mDrawable.setColorFilter(mAccentColorFilter);
- }
+ updateColorFilter();
}
public void setPowerSave(boolean powerSave) {
mDrawable.setPowerSaveEnabled(powerSave);
- mPowerSaveEnabled = powerSave;
+ updateColorFilter();
}
public boolean getPowerSave() {
- return mPowerSaveEnabled;
+ return mDrawable.getPowerSaveEnabled();
}
public int getBatteryLevel() {
@@ -94,6 +92,18 @@
return mDrawable.getCharging();
}
+ private void updateColorFilter() {
+ final boolean powerSaveEnabled = mDrawable.getPowerSaveEnabled();
+ final int level = mDrawable.getBatteryLevel();
+ if (powerSaveEnabled) {
+ mDrawable.setColorFilter(mForegroundColorFilter);
+ } else if (level < mDrawable.getCriticalLevel()) {
+ mDrawable.setColorFilter(mErrorColorFilter);
+ } else {
+ mDrawable.setColorFilter(mAccentColorFilter);
+ }
+ }
+
public static class BatteryMeterDrawable extends ThemedBatteryDrawable {
private final int mIntrinsicWidth;
private final int mIntrinsicHeight;
diff --git a/src/com/android/settings/fuelgauge/BatteryUtils.java b/src/com/android/settings/fuelgauge/BatteryUtils.java
index cb22356..b293695 100644
--- a/src/com/android/settings/fuelgauge/BatteryUtils.java
+++ b/src/com/android/settings/fuelgauge/BatteryUtils.java
@@ -450,7 +450,6 @@
SystemClock.elapsedRealtime());
final BatteryStats stats = statsHelper.getStats();
BatteryInfo batteryInfo;
-
Estimate estimate = null;
// Get enhanced prediction if available
if (mPowerUsageFeatureProvider != null &&
@@ -458,7 +457,9 @@
estimate = mPowerUsageFeatureProvider.getEnhancedBatteryPrediction(mContext);
}
- if (estimate == null) {
+ if (estimate != null) {
+ Estimate.storeCachedEstimate(mContext, estimate);
+ } else {
estimate = new Estimate(
PowerUtil.convertUsToMs(stats.computeBatteryTimeRemaining(elapsedRealtimeUs)),
false /* isBasedOnUsage */,
diff --git a/src/com/android/settings/fuelgauge/PowerUsageSummary.java b/src/com/android/settings/fuelgauge/PowerUsageSummary.java
index 82ff4c2..78391f2 100644
--- a/src/com/android/settings/fuelgauge/PowerUsageSummary.java
+++ b/src/com/android/settings/fuelgauge/PowerUsageSummary.java
@@ -20,9 +20,14 @@
import android.app.settings.SettingsEnums;
import android.content.Context;
+import android.database.ContentObserver;
+import android.net.Uri;
import android.os.BatteryStats;
import android.os.Bundle;
+import android.os.Handler;
import android.provider.SearchIndexableResource;
+import android.provider.Settings;
+import android.provider.Settings.Global;
import android.text.format.Formatter;
import android.view.Menu;
import android.view.MenuInflater;
@@ -102,6 +107,13 @@
BatteryTipPreferenceController mBatteryTipPreferenceController;
private int mStatsType = BatteryStats.STATS_SINCE_CHARGED;
+ private final ContentObserver mSettingsObserver = new ContentObserver(new Handler()) {
+ @Override
+ public void onChange(boolean selfChange, Uri uri) {
+ restartBatteryInfoLoader();
+ }
+ };
+
@VisibleForTesting
LoaderManager.LoaderCallbacks<BatteryInfo> mBatteryInfoLoaderCallbacks =
new LoaderManager.LoaderCallbacks<BatteryInfo>() {
@@ -190,6 +202,21 @@
};
@Override
+ public void onStop() {
+ getContentResolver().unregisterContentObserver(mSettingsObserver);
+ super.onStop();
+ }
+
+ @Override
+ public void onResume() {
+ super.onResume();
+ getContentResolver().registerContentObserver(
+ Global.getUriFor(Global.BATTERY_ESTIMATES_LAST_UPDATE_TIME),
+ false,
+ mSettingsObserver);
+ }
+
+ @Override
public void onAttach(Context context) {
super.onAttach(context);
final SettingsActivity activity = (SettingsActivity) getActivity();
diff --git a/src/com/android/settings/homepage/contextualcards/slices/NotificationChannelSlice.java b/src/com/android/settings/homepage/contextualcards/slices/NotificationChannelSlice.java
index 07fc899..a262191 100644
--- a/src/com/android/settings/homepage/contextualcards/slices/NotificationChannelSlice.java
+++ b/src/com/android/settings/homepage/contextualcards/slices/NotificationChannelSlice.java
@@ -66,7 +66,12 @@
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;
+import java.util.concurrent.TimeoutException;
import java.util.stream.Collectors;
public class NotificationChannelSlice implements CustomSliceable {
@@ -98,6 +103,7 @@
private static final String PACKAGE_NAME = "package_name";
private static final String PACKAGE_UID = "package_uid";
private static final String CHANNEL_ID = "channel_id";
+ private static final long TASK_TIMEOUT_MS = 100;
/**
* Sort notification channel with weekly average sent count by descending.
@@ -129,6 +135,7 @@
};
protected final Context mContext;
+ private final ExecutorService mExecutorService;
@VisibleForTesting
NotificationBackend mNotificationBackend;
private NotificationBackend.AppRow mAppRow;
@@ -138,6 +145,7 @@
public NotificationChannelSlice(Context context) {
mContext = context;
mNotificationBackend = new NotificationBackend();
+ mExecutorService = Executors.newCachedThreadPool();
}
@Override
@@ -151,10 +159,7 @@
* 2. Multiple channels.
* 3. Sent at least ~10 notifications.
*/
- // TODO(b/123065955): Review latency of NotificationChannelSlice
- final List<PackageInfo> multiChannelPackages = getMultiChannelPackages(
- getRecentlyInstalledPackages());
- mPackageName = getMaxSentNotificationsPackage(multiChannelPackages);
+ mPackageName = getEligibleNotificationsPackage(getRecentlyInstalledPackages());
if (mPackageName == null) {
// Return a header with IsError flag, if package is not found.
return listBuilder.setHeader(getNoSuggestedAppHeader())
@@ -306,25 +311,6 @@
return PendingIntent.getBroadcast(mContext, intent.hashCode(), intent, 0);
}
- private List<PackageInfo> getMultiChannelPackages(List<PackageInfo> packageInfoList) {
- final List<PackageInfo> multiChannelPackages = new ArrayList<>();
-
- if (packageInfoList.isEmpty()) {
- return multiChannelPackages;
- }
-
- for (PackageInfo packageInfo : packageInfoList) {
- final int channelCount = mNotificationBackend.getChannelCount(packageInfo.packageName,
- getApplicationUid(packageInfo.packageName));
- if (channelCount > 1) {
- multiChannelPackages.add(packageInfo);
- }
- }
-
- // TODO(b/119831690): Filter the packages which doesn't have any configurable channel.
- return multiChannelPackages;
- }
-
private List<PackageInfo> getRecentlyInstalledPackages() {
final long startTime = System.currentTimeMillis() - DURATION_START_DAYS;
final long endTime = System.currentTimeMillis() - DURATION_END_DAYS;
@@ -383,19 +369,33 @@
.collect(Collectors.toList());
}
- private String getMaxSentNotificationsPackage(List<PackageInfo> packageInfoList) {
+ private String getEligibleNotificationsPackage(List<PackageInfo> packageInfoList) {
if (packageInfoList.isEmpty()) {
return null;
}
+ // Create tasks to get notification data for multi-channel packages.
+ final List<Future<NotificationBackend.AppRow>> appRowTasks = new ArrayList<>();
+ for (PackageInfo packageInfo : packageInfoList) {
+ final NotificationMultiChannelAppRow future = new NotificationMultiChannelAppRow(
+ mContext, mNotificationBackend, packageInfo);
+ appRowTasks.add(mExecutorService.submit(future));
+ }
+
// Get the package which has sent at least ~10 notifications and not turn off channels.
int maxSentCount = 0;
String maxSentCountPackage = null;
- for (PackageInfo packageInfo : packageInfoList) {
- final NotificationBackend.AppRow appRow = mNotificationBackend.loadAppRow(mContext,
- mContext.getPackageManager(), packageInfo);
+ for (Future<NotificationBackend.AppRow> appRowTask : appRowTasks) {
+ NotificationBackend.AppRow appRow = null;
+ try {
+ appRow = appRowTask.get(TASK_TIMEOUT_MS, TimeUnit.MILLISECONDS);
+ } catch (ExecutionException | InterruptedException | TimeoutException e) {
+ Log.w(TAG, "Failed to get notification data.", e);
+ }
+
// Ignore packages which are banned notifications or block all displayable channels.
- if (appRow.banned || isAllChannelsBlocked(getDisplayableChannels(appRow))) {
+ if (appRow == null || appRow.banned || isAllChannelsBlocked(
+ getDisplayableChannels(appRow))) {
continue;
}
@@ -403,7 +403,7 @@
final int sentCount = appRow.sentByApp.sentCount;
if (sentCount >= MIN_NOTIFICATION_SENT_COUNT && sentCount > maxSentCount) {
maxSentCount = sentCount;
- maxSentCountPackage = packageInfo.packageName;
+ maxSentCountPackage = appRow.pkg;
mAppRow = appRow;
}
}
diff --git a/src/com/android/settings/homepage/contextualcards/slices/NotificationMultiChannelAppRow.java b/src/com/android/settings/homepage/contextualcards/slices/NotificationMultiChannelAppRow.java
new file mode 100644
index 0000000..4edce14
--- /dev/null
+++ b/src/com/android/settings/homepage/contextualcards/slices/NotificationMultiChannelAppRow.java
@@ -0,0 +1,53 @@
+/*
+ * Copyright (C) 2019 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License
+ */
+
+package com.android.settings.homepage.contextualcards.slices;
+
+import android.content.Context;
+import android.content.pm.PackageInfo;
+
+import com.android.settings.notification.NotificationBackend;
+
+import java.util.concurrent.Callable;
+
+/**
+ * This class is responsible for getting notification app row from package which has multiple
+ * notification channels.{@link NotificationChannelSlice} uses it to improve latency.
+ */
+class NotificationMultiChannelAppRow implements Callable<NotificationBackend.AppRow> {
+
+ private final Context mContext;
+ private final NotificationBackend mNotificationBackend;
+ private final PackageInfo mPackageInfo;
+
+ public NotificationMultiChannelAppRow(Context context, NotificationBackend notificationBackend,
+ PackageInfo packageInfo) {
+ mContext = context;
+ mNotificationBackend = notificationBackend;
+ mPackageInfo = packageInfo;
+ }
+
+ @Override
+ public NotificationBackend.AppRow call() throws Exception {
+ final int channelCount = mNotificationBackend.getChannelCount(
+ mPackageInfo.applicationInfo.packageName, mPackageInfo.applicationInfo.uid);
+ if (channelCount > 1) {
+ return mNotificationBackend.loadAppRow(mContext, mContext.getPackageManager(),
+ mPackageInfo);
+ }
+ return null;
+ }
+}
diff --git a/src/com/android/settings/location/RecentLocationAccessPreferenceController.java b/src/com/android/settings/location/RecentLocationAccessPreferenceController.java
index f44e107..c835a51 100644
--- a/src/com/android/settings/location/RecentLocationAccessPreferenceController.java
+++ b/src/com/android/settings/location/RecentLocationAccessPreferenceController.java
@@ -18,6 +18,7 @@
import android.Manifest;
import android.content.Context;
import android.content.Intent;
+import android.icu.text.RelativeDateTimeFormatter;
import android.provider.DeviceConfig;
import android.view.View;
@@ -30,6 +31,7 @@
import com.android.settings.core.PreferenceControllerMixin;
import com.android.settingslib.core.AbstractPreferenceController;
import com.android.settingslib.location.RecentLocationAccesses;
+import com.android.settingslib.utils.StringUtil;
import com.android.settingslib.widget.AppEntitiesHeaderController;
import com.android.settingslib.widget.AppEntityInfo;
import com.android.settingslib.widget.LayoutPreference;
@@ -101,7 +103,9 @@
final AppEntityInfo appEntityInfo = new AppEntityInfo.Builder()
.setIcon(access.icon)
.setTitle(access.label)
- .setSummary(access.contentDescription)
+ .setSummary(StringUtil.formatRelativeTime(mContext,
+ System.currentTimeMillis() - access.accessFinishTime, false,
+ RelativeDateTimeFormatter.Style.SHORT))
.setOnClickListener((v) -> {
final Intent intent = new Intent(Intent.ACTION_MANAGE_APP_PERMISSION);
intent.putExtra(Intent.EXTRA_PERMISSION_NAME,
diff --git a/src/com/android/settings/media/MediaOutputSlice.java b/src/com/android/settings/media/MediaOutputSlice.java
index 30551a9..dee5d62 100644
--- a/src/com/android/settings/media/MediaOutputSlice.java
+++ b/src/com/android/settings/media/MediaOutputSlice.java
@@ -70,21 +70,27 @@
@Override
public Slice getSlice() {
+ // Reload theme for switching dark mode on/off
+ mContext.getTheme().applyStyle(R.style.Theme_Settings_Home, true /* force */);
+
+ final ListBuilder listBuilder = new ListBuilder(mContext, getUri(), ListBuilder.INFINITY)
+ .setAccentColor(COLOR_NOT_TINTED);
+
final BluetoothAdapter adapter = BluetoothAdapter.getDefaultAdapter();
if (!adapter.isEnabled()) {
Log.d(TAG, "getSlice() Bluetooth is off");
- return null;
+ return listBuilder.build();
}
if (getWorker() == null) {
Log.d(TAG, "getSlice() Can not get worker through uri!");
- return null;
+ return listBuilder.build();
}
final List<MediaDevice> devices = getMediaDevices();
final MediaDevice connectedDevice = getWorker().getCurrentConnectedMediaDevice();
- final ListBuilder listBuilder = buildActiveDeviceHeader(connectedDevice);
+ listBuilder.addRow(getActiveDeviceHeaderRow(connectedDevice));
for (MediaDevice device : devices) {
if (!TextUtils.equals(connectedDevice.getId(), device.getId())) {
@@ -95,7 +101,7 @@
return listBuilder.build();
}
- private ListBuilder buildActiveDeviceHeader(MediaDevice device) {
+ private ListBuilder.RowBuilder getActiveDeviceHeaderRow(MediaDevice device) {
final String title = device.getName();
final IconCompat icon = getDeviceIconCompat(device);
@@ -104,16 +110,13 @@
final SliceAction primarySliceAction = SliceAction.createDeeplink(broadcastAction, icon,
ListBuilder.ICON_IMAGE, title);
- final ListBuilder listBuilder = new ListBuilder(mContext, MEDIA_OUTPUT_SLICE_URI,
- ListBuilder.INFINITY)
- .setAccentColor(COLOR_NOT_TINTED)
- .addRow(new ListBuilder.RowBuilder()
- .setTitleItem(icon, ListBuilder.ICON_IMAGE)
- .setTitle(title)
- .setSubtitle(device.getSummary())
- .setPrimaryAction(primarySliceAction));
+ final ListBuilder.RowBuilder rowBuilder = new ListBuilder.RowBuilder()
+ .setTitleItem(icon, ListBuilder.ICON_IMAGE)
+ .setTitle(title)
+ .setSubtitle(device.getSummary())
+ .setPrimaryAction(primarySliceAction);
- return listBuilder;
+ return rowBuilder;
}
private IconCompat getDeviceIconCompat(MediaDevice device) {
diff --git a/src/com/android/settings/network/SubscriptionUtil.java b/src/com/android/settings/network/SubscriptionUtil.java
index 86655d4..e700329 100644
--- a/src/com/android/settings/network/SubscriptionUtil.java
+++ b/src/com/android/settings/network/SubscriptionUtil.java
@@ -101,16 +101,6 @@
}
}
}
-
- // With some carriers such as Google Fi which provide a sort of virtual service that spans
- // across multiple underlying networks, we end up with subscription entries for the
- // underlying networks that need to be hidden from the user in the UI.
- for (Iterator<SubscriptionInfo> iter = subscriptions.iterator(); iter.hasNext(); ) {
- SubscriptionInfo info = iter.next();
- if (TextUtils.isEmpty(info.getMncString())) {
- iter.remove();
- }
- }
return subscriptions;
}
}
diff --git a/src/com/android/settings/network/telephony/RenameMobileNetworkDialogFragment.java b/src/com/android/settings/network/telephony/RenameMobileNetworkDialogFragment.java
index 7a131d7..f7e7de5 100644
--- a/src/com/android/settings/network/telephony/RenameMobileNetworkDialogFragment.java
+++ b/src/com/android/settings/network/telephony/RenameMobileNetworkDialogFragment.java
@@ -109,7 +109,7 @@
@VisibleForTesting
protected void populateView(View view) {
- mNameView = (EditText) view.findViewById(R.id.edittext);
+ mNameView = view.findViewById(R.id.edittext);
final SubscriptionInfo info = mSubscriptionManager.getActiveSubscriptionInfo(mSubId);
if (info == null) {
Log.w(TAG, "got null SubscriptionInfo for mSubId:" + mSubId);
@@ -125,6 +125,9 @@
final ServiceState serviceState = mTelephonyManager.getServiceStateForSubscriber(mSubId);
operatorName.setText(serviceState.getOperatorAlphaLong());
+ final TextView phoneTitle = view.findViewById(R.id.number_label);
+ phoneTitle.setVisibility(info.isOpportunistic() ? View.GONE : View.VISIBLE);
+
final TextView phoneNumber = view.findViewById(R.id.number_value);
final String formattedNumber = DeviceInfoUtils.getFormattedPhoneNumber(getContext(), info);
phoneNumber.setText(BidiFormatter.getInstance().unicodeWrap(formattedNumber,
diff --git a/src/com/android/settings/notification/RecentNotifyingAppsPreferenceController.java b/src/com/android/settings/notification/RecentNotifyingAppsPreferenceController.java
index 1ec3c4f..8122df7 100644
--- a/src/com/android/settings/notification/RecentNotifyingAppsPreferenceController.java
+++ b/src/com/android/settings/notification/RecentNotifyingAppsPreferenceController.java
@@ -214,7 +214,7 @@
.setSourceMetricsCategory(
SettingsEnums.MANAGE_APPLICATIONS_NOTIFICATIONS)
.toIntent());
- pref.setEnabled(mNotificationBackend.isBlockable(mContext, appEntry.info));
+ pref.setSwitchEnabled(mNotificationBackend.isBlockable(mContext, appEntry.info));
pref.setOnPreferenceChangeListener((preference, newValue) -> {
boolean blocked = !(Boolean) newValue;
mNotificationBackend.setNotificationsEnabledForPackage(
diff --git a/src/com/android/settings/sim/SimDialogActivity.java b/src/com/android/settings/sim/SimDialogActivity.java
index d721efd..05bb0b2 100644
--- a/src/com/android/settings/sim/SimDialogActivity.java
+++ b/src/com/android/settings/sim/SimDialogActivity.java
@@ -78,23 +78,24 @@
}
private SimDialogFragment createFragment(int dialogType) {
- switch(dialogType) {
+ switch (dialogType) {
case DATA_PICK:
return SimListDialogFragment.newInstance(dialogType, R.string.select_sim_for_data,
false /* includeAskEveryTime */);
case CALLS_PICK:
- return CallsSimListDialogFragment.newInstance(dialogType, R.string.select_sim_for_calls,
+ return CallsSimListDialogFragment.newInstance(dialogType,
+ R.string.select_sim_for_calls,
true /* includeAskEveryTime */);
case SMS_PICK:
return SimListDialogFragment.newInstance(dialogType, R.string.select_sim_for_sms,
- false /* includeAskEveryTime */);
+ true /* includeAskEveryTime */);
case PREFERRED_PICK:
if (!getIntent().hasExtra(PREFERRED_SIM)) {
throw new IllegalArgumentException("Missing required extra " + PREFERRED_SIM);
}
return PreferredSimDialogFragment.newInstance();
default:
- throw new IllegalArgumentException( "Invalid dialog type " + dialogType + " sent.");
+ throw new IllegalArgumentException("Invalid dialog type " + dialogType + " sent.");
}
}
diff --git a/tests/robotests/assets/grandfather_not_implementing_index_provider b/tests/robotests/assets/grandfather_not_implementing_index_provider
index d7e5585..b950f30 100644
--- a/tests/robotests/assets/grandfather_not_implementing_index_provider
+++ b/tests/robotests/assets/grandfather_not_implementing_index_provider
@@ -28,6 +28,7 @@
com.android.settings.bluetooth.DevicePickerFragment
com.android.settings.datausage.AppDataUsage
com.android.settings.datausage.DataUsageList
+com.android.settings.datausage.DataUsageSummary
com.android.settings.datetime.timezone.TimeZoneSettings
com.android.settings.deviceinfo.PrivateVolumeSettings
com.android.settings.deviceinfo.PublicVolumeSettings
diff --git a/tests/robotests/src/com/android/settings/backup/BackupInactivePreferenceControllerTest.java b/tests/robotests/src/com/android/settings/backup/BackupInactivePreferenceControllerTest.java
index 669aabb..e9c0469 100644
--- a/tests/robotests/src/com/android/settings/backup/BackupInactivePreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/backup/BackupInactivePreferenceControllerTest.java
@@ -54,18 +54,18 @@
}
@Test
- public void getAvailabilityStatus_isnotInvisibleKey_showBackup_shouldBeAvailable() {
+ public void getAvailabilityStatus_isnotInvisibleKey_backupActive_shouldBeAvailable() {
ShadowPrivacySettingsUtils.setIsInvisibleKey(false);
- ShadowBackupSettingsHelper.showBackupSettingsForUser = true;
+ ShadowBackupSettingsHelper.isBackupServiceActive = true;
assertThat(mController.getAvailabilityStatus())
.isEqualTo(BasePreferenceController.AVAILABLE);
}
@Test
- public void getAvailabilityStatus_isnotInvisibleKey_dontShowBackup_shouldBeUnsearchable() {
+ public void getAvailabilityStatus_isnotInvisibleKey_backupNotActive_shouldBeUnsearchable() {
ShadowPrivacySettingsUtils.setIsInvisibleKey(false);
- ShadowBackupSettingsHelper.showBackupSettingsForUser = false;
+ ShadowBackupSettingsHelper.isBackupServiceActive = false;
assertThat(mController.getAvailabilityStatus())
.isEqualTo(BasePreferenceController.AVAILABLE_UNSEARCHABLE);
@@ -74,7 +74,7 @@
@Test
public void getAvailabilityStatus_isInvisibleKey_shouldBeDisabledUnsupported() {
ShadowPrivacySettingsUtils.setIsInvisibleKey(true);
- ShadowBackupSettingsHelper.showBackupSettingsForUser = true;
+ ShadowBackupSettingsHelper.isBackupServiceActive = true;
assertThat(mController.getAvailabilityStatus())
.isEqualTo(BasePreferenceController.UNSUPPORTED_ON_DEVICE);
diff --git a/tests/robotests/src/com/android/settings/backup/UserBackupSettingsActivityTest.java b/tests/robotests/src/com/android/settings/backup/UserBackupSettingsActivityTest.java
index 9c5a11a..7e703a6 100644
--- a/tests/robotests/src/com/android/settings/backup/UserBackupSettingsActivityTest.java
+++ b/tests/robotests/src/com/android/settings/backup/UserBackupSettingsActivityTest.java
@@ -123,8 +123,8 @@
}
@Test
- public void getNonIndexableKeys_whenShowBackupSettings() {
- ShadowBackupSettingsHelper.showBackupSettingsForUser = true;
+ public void getNonIndexableKeys_whenBackupServiceActive() {
+ ShadowBackupSettingsHelper.isBackupServiceActive = true;
assertThat(UserBackupSettingsActivity.SEARCH_INDEX_DATA_PROVIDER.getRawDataToIndex(
mApplication, true)).isNotEmpty();
@@ -133,8 +133,8 @@
}
@Test
- public void getNonIndexableKeys_whenDontShowBackupSettings() {
- ShadowBackupSettingsHelper.showBackupSettingsForUser = false;
+ public void getNonIndexableKeys_whenBackupServiceNotActive() {
+ ShadowBackupSettingsHelper.isBackupServiceActive = false;
assertThat(UserBackupSettingsActivity.SEARCH_INDEX_DATA_PROVIDER.getRawDataToIndex(
mApplication, true)).isNotEmpty();
@@ -144,11 +144,11 @@
@Implements(BackupSettingsHelper.class)
public static class ShadowBackupSettingsHelper {
- static boolean showBackupSettingsForUser = true;
+ static boolean isBackupServiceActive = true;
@Implementation
- public boolean showBackupSettingsForUser() {
- return showBackupSettingsForUser;
+ public boolean isBackupServiceActive() {
+ return isBackupServiceActive;
}
@Implementation
@@ -163,7 +163,7 @@
@Resetter
public static void reset() {
- showBackupSettingsForUser = true;
+ isBackupServiceActive = true;
}
}
}
diff --git a/tests/robotests/src/com/android/settings/deviceinfo/imei/ImeiInfoDialogControllerTest.java b/tests/robotests/src/com/android/settings/deviceinfo/imei/ImeiInfoDialogControllerTest.java
index a19f022..f38668c 100644
--- a/tests/robotests/src/com/android/settings/deviceinfo/imei/ImeiInfoDialogControllerTest.java
+++ b/tests/robotests/src/com/android/settings/deviceinfo/imei/ImeiInfoDialogControllerTest.java
@@ -28,12 +28,14 @@
import static org.mockito.ArgumentMatchers.anyInt;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.eq;
+import static org.mockito.Mockito.never;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import android.content.Context;
import android.telephony.SubscriptionInfo;
+import android.telephony.SubscriptionManager;
import android.telephony.TelephonyManager;
import org.junit.Before;
@@ -43,6 +45,9 @@
import org.mockito.MockitoAnnotations;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.RuntimeEnvironment;
+import org.robolectric.shadow.api.Shadow;
+import org.robolectric.shadows.ShadowSubscriptionManager;
+import org.robolectric.shadows.ShadowTelephonyManager;
import org.robolectric.util.ReflectionHelpers;
@RunWith(RobolectricTestRunner.class)
@@ -53,6 +58,8 @@
private static final String IMEI_NUMBER = "2341982751254";
private static final String MIN_NUMBER = "123417851315";
private static final String IMEI_SV_NUMBER = "12";
+ private static final int SLOT_ID = 0;
+ private static final int SUB_ID = 0;
@Mock
private ImeiInfoDialogFragment mDialog;
@@ -68,10 +75,16 @@
public void setup() {
MockitoAnnotations.initMocks(this);
mContext = spy(RuntimeEnvironment.application);
- doReturn(mTelephonyManager).when(mContext).getSystemService(Context.TELEPHONY_SERVICE);
+ final ShadowSubscriptionManager ssm = Shadow.extract(mContext.getSystemService(
+ SubscriptionManager.class));
+ ssm.setActiveSubscriptionInfos(mSubscriptionInfo);
+ when(mSubscriptionInfo.getSubscriptionId()).thenReturn(SUB_ID);
+ final ShadowTelephonyManager stm = Shadow.extract(mContext.getSystemService(
+ TelephonyManager.class));
+ stm.setTelephonyManagerForSubscriptionId(SUB_ID, mTelephonyManager);
when(mDialog.getContext()).thenReturn(mContext);
- mController = spy(new ImeiInfoDialogController(mDialog, 0 /* phone id */));
- ReflectionHelpers.setField(mController, "mSubscriptionInfo", mSubscriptionInfo);
+
+ mController = spy(new ImeiInfoDialogController(mDialog, SLOT_ID));
doReturn(PRL_VERSION).when(mController).getCdmaPrlVersion();
doReturn(MEID_NUMBER).when(mController).getMeid();
@@ -81,6 +94,14 @@
}
@Test
+ public void populateImeiInfo_invalidSlot_shouldSetNothing() {
+ mController = spy(new ImeiInfoDialogController(mDialog, SLOT_ID + 1));
+
+ mController.populateImeiInfo();
+ verify(mDialog, never()).setText(anyInt(), any());
+ }
+
+ @Test
public void populateImeiInfo_cdmaLteEnabled_shouldSetMeidAndImeiAndMin() {
doReturn(true).when(mController).isCdmaLteEnabled();
when(mTelephonyManager.getPhoneType()).thenReturn(TelephonyManager.PHONE_TYPE_CDMA);
diff --git a/tests/robotests/src/com/android/settings/deviceinfo/imei/ImeiInfoPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/deviceinfo/imei/ImeiInfoPreferenceControllerTest.java
index 69bc494..997c35e 100644
--- a/tests/robotests/src/com/android/settings/deviceinfo/imei/ImeiInfoPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/deviceinfo/imei/ImeiInfoPreferenceControllerTest.java
@@ -93,7 +93,7 @@
public void displayPreference_multiSimGsm_shouldAddSecondPreference() {
ReflectionHelpers.setField(mController, "mIsMultiSim", true);
when(mTelephonyManager.getPhoneCount()).thenReturn(2);
- when(mTelephonyManager.getPhoneType()).thenReturn(PHONE_TYPE_GSM);
+ when(mTelephonyManager.getCurrentPhoneType(anyInt())).thenReturn(PHONE_TYPE_GSM);
mController.displayPreference(mScreen);
@@ -104,8 +104,8 @@
public void displayPreference_singleSimCdmaPhone_shouldSetSingleSimCdmaTitleAndMeid() {
ReflectionHelpers.setField(mController, "mIsMultiSim", false);
final String meid = "125132215123";
- when(mTelephonyManager.getPhoneType()).thenReturn(PHONE_TYPE_CDMA);
- doReturn(meid).when(mController).getMeid(anyInt());
+ when(mTelephonyManager.getCurrentPhoneType(anyInt())).thenReturn(PHONE_TYPE_CDMA);
+ when(mTelephonyManager.getMeid(anyInt())).thenReturn(meid);
mController.displayPreference(mScreen);
@@ -118,8 +118,8 @@
ReflectionHelpers.setField(mController, "mIsMultiSim", true);
final String meid = "125132215123";
when(mTelephonyManager.getPhoneCount()).thenReturn(2);
- when(mTelephonyManager.getPhoneType()).thenReturn(PHONE_TYPE_CDMA);
- doReturn(meid).when(mController).getMeid(anyInt());
+ when(mTelephonyManager.getCurrentPhoneType(anyInt())).thenReturn(PHONE_TYPE_CDMA);
+ when(mTelephonyManager.getMeid(anyInt())).thenReturn(meid);
mController.displayPreference(mScreen);
@@ -134,7 +134,7 @@
public void displayPreference_singleSimGsmPhone_shouldSetSingleSimGsmTitleAndImei() {
ReflectionHelpers.setField(mController, "mIsMultiSim", false);
final String imei = "125132215123";
- when(mTelephonyManager.getPhoneType()).thenReturn(PHONE_TYPE_GSM);
+ when(mTelephonyManager.getCurrentPhoneType(anyInt())).thenReturn(PHONE_TYPE_GSM);
when(mTelephonyManager.getImei(anyInt())).thenReturn(imei);
mController.displayPreference(mScreen);
@@ -148,7 +148,7 @@
ReflectionHelpers.setField(mController, "mIsMultiSim", true);
final String imei = "125132215123";
when(mTelephonyManager.getPhoneCount()).thenReturn(2);
- when(mTelephonyManager.getPhoneType()).thenReturn(PHONE_TYPE_GSM);
+ when(mTelephonyManager.getCurrentPhoneType(anyInt())).thenReturn(PHONE_TYPE_GSM);
when(mTelephonyManager.getImei(anyInt())).thenReturn(imei);
mController.displayPreference(mScreen);
@@ -176,8 +176,8 @@
public void copy_shouldCopyImeiToClipboard() {
ReflectionHelpers.setField(mController, "mIsMultiSim", false);
final String meid = "125132215123";
- when(mTelephonyManager.getPhoneType()).thenReturn(PHONE_TYPE_CDMA);
- when(mTelephonyManager.getMeid()).thenReturn(meid);
+ when(mTelephonyManager.getCurrentPhoneType(anyInt())).thenReturn(PHONE_TYPE_CDMA);
+ when(mTelephonyManager.getMeid(anyInt())).thenReturn(meid);
mController.copy();
diff --git a/tests/robotests/src/com/android/settings/display/DarkUIInfoDialogFragmentTest.java b/tests/robotests/src/com/android/settings/display/DarkUIInfoDialogFragmentTest.java
index 87284ed..f90c590 100644
--- a/tests/robotests/src/com/android/settings/display/DarkUIInfoDialogFragmentTest.java
+++ b/tests/robotests/src/com/android/settings/display/DarkUIInfoDialogFragmentTest.java
@@ -26,9 +26,9 @@
import android.content.Context;
import android.content.DialogInterface;
import android.content.SharedPreferences;
+import android.provider.Settings;
import org.junit.Before;
-import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
@@ -50,7 +50,6 @@
}
@Test
- @Ignore("b/130897882")
public void dialogDismissedOnConfirmation() {
doReturn(RuntimeEnvironment.application).when(mFragment).getContext();
SharedPreferences prefs = RuntimeEnvironment.application.getSharedPreferences(
@@ -60,8 +59,7 @@
.isFalse();
mFragment.onClick(dialog, DialogInterface.BUTTON_POSITIVE);
verify(dialog, times(1)).dismiss();
- assertThat(prefs.getBoolean(DarkUIPreferenceController.PREF_DARK_MODE_DIALOG_SEEN, false))
- .isTrue();
-
+ assertThat(Settings.Secure.getInt(RuntimeEnvironment.application.getContentResolver(),
+ Settings.Secure.DARK_MODE_DIALOG_SEEN, -1)).isEqualTo(1);
}
}
diff --git a/tests/robotests/src/com/android/settings/fuelgauge/BatteryMeterViewTest.java b/tests/robotests/src/com/android/settings/fuelgauge/BatteryMeterViewTest.java
index 3e99433..0aa702a 100644
--- a/tests/robotests/src/com/android/settings/fuelgauge/BatteryMeterViewTest.java
+++ b/tests/robotests/src/com/android/settings/fuelgauge/BatteryMeterViewTest.java
@@ -43,6 +43,8 @@
private ColorFilter mErrorColorFilter;
@Mock
private ColorFilter mAccentColorFilter;
+ @Mock
+ private ColorFilter mForegroundColorFilter;
private Context mContext;
private BatteryMeterView mBatteryMeterView;
private BatteryMeterView.BatteryMeterDrawable mDrawable;
@@ -58,6 +60,7 @@
mBatteryMeterView.mDrawable = mDrawable;
mBatteryMeterView.mAccentColorFilter = mAccentColorFilter;
mBatteryMeterView.mErrorColorFilter = mErrorColorFilter;
+ mBatteryMeterView.mForegroundColorFilter = mForegroundColorFilter;
when(mDrawable.getCriticalLevel()).thenReturn(BATTERY_CRITICAL_LEVEL);
}
@@ -88,5 +91,6 @@
mBatteryMeterView.setPowerSave(true);
assertThat(mBatteryMeterView.getPowerSave()).isEqualTo(true);
+ verify(mDrawable).setColorFilter(mForegroundColorFilter);
}
}
diff --git a/tests/robotests/src/com/android/settings/homepage/contextualcards/slices/NotificationChannelSliceTest.java b/tests/robotests/src/com/android/settings/homepage/contextualcards/slices/NotificationChannelSliceTest.java
index 6c020f8..60a6b42 100644
--- a/tests/robotests/src/com/android/settings/homepage/contextualcards/slices/NotificationChannelSliceTest.java
+++ b/tests/robotests/src/com/android/settings/homepage/contextualcards/slices/NotificationChannelSliceTest.java
@@ -319,6 +319,7 @@
applicationInfo.name = APP_LABEL;
applicationInfo.uid = UID;
applicationInfo.flags = flags;
+ applicationInfo.packageName = PACKAGE_NAME;
final PackageInfo packageInfo = new PackageInfo();
packageInfo.packageName = PACKAGE_NAME;
diff --git a/tests/robotests/src/com/android/settings/homepage/contextualcards/slices/NotificationMultiChannelAppRowTest.java b/tests/robotests/src/com/android/settings/homepage/contextualcards/slices/NotificationMultiChannelAppRowTest.java
new file mode 100644
index 0000000..d722af6
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/homepage/contextualcards/slices/NotificationMultiChannelAppRowTest.java
@@ -0,0 +1,81 @@
+/*
+ * Copyright (C) 2019 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License
+ */
+
+package com.android.settings.homepage.contextualcards.slices;
+
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.never;
+import static org.mockito.Mockito.verify;
+
+import android.content.Context;
+import android.content.pm.ApplicationInfo;
+import android.content.pm.PackageInfo;
+import android.content.pm.PackageManager;
+
+import com.android.settings.notification.NotificationBackend;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+import org.robolectric.RobolectricTestRunner;
+import org.robolectric.RuntimeEnvironment;
+
+@RunWith(RobolectricTestRunner.class)
+public class NotificationMultiChannelAppRowTest {
+
+ @Mock
+ private NotificationBackend mNotificationBackend;
+ private Context mContext;
+ private NotificationMultiChannelAppRow mNotificationMultiChannelAppRow;
+ private PackageInfo mPackageInfo;
+
+ @Before
+ public void setUp() {
+ MockitoAnnotations.initMocks(this);
+
+ mContext = RuntimeEnvironment.application;
+ mPackageInfo = new PackageInfo();
+ mPackageInfo.applicationInfo = new ApplicationInfo();
+ mPackageInfo.applicationInfo.packageName = "com.android.test";
+ mNotificationMultiChannelAppRow = new NotificationMultiChannelAppRow(mContext,
+ mNotificationBackend, mPackageInfo);
+ }
+
+ @Test
+ public void call_isMultiChannel_shouldLoadAppRow() throws Exception {
+ doReturn(3).when(mNotificationBackend).getChannelCount(any(String.class),
+ any(int.class));
+
+ mNotificationMultiChannelAppRow.call();
+
+ verify(mNotificationBackend).loadAppRow(any(Context.class), any(PackageManager.class),
+ any(PackageInfo.class));
+ }
+
+ @Test
+ public void call_isNotMultiChannel_shouldNotLoadAppRow() throws Exception {
+ doReturn(1).when(mNotificationBackend).getChannelCount(any(String.class),
+ any(int.class));
+
+ mNotificationMultiChannelAppRow.call();
+
+ verify(mNotificationBackend, never()).loadAppRow(any(Context.class),
+ any(PackageManager.class), any(PackageInfo.class));
+ }
+}
diff --git a/tests/robotests/src/com/android/settings/location/RecentLocationAccessPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/location/RecentLocationAccessPreferenceControllerTest.java
index d210c7b..71a80de 100644
--- a/tests/robotests/src/com/android/settings/location/RecentLocationAccessPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/location/RecentLocationAccessPreferenceControllerTest.java
@@ -129,32 +129,26 @@
final View app1View = mAppEntitiesHeaderView.findViewById(R.id.app1_view);
final ImageView appIconView1 = app1View.findViewById(R.id.app_icon);
final TextView appTitle1 = app1View.findViewById(R.id.app_title);
- final TextView appSummary1 = app1View.findViewById(R.id.app_summary);
assertThat(app1View.getVisibility()).isEqualTo(View.VISIBLE);
assertThat(appIconView1.getDrawable()).isNotNull();
assertThat(appTitle1.getText()).isEqualTo("appTitle0");
- assertThat(appSummary1.getText()).isEqualTo("appSummary0");
final View app2View = mAppEntitiesHeaderView.findViewById(R.id.app2_view);
final ImageView appIconView2 = app2View.findViewById(R.id.app_icon);
final TextView appTitle2 = app2View.findViewById(R.id.app_title);
- final TextView appSummary2 = app2View.findViewById(R.id.app_summary);
assertThat(app2View.getVisibility()).isEqualTo(View.VISIBLE);
assertThat(appIconView2.getDrawable()).isNotNull();
assertThat(appTitle2.getText()).isEqualTo("appTitle1");
- assertThat(appSummary2.getText()).isEqualTo("appSummary1");
final View app3View = mAppEntitiesHeaderView.findViewById(R.id.app3_view);
final ImageView appIconView3 = app3View.findViewById(R.id.app_icon);
final TextView appTitle3 = app3View.findViewById(R.id.app_title);
- final TextView appSummary3 = app3View.findViewById(R.id.app_summary);
assertThat(app3View.getVisibility()).isEqualTo(View.VISIBLE);
assertThat(appIconView3.getDrawable()).isNotNull();
assertThat(appTitle3.getText()).isEqualTo("appTitle2");
- assertThat(appSummary3.getText()).isEqualTo("appSummary2");
}
private List<RecentLocationAccesses.Access> createMockAccesses(int count) {
diff --git a/tests/robotests/src/com/android/settings/media/MediaOutputSliceTest.java b/tests/robotests/src/com/android/settings/media/MediaOutputSliceTest.java
index 205f295..4a34919 100644
--- a/tests/robotests/src/com/android/settings/media/MediaOutputSliceTest.java
+++ b/tests/robotests/src/com/android/settings/media/MediaOutputSliceTest.java
@@ -17,6 +17,9 @@
package com.android.settings.media;
+import static android.app.slice.Slice.HINT_LIST_ITEM;
+import static android.app.slice.SliceItem.FORMAT_SLICE;
+
import static com.android.settings.slices.CustomSliceRegistry.MEDIA_OUTPUT_SLICE_URI;
import static com.google.common.truth.Truth.assertThat;
@@ -36,6 +39,7 @@
import androidx.slice.SliceMetadata;
import androidx.slice.SliceProvider;
import androidx.slice.core.SliceAction;
+import androidx.slice.core.SliceQuery;
import androidx.slice.widget.SliceLiveData;
import com.android.settings.testutils.shadow.ShadowBluetoothAdapter;
@@ -97,10 +101,27 @@
}
@Test
- public void getSlice_workerIsNull_shouldNotCrash() {
+ public void getSlice_workerIsNull_shouldReturnZeroRow() {
mMediaOutputSlice.init(TEST_PACKAGE_NAME, null);
- mMediaOutputSlice.getSlice();
+ final Slice slice = mMediaOutputSlice.getSlice();
+
+ final int rows = SliceQuery.findAll(slice, FORMAT_SLICE, HINT_LIST_ITEM,
+ null /* nonHints */).size();
+
+ assertThat(rows).isEqualTo(0);
+ }
+
+ @Test
+ public void getSlice_bluetoothIsDisable_shouldReturnZeroRow() {
+ mShadowBluetoothAdapter.setEnabled(false);
+
+ final Slice slice = mMediaOutputSlice.getSlice();
+
+ final int rows = SliceQuery.findAll(slice, FORMAT_SLICE, HINT_LIST_ITEM,
+ null /* nonHints */).size();
+
+ assertThat(rows).isEqualTo(0);
}
@Test
diff --git a/tests/robotests/src/com/android/settings/network/SubscriptionUtilTest.java b/tests/robotests/src/com/android/settings/network/SubscriptionUtilTest.java
index 28a390d..c647914 100644
--- a/tests/robotests/src/com/android/settings/network/SubscriptionUtilTest.java
+++ b/tests/robotests/src/com/android/settings/network/SubscriptionUtilTest.java
@@ -72,7 +72,6 @@
@Test
public void getAvailableSubscriptions_oneSubscription_oneResult() {
final SubscriptionInfo info = mock(SubscriptionInfo.class);
- when(info.getMncString()).thenReturn("fake1234");
when(mSubMgr.getSelectableSubscriptionInfoList()).thenReturn(Arrays.asList(info));
final List<SubscriptionInfo> subs = SubscriptionUtil.getAvailableSubscriptions(mContext);
assertThat(subs).isNotNull();
@@ -83,8 +82,6 @@
public void getAvailableSubscriptions_twoSubscriptions_twoResults() {
final SubscriptionInfo info1 = mock(SubscriptionInfo.class);
final SubscriptionInfo info2 = mock(SubscriptionInfo.class);
- when(info1.getMncString()).thenReturn("fake1234");
- when(info2.getMncString()).thenReturn("fake5678");
when(mSubMgr.getSelectableSubscriptionInfoList()).thenReturn(Arrays.asList(info1, info2));
final List<SubscriptionInfo> subs = SubscriptionUtil.getAvailableSubscriptions(mContext);
assertThat(subs).isNotNull();
@@ -92,51 +89,15 @@
}
@Test
- public void getAvailableSubscriptions_oneSubWithHiddenNetworks_oneResult() {
- final SubscriptionInfo info1 = mock(SubscriptionInfo.class);
- final SubscriptionInfo info2 = mock(SubscriptionInfo.class);
- final SubscriptionInfo info3 = mock(SubscriptionInfo.class);
- when(info1.getSubscriptionId()).thenReturn(1);
- when(info1.getMncString()).thenReturn("fake1234");
- when(mSubMgr.getSelectableSubscriptionInfoList()).thenReturn(
- new ArrayList<>(Arrays.asList(info1, info2, info3)));
- final List<SubscriptionInfo> subs = SubscriptionUtil.getAvailableSubscriptions(mContext);
- assertThat(subs).isNotNull();
- assertThat(subs).hasSize(1);
- assertThat(subs.get(0).getSubscriptionId()).isEqualTo(1);
- }
-
- @Test
- public void getAvailableSubscriptions_twoSubsWithHiddenNetworks_twoResults() {
- final SubscriptionInfo info1 = mock(SubscriptionInfo.class);
- final SubscriptionInfo info2 = mock(SubscriptionInfo.class);
- final SubscriptionInfo info3 = mock(SubscriptionInfo.class);
- final SubscriptionInfo info4 = mock(SubscriptionInfo.class);
- when(info1.getSubscriptionId()).thenReturn(1);
- when(info1.getMncString()).thenReturn("fake1234");
- when(info4.getSubscriptionId()).thenReturn(4);
- when(info4.getMncString()).thenReturn("fake5678");
- when(mSubMgr.getSelectableSubscriptionInfoList()).thenReturn(new ArrayList<>(
- Arrays.asList(info1, info2, info3, info4)));
- final List<SubscriptionInfo> subs = SubscriptionUtil.getAvailableSubscriptions(mContext);
- assertThat(subs).isNotNull();
- assertThat(subs).hasSize(2);
- assertThat(subs.get(0).getSubscriptionId()).isEqualTo(1);
- assertThat(subs.get(1).getSubscriptionId()).isEqualTo(4);
- }
-
- @Test
public void getAvailableSubscriptions_oneSelectableOneDisabledPSim_twoResults() {
final SubscriptionInfo info1 = mock(SubscriptionInfo.class);
final SubscriptionInfo info2 = mock(SubscriptionInfo.class);
when(info1.getSubscriptionId()).thenReturn(111);
- when(info1.getMncString()).thenReturn("fake111");
when(info1.getSimSlotIndex()).thenReturn(-1);
when(info1.getCardString()).thenReturn("info1_cardid");
when(info2.getSubscriptionId()).thenReturn(222);
- when(info2.getMncString()).thenReturn("fake222");
when(info2.getSimSlotIndex()).thenReturn(0);
when(info2.getCardString()).thenReturn("info2_cardid");
@@ -165,17 +126,14 @@
final SubscriptionInfo info3 = mock(SubscriptionInfo.class);
when(info1.getSubscriptionId()).thenReturn(111);
- when(info1.getMncString()).thenReturn("fake111");
when(info1.getSimSlotIndex()).thenReturn(-1);
when(info1.getCardString()).thenReturn("info1_cardid");
when(info2.getSubscriptionId()).thenReturn(222);
- when(info2.getMncString()).thenReturn("fake222");
when(info2.getSimSlotIndex()).thenReturn(-1);
when(info2.getCardString()).thenReturn("info2_cardid");
when(info3.getSubscriptionId()).thenReturn(333);
- when(info3.getMncString()).thenReturn("fake333");
when(info3.getSimSlotIndex()).thenReturn(0);
when(info3.getCardString()).thenReturn("info3_cardid");
diff --git a/tests/robotests/src/com/android/settings/network/telephony/RenameMobileNetworkDialogFragmentTest.java b/tests/robotests/src/com/android/settings/network/telephony/RenameMobileNetworkDialogFragmentTest.java
index 70816ea..5b008be 100644
--- a/tests/robotests/src/com/android/settings/network/telephony/RenameMobileNetworkDialogFragmentTest.java
+++ b/tests/robotests/src/com/android/settings/network/telephony/RenameMobileNetworkDialogFragmentTest.java
@@ -34,9 +34,15 @@
import android.telephony.SubscriptionInfo;
import android.telephony.SubscriptionManager;
import android.telephony.TelephonyManager;
+import android.view.LayoutInflater;
+import android.view.View;
import android.widget.Button;
import android.widget.EditText;
+import androidx.appcompat.app.AlertDialog;
+import androidx.fragment.app.FragmentActivity;
+
+import com.android.settings.R;
import com.android.settings.testutils.shadow.ShadowAlertDialogCompat;
import org.junit.Before;
@@ -49,9 +55,6 @@
import org.robolectric.RobolectricTestRunner;
import org.robolectric.annotation.Config;
-import androidx.appcompat.app.AlertDialog;
-import androidx.fragment.app.FragmentActivity;
-
@RunWith(RobolectricTestRunner.class)
@Config(shadows = ShadowAlertDialogCompat.class)
public class RenameMobileNetworkDialogFragmentTest {
@@ -123,6 +126,20 @@
assertThat(captor.getValue()).isEqualTo("test2");
}
+ @Test
+ public void populateView_infoIsOpportunistic_hideNumberLabel() {
+ final View view = LayoutInflater.from(mActivity).inflate(
+ R.layout.dialog_mobile_network_rename, null);
+ when(mSubscriptionMgr.getActiveSubscriptionInfo(mSubscriptionId)).thenReturn(
+ mSubscriptionInfo);
+ when(mSubscriptionInfo.isOpportunistic()).thenReturn(true);
+
+ startDialog();
+ mFragment.populateView(view);
+
+ assertThat(view.findViewById(R.id.number_label).getVisibility()).isEqualTo(View.GONE);
+ }
+
/** Helper method to start the dialog */
private AlertDialog startDialog() {
mFragment.show(mActivity.getSupportFragmentManager(), null);