From 87212cf504da083e76ecca6a2d6eef3037efd3c2 Mon Sep 17 00:00:00 2001 From: Arc Wang Date: Tue, 10 May 2022 16:04:56 +0800 Subject: [PATCH 01/11] Storage Settings crash Storage settings will crash because there is no emulated primary volume found after private internal volume is Ejected. Below change in Settings impacted Storage dashboard screen behavior as it Query storage size instead of calculate size of installed APP. Due to this design change now MediaProvider is queried for file sizes, but due to unmounting of primary emulated volume it crashes. We should not show Eject option for private Internal volume. Author: ramneek.kalra@mediatek.com Bug: 230689829 Test: atest com.android.settings.deviceinfo.VolumeOptionMenuControllerTest manual 1. Insert sdcard or generate virtual disk using command : adb shell "sm set-virtual-disk true" 2. Go to Settings -> Storage -> Sdcard/virtual disk -> Format as Internal -> do migrate data 3. After above process completed, go to Settings-> Storage -> sd card/virtual disk and chose Eject menu option. 4. Eject page gets open, Click on Eject button. Change-Id: I98d09f75ee7c2cd5aae10808bd0e0cdf10da7582 --- .../android/settings/deviceinfo/VolumeOptionMenuController.java | 1 - .../settings/deviceinfo/VolumeOptionMenuControllerTest.java | 1 - 2 files changed, 2 deletions(-) diff --git a/src/com/android/settings/deviceinfo/VolumeOptionMenuController.java b/src/com/android/settings/deviceinfo/VolumeOptionMenuController.java index d4f93fa83cd..42a3a16da3e 100644 --- a/src/com/android/settings/deviceinfo/VolumeOptionMenuController.java +++ b/src/com/android/settings/deviceinfo/VolumeOptionMenuController.java @@ -132,7 +132,6 @@ public class VolumeOptionMenuController implements LifecycleObserver, OnCreateOp if (mStorageEntry.isPrivate()) { if (!mStorageEntry.isDefaultInternalStorage()) { mRename.setVisible(true); - mUnmount.setVisible(true); mFormatAsPortable.setVisible(true); } diff --git a/tests/unit/src/com/android/settings/deviceinfo/VolumeOptionMenuControllerTest.java b/tests/unit/src/com/android/settings/deviceinfo/VolumeOptionMenuControllerTest.java index 314f8c22138..8bd9b018d18 100644 --- a/tests/unit/src/com/android/settings/deviceinfo/VolumeOptionMenuControllerTest.java +++ b/tests/unit/src/com/android/settings/deviceinfo/VolumeOptionMenuControllerTest.java @@ -142,7 +142,6 @@ public class VolumeOptionMenuControllerTest { mController.onPrepareOptionsMenu(mMenu); verify(mController.mRename, atLeastOnce()).setVisible(true); - verify(mController.mUnmount, atLeastOnce()).setVisible(true); verify(mController.mFormatAsPortable, atLeastOnce()).setVisible(true); verify(mController.mMount, never()).setVisible(true); verify(mController.mFormat, never()).setVisible(true); From 85db3167e256a343a89c21fe7dfe1a500bb98d5a Mon Sep 17 00:00:00 2001 From: "James.cf Lin" Date: Wed, 11 May 2022 12:05:17 +0800 Subject: [PATCH 02/11] [Panlingual] Remove the warning message from AppLocaleDetails Since opt-in is enabled and it will only display locales that are available or downloadable, there is no longer a need to display the warning message to users. Bug: 228923650 Test: manual test Change-Id: Ibd98f3a292eb09c921f4bf00dbf448c976927e5d --- res/drawable/ic_error_outline.xml | 28 ------------ res/values/strings.xml | 9 ---- res/xml/app_locale_details.xml | 7 --- .../appinfo/AppLocaleDetails.java | 43 ------------------- 4 files changed, 87 deletions(-) delete mode 100644 res/drawable/ic_error_outline.xml diff --git a/res/drawable/ic_error_outline.xml b/res/drawable/ic_error_outline.xml deleted file mode 100644 index 2ddc6d4d501..00000000000 --- a/res/drawable/ic_error_outline.xml +++ /dev/null @@ -1,28 +0,0 @@ - - - - - \ No newline at end of file diff --git a/res/values/strings.xml b/res/values/strings.xml index 81303b0654d..a8e37dbc871 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -500,15 +500,6 @@ App Language - - Update the app - - - You need to update the app for the latest available languages - - - Update now - Suggested languages diff --git a/res/xml/app_locale_details.xml b/res/xml/app_locale_details.xml index e01db2f9389..f849441b03f 100644 --- a/res/xml/app_locale_details.xml +++ b/res/xml/app_locale_details.xml @@ -24,13 +24,6 @@ android:title="@string/desc_app_locale_disclaimer" android:order="1"/> - - Help & feedback - Help articles, phone & chat + Help articles, phone & chat + + Help articles, tablet & chat + + Help articles, device & chat From 2011588b165ff81f07203cc86773b28baacced83 Mon Sep 17 00:00:00 2001 From: Julia Reynolds Date: Tue, 10 May 2022 16:42:37 -0400 Subject: [PATCH 06/11] Use NMS calculation of fixed importance Rather than recalculating it again. Also align logic on listing and details pages. Test: NotificationBackendTest, NotificationPreferenceControllerTest Bug: 231662091 Fixes: 231815850 Change-Id: If9572766666620008afb839ecb0828ace8d6073d --- .../notification/NotificationBackend.java | 42 ++-------- .../app/NotificationPreferenceController.java | 4 +- .../app/NotificationSettings.java | 5 +- .../notification/NotificationBackendTest.java | 84 ++----------------- .../NotificationPreferenceControllerTest.java | 20 ++++- 5 files changed, 35 insertions(+), 120 deletions(-) diff --git a/src/com/android/settings/notification/NotificationBackend.java b/src/com/android/settings/notification/NotificationBackend.java index 5215a33fcc4..150dbe0483d 100644 --- a/src/com/android/settings/notification/NotificationBackend.java +++ b/src/com/android/settings/notification/NotificationBackend.java @@ -106,29 +106,20 @@ public class NotificationBackend { return row; } - public AppRow loadAppRow(Context context, PackageManager pm, - RoleManager roleManager, PackageInfo app) { + public AppRow loadAppRow(Context context, PackageManager pm, PackageInfo app) { final AppRow row = loadAppRow(context, pm, app.applicationInfo); - recordCanBeBlocked(context, pm, roleManager, app, row); + recordCanBeBlocked(app, row); return row; } - void recordCanBeBlocked(Context context, PackageManager pm, RoleManager rm, PackageInfo app, - AppRow row) { - + void recordCanBeBlocked(PackageInfo app, AppRow row) { try { row.systemApp = row.lockedImportance = - sINM.isPermissionFixed(app.packageName, row.userId); + sINM.isImportanceLocked(app.packageName, app.applicationInfo.uid); } catch (RemoteException e) { Log.w(TAG, "Error calling NMS", e); } - // The permission system cannot make role permissions 'fixed', so check for these - // roles explicitly - List roles = rm.getHeldRolesFromController(app.packageName); - if (roles.contains(RoleManager.ROLE_DIALER) - || roles.contains(RoleManager.ROLE_EMERGENCY)) { - row.systemApp = row.lockedImportance = true; - } + // if the app targets T but has not requested the permission, we cannot change the // permission state if (app.applicationInfo.targetSdkVersion > Build.VERSION_CODES.S_V2) { @@ -139,24 +130,6 @@ public class NotificationBackend { } } - @VisibleForTesting static void markAppRowWithBlockables(String[] nonBlockablePkgs, AppRow row, - String packageName) { - if (nonBlockablePkgs != null) { - int N = nonBlockablePkgs.length; - for (int i = 0; i < N; i++) { - String pkg = nonBlockablePkgs[i]; - if (pkg == null) { - continue; - } else if (pkg.contains(":")) { - // handled by NotificationChannel.isImportanceLockedByOEM() - continue; - } else if (packageName.equals(nonBlockablePkgs[i])) { - row.systemApp = row.lockedImportance = true; - } - } - } - } - static public CharSequence getDeviceList(ICompanionDeviceManager cdm, LocalBluetoothManager lbm, String pkg, int userId) { boolean multiple = false; @@ -191,10 +164,9 @@ public class NotificationBackend { public boolean enableSwitch(Context context, ApplicationInfo app) { try { PackageInfo info = context.getPackageManager().getPackageInfo( - app.packageName, PackageManager.GET_SIGNATURES); - RoleManager rm = context.getSystemService(RoleManager.class); + app.packageName, PackageManager.GET_PERMISSIONS); final AppRow row = new AppRow(); - recordCanBeBlocked(context, context.getPackageManager(), rm, info, row); + recordCanBeBlocked(info, row); boolean systemBlockable = !row.systemApp || (row.systemApp && row.banned); return systemBlockable && !row.lockedImportance; } catch (PackageManager.NameNotFoundException e) { diff --git a/src/com/android/settings/notification/app/NotificationPreferenceController.java b/src/com/android/settings/notification/app/NotificationPreferenceController.java index 9d339f02737..fb19d9d6b4c 100644 --- a/src/com/android/settings/notification/app/NotificationPreferenceController.java +++ b/src/com/android/settings/notification/app/NotificationPreferenceController.java @@ -24,6 +24,7 @@ import android.app.NotificationChannel; import android.app.NotificationChannelGroup; import android.app.NotificationManager; import android.content.Context; +import android.content.pm.ApplicationInfo; import android.content.pm.PackageManager; import android.content.pm.ShortcutInfo; import android.graphics.drawable.Drawable; @@ -171,7 +172,8 @@ public abstract class NotificationPreferenceController extends AbstractPreferenc return overrideCanConfigureValue; } if (mAppRow != null) { - return !mAppRow.systemApp && !mAppRow.lockedImportance; + boolean systemBlockable = !mAppRow.systemApp || (mAppRow.systemApp && mAppRow.banned); + return systemBlockable && !mAppRow.lockedImportance; } return true; } diff --git a/src/com/android/settings/notification/app/NotificationSettings.java b/src/com/android/settings/notification/app/NotificationSettings.java index afc9a66716d..192a0ee9fc7 100644 --- a/src/com/android/settings/notification/app/NotificationSettings.java +++ b/src/com/android/settings/notification/app/NotificationSettings.java @@ -25,7 +25,6 @@ import android.app.Notification; import android.app.NotificationChannel; import android.app.NotificationChannelGroup; import android.app.NotificationManager; -import android.app.role.RoleManager; import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; @@ -69,7 +68,6 @@ abstract public class NotificationSettings extends DashboardFragment { protected PackageManager mPm; protected NotificationBackend mBackend = new NotificationBackend(); protected NotificationManager mNm; - protected RoleManager mRm; protected Context mContext; protected int mUid; @@ -116,7 +114,6 @@ abstract public class NotificationSettings extends DashboardFragment { mPm = getPackageManager(); mNm = NotificationManager.from(mContext); - mRm = mContext.getSystemService(RoleManager.class); mPkg = mArgs != null && mArgs.containsKey(AppInfoBase.ARG_PACKAGE_NAME) ? mArgs.getString(AppInfoBase.ARG_PACKAGE_NAME) @@ -290,7 +287,7 @@ abstract public class NotificationSettings extends DashboardFragment { } private void loadAppRow() { - mAppRow = mBackend.loadAppRow(mContext, mPm, mRm, mPkgInfo); + mAppRow = mBackend.loadAppRow(mContext, mPm, mPkgInfo); } private void loadChannelGroup() { diff --git a/tests/robotests/src/com/android/settings/notification/NotificationBackendTest.java b/tests/robotests/src/com/android/settings/notification/NotificationBackendTest.java index 5745aa0718d..764962fa3b2 100644 --- a/tests/robotests/src/com/android/settings/notification/NotificationBackendTest.java +++ b/tests/robotests/src/com/android/settings/notification/NotificationBackendTest.java @@ -20,6 +20,7 @@ import static com.google.common.truth.Truth.assertThat; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; +import static org.mockito.ArgumentMatchers.anyInt; import static org.mockito.ArgumentMatchers.anyString; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; @@ -80,69 +81,17 @@ public class NotificationBackendTest { } @Test - public void testMarkAppRow_unblockablePackage() { - AppRow appRow = new AppRow(); - String packageName = "foo.bar.unblockable"; - appRow.pkg = packageName; - String[] nonBlockablePkgs = new String[2]; - nonBlockablePkgs[0] = packageName; - nonBlockablePkgs[1] = "some.other.package"; - NotificationBackend.markAppRowWithBlockables(nonBlockablePkgs, appRow, packageName); - - // This package has a package lock but no locked channels - assertTrue(appRow.lockedImportance); - } - - @Test - public void testMarkAppRow_defaultPackage() { - PackageInfo pi = new PackageInfo(); - pi.packageName = "test"; - pi.applicationInfo = new ApplicationInfo(); - pi.applicationInfo.packageName = "test"; - List roles = new ArrayList<>(); - roles.add(RoleManager.ROLE_DIALER); - RoleManager rm = mock(RoleManager.class); - when(rm.getHeldRolesFromController(anyString())).thenReturn(roles); - - AppRow appRow = new NotificationBackend().loadAppRow(RuntimeEnvironment.application, - mock(PackageManager.class), rm, pi); - - assertTrue(appRow.systemApp); - } - - @Test - public void testMarkAppRow_fixedPermission_withRole() throws Exception { + public void testMarkAppRow_fixedImportance() throws Exception { PackageInfo pi = new PackageInfo(); pi.packageName = "test"; pi.applicationInfo = new ApplicationInfo(); pi.applicationInfo.packageName = "test"; pi.applicationInfo.uid = 123; - List roles = new ArrayList<>(); - roles.add(RoleManager.ROLE_DIALER); - RoleManager rm = mock(RoleManager.class); - when(rm.getHeldRolesFromController(anyString())).thenReturn(roles); - when(mInm.isPermissionFixed(pi.packageName, 0)).thenReturn(false); + when(mInm.isImportanceLocked(pi.packageName, 123)).thenReturn(true); AppRow appRow = new NotificationBackend().loadAppRow(RuntimeEnvironment.application, - mock(PackageManager.class), rm, pi); - - assertTrue(appRow.systemApp); - assertTrue(appRow.lockedImportance); - } - - @Test - public void testMarkAppRow_fixedPermission() throws Exception { - PackageInfo pi = new PackageInfo(); - pi.packageName = "test"; - pi.applicationInfo = new ApplicationInfo(); - pi.applicationInfo.packageName = "test"; - pi.applicationInfo.uid = 123; - - when(mInm.isPermissionFixed(pi.packageName, 0)).thenReturn(true); - - AppRow appRow = new NotificationBackend().loadAppRow(RuntimeEnvironment.application, - mock(PackageManager.class), mock(RoleManager.class), pi); + mock(PackageManager.class), pi); assertTrue(appRow.systemApp); assertTrue(appRow.lockedImportance); @@ -156,10 +105,10 @@ public class NotificationBackendTest { pi.applicationInfo.packageName = "test"; pi.applicationInfo.uid = 123; - when(mInm.isPermissionFixed(pi.packageName, 0)).thenReturn(false); + when(mInm.isImportanceLocked(anyString(), anyInt())).thenReturn(false); AppRow appRow = new NotificationBackend().loadAppRow(RuntimeEnvironment.application, - mock(PackageManager.class), mock(RoleManager.class), pi); + mock(PackageManager.class), pi); assertFalse(appRow.systemApp); assertFalse(appRow.lockedImportance); @@ -178,7 +127,7 @@ public class NotificationBackendTest { when(mInm.isPermissionFixed(pi.packageName, 0)).thenReturn(false); AppRow appRow = new NotificationBackend().loadAppRow(RuntimeEnvironment.application, - mock(PackageManager.class), mock(RoleManager.class), pi); + mock(PackageManager.class), pi); assertFalse(appRow.systemApp); assertTrue(appRow.lockedImportance); @@ -198,29 +147,12 @@ public class NotificationBackendTest { when(mInm.isPermissionFixed(pi.packageName, 0)).thenReturn(false); AppRow appRow = new NotificationBackend().loadAppRow(RuntimeEnvironment.application, - mock(PackageManager.class), mock(RoleManager.class), pi); + mock(PackageManager.class), pi); assertFalse(appRow.systemApp); assertFalse(appRow.lockedImportance); } - @Test - public void testMarkAppRow_notDefaultPackage() { - PackageInfo pi = new PackageInfo(); - pi.packageName = "test"; - pi.applicationInfo = new ApplicationInfo(); - pi.applicationInfo.packageName = "test"; - List roles = new ArrayList<>(); - roles.add(RoleManager.ROLE_HOME); - RoleManager rm = mock(RoleManager.class); - when(rm.getHeldRolesFromController(anyString())).thenReturn(roles); - - AppRow appRow = new NotificationBackend().loadAppRow(RuntimeEnvironment.application, - mock(PackageManager.class), rm, pi); - - assertFalse(appRow.systemApp); - } - @Test public void testGetAggregatedUsageEvents_multipleEventsAgg() { List events = new ArrayList<>(); diff --git a/tests/robotests/src/com/android/settings/notification/app/NotificationPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/notification/app/NotificationPreferenceControllerTest.java index 4ba5fe7f644..b2f1673f317 100644 --- a/tests/robotests/src/com/android/settings/notification/app/NotificationPreferenceControllerTest.java +++ b/tests/robotests/src/com/android/settings/notification/app/NotificationPreferenceControllerTest.java @@ -284,24 +284,36 @@ public class NotificationPreferenceControllerTest { } @Test - public void testIsAppBlockable_postMigration_locked() { + public void testIsAppBlockable_fixedPermission() { mController = new TestPreferenceController(mContext, mBackend); NotificationBackend.AppRow appRow = new NotificationBackend.AppRow(); - appRow.lockedImportance = true; + appRow.systemApp = true; appRow.banned = false; mController.onResume(appRow, null, null, null, null, null, null); assertFalse(mController.isAppBlockable()); } @Test - public void testIsAppBlockable_postMigration_locked_butAppOff() { + public void testIsAppBlockable_fixedPermission_butAppOff() { mController = new TestPreferenceController(mContext, mBackend); NotificationBackend.AppRow appRow = new NotificationBackend.AppRow(); - appRow.lockedImportance = true; + appRow.systemApp = true; appRow.banned = true; mController.onResume(appRow, null, null, null, null, null, null); + assertTrue(mController.isAppBlockable()); + } + + @Test + public void testIsAppBlockable_notFixedButAppInBadState() { + mController = new TestPreferenceController(mContext, mBackend); + + NotificationBackend.AppRow appRow = new NotificationBackend.AppRow(); + appRow.systemApp = false; + appRow.banned = true; + appRow.lockedImportance = true; + mController.onResume(appRow, null, null, null, null, null, null); assertFalse(mController.isAppBlockable()); } From 89f48dce823dbee8721d73cff3db029999c3c6b9 Mon Sep 17 00:00:00 2001 From: tom hsu Date: Thu, 12 May 2022 01:50:13 +0800 Subject: [PATCH 07/11] [Panlingual] Fix shall not show app with empty LocaleConfig. Bug: b/231990625 Test: local Change-Id: Ia4747b777ee5228b57c0293d366c77e91ae5bee0 --- src/com/android/settings/applications/AppLocaleUtil.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/com/android/settings/applications/AppLocaleUtil.java b/src/com/android/settings/applications/AppLocaleUtil.java index 77fba89e861..31357968a07 100644 --- a/src/com/android/settings/applications/AppLocaleUtil.java +++ b/src/com/android/settings/applications/AppLocaleUtil.java @@ -99,7 +99,8 @@ public class AppLocaleUtil { * Check the function of per app language is supported by current application. */ public static boolean isAppLocaleSupported(Context context, String packageName) { - if (getPackageLocales(context, packageName) != null) { + LocaleList localeList = getPackageLocales(context, packageName); + if (localeList != null && localeList.size() > 0) { return true; } From f29a071fca50c579992a81004a666e50e8083915 Mon Sep 17 00:00:00 2001 From: Lifu Tang Date: Wed, 11 May 2022 14:49:19 -0700 Subject: [PATCH 08/11] Cache summary text to avoid flickering Bug: 231927706 Test: build, flash, run unit test, then test manually. Change-Id: Ia0585302c5cf86cd6035315fa750c71b9df55237 --- .../TopLevelLocationPreferenceController.java | 16 ++++++------ ...LevelLocationPreferenceControllerTest.java | 26 +++++++++++++------ 2 files changed, 26 insertions(+), 16 deletions(-) diff --git a/src/com/android/settings/location/TopLevelLocationPreferenceController.java b/src/com/android/settings/location/TopLevelLocationPreferenceController.java index ec58a3422d2..5effe6c6210 100644 --- a/src/com/android/settings/location/TopLevelLocationPreferenceController.java +++ b/src/com/android/settings/location/TopLevelLocationPreferenceController.java @@ -31,9 +31,9 @@ public class TopLevelLocationPreferenceController extends BasePreferenceControll private static final IntentFilter INTENT_FILTER_LOCATION_MODE_CHANGED = new IntentFilter(LocationManager.MODE_CHANGED_ACTION); private final LocationManager mLocationManager; - /** Total number of apps that has location permission. */ - private int mNumTotal = -1; private int mNumTotalLoading = 0; + /** Summary text. */ + private static String sSummary = null; private BroadcastReceiver mReceiver; private Preference mPreference; private AtomicInteger loadingInProgress = new AtomicInteger(0); @@ -51,12 +51,11 @@ public class TopLevelLocationPreferenceController extends BasePreferenceControll @Override public CharSequence getSummary() { if (mLocationManager.isLocationEnabled()) { - if (mNumTotal == -1) { - return mContext.getString(R.string.location_settings_loading_app_permission_stats); + if (sSummary == null) { + sSummary = mContext.getString( + R.string.location_settings_loading_app_permission_stats); } - return mContext.getResources().getQuantityString( - R.plurals.location_settings_summary_location_on, - mNumTotal, mNumTotal); + return sSummary; } else { return mContext.getString(R.string.location_settings_summary_location_off); } @@ -64,7 +63,8 @@ public class TopLevelLocationPreferenceController extends BasePreferenceControll @VisibleForTesting void setLocationAppCount(int numApps) { - mNumTotal = numApps; + sSummary = mContext.getResources().getQuantityString( + R.plurals.location_settings_summary_location_on, numApps, numApps); refreshSummary(mPreference); } diff --git a/tests/robotests/src/com/android/settings/location/TopLevelLocationPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/location/TopLevelLocationPreferenceControllerTest.java index 68e7f88ddf5..f0bc705c491 100644 --- a/tests/robotests/src/com/android/settings/location/TopLevelLocationPreferenceControllerTest.java +++ b/tests/robotests/src/com/android/settings/location/TopLevelLocationPreferenceControllerTest.java @@ -56,31 +56,41 @@ public class TopLevelLocationPreferenceControllerTest { } @Test - public void getSummary_whenLocationIsOn_shouldShowLoadingString() { + public void getSummary_whenLocationIsOn_shouldPreservePreviousText() { + final int locationAppCount = 5; + // Retrieve summary text once. + mLocationManager.setLocationEnabledForUser(true, android.os.Process.myUserHandle()); + mController.setLocationAppCount(locationAppCount); + mController.getSummary(); + // Turn off location. + mLocationManager.setLocationEnabledForUser(false, android.os.Process.myUserHandle()); + // Turn on location again and check if the previous summary text is still cached. mLocationManager.setLocationEnabledForUser(true, android.os.Process.myUserHandle()); assertThat(mController.getSummary()).isEqualTo( - mContext.getString(R.string.location_settings_loading_app_permission_stats)); + mContext.getResources().getQuantityString( + R.plurals.location_settings_summary_location_on, locationAppCount, + locationAppCount)); } @Test public void getSummary_whenLocationAppCountIsOne_shouldShowSingularString() { - final int LOCATION_APP_COUNT = 1; + final int locationAppCount = 1; mLocationManager.setLocationEnabledForUser(true, android.os.Process.myUserHandle()); - mController.setLocationAppCount(LOCATION_APP_COUNT); + mController.setLocationAppCount(locationAppCount); assertThat(mController.getSummary()).isEqualTo( mContext.getResources().getQuantityString( R.plurals.location_settings_summary_location_on, - LOCATION_APP_COUNT, LOCATION_APP_COUNT)); + locationAppCount, locationAppCount)); } @Test public void getSummary_whenLocationAppCountIsGreaterThanOne_shouldShowPluralString() { - final int LOCATION_APP_COUNT = 5; + final int locationAppCount = 5; mLocationManager.setLocationEnabledForUser(true, android.os.Process.myUserHandle()); - mController.setLocationAppCount(LOCATION_APP_COUNT); + mController.setLocationAppCount(locationAppCount); assertThat(mController.getSummary()).isEqualTo( mContext.getResources().getQuantityString( R.plurals.location_settings_summary_location_on, - LOCATION_APP_COUNT, LOCATION_APP_COUNT)); + locationAppCount, locationAppCount)); } } \ No newline at end of file From 9b09c575785ab603ca9e1f8d77cc19f832d21c72 Mon Sep 17 00:00:00 2001 From: Peter_Liang Date: Wed, 11 May 2022 21:42:05 +0800 Subject: [PATCH 09/11] Fine-tune the location of the logging for accessibility text and reading options. Goals: To have the precise logs, move the previous logs to the proper location. Bug: 222661478 Test: manual test Change-Id: I74d99659d2b383222b381c430c3c373879f5cbdc --- .../PreviewSizeSeekBarController.java | 18 -------- .../TextReadingPreferenceFragment.java | 3 +- .../TextReadingPreviewController.java | 41 ++++++++++++++++++- 3 files changed, 40 insertions(+), 22 deletions(-) diff --git a/src/com/android/settings/accessibility/PreviewSizeSeekBarController.java b/src/com/android/settings/accessibility/PreviewSizeSeekBarController.java index 711eb0fe527..2078112811a 100644 --- a/src/com/android/settings/accessibility/PreviewSizeSeekBarController.java +++ b/src/com/android/settings/accessibility/PreviewSizeSeekBarController.java @@ -22,9 +22,7 @@ import android.widget.SeekBar; import androidx.annotation.NonNull; import androidx.preference.PreferenceScreen; -import com.android.settings.accessibility.TextReadingPreferenceFragment.EntryPoint; import com.android.settings.core.BasePreferenceController; -import com.android.settings.core.instrumentation.SettingsStatsLog; import com.android.settings.widget.LabeledSeekBarPreference; /** @@ -38,9 +36,6 @@ class PreviewSizeSeekBarController extends BasePreferenceController implements private ProgressInteractionListener mInteractionListener; private LabeledSeekBarPreference mSeekBarPreference; - @EntryPoint - private int mEntryPoint; - private final SeekBar.OnSeekBarChangeListener mSeekBarChangeListener = new SeekBar.OnSeekBarChangeListener() { @Override @@ -51,11 +46,6 @@ class PreviewSizeSeekBarController extends BasePreferenceController implements mInteractionListener.onProgressChanged(); } - SettingsStatsLog.write( - SettingsStatsLog.ACCESSIBILITY_TEXT_READING_OPTIONS_CHANGED, - AccessibilityStatsLogUtils.convertToItemKeyName(getPreferenceKey()), - progress, - AccessibilityStatsLogUtils.convertToEntryPoint(mEntryPoint)); } @Override @@ -107,14 +97,6 @@ class PreviewSizeSeekBarController extends BasePreferenceController implements mSeekBarPreference.setProgress(defaultProgress); } - /** - * The entry point is used for logging. - * - * @param entryPoint from which settings page - */ - void setEntryPoint(@EntryPoint int entryPoint) { - mEntryPoint = entryPoint; - } /** * Interface for callbacks when users interact with the seek bar. diff --git a/src/com/android/settings/accessibility/TextReadingPreferenceFragment.java b/src/com/android/settings/accessibility/TextReadingPreferenceFragment.java index 104be2644a2..4033404cd98 100644 --- a/src/com/android/settings/accessibility/TextReadingPreferenceFragment.java +++ b/src/com/android/settings/accessibility/TextReadingPreferenceFragment.java @@ -129,18 +129,17 @@ public class TextReadingPreferenceFragment extends DashboardFragment { final TextReadingPreviewController previewController = new TextReadingPreviewController( context, PREVIEW_KEY, fontSizeData, displaySizeData); + previewController.setEntryPoint(mEntryPoint); controllers.add(previewController); final PreviewSizeSeekBarController fontSizeController = new PreviewSizeSeekBarController( context, FONT_SIZE_KEY, fontSizeData); fontSizeController.setInteractionListener(previewController); - fontSizeController.setEntryPoint(mEntryPoint); controllers.add(fontSizeController); final PreviewSizeSeekBarController displaySizeController = new PreviewSizeSeekBarController( context, DISPLAY_SIZE_KEY, displaySizeData); displaySizeController.setInteractionListener(previewController); - displaySizeController.setEntryPoint(mEntryPoint); controllers.add(displaySizeController); mFontWeightAdjustmentController = diff --git a/src/com/android/settings/accessibility/TextReadingPreviewController.java b/src/com/android/settings/accessibility/TextReadingPreviewController.java index cef20aac546..1be8c70f4f6 100644 --- a/src/com/android/settings/accessibility/TextReadingPreviewController.java +++ b/src/com/android/settings/accessibility/TextReadingPreviewController.java @@ -19,6 +19,7 @@ package com.android.settings.accessibility; import android.content.Context; import android.content.res.Configuration; import android.os.SystemClock; +import android.util.Log; import android.view.Choreographer; import android.view.View; @@ -26,7 +27,9 @@ import androidx.annotation.NonNull; import androidx.preference.PreferenceScreen; import com.android.settings.R; +import com.android.settings.accessibility.TextReadingPreferenceFragment.EntryPoint; import com.android.settings.core.BasePreferenceController; +import com.android.settings.core.instrumentation.SettingsStatsLog; import com.android.settings.display.PreviewPagerAdapter; import com.android.settings.widget.LabeledSeekBarPreference; @@ -38,6 +41,7 @@ import java.util.Objects; */ class TextReadingPreviewController extends BasePreferenceController implements PreviewSizeSeekBarController.ProgressInteractionListener { + private static final String TAG = "TextReadingPreviewCtrl"; static final int[] PREVIEW_SAMPLE_RES_IDS = new int[]{ R.layout.accessibility_text_reading_preview_app_grid, R.layout.screen_zoom_preview_1, @@ -58,6 +62,9 @@ class TextReadingPreviewController extends BasePreferenceController implements private LabeledSeekBarPreference mFontSizePreference; private LabeledSeekBarPreference mDisplaySizePreference; + @EntryPoint + private int mEntryPoint; + private final Choreographer.FrameCallback mCommit = f -> { tryCommitFontSizeConfig(); tryCommitDisplaySizeConfig(); @@ -92,8 +99,8 @@ class TextReadingPreviewController extends BasePreferenceController implements /* message= */ "Display size preference is null, the preview controller" + " couldn't get the info"); - mLastFontProgress = mFontSizePreference.getProgress(); - mLastDisplayProgress = mDisplaySizePreference.getProgress(); + mLastFontProgress = mFontSizeData.getInitialIndex(); + mLastDisplayProgress = mDisplaySizeData.getInitialIndex(); final Configuration origConfig = mContext.getResources().getConfiguration(); final boolean isLayoutRtl = @@ -131,6 +138,15 @@ class TextReadingPreviewController extends BasePreferenceController implements postCommitDelayed(CHANGE_BY_SEEKBAR_DELAY_MS); } + /** + * The entry point is used for logging. + * + * @param entryPoint from which settings page + */ + void setEntryPoint(@EntryPoint int entryPoint) { + mEntryPoint = entryPoint; + } + /** * Avoids the flicker when switching to the previous or next level. * @@ -162,6 +178,16 @@ class TextReadingPreviewController extends BasePreferenceController implements if (fontProgress != mLastFontProgress) { mFontSizeData.commit(fontProgress); mLastFontProgress = fontProgress; + + if (Log.isLoggable(TAG, Log.DEBUG)) { + Log.d(TAG, "Font size: " + fontProgress); + } + + SettingsStatsLog.write( + SettingsStatsLog.ACCESSIBILITY_TEXT_READING_OPTIONS_CHANGED, + AccessibilityStatsLogUtils.convertToItemKeyName(mFontSizePreference.getKey()), + fontProgress, + AccessibilityStatsLogUtils.convertToEntryPoint(mEntryPoint)); } } @@ -170,6 +196,17 @@ class TextReadingPreviewController extends BasePreferenceController implements if (displayProgress != mLastDisplayProgress) { mDisplaySizeData.commit(displayProgress); mLastDisplayProgress = displayProgress; + + if (Log.isLoggable(TAG, Log.DEBUG)) { + Log.d(TAG, "Display size: " + displayProgress); + } + + SettingsStatsLog.write( + SettingsStatsLog.ACCESSIBILITY_TEXT_READING_OPTIONS_CHANGED, + AccessibilityStatsLogUtils.convertToItemKeyName( + mDisplaySizePreference.getKey()), + displayProgress, + AccessibilityStatsLogUtils.convertToEntryPoint(mEntryPoint)); } } From 87e0b3c7e516fdc59734bc11ac92dc0e3aec071d Mon Sep 17 00:00:00 2001 From: jasonwshsu Date: Thu, 12 May 2022 17:33:07 +0800 Subject: [PATCH 10/11] Correct Magnification shortcut title in edit shortcut dialog Root Cause: Magnification has its own edit shortcut dialog, but we did not update correct title with getShortcutTitle() Solution: set dialog title to getShortcutTitle() Bug: 231531313 Test: manual test Change-Id: I0679be2807a4b1f8b8a733604e16a35b0a1258c3 --- .../ToggleScreenMagnificationPreferenceFragment.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/com/android/settings/accessibility/ToggleScreenMagnificationPreferenceFragment.java b/src/com/android/settings/accessibility/ToggleScreenMagnificationPreferenceFragment.java index a6aeb897357..9289db61f21 100644 --- a/src/com/android/settings/accessibility/ToggleScreenMagnificationPreferenceFragment.java +++ b/src/com/android/settings/accessibility/ToggleScreenMagnificationPreferenceFragment.java @@ -147,8 +147,7 @@ public class ToggleScreenMagnificationPreferenceFragment extends return AccessibilityGestureNavigationTutorial .showAccessibilityGestureTutorialDialog(getPrefContext()); case DialogEnums.MAGNIFICATION_EDIT_SHORTCUT: - final CharSequence dialogTitle = getPrefContext().getString( - R.string.accessibility_shortcut_title, mPackageName); + final CharSequence dialogTitle = getShortcutTitle(); final int dialogType = WizardManagerHelper.isAnySetupWizard(getIntent()) ? DialogType.EDIT_SHORTCUT_MAGNIFICATION_SUW : DialogType.EDIT_SHORTCUT_MAGNIFICATION; From a0754055178e7a9ff5f815c8b466c599cdf61721 Mon Sep 17 00:00:00 2001 From: Kuan Wang Date: Thu, 12 May 2022 17:09:28 +0800 Subject: [PATCH 11/11] Add string "Battery usage settings" into Reset App dialog. Bug: 222037028 Test: emulator Change-Id: I5482de6573d34533db35c82136af13c03a34b7ab --- res/values/strings.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/res/values/strings.xml b/res/values/strings.xml index 1cbbeba2946..4b208990faf 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -4742,7 +4742,7 @@ Reset app preferences? - This will reset all preferences for:\n\n
  • Disabled apps
  • \n
  • Disabled app notifications
  • \n
  • Default applications for actions
  • \n
  • Background data restrictions for apps
  • \n
  • Any permission restrictions
  • \n\nYou will not lose any app data.
    + This will reset all preferences for:\n\n
  • Disabled apps
  • \n
  • Disabled app notifications
  • \n
  • Default applications for actions
  • \n
  • Background data restrictions for apps
  • \n
  • Any permission restrictions
  • \n
  • Battery usage settings
  • \n\nYou will not lose any app data.
    Reset apps