From 7e8d79b3c2fca04066307af294f88abf942aa0e7 Mon Sep 17 00:00:00 2001 From: Wesley Wang Date: Tue, 19 Jul 2022 16:27:14 +0800 Subject: [PATCH 1/9] Update battery optimize page states condition - Keep apps optimize state as what it set even it's a system or default app - Previously we force system/defualt apps present as Unrestricted mode only and disable other options but that can not shows that apps actual optimize states, it's possible to be other states even it's a system or default apps, so we change the UI logic back to: present it's actual states and disable other options when it's a system or default apps. Bug: 234419032 Test: make SettingsRoboTests Change-Id: Ib5b6cb0aacb570cb8d15b1bb9ac2d480356eda49 --- .../OptimizedPreferenceController.java | 10 +++++----- .../RestrictedPreferenceController.java | 10 +++++----- .../UnrestrictedPreferenceController.java | 9 +++++---- .../OptimizedPreferenceControllerTest.java | 12 ++++++++++++ .../RestrictedPreferenceControllerTest.java | 14 +++++++++++++- .../UnrestrictedPreferenceControllerTest.java | 17 +++++++++++++++-- 6 files changed, 55 insertions(+), 17 deletions(-) diff --git a/src/com/android/settings/fuelgauge/OptimizedPreferenceController.java b/src/com/android/settings/fuelgauge/OptimizedPreferenceController.java index 708ba5efa51..88241b6ff39 100644 --- a/src/com/android/settings/fuelgauge/OptimizedPreferenceController.java +++ b/src/com/android/settings/fuelgauge/OptimizedPreferenceController.java @@ -53,16 +53,16 @@ public class OptimizedPreferenceController extends AbstractPreferenceController return; } - if (mBatteryOptimizeUtils.isSystemOrDefaultApp()) { - Log.d(TAG, "is system or default app, disable pref"); - ((SelectorWithWidgetPreference) preference).setChecked(false); - preference.setEnabled(false); - } else if (mBatteryOptimizeUtils.getAppOptimizationMode() + if (mBatteryOptimizeUtils.getAppOptimizationMode() == BatteryOptimizeUtils.MODE_OPTIMIZED) { Log.d(TAG, "is optimized states"); ((SelectorWithWidgetPreference) preference).setChecked(true); } else { ((SelectorWithWidgetPreference) preference).setChecked(false); + if (mBatteryOptimizeUtils.isSystemOrDefaultApp()) { + Log.d(TAG, "is system or default app, disable pref"); + preference.setEnabled(false); + } } } diff --git a/src/com/android/settings/fuelgauge/RestrictedPreferenceController.java b/src/com/android/settings/fuelgauge/RestrictedPreferenceController.java index 99e742ba236..fe896a6aed0 100644 --- a/src/com/android/settings/fuelgauge/RestrictedPreferenceController.java +++ b/src/com/android/settings/fuelgauge/RestrictedPreferenceController.java @@ -51,16 +51,16 @@ public class RestrictedPreferenceController extends AbstractPreferenceController preference.setEnabled(true); } - if (mBatteryOptimizeUtils.isSystemOrDefaultApp()) { - Log.d(TAG, "is system or default app, disable pref"); - ((SelectorWithWidgetPreference) preference).setChecked(false); - preference.setEnabled(false); - } else if (mBatteryOptimizeUtils.getAppOptimizationMode() + if (mBatteryOptimizeUtils.getAppOptimizationMode() == BatteryOptimizeUtils.MODE_RESTRICTED) { Log.d(TAG, "is restricted states"); ((SelectorWithWidgetPreference) preference).setChecked(true); } else { ((SelectorWithWidgetPreference) preference).setChecked(false); + if (mBatteryOptimizeUtils.isSystemOrDefaultApp()) { + Log.d(TAG, "is system or default app, disable pref"); + preference.setEnabled(false); + } } } diff --git a/src/com/android/settings/fuelgauge/UnrestrictedPreferenceController.java b/src/com/android/settings/fuelgauge/UnrestrictedPreferenceController.java index 244a33c4dfd..be4091c782f 100644 --- a/src/com/android/settings/fuelgauge/UnrestrictedPreferenceController.java +++ b/src/com/android/settings/fuelgauge/UnrestrictedPreferenceController.java @@ -50,15 +50,16 @@ public class UnrestrictedPreferenceController extends AbstractPreferenceControll preference.setEnabled(true); } - if (mBatteryOptimizeUtils.isSystemOrDefaultApp()) { - Log.d(TAG, "is system or default app, unrestricted states only"); - ((SelectorWithWidgetPreference) preference).setChecked(true); - } else if (mBatteryOptimizeUtils.getAppOptimizationMode() + if (mBatteryOptimizeUtils.getAppOptimizationMode() == BatteryOptimizeUtils.MODE_UNRESTRICTED) { Log.d(TAG, "is unrestricted states"); ((SelectorWithWidgetPreference) preference).setChecked(true); } else { ((SelectorWithWidgetPreference) preference).setChecked(false); + if (mBatteryOptimizeUtils.isSystemOrDefaultApp()) { + Log.d(TAG, "is system or default app, disable pref"); + preference.setEnabled(false); + } } } diff --git a/tests/robotests/src/com/android/settings/fuelgauge/OptimizedPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/fuelgauge/OptimizedPreferenceControllerTest.java index 1b5ded0b7da..1fec92a8134 100644 --- a/tests/robotests/src/com/android/settings/fuelgauge/OptimizedPreferenceControllerTest.java +++ b/tests/robotests/src/com/android/settings/fuelgauge/OptimizedPreferenceControllerTest.java @@ -60,6 +60,18 @@ public class OptimizedPreferenceControllerTest { assertThat(mPreference.isChecked()).isTrue(); } + @Test + public void testUpdateState_isSystemOrDefaultAppAndOptimizeStates_prefChecked() { + when(mockBatteryOptimizeUtils.isValidPackageName()).thenReturn(true); + when(mockBatteryOptimizeUtils.isSystemOrDefaultApp()).thenReturn(true); + when(mockBatteryOptimizeUtils.getAppOptimizationMode()).thenReturn( + BatteryOptimizeUtils.MODE_OPTIMIZED); + + mController.updateState(mPreference); + + assertThat(mPreference.isChecked()).isTrue(); + } + @Test public void testUpdateState_isSystemOrDefaultApp_prefUnchecked() { when(mockBatteryOptimizeUtils.isValidPackageName()).thenReturn(true); diff --git a/tests/robotests/src/com/android/settings/fuelgauge/RestrictedPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/fuelgauge/RestrictedPreferenceControllerTest.java index bacfb1af714..944376c77dd 100644 --- a/tests/robotests/src/com/android/settings/fuelgauge/RestrictedPreferenceControllerTest.java +++ b/tests/robotests/src/com/android/settings/fuelgauge/RestrictedPreferenceControllerTest.java @@ -69,7 +69,19 @@ public class RestrictedPreferenceControllerTest { } @Test - public void testUpdateState_isSystemOrDefaultApp_prefChecked() { + public void testUpdateState_isSystemOrDefaultAppAndRestrictedStates_prefChecked() { + when(mockBatteryOptimizeUtils.isValidPackageName()).thenReturn(true); + when(mockBatteryOptimizeUtils.isSystemOrDefaultApp()).thenReturn(true); + when(mockBatteryOptimizeUtils.getAppOptimizationMode()).thenReturn( + BatteryOptimizeUtils.MODE_RESTRICTED); + + mController.updateState(mPreference); + + assertThat(mPreference.isChecked()).isTrue(); + } + + @Test + public void testUpdateState_isSystemOrDefaultApp_prefUnchecked() { when(mockBatteryOptimizeUtils.isValidPackageName()).thenReturn(true); when(mockBatteryOptimizeUtils.isSystemOrDefaultApp()).thenReturn(true); diff --git a/tests/robotests/src/com/android/settings/fuelgauge/UnrestrictedPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/fuelgauge/UnrestrictedPreferenceControllerTest.java index d5500faf983..c5642df576c 100644 --- a/tests/robotests/src/com/android/settings/fuelgauge/UnrestrictedPreferenceControllerTest.java +++ b/tests/robotests/src/com/android/settings/fuelgauge/UnrestrictedPreferenceControllerTest.java @@ -70,13 +70,26 @@ public class UnrestrictedPreferenceControllerTest { } @Test - public void testUpdateState_isSystemOrDefaultApp_prefChecked() { + public void testUpdateState_isSystemOrDefaultAppAndUnrestrictedStates_prefChecked() { + when(mockBatteryOptimizeUtils.isValidPackageName()).thenReturn(true); + when(mockBatteryOptimizeUtils.isSystemOrDefaultApp()).thenReturn(true); + when(mockBatteryOptimizeUtils.getAppOptimizationMode()).thenReturn( + BatteryOptimizeUtils.MODE_UNRESTRICTED); + + mController.updateState(mPreference); + + assertThat(mPreference.isChecked()).isTrue(); + } + + @Test + public void testUpdateState_isSystemOrDefaultApp_prefUnchecked() { when(mockBatteryOptimizeUtils.isValidPackageName()).thenReturn(true); when(mockBatteryOptimizeUtils.isSystemOrDefaultApp()).thenReturn(true); mController.updateState(mPreference); - assertThat(mPreference.isChecked()).isTrue(); + assertThat(mPreference.isChecked()).isFalse(); + assertThat(mPreference.isEnabled()).isFalse(); } @Test From e90507373c7da89d74cf8511000480d126640995 Mon Sep 17 00:00:00 2001 From: Julia Reynolds Date: Thu, 14 Jul 2022 16:15:26 -0400 Subject: [PATCH 2/9] Improve App notification loading 1) Use UiBlocker, for better animations for apps with a lot of channels 2) Only load data in onResume, because the data loading step in some of the controllers is expensive Test: make -j64 RunSettingsRoboTests ROBOTEST_FILTER="com.android.settings.notification" Test: load small channel and large (6000ish) channel app pages Test: load individual channel pages Test: load in-app channel shelf UI Fixes: 215072888 Change-Id: I9a1c96f75b02f94b3ffc529d17d9c0cad7752de1 --- .../AppBubbleListPreferenceController.java | 14 +-- .../AddToHomeScreenPreferenceController.java | 10 +- .../app/AllowSoundPreferenceController.java | 13 ++- ...nnelsBypassingDndPreferenceController.java | 6 +- ...pConversationListPreferenceController.java | 22 +++-- .../app/AppLinkPreferenceController.java | 10 +- .../app/BadgePreferenceController.java | 22 +++-- .../app/BlockPreferenceController.java | 10 +- .../BubbleCategoryPreferenceController.java | 10 +- .../app/BubbleLinkPreferenceController.java | 10 +- .../app/BubblePreferenceController.java | 19 ++-- .../BubbleSummaryPreferenceController.java | 21 +++-- .../app/ChannelListPreferenceController.java | 47 +++++----- ...onversationDemotePreferenceController.java | 15 +-- ...onversationHeaderPreferenceController.java | 6 +- ...versationPriorityPreferenceController.java | 12 +-- ...nversationPromotePreferenceController.java | 15 +-- .../DeletedChannelsPreferenceController.java | 15 +-- .../app/DescriptionPreferenceController.java | 16 ++-- .../app/DndPreferenceController.java | 10 +- .../app/HeaderPreferenceController.java | 6 +- .../HighImportancePreferenceController.java | 16 ++-- .../app/ImportancePreferenceController.java | 12 +-- ...dConversationInfoPreferenceController.java | 14 +-- ...validConversationPreferenceController.java | 14 +-- .../app/LightsPreferenceController.java | 18 ++-- .../MinImportancePreferenceController.java | 14 +-- .../app/NotificationPreferenceController.java | 33 ++++--- .../app/NotificationSettings.java | 94 +++++++++---------- .../NotificationsOffPreferenceController.java | 14 ++- .../app/SoundPreferenceController.java | 15 +-- .../app/VibrationPreferenceController.java | 19 ++-- .../app/VisibilityPreferenceController.java | 16 ++-- .../NotificationPreferenceControllerTest.java | 2 +- 34 files changed, 318 insertions(+), 272 deletions(-) diff --git a/src/com/android/settings/notification/AppBubbleListPreferenceController.java b/src/com/android/settings/notification/AppBubbleListPreferenceController.java index bf7fcc03756..6ebb376b5c1 100644 --- a/src/com/android/settings/notification/AppBubbleListPreferenceController.java +++ b/src/com/android/settings/notification/AppBubbleListPreferenceController.java @@ -51,7 +51,7 @@ public class AppBubbleListPreferenceController extends AppConversationListPrefer private static final String KEY = "bubble_conversations"; public AppBubbleListPreferenceController(Context context, NotificationBackend backend) { - super(context, backend); + super(context, backend, KEY); } @Override @@ -80,25 +80,25 @@ public class AppBubbleListPreferenceController extends AppConversationListPrefer } @Override - public boolean isAvailable() { + public int getAvailabilityStatus() { // copy rather than inherit super's isAvailable because apps can link to this page // as part of onboarding, before they send a valid conversation notification if (mAppRow == null) { - return false; + return CONDITIONALLY_UNAVAILABLE; } if (mAppRow.banned) { - return false; + return CONDITIONALLY_UNAVAILABLE; } if (mChannel != null) { if (mBackend.onlyHasDefaultChannel(mAppRow.pkg, mAppRow.uid) || NotificationChannel.DEFAULT_CHANNEL_ID.equals(mChannel.getId())) { - return false; + return CONDITIONALLY_UNAVAILABLE; } } if (mAppRow.bubblePreference == BUBBLE_PREFERENCE_NONE) { - return false; + return CONDITIONALLY_UNAVAILABLE; } - return true; + return AVAILABLE; } @VisibleForTesting diff --git a/src/com/android/settings/notification/app/AddToHomeScreenPreferenceController.java b/src/com/android/settings/notification/app/AddToHomeScreenPreferenceController.java index e5afd9d3db0..12b807534f9 100644 --- a/src/com/android/settings/notification/app/AddToHomeScreenPreferenceController.java +++ b/src/com/android/settings/notification/app/AddToHomeScreenPreferenceController.java @@ -32,7 +32,7 @@ public class AddToHomeScreenPreferenceController extends NotificationPreferenceC private static final String KEY = "add_to_home"; public AddToHomeScreenPreferenceController(Context context, NotificationBackend backend) { - super(context, backend); + super(context, backend, KEY); } @Override @@ -41,11 +41,11 @@ public class AddToHomeScreenPreferenceController extends NotificationPreferenceC } @Override - public boolean isAvailable() { - if (!super.isAvailable()) { - return false; + public int getAvailabilityStatus() { + if (super.getAvailabilityStatus() == CONDITIONALLY_UNAVAILABLE) { + return CONDITIONALLY_UNAVAILABLE; } - return mConversationInfo != null; + return mConversationInfo != null ? AVAILABLE : CONDITIONALLY_UNAVAILABLE; } @Override diff --git a/src/com/android/settings/notification/app/AllowSoundPreferenceController.java b/src/com/android/settings/notification/app/AllowSoundPreferenceController.java index 0664c544bec..99d08734c96 100644 --- a/src/com/android/settings/notification/app/AllowSoundPreferenceController.java +++ b/src/com/android/settings/notification/app/AllowSoundPreferenceController.java @@ -40,7 +40,7 @@ public class AllowSoundPreferenceController extends NotificationPreferenceContro public AllowSoundPreferenceController(Context context, NotificationSettings.DependentFieldListener dependentFieldListener, NotificationBackend backend) { - super(context, backend); + super(context, backend, KEY_IMPORTANCE); mDependentFieldListener = dependentFieldListener; } @@ -50,11 +50,14 @@ public class AllowSoundPreferenceController extends NotificationPreferenceContro } @Override - public boolean isAvailable() { - if (!super.isAvailable()) { - return false; + public int getAvailabilityStatus() { + if (super.getAvailabilityStatus() == CONDITIONALLY_UNAVAILABLE) { + return CONDITIONALLY_UNAVAILABLE; } - return mChannel != null && NotificationChannel.DEFAULT_CHANNEL_ID.equals(mChannel.getId()); + if (mChannel != null && NotificationChannel.DEFAULT_CHANNEL_ID.equals(mChannel.getId())) { + return AVAILABLE; + } + return CONDITIONALLY_UNAVAILABLE; } diff --git a/src/com/android/settings/notification/app/AppChannelsBypassingDndPreferenceController.java b/src/com/android/settings/notification/app/AppChannelsBypassingDndPreferenceController.java index 92cd911843a..6c2c0c3cf77 100644 --- a/src/com/android/settings/notification/app/AppChannelsBypassingDndPreferenceController.java +++ b/src/com/android/settings/notification/app/AppChannelsBypassingDndPreferenceController.java @@ -64,7 +64,7 @@ public class AppChannelsBypassingDndPreferenceController extends NotificationPre public AppChannelsBypassingDndPreferenceController( Context context, NotificationBackend backend) { - super(context, backend); + super(context, backend, KEY); } @Override @@ -110,8 +110,8 @@ public class AppChannelsBypassingDndPreferenceController extends NotificationPre } @Override - public boolean isAvailable() { - return mAppRow != null; + public int getAvailabilityStatus() { + return mAppRow != null ? AVAILABLE : CONDITIONALLY_UNAVAILABLE; } @Override diff --git a/src/com/android/settings/notification/app/AppConversationListPreferenceController.java b/src/com/android/settings/notification/app/AppConversationListPreferenceController.java index dd44a13f7c8..e7b23788968 100644 --- a/src/com/android/settings/notification/app/AppConversationListPreferenceController.java +++ b/src/com/android/settings/notification/app/AppConversationListPreferenceController.java @@ -49,7 +49,12 @@ public class AppConversationListPreferenceController extends NotificationPrefere protected PreferenceCategory mPreference; public AppConversationListPreferenceController(Context context, NotificationBackend backend) { - super(context, backend); + this(context, backend, KEY); + } + + public AppConversationListPreferenceController(Context context, NotificationBackend backend, + String key) { + super(context, backend, key); } @Override @@ -58,21 +63,24 @@ public class AppConversationListPreferenceController extends NotificationPrefere } @Override - public boolean isAvailable() { + public int getAvailabilityStatus() { if (mAppRow == null) { - return false; + return CONDITIONALLY_UNAVAILABLE; } if (mAppRow.banned) { - return false; + return CONDITIONALLY_UNAVAILABLE; } if (mChannel != null) { if (mBackend.onlyHasDefaultChannel(mAppRow.pkg, mAppRow.uid) || NotificationChannel.DEFAULT_CHANNEL_ID.equals(mChannel.getId())) { - return false; + return CONDITIONALLY_UNAVAILABLE; } } - return mBackend.hasSentValidMsg(mAppRow.pkg, mAppRow.uid) || mBackend.isInInvalidMsgState( - mAppRow.pkg, mAppRow.uid); + if (mBackend.hasSentValidMsg(mAppRow.pkg, mAppRow.uid) || mBackend.isInInvalidMsgState( + mAppRow.pkg, mAppRow.uid)) { + return AVAILABLE; + } + return CONDITIONALLY_UNAVAILABLE; } @Override diff --git a/src/com/android/settings/notification/app/AppLinkPreferenceController.java b/src/com/android/settings/notification/app/AppLinkPreferenceController.java index 043ae698f54..ecf9670cba9 100644 --- a/src/com/android/settings/notification/app/AppLinkPreferenceController.java +++ b/src/com/android/settings/notification/app/AppLinkPreferenceController.java @@ -32,7 +32,7 @@ public class AppLinkPreferenceController extends NotificationPreferenceControlle private static final String KEY_APP_LINK = "app_link"; public AppLinkPreferenceController(Context context) { - super(context, null); + super(context, null, KEY_APP_LINK); } @Override @@ -41,11 +41,11 @@ public class AppLinkPreferenceController extends NotificationPreferenceControlle } @Override - public boolean isAvailable() { - if (!super.isAvailable()) { - return false; + public int getAvailabilityStatus() { + if (super.getAvailabilityStatus() == CONDITIONALLY_UNAVAILABLE) { + return CONDITIONALLY_UNAVAILABLE; } - return mAppRow.settingsIntent != null; + return mAppRow.settingsIntent != null ? AVAILABLE : CONDITIONALLY_UNAVAILABLE; } @Override diff --git a/src/com/android/settings/notification/app/BadgePreferenceController.java b/src/com/android/settings/notification/app/BadgePreferenceController.java index 108fa1d7a07..f94dfb513ae 100644 --- a/src/com/android/settings/notification/app/BadgePreferenceController.java +++ b/src/com/android/settings/notification/app/BadgePreferenceController.java @@ -38,7 +38,7 @@ public class BadgePreferenceController extends NotificationPreferenceController public BadgePreferenceController(Context context, NotificationBackend backend) { - super(context, backend); + super(context, backend, KEY_BADGE); } @Override @@ -47,25 +47,29 @@ public class BadgePreferenceController extends NotificationPreferenceController } @Override - public boolean isAvailable() { - if (!super.isAvailable()) { - return false; + public int getAvailabilityStatus() { + if (super.getAvailabilityStatus() == CONDITIONALLY_UNAVAILABLE) { + return CONDITIONALLY_UNAVAILABLE; } if (mAppRow == null && mChannel == null) { - return false; + return CONDITIONALLY_UNAVAILABLE; } if (Settings.Secure.getInt(mContext.getContentResolver(), NOTIFICATION_BADGING, SYSTEM_WIDE_ON) == SYSTEM_WIDE_OFF) { - return false; + return CONDITIONALLY_UNAVAILABLE; } if (mChannel != null) { if (isDefaultChannel()) { - return true; + return AVAILABLE; } else { - return mAppRow == null ? false : mAppRow.showBadge; + return mAppRow == null + ? CONDITIONALLY_UNAVAILABLE + : mAppRow.showBadge + ? AVAILABLE + : CONDITIONALLY_UNAVAILABLE; } } - return true; + return AVAILABLE; } @Override diff --git a/src/com/android/settings/notification/app/BlockPreferenceController.java b/src/com/android/settings/notification/app/BlockPreferenceController.java index f4e213298a7..ea3eaeb3353 100644 --- a/src/com/android/settings/notification/app/BlockPreferenceController.java +++ b/src/com/android/settings/notification/app/BlockPreferenceController.java @@ -42,7 +42,7 @@ public class BlockPreferenceController extends NotificationPreferenceController public BlockPreferenceController(Context context, NotificationSettings.DependentFieldListener dependentFieldListener, NotificationBackend backend) { - super(context, backend); + super(context, backend, KEY_BLOCK); mDependentFieldListener = dependentFieldListener; } @@ -52,14 +52,14 @@ public class BlockPreferenceController extends NotificationPreferenceController } @Override - public boolean isAvailable() { + public int getAvailabilityStatus() { if (mAppRow == null) { - return false; + return CONDITIONALLY_UNAVAILABLE; } if (mPreferenceFilter != null && !isIncludedInFilter()) { - return false; + return CONDITIONALLY_UNAVAILABLE; } - return true; + return AVAILABLE; } @Override diff --git a/src/com/android/settings/notification/app/BubbleCategoryPreferenceController.java b/src/com/android/settings/notification/app/BubbleCategoryPreferenceController.java index ad3a10cf381..da67afeeb33 100644 --- a/src/com/android/settings/notification/app/BubbleCategoryPreferenceController.java +++ b/src/com/android/settings/notification/app/BubbleCategoryPreferenceController.java @@ -32,15 +32,15 @@ public class BubbleCategoryPreferenceController extends NotificationPreferenceCo static final int ON = 1; public BubbleCategoryPreferenceController(Context context) { - super(context, null); + super(context, null, KEY); } @Override - public boolean isAvailable() { - if (!super.isAvailable()) { - return false; + public int getAvailabilityStatus() { + if (super.getAvailabilityStatus() == CONDITIONALLY_UNAVAILABLE) { + return CONDITIONALLY_UNAVAILABLE; } - return areBubblesEnabled(); + return areBubblesEnabled() ? AVAILABLE : CONDITIONALLY_UNAVAILABLE; } @Override diff --git a/src/com/android/settings/notification/app/BubbleLinkPreferenceController.java b/src/com/android/settings/notification/app/BubbleLinkPreferenceController.java index 0b9529b10b5..ed1c9b53079 100644 --- a/src/com/android/settings/notification/app/BubbleLinkPreferenceController.java +++ b/src/com/android/settings/notification/app/BubbleLinkPreferenceController.java @@ -32,15 +32,15 @@ public class BubbleLinkPreferenceController extends NotificationPreferenceContro static final int ON = 1; public BubbleLinkPreferenceController(Context context) { - super(context, null); + super(context, null, KEY); } @Override - public boolean isAvailable() { - if (!super.isAvailable()) { - return false; + public int getAvailabilityStatus() { + if (super.getAvailabilityStatus() == CONDITIONALLY_UNAVAILABLE) { + return CONDITIONALLY_UNAVAILABLE; } - return areBubblesEnabled(); + return areBubblesEnabled() ? AVAILABLE : CONDITIONALLY_UNAVAILABLE; } @Override diff --git a/src/com/android/settings/notification/app/BubblePreferenceController.java b/src/com/android/settings/notification/app/BubblePreferenceController.java index 351b4635bb6..516a45e482d 100644 --- a/src/com/android/settings/notification/app/BubblePreferenceController.java +++ b/src/com/android/settings/notification/app/BubblePreferenceController.java @@ -56,7 +56,7 @@ public class BubblePreferenceController extends NotificationPreferenceController public BubblePreferenceController(Context context, @Nullable FragmentManager fragmentManager, NotificationBackend backend, boolean isAppPage, @Nullable NotificationSettings.DependentFieldListener listener) { - super(context, backend); + super(context, backend, KEY); mFragmentManager = fragmentManager; mIsAppPage = isAppPage; mListener = listener; @@ -68,21 +68,24 @@ public class BubblePreferenceController extends NotificationPreferenceController } @Override - public boolean isAvailable() { - if (!super.isAvailable()) { - return false; + public int getAvailabilityStatus() { + if (super.getAvailabilityStatus() == CONDITIONALLY_UNAVAILABLE) { + return CONDITIONALLY_UNAVAILABLE; } if (!mIsAppPage && !isEnabled()) { - return false; + return CONDITIONALLY_UNAVAILABLE; } if (mChannel != null) { if (isDefaultChannel()) { - return true; + return AVAILABLE; } else { - return mAppRow != null && mAppRow.bubblePreference != BUBBLE_PREFERENCE_NONE; + if (mAppRow != null && mAppRow.bubblePreference != BUBBLE_PREFERENCE_NONE) { + return AVAILABLE; + } + return CONDITIONALLY_UNAVAILABLE; } } - return true; + return AVAILABLE; } @Override diff --git a/src/com/android/settings/notification/app/BubbleSummaryPreferenceController.java b/src/com/android/settings/notification/app/BubbleSummaryPreferenceController.java index 51370b16bef..abbe89e6fa8 100644 --- a/src/com/android/settings/notification/app/BubbleSummaryPreferenceController.java +++ b/src/com/android/settings/notification/app/BubbleSummaryPreferenceController.java @@ -42,28 +42,31 @@ public class BubbleSummaryPreferenceController extends NotificationPreferenceCon static final int ON = 1; public BubbleSummaryPreferenceController(Context context, NotificationBackend backend) { - super(context, backend); + super(context, backend, KEY); } @Override - public boolean isAvailable() { - if (!super.isAvailable()) { - return false; + public int getAvailabilityStatus() { + if (super.getAvailabilityStatus() == CONDITIONALLY_UNAVAILABLE) { + return CONDITIONALLY_UNAVAILABLE; } if (mAppRow == null) { - return false; + return CONDITIONALLY_UNAVAILABLE; } if (mChannel != null) { if (!isGloballyEnabled()) { - return false; + return CONDITIONALLY_UNAVAILABLE; } if (isDefaultChannel()) { - return true; + return AVAILABLE; } else { - return mAppRow != null; + return mAppRow != null ? AVAILABLE : CONDITIONALLY_UNAVAILABLE; } } - return isGloballyEnabled() && mBackend.hasSentValidBubble(mAppRow.pkg, mAppRow.uid); + if (isGloballyEnabled() && mBackend.hasSentValidBubble(mAppRow.pkg, mAppRow.uid)) { + return AVAILABLE; + } + return CONDITIONALLY_UNAVAILABLE; } @Override diff --git a/src/com/android/settings/notification/app/ChannelListPreferenceController.java b/src/com/android/settings/notification/app/ChannelListPreferenceController.java index 8db3b21f4be..8d079114a9e 100644 --- a/src/com/android/settings/notification/app/ChannelListPreferenceController.java +++ b/src/com/android/settings/notification/app/ChannelListPreferenceController.java @@ -28,6 +28,7 @@ import android.os.AsyncTask; import android.os.Bundle; import android.provider.Settings; import android.text.TextUtils; +import android.util.Slog; import androidx.annotation.NonNull; import androidx.annotation.Nullable; @@ -39,16 +40,19 @@ import androidx.preference.SwitchPreference; import com.android.settings.R; import com.android.settings.Utils; import com.android.settings.applications.AppInfoBase; +import com.android.settings.core.BasePreferenceController; import com.android.settings.core.SubSettingLauncher; import com.android.settings.notification.NotificationBackend; import com.android.settingslib.PrimarySwitchPreference; import com.android.settingslib.RestrictedSwitchPreference; +import com.android.settingslib.utils.ThreadUtils; import java.util.ArrayList; import java.util.Collections; import java.util.List; -public class ChannelListPreferenceController extends NotificationPreferenceController { +public class ChannelListPreferenceController extends NotificationPreferenceController + implements BasePreferenceController.UiBlocker { private static final String KEY = "channels"; private static final String KEY_GENERAL_CATEGORY = "categories"; @@ -59,7 +63,7 @@ public class ChannelListPreferenceController extends NotificationPreferenceContr private PreferenceCategory mPreference; public ChannelListPreferenceController(Context context, NotificationBackend backend) { - super(context, backend); + super(context, backend, KEY); } @Override @@ -68,20 +72,20 @@ public class ChannelListPreferenceController extends NotificationPreferenceContr } @Override - public boolean isAvailable() { + public int getAvailabilityStatus() { if (mAppRow == null) { - return false; + return CONDITIONALLY_UNAVAILABLE; } if (mAppRow.banned) { - return false; + return CONDITIONALLY_UNAVAILABLE; } if (mChannel != null) { if (mBackend.onlyHasDefaultChannel(mAppRow.pkg, mAppRow.uid) || NotificationChannel.DEFAULT_CHANNEL_ID.equals(mChannel.getId())) { - return false; + return CONDITIONALLY_UNAVAILABLE; } } - return true; + return AVAILABLE; } @Override @@ -91,24 +95,17 @@ public class ChannelListPreferenceController extends NotificationPreferenceContr @Override public void updateState(Preference preference) { - mPreference = (PreferenceCategory) preference; - // Load channel settings - new AsyncTask() { - @Override - protected Void doInBackground(Void... unused) { + mPreference = (PreferenceCategory) preference; + // Load channel settings + ThreadUtils.postOnBackgroundThread(() -> { mChannelGroupList = mBackend.getGroups(mAppRow.pkg, mAppRow.uid).getList(); Collections.sort(mChannelGroupList, CHANNEL_GROUP_COMPARATOR); - return null; - } - - @Override - protected void onPostExecute(Void unused) { - if (mContext == null) { - return; - } + ThreadUtils.getUiThreadHandler().getLooper().prepare(); updateFullList(mPreference, mChannelGroupList); - } - }.execute(); + ThreadUtils.postOnMainThread(() -> { + showPreferences(); + }); + }); } /** @@ -144,6 +141,12 @@ public class ChannelListPreferenceController extends NotificationPreferenceContr } } + private void showPreferences() { + if (mUiBlockListener != null) { + mUiBlockListener.onBlockerWorkFinished(this); + } + } + /** * Looks for the category for the given group's key at the expected index, if that doesn't * match, it checks all groups, and if it can't find that group anywhere, it creates it. diff --git a/src/com/android/settings/notification/app/ConversationDemotePreferenceController.java b/src/com/android/settings/notification/app/ConversationDemotePreferenceController.java index 02f639c3157..ba7ca358b8b 100644 --- a/src/com/android/settings/notification/app/ConversationDemotePreferenceController.java +++ b/src/com/android/settings/notification/app/ConversationDemotePreferenceController.java @@ -37,7 +37,7 @@ public class ConversationDemotePreferenceController extends NotificationPreferen public ConversationDemotePreferenceController(Context context, SettingsPreferenceFragment hostFragment, NotificationBackend backend) { - super(context, backend); + super(context, backend, KEY); mHostFragment = hostFragment; } @@ -47,14 +47,17 @@ public class ConversationDemotePreferenceController extends NotificationPreferen } @Override - public boolean isAvailable() { - if (!super.isAvailable()) { - return false; + public int getAvailabilityStatus() { + if (super.getAvailabilityStatus() == CONDITIONALLY_UNAVAILABLE) { + return CONDITIONALLY_UNAVAILABLE; } if (mAppRow == null || mChannel == null) { - return false; + return CONDITIONALLY_UNAVAILABLE; } - return !TextUtils.isEmpty(mChannel.getConversationId()) && !mChannel.isDemoted(); + if (!TextUtils.isEmpty(mChannel.getConversationId()) && !mChannel.isDemoted()) { + return AVAILABLE; + } + return CONDITIONALLY_UNAVAILABLE; } @Override diff --git a/src/com/android/settings/notification/app/ConversationHeaderPreferenceController.java b/src/com/android/settings/notification/app/ConversationHeaderPreferenceController.java index f99a56aabda..56de88b324a 100644 --- a/src/com/android/settings/notification/app/ConversationHeaderPreferenceController.java +++ b/src/com/android/settings/notification/app/ConversationHeaderPreferenceController.java @@ -45,7 +45,7 @@ public class ConversationHeaderPreferenceController extends NotificationPreferen private boolean mStarted = false; public ConversationHeaderPreferenceController(Context context, DashboardFragment fragment) { - super(context, null); + super(context, null, PREF_KEY_APP_HEADER); mFragment = fragment; } @@ -55,8 +55,8 @@ public class ConversationHeaderPreferenceController extends NotificationPreferen } @Override - public boolean isAvailable() { - return mAppRow != null; + public int getAvailabilityStatus() { + return mAppRow != null ? AVAILABLE : CONDITIONALLY_UNAVAILABLE; } @Override diff --git a/src/com/android/settings/notification/app/ConversationPriorityPreferenceController.java b/src/com/android/settings/notification/app/ConversationPriorityPreferenceController.java index ae169282484..46bc3c0c840 100644 --- a/src/com/android/settings/notification/app/ConversationPriorityPreferenceController.java +++ b/src/com/android/settings/notification/app/ConversationPriorityPreferenceController.java @@ -34,7 +34,7 @@ public class ConversationPriorityPreferenceController extends NotificationPrefer public ConversationPriorityPreferenceController(Context context, NotificationBackend backend, NotificationSettings.DependentFieldListener listener) { - super(context, backend); + super(context, backend, KEY); mDependentFieldListener = listener; } @@ -44,14 +44,14 @@ public class ConversationPriorityPreferenceController extends NotificationPrefer } @Override - public boolean isAvailable() { - if (!super.isAvailable()) { - return false; + public int getAvailabilityStatus() { + if (super.getAvailabilityStatus() == CONDITIONALLY_UNAVAILABLE) { + return CONDITIONALLY_UNAVAILABLE; } if (mAppRow == null || mChannel == null) { - return false; + return CONDITIONALLY_UNAVAILABLE; } - return true; + return AVAILABLE; } @Override diff --git a/src/com/android/settings/notification/app/ConversationPromotePreferenceController.java b/src/com/android/settings/notification/app/ConversationPromotePreferenceController.java index 24c3d2ff6a1..a5ef569d620 100644 --- a/src/com/android/settings/notification/app/ConversationPromotePreferenceController.java +++ b/src/com/android/settings/notification/app/ConversationPromotePreferenceController.java @@ -37,7 +37,7 @@ public class ConversationPromotePreferenceController extends NotificationPrefere public ConversationPromotePreferenceController(Context context, SettingsPreferenceFragment hostFragment, NotificationBackend backend) { - super(context, backend); + super(context, backend, KEY); mHostFragment = hostFragment; } @@ -47,14 +47,17 @@ public class ConversationPromotePreferenceController extends NotificationPrefere } @Override - public boolean isAvailable() { - if (!super.isAvailable()) { - return false; + public int getAvailabilityStatus() { + if (super.getAvailabilityStatus() == CONDITIONALLY_UNAVAILABLE) { + return CONDITIONALLY_UNAVAILABLE; } if (mAppRow == null || mChannel == null) { - return false; + return CONDITIONALLY_UNAVAILABLE; } - return !TextUtils.isEmpty(mChannel.getConversationId()) && mChannel.isDemoted(); + if (!TextUtils.isEmpty(mChannel.getConversationId()) && mChannel.isDemoted()) { + return AVAILABLE; + } + return CONDITIONALLY_UNAVAILABLE; } @Override diff --git a/src/com/android/settings/notification/app/DeletedChannelsPreferenceController.java b/src/com/android/settings/notification/app/DeletedChannelsPreferenceController.java index 77a692f1488..cd160df1fd4 100644 --- a/src/com/android/settings/notification/app/DeletedChannelsPreferenceController.java +++ b/src/com/android/settings/notification/app/DeletedChannelsPreferenceController.java @@ -30,7 +30,7 @@ public class DeletedChannelsPreferenceController extends NotificationPreferenceC private static final String KEY_DELETED = "deleted"; public DeletedChannelsPreferenceController(Context context, NotificationBackend backend) { - super(context, backend); + super(context, backend, KEY_DELETED); } @Override @@ -39,16 +39,19 @@ public class DeletedChannelsPreferenceController extends NotificationPreferenceC } @Override - public boolean isAvailable() { - if (!super.isAvailable()) { - return false; + public int getAvailabilityStatus() { + if (super.getAvailabilityStatus() == CONDITIONALLY_UNAVAILABLE) { + return CONDITIONALLY_UNAVAILABLE; } // only visible on app screen if (mChannel != null || hasValidGroup()) { - return false; + return CONDITIONALLY_UNAVAILABLE; } - return mBackend.getDeletedChannelCount(mAppRow.pkg, mAppRow.uid) > 0; + if (mBackend.getDeletedChannelCount(mAppRow.pkg, mAppRow.uid) > 0) { + return AVAILABLE; + } + return CONDITIONALLY_UNAVAILABLE; } @Override diff --git a/src/com/android/settings/notification/app/DescriptionPreferenceController.java b/src/com/android/settings/notification/app/DescriptionPreferenceController.java index 0a5bb2f9260..413a876cec9 100644 --- a/src/com/android/settings/notification/app/DescriptionPreferenceController.java +++ b/src/com/android/settings/notification/app/DescriptionPreferenceController.java @@ -29,7 +29,7 @@ public class DescriptionPreferenceController extends NotificationPreferenceContr private static final String KEY_DESC = "desc"; public DescriptionPreferenceController(Context context) { - super(context, null); + super(context, null, KEY_DESC); } @Override @@ -38,20 +38,20 @@ public class DescriptionPreferenceController extends NotificationPreferenceContr } @Override - public boolean isAvailable() { - if (!super.isAvailable()) { - return false; + public int getAvailabilityStatus() { + if (super.getAvailabilityStatus() == CONDITIONALLY_UNAVAILABLE) { + return CONDITIONALLY_UNAVAILABLE; } if (mChannel == null && !hasValidGroup()) { - return false; + return CONDITIONALLY_UNAVAILABLE; } if (mChannel != null && !TextUtils.isEmpty(mChannel.getDescription())) { - return true; + return AVAILABLE; } if (hasValidGroup() && !TextUtils.isEmpty(mChannelGroup.getDescription())) { - return true; + return AVAILABLE; } - return false; + return CONDITIONALLY_UNAVAILABLE; } @Override diff --git a/src/com/android/settings/notification/app/DndPreferenceController.java b/src/com/android/settings/notification/app/DndPreferenceController.java index b65928aa915..811eeb4ec79 100644 --- a/src/com/android/settings/notification/app/DndPreferenceController.java +++ b/src/com/android/settings/notification/app/DndPreferenceController.java @@ -31,7 +31,7 @@ public class DndPreferenceController extends NotificationPreferenceController private static final String KEY_BYPASS_DND = "bypass_dnd"; public DndPreferenceController(Context context, NotificationBackend backend) { - super(context, backend); + super(context, backend, KEY_BYPASS_DND); } @Override @@ -40,11 +40,11 @@ public class DndPreferenceController extends NotificationPreferenceController } @Override - public boolean isAvailable() { - if (!super.isAvailable() || mChannel == null) { - return false; + public int getAvailabilityStatus() { + if (super.getAvailabilityStatus() == CONDITIONALLY_UNAVAILABLE || mChannel == null) { + return CONDITIONALLY_UNAVAILABLE; } - return true; + return AVAILABLE; } @Override diff --git a/src/com/android/settings/notification/app/HeaderPreferenceController.java b/src/com/android/settings/notification/app/HeaderPreferenceController.java index 7379d55395b..c4b0e598dff 100644 --- a/src/com/android/settings/notification/app/HeaderPreferenceController.java +++ b/src/com/android/settings/notification/app/HeaderPreferenceController.java @@ -45,7 +45,7 @@ public class HeaderPreferenceController extends NotificationPreferenceController private boolean mStarted = false; public HeaderPreferenceController(Context context, DashboardFragment fragment) { - super(context, null); + super(context, null, PREF_KEY_APP_HEADER); mFragment = fragment; } @@ -55,8 +55,8 @@ public class HeaderPreferenceController extends NotificationPreferenceController } @Override - public boolean isAvailable() { - return mAppRow != null; + public int getAvailabilityStatus() { + return mAppRow != null ? AVAILABLE : CONDITIONALLY_UNAVAILABLE; } @Override diff --git a/src/com/android/settings/notification/app/HighImportancePreferenceController.java b/src/com/android/settings/notification/app/HighImportancePreferenceController.java index d60668b9abe..98dc8a760e2 100644 --- a/src/com/android/settings/notification/app/HighImportancePreferenceController.java +++ b/src/com/android/settings/notification/app/HighImportancePreferenceController.java @@ -37,7 +37,7 @@ public class HighImportancePreferenceController extends NotificationPreferenceCo public HighImportancePreferenceController(Context context, NotificationSettings.DependentFieldListener dependentFieldListener, NotificationBackend backend) { - super(context, backend); + super(context, backend, KEY_IMPORTANCE); mDependentFieldListener = dependentFieldListener; } @@ -47,17 +47,19 @@ public class HighImportancePreferenceController extends NotificationPreferenceCo } @Override - public boolean isAvailable() { - if (!super.isAvailable()) { - return false; + public int getAvailabilityStatus() { + if (super.getAvailabilityStatus() == CONDITIONALLY_UNAVAILABLE) { + return CONDITIONALLY_UNAVAILABLE; } if (mChannel == null) { - return false; + return CONDITIONALLY_UNAVAILABLE; } if (isDefaultChannel()) { - return false; + return CONDITIONALLY_UNAVAILABLE; } - return mChannel.getImportance() >= IMPORTANCE_DEFAULT; + return mChannel.getImportance() >= IMPORTANCE_DEFAULT + ? AVAILABLE + : CONDITIONALLY_UNAVAILABLE; } @Override diff --git a/src/com/android/settings/notification/app/ImportancePreferenceController.java b/src/com/android/settings/notification/app/ImportancePreferenceController.java index 3c32ca4b0bc..31ddac39373 100644 --- a/src/com/android/settings/notification/app/ImportancePreferenceController.java +++ b/src/com/android/settings/notification/app/ImportancePreferenceController.java @@ -38,7 +38,7 @@ public class ImportancePreferenceController extends NotificationPreferenceContro public ImportancePreferenceController(Context context, NotificationSettings.DependentFieldListener dependentFieldListener, NotificationBackend backend) { - super(context, backend); + super(context, backend, KEY_IMPORTANCE); mDependentFieldListener = dependentFieldListener; } @@ -48,14 +48,14 @@ public class ImportancePreferenceController extends NotificationPreferenceContro } @Override - public boolean isAvailable() { - if (!super.isAvailable()) { - return false; + public int getAvailabilityStatus() { + if (super.getAvailabilityStatus() == CONDITIONALLY_UNAVAILABLE) { + return CONDITIONALLY_UNAVAILABLE; } if (mChannel == null) { - return false; + return CONDITIONALLY_UNAVAILABLE; } - return !isDefaultChannel(); + return !isDefaultChannel() ? AVAILABLE : CONDITIONALLY_UNAVAILABLE; } @Override diff --git a/src/com/android/settings/notification/app/InvalidConversationInfoPreferenceController.java b/src/com/android/settings/notification/app/InvalidConversationInfoPreferenceController.java index b937e80e0d6..bb2c58b728b 100644 --- a/src/com/android/settings/notification/app/InvalidConversationInfoPreferenceController.java +++ b/src/com/android/settings/notification/app/InvalidConversationInfoPreferenceController.java @@ -31,7 +31,7 @@ public class InvalidConversationInfoPreferenceController extends NotificationPre public InvalidConversationInfoPreferenceController(Context context, NotificationBackend backend) { - super(context, backend); + super(context, backend, KEY); } @Override @@ -40,17 +40,19 @@ public class InvalidConversationInfoPreferenceController extends NotificationPre } @Override - public boolean isAvailable() { + public int getAvailabilityStatus() { if (mAppRow == null) { - return false; + return CONDITIONALLY_UNAVAILABLE; } if (mAppRow.banned) { - return false; + return CONDITIONALLY_UNAVAILABLE; } if (mPreferenceFilter != null && !isIncludedInFilter()) { - return false; + return CONDITIONALLY_UNAVAILABLE; } - return mBackend.isInInvalidMsgState(mAppRow.pkg, mAppRow.uid); + return mBackend.isInInvalidMsgState(mAppRow.pkg, mAppRow.uid) + ? AVAILABLE + : CONDITIONALLY_UNAVAILABLE; } @Override diff --git a/src/com/android/settings/notification/app/InvalidConversationPreferenceController.java b/src/com/android/settings/notification/app/InvalidConversationPreferenceController.java index 5c502dccbe0..219ccbcea85 100644 --- a/src/com/android/settings/notification/app/InvalidConversationPreferenceController.java +++ b/src/com/android/settings/notification/app/InvalidConversationPreferenceController.java @@ -31,7 +31,7 @@ public class InvalidConversationPreferenceController extends NotificationPrefere private static final String KEY = "invalid_conversation_switch"; public InvalidConversationPreferenceController(Context context, NotificationBackend backend) { - super(context, backend); + super(context, backend, KEY); } @Override @@ -40,17 +40,19 @@ public class InvalidConversationPreferenceController extends NotificationPrefere } @Override - public boolean isAvailable() { + public int getAvailabilityStatus() { if (mAppRow == null) { - return false; + return CONDITIONALLY_UNAVAILABLE; } if (mAppRow.banned) { - return false; + return CONDITIONALLY_UNAVAILABLE; } if (mPreferenceFilter != null && !isIncludedInFilter()) { - return false; + return CONDITIONALLY_UNAVAILABLE; } - return mBackend.isInInvalidMsgState(mAppRow.pkg, mAppRow.uid); + return mBackend.isInInvalidMsgState(mAppRow.pkg, mAppRow.uid) + ? AVAILABLE + : CONDITIONALLY_UNAVAILABLE; } @Override diff --git a/src/com/android/settings/notification/app/LightsPreferenceController.java b/src/com/android/settings/notification/app/LightsPreferenceController.java index d096922e348..f7f92442c9b 100644 --- a/src/com/android/settings/notification/app/LightsPreferenceController.java +++ b/src/com/android/settings/notification/app/LightsPreferenceController.java @@ -33,7 +33,7 @@ public class LightsPreferenceController extends NotificationPreferenceController private static final String KEY_LIGHTS = "lights"; public LightsPreferenceController(Context context, NotificationBackend backend) { - super(context, backend); + super(context, backend, KEY_LIGHTS); } @Override @@ -42,16 +42,18 @@ public class LightsPreferenceController extends NotificationPreferenceController } @Override - public boolean isAvailable() { - if (!super.isAvailable()) { - return false; + public int getAvailabilityStatus() { + if (super.getAvailabilityStatus() == CONDITIONALLY_UNAVAILABLE) { + return CONDITIONALLY_UNAVAILABLE; } if (mChannel == null) { - return false; + return CONDITIONALLY_UNAVAILABLE; } - return checkCanBeVisible(NotificationManager.IMPORTANCE_DEFAULT) - && canPulseLight() - && !isDefaultChannel(); + if (checkCanBeVisible(NotificationManager.IMPORTANCE_DEFAULT) && canPulseLight() + && !isDefaultChannel()) { + return AVAILABLE; + } + return CONDITIONALLY_UNAVAILABLE; } @Override diff --git a/src/com/android/settings/notification/app/MinImportancePreferenceController.java b/src/com/android/settings/notification/app/MinImportancePreferenceController.java index f8257636615..b2c0862b8f8 100644 --- a/src/com/android/settings/notification/app/MinImportancePreferenceController.java +++ b/src/com/android/settings/notification/app/MinImportancePreferenceController.java @@ -37,7 +37,7 @@ public class MinImportancePreferenceController extends NotificationPreferenceCon public MinImportancePreferenceController(Context context, NotificationSettings.DependentFieldListener dependentFieldListener, NotificationBackend backend) { - super(context, backend); + super(context, backend, KEY_IMPORTANCE); mDependentFieldListener = dependentFieldListener; } @@ -47,17 +47,17 @@ public class MinImportancePreferenceController extends NotificationPreferenceCon } @Override - public boolean isAvailable() { - if (!super.isAvailable()) { - return false; + public int getAvailabilityStatus() { + if (super.getAvailabilityStatus() == CONDITIONALLY_UNAVAILABLE) { + return CONDITIONALLY_UNAVAILABLE; } if (mChannel == null) { - return false; + return CONDITIONALLY_UNAVAILABLE; } if (isDefaultChannel()) { - return false; + return CONDITIONALLY_UNAVAILABLE; } - return mChannel.getImportance() <= IMPORTANCE_LOW; + return mChannel.getImportance() <= IMPORTANCE_LOW ? AVAILABLE : CONDITIONALLY_UNAVAILABLE; } @Override diff --git a/src/com/android/settings/notification/app/NotificationPreferenceController.java b/src/com/android/settings/notification/app/NotificationPreferenceController.java index fb19d9d6b4c..271a83d76f8 100644 --- a/src/com/android/settings/notification/app/NotificationPreferenceController.java +++ b/src/com/android/settings/notification/app/NotificationPreferenceController.java @@ -17,26 +17,24 @@ package com.android.settings.notification.app; import static android.app.NotificationManager.IMPORTANCE_NONE; -import static android.os.UserHandle.USER_SYSTEM; import android.annotation.Nullable; 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; import android.os.UserManager; -import android.provider.Settings; import android.util.Log; +import android.util.Slog; import androidx.preference.Preference; +import com.android.settings.core.BasePreferenceController; import com.android.settings.notification.NotificationBackend; import com.android.settingslib.RestrictedLockUtils; -import com.android.settingslib.core.AbstractPreferenceController; import java.util.Comparator; import java.util.List; @@ -46,7 +44,7 @@ import java.util.Objects; * Parent class for preferences appearing on notification setting pages at the app, * notification channel group, or notification channel level. */ -public abstract class NotificationPreferenceController extends AbstractPreferenceController { +public abstract class NotificationPreferenceController extends BasePreferenceController { private static final String TAG = "ChannelPrefContr"; @Nullable protected NotificationChannel mChannel; @@ -71,8 +69,11 @@ public abstract class NotificationPreferenceController extends AbstractPreferenc boolean overrideCanBlockValue; boolean overrideCanConfigureValue; - public NotificationPreferenceController(Context context, NotificationBackend backend) { - super(context); + boolean mLoadedChannelState; + + public NotificationPreferenceController(Context context, NotificationBackend backend, + String key) { + super(context, key); mContext = context; mNm = (NotificationManager) mContext.getSystemService(Context.NOTIFICATION_SERVICE); mBackend = backend; @@ -81,28 +82,30 @@ public abstract class NotificationPreferenceController extends AbstractPreferenc } /** - * Returns true if field's parent object is not blocked. + * Returns available if field's parent object is not blocked. */ @Override - public boolean isAvailable() { + public int getAvailabilityStatus() { if (mAppRow == null) { - return false; + return CONDITIONALLY_UNAVAILABLE; } if (mAppRow.banned) { - return false; + return CONDITIONALLY_UNAVAILABLE; } if (mChannelGroup != null) { if (mChannelGroup.isBlocked()) { - return false; + return CONDITIONALLY_UNAVAILABLE; } } if (mChannel != null) { if (mPreferenceFilter != null && !isIncludedInFilter()) { - return false; + return CONDITIONALLY_UNAVAILABLE; + } + if(mChannel.getImportance() == IMPORTANCE_NONE) { + return CONDITIONALLY_UNAVAILABLE; } - return mChannel.getImportance() != IMPORTANCE_NONE; } - return true; + return AVAILABLE; } protected void onResume(NotificationBackend.AppRow appRow, diff --git a/src/com/android/settings/notification/app/NotificationSettings.java b/src/com/android/settings/notification/app/NotificationSettings.java index 192a0ee9fc7..5750167c271 100644 --- a/src/com/android/settings/notification/app/NotificationSettings.java +++ b/src/com/android/settings/notification/app/NotificationSettings.java @@ -41,6 +41,7 @@ import android.os.UserHandle; import android.provider.Settings; import android.text.TextUtils; import android.util.Log; +import android.util.Slog; import android.view.View; import android.view.ViewGroup; import android.view.ViewTreeObserver; @@ -129,15 +130,52 @@ abstract public class NotificationSettings extends DashboardFragment { } } + mUserId = UserHandle.getUserId(mUid); mPkgInfo = findPackageInfo(mPkg, mUid); + } + @Override + public void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + + if (mIntent == null && mArgs == null) { + toastAndFinish("no intent"); + return; + } + + if (mUid < 0 || TextUtils.isEmpty(mPkg) || mPkgInfo == null) { + toastAndFinish("Missing package or uid or packageinfo"); + return; + } + + startListeningToPackageRemove(); + } + + @Override + public void onDestroy() { + stopListeningToPackageRemove(); + super.onDestroy(); + } + + @Override + public void onResume() { + super.onResume(); + if (mUid < 0 || TextUtils.isEmpty(mPkg) || mPkgInfo == null) { + toastAndFinish("Missing package or uid or packageinfo"); + return; + } + mPkgInfo = findPackageInfo(mPkg, mUid); if (mPkgInfo != null) { - mUserId = UserHandle.getUserId(mUid); mSuspendedAppsAdmin = RestrictedLockUtilsInternal.checkIfApplicationIsSuspended( mContext, mPkg, mUserId); - loadChannel(); loadAppRow(); + if (mAppRow == null) { + toastAndFinish("Can't load package"); + return; + } + loadChannel(); + loadConversation(); loadChannelGroup(); loadPreferencesFilter(); collectConfigActivities(); @@ -157,55 +195,6 @@ abstract public class NotificationSettings extends DashboardFragment { } } - @Override - public void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - - if (mIntent == null && mArgs == null) { - Log.w(TAG, "No intent"); - toastAndFinish(); - return; - } - - if (mUid < 0 || TextUtils.isEmpty(mPkg) || mPkgInfo == null) { - Log.w(TAG, "Missing package or uid or packageinfo"); - toastAndFinish(); - return; - } - - startListeningToPackageRemove(); - } - - @Override - public void onDestroy() { - stopListeningToPackageRemove(); - super.onDestroy(); - } - - @Override - public void onResume() { - super.onResume(); - if (mUid < 0 || TextUtils.isEmpty(mPkg) || mPkgInfo == null || mAppRow == null) { - Log.w(TAG, "Missing package or uid or packageinfo"); - finish(); - return; - } - // Reload app, channel, etc onResume in case they've changed. A little wasteful if we've - // just done onAttach but better than making every preference controller reload all - // the data - loadAppRow(); - if (mAppRow == null) { - Log.w(TAG, "Can't load package"); - finish(); - return; - } - loadChannel(); - loadConversation(); - loadChannelGroup(); - loadPreferencesFilter(); - collectConfigActivities(); - } - protected void animatePanel() { if (mPreferenceFilter != null) { mLayoutView = getActivity().findViewById(R.id.main_content); @@ -307,7 +296,8 @@ abstract public class NotificationSettings extends DashboardFragment { } } - protected void toastAndFinish() { + protected void toastAndFinish(String msg) { + Log.w(TAG, msg); Toast.makeText(mContext, R.string.app_not_found_dlg_text, Toast.LENGTH_SHORT).show(); getActivity().finish(); } diff --git a/src/com/android/settings/notification/app/NotificationsOffPreferenceController.java b/src/com/android/settings/notification/app/NotificationsOffPreferenceController.java index 0c7cd2361e2..46625c3101a 100644 --- a/src/com/android/settings/notification/app/NotificationsOffPreferenceController.java +++ b/src/com/android/settings/notification/app/NotificationsOffPreferenceController.java @@ -30,7 +30,7 @@ public class NotificationsOffPreferenceController extends NotificationPreference private static final String KEY_BLOCKED_DESC = "block_desc"; public NotificationsOffPreferenceController(Context context) { - super(context, null); + super(context, null, KEY_BLOCKED_DESC); } @Override @@ -39,16 +39,20 @@ public class NotificationsOffPreferenceController extends NotificationPreference } @Override - public boolean isAvailable() { + public int getAvailabilityStatus() { if (mAppRow == null) { - return false; + return CONDITIONALLY_UNAVAILABLE; } if (mPreferenceFilter != null && !isIncludedInFilter()) { - return false; + return CONDITIONALLY_UNAVAILABLE; } // Available only when other controllers are unavailable - this UI replaces the UI that // would give more detailed notification controls. - return !super.isAvailable(); + if (super.getAvailabilityStatus() == AVAILABLE) { + return CONDITIONALLY_UNAVAILABLE; + } else { + return AVAILABLE; + } } @Override diff --git a/src/com/android/settings/notification/app/SoundPreferenceController.java b/src/com/android/settings/notification/app/SoundPreferenceController.java index b23b4fc86cb..335b44226ce 100644 --- a/src/com/android/settings/notification/app/SoundPreferenceController.java +++ b/src/com/android/settings/notification/app/SoundPreferenceController.java @@ -47,7 +47,7 @@ public class SoundPreferenceController extends NotificationPreferenceController public SoundPreferenceController(Context context, SettingsPreferenceFragment hostFragment, NotificationSettings.DependentFieldListener dependentFieldListener, NotificationBackend backend) { - super(context, backend); + super(context, backend, KEY_SOUND); mFragment = hostFragment; mListener = dependentFieldListener; } @@ -58,14 +58,17 @@ public class SoundPreferenceController extends NotificationPreferenceController } @Override - public boolean isAvailable() { - if (!super.isAvailable()) { - return false; + public int getAvailabilityStatus() { + if (super.getAvailabilityStatus() == CONDITIONALLY_UNAVAILABLE) { + return CONDITIONALLY_UNAVAILABLE; } if (mChannel == null) { - return false; + return CONDITIONALLY_UNAVAILABLE; } - return checkCanBeVisible(NotificationManager.IMPORTANCE_DEFAULT) && !isDefaultChannel(); + if (checkCanBeVisible(NotificationManager.IMPORTANCE_DEFAULT) && !isDefaultChannel()) { + return AVAILABLE; + } + return CONDITIONALLY_UNAVAILABLE; } @Override diff --git a/src/com/android/settings/notification/app/VibrationPreferenceController.java b/src/com/android/settings/notification/app/VibrationPreferenceController.java index 34d1a543b56..f91999f074d 100644 --- a/src/com/android/settings/notification/app/VibrationPreferenceController.java +++ b/src/com/android/settings/notification/app/VibrationPreferenceController.java @@ -34,7 +34,7 @@ public class VibrationPreferenceController extends NotificationPreferenceControl private final Vibrator mVibrator; public VibrationPreferenceController(Context context, NotificationBackend backend) { - super(context, backend); + super(context, backend, KEY_VIBRATE); mVibrator = context.getSystemService(Vibrator.class); } @@ -44,14 +44,15 @@ public class VibrationPreferenceController extends NotificationPreferenceControl } @Override - public boolean isAvailable() { - if (!super.isAvailable() || mChannel == null) { - return false; - } - return checkCanBeVisible(NotificationManager.IMPORTANCE_DEFAULT) - && !isDefaultChannel() - && mVibrator != null - && mVibrator.hasVibrator(); + public int getAvailabilityStatus() { + if (super.getAvailabilityStatus() == CONDITIONALLY_UNAVAILABLE || mChannel == null) { + return CONDITIONALLY_UNAVAILABLE; + } + if (checkCanBeVisible(NotificationManager.IMPORTANCE_DEFAULT) && !isDefaultChannel() + && mVibrator != null && mVibrator.hasVibrator()) { + return AVAILABLE; + } + return CONDITIONALLY_UNAVAILABLE; } @Override diff --git a/src/com/android/settings/notification/app/VisibilityPreferenceController.java b/src/com/android/settings/notification/app/VisibilityPreferenceController.java index a2a1d76b71c..3f33267a749 100644 --- a/src/com/android/settings/notification/app/VisibilityPreferenceController.java +++ b/src/com/android/settings/notification/app/VisibilityPreferenceController.java @@ -48,7 +48,7 @@ public class VisibilityPreferenceController extends NotificationPreferenceContro public VisibilityPreferenceController(Context context, LockPatternUtils utils, NotificationBackend backend) { - super(context, backend); + super(context, backend, KEY_VISIBILITY_OVERRIDE); mLockPatternUtils = utils; } @@ -58,14 +58,18 @@ public class VisibilityPreferenceController extends NotificationPreferenceContro } @Override - public boolean isAvailable() { - if (!super.isAvailable()) { - return false; + public int getAvailabilityStatus() { + if (super.getAvailabilityStatus() == CONDITIONALLY_UNAVAILABLE) { + return CONDITIONALLY_UNAVAILABLE; } if (mChannel == null || mAppRow.banned) { - return false; + return CONDITIONALLY_UNAVAILABLE; } - return checkCanBeVisible(NotificationManager.IMPORTANCE_LOW) && isLockScreenSecure(); + if (checkCanBeVisible(NotificationManager.IMPORTANCE_LOW) && isLockScreenSecure()) { + return AVAILABLE; + } + + return CONDITIONALLY_UNAVAILABLE; } @Override 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 b2f1673f317..bf529e67568 100644 --- a/tests/robotests/src/com/android/settings/notification/app/NotificationPreferenceControllerTest.java +++ b/tests/robotests/src/com/android/settings/notification/app/NotificationPreferenceControllerTest.java @@ -426,7 +426,7 @@ public class NotificationPreferenceControllerTest { private final class TestPreferenceController extends NotificationPreferenceController { private TestPreferenceController(Context context, NotificationBackend backend) { - super(context, backend); + super(context, backend, "key"); } @Override From 65f53e98e352580cba8892c3c0c4194d782b5593 Mon Sep 17 00:00:00 2001 From: Vincent Wang Date: Thu, 21 Jul 2022 16:52:37 +0800 Subject: [PATCH 3/9] Fix Delete face model button flicker Update the visibility of button in onCreate & onActivityResult to avoid button flicker Bug: 191112124 Test: Reference reproduce step in b/191112124 Change-Id: I68e42433631db27e3f8f03ab4fc68e2326852f9b --- .../settings/biometrics/face/FaceSettings.java | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/com/android/settings/biometrics/face/FaceSettings.java b/src/com/android/settings/biometrics/face/FaceSettings.java index dc94376b91d..3710528ef4c 100644 --- a/src/com/android/settings/biometrics/face/FaceSettings.java +++ b/src/com/android/settings/biometrics/face/FaceSettings.java @@ -203,6 +203,10 @@ public class FaceSettings extends DashboardFragment { if (savedInstanceState != null) { mToken = savedInstanceState.getByteArray(KEY_TOKEN); } + + final boolean hasEnrolled = mFaceManager.hasEnrolledTemplates(mUserId); + mEnrollButton.setVisible(!hasEnrolled); + mRemoveButton.setVisible(hasEnrolled); } @Override @@ -230,10 +234,6 @@ public class FaceSettings extends DashboardFragment { mEnrollController.setToken(mToken); } - final boolean hasEnrolled = mFaceManager.hasEnrolledTemplates(mUserId); - mEnrollButton.setVisible(!hasEnrolled); - mRemoveButton.setVisible(hasEnrolled); - if (!mFaceFeatureProvider.isAttentionSupported(getContext())) { removePreference(FaceSettingsAttentionPreferenceController.KEY); } @@ -261,6 +261,10 @@ public class FaceSettings extends DashboardFragment { mEnrollController.setToken(mToken); mConfirmingPassword = false; }); + + final boolean hasEnrolled = mFaceManager.hasEnrolledTemplates(mUserId); + mEnrollButton.setVisible(!hasEnrolled); + mRemoveButton.setVisible(hasEnrolled); } } else if (requestCode == ENROLL_REQUEST) { if (resultCode == RESULT_TIMEOUT) { From 1bda6428c234431234782efca65d1637b0729d7d Mon Sep 17 00:00:00 2001 From: kellyz Date: Fri, 22 Jul 2022 10:23:28 +0800 Subject: [PATCH 4/9] Enable predictive back gesture for Settings app. Bug: 238729272 Test: manually tested on device Change-Id: Ib75902d1d7bbd289705cb62ef00d5840676bda72 --- AndroidManifest.xml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/AndroidManifest.xml b/AndroidManifest.xml index 938e33d0fee..2ff62cced30 100644 --- a/AndroidManifest.xml +++ b/AndroidManifest.xml @@ -132,7 +132,8 @@ android:defaultToDeviceProtectedStorage="true" android:directBootAware="true" android:appComponentFactory="androidx.core.app.CoreComponentFactory" - android:gwpAsanMode="always"> + android:gwpAsanMode="always" + android:enableOnBackInvokedCallback="true"> From d34c775b59d677bb25341cdffe9206b642591e9e Mon Sep 17 00:00:00 2001 From: Bill Yi Date: Thu, 21 Jul 2022 23:01:08 -0700 Subject: [PATCH 5/9] Import translations. DO NOT MERGE ANYWHERE Auto-generated-cl: translation import Change-Id: Ib1f37eb6e359d977359e2fd67f60ffe03ef28896 --- res/values-te/arrays.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/res/values-te/arrays.xml b/res/values-te/arrays.xml index e220e4f28cb..aa8bedadc2a 100644 --- a/res/values-te/arrays.xml +++ b/res/values-te/arrays.xml @@ -222,7 +222,7 @@ "అంతర్గత పరికర నిల్వ" "తీసివేయదగిన SD కార్డు" - "సిస్టమ్ నిర్ణయించుకునేలా అనుమతించు" + "సిస్టమ్ నిర్ణయించుకునేలా అనుమతించండి" "లొకేషన్" @@ -453,7 +453,7 @@ "అడగండి" "ఎప్పటికీ అనుమతించవద్దు" - "ఎల్లప్పుడూ అనుమతించు" + "ఎల్లప్పుడూ అనుమతించండి" "సాధారణం" From 04531538c2614a22c75a7979627e73cfebb2edd2 Mon Sep 17 00:00:00 2001 From: Bill Yi Date: Thu, 21 Jul 2022 23:02:36 -0700 Subject: [PATCH 6/9] Import translations. DO NOT MERGE ANYWHERE Auto-generated-cl: translation import Change-Id: Ic6afe4d66b49f6e961977912550f1f3f724f816f --- res/values-te/arrays.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/res/values-te/arrays.xml b/res/values-te/arrays.xml index e220e4f28cb..aa8bedadc2a 100644 --- a/res/values-te/arrays.xml +++ b/res/values-te/arrays.xml @@ -222,7 +222,7 @@ "అంతర్గత పరికర నిల్వ" "తీసివేయదగిన SD కార్డు" - "సిస్టమ్ నిర్ణయించుకునేలా అనుమతించు" + "సిస్టమ్ నిర్ణయించుకునేలా అనుమతించండి" "లొకేషన్" @@ -453,7 +453,7 @@ "అడగండి" "ఎప్పటికీ అనుమతించవద్దు" - "ఎల్లప్పుడూ అనుమతించు" + "ఎల్లప్పుడూ అనుమతించండి" "సాధారణం" From 33dda10ae7c00a833642dc8a645cc6561bd38fc4 Mon Sep 17 00:00:00 2001 From: menghanli Date: Fri, 22 Jul 2022 15:38:09 +0800 Subject: [PATCH 7/9] Remove obsoleted code: AccessibilityGestureNavigationTutorial Don't show the button tutorial when changing into sysem button navigation Bug: 197695932 Test: make RunSettingsRoboTest Change-Id: Ied90a602cd3228ee6f36b4b50fb1c019429a271e --- ...ccessibilityGestureNavigationTutorial.java | 58 ------------------- 1 file changed, 58 deletions(-) diff --git a/src/com/android/settings/accessibility/AccessibilityGestureNavigationTutorial.java b/src/com/android/settings/accessibility/AccessibilityGestureNavigationTutorial.java index 95469d4bc2f..bceed73d4b8 100644 --- a/src/com/android/settings/accessibility/AccessibilityGestureNavigationTutorial.java +++ b/src/com/android/settings/accessibility/AccessibilityGestureNavigationTutorial.java @@ -24,7 +24,6 @@ import static com.android.settings.accessibility.AccessibilityUtil.UserShortcutT import android.app.settings.SettingsEnums; import android.content.Context; import android.content.DialogInterface; -import android.content.res.TypedArray; import android.graphics.drawable.Drawable; import android.text.Spannable; import android.text.SpannableString; @@ -43,7 +42,6 @@ import android.widget.TextSwitcher; import android.widget.TextView; import androidx.annotation.AnimRes; -import androidx.annotation.ColorInt; import androidx.annotation.DrawableRes; import androidx.annotation.IntDef; import androidx.annotation.NonNull; @@ -51,7 +49,6 @@ import androidx.annotation.Nullable; import androidx.annotation.RawRes; import androidx.annotation.VisibleForTesting; import androidx.appcompat.app.AlertDialog; -import androidx.core.content.ContextCompat; import androidx.core.util.Preconditions; import androidx.core.widget.TextViewCompat; import androidx.viewpager.widget.PagerAdapter; @@ -112,17 +109,6 @@ public final class AccessibilityGestureNavigationTutorial { alertDialog.show(); } - static AlertDialog showAccessibilityButtonTutorialDialog(Context context) { - final AlertDialog alertDialog = createDialog(context, - DialogType.LAUNCH_SERVICE_BY_ACCESSIBILITY_BUTTON); - - if (!AccessibilityUtil.isGestureNavigateEnabled(context)) { - updateMessageWithIcon(context, alertDialog); - } - - return alertDialog; - } - static AlertDialog showAccessibilityGestureTutorialDialog(Context context) { return createDialog(context, DialogType.LAUNCH_SERVICE_BY_ACCESSIBILITY_GESTURE); } @@ -218,50 +204,6 @@ public final class AccessibilityGestureNavigationTutorial { return alertDialog; } - private static void updateMessageWithIcon(Context context, AlertDialog alertDialog) { - final TextView gestureTutorialMessage = alertDialog.findViewById( - R.id.button_tutorial_message); - - // Get the textView line height to update [icon] size. Must be called after show() - final int lineHeight = gestureTutorialMessage.getLineHeight(); - gestureTutorialMessage.setText(getMessageStringWithIcon(context, lineHeight)); - } - - private static SpannableString getMessageStringWithIcon(Context context, int lineHeight) { - final String messageString = context - .getString(R.string.accessibility_tutorial_dialog_message_button); - final SpannableString spannableMessage = SpannableString.valueOf(messageString); - - // Icon - final int indexIconStart = messageString.indexOf("%s"); - final int indexIconEnd = indexIconStart + 2; - final Drawable icon = context.getDrawable(R.drawable.ic_accessibility_new); - final ImageSpan imageSpan = new ImageSpan(icon); - imageSpan.setContentDescription(""); - icon.setBounds(0, 0, lineHeight, lineHeight); - spannableMessage.setSpan( - imageSpan, indexIconStart, indexIconEnd, - Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); - - return spannableMessage; - } - - /** Returns the color associated with the specified attribute in the context's theme. */ - @ColorInt - private static int getThemeAttrColor(final Context context, final int attributeColor) { - final int colorResId = getAttrResourceId(context, attributeColor); - return ContextCompat.getColor(context, colorResId); - } - - /** Returns the identifier of the resolved resource assigned to the given attribute. */ - private static int getAttrResourceId(final Context context, final int attributeColor) { - final int[] attrs = {attributeColor}; - final TypedArray typedArray = context.obtainStyledAttributes(attrs); - final int colorResId = typedArray.getResourceId(0, 0); - typedArray.recycle(); - return colorResId; - } - private static class TutorialPagerAdapter extends PagerAdapter { private final List mTutorialPages; private TutorialPagerAdapter(List tutorialPages) { From 16db5370eb40755e768e812896dc43e589e39c88 Mon Sep 17 00:00:00 2001 From: Yohei Yukawa Date: Fri, 22 Jul 2022 07:45:04 -0700 Subject: [PATCH 8/9] Grant CONTROL_UI_TRACING permission to Settings app We are going to guard the following IPCs with CONTROL_UI_TRACING permission [1]. * IWindowManager#startWindowTrace() * IWindowManager#stopWindowTrace() * IInputMethodManager#startImeTrace() * IInputMethodManager#stopImeTrace() For QS DevelopmentTiles to continue being allowed to access those IPCs, this CL gives CONTROL_UI_TRACING to the Settings app. [1]: Ibdeb38dc9a066cb8ed2904adcdac29014b166526 2ad02a383b036b02a836a50a43c679a17c2fde6b Bug: 172444310 Test: Manually verified as follows. 1. build aosp_coral-userdebug and flash it. 2. adb shell dumpsys package com.android.settings 3. Verify that android.permission.CONTROL_UI_TRACING is granted. Change-Id: I2165ce38e5897ea0321fad9d54047e964a0a6ddb --- AndroidManifest.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/AndroidManifest.xml b/AndroidManifest.xml index 938e33d0fee..7096befe2b3 100644 --- a/AndroidManifest.xml +++ b/AndroidManifest.xml @@ -16,6 +16,7 @@ + From 1177e857af07b7b63b311106a8a92060420eac86 Mon Sep 17 00:00:00 2001 From: Luigi Zevola Date: Fri, 22 Jul 2022 20:38:01 +0000 Subject: [PATCH 9/9] Revert "Grant CONTROL_UI_TRACING permission to Settings app" Revert submission 19391474-yukawa-b172444310 Reason for revert: b/239969206 Reverted Changes: I34bc22392:Allow com.android.settings to have CONTROL_UI_TRAC... I2165ce38e:Grant CONTROL_UI_TRACING permission to Settings ap... Change-Id: I4c9db66d852baa25c7f6f7a435639017140f9d5d --- AndroidManifest.xml | 1 - 1 file changed, 1 deletion(-) diff --git a/AndroidManifest.xml b/AndroidManifest.xml index 7096befe2b3..938e33d0fee 100644 --- a/AndroidManifest.xml +++ b/AndroidManifest.xml @@ -16,7 +16,6 @@ -