Merge "[Settings] Replace getSimCount() API"
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index afc4d40..f2ed29c 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -2701,20 +2701,13 @@
<action android:name="android.settings.action.MANAGE_OVERLAY_PERMISSION" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
- <meta-data android:name="com.android.settings.FRAGMENT_CLASS"
- android:value="com.android.settings.applications.manageapplications.ManageApplications" />
- </activity>
-
- <activity
- android:name="Settings$AppDrawOverlaySettingsActivity"
- android:label="@string/draw_overlay">
<intent-filter android:priority="1">
<action android:name="android.settings.action.MANAGE_OVERLAY_PERMISSION" />
<category android:name="android.intent.category.DEFAULT" />
<data android:scheme="package" />
</intent-filter>
<meta-data android:name="com.android.settings.FRAGMENT_CLASS"
- android:value="com.android.settings.applications.appinfo.DrawOverlayDetails" />
+ android:value="com.android.settings.applications.manageapplications.ManageApplications" />
</activity>
<activity
diff --git a/res/layout/screen_pinning_instructions.xml b/res/layout/screen_pinning_instructions.xml
deleted file mode 100644
index fea5ed8..0000000
--- a/res/layout/screen_pinning_instructions.xml
+++ /dev/null
@@ -1,38 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
-/*
-** Copyright 2014, 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.
-*/
--->
-
-<ScrollView
- xmlns:android="http://schemas.android.com/apk/res/android"
- android:id="@+id/instructions_area"
- android:layout_width="match_parent"
- android:layout_height="match_parent">
-
- <TextView
- android:id="@+id/screen_pinning_description"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:layout_alignParentTop="true"
- android:paddingTop="@dimen/screen_pinning_textview_padding"
- android:text="@string/screen_pinning_description"
- android:textAppearance="@style/TextAppearance.Medium"
- android:paddingStart="@dimen/screen_pinning_padding_start"
- android:paddingEnd="@dimen/screen_pinning_padding_end"
- />
-
-</ScrollView>
diff --git a/res/values/dimens.xml b/res/values/dimens.xml
index f97da1f..242b690 100755
--- a/res/values/dimens.xml
+++ b/res/values/dimens.xml
@@ -158,9 +158,6 @@
<!-- CryptKeeper pattern size for tablet -->
<dimen name="crypt_keeper_pattern_size">354dip</dimen>
- <!-- Screen pinning textview paddings -->
- <dimen name="screen_pinning_textview_padding">40dp</dimen>
-
<!-- SIM Dialog Margin top -->
<dimen name="sim_dialog_margin_top">8dip</dimen>
<!-- SIM Dialog Margin bottom -->
@@ -329,10 +326,6 @@
<dimen name="reset_master_clear_margin_start">32dp</dimen>
<dimen name="reset_master_clear_margin_end">12dp</dimen>
- <!-- Padding for screen pinning -->
- <dimen name="screen_pinning_padding_start">64dp</dimen>
- <dimen name="screen_pinning_padding_end">64dp</dimen>
-
<!-- Padding for the reset screens -->
<dimen name="reset_checkbox_padding_end">8dp</dimen>
<dimen name="reset_checkbox_title_padding_top">12dp</dimen>
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 3af7142..758c054 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -6756,9 +6756,6 @@
<!-- Restrictions screen - menu label to change restrictions pin [CHAR LIMIT=25] -->
<string name="restriction_menu_change_pin">Change PIN</string>
- <!-- Label for are-notifications-enabled checkbox in app details [CHAR LIMIT=20] -->
- <string name="app_notifications_switch_label">Show notifications</string>
-
<!-- Help URLs for some screens. Not specified here. Specified in product overlays --><skip/>
<!-- Help menu label [CHAR LIMIT=20] -->
<string name="help_label">Help & feedback</string>
@@ -8026,7 +8023,7 @@
<string name="notification_channel_summary_high">When device is unlocked, show notifications as a banner across the top of the screen</string>
<!-- [CHAR LIMIT=100] Label for on/off toggle -->
- <string name="notification_switch_label">Show notifications</string>
+ <string name="notification_switch_label">All <xliff:g id="app_name" example="Android Services">%1$s</xliff:g> notifications</string>
<!-- Default Apps > Default notification assistant -->
<string name="default_notification_assistant">Adaptive Notifications</string>
diff --git a/res/xml/screen_pinning_settings.xml b/res/xml/screen_pinning_settings.xml
index f27e4aa..7ff7f1d 100644
--- a/res/xml/screen_pinning_settings.xml
+++ b/res/xml/screen_pinning_settings.xml
@@ -16,6 +16,7 @@
<PreferenceScreen
xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:settings="http://schemas.android.com/apk/res-auto"
android:key="screen_pinning_settings_screen"
android:title="@string/screen_pinning_title">
@@ -23,4 +24,10 @@
android:key="use_screen_lock"
android:title="@string/screen_pinning_unlock_none" />
+ <com.android.settingslib.widget.FooterPreference
+ android:key="screen_pinning_settings_screen_footer"
+ android:title="@string/screen_pinning_description"
+ android:selectable="false"
+ settings:searchable="false" />
+
</PreferenceScreen>
diff --git a/src/com/android/settings/EncryptionInterstitial.java b/src/com/android/settings/EncryptionInterstitial.java
index c132c89..7a11053 100644
--- a/src/com/android/settings/EncryptionInterstitial.java
+++ b/src/com/android/settings/EncryptionInterstitial.java
@@ -31,7 +31,6 @@
import android.view.View;
import android.view.ViewGroup;
import android.view.accessibility.AccessibilityManager;
-import android.widget.LinearLayout;
import android.widget.TextView;
import androidx.appcompat.app.AlertDialog;
diff --git a/src/com/android/settings/Settings.java b/src/com/android/settings/Settings.java
index 24963b3..c189b7b 100644
--- a/src/com/android/settings/Settings.java
+++ b/src/com/android/settings/Settings.java
@@ -137,7 +137,6 @@
public static class OverlaySettingsActivity extends SettingsActivity { /* empty */ }
public static class WriteSettingsActivity extends SettingsActivity { /* empty */ }
public static class ChangeWifiStateActivity extends SettingsActivity { /* empty */ }
- public static class AppDrawOverlaySettingsActivity extends SettingsActivity { /* empty */ }
public static class AppWriteSettingsActivity extends SettingsActivity { /* empty */ }
public static class ManageExternalSourcesActivity extends SettingsActivity {/* empty */ }
diff --git a/src/com/android/settings/Utils.java b/src/com/android/settings/Utils.java
index 436acef..65d0c82 100644
--- a/src/com/android/settings/Utils.java
+++ b/src/com/android/settings/Utils.java
@@ -156,19 +156,19 @@
public static boolean updatePreferenceToSpecificActivityOrRemove(Context context,
PreferenceGroup parentPreferenceGroup, String preferenceKey, int flags) {
- Preference preference = parentPreferenceGroup.findPreference(preferenceKey);
+ final Preference preference = parentPreferenceGroup.findPreference(preferenceKey);
if (preference == null) {
return false;
}
- Intent intent = preference.getIntent();
+ final Intent intent = preference.getIntent();
if (intent != null) {
// Find the activity that is in the system image
- PackageManager pm = context.getPackageManager();
- List<ResolveInfo> list = pm.queryIntentActivities(intent, 0);
- int listSize = list.size();
+ final PackageManager pm = context.getPackageManager();
+ final List<ResolveInfo> list = pm.queryIntentActivities(intent, 0);
+ final int listSize = list.size();
for (int i = 0; i < listSize; i++) {
- ResolveInfo resolveInfo = list.get(i);
+ final ResolveInfo resolveInfo = list.get(i);
if ((resolveInfo.activityInfo.applicationInfo.flags & ApplicationInfo.FLAG_SYSTEM)
!= 0) {
@@ -199,7 +199,7 @@
* @throws IllegalStateException if no UserManager could be retrieved.
*/
public static UserManager getUserManager(Context context) {
- UserManager um = UserManager.get(context);
+ final UserManager um = UserManager.get(context);
if (um == null) {
throw new IllegalStateException("Unable to load UserManager");
}
@@ -217,7 +217,7 @@
* Returns whether the device is voice-capable (meaning, it is also a phone).
*/
public static boolean isVoiceCapable(Context context) {
- TelephonyManager telephony =
+ final TelephonyManager telephony =
(TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
return telephony != null && telephony.isVoiceCapable();
}
@@ -228,12 +228,12 @@
* @return the formatted and newline-separated IP addresses, or null if none.
*/
public static String getWifiIpAddresses(Context context) {
- WifiManager wifiManager = context.getSystemService(WifiManager.class);
- Network currentNetwork = wifiManager.getCurrentNetwork();
+ final WifiManager wifiManager = context.getSystemService(WifiManager.class);
+ final Network currentNetwork = wifiManager.getCurrentNetwork();
if (currentNetwork != null) {
- ConnectivityManager cm = (ConnectivityManager)
+ final ConnectivityManager cm = (ConnectivityManager)
context.getSystemService(Context.CONNECTIVITY_SERVICE);
- LinkProperties prop = cm.getLinkProperties(currentNetwork);
+ final LinkProperties prop = cm.getLinkProperties(currentNetwork);
return formatIpAddresses(prop);
}
return null;
@@ -241,7 +241,7 @@
private static String formatIpAddresses(LinkProperties prop) {
if (prop == null) return null;
- Iterator<InetAddress> iter = prop.getAllAddresses().iterator();
+ final Iterator<InetAddress> iter = prop.getAllAddresses().iterator();
// If there are no entries, return null
if (!iter.hasNext()) return null;
// Concatenate all available addresses, comma separated
@@ -262,7 +262,7 @@
// And : new Locale("en_US").toString() => "en_us"
if (null == localeStr)
return Locale.getDefault();
- String[] brokenDownLocale = localeStr.split("_", 3);
+ final String[] brokenDownLocale = localeStr.split("_", 3);
// split may not return a 0-length array.
if (1 == brokenDownLocale.length) {
return new Locale(brokenDownLocale[0]);
@@ -396,7 +396,7 @@
* exists but it is disabled.
*/
public static UserHandle getManagedProfile(UserManager userManager) {
- List<UserHandle> userProfiles = userManager.getUserProfiles();
+ final List<UserHandle> userProfiles = userManager.getUserProfiles();
for (UserHandle profile : userProfiles) {
if (profile.getIdentifier() == userManager.getUserHandle()) {
continue;
@@ -420,7 +420,7 @@
// we need to use UserManager.getProfiles that is available on API 23 (the one currently
// used for Settings Robolectric tests).
final int myUserId = UserHandle.myUserId();
- List<UserInfo> profiles = userManager.getProfiles(myUserId);
+ final List<UserInfo> profiles = userManager.getProfiles(myUserId);
final int count = profiles.size();
for (int i = 0; i < count; i++) {
final UserInfo profile = profiles.get(i);
@@ -438,7 +438,7 @@
* @return the managed profile id or UserHandle.USER_NULL if there is none.
*/
public static int getManagedProfileId(UserManager um, int parentUserId) {
- int[] profileIds = um.getProfileIdsWithDisabled(parentUserId);
+ final int[] profileIds = um.getProfileIdsWithDisabled(parentUserId);
for (int profileId : profileIds) {
if (profileId != parentUserId) {
return profileId;
@@ -464,13 +464,14 @@
*/
public static UserHandle getSecureTargetUser(IBinder activityToken,
UserManager um, @Nullable Bundle arguments, @Nullable Bundle intentExtras) {
- UserHandle currentUser = new UserHandle(UserHandle.myUserId());
- IActivityManager am = ActivityManager.getService();
+ final UserHandle currentUser = new UserHandle(UserHandle.myUserId());
+ final IActivityManager am = ActivityManager.getService();
try {
- String launchedFromPackage = am.getLaunchedFromPackage(activityToken);
- boolean launchedFromSettingsApp = SETTINGS_PACKAGE_NAME.equals(launchedFromPackage);
+ final String launchedFromPackage = am.getLaunchedFromPackage(activityToken);
+ final boolean launchedFromSettingsApp =
+ SETTINGS_PACKAGE_NAME.equals(launchedFromPackage);
- UserHandle launchedFromUser = new UserHandle(UserHandle.getUserId(
+ final UserHandle launchedFromUser = new UserHandle(UserHandle.getUserId(
am.getLaunchedFromUid(activityToken)));
if (launchedFromUser != null && !launchedFromUser.equals(currentUser)) {
// Check it's secure
@@ -478,14 +479,14 @@
return launchedFromUser;
}
}
- UserHandle extrasUser = getUserHandleFromBundle(intentExtras);
+ final UserHandle extrasUser = getUserHandleFromBundle(intentExtras);
if (extrasUser != null && !extrasUser.equals(currentUser)) {
// Check it's secure
if (launchedFromSettingsApp && isProfileOf(um, extrasUser)) {
return extrasUser;
}
}
- UserHandle argumentsUser = getUserHandleFromBundle(arguments);
+ final UserHandle argumentsUser = getUserHandleFromBundle(arguments);
if (argumentsUser != null && !argumentsUser.equals(currentUser)) {
// Check it's secure
if (launchedFromSettingsApp && isProfileOf(um, argumentsUser)) {
@@ -555,10 +556,11 @@
}
public static ArraySet<String> getHandledDomains(PackageManager pm, String packageName) {
- List<IntentFilterVerificationInfo> iviList = pm.getIntentFilterVerifications(packageName);
- List<IntentFilter> filters = pm.getAllIntentFilters(packageName);
+ final List<IntentFilterVerificationInfo> iviList =
+ pm.getIntentFilterVerifications(packageName);
+ final List<IntentFilter> filters = pm.getAllIntentFilters(packageName);
- ArraySet<String> result = new ArraySet<>();
+ final ArraySet<String> result = new ArraySet<>();
if (iviList != null && iviList.size() > 0) {
for (IntentFilterVerificationInfo ivi : iviList) {
for (String host : ivi.getDomains()) {
@@ -582,16 +584,16 @@
* Returns the application info of the currently installed MDM package.
*/
public static ApplicationInfo getAdminApplicationInfo(Context context, int profileId) {
- DevicePolicyManager dpm =
+ final DevicePolicyManager dpm =
(DevicePolicyManager) context.getSystemService(Context.DEVICE_POLICY_SERVICE);
- ComponentName mdmPackage = dpm.getProfileOwnerAsUser(profileId);
+ final ComponentName mdmPackage = dpm.getProfileOwnerAsUser(profileId);
if (mdmPackage == null) {
return null;
}
- String mdmPackageName = mdmPackage.getPackageName();
+ final String mdmPackageName = mdmPackage.getPackageName();
try {
- IPackageManager ipm = AppGlobals.getPackageManager();
- ApplicationInfo mdmApplicationInfo =
+ final IPackageManager ipm = AppGlobals.getPackageManager();
+ final ApplicationInfo mdmApplicationInfo =
ipm.getApplicationInfo(mdmPackageName, 0, profileId);
return mdmApplicationInfo;
} catch (RemoteException e) {
@@ -618,7 +620,7 @@
*/
public static SpannableString createAccessibleSequence(CharSequence displayText,
String accessibileText) {
- SpannableString str = new SpannableString(displayText);
+ final SpannableString str = new SpannableString(displayText);
str.setSpan(new TtsSpan.TextBuilder(accessibileText).build(), 0,
displayText.length(),
Spannable.SPAN_INCLUSIVE_INCLUSIVE);
@@ -652,7 +654,7 @@
}
final boolean allowAnyUser = isInternal
&& bundle.getBoolean(ChooseLockSettingsHelper.EXTRA_ALLOW_ANY_USER, false);
- int userId = bundle.getInt(Intent.EXTRA_USER_ID, UserHandle.myUserId());
+ final int userId = bundle.getInt(Intent.EXTRA_USER_ID, UserHandle.myUserId());
if (userId == LockPatternUtils.USER_FRP) {
return allowAnyUser ? userId : enforceSystemUser(context, userId);
} else {
@@ -699,7 +701,7 @@
* Returns the user id of the credential owner of the given user id.
*/
public static int getCredentialOwnerUserId(Context context, int userId) {
- UserManager um = getUserManager(context);
+ final UserManager um = getUserManager(context);
return um.getCredentialOwnerProfile(userId);
}
@@ -799,7 +801,7 @@
}
public static boolean hasFingerprintHardware(Context context) {
- FingerprintManager fingerprintManager = getFingerprintManagerOrNull(context);
+ final FingerprintManager fingerprintManager = getFingerprintManagerOrNull(context);
return fingerprintManager != null && fingerprintManager.isHardwareDetected();
}
@@ -812,7 +814,7 @@
}
public static boolean hasFaceHardware(Context context) {
- FaceManager faceManager = getFaceManagerOrNull(context);
+ final FaceManager faceManager = getFaceManagerOrNull(context);
return faceManager != null && faceManager.isHardwareDetected();
}
@@ -865,7 +867,7 @@
public static VolumeInfo maybeInitializeVolume(StorageManager sm, Bundle bundle) {
final String volumeId = bundle.getString(VolumeInfo.EXTRA_VOLUME_ID,
VolumeInfo.ID_PRIVATE_INTERNAL);
- VolumeInfo volume = sm.findVolumeById(volumeId);
+ final VolumeInfo volume = sm.findVolumeById(volumeId);
return isVolumeValid(volume) ? volume : null;
}
@@ -878,12 +880,13 @@
*/
public static boolean isProfileOrDeviceOwner(UserManager userManager,
DevicePolicyManager devicePolicyManager, String packageName) {
- List<UserInfo> userInfos = userManager.getUsers();
+ final List<UserInfo> userInfos = userManager.getUsers();
if (devicePolicyManager.isDeviceOwnerAppOnAnyUser(packageName)) {
return true;
}
for (int i = 0, size = userInfos.size(); i < size; i++) {
- ComponentName cn = devicePolicyManager.getProfileOwnerAsUser(userInfos.get(i).id);
+ final ComponentName cn = devicePolicyManager
+ .getProfileOwnerAsUser(userInfos.get(i).id);
if (cn != null && cn.getPackageName().equals(packageName)) {
return true;
}
@@ -938,9 +941,9 @@
return original;
}
- float scaleWidth = ((float) maxWidth) / actualWidth;
- float scaleHeight = ((float) maxHeight) / actualHeight;
- float scale = Math.min(scaleWidth, scaleHeight);
+ final float scaleWidth = ((float) maxWidth) / actualWidth;
+ final float scaleHeight = ((float) maxHeight) / actualHeight;
+ final float scale = Math.min(scaleWidth, scaleHeight);
final int width = (int) (actualWidth * scale);
final int height = (int) (actualHeight * scale);
diff --git a/src/com/android/settings/applications/specialaccess/zenaccess/ScaryWarningDialogFragment.java b/src/com/android/settings/applications/specialaccess/zenaccess/ScaryWarningDialogFragment.java
index 69318f8..778206b 100644
--- a/src/com/android/settings/applications/specialaccess/zenaccess/ScaryWarningDialogFragment.java
+++ b/src/com/android/settings/applications/specialaccess/zenaccess/ScaryWarningDialogFragment.java
@@ -25,7 +25,6 @@
import com.android.settings.R;
import com.android.settings.core.instrumentation.InstrumentedDialogFragment;
-import com.android.settings.notification.ZenAccessSettings;
/**
* Warning dialog when allowing zen access warning about the privileges being granted.
diff --git a/src/com/android/settings/bluetooth/AdvancedBluetoothDetailsHeaderController.java b/src/com/android/settings/bluetooth/AdvancedBluetoothDetailsHeaderController.java
index e245c22..2bc5592 100644
--- a/src/com/android/settings/bluetooth/AdvancedBluetoothDetailsHeaderController.java
+++ b/src/com/android/settings/bluetooth/AdvancedBluetoothDetailsHeaderController.java
@@ -112,7 +112,7 @@
if (!isAvailable()) {
return;
}
- mCachedDevice.registerCallback(this::onDeviceAttributesChanged);
+ mCachedDevice.registerCallback(this);
mBluetoothAdapter.addOnMetadataChangedListener(mCachedDevice.getDevice(),
mContext.getMainExecutor(), mMetadataListener);
}
@@ -122,7 +122,7 @@
if (!isAvailable()) {
return;
}
- mCachedDevice.unregisterCallback(this::onDeviceAttributesChanged);
+ mCachedDevice.unregisterCallback(this);
mBluetoothAdapter.removeOnMetadataChangedListener(mCachedDevice.getDevice(),
mMetadataListener);
}
@@ -153,7 +153,7 @@
final TextView summary = mLayoutPreference.findViewById(R.id.entity_header_summary);
summary.setText(mCachedDevice.getConnectionSummary(true /* shortSummary */));
- if (!mCachedDevice.isConnected()) {
+ if (!mCachedDevice.isConnected() || mCachedDevice.isBusy()) {
updateDisconnectLayout();
return;
}
diff --git a/src/com/android/settings/bluetooth/Utils.java b/src/com/android/settings/bluetooth/Utils.java
index 5e9ac3a..48c7212 100755
--- a/src/com/android/settings/bluetooth/Utils.java
+++ b/src/com/android/settings/bluetooth/Utils.java
@@ -45,7 +45,7 @@
private static final String TAG = "BluetoothUtils";
static final boolean V = BluetoothUtils.V; // verbose logging
- static final boolean D = BluetoothUtils.D; // regular logging
+ static final boolean D = BluetoothUtils.D; // regular logging
private Utils() {
}
@@ -93,7 +93,8 @@
@VisibleForTesting
static void showConnectingError(Context context, String name, LocalBluetoothManager manager) {
FeatureFactory.getFactory(context).getMetricsFeatureProvider().visible(context,
- SettingsEnums.PAGE_UNKNOWN, SettingsEnums.ACTION_SETTINGS_BLUETOOTH_CONNECT_ERROR);
+ SettingsEnums.PAGE_UNKNOWN, SettingsEnums.ACTION_SETTINGS_BLUETOOTH_CONNECT_ERROR,
+ 0);
showError(context, name, R.string.bluetooth_connecting_error_message, manager);
}
diff --git a/src/com/android/settings/core/FeatureFlags.java b/src/com/android/settings/core/FeatureFlags.java
index 4b65df1..92e4e72 100644
--- a/src/com/android/settings/core/FeatureFlags.java
+++ b/src/com/android/settings/core/FeatureFlags.java
@@ -26,4 +26,5 @@
public static final String WIFI_DETAILS_DATAUSAGE_HEADER =
"settings_wifi_details_datausage_header";
public static final String PERSONAL_WORK_PROFILE = "settings_work_profile";
+ public static final String CONTROLLER_ENHANCEMENT = "settings_controller_loading_enhancement";
}
diff --git a/src/com/android/settings/core/InstrumentedFragment.java b/src/com/android/settings/core/InstrumentedFragment.java
index 427e33a..c4ceb4a 100644
--- a/src/com/android/settings/core/InstrumentedFragment.java
+++ b/src/com/android/settings/core/InstrumentedFragment.java
@@ -47,8 +47,4 @@
mVisibilityLoggerMixin.setSourceMetricsCategory(getActivity());
super.onResume();
}
-
- protected final VisibilityLoggerMixin getVisibilityLogger() {
- return mVisibilityLoggerMixin;
- }
}
diff --git a/src/com/android/settings/core/InstrumentedPreferenceFragment.java b/src/com/android/settings/core/InstrumentedPreferenceFragment.java
index f5f245f..8b59281 100644
--- a/src/com/android/settings/core/InstrumentedPreferenceFragment.java
+++ b/src/com/android/settings/core/InstrumentedPreferenceFragment.java
@@ -91,10 +91,6 @@
return getPreferenceManager().getContext();
}
- protected final VisibilityLoggerMixin getVisibilityLogger() {
- return mVisibilityLoggerMixin;
- }
-
/**
* Get the res id for static preference xml for this fragment.
*/
diff --git a/src/com/android/settings/core/instrumentation/SettingsEventLogWriter.java b/src/com/android/settings/core/instrumentation/SettingsEventLogWriter.java
index a58555f..4ffa2d0 100644
--- a/src/com/android/settings/core/instrumentation/SettingsEventLogWriter.java
+++ b/src/com/android/settings/core/instrumentation/SettingsEventLogWriter.java
@@ -25,11 +25,11 @@
public class SettingsEventLogWriter extends EventLogWriter {
@Override
- public void visible(Context context, int source, int category) {
+ public void visible(Context context, int source, int category, int latency) {
if (shouldDisableGenericEventLogging()) {
return;
}
- super.visible(context, source, category);
+ super.visible(context, source, category, latency);
}
@Override
diff --git a/src/com/android/settings/core/instrumentation/SettingsIntelligenceLogWriter.java b/src/com/android/settings/core/instrumentation/SettingsIntelligenceLogWriter.java
index 9498732..62954ea 100644
--- a/src/com/android/settings/core/instrumentation/SettingsIntelligenceLogWriter.java
+++ b/src/com/android/settings/core/instrumentation/SettingsIntelligenceLogWriter.java
@@ -61,12 +61,12 @@
}
@Override
- public void visible(Context context, int attribution, int pageId) {
- action(attribution /* attribution */,
+ public void visible(Context context, int attribution, int pageId, int latency) {
+ action(attribution /* from pageId */,
SettingsEnums.PAGE_VISIBLE /* action */,
- pageId /* pageId */,
+ pageId /* target pageId */,
"" /* changedPreferenceKey */,
- 0 /* changedPreferenceIntValue */);
+ latency /* changedPreferenceIntValue */);
}
@Override
diff --git a/src/com/android/settings/core/instrumentation/StatsLogWriter.java b/src/com/android/settings/core/instrumentation/StatsLogWriter.java
index bcdecf3..6e09b72 100644
--- a/src/com/android/settings/core/instrumentation/StatsLogWriter.java
+++ b/src/com/android/settings/core/instrumentation/StatsLogWriter.java
@@ -26,13 +26,13 @@
public class StatsLogWriter implements LogWriter {
@Override
- public void visible(Context context, int attribution, int pageId) {
+ public void visible(Context context, int attribution, int pageId, int latency) {
StatsLog.write(StatsLog.SETTINGS_UI_CHANGED /* Atom name */,
- attribution,
+ attribution, /* from pageId */
SettingsEnums.PAGE_VISIBLE /* action */,
- pageId,
+ pageId, /* target pageId */
null /* changedPreferenceKey */,
- 0 /* changedPreferenceIntValue */);
+ latency /* changedPreferenceIntValue */);
}
@Override
diff --git a/src/com/android/settings/datausage/BillingCyclePreference.java b/src/com/android/settings/datausage/BillingCyclePreference.java
index 23c577c..8dea7de 100644
--- a/src/com/android/settings/datausage/BillingCyclePreference.java
+++ b/src/com/android/settings/datausage/BillingCyclePreference.java
@@ -26,27 +26,39 @@
import com.android.settings.R;
import com.android.settings.core.SubSettingLauncher;
-import com.android.settings.datausage.CellDataPreference.DataStateListener;
+import com.android.settings.network.MobileDataEnabledListener;
-public class BillingCyclePreference extends Preference implements TemplatePreference {
+/**
+ * Preference which displays billing cycle of subscription
+ */
+public class BillingCyclePreference extends Preference
+ implements TemplatePreference, MobileDataEnabledListener.Client {
private NetworkTemplate mTemplate;
private NetworkServices mServices;
private int mSubId;
+ private MobileDataEnabledListener mListener;
+ /**
+ * Preference constructor
+ *
+ * @param context Context of preference
+ * @param arrts The attributes of the XML tag that is inflating the preference
+ */
public BillingCyclePreference(Context context, AttributeSet attrs) {
super(context, attrs);
+ mListener = new MobileDataEnabledListener(context, this);
}
@Override
public void onAttached() {
super.onAttached();
- mListener.setListener(true, mSubId, getContext());
+ mListener.start(mSubId);
}
@Override
public void onDetached() {
- mListener.setListener(false, mSubId, getContext());
+ mListener.stop();
super.onDetached();
}
@@ -73,7 +85,7 @@
@Override
public Intent getIntent() {
- Bundle args = new Bundle();
+ final Bundle args = new Bundle();
args.putParcelable(DataUsageList.EXTRA_NETWORK_TEMPLATE, mTemplate);
return new SubSettingLauncher(getContext())
.setDestination(BillingCycleSettings.class.getName())
@@ -83,10 +95,10 @@
.toIntent();
}
- private final DataStateListener mListener = new DataStateListener() {
- @Override
- public void onChange(boolean selfChange) {
- updateEnabled();
- }
- };
+ /**
+ * Implementation of MobileDataEnabledListener.Client
+ */
+ public void onMobileDataEnabledChange() {
+ updateEnabled();
+ }
}
diff --git a/src/com/android/settings/datausage/CellDataPreference.java b/src/com/android/settings/datausage/CellDataPreference.java
index 5bfe967..f4f2be7 100644
--- a/src/com/android/settings/datausage/CellDataPreference.java
+++ b/src/com/android/settings/datausage/CellDataPreference.java
@@ -17,14 +17,9 @@
import android.app.settings.SettingsEnums;
import android.content.Context;
import android.content.DialogInterface;
-import android.database.ContentObserver;
import android.net.NetworkTemplate;
-import android.net.Uri;
-import android.os.Handler;
-import android.os.Looper;
import android.os.Parcel;
import android.os.Parcelable;
-import android.provider.Settings.Global;
import android.telephony.SubscriptionInfo;
import android.telephony.SubscriptionManager;
import android.telephony.TelephonyManager;
@@ -39,33 +34,38 @@
import androidx.preference.PreferenceViewHolder;
import com.android.settings.R;
+import com.android.settings.network.MobileDataEnabledListener;
+import com.android.settings.network.ProxySubscriptionManager;
import com.android.settings.overlay.FeatureFactory;
import com.android.settingslib.CustomDialogPreferenceCompat;
-import java.util.List;
-
-public class CellDataPreference extends CustomDialogPreferenceCompat implements TemplatePreference {
+/**
+ * Preference of cellular data control within Data Usage
+ */
+public class CellDataPreference extends CustomDialogPreferenceCompat
+ implements TemplatePreference, MobileDataEnabledListener.Client {
private static final String TAG = "CellDataPreference";
public int mSubId = SubscriptionManager.INVALID_SUBSCRIPTION_ID;
public boolean mChecked;
public boolean mMultiSimDialog;
- private TelephonyManager mTelephonyManager;
@VisibleForTesting
- SubscriptionManager mSubscriptionManager;
+ ProxySubscriptionManager mProxySubscriptionMgr;
+ private MobileDataEnabledListener mDataStateListener;
public CellDataPreference(Context context, AttributeSet attrs) {
super(context, attrs, TypedArrayUtils.getAttr(context,
androidx.preference.R.attr.switchPreferenceStyle,
android.R.attr.switchPreferenceStyle));
+ mProxySubscriptionMgr = ProxySubscriptionManager.getInstance(context);
+ mDataStateListener = new MobileDataEnabledListener(context, this);
}
@Override
protected void onRestoreInstanceState(Parcelable s) {
- CellDataState state = (CellDataState) s;
+ final CellDataState state = (CellDataState) s;
super.onRestoreInstanceState(state.getSuperState());
- mTelephonyManager = TelephonyManager.from(getContext());
mChecked = state.mChecked;
mMultiSimDialog = state.mMultiSimDialog;
if (mSubId == SubscriptionManager.INVALID_SUBSCRIPTION_ID) {
@@ -77,7 +77,7 @@
@Override
protected Parcelable onSaveInstanceState() {
- CellDataState state = new CellDataState(super.onSaveInstanceState());
+ final CellDataState state = new CellDataState(super.onSaveInstanceState());
state.mChecked = mChecked;
state.mMultiSimDialog = mMultiSimDialog;
state.mSubId = mSubId;
@@ -87,19 +87,14 @@
@Override
public void onAttached() {
super.onAttached();
- mDataStateListener.setListener(true, mSubId, getContext());
- if (mSubscriptionManager!= null) {
- mSubscriptionManager.addOnSubscriptionsChangedListener(mOnSubscriptionsChangeListener);
- }
+ mDataStateListener.start(mSubId);
+ mProxySubscriptionMgr.addActiveSubscriptionsListener(mOnSubscriptionsChangeListener);
}
@Override
public void onDetached() {
- mDataStateListener.setListener(false, mSubId, getContext());
- if (mSubscriptionManager!= null) {
- mSubscriptionManager.removeOnSubscriptionsChangedListener(
- mOnSubscriptionsChangeListener);
- }
+ mDataStateListener.stop();
+ mProxySubscriptionMgr.removeActiveSubscriptionsListener(mOnSubscriptionsChangeListener);
super.onDetached();
}
@@ -108,10 +103,9 @@
if (subId == SubscriptionManager.INVALID_SUBSCRIPTION_ID) {
throw new IllegalArgumentException("CellDataPreference needs a SubscriptionInfo");
}
- mSubscriptionManager = SubscriptionManager.from(getContext());
- mTelephonyManager = TelephonyManager.from(getContext());
- mSubscriptionManager.addOnSubscriptionsChangedListener(mOnSubscriptionsChangeListener);
+ mProxySubscriptionMgr = ProxySubscriptionManager.getInstance(getContext());
+ mProxySubscriptionMgr.addActiveSubscriptionsListener(mOnSubscriptionsChangeListener);
if (mSubId == SubscriptionManager.INVALID_SUBSCRIPTION_ID) {
mSubId = subId;
@@ -122,13 +116,13 @@
}
private void updateChecked() {
- setChecked(mTelephonyManager.getDataEnabled(mSubId));
+ setChecked(getContext().getSystemService(TelephonyManager.class).getDataEnabled(mSubId));
}
private void updateEnabled() {
// If this subscription is not active, for example, SIM card is taken out, we disable
// the button.
- setEnabled(mSubscriptionManager.getActiveSubscriptionInfo(mSubId) != null);
+ setEnabled(mProxySubscriptionMgr.getActiveSubscriptionInfo(mSubId) != null);
}
@Override
@@ -136,9 +130,10 @@
final Context context = getContext();
FeatureFactory.getFactory(context).getMetricsFeatureProvider()
.action(context, SettingsEnums.ACTION_CELL_DATA_TOGGLE, !mChecked);
- final SubscriptionInfo currentSir = mSubscriptionManager.getActiveSubscriptionInfo(
+ final SubscriptionInfo currentSir = mProxySubscriptionMgr.getActiveSubscriptionInfo(
mSubId);
- final SubscriptionInfo nextSir = mSubscriptionManager.getDefaultDataSubscriptionInfo();
+ final SubscriptionInfo nextSir = mProxySubscriptionMgr.getActiveSubscriptionInfo(
+ SubscriptionManager.getDefaultDataSubscriptionId());
if (mChecked) {
setMobileDataEnabled(false);
if (nextSir != null && currentSir != null
@@ -153,7 +148,7 @@
private void setMobileDataEnabled(boolean enabled) {
if (DataUsageSummary.LOGD) Log.d(TAG, "setMobileDataEnabled(" + enabled + ","
+ mSubId + ")");
- mTelephonyManager.setDataEnabled(mSubId, enabled);
+ getContext().getSystemService(TelephonyManager.class).setDataEnabled(mSubId, enabled);
setChecked(enabled);
}
@@ -166,7 +161,7 @@
@Override
public void onBindViewHolder(PreferenceViewHolder holder) {
super.onBindViewHolder(holder);
- View switchView = holder.findViewById(android.R.id.switch_widget);
+ final View switchView = holder.findViewById(android.R.id.switch_widget);
switchView.setClickable(false);
((Checkable) switchView).setChecked(mChecked);
}
@@ -191,8 +186,10 @@
private void showMultiSimDialog(Builder builder,
DialogInterface.OnClickListener listener) {
- final SubscriptionInfo currentSir = mSubscriptionManager.getActiveSubscriptionInfo(mSubId);
- final SubscriptionInfo nextSir = mSubscriptionManager.getDefaultDataSubscriptionInfo();
+ final SubscriptionInfo currentSir = mProxySubscriptionMgr.getActiveSubscriptionInfo(
+ mSubId);
+ final SubscriptionInfo nextSir = mProxySubscriptionMgr.getActiveSubscriptionInfo(
+ SubscriptionManager.getDefaultDataSubscriptionId());
final String previousName = (nextSir == null)
? getContext().getResources().getString(R.string.sim_selection_required_pref)
@@ -208,14 +205,10 @@
}
private void disableDataForOtherSubscriptions(int subId) {
- List<SubscriptionInfo> subInfoList = mSubscriptionManager
- .getActiveSubscriptionInfoList(true);
- if (subInfoList != null) {
- for (SubscriptionInfo subInfo : subInfoList) {
- if (subInfo.getSubscriptionId() != subId) {
- mTelephonyManager.setDataEnabled(subInfo.getSubscriptionId(), false);
- }
- }
+ final SubscriptionInfo subInfo = mProxySubscriptionMgr.getActiveSubscriptionInfo(
+ subId);
+ if (subInfo != null) {
+ getContext().getSystemService(TelephonyManager.class).setDataEnabled(subId, false);
}
}
@@ -225,7 +218,7 @@
return;
}
if (mMultiSimDialog) {
- mSubscriptionManager.setDefaultDataSubId(mSubId);
+ mProxySubscriptionMgr.get().setDefaultDataSubId(mSubId);
setMobileDataEnabled(true);
disableDataForOtherSubscriptions(mSubId);
} else {
@@ -235,40 +228,23 @@
}
@VisibleForTesting
- final SubscriptionManager.OnSubscriptionsChangedListener mOnSubscriptionsChangeListener
- = new SubscriptionManager.OnSubscriptionsChangedListener() {
- @Override
- public void onSubscriptionsChanged() {
- if (DataUsageSummary.LOGD) {
- Log.d(TAG, "onSubscriptionsChanged");
- }
- updateEnabled();
- }
- };
-
- private final DataStateListener mDataStateListener = new DataStateListener() {
- @Override
- public void onChange(boolean selfChange) {
- updateChecked();
- }
- };
-
- public abstract static class DataStateListener extends ContentObserver {
- public DataStateListener() {
- super(new Handler(Looper.getMainLooper()));
- }
-
- public void setListener(boolean listening, int subId, Context context) {
- if (listening) {
- Uri uri = Global.getUriFor(Global.MOBILE_DATA);
- if (TelephonyManager.getDefault().getSimCount() != 1) {
- uri = Global.getUriFor(Global.MOBILE_DATA + subId);
+ final ProxySubscriptionManager.OnActiveSubscriptionChangedListener
+ mOnSubscriptionsChangeListener =
+ new ProxySubscriptionManager.OnActiveSubscriptionChangedListener() {
+ public void onChanged() {
+ if (DataUsageSummary.LOGD) {
+ Log.d(TAG, "onSubscriptionsChanged");
+ }
+ updateEnabled();
}
- context.getContentResolver().registerContentObserver(uri, false, this);
- } else {
- context.getContentResolver().unregisterContentObserver(this);
- }
- }
+ };
+
+ /**
+ * Implementation of MobileDataEnabledListener.Client
+ */
+ @VisibleForTesting
+ public void onMobileDataEnabledChange() {
+ updateChecked();
}
public static class CellDataState extends BaseSavedState {
diff --git a/src/com/android/settings/datausage/DataUsageList.java b/src/com/android/settings/datausage/DataUsageList.java
index f477ba3..f747951 100644
--- a/src/com/android/settings/datausage/DataUsageList.java
+++ b/src/com/android/settings/datausage/DataUsageList.java
@@ -39,7 +39,6 @@
import android.provider.Settings;
import android.telephony.SubscriptionInfo;
import android.telephony.SubscriptionManager;
-import android.telephony.TelephonyManager;
import android.util.Log;
import android.util.SparseArray;
import android.view.View;
@@ -57,6 +56,8 @@
import com.android.settings.R;
import com.android.settings.core.SubSettingLauncher;
import com.android.settings.datausage.CycleAdapter.SpinnerInterface;
+import com.android.settings.network.MobileDataEnabledListener;
+import com.android.settings.network.ProxySubscriptionManager;
import com.android.settings.widget.LoadingViewController;
import com.android.settingslib.AppItem;
import com.android.settingslib.net.NetworkCycleChartData;
@@ -72,7 +73,8 @@
* Panel showing data usage history across various networks, including options
* to inspect based on usage cycle and control through {@link NetworkPolicy}.
*/
-public class DataUsageList extends DataUsageBaseFragment {
+public class DataUsageList extends DataUsageBaseFragment
+ implements MobileDataEnabledListener.Client {
static final String EXTRA_SUB_ID = "sub_id";
static final String EXTRA_NETWORK_TEMPLATE = "network_template";
@@ -91,13 +93,8 @@
private static final int LOADER_CHART_DATA = 2;
private static final int LOADER_SUMMARY = 3;
- private final CellDataPreference.DataStateListener mDataStateListener =
- new CellDataPreference.DataStateListener() {
- @Override
- public void onChange(boolean selfChange) {
- updatePolicy();
- }
- };
+ @VisibleForTesting
+ MobileDataEnabledListener mDataStateListener;
@VisibleForTesting
NetworkTemplate mTemplate;
@@ -111,7 +108,6 @@
LoadingViewController mLoadingViewController;
private ChartDataUsagePreference mChart;
- private TelephonyManager mTelephonyManager;
private List<NetworkCycleChartData> mCycleData;
private ArrayList<Long> mCycles;
private UidDetailProvider mUidDetailProvider;
@@ -133,14 +129,15 @@
if (!isBandwidthControlEnabled()) {
Log.w(TAG, "No bandwidth control; leaving");
activity.finish();
+ return;
}
mUidDetailProvider = new UidDetailProvider(activity);
- mTelephonyManager = activity.getSystemService(TelephonyManager.class);
mUsageAmount = findPreference(KEY_USAGE_AMOUNT);
mChart = findPreference(KEY_CHART_DATA);
mApps = findPreference(KEY_APPS_GROUP);
processArgument();
+ mDataStateListener = new MobileDataEnabledListener(activity, this);
}
@Override
@@ -190,20 +187,21 @@
@Override
public void onResume() {
super.onResume();
- mDataStateListener.setListener(true, mSubId, getContext());
+ mDataStateListener.start(mSubId);
updateBody();
}
@Override
public void onPause() {
super.onPause();
- mDataStateListener.setListener(false, mSubId, getContext());
+ mDataStateListener.stop();
}
@Override
public void onDestroy() {
mUidDetailProvider.clearCache();
mUidDetailProvider = null;
+ mDataStateListener.stop();
super.onDestroy();
}
@@ -234,6 +232,13 @@
}
/**
+ * Implementation of MobileDataEnabledListener.Client
+ */
+ public void onMobileDataEnabledChange() {
+ updatePolicy();
+ }
+
+ /**
* Update body content based on current tab. Loads network cycle data from system, and
* binds them to visible controls.
*/
@@ -253,7 +258,7 @@
int seriesColor = context.getColor(R.color.sim_noitification);
if (mSubId != SubscriptionManager.INVALID_SUBSCRIPTION_ID) {
- final SubscriptionInfo sir = services.mSubscriptionManager
+ final SubscriptionInfo sir = ProxySubscriptionManager.getInstance(context)
.getActiveSubscriptionInfo(mSubId);
if (sir != null) {
@@ -400,7 +405,7 @@
Collections.sort(items);
for (int i = 0; i < items.size(); i++) {
final int percentTotal = largest != 0 ? (int) (items.get(i).total * 100 / largest) : 0;
- AppDataUsagePreference preference = new AppDataUsagePreference(getContext(),
+ final AppDataUsagePreference preference = new AppDataUsagePreference(getContext(),
items.get(i), percentTotal, mUidDetailProvider);
preference.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
@Override
diff --git a/src/com/android/settings/datausage/DataUsageSummary.java b/src/com/android/settings/datausage/DataUsageSummary.java
index d26fc30..0796e5a 100644
--- a/src/com/android/settings/datausage/DataUsageSummary.java
+++ b/src/com/android/settings/datausage/DataUsageSummary.java
@@ -33,6 +33,7 @@
import androidx.preference.PreferenceScreen;
import com.android.settings.R;
+import com.android.settings.network.ProxySubscriptionManager;
import com.android.settingslib.NetworkPolicyEditor;
import com.android.settingslib.core.AbstractPreferenceController;
@@ -65,6 +66,7 @@
private DataUsageSummaryPreference mSummaryPreference;
private DataUsageSummaryPreferenceController mSummaryController;
private NetworkTemplate mDefaultTemplate;
+ private ProxySubscriptionManager mProxySubscriptionMgr;
@Override
public int getHelpResource() {
@@ -76,6 +78,11 @@
super.onCreate(icicle);
Context context = getContext();
+ // enable ProxySubscriptionMgr with Lifecycle support for all controllers
+ // live within this fragment
+ mProxySubscriptionMgr = ProxySubscriptionManager.getInstance(context);
+ mProxySubscriptionMgr.setLifecycle(getLifecycle());
+
boolean hasMobileData = DataUsageUtils.hasMobileData(context);
final int defaultSubId = SubscriptionManager.getDefaultDataSubscriptionId();
diff --git a/src/com/android/settings/homepage/contextualcards/conditional/ConditionContextualCardRenderer.java b/src/com/android/settings/homepage/contextualcards/conditional/ConditionContextualCardRenderer.java
index 91b2e97..ccfb732 100644
--- a/src/com/android/settings/homepage/contextualcards/conditional/ConditionContextualCardRenderer.java
+++ b/src/com/android/settings/homepage/contextualcards/conditional/ConditionContextualCardRenderer.java
@@ -65,7 +65,7 @@
mContext).getMetricsFeatureProvider();
metricsFeatureProvider.visible(mContext, SettingsEnums.SETTINGS_HOMEPAGE,
- card.getMetricsConstant());
+ card.getMetricsConstant(), 0);
initializePrimaryClick(view, card, metricsFeatureProvider);
initializeView(view, card);
initializeActionButton(view, card, metricsFeatureProvider);
diff --git a/src/com/android/settings/media/MediaOutputSlice.java b/src/com/android/settings/media/MediaOutputSlice.java
index 8086c41..2b70caf 100644
--- a/src/com/android/settings/media/MediaOutputSlice.java
+++ b/src/com/android/settings/media/MediaOutputSlice.java
@@ -164,7 +164,7 @@
intent.putExtra(MEDIA_DEVICE_ID, id);
intent.addFlags(Intent.FLAG_RECEIVER_FOREGROUND);
return PendingIntent.getBroadcast(context, requestCode /* requestCode */, intent,
- PendingIntent.FLAG_CANCEL_CURRENT);
+ PendingIntent.FLAG_UPDATE_CURRENT);
}
@Override
diff --git a/src/com/android/settings/network/ActiveSubsciptionsListener.java b/src/com/android/settings/network/ActiveSubsciptionsListener.java
index 1ed8078..d7a1def 100644
--- a/src/com/android/settings/network/ActiveSubsciptionsListener.java
+++ b/src/com/android/settings/network/ActiveSubsciptionsListener.java
@@ -85,6 +85,7 @@
@VisibleForTesting
BroadcastReceiver mSubscriptionChangeReceiver;
+ private Integer mMaxActiveSubscriptionInfos;
private List<SubscriptionInfo> mCachedActiveSubscriptionInfo;
/**
@@ -126,6 +127,24 @@
}
/**
+ * Get current max. number active subscription info(s) been setup within device
+ *
+ * @return max. number of active subscription info(s)
+ */
+ public int getActiveSubscriptionInfoCountMax() {
+ int count = 0;
+ if (mMaxActiveSubscriptionInfos == null) {
+ count = getSubscriptionManager().getActiveSubscriptionInfoCountMax();
+ if (mIsMonitoringDataChange) {
+ mMaxActiveSubscriptionInfos = count;
+ }
+ } else {
+ count = mMaxActiveSubscriptionInfos.intValue();
+ }
+ return count;
+ }
+
+ /**
* Get a list of active subscription info
*
* @return A list of active subscription info
@@ -134,7 +153,7 @@
if (mIsCachedDataAvailable) {
return mCachedActiveSubscriptionInfo;
}
- mIsCachedDataAvailable = true;
+ mIsCachedDataAvailable = mIsMonitoringDataChange;
mCachedActiveSubscriptionInfo = getSubscriptionManager().getActiveSubscriptionInfoList();
return mCachedActiveSubscriptionInfo;
}
@@ -163,6 +182,7 @@
*/
public void clearCache() {
mIsCachedDataAvailable = false;
+ mMaxActiveSubscriptionInfos = null;
mCachedActiveSubscriptionInfo = null;
}
diff --git a/src/com/android/settings/network/GlobalSettingsChangeListener.java b/src/com/android/settings/network/GlobalSettingsChangeListener.java
index 03103d7..89d374b 100644
--- a/src/com/android/settings/network/GlobalSettingsChangeListener.java
+++ b/src/com/android/settings/network/GlobalSettingsChangeListener.java
@@ -33,7 +33,8 @@
/**
* A listener for Settings.Global configuration change, with support of Lifecycle
*/
-abstract class GlobalSettingsChangeListener extends ContentObserver implements LifecycleObserver {
+public abstract class GlobalSettingsChangeListener extends ContentObserver
+ implements LifecycleObserver, AutoCloseable {
/**
* Constructor
@@ -41,7 +42,7 @@
* @param context of this listener
* @param field field of Global Settings
*/
- GlobalSettingsChangeListener(Context context, String field) {
+ public GlobalSettingsChangeListener(Context context, String field) {
super(new Handler());
mContext = context;
mField = field;
@@ -92,6 +93,13 @@
@OnLifecycleEvent(ON_DESTROY)
void onDestroy() {
+ close();
+ }
+
+ /**
+ * Implementation of AutoCloseable
+ */
+ public void close() {
monitorUri(false);
notifyChangeBasedOn(null);
}
diff --git a/src/com/android/settings/network/MobileDataEnabledListener.java b/src/com/android/settings/network/MobileDataEnabledListener.java
index 8344f88..4c04282 100644
--- a/src/com/android/settings/network/MobileDataEnabledListener.java
+++ b/src/com/android/settings/network/MobileDataEnabledListener.java
@@ -17,53 +17,98 @@
package com.android.settings.network;
import android.content.Context;
-import android.database.ContentObserver;
-import android.net.Uri;
-import android.os.Handler;
import android.provider.Settings;
import android.telephony.SubscriptionManager;
/** Helper class to listen for changes in the enabled state of mobile data. */
-public class MobileDataEnabledListener extends ContentObserver {
+public class MobileDataEnabledListener {
private Context mContext;
private Client mClient;
private int mSubId;
+ /**
+ * There're 2 listeners both activated at the same time.
+ * For project that access MOBILE_DATA, only first listener is functional.
+ * For project that access "MOBILE_DATA + subId", first listener will be stopped when receiving
+ * any onChange from second listener.
+ */
+ private GlobalSettingsChangeListener mListener;
+ private GlobalSettingsChangeListener mListenerForSubId;
public interface Client {
void onMobileDataEnabledChange();
}
+ /**
+ * Constructor
+ *
+ * @param context of this listener
+ * @param client callback when configuration changed
+ */
public MobileDataEnabledListener(Context context, Client client) {
- super(new Handler());
mContext = context;
mClient = client;
mSubId = SubscriptionManager.INVALID_SUBSCRIPTION_ID;
}
- /** Starts listening to changes in the enabled state for data on the given subscription id. */
+ /**
+ * Starts listening to changes in the enabled state for data on the given subscription id.
+ *
+ * @param subId subscription id for enabled state of data subscription
+ */
public void start(int subId) {
mSubId = subId;
- Uri uri;
- if (mSubId == SubscriptionManager.INVALID_SUBSCRIPTION_ID) {
- uri = Settings.Global.getUriFor(Settings.Global.MOBILE_DATA);
- } else {
- uri = Settings.Global.getUriFor(Settings.Global.MOBILE_DATA + mSubId);
+
+ if (mListener == null) {
+ mListener = new GlobalSettingsChangeListener(mContext,
+ Settings.Global.MOBILE_DATA) {
+ public void onChanged(String field) {
+ mClient.onMobileDataEnabledChange();
+ }
+ };
}
- mContext.getContentResolver().registerContentObserver(uri, true /*notifyForDescendants*/,
- this);
+ stopMonitorSubIdSpecific();
+
+ if (mSubId == SubscriptionManager.INVALID_SUBSCRIPTION_ID) {
+ return;
+ }
+
+ mListenerForSubId = new GlobalSettingsChangeListener(mContext,
+ Settings.Global.MOBILE_DATA + mSubId) {
+ public void onChanged(String field) {
+ stopMonitor();
+ mClient.onMobileDataEnabledChange();
+ }
+ };
}
+ /**
+ * Get latest subscription id configured for listening
+ *
+ * @return subscription id
+ */
public int getSubId() {
return mSubId;
}
- public MobileDataEnabledListener stop() {
- mContext.getContentResolver().unregisterContentObserver(this);
- return this;
+ /**
+ * Stop listening to changes in the enabled state for data.
+ */
+ public void stop() {
+ stopMonitor();
+ stopMonitorSubIdSpecific();
}
- @Override
- public void onChange(boolean selfChange) {
- mClient.onMobileDataEnabledChange();
+ private void stopMonitor() {
+ if (mListener != null) {
+ mListener.close();
+ mListener = null;
+ }
+ }
+
+ private void stopMonitorSubIdSpecific() {
+ if (mListenerForSubId != null) {
+ mListenerForSubId.close();
+ mListenerForSubId = null;
+ }
}
}
diff --git a/src/com/android/settings/network/ProxySubscriptionManager.java b/src/com/android/settings/network/ProxySubscriptionManager.java
index ec4fcbe..4e3e717 100644
--- a/src/com/android/settings/network/ProxySubscriptionManager.java
+++ b/src/com/android/settings/network/ProxySubscriptionManager.java
@@ -82,7 +82,6 @@
}
};
- mKeepCacheWhenOnStart = true;
mSubsciptionsMonitor.start();
}
@@ -90,7 +89,6 @@
private Context mContext;
private ActiveSubsciptionsListener mSubsciptionsMonitor;
private GlobalSettingsChangeListener mAirplaneModeMonitor;
- private boolean mKeepCacheWhenOnStart;
private List<OnActiveSubscriptionChangedListener> mActiveSubscriptionsListeners;
@@ -100,6 +98,12 @@
}
}
+ @Override
+ public void onSubscriptionsChanged() {
+ clearCache();
+ notifyAllListeners();
+ }
+
/**
* Lifecycle for data within proxy
*
@@ -118,15 +122,11 @@
@OnLifecycleEvent(ON_START)
void onStart() {
- if (!mKeepCacheWhenOnStart) {
- mSubsciptionsMonitor.clearCache();
- }
mSubsciptionsMonitor.start();
}
@OnLifecycleEvent(ON_STOP)
void onStop() {
- mKeepCacheWhenOnStart = false;
mSubsciptionsMonitor.stop();
}
@@ -152,6 +152,15 @@
}
/**
+ * Get current max. number active subscription info(s) been setup within device
+ *
+ * @return max. number of active subscription info(s)
+ */
+ public int getActiveSubscriptionInfoCountMax() {
+ return mSubsciptionsMonitor.getActiveSubscriptionInfoCountMax();
+ }
+
+ /**
* Get a list of active subscription info
*
* @return A list of active subscription info
@@ -183,6 +192,9 @@
* @param listener listener to active subscriptions change
*/
public void addActiveSubscriptionsListener(OnActiveSubscriptionChangedListener listener) {
+ if (mActiveSubscriptionsListeners.contains(listener)) {
+ return;
+ }
mActiveSubscriptionsListeners.add(listener);
}
diff --git a/src/com/android/settings/notification/BlockPreferenceController.java b/src/com/android/settings/notification/BlockPreferenceController.java
index 27144b8..0dfd38b 100644
--- a/src/com/android/settings/notification/BlockPreferenceController.java
+++ b/src/com/android/settings/notification/BlockPreferenceController.java
@@ -62,8 +62,8 @@
pref.setSelectable(false);
SwitchBar bar = pref.findViewById(R.id.switch_bar);
if (bar != null) {
- bar.setSwitchBarText(R.string.notification_switch_label,
- R.string.notification_switch_label);
+ String switchBarText = getSwitchBarText();
+ bar.setSwitchBarText(switchBarText, switchBarText);
bar.show();
try {
bar.addOnSwitchChangeListener(this);
@@ -125,4 +125,18 @@
}
mImportanceListener.onImportanceChanged();
}
+
+ String getSwitchBarText() {
+ if (mChannel != null) {
+ return mContext.getString(R.string.notification_content_block_title);
+ } else {
+ CharSequence fieldContextName;
+ if (mChannelGroup != null) {
+ fieldContextName = mChannelGroup.getName();
+ } else {
+ fieldContextName = mAppRow.label;
+ }
+ return mContext.getString(R.string.notification_switch_label, fieldContextName);
+ }
+ }
}
diff --git a/src/com/android/settings/notification/ChannelListPreferenceController.java b/src/com/android/settings/notification/ChannelListPreferenceController.java
index 7ff407c..7ea3339 100644
--- a/src/com/android/settings/notification/ChannelListPreferenceController.java
+++ b/src/com/android/settings/notification/ChannelListPreferenceController.java
@@ -156,7 +156,8 @@
NotificationChannelGroup group) {
RestrictedSwitchPreference preference =
new RestrictedSwitchPreference(mContext);
- preference.setTitle(R.string.notification_switch_label);
+ preference.setTitle(mContext.getString(
+ R.string.notification_switch_label, group.getName()));
preference.setEnabled(mAdmin == null
&& isChannelGroupBlockable(group));
preference.setChecked(!group.isBlocked());
diff --git a/src/com/android/settings/notification/RecentNotifyingAppsPreferenceController.java b/src/com/android/settings/notification/RecentNotifyingAppsPreferenceController.java
index 9b20e7a..9efe34e 100644
--- a/src/com/android/settings/notification/RecentNotifyingAppsPreferenceController.java
+++ b/src/com/android/settings/notification/RecentNotifyingAppsPreferenceController.java
@@ -97,7 +97,7 @@
app == null ? null : ApplicationsState.getInstance(app), host);
}
- @VisibleForTesting(otherwise = VisibleForTesting.NONE)
+ @VisibleForTesting(otherwise = VisibleForTesting.PACKAGE_PRIVATE)
RecentNotifyingAppsPreferenceController(Context context, NotificationBackend backend,
IUsageStatsManager usageStatsManager, UserManager userManager,
ApplicationsState appState, Fragment host) {
@@ -118,7 +118,7 @@
@Override
public boolean isAvailable() {
- return true;
+ return mApplicationsState != null;
}
@Override
@@ -307,9 +307,6 @@
if (appEntry == null) {
continue;
}
- if (!shouldIncludePkgInRecents(app.getPackage(), app.getUserId())) {
- continue;
- }
displayableApps.add(app);
count++;
if (count >= SHOW_RECENT_APP_COUNT) {
@@ -318,24 +315,4 @@
}
return displayableApps;
}
-
-
- /**
- * Whether or not the app should be included in recent list.
- */
- private boolean shouldIncludePkgInRecents(String pkgName, int userId) {
- final Intent launchIntent = new Intent().addCategory(Intent.CATEGORY_LAUNCHER)
- .setPackage(pkgName);
-
- if (mPm.resolveActivity(launchIntent, 0) == null) {
- // Not visible on launcher -> likely not a user visible app, skip if non-instant.
- final ApplicationsState.AppEntry appEntry =
- mApplicationsState.getEntry(pkgName, userId);
- if (appEntry == null || appEntry.info == null || !AppUtils.isInstant(appEntry.info)) {
- Log.d(TAG, "Not a user visible or instant app, skipping " + pkgName);
- return false;
- }
- }
- return true;
- }
}
diff --git a/src/com/android/settings/security/ScreenPinningSettings.java b/src/com/android/settings/security/ScreenPinningSettings.java
index 849db40..aa3e862 100644
--- a/src/com/android/settings/security/ScreenPinningSettings.java
+++ b/src/com/android/settings/security/ScreenPinningSettings.java
@@ -23,9 +23,6 @@
import android.os.UserHandle;
import android.provider.SearchIndexableResource;
import android.provider.Settings;
-import android.view.LayoutInflater;
-import android.view.View;
-import android.view.ViewGroup;
import android.widget.Switch;
import androidx.preference.Preference;
@@ -41,6 +38,7 @@
import com.android.settings.search.BaseSearchIndexProvider;
import com.android.settings.widget.SwitchBar;
import com.android.settingslib.search.SearchIndexable;
+import com.android.settingslib.widget.FooterPreference;
import java.util.Arrays;
import java.util.List;
@@ -52,11 +50,13 @@
public class ScreenPinningSettings extends SettingsPreferenceFragment
implements SwitchBar.OnSwitchChangeListener {
- private static final CharSequence KEY_USE_SCREEN_LOCK = "use_screen_lock";
+ private static final String KEY_USE_SCREEN_LOCK = "use_screen_lock";
+ private static final String KEY_FOOTER = "screen_pinning_settings_screen_footer";
private static final int CHANGE_LOCK_METHOD_REQUEST = 43;
private SwitchBar mSwitchBar;
private SwitchPreference mUseScreenLock;
+ private FooterPreference mFooterPreference;
private LockPatternUtils mLockPatternUtils;
@Override
@@ -77,6 +77,13 @@
mSwitchBar.addOnSwitchChangeListener(this);
mSwitchBar.show();
mSwitchBar.setChecked(isLockToAppEnabled(getActivity()));
+
+ addPreferencesFromResource(R.xml.screen_pinning_settings);
+
+ final PreferenceScreen root = getPreferenceScreen();
+ mUseScreenLock = root.findPreference(KEY_USE_SCREEN_LOCK);
+ mFooterPreference = root.findPreference(KEY_FOOTER);
+ updateDisplay();
}
@Override
@@ -85,16 +92,6 @@
}
@Override
- public void onViewCreated(View view, Bundle savedInstanceState) {
- super.onViewCreated(view, savedInstanceState);
- ViewGroup parent = (ViewGroup) view.findViewById(android.R.id.list_container);
- View emptyView = LayoutInflater.from(getContext())
- .inflate(R.layout.screen_pinning_instructions, parent, false);
- parent.addView(emptyView);
- setEmptyView(emptyView);
- }
-
- @Override
public void onDestroyView() {
super.onDestroyView();
@@ -192,16 +189,10 @@
updateDisplay();
}
- public void updateDisplay() {
- PreferenceScreen root = getPreferenceScreen();
- if (root != null) {
- root.removeAll();
- }
+ private void updateDisplay() {
if (isLockToAppEnabled(getActivity())) {
- addPreferencesFromResource(R.xml.screen_pinning_settings);
- root = getPreferenceScreen();
-
- mUseScreenLock = (SwitchPreference) root.findPreference(KEY_USE_SCREEN_LOCK);
+ mFooterPreference.setVisible(false);
+ mUseScreenLock.setVisible(true);
mUseScreenLock.setOnPreferenceChangeListener(new OnPreferenceChangeListener() {
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
@@ -210,6 +201,9 @@
});
mUseScreenLock.setChecked(isScreenLockUsed());
mUseScreenLock.setTitle(getCurrentSecurityTitle());
+ } else {
+ mFooterPreference.setVisible(true);
+ mUseScreenLock.setVisible(false);
}
}
diff --git a/tests/robotests/src/com/android/settings/bluetooth/UtilsTest.java b/tests/robotests/src/com/android/settings/bluetooth/UtilsTest.java
index 1920019..25808b5 100644
--- a/tests/robotests/src/com/android/settings/bluetooth/UtilsTest.java
+++ b/tests/robotests/src/com/android/settings/bluetooth/UtilsTest.java
@@ -15,8 +15,6 @@
*/
package com.android.settings.bluetooth;
-import static com.google.common.truth.Truth.assertThat;
-
import static org.mockito.ArgumentMatchers.anyInt;
import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.ArgumentMatchers.eq;
@@ -24,7 +22,6 @@
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
-import android.bluetooth.BluetoothDevice;
import android.content.Context;
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
@@ -61,6 +58,6 @@
Utils.showConnectingError(mContext, "testName", mock(LocalBluetoothManager.class));
verify(mMetricsFeatureProvider).visible(eq(mContext), anyInt(),
- eq(MetricsEvent.ACTION_SETTINGS_BLUETOOTH_CONNECT_ERROR));
+ eq(MetricsEvent.ACTION_SETTINGS_BLUETOOTH_CONNECT_ERROR), anyInt());
}
}
diff --git a/tests/robotests/src/com/android/settings/core/instrumentation/SettingsEventLogWriterTest.java b/tests/robotests/src/com/android/settings/core/instrumentation/SettingsEventLogWriterTest.java
index ba2553d..8f22df0 100644
--- a/tests/robotests/src/com/android/settings/core/instrumentation/SettingsEventLogWriterTest.java
+++ b/tests/robotests/src/com/android/settings/core/instrumentation/SettingsEventLogWriterTest.java
@@ -62,7 +62,7 @@
SettingsUIDeviceConfig.GENERIC_EVENT_LOGGING_ENABLED, "true", true);
mWriter.visible(RuntimeEnvironment.application, SettingsEnums.PAGE_UNKNOWN,
- SettingsEnums.SETTINGS_HOMEPAGE);
+ SettingsEnums.SETTINGS_HOMEPAGE, 0);
assertThat(ShadowMetricsLogger.sActionLoggedCount).isEqualTo(1);
}
@@ -83,7 +83,7 @@
SettingsUIDeviceConfig.GENERIC_EVENT_LOGGING_ENABLED, "false", true);
mWriter.visible(RuntimeEnvironment.application, SettingsEnums.PAGE_UNKNOWN,
- SettingsEnums.SETTINGS_HOMEPAGE);
+ SettingsEnums.SETTINGS_HOMEPAGE, 0);
assertThat(ShadowMetricsLogger.sActionLoggedCount).isEqualTo(0);
}
diff --git a/tests/robotests/src/com/android/settings/datausage/CellDataPreferenceTest.java b/tests/robotests/src/com/android/settings/datausage/CellDataPreferenceTest.java
index 9b14e19..0b8ebbf 100644
--- a/tests/robotests/src/com/android/settings/datausage/CellDataPreferenceTest.java
+++ b/tests/robotests/src/com/android/settings/datausage/CellDataPreferenceTest.java
@@ -18,17 +18,18 @@
import static com.google.common.truth.Truth.assertThat;
import static org.mockito.ArgumentMatchers.anyInt;
-import static org.mockito.Mockito.when;
+import static org.mockito.Mockito.doReturn;
import android.content.Context;
import android.telephony.SubscriptionInfo;
-import android.telephony.SubscriptionManager;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.LinearLayout;
import androidx.preference.PreferenceViewHolder;
+import com.android.settings.network.ProxySubscriptionManager;
+
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -41,14 +42,13 @@
public class CellDataPreferenceTest {
@Mock
- private SubscriptionManager mSubscriptionManager;
+ private ProxySubscriptionManager mProxySubscriptionMgr;
@Mock
private SubscriptionInfo mSubInfo;
private Context mContext;
private PreferenceViewHolder mHolder;
private CellDataPreference mPreference;
- private SubscriptionManager.OnSubscriptionsChangedListener mListener;
@Before
public void setUp() {
@@ -56,9 +56,9 @@
mContext = RuntimeEnvironment.application;
mPreference = new CellDataPreference(mContext, null);
- mListener = mPreference.mOnSubscriptionsChangeListener;
+ mPreference.mProxySubscriptionMgr = mProxySubscriptionMgr;
- LayoutInflater inflater = LayoutInflater.from(mContext);
+ final LayoutInflater inflater = LayoutInflater.from(mContext);
final View view = inflater.inflate(mPreference.getLayoutResource(),
new LinearLayout(mContext), false);
@@ -67,12 +67,15 @@
@Test
public void noActiveSub_shouldDisable() {
- mPreference.mSubscriptionManager = mSubscriptionManager;
- mListener.onSubscriptionsChanged();
+ doReturn(null).when(mProxySubscriptionMgr).getActiveSubscriptionInfo(anyInt());
+ mPreference.mOnSubscriptionsChangeListener.onChanged();
assertThat(mPreference.isEnabled()).isFalse();
+ }
- when(mSubscriptionManager.getActiveSubscriptionInfo(anyInt())).thenReturn(mSubInfo);
- mListener.onSubscriptionsChanged();
+ @Test
+ public void hasActiveSub_shouldEnable() {
+ doReturn(mSubInfo).when(mProxySubscriptionMgr).getActiveSubscriptionInfo(anyInt());
+ mPreference.mOnSubscriptionsChangeListener.onChanged();
assertThat(mPreference.isEnabled()).isTrue();
}
}
diff --git a/tests/robotests/src/com/android/settings/datausage/DataUsageListTest.java b/tests/robotests/src/com/android/settings/datausage/DataUsageListTest.java
index 9aa1c6f..6894d38 100644
--- a/tests/robotests/src/com/android/settings/datausage/DataUsageListTest.java
+++ b/tests/robotests/src/com/android/settings/datausage/DataUsageListTest.java
@@ -42,6 +42,7 @@
import com.android.settings.R;
import com.android.settings.SettingsActivity;
+import com.android.settings.network.MobileDataEnabledListener;
import com.android.settings.testutils.FakeFeatureFactory;
import com.android.settings.widget.LoadingViewController;
import com.android.settingslib.AppItem;
@@ -67,7 +68,7 @@
public class DataUsageListTest {
@Mock
- private CellDataPreference.DataStateListener mListener;
+ private MobileDataEnabledListener mMobileDataEnabledListener;
@Mock
private TemplatePreference.NetworkServices mNetworkServices;
@@ -83,9 +84,11 @@
mActivity = spy(mActivityController.get());
mNetworkServices.mPolicyEditor = mock(NetworkPolicyEditor.class);
mDataUsageList = spy(DataUsageList.class);
+ mDataUsageList.mDataStateListener = mMobileDataEnabledListener;
doReturn(mActivity).when(mDataUsageList).getContext();
- ReflectionHelpers.setField(mDataUsageList, "mDataStateListener", mListener);
+ ReflectionHelpers.setField(mDataUsageList, "mDataStateListener",
+ mMobileDataEnabledListener);
ReflectionHelpers.setField(mDataUsageList, "services", mNetworkServices);
}
@@ -98,11 +101,11 @@
mDataUsageList.onResume();
- verify(mListener).setListener(true, mDataUsageList.mSubId, mActivity);
+ verify(mMobileDataEnabledListener).start(anyInt());
mDataUsageList.onPause();
- verify(mListener).setListener(false, mDataUsageList.mSubId, mActivity);
+ verify(mMobileDataEnabledListener).stop();
}
@Test
diff --git a/tests/robotests/src/com/android/settings/datausage/DataUsageUtilsTest.java b/tests/robotests/src/com/android/settings/datausage/DataUsageUtilsTest.java
index aa5db22..fe02cb1 100644
--- a/tests/robotests/src/com/android/settings/datausage/DataUsageUtilsTest.java
+++ b/tests/robotests/src/com/android/settings/datausage/DataUsageUtilsTest.java
@@ -54,7 +54,7 @@
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
- ShadowApplication shadowContext = ShadowApplication.getInstance();
+ final ShadowApplication shadowContext = ShadowApplication.getInstance();
mContext = RuntimeEnvironment.application;
shadowContext.setSystemService(Context.CONNECTIVITY_SERVICE, mManager);
shadowContext.setSystemService(Context.TELEPHONY_SERVICE, mTelephonyManager);
@@ -64,28 +64,28 @@
@Test
public void mobileDataStatus_whenNetworkIsSupported() {
when(mManager.isNetworkSupported(anyInt())).thenReturn(true);
- boolean hasMobileData = DataUsageUtils.hasMobileData(mContext);
+ final boolean hasMobileData = DataUsageUtils.hasMobileData(mContext);
assertThat(hasMobileData).isTrue();
}
@Test
public void mobileDataStatus_whenNetworkIsNotSupported() {
when(mManager.isNetworkSupported(anyInt())).thenReturn(false);
- boolean hasMobileData = DataUsageUtils.hasMobileData(mContext);
+ final boolean hasMobileData = DataUsageUtils.hasMobileData(mContext);
assertThat(hasMobileData).isFalse();
}
@Test
public void hasSim_simStateReady() {
when(mTelephonyManager.getSimState()).thenReturn(TelephonyManager.SIM_STATE_READY);
- boolean hasSim = DataUsageUtils.hasSim(mContext);
+ final boolean hasSim = DataUsageUtils.hasSim(mContext);
assertThat(hasSim).isTrue();
}
@Test
public void hasSim_simStateMissing() {
when(mTelephonyManager.getSimState()).thenReturn(TelephonyManager.SIM_STATE_ABSENT);
- boolean hasSim = DataUsageUtils.hasSim(mContext);
+ final boolean hasSim = DataUsageUtils.hasSim(mContext);
assertThat(hasSim).isFalse();
}