Merge "Don't cancel passkey entry pairing autonomously" into tm-qpr-dev
diff --git a/color-check-baseline.xml b/color-check-baseline.xml
index edd2d59..b4915b9 100644
--- a/color-check-baseline.xml
+++ b/color-check-baseline.xml
@@ -4405,27 +4405,11 @@
priority="4"
summary="Using hardcoded color"
explanation="Hardcoded color values are bad because theme changes cannot be uniformly applied.Instead use the theme specific colors such as `?android:attr/textColorPrimary` in attributes.
This ensures that a theme change from a light to a dark theme can be uniformlyapplied across the app."
- errorLine1=" <string name="sync_plug" msgid="7956982719077985381">""<font fgcolor="#ffffffff">"Welcome to Google sync!"</font>" \nA Google approach to syncing data to allow access to your contacts, appointments, and more from wherever you are."</string>"
- errorLine2=" ~~~~~~~~~~~~~~~~~~~">
- <location
- file="res/values-en-rXC/strings.xml"
- line="3152"
- column="170"/>
- </issue>
-
- <issue
- id="HardCodedColor"
- severity="Error"
- message="Avoid using hardcoded color"
- category="Correctness"
- priority="4"
- summary="Using hardcoded color"
- explanation="Hardcoded color values are bad because theme changes cannot be uniformly applied.Instead use the theme specific colors such as `?android:attr/textColorPrimary` in attributes.
This ensures that a theme change from a light to a dark theme can be uniformlyapplied across the app."
errorLine1=" <string name="sync_plug" msgid="7956982719077985381"><font fgcolor="#ffffffff">"Welcome to Google sync!"</font>" \nA Google approach to syncing data to allow access to your contacts, appointments and more from wherever you are."</string>"
errorLine2=" ~~~~~~~~~~~~~~~~~~~">
<location
file="res/values-en-rAU/strings.xml"
- line="3157"
+ line="3173"
column="64"/>
</issue>
@@ -4441,7 +4425,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~">
<location
file="res/values-en-rCA/strings.xml"
- line="3157"
+ line="3173"
column="64"/>
</issue>
@@ -4457,7 +4441,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~">
<location
file="res/values-en-rGB/strings.xml"
- line="3157"
+ line="3173"
column="64"/>
</issue>
@@ -4473,7 +4457,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~">
<location
file="res/values-en-rIN/strings.xml"
- line="3157"
+ line="3173"
column="64"/>
</issue>
@@ -4485,11 +4469,27 @@
priority="4"
summary="Using hardcoded color"
explanation="Hardcoded color values are bad because theme changes cannot be uniformly applied.Instead use the theme specific colors such as `?android:attr/textColorPrimary` in attributes.
This ensures that a theme change from a light to a dark theme can be uniformlyapplied across the app."
+ errorLine1=" <string name="sync_plug" msgid="7956982719077985381">""<font fgcolor="#ffffffff">"Welcome to Google sync!"</font>" \nA Google approach to syncing data to allow access to your contacts, appointments, and more from wherever you are."</string>"
+ errorLine2=" ~~~~~~~~~~~~~~~~~~~">
+ <location
+ file="res/values-en-rXC/strings.xml"
+ line="3173"
+ column="170"/>
+ </issue>
+
+ <issue
+ id="HardCodedColor"
+ severity="Error"
+ message="Avoid using hardcoded color"
+ category="Correctness"
+ priority="4"
+ summary="Using hardcoded color"
+ explanation="Hardcoded color values are bad because theme changes cannot be uniformly applied.Instead use the theme specific colors such as `?android:attr/textColorPrimary` in attributes.
This ensures that a theme change from a light to a dark theme can be uniformlyapplied across the app."
errorLine1=" <string name="sync_plug"><font fgcolor="#ffffffff">Welcome to Google sync!</font>"
errorLine2=" ~~~~~~~~~~~~~~~~~~~">
<location
file="res/values/strings.xml"
- line="7160"
+ line="7204"
column="36"/>
</issue>
@@ -4757,11 +4757,43 @@
priority="4"
summary="Using hardcoded color"
explanation="Hardcoded color values are bad because theme changes cannot be uniformly applied.Instead use the theme specific colors such as `?android:attr/textColorPrimary` in attributes.
This ensures that a theme change from a light to a dark theme can be uniformlyapplied across the app."
+ errorLine1=" <item name="wifi_signal_color">@color/setup_wizard_wifi_color_dark</item>"
+ errorLine2=" ^">
+ <location
+ file="res/values/themes_suw.xml"
+ line="145"
+ column="40"/>
+ </issue>
+
+ <issue
+ id="HardCodedColor"
+ severity="Error"
+ message="Avoid using hardcoded color"
+ category="Correctness"
+ priority="4"
+ summary="Using hardcoded color"
+ explanation="Hardcoded color values are bad because theme changes cannot be uniformly applied.Instead use the theme specific colors such as `?android:attr/textColorPrimary` in attributes.
This ensures that a theme change from a light to a dark theme can be uniformlyapplied across the app."
+ errorLine1=" <item name="wifi_signal_color">@color/setup_wizard_wifi_color_light</item>"
+ errorLine2=" ^">
+ <location
+ file="res/values/themes_suw.xml"
+ line="164"
+ column="40"/>
+ </issue>
+
+ <issue
+ id="HardCodedColor"
+ severity="Error"
+ message="Avoid using hardcoded color"
+ category="Correctness"
+ priority="4"
+ summary="Using hardcoded color"
+ explanation="Hardcoded color values are bad because theme changes cannot be uniformly applied.Instead use the theme specific colors such as `?android:attr/textColorPrimary` in attributes.
This ensures that a theme change from a light to a dark theme can be uniformlyapplied across the app."
errorLine1=" <item name="android:colorPrimary">@color/material_grey_100</item>"
errorLine2=" ^">
<location
file="res/values/themes_suw.xml"
- line="196"
+ line="233"
column="43"/>
</issue>
@@ -4777,7 +4809,7 @@
errorLine2=" ^">
<location
file="res/values/themes_suw.xml"
- line="197"
+ line="234"
column="42"/>
</issue>
@@ -4793,7 +4825,7 @@
errorLine2=" ^">
<location
file="res/values/themes_suw.xml"
- line="198"
+ line="235"
column="45"/>
</issue>
diff --git a/res/values/bools.xml b/res/values/bools.xml
new file mode 100644
index 0000000..25c3e0d
--- /dev/null
+++ b/res/values/bools.xml
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+**
+** Copyright 2022, The Android Open Source Project
+**
+** Licensed under the Apache License, Version 2.0 (the "License");
+** you may not use this file except in compliance with the License.
+** You may obtain a copy of the License at
+**
+** http://www.apache.org/licenses/LICENSE-2.0
+**
+** Unless required by applicable law or agreed to in writing, software
+** distributed under the License is distributed on an "AS IS" BASIS,
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+** See the License for the specific language governing permissions and
+** limitations under the License.
+*/
+-->
+<resources>
+ <!-- Referenced outside of Settings to confirm bug fixed - bug involved multiple
+ pending intents with difference only in intent extras, which doesn't work. -->
+ <bool name="config_isSafetyCenterLockScreenPendingIntentFixed">true</bool>
+</resources>
diff --git a/res/values/config.xml b/res/values/config.xml
index fb1859c..00117d7 100755
--- a/res/values/config.xml
+++ b/res/values/config.xml
@@ -49,6 +49,10 @@
<string name="config_wallpaper_picker_class" translatable="false">com.android.settings.Settings$WallpaperSettingsActivity</string>
<!-- Fully-qualified class name for the styles & wallpaper picker activity. -->
<string name="config_styles_and_wallpaper_picker_class" translatable="false"></string>
+ <!-- Action name for the wallpaper picker activity. -->
+ <string name="config_wallpaper_picker_action" translatable="false"></string>
+ <!-- Action name for the styles & wallpaper picker activity. -->
+ <string name="config_styles_and_wallpaper_picker_action" translatable="false"></string>
<!-- Intent extra for wallpaper picker activity. -->
<string name="config_wallpaper_picker_launch_extra" translatable="false">com.android.wallpaper.LAUNCH_SOURCE</string>
diff --git a/src/com/android/settings/development/NotificationChannelWarningsPreferenceController.java b/src/com/android/settings/development/NotificationChannelWarningsPreferenceController.java
index 775b708..22b3f83 100644
--- a/src/com/android/settings/development/NotificationChannelWarningsPreferenceController.java
+++ b/src/com/android/settings/development/NotificationChannelWarningsPreferenceController.java
@@ -38,10 +38,6 @@
final static int SETTING_VALUE_ON = 1;
@VisibleForTesting
final static int SETTING_VALUE_OFF = 0;
- @VisibleForTesting
- final static int DEBUGGING_ENABLED = 1;
- @VisibleForTesting
- final static int DEBUGGING_DISABLED = 0;
public NotificationChannelWarningsPreferenceController(Context context) {
super(context);
@@ -64,9 +60,8 @@
@Override
public void updateState(Preference preference) {
- final int defaultWarningEnabled = isDebuggable() ? DEBUGGING_ENABLED : DEBUGGING_DISABLED;
final int mode = Settings.Global.getInt(mContext.getContentResolver(),
- Settings.Global.SHOW_NOTIFICATION_CHANNEL_WARNINGS, defaultWarningEnabled);
+ Settings.Global.SHOW_NOTIFICATION_CHANNEL_WARNINGS, 0);
((SwitchPreference) mPreference).setChecked(mode != SETTING_VALUE_OFF);
}
diff --git a/src/com/android/settings/development/StayAwakePreferenceController.java b/src/com/android/settings/development/StayAwakePreferenceController.java
index 25a92b2..9ed0ef8 100644
--- a/src/com/android/settings/development/StayAwakePreferenceController.java
+++ b/src/com/android/settings/development/StayAwakePreferenceController.java
@@ -50,7 +50,7 @@
@VisibleForTesting
static final int SETTING_VALUE_ON =
BatteryManager.BATTERY_PLUGGED_AC | BatteryManager.BATTERY_PLUGGED_USB
- | BatteryManager.BATTERY_PLUGGED_WIRELESS;
+ | BatteryManager.BATTERY_PLUGGED_WIRELESS | BatteryManager.BATTERY_PLUGGED_DOCK;
@VisibleForTesting
SettingsObserver mSettingsObserver;
diff --git a/src/com/android/settings/display/WallpaperPreferenceController.java b/src/com/android/settings/display/WallpaperPreferenceController.java
index 00687b2..9972bf9 100644
--- a/src/com/android/settings/display/WallpaperPreferenceController.java
+++ b/src/com/android/settings/display/WallpaperPreferenceController.java
@@ -41,6 +41,8 @@
private final String mWallpaperPackage;
private final String mWallpaperClass;
private final String mStylesAndWallpaperClass;
+ private final String mWallpaperActionName;
+ private final String mStylesAndWallpaperActionName;
private final String mWallpaperLaunchExtra;
public WallpaperPreferenceController(Context context, String key) {
@@ -49,6 +51,9 @@
mWallpaperClass = mContext.getString(R.string.config_wallpaper_picker_class);
mStylesAndWallpaperClass =
mContext.getString(R.string.config_styles_and_wallpaper_picker_class);
+ mWallpaperActionName = mContext.getString(R.string.config_wallpaper_picker_action);
+ mStylesAndWallpaperActionName =
+ mContext.getString(R.string.config_styles_and_wallpaper_picker_action);
mWallpaperLaunchExtra = mContext.getString(R.string.config_wallpaper_picker_launch_extra);
}
@@ -72,6 +77,10 @@
return areStylesAvailable() ? mStylesAndWallpaperClass : mWallpaperClass;
}
+ public String getComponentActionName() {
+ return areStylesAvailable() ? mStylesAndWallpaperActionName : mWallpaperActionName;
+ }
+
public String getKeywords() {
StringBuilder sb = new StringBuilder(mContext.getString(R.string.keywords_wallpaper));
if (areStylesAvailable()) {
diff --git a/src/com/android/settings/notification/AppBubbleListPreferenceController.java b/src/com/android/settings/notification/AppBubbleListPreferenceController.java
index 6ebb376..bf7fcc0 100644
--- a/src/com/android/settings/notification/AppBubbleListPreferenceController.java
+++ b/src/com/android/settings/notification/AppBubbleListPreferenceController.java
@@ -51,7 +51,7 @@
private static final String KEY = "bubble_conversations";
public AppBubbleListPreferenceController(Context context, NotificationBackend backend) {
- super(context, backend, KEY);
+ super(context, backend);
}
@Override
@@ -80,25 +80,25 @@
}
@Override
- public int getAvailabilityStatus() {
+ public boolean isAvailable() {
// 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 CONDITIONALLY_UNAVAILABLE;
+ return false;
}
if (mAppRow.banned) {
- return CONDITIONALLY_UNAVAILABLE;
+ return false;
}
if (mChannel != null) {
if (mBackend.onlyHasDefaultChannel(mAppRow.pkg, mAppRow.uid)
|| NotificationChannel.DEFAULT_CHANNEL_ID.equals(mChannel.getId())) {
- return CONDITIONALLY_UNAVAILABLE;
+ return false;
}
}
if (mAppRow.bubblePreference == BUBBLE_PREFERENCE_NONE) {
- return CONDITIONALLY_UNAVAILABLE;
+ return false;
}
- return AVAILABLE;
+ return true;
}
@VisibleForTesting
diff --git a/src/com/android/settings/notification/app/AddToHomeScreenPreferenceController.java b/src/com/android/settings/notification/app/AddToHomeScreenPreferenceController.java
index 12b8075..e5afd9d 100644
--- a/src/com/android/settings/notification/app/AddToHomeScreenPreferenceController.java
+++ b/src/com/android/settings/notification/app/AddToHomeScreenPreferenceController.java
@@ -32,7 +32,7 @@
private static final String KEY = "add_to_home";
public AddToHomeScreenPreferenceController(Context context, NotificationBackend backend) {
- super(context, backend, KEY);
+ super(context, backend);
}
@Override
@@ -41,11 +41,11 @@
}
@Override
- public int getAvailabilityStatus() {
- if (super.getAvailabilityStatus() == CONDITIONALLY_UNAVAILABLE) {
- return CONDITIONALLY_UNAVAILABLE;
+ public boolean isAvailable() {
+ if (!super.isAvailable()) {
+ return false;
}
- return mConversationInfo != null ? AVAILABLE : CONDITIONALLY_UNAVAILABLE;
+ return mConversationInfo != null;
}
@Override
diff --git a/src/com/android/settings/notification/app/AllowSoundPreferenceController.java b/src/com/android/settings/notification/app/AllowSoundPreferenceController.java
index 99d0873..0664c54 100644
--- a/src/com/android/settings/notification/app/AllowSoundPreferenceController.java
+++ b/src/com/android/settings/notification/app/AllowSoundPreferenceController.java
@@ -40,7 +40,7 @@
public AllowSoundPreferenceController(Context context,
NotificationSettings.DependentFieldListener dependentFieldListener,
NotificationBackend backend) {
- super(context, backend, KEY_IMPORTANCE);
+ super(context, backend);
mDependentFieldListener = dependentFieldListener;
}
@@ -50,14 +50,11 @@
}
@Override
- public int getAvailabilityStatus() {
- if (super.getAvailabilityStatus() == CONDITIONALLY_UNAVAILABLE) {
- return CONDITIONALLY_UNAVAILABLE;
+ public boolean isAvailable() {
+ if (!super.isAvailable()) {
+ return false;
}
- if (mChannel != null && NotificationChannel.DEFAULT_CHANNEL_ID.equals(mChannel.getId())) {
- return AVAILABLE;
- }
- return CONDITIONALLY_UNAVAILABLE;
+ return mChannel != null && NotificationChannel.DEFAULT_CHANNEL_ID.equals(mChannel.getId());
}
diff --git a/src/com/android/settings/notification/app/AppChannelsBypassingDndPreferenceController.java b/src/com/android/settings/notification/app/AppChannelsBypassingDndPreferenceController.java
index 6c2c0c3..92cd911 100644
--- a/src/com/android/settings/notification/app/AppChannelsBypassingDndPreferenceController.java
+++ b/src/com/android/settings/notification/app/AppChannelsBypassingDndPreferenceController.java
@@ -64,7 +64,7 @@
public AppChannelsBypassingDndPreferenceController(
Context context,
NotificationBackend backend) {
- super(context, backend, KEY);
+ super(context, backend);
}
@Override
@@ -110,8 +110,8 @@
}
@Override
- public int getAvailabilityStatus() {
- return mAppRow != null ? AVAILABLE : CONDITIONALLY_UNAVAILABLE;
+ public boolean isAvailable() {
+ return mAppRow != null;
}
@Override
diff --git a/src/com/android/settings/notification/app/AppConversationListPreferenceController.java b/src/com/android/settings/notification/app/AppConversationListPreferenceController.java
index e7b2378..dd44a13 100644
--- a/src/com/android/settings/notification/app/AppConversationListPreferenceController.java
+++ b/src/com/android/settings/notification/app/AppConversationListPreferenceController.java
@@ -49,12 +49,7 @@
protected PreferenceCategory mPreference;
public AppConversationListPreferenceController(Context context, NotificationBackend backend) {
- this(context, backend, KEY);
- }
-
- public AppConversationListPreferenceController(Context context, NotificationBackend backend,
- String key) {
- super(context, backend, key);
+ super(context, backend);
}
@Override
@@ -63,24 +58,21 @@
}
@Override
- public int getAvailabilityStatus() {
+ public boolean isAvailable() {
if (mAppRow == null) {
- return CONDITIONALLY_UNAVAILABLE;
+ return false;
}
if (mAppRow.banned) {
- return CONDITIONALLY_UNAVAILABLE;
+ return false;
}
if (mChannel != null) {
if (mBackend.onlyHasDefaultChannel(mAppRow.pkg, mAppRow.uid)
|| NotificationChannel.DEFAULT_CHANNEL_ID.equals(mChannel.getId())) {
- return CONDITIONALLY_UNAVAILABLE;
+ return false;
}
}
- if (mBackend.hasSentValidMsg(mAppRow.pkg, mAppRow.uid) || mBackend.isInInvalidMsgState(
- mAppRow.pkg, mAppRow.uid)) {
- return AVAILABLE;
- }
- return CONDITIONALLY_UNAVAILABLE;
+ return mBackend.hasSentValidMsg(mAppRow.pkg, mAppRow.uid) || mBackend.isInInvalidMsgState(
+ mAppRow.pkg, mAppRow.uid);
}
@Override
diff --git a/src/com/android/settings/notification/app/AppLinkPreferenceController.java b/src/com/android/settings/notification/app/AppLinkPreferenceController.java
index ecf9670..043ae69 100644
--- a/src/com/android/settings/notification/app/AppLinkPreferenceController.java
+++ b/src/com/android/settings/notification/app/AppLinkPreferenceController.java
@@ -32,7 +32,7 @@
private static final String KEY_APP_LINK = "app_link";
public AppLinkPreferenceController(Context context) {
- super(context, null, KEY_APP_LINK);
+ super(context, null);
}
@Override
@@ -41,11 +41,11 @@
}
@Override
- public int getAvailabilityStatus() {
- if (super.getAvailabilityStatus() == CONDITIONALLY_UNAVAILABLE) {
- return CONDITIONALLY_UNAVAILABLE;
+ public boolean isAvailable() {
+ if (!super.isAvailable()) {
+ return false;
}
- return mAppRow.settingsIntent != null ? AVAILABLE : CONDITIONALLY_UNAVAILABLE;
+ return mAppRow.settingsIntent != null;
}
@Override
diff --git a/src/com/android/settings/notification/app/BadgePreferenceController.java b/src/com/android/settings/notification/app/BadgePreferenceController.java
index f94dfb5..108fa1d 100644
--- a/src/com/android/settings/notification/app/BadgePreferenceController.java
+++ b/src/com/android/settings/notification/app/BadgePreferenceController.java
@@ -38,7 +38,7 @@
public BadgePreferenceController(Context context,
NotificationBackend backend) {
- super(context, backend, KEY_BADGE);
+ super(context, backend);
}
@Override
@@ -47,29 +47,25 @@
}
@Override
- public int getAvailabilityStatus() {
- if (super.getAvailabilityStatus() == CONDITIONALLY_UNAVAILABLE) {
- return CONDITIONALLY_UNAVAILABLE;
+ public boolean isAvailable() {
+ if (!super.isAvailable()) {
+ return false;
}
if (mAppRow == null && mChannel == null) {
- return CONDITIONALLY_UNAVAILABLE;
+ return false;
}
if (Settings.Secure.getInt(mContext.getContentResolver(),
NOTIFICATION_BADGING, SYSTEM_WIDE_ON) == SYSTEM_WIDE_OFF) {
- return CONDITIONALLY_UNAVAILABLE;
+ return false;
}
if (mChannel != null) {
if (isDefaultChannel()) {
- return AVAILABLE;
+ return true;
} else {
- return mAppRow == null
- ? CONDITIONALLY_UNAVAILABLE
- : mAppRow.showBadge
- ? AVAILABLE
- : CONDITIONALLY_UNAVAILABLE;
+ return mAppRow == null ? false : mAppRow.showBadge;
}
}
- return AVAILABLE;
+ return true;
}
@Override
diff --git a/src/com/android/settings/notification/app/BlockPreferenceController.java b/src/com/android/settings/notification/app/BlockPreferenceController.java
index ea3eaeb..f4e2132 100644
--- a/src/com/android/settings/notification/app/BlockPreferenceController.java
+++ b/src/com/android/settings/notification/app/BlockPreferenceController.java
@@ -42,7 +42,7 @@
public BlockPreferenceController(Context context,
NotificationSettings.DependentFieldListener dependentFieldListener,
NotificationBackend backend) {
- super(context, backend, KEY_BLOCK);
+ super(context, backend);
mDependentFieldListener = dependentFieldListener;
}
@@ -52,14 +52,14 @@
}
@Override
- public int getAvailabilityStatus() {
+ public boolean isAvailable() {
if (mAppRow == null) {
- return CONDITIONALLY_UNAVAILABLE;
+ return false;
}
if (mPreferenceFilter != null && !isIncludedInFilter()) {
- return CONDITIONALLY_UNAVAILABLE;
+ return false;
}
- return AVAILABLE;
+ return true;
}
@Override
diff --git a/src/com/android/settings/notification/app/BubbleCategoryPreferenceController.java b/src/com/android/settings/notification/app/BubbleCategoryPreferenceController.java
index da67afe..ad3a10c 100644
--- a/src/com/android/settings/notification/app/BubbleCategoryPreferenceController.java
+++ b/src/com/android/settings/notification/app/BubbleCategoryPreferenceController.java
@@ -32,15 +32,15 @@
static final int ON = 1;
public BubbleCategoryPreferenceController(Context context) {
- super(context, null, KEY);
+ super(context, null);
}
@Override
- public int getAvailabilityStatus() {
- if (super.getAvailabilityStatus() == CONDITIONALLY_UNAVAILABLE) {
- return CONDITIONALLY_UNAVAILABLE;
+ public boolean isAvailable() {
+ if (!super.isAvailable()) {
+ return false;
}
- return areBubblesEnabled() ? AVAILABLE : CONDITIONALLY_UNAVAILABLE;
+ return areBubblesEnabled();
}
@Override
diff --git a/src/com/android/settings/notification/app/BubbleLinkPreferenceController.java b/src/com/android/settings/notification/app/BubbleLinkPreferenceController.java
index ed1c9b5..0b9529b 100644
--- a/src/com/android/settings/notification/app/BubbleLinkPreferenceController.java
+++ b/src/com/android/settings/notification/app/BubbleLinkPreferenceController.java
@@ -32,15 +32,15 @@
static final int ON = 1;
public BubbleLinkPreferenceController(Context context) {
- super(context, null, KEY);
+ super(context, null);
}
@Override
- public int getAvailabilityStatus() {
- if (super.getAvailabilityStatus() == CONDITIONALLY_UNAVAILABLE) {
- return CONDITIONALLY_UNAVAILABLE;
+ public boolean isAvailable() {
+ if (!super.isAvailable()) {
+ return false;
}
- return areBubblesEnabled() ? AVAILABLE : CONDITIONALLY_UNAVAILABLE;
+ return areBubblesEnabled();
}
@Override
diff --git a/src/com/android/settings/notification/app/BubblePreferenceController.java b/src/com/android/settings/notification/app/BubblePreferenceController.java
index 516a45e..351b463 100644
--- a/src/com/android/settings/notification/app/BubblePreferenceController.java
+++ b/src/com/android/settings/notification/app/BubblePreferenceController.java
@@ -56,7 +56,7 @@
public BubblePreferenceController(Context context, @Nullable FragmentManager fragmentManager,
NotificationBackend backend, boolean isAppPage,
@Nullable NotificationSettings.DependentFieldListener listener) {
- super(context, backend, KEY);
+ super(context, backend);
mFragmentManager = fragmentManager;
mIsAppPage = isAppPage;
mListener = listener;
@@ -68,24 +68,21 @@
}
@Override
- public int getAvailabilityStatus() {
- if (super.getAvailabilityStatus() == CONDITIONALLY_UNAVAILABLE) {
- return CONDITIONALLY_UNAVAILABLE;
+ public boolean isAvailable() {
+ if (!super.isAvailable()) {
+ return false;
}
if (!mIsAppPage && !isEnabled()) {
- return CONDITIONALLY_UNAVAILABLE;
+ return false;
}
if (mChannel != null) {
if (isDefaultChannel()) {
- return AVAILABLE;
+ return true;
} else {
- if (mAppRow != null && mAppRow.bubblePreference != BUBBLE_PREFERENCE_NONE) {
- return AVAILABLE;
- }
- return CONDITIONALLY_UNAVAILABLE;
+ return mAppRow != null && mAppRow.bubblePreference != BUBBLE_PREFERENCE_NONE;
}
}
- return AVAILABLE;
+ return true;
}
@Override
diff --git a/src/com/android/settings/notification/app/BubbleSummaryPreferenceController.java b/src/com/android/settings/notification/app/BubbleSummaryPreferenceController.java
index abbe89e..51370b1 100644
--- a/src/com/android/settings/notification/app/BubbleSummaryPreferenceController.java
+++ b/src/com/android/settings/notification/app/BubbleSummaryPreferenceController.java
@@ -42,31 +42,28 @@
static final int ON = 1;
public BubbleSummaryPreferenceController(Context context, NotificationBackend backend) {
- super(context, backend, KEY);
+ super(context, backend);
}
@Override
- public int getAvailabilityStatus() {
- if (super.getAvailabilityStatus() == CONDITIONALLY_UNAVAILABLE) {
- return CONDITIONALLY_UNAVAILABLE;
+ public boolean isAvailable() {
+ if (!super.isAvailable()) {
+ return false;
}
if (mAppRow == null) {
- return CONDITIONALLY_UNAVAILABLE;
+ return false;
}
if (mChannel != null) {
if (!isGloballyEnabled()) {
- return CONDITIONALLY_UNAVAILABLE;
+ return false;
}
if (isDefaultChannel()) {
- return AVAILABLE;
+ return true;
} else {
- return mAppRow != null ? AVAILABLE : CONDITIONALLY_UNAVAILABLE;
+ return mAppRow != null;
}
}
- if (isGloballyEnabled() && mBackend.hasSentValidBubble(mAppRow.pkg, mAppRow.uid)) {
- return AVAILABLE;
- }
- return CONDITIONALLY_UNAVAILABLE;
+ return isGloballyEnabled() && mBackend.hasSentValidBubble(mAppRow.pkg, mAppRow.uid);
}
@Override
diff --git a/src/com/android/settings/notification/app/ChannelListPreferenceController.java b/src/com/android/settings/notification/app/ChannelListPreferenceController.java
index 8d07911..8db3b21 100644
--- a/src/com/android/settings/notification/app/ChannelListPreferenceController.java
+++ b/src/com/android/settings/notification/app/ChannelListPreferenceController.java
@@ -28,7 +28,6 @@
import android.os.Bundle;
import android.provider.Settings;
import android.text.TextUtils;
-import android.util.Slog;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
@@ -40,19 +39,16 @@
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
- implements BasePreferenceController.UiBlocker {
+public class ChannelListPreferenceController extends NotificationPreferenceController {
private static final String KEY = "channels";
private static final String KEY_GENERAL_CATEGORY = "categories";
@@ -63,7 +59,7 @@
private PreferenceCategory mPreference;
public ChannelListPreferenceController(Context context, NotificationBackend backend) {
- super(context, backend, KEY);
+ super(context, backend);
}
@Override
@@ -72,20 +68,20 @@
}
@Override
- public int getAvailabilityStatus() {
+ public boolean isAvailable() {
if (mAppRow == null) {
- return CONDITIONALLY_UNAVAILABLE;
+ return false;
}
if (mAppRow.banned) {
- return CONDITIONALLY_UNAVAILABLE;
+ return false;
}
if (mChannel != null) {
if (mBackend.onlyHasDefaultChannel(mAppRow.pkg, mAppRow.uid)
|| NotificationChannel.DEFAULT_CHANNEL_ID.equals(mChannel.getId())) {
- return CONDITIONALLY_UNAVAILABLE;
+ return false;
}
}
- return AVAILABLE;
+ return true;
}
@Override
@@ -95,17 +91,24 @@
@Override
public void updateState(Preference preference) {
- mPreference = (PreferenceCategory) preference;
- // Load channel settings
- ThreadUtils.postOnBackgroundThread(() -> {
+ mPreference = (PreferenceCategory) preference;
+ // Load channel settings
+ new AsyncTask<Void, Void, Void>() {
+ @Override
+ protected Void doInBackground(Void... unused) {
mChannelGroupList = mBackend.getGroups(mAppRow.pkg, mAppRow.uid).getList();
Collections.sort(mChannelGroupList, CHANNEL_GROUP_COMPARATOR);
- ThreadUtils.getUiThreadHandler().getLooper().prepare();
+ return null;
+ }
+
+ @Override
+ protected void onPostExecute(Void unused) {
+ if (mContext == null) {
+ return;
+ }
updateFullList(mPreference, mChannelGroupList);
- ThreadUtils.postOnMainThread(() -> {
- showPreferences();
- });
- });
+ }
+ }.execute();
}
/**
@@ -141,12 +144,6 @@
}
}
- 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 ba7ca35..02f639c 100644
--- a/src/com/android/settings/notification/app/ConversationDemotePreferenceController.java
+++ b/src/com/android/settings/notification/app/ConversationDemotePreferenceController.java
@@ -37,7 +37,7 @@
public ConversationDemotePreferenceController(Context context,
SettingsPreferenceFragment hostFragment,
NotificationBackend backend) {
- super(context, backend, KEY);
+ super(context, backend);
mHostFragment = hostFragment;
}
@@ -47,17 +47,14 @@
}
@Override
- public int getAvailabilityStatus() {
- if (super.getAvailabilityStatus() == CONDITIONALLY_UNAVAILABLE) {
- return CONDITIONALLY_UNAVAILABLE;
+ public boolean isAvailable() {
+ if (!super.isAvailable()) {
+ return false;
}
if (mAppRow == null || mChannel == null) {
- return CONDITIONALLY_UNAVAILABLE;
+ return false;
}
- if (!TextUtils.isEmpty(mChannel.getConversationId()) && !mChannel.isDemoted()) {
- return AVAILABLE;
- }
- return CONDITIONALLY_UNAVAILABLE;
+ return !TextUtils.isEmpty(mChannel.getConversationId()) && !mChannel.isDemoted();
}
@Override
diff --git a/src/com/android/settings/notification/app/ConversationHeaderPreferenceController.java b/src/com/android/settings/notification/app/ConversationHeaderPreferenceController.java
index 56de88b..f99a56a 100644
--- a/src/com/android/settings/notification/app/ConversationHeaderPreferenceController.java
+++ b/src/com/android/settings/notification/app/ConversationHeaderPreferenceController.java
@@ -45,7 +45,7 @@
private boolean mStarted = false;
public ConversationHeaderPreferenceController(Context context, DashboardFragment fragment) {
- super(context, null, PREF_KEY_APP_HEADER);
+ super(context, null);
mFragment = fragment;
}
@@ -55,8 +55,8 @@
}
@Override
- public int getAvailabilityStatus() {
- return mAppRow != null ? AVAILABLE : CONDITIONALLY_UNAVAILABLE;
+ public boolean isAvailable() {
+ return mAppRow != null;
}
@Override
diff --git a/src/com/android/settings/notification/app/ConversationPriorityPreferenceController.java b/src/com/android/settings/notification/app/ConversationPriorityPreferenceController.java
index 46bc3c0..ae16928 100644
--- a/src/com/android/settings/notification/app/ConversationPriorityPreferenceController.java
+++ b/src/com/android/settings/notification/app/ConversationPriorityPreferenceController.java
@@ -34,7 +34,7 @@
public ConversationPriorityPreferenceController(Context context,
NotificationBackend backend, NotificationSettings.DependentFieldListener listener) {
- super(context, backend, KEY);
+ super(context, backend);
mDependentFieldListener = listener;
}
@@ -44,14 +44,14 @@
}
@Override
- public int getAvailabilityStatus() {
- if (super.getAvailabilityStatus() == CONDITIONALLY_UNAVAILABLE) {
- return CONDITIONALLY_UNAVAILABLE;
+ public boolean isAvailable() {
+ if (!super.isAvailable()) {
+ return false;
}
if (mAppRow == null || mChannel == null) {
- return CONDITIONALLY_UNAVAILABLE;
+ return false;
}
- return AVAILABLE;
+ return true;
}
@Override
diff --git a/src/com/android/settings/notification/app/ConversationPromotePreferenceController.java b/src/com/android/settings/notification/app/ConversationPromotePreferenceController.java
index a5ef569..24c3d2f 100644
--- a/src/com/android/settings/notification/app/ConversationPromotePreferenceController.java
+++ b/src/com/android/settings/notification/app/ConversationPromotePreferenceController.java
@@ -37,7 +37,7 @@
public ConversationPromotePreferenceController(Context context,
SettingsPreferenceFragment hostFragment,
NotificationBackend backend) {
- super(context, backend, KEY);
+ super(context, backend);
mHostFragment = hostFragment;
}
@@ -47,17 +47,14 @@
}
@Override
- public int getAvailabilityStatus() {
- if (super.getAvailabilityStatus() == CONDITIONALLY_UNAVAILABLE) {
- return CONDITIONALLY_UNAVAILABLE;
+ public boolean isAvailable() {
+ if (!super.isAvailable()) {
+ return false;
}
if (mAppRow == null || mChannel == null) {
- return CONDITIONALLY_UNAVAILABLE;
+ return false;
}
- if (!TextUtils.isEmpty(mChannel.getConversationId()) && mChannel.isDemoted()) {
- return AVAILABLE;
- }
- return CONDITIONALLY_UNAVAILABLE;
+ return !TextUtils.isEmpty(mChannel.getConversationId()) && mChannel.isDemoted();
}
@Override
diff --git a/src/com/android/settings/notification/app/DeletedChannelsPreferenceController.java b/src/com/android/settings/notification/app/DeletedChannelsPreferenceController.java
index cd160df..77a692f 100644
--- a/src/com/android/settings/notification/app/DeletedChannelsPreferenceController.java
+++ b/src/com/android/settings/notification/app/DeletedChannelsPreferenceController.java
@@ -30,7 +30,7 @@
private static final String KEY_DELETED = "deleted";
public DeletedChannelsPreferenceController(Context context, NotificationBackend backend) {
- super(context, backend, KEY_DELETED);
+ super(context, backend);
}
@Override
@@ -39,19 +39,16 @@
}
@Override
- public int getAvailabilityStatus() {
- if (super.getAvailabilityStatus() == CONDITIONALLY_UNAVAILABLE) {
- return CONDITIONALLY_UNAVAILABLE;
+ public boolean isAvailable() {
+ if (!super.isAvailable()) {
+ return false;
}
// only visible on app screen
if (mChannel != null || hasValidGroup()) {
- return CONDITIONALLY_UNAVAILABLE;
+ return false;
}
- if (mBackend.getDeletedChannelCount(mAppRow.pkg, mAppRow.uid) > 0) {
- return AVAILABLE;
- }
- return CONDITIONALLY_UNAVAILABLE;
+ return mBackend.getDeletedChannelCount(mAppRow.pkg, mAppRow.uid) > 0;
}
@Override
diff --git a/src/com/android/settings/notification/app/DescriptionPreferenceController.java b/src/com/android/settings/notification/app/DescriptionPreferenceController.java
index 413a876..0a5bb2f 100644
--- a/src/com/android/settings/notification/app/DescriptionPreferenceController.java
+++ b/src/com/android/settings/notification/app/DescriptionPreferenceController.java
@@ -29,7 +29,7 @@
private static final String KEY_DESC = "desc";
public DescriptionPreferenceController(Context context) {
- super(context, null, KEY_DESC);
+ super(context, null);
}
@Override
@@ -38,20 +38,20 @@
}
@Override
- public int getAvailabilityStatus() {
- if (super.getAvailabilityStatus() == CONDITIONALLY_UNAVAILABLE) {
- return CONDITIONALLY_UNAVAILABLE;
+ public boolean isAvailable() {
+ if (!super.isAvailable()) {
+ return false;
}
if (mChannel == null && !hasValidGroup()) {
- return CONDITIONALLY_UNAVAILABLE;
+ return false;
}
if (mChannel != null && !TextUtils.isEmpty(mChannel.getDescription())) {
- return AVAILABLE;
+ return true;
}
if (hasValidGroup() && !TextUtils.isEmpty(mChannelGroup.getDescription())) {
- return AVAILABLE;
+ return true;
}
- return CONDITIONALLY_UNAVAILABLE;
+ return false;
}
@Override
diff --git a/src/com/android/settings/notification/app/DndPreferenceController.java b/src/com/android/settings/notification/app/DndPreferenceController.java
index 811eeb4..b65928a 100644
--- a/src/com/android/settings/notification/app/DndPreferenceController.java
+++ b/src/com/android/settings/notification/app/DndPreferenceController.java
@@ -31,7 +31,7 @@
private static final String KEY_BYPASS_DND = "bypass_dnd";
public DndPreferenceController(Context context, NotificationBackend backend) {
- super(context, backend, KEY_BYPASS_DND);
+ super(context, backend);
}
@Override
@@ -40,11 +40,11 @@
}
@Override
- public int getAvailabilityStatus() {
- if (super.getAvailabilityStatus() == CONDITIONALLY_UNAVAILABLE || mChannel == null) {
- return CONDITIONALLY_UNAVAILABLE;
+ public boolean isAvailable() {
+ if (!super.isAvailable() || mChannel == null) {
+ return false;
}
- return AVAILABLE;
+ return true;
}
@Override
diff --git a/src/com/android/settings/notification/app/HeaderPreferenceController.java b/src/com/android/settings/notification/app/HeaderPreferenceController.java
index c4b0e59..7379d55 100644
--- a/src/com/android/settings/notification/app/HeaderPreferenceController.java
+++ b/src/com/android/settings/notification/app/HeaderPreferenceController.java
@@ -45,7 +45,7 @@
private boolean mStarted = false;
public HeaderPreferenceController(Context context, DashboardFragment fragment) {
- super(context, null, PREF_KEY_APP_HEADER);
+ super(context, null);
mFragment = fragment;
}
@@ -55,8 +55,8 @@
}
@Override
- public int getAvailabilityStatus() {
- return mAppRow != null ? AVAILABLE : CONDITIONALLY_UNAVAILABLE;
+ public boolean isAvailable() {
+ return mAppRow != null;
}
@Override
diff --git a/src/com/android/settings/notification/app/HighImportancePreferenceController.java b/src/com/android/settings/notification/app/HighImportancePreferenceController.java
index 98dc8a7..d60668b 100644
--- a/src/com/android/settings/notification/app/HighImportancePreferenceController.java
+++ b/src/com/android/settings/notification/app/HighImportancePreferenceController.java
@@ -37,7 +37,7 @@
public HighImportancePreferenceController(Context context,
NotificationSettings.DependentFieldListener dependentFieldListener,
NotificationBackend backend) {
- super(context, backend, KEY_IMPORTANCE);
+ super(context, backend);
mDependentFieldListener = dependentFieldListener;
}
@@ -47,19 +47,17 @@
}
@Override
- public int getAvailabilityStatus() {
- if (super.getAvailabilityStatus() == CONDITIONALLY_UNAVAILABLE) {
- return CONDITIONALLY_UNAVAILABLE;
+ public boolean isAvailable() {
+ if (!super.isAvailable()) {
+ return false;
}
if (mChannel == null) {
- return CONDITIONALLY_UNAVAILABLE;
+ return false;
}
if (isDefaultChannel()) {
- return CONDITIONALLY_UNAVAILABLE;
+ return false;
}
- return mChannel.getImportance() >= IMPORTANCE_DEFAULT
- ? AVAILABLE
- : CONDITIONALLY_UNAVAILABLE;
+ return mChannel.getImportance() >= IMPORTANCE_DEFAULT;
}
@Override
diff --git a/src/com/android/settings/notification/app/ImportancePreferenceController.java b/src/com/android/settings/notification/app/ImportancePreferenceController.java
index 31ddac3..3c32ca4 100644
--- a/src/com/android/settings/notification/app/ImportancePreferenceController.java
+++ b/src/com/android/settings/notification/app/ImportancePreferenceController.java
@@ -38,7 +38,7 @@
public ImportancePreferenceController(Context context,
NotificationSettings.DependentFieldListener dependentFieldListener,
NotificationBackend backend) {
- super(context, backend, KEY_IMPORTANCE);
+ super(context, backend);
mDependentFieldListener = dependentFieldListener;
}
@@ -48,14 +48,14 @@
}
@Override
- public int getAvailabilityStatus() {
- if (super.getAvailabilityStatus() == CONDITIONALLY_UNAVAILABLE) {
- return CONDITIONALLY_UNAVAILABLE;
+ public boolean isAvailable() {
+ if (!super.isAvailable()) {
+ return false;
}
if (mChannel == null) {
- return CONDITIONALLY_UNAVAILABLE;
+ return false;
}
- return !isDefaultChannel() ? AVAILABLE : CONDITIONALLY_UNAVAILABLE;
+ return !isDefaultChannel();
}
@Override
diff --git a/src/com/android/settings/notification/app/InvalidConversationInfoPreferenceController.java b/src/com/android/settings/notification/app/InvalidConversationInfoPreferenceController.java
index bb2c58b..b937e80 100644
--- a/src/com/android/settings/notification/app/InvalidConversationInfoPreferenceController.java
+++ b/src/com/android/settings/notification/app/InvalidConversationInfoPreferenceController.java
@@ -31,7 +31,7 @@
public InvalidConversationInfoPreferenceController(Context context,
NotificationBackend backend) {
- super(context, backend, KEY);
+ super(context, backend);
}
@Override
@@ -40,19 +40,17 @@
}
@Override
- public int getAvailabilityStatus() {
+ public boolean isAvailable() {
if (mAppRow == null) {
- return CONDITIONALLY_UNAVAILABLE;
+ return false;
}
if (mAppRow.banned) {
- return CONDITIONALLY_UNAVAILABLE;
+ return false;
}
if (mPreferenceFilter != null && !isIncludedInFilter()) {
- return CONDITIONALLY_UNAVAILABLE;
+ return false;
}
- return mBackend.isInInvalidMsgState(mAppRow.pkg, mAppRow.uid)
- ? AVAILABLE
- : CONDITIONALLY_UNAVAILABLE;
+ return mBackend.isInInvalidMsgState(mAppRow.pkg, mAppRow.uid);
}
@Override
diff --git a/src/com/android/settings/notification/app/InvalidConversationPreferenceController.java b/src/com/android/settings/notification/app/InvalidConversationPreferenceController.java
index 219ccbc..5c502dc 100644
--- a/src/com/android/settings/notification/app/InvalidConversationPreferenceController.java
+++ b/src/com/android/settings/notification/app/InvalidConversationPreferenceController.java
@@ -31,7 +31,7 @@
private static final String KEY = "invalid_conversation_switch";
public InvalidConversationPreferenceController(Context context, NotificationBackend backend) {
- super(context, backend, KEY);
+ super(context, backend);
}
@Override
@@ -40,19 +40,17 @@
}
@Override
- public int getAvailabilityStatus() {
+ public boolean isAvailable() {
if (mAppRow == null) {
- return CONDITIONALLY_UNAVAILABLE;
+ return false;
}
if (mAppRow.banned) {
- return CONDITIONALLY_UNAVAILABLE;
+ return false;
}
if (mPreferenceFilter != null && !isIncludedInFilter()) {
- return CONDITIONALLY_UNAVAILABLE;
+ return false;
}
- return mBackend.isInInvalidMsgState(mAppRow.pkg, mAppRow.uid)
- ? AVAILABLE
- : CONDITIONALLY_UNAVAILABLE;
+ return mBackend.isInInvalidMsgState(mAppRow.pkg, mAppRow.uid);
}
@Override
diff --git a/src/com/android/settings/notification/app/LightsPreferenceController.java b/src/com/android/settings/notification/app/LightsPreferenceController.java
index f7f9244..d096922 100644
--- a/src/com/android/settings/notification/app/LightsPreferenceController.java
+++ b/src/com/android/settings/notification/app/LightsPreferenceController.java
@@ -33,7 +33,7 @@
private static final String KEY_LIGHTS = "lights";
public LightsPreferenceController(Context context, NotificationBackend backend) {
- super(context, backend, KEY_LIGHTS);
+ super(context, backend);
}
@Override
@@ -42,18 +42,16 @@
}
@Override
- public int getAvailabilityStatus() {
- if (super.getAvailabilityStatus() == CONDITIONALLY_UNAVAILABLE) {
- return CONDITIONALLY_UNAVAILABLE;
+ public boolean isAvailable() {
+ if (!super.isAvailable()) {
+ return false;
}
if (mChannel == null) {
- return CONDITIONALLY_UNAVAILABLE;
+ return false;
}
- if (checkCanBeVisible(NotificationManager.IMPORTANCE_DEFAULT) && canPulseLight()
- && !isDefaultChannel()) {
- return AVAILABLE;
- }
- return CONDITIONALLY_UNAVAILABLE;
+ return checkCanBeVisible(NotificationManager.IMPORTANCE_DEFAULT)
+ && canPulseLight()
+ && !isDefaultChannel();
}
@Override
diff --git a/src/com/android/settings/notification/app/MinImportancePreferenceController.java b/src/com/android/settings/notification/app/MinImportancePreferenceController.java
index b2c0862..f825763 100644
--- a/src/com/android/settings/notification/app/MinImportancePreferenceController.java
+++ b/src/com/android/settings/notification/app/MinImportancePreferenceController.java
@@ -37,7 +37,7 @@
public MinImportancePreferenceController(Context context,
NotificationSettings.DependentFieldListener dependentFieldListener,
NotificationBackend backend) {
- super(context, backend, KEY_IMPORTANCE);
+ super(context, backend);
mDependentFieldListener = dependentFieldListener;
}
@@ -47,17 +47,17 @@
}
@Override
- public int getAvailabilityStatus() {
- if (super.getAvailabilityStatus() == CONDITIONALLY_UNAVAILABLE) {
- return CONDITIONALLY_UNAVAILABLE;
+ public boolean isAvailable() {
+ if (!super.isAvailable()) {
+ return false;
}
if (mChannel == null) {
- return CONDITIONALLY_UNAVAILABLE;
+ return false;
}
if (isDefaultChannel()) {
- return CONDITIONALLY_UNAVAILABLE;
+ return false;
}
- return mChannel.getImportance() <= IMPORTANCE_LOW ? AVAILABLE : CONDITIONALLY_UNAVAILABLE;
+ return mChannel.getImportance() <= IMPORTANCE_LOW;
}
@Override
diff --git a/src/com/android/settings/notification/app/NotificationPreferenceController.java b/src/com/android/settings/notification/app/NotificationPreferenceController.java
index 271a83d..fb19d9d 100644
--- a/src/com/android/settings/notification/app/NotificationPreferenceController.java
+++ b/src/com/android/settings/notification/app/NotificationPreferenceController.java
@@ -17,24 +17,26 @@
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;
@@ -44,7 +46,7 @@
* Parent class for preferences appearing on notification setting pages at the app,
* notification channel group, or notification channel level.
*/
-public abstract class NotificationPreferenceController extends BasePreferenceController {
+public abstract class NotificationPreferenceController extends AbstractPreferenceController {
private static final String TAG = "ChannelPrefContr";
@Nullable
protected NotificationChannel mChannel;
@@ -69,11 +71,8 @@
boolean overrideCanBlockValue;
boolean overrideCanConfigureValue;
- boolean mLoadedChannelState;
-
- public NotificationPreferenceController(Context context, NotificationBackend backend,
- String key) {
- super(context, key);
+ public NotificationPreferenceController(Context context, NotificationBackend backend) {
+ super(context);
mContext = context;
mNm = (NotificationManager) mContext.getSystemService(Context.NOTIFICATION_SERVICE);
mBackend = backend;
@@ -82,30 +81,28 @@
}
/**
- * Returns available if field's parent object is not blocked.
+ * Returns true if field's parent object is not blocked.
*/
@Override
- public int getAvailabilityStatus() {
+ public boolean isAvailable() {
if (mAppRow == null) {
- return CONDITIONALLY_UNAVAILABLE;
+ return false;
}
if (mAppRow.banned) {
- return CONDITIONALLY_UNAVAILABLE;
+ return false;
}
if (mChannelGroup != null) {
if (mChannelGroup.isBlocked()) {
- return CONDITIONALLY_UNAVAILABLE;
+ return false;
}
}
if (mChannel != null) {
if (mPreferenceFilter != null && !isIncludedInFilter()) {
- return CONDITIONALLY_UNAVAILABLE;
+ return false;
}
- if(mChannel.getImportance() == IMPORTANCE_NONE) {
- return CONDITIONALLY_UNAVAILABLE;
- }
+ return mChannel.getImportance() != IMPORTANCE_NONE;
}
- return AVAILABLE;
+ return true;
}
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 5750167..192a0ee 100644
--- a/src/com/android/settings/notification/app/NotificationSettings.java
+++ b/src/com/android/settings/notification/app/NotificationSettings.java
@@ -41,7 +41,6 @@
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;
@@ -130,52 +129,15 @@
}
}
- 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);
- loadAppRow();
- if (mAppRow == null) {
- toastAndFinish("Can't load package");
- return;
- }
loadChannel();
- loadConversation();
+ loadAppRow();
loadChannelGroup();
loadPreferencesFilter();
collectConfigActivities();
@@ -195,6 +157,55 @@
}
}
+ @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);
@@ -296,8 +307,7 @@
}
}
- protected void toastAndFinish(String msg) {
- Log.w(TAG, msg);
+ protected void toastAndFinish() {
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 46625c3..0c7cd23 100644
--- a/src/com/android/settings/notification/app/NotificationsOffPreferenceController.java
+++ b/src/com/android/settings/notification/app/NotificationsOffPreferenceController.java
@@ -30,7 +30,7 @@
private static final String KEY_BLOCKED_DESC = "block_desc";
public NotificationsOffPreferenceController(Context context) {
- super(context, null, KEY_BLOCKED_DESC);
+ super(context, null);
}
@Override
@@ -39,20 +39,16 @@
}
@Override
- public int getAvailabilityStatus() {
+ public boolean isAvailable() {
if (mAppRow == null) {
- return CONDITIONALLY_UNAVAILABLE;
+ return false;
}
if (mPreferenceFilter != null && !isIncludedInFilter()) {
- return CONDITIONALLY_UNAVAILABLE;
+ return false;
}
// Available only when other controllers are unavailable - this UI replaces the UI that
// would give more detailed notification controls.
- if (super.getAvailabilityStatus() == AVAILABLE) {
- return CONDITIONALLY_UNAVAILABLE;
- } else {
- return AVAILABLE;
- }
+ return !super.isAvailable();
}
@Override
diff --git a/src/com/android/settings/notification/app/SoundPreferenceController.java b/src/com/android/settings/notification/app/SoundPreferenceController.java
index 335b442..b23b4fc 100644
--- a/src/com/android/settings/notification/app/SoundPreferenceController.java
+++ b/src/com/android/settings/notification/app/SoundPreferenceController.java
@@ -47,7 +47,7 @@
public SoundPreferenceController(Context context, SettingsPreferenceFragment hostFragment,
NotificationSettings.DependentFieldListener dependentFieldListener,
NotificationBackend backend) {
- super(context, backend, KEY_SOUND);
+ super(context, backend);
mFragment = hostFragment;
mListener = dependentFieldListener;
}
@@ -58,17 +58,14 @@
}
@Override
- public int getAvailabilityStatus() {
- if (super.getAvailabilityStatus() == CONDITIONALLY_UNAVAILABLE) {
- return CONDITIONALLY_UNAVAILABLE;
+ public boolean isAvailable() {
+ if (!super.isAvailable()) {
+ return false;
}
if (mChannel == null) {
- return CONDITIONALLY_UNAVAILABLE;
+ return false;
}
- if (checkCanBeVisible(NotificationManager.IMPORTANCE_DEFAULT) && !isDefaultChannel()) {
- return AVAILABLE;
- }
- return CONDITIONALLY_UNAVAILABLE;
+ return checkCanBeVisible(NotificationManager.IMPORTANCE_DEFAULT) && !isDefaultChannel();
}
@Override
diff --git a/src/com/android/settings/notification/app/VibrationPreferenceController.java b/src/com/android/settings/notification/app/VibrationPreferenceController.java
index f91999f..34d1a54 100644
--- a/src/com/android/settings/notification/app/VibrationPreferenceController.java
+++ b/src/com/android/settings/notification/app/VibrationPreferenceController.java
@@ -34,7 +34,7 @@
private final Vibrator mVibrator;
public VibrationPreferenceController(Context context, NotificationBackend backend) {
- super(context, backend, KEY_VIBRATE);
+ super(context, backend);
mVibrator = context.getSystemService(Vibrator.class);
}
@@ -44,15 +44,14 @@
}
@Override
- 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;
+ public boolean isAvailable() {
+ if (!super.isAvailable() || mChannel == null) {
+ return false;
+ }
+ return checkCanBeVisible(NotificationManager.IMPORTANCE_DEFAULT)
+ && !isDefaultChannel()
+ && mVibrator != null
+ && mVibrator.hasVibrator();
}
@Override
diff --git a/src/com/android/settings/notification/app/VisibilityPreferenceController.java b/src/com/android/settings/notification/app/VisibilityPreferenceController.java
index 3f33267..a2a1d76 100644
--- a/src/com/android/settings/notification/app/VisibilityPreferenceController.java
+++ b/src/com/android/settings/notification/app/VisibilityPreferenceController.java
@@ -48,7 +48,7 @@
public VisibilityPreferenceController(Context context, LockPatternUtils utils,
NotificationBackend backend) {
- super(context, backend, KEY_VISIBILITY_OVERRIDE);
+ super(context, backend);
mLockPatternUtils = utils;
}
@@ -58,18 +58,14 @@
}
@Override
- public int getAvailabilityStatus() {
- if (super.getAvailabilityStatus() == CONDITIONALLY_UNAVAILABLE) {
- return CONDITIONALLY_UNAVAILABLE;
+ public boolean isAvailable() {
+ if (!super.isAvailable()) {
+ return false;
}
if (mChannel == null || mAppRow.banned) {
- return CONDITIONALLY_UNAVAILABLE;
+ return false;
}
- if (checkCanBeVisible(NotificationManager.IMPORTANCE_LOW) && isLockScreenSecure()) {
- return AVAILABLE;
- }
-
- return CONDITIONALLY_UNAVAILABLE;
+ return checkCanBeVisible(NotificationManager.IMPORTANCE_LOW) && isLockScreenSecure();
}
@Override
diff --git a/src/com/android/settings/wallpaper/WallpaperSuggestionActivity.java b/src/com/android/settings/wallpaper/WallpaperSuggestionActivity.java
index c2b3fa0..675e10f 100644
--- a/src/com/android/settings/wallpaper/WallpaperSuggestionActivity.java
+++ b/src/com/android/settings/wallpaper/WallpaperSuggestionActivity.java
@@ -84,7 +84,7 @@
ComponentName component = controller.getComponentName();
data.intentTargetPackage = component.getPackageName();
data.intentTargetClass = component.getClassName();
- data.intentAction = Intent.ACTION_MAIN;
+ data.intentAction = controller.getComponentActionName();
data.key = SUPPORT_SEARCH_INDEX_KEY;
data.keywords = controller.getKeywords();
result.add(data);
diff --git a/src/com/android/settings/wifi/WifiScanModeActivity.java b/src/com/android/settings/wifi/WifiScanModeActivity.java
index d372135..c10ee27 100644
--- a/src/com/android/settings/wifi/WifiScanModeActivity.java
+++ b/src/com/android/settings/wifi/WifiScanModeActivity.java
@@ -18,11 +18,15 @@
import android.app.Dialog;
import android.app.settings.SettingsEnums;
+import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.net.wifi.WifiManager;
import android.os.Bundle;
+import android.os.UserManager;
import android.text.TextUtils;
+import android.util.EventLog;
+import android.util.Log;
import android.view.WindowManager;
import androidx.annotation.VisibleForTesting;
@@ -39,6 +43,7 @@
* This activity requests users permission to allow scanning even when Wi-Fi is turned off
*/
public class WifiScanModeActivity extends FragmentActivity {
+ private static final String TAG = "WifiScanModeActivity";
private DialogFragment mDialog;
@VisibleForTesting
String mApp;
@@ -78,7 +83,15 @@
mApp = Utils.getApplicationLabel(getApplicationContext(), packageName).toString();
}
- private void createDialog() {
+ @VisibleForTesting
+ void createDialog() {
+ if (isGuestUser(getApplicationContext())) {
+ Log.e(TAG, "Guest user is not allowed to configure Wi-Fi Scan Mode!");
+ EventLog.writeEvent(0x534e4554, "235601169", -1 /* UID */, "User is a guest");
+ finish();
+ return;
+ }
+
if (mDialog == null) {
mDialog = AlertDialogFragment.newInstance(mApp);
mDialog.show(getSupportFragmentManager(), "dialog");
@@ -169,4 +182,11 @@
((WifiScanModeActivity) getActivity()).doNegativeClick();
}
}
+
+ private static boolean isGuestUser(Context context) {
+ if (context == null) return false;
+ final UserManager userManager = context.getSystemService(UserManager.class);
+ if (userManager == null) return false;
+ return userManager.isGuestUser();
+ }
}
diff --git a/tests/robotests/src/com/android/settings/development/NotificationChannelWarningsPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/development/NotificationChannelWarningsPreferenceControllerTest.java
index 7d08c66..1887247 100644
--- a/tests/robotests/src/com/android/settings/development/NotificationChannelWarningsPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/development/NotificationChannelWarningsPreferenceControllerTest.java
@@ -102,7 +102,7 @@
}
@Test
- public void updateState_settingUndefinedDebuggingEnabled_preferenceShouldBeChecked() {
+ public void updateState_settingUndefinedDebuggingEnabled_preferenceShouldNotBeChecked() {
mController = spy(mController);
doReturn(true).when(mController).isDebuggable();
Settings.Global.putString(mContext.getContentResolver(),
@@ -110,18 +110,6 @@
mController.updateState(mPreference);
- verify(mPreference).setChecked(true);
- }
-
- @Test
- public void updateState_settingUndefinedDebuggingDisabled_preferenceShouldNotBeChecked() {
- mController = spy(mController);
- doReturn(false).when(mController).isDebuggable();
- Settings.Global.putString(mContext.getContentResolver(),
- Settings.Global.SHOW_NOTIFICATION_CHANNEL_WARNINGS, "NotAnInteger");
-
- mController.updateState(mPreference);
-
verify(mPreference).setChecked(false);
}
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 bf529e6..b2f1673 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 @@
private final class TestPreferenceController extends NotificationPreferenceController {
private TestPreferenceController(Context context, NotificationBackend backend) {
- super(context, backend, "key");
+ super(context, backend);
}
@Override
diff --git a/tests/robotests/src/com/android/settings/wifi/WifiScanModeActivityTest.java b/tests/robotests/src/com/android/settings/wifi/WifiScanModeActivityTest.java
index 1e3afdb..5937997 100644
--- a/tests/robotests/src/com/android/settings/wifi/WifiScanModeActivityTest.java
+++ b/tests/robotests/src/com/android/settings/wifi/WifiScanModeActivityTest.java
@@ -18,11 +18,17 @@
import static com.google.common.truth.Truth.assertThat;
+import static org.mockito.Mockito.never;
import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
+import android.content.Context;
+import android.os.UserManager;
import android.text.TextUtils;
+import androidx.test.core.app.ApplicationProvider;
+
import com.android.settings.testutils.shadow.ShadowUtils;
import com.android.settingslib.wifi.WifiPermissionChecker;
@@ -32,6 +38,7 @@
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
+import org.mockito.Spy;
import org.mockito.junit.MockitoJUnit;
import org.mockito.junit.MockitoRule;
import org.robolectric.Robolectric;
@@ -47,6 +54,10 @@
@Rule
public final MockitoRule mMockitoRule = MockitoJUnit.rule();
+ @Spy
+ Context mContext = ApplicationProvider.getApplicationContext();
+ @Mock
+ UserManager mUserManager;
@Mock
WifiPermissionChecker mWifiPermissionChecker;
@@ -54,7 +65,11 @@
@Before
public void setUp() {
+ when(mContext.getSystemService(UserManager.class)).thenReturn(mUserManager);
+ when(mUserManager.isGuestUser()).thenReturn(false);
+
mActivity = spy(Robolectric.setupActivity(WifiScanModeActivity.class));
+ when(mActivity.getApplicationContext()).thenReturn(mContext);
mActivity.mWifiPermissionChecker = mWifiPermissionChecker;
}
@@ -87,4 +102,22 @@
assertThat(mActivity.mApp).isEqualTo(APP_LABEL);
}
+
+ @Test
+ public void createDialog_isNotGuestUser_shouldNotFinishDialog() {
+ when(mUserManager.isGuestUser()).thenReturn(false);
+
+ mActivity.createDialog();
+
+ verify(mActivity, never()).finish();
+ }
+
+ @Test
+ public void createDialog_isGuestUser_shouldFinishDialog() {
+ when(mUserManager.isGuestUser()).thenReturn(true);
+
+ mActivity.createDialog();
+
+ verify(mActivity).finish();
+ }
}