Revert^3 "Improve App notification loading"

33710fd9e2

Change-Id: Ifb45f949c28bff04f8abfe3e1a73628f2e407241
This commit is contained in:
Michael Wright
2022-08-24 12:22:12 +00:00
parent 33710fd9e2
commit 475632c4fe
34 changed files with 272 additions and 318 deletions

View File

@@ -51,7 +51,7 @@ public class AppBubbleListPreferenceController extends AppConversationListPrefer
private static final String KEY = "bubble_conversations"; private static final String KEY = "bubble_conversations";
public AppBubbleListPreferenceController(Context context, NotificationBackend backend) { public AppBubbleListPreferenceController(Context context, NotificationBackend backend) {
super(context, backend, KEY); super(context, backend);
} }
@Override @Override
@@ -80,25 +80,25 @@ public class AppBubbleListPreferenceController extends AppConversationListPrefer
} }
@Override @Override
public int getAvailabilityStatus() { public boolean isAvailable() {
// copy rather than inherit super's isAvailable because apps can link to this page // 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 // as part of onboarding, before they send a valid conversation notification
if (mAppRow == null) { if (mAppRow == null) {
return CONDITIONALLY_UNAVAILABLE; return false;
} }
if (mAppRow.banned) { if (mAppRow.banned) {
return CONDITIONALLY_UNAVAILABLE; return false;
} }
if (mChannel != null) { if (mChannel != null) {
if (mBackend.onlyHasDefaultChannel(mAppRow.pkg, mAppRow.uid) if (mBackend.onlyHasDefaultChannel(mAppRow.pkg, mAppRow.uid)
|| NotificationChannel.DEFAULT_CHANNEL_ID.equals(mChannel.getId())) { || NotificationChannel.DEFAULT_CHANNEL_ID.equals(mChannel.getId())) {
return CONDITIONALLY_UNAVAILABLE; return false;
} }
} }
if (mAppRow.bubblePreference == BUBBLE_PREFERENCE_NONE) { if (mAppRow.bubblePreference == BUBBLE_PREFERENCE_NONE) {
return CONDITIONALLY_UNAVAILABLE; return false;
} }
return AVAILABLE; return true;
} }
@VisibleForTesting @VisibleForTesting

View File

@@ -32,7 +32,7 @@ public class AddToHomeScreenPreferenceController extends NotificationPreferenceC
private static final String KEY = "add_to_home"; private static final String KEY = "add_to_home";
public AddToHomeScreenPreferenceController(Context context, NotificationBackend backend) { public AddToHomeScreenPreferenceController(Context context, NotificationBackend backend) {
super(context, backend, KEY); super(context, backend);
} }
@Override @Override
@@ -41,11 +41,11 @@ public class AddToHomeScreenPreferenceController extends NotificationPreferenceC
} }
@Override @Override
public int getAvailabilityStatus() { public boolean isAvailable() {
if (super.getAvailabilityStatus() == CONDITIONALLY_UNAVAILABLE) { if (!super.isAvailable()) {
return CONDITIONALLY_UNAVAILABLE; return false;
} }
return mConversationInfo != null ? AVAILABLE : CONDITIONALLY_UNAVAILABLE; return mConversationInfo != null;
} }
@Override @Override

View File

@@ -40,7 +40,7 @@ public class AllowSoundPreferenceController extends NotificationPreferenceContro
public AllowSoundPreferenceController(Context context, public AllowSoundPreferenceController(Context context,
NotificationSettings.DependentFieldListener dependentFieldListener, NotificationSettings.DependentFieldListener dependentFieldListener,
NotificationBackend backend) { NotificationBackend backend) {
super(context, backend, KEY_IMPORTANCE); super(context, backend);
mDependentFieldListener = dependentFieldListener; mDependentFieldListener = dependentFieldListener;
} }
@@ -50,14 +50,11 @@ public class AllowSoundPreferenceController extends NotificationPreferenceContro
} }
@Override @Override
public int getAvailabilityStatus() { public boolean isAvailable() {
if (super.getAvailabilityStatus() == CONDITIONALLY_UNAVAILABLE) { if (!super.isAvailable()) {
return CONDITIONALLY_UNAVAILABLE; return false;
} }
if (mChannel != null && NotificationChannel.DEFAULT_CHANNEL_ID.equals(mChannel.getId())) { return mChannel != null && NotificationChannel.DEFAULT_CHANNEL_ID.equals(mChannel.getId());
return AVAILABLE;
}
return CONDITIONALLY_UNAVAILABLE;
} }

View File

@@ -64,7 +64,7 @@ public class AppChannelsBypassingDndPreferenceController extends NotificationPre
public AppChannelsBypassingDndPreferenceController( public AppChannelsBypassingDndPreferenceController(
Context context, Context context,
NotificationBackend backend) { NotificationBackend backend) {
super(context, backend, KEY); super(context, backend);
} }
@Override @Override
@@ -110,8 +110,8 @@ public class AppChannelsBypassingDndPreferenceController extends NotificationPre
} }
@Override @Override
public int getAvailabilityStatus() { public boolean isAvailable() {
return mAppRow != null ? AVAILABLE : CONDITIONALLY_UNAVAILABLE; return mAppRow != null;
} }
@Override @Override

View File

@@ -49,12 +49,7 @@ public class AppConversationListPreferenceController extends NotificationPrefere
protected PreferenceCategory mPreference; protected PreferenceCategory mPreference;
public AppConversationListPreferenceController(Context context, NotificationBackend backend) { public AppConversationListPreferenceController(Context context, NotificationBackend backend) {
this(context, backend, KEY); super(context, backend);
}
public AppConversationListPreferenceController(Context context, NotificationBackend backend,
String key) {
super(context, backend, key);
} }
@Override @Override
@@ -63,24 +58,21 @@ public class AppConversationListPreferenceController extends NotificationPrefere
} }
@Override @Override
public int getAvailabilityStatus() { public boolean isAvailable() {
if (mAppRow == null) { if (mAppRow == null) {
return CONDITIONALLY_UNAVAILABLE; return false;
} }
if (mAppRow.banned) { if (mAppRow.banned) {
return CONDITIONALLY_UNAVAILABLE; return false;
} }
if (mChannel != null) { if (mChannel != null) {
if (mBackend.onlyHasDefaultChannel(mAppRow.pkg, mAppRow.uid) if (mBackend.onlyHasDefaultChannel(mAppRow.pkg, mAppRow.uid)
|| NotificationChannel.DEFAULT_CHANNEL_ID.equals(mChannel.getId())) { || NotificationChannel.DEFAULT_CHANNEL_ID.equals(mChannel.getId())) {
return CONDITIONALLY_UNAVAILABLE; return false;
} }
} }
if (mBackend.hasSentValidMsg(mAppRow.pkg, mAppRow.uid) || mBackend.isInInvalidMsgState( return mBackend.hasSentValidMsg(mAppRow.pkg, mAppRow.uid) || mBackend.isInInvalidMsgState(
mAppRow.pkg, mAppRow.uid)) { mAppRow.pkg, mAppRow.uid);
return AVAILABLE;
}
return CONDITIONALLY_UNAVAILABLE;
} }
@Override @Override

View File

@@ -32,7 +32,7 @@ public class AppLinkPreferenceController extends NotificationPreferenceControlle
private static final String KEY_APP_LINK = "app_link"; private static final String KEY_APP_LINK = "app_link";
public AppLinkPreferenceController(Context context) { public AppLinkPreferenceController(Context context) {
super(context, null, KEY_APP_LINK); super(context, null);
} }
@Override @Override
@@ -41,11 +41,11 @@ public class AppLinkPreferenceController extends NotificationPreferenceControlle
} }
@Override @Override
public int getAvailabilityStatus() { public boolean isAvailable() {
if (super.getAvailabilityStatus() == CONDITIONALLY_UNAVAILABLE) { if (!super.isAvailable()) {
return CONDITIONALLY_UNAVAILABLE; return false;
} }
return mAppRow.settingsIntent != null ? AVAILABLE : CONDITIONALLY_UNAVAILABLE; return mAppRow.settingsIntent != null;
} }
@Override @Override

View File

@@ -38,7 +38,7 @@ public class BadgePreferenceController extends NotificationPreferenceController
public BadgePreferenceController(Context context, public BadgePreferenceController(Context context,
NotificationBackend backend) { NotificationBackend backend) {
super(context, backend, KEY_BADGE); super(context, backend);
} }
@Override @Override
@@ -47,29 +47,25 @@ public class BadgePreferenceController extends NotificationPreferenceController
} }
@Override @Override
public int getAvailabilityStatus() { public boolean isAvailable() {
if (super.getAvailabilityStatus() == CONDITIONALLY_UNAVAILABLE) { if (!super.isAvailable()) {
return CONDITIONALLY_UNAVAILABLE; return false;
} }
if (mAppRow == null && mChannel == null) { if (mAppRow == null && mChannel == null) {
return CONDITIONALLY_UNAVAILABLE; return false;
} }
if (Settings.Secure.getInt(mContext.getContentResolver(), if (Settings.Secure.getInt(mContext.getContentResolver(),
NOTIFICATION_BADGING, SYSTEM_WIDE_ON) == SYSTEM_WIDE_OFF) { NOTIFICATION_BADGING, SYSTEM_WIDE_ON) == SYSTEM_WIDE_OFF) {
return CONDITIONALLY_UNAVAILABLE; return false;
} }
if (mChannel != null) { if (mChannel != null) {
if (isDefaultChannel()) { if (isDefaultChannel()) {
return AVAILABLE; return true;
} else { } else {
return mAppRow == null return mAppRow == null ? false : mAppRow.showBadge;
? CONDITIONALLY_UNAVAILABLE
: mAppRow.showBadge
? AVAILABLE
: CONDITIONALLY_UNAVAILABLE;
} }
} }
return AVAILABLE; return true;
} }
@Override @Override

View File

@@ -42,7 +42,7 @@ public class BlockPreferenceController extends NotificationPreferenceController
public BlockPreferenceController(Context context, public BlockPreferenceController(Context context,
NotificationSettings.DependentFieldListener dependentFieldListener, NotificationSettings.DependentFieldListener dependentFieldListener,
NotificationBackend backend) { NotificationBackend backend) {
super(context, backend, KEY_BLOCK); super(context, backend);
mDependentFieldListener = dependentFieldListener; mDependentFieldListener = dependentFieldListener;
} }
@@ -52,14 +52,14 @@ public class BlockPreferenceController extends NotificationPreferenceController
} }
@Override @Override
public int getAvailabilityStatus() { public boolean isAvailable() {
if (mAppRow == null) { if (mAppRow == null) {
return CONDITIONALLY_UNAVAILABLE; return false;
} }
if (mPreferenceFilter != null && !isIncludedInFilter()) { if (mPreferenceFilter != null && !isIncludedInFilter()) {
return CONDITIONALLY_UNAVAILABLE; return false;
} }
return AVAILABLE; return true;
} }
@Override @Override

View File

@@ -32,15 +32,15 @@ public class BubbleCategoryPreferenceController extends NotificationPreferenceCo
static final int ON = 1; static final int ON = 1;
public BubbleCategoryPreferenceController(Context context) { public BubbleCategoryPreferenceController(Context context) {
super(context, null, KEY); super(context, null);
} }
@Override @Override
public int getAvailabilityStatus() { public boolean isAvailable() {
if (super.getAvailabilityStatus() == CONDITIONALLY_UNAVAILABLE) { if (!super.isAvailable()) {
return CONDITIONALLY_UNAVAILABLE; return false;
} }
return areBubblesEnabled() ? AVAILABLE : CONDITIONALLY_UNAVAILABLE; return areBubblesEnabled();
} }
@Override @Override

View File

@@ -32,15 +32,15 @@ public class BubbleLinkPreferenceController extends NotificationPreferenceContro
static final int ON = 1; static final int ON = 1;
public BubbleLinkPreferenceController(Context context) { public BubbleLinkPreferenceController(Context context) {
super(context, null, KEY); super(context, null);
} }
@Override @Override
public int getAvailabilityStatus() { public boolean isAvailable() {
if (super.getAvailabilityStatus() == CONDITIONALLY_UNAVAILABLE) { if (!super.isAvailable()) {
return CONDITIONALLY_UNAVAILABLE; return false;
} }
return areBubblesEnabled() ? AVAILABLE : CONDITIONALLY_UNAVAILABLE; return areBubblesEnabled();
} }
@Override @Override

View File

@@ -56,7 +56,7 @@ public class BubblePreferenceController extends NotificationPreferenceController
public BubblePreferenceController(Context context, @Nullable FragmentManager fragmentManager, public BubblePreferenceController(Context context, @Nullable FragmentManager fragmentManager,
NotificationBackend backend, boolean isAppPage, NotificationBackend backend, boolean isAppPage,
@Nullable NotificationSettings.DependentFieldListener listener) { @Nullable NotificationSettings.DependentFieldListener listener) {
super(context, backend, KEY); super(context, backend);
mFragmentManager = fragmentManager; mFragmentManager = fragmentManager;
mIsAppPage = isAppPage; mIsAppPage = isAppPage;
mListener = listener; mListener = listener;
@@ -68,24 +68,21 @@ public class BubblePreferenceController extends NotificationPreferenceController
} }
@Override @Override
public int getAvailabilityStatus() { public boolean isAvailable() {
if (super.getAvailabilityStatus() == CONDITIONALLY_UNAVAILABLE) { if (!super.isAvailable()) {
return CONDITIONALLY_UNAVAILABLE; return false;
} }
if (!mIsAppPage && !isEnabled()) { if (!mIsAppPage && !isEnabled()) {
return CONDITIONALLY_UNAVAILABLE; return false;
} }
if (mChannel != null) { if (mChannel != null) {
if (isDefaultChannel()) { if (isDefaultChannel()) {
return AVAILABLE; return true;
} else { } else {
if (mAppRow != null && mAppRow.bubblePreference != BUBBLE_PREFERENCE_NONE) { return mAppRow != null && mAppRow.bubblePreference != BUBBLE_PREFERENCE_NONE;
return AVAILABLE;
}
return CONDITIONALLY_UNAVAILABLE;
} }
} }
return AVAILABLE; return true;
} }
@Override @Override

View File

@@ -42,31 +42,28 @@ public class BubbleSummaryPreferenceController extends NotificationPreferenceCon
static final int ON = 1; static final int ON = 1;
public BubbleSummaryPreferenceController(Context context, NotificationBackend backend) { public BubbleSummaryPreferenceController(Context context, NotificationBackend backend) {
super(context, backend, KEY); super(context, backend);
} }
@Override @Override
public int getAvailabilityStatus() { public boolean isAvailable() {
if (super.getAvailabilityStatus() == CONDITIONALLY_UNAVAILABLE) { if (!super.isAvailable()) {
return CONDITIONALLY_UNAVAILABLE; return false;
} }
if (mAppRow == null) { if (mAppRow == null) {
return CONDITIONALLY_UNAVAILABLE; return false;
} }
if (mChannel != null) { if (mChannel != null) {
if (!isGloballyEnabled()) { if (!isGloballyEnabled()) {
return CONDITIONALLY_UNAVAILABLE; return false;
} }
if (isDefaultChannel()) { if (isDefaultChannel()) {
return AVAILABLE; return true;
} else { } else {
return mAppRow != null ? AVAILABLE : CONDITIONALLY_UNAVAILABLE; return mAppRow != null;
} }
} }
if (isGloballyEnabled() && mBackend.hasSentValidBubble(mAppRow.pkg, mAppRow.uid)) { return isGloballyEnabled() && mBackend.hasSentValidBubble(mAppRow.pkg, mAppRow.uid);
return AVAILABLE;
}
return CONDITIONALLY_UNAVAILABLE;
} }
@Override @Override

View File

@@ -28,7 +28,6 @@ import android.os.AsyncTask;
import android.os.Bundle; import android.os.Bundle;
import android.provider.Settings; import android.provider.Settings;
import android.text.TextUtils; import android.text.TextUtils;
import android.util.Slog;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
@@ -40,19 +39,16 @@ import androidx.preference.SwitchPreference;
import com.android.settings.R; import com.android.settings.R;
import com.android.settings.Utils; import com.android.settings.Utils;
import com.android.settings.applications.AppInfoBase; import com.android.settings.applications.AppInfoBase;
import com.android.settings.core.BasePreferenceController;
import com.android.settings.core.SubSettingLauncher; import com.android.settings.core.SubSettingLauncher;
import com.android.settings.notification.NotificationBackend; import com.android.settings.notification.NotificationBackend;
import com.android.settingslib.PrimarySwitchPreference; import com.android.settingslib.PrimarySwitchPreference;
import com.android.settingslib.RestrictedSwitchPreference; import com.android.settingslib.RestrictedSwitchPreference;
import com.android.settingslib.utils.ThreadUtils;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.List; 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 = "channels";
private static final String KEY_GENERAL_CATEGORY = "categories"; private static final String KEY_GENERAL_CATEGORY = "categories";
@@ -63,7 +59,7 @@ public class ChannelListPreferenceController extends NotificationPreferenceContr
private PreferenceCategory mPreference; private PreferenceCategory mPreference;
public ChannelListPreferenceController(Context context, NotificationBackend backend) { public ChannelListPreferenceController(Context context, NotificationBackend backend) {
super(context, backend, KEY); super(context, backend);
} }
@Override @Override
@@ -72,20 +68,20 @@ public class ChannelListPreferenceController extends NotificationPreferenceContr
} }
@Override @Override
public int getAvailabilityStatus() { public boolean isAvailable() {
if (mAppRow == null) { if (mAppRow == null) {
return CONDITIONALLY_UNAVAILABLE; return false;
} }
if (mAppRow.banned) { if (mAppRow.banned) {
return CONDITIONALLY_UNAVAILABLE; return false;
} }
if (mChannel != null) { if (mChannel != null) {
if (mBackend.onlyHasDefaultChannel(mAppRow.pkg, mAppRow.uid) if (mBackend.onlyHasDefaultChannel(mAppRow.pkg, mAppRow.uid)
|| NotificationChannel.DEFAULT_CHANNEL_ID.equals(mChannel.getId())) { || NotificationChannel.DEFAULT_CHANNEL_ID.equals(mChannel.getId())) {
return CONDITIONALLY_UNAVAILABLE; return false;
} }
} }
return AVAILABLE; return true;
} }
@Override @Override
@@ -95,17 +91,24 @@ public class ChannelListPreferenceController extends NotificationPreferenceContr
@Override @Override
public void updateState(Preference preference) { public void updateState(Preference preference) {
mPreference = (PreferenceCategory) preference; mPreference = (PreferenceCategory) preference;
// Load channel settings // Load channel settings
ThreadUtils.postOnBackgroundThread(() -> { new AsyncTask<Void, Void, Void>() {
@Override
protected Void doInBackground(Void... unused) {
mChannelGroupList = mBackend.getGroups(mAppRow.pkg, mAppRow.uid).getList(); mChannelGroupList = mBackend.getGroups(mAppRow.pkg, mAppRow.uid).getList();
Collections.sort(mChannelGroupList, CHANNEL_GROUP_COMPARATOR); 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); updateFullList(mPreference, mChannelGroupList);
ThreadUtils.postOnMainThread(() -> { }
showPreferences(); }.execute();
});
});
} }
/** /**
@@ -141,12 +144,6 @@ 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 * 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. * match, it checks all groups, and if it can't find that group anywhere, it creates it.

View File

@@ -37,7 +37,7 @@ public class ConversationDemotePreferenceController extends NotificationPreferen
public ConversationDemotePreferenceController(Context context, public ConversationDemotePreferenceController(Context context,
SettingsPreferenceFragment hostFragment, SettingsPreferenceFragment hostFragment,
NotificationBackend backend) { NotificationBackend backend) {
super(context, backend, KEY); super(context, backend);
mHostFragment = hostFragment; mHostFragment = hostFragment;
} }
@@ -47,17 +47,14 @@ public class ConversationDemotePreferenceController extends NotificationPreferen
} }
@Override @Override
public int getAvailabilityStatus() { public boolean isAvailable() {
if (super.getAvailabilityStatus() == CONDITIONALLY_UNAVAILABLE) { if (!super.isAvailable()) {
return CONDITIONALLY_UNAVAILABLE; return false;
} }
if (mAppRow == null || mChannel == null) { if (mAppRow == null || mChannel == null) {
return CONDITIONALLY_UNAVAILABLE; return false;
} }
if (!TextUtils.isEmpty(mChannel.getConversationId()) && !mChannel.isDemoted()) { return !TextUtils.isEmpty(mChannel.getConversationId()) && !mChannel.isDemoted();
return AVAILABLE;
}
return CONDITIONALLY_UNAVAILABLE;
} }
@Override @Override

View File

@@ -45,7 +45,7 @@ public class ConversationHeaderPreferenceController extends NotificationPreferen
private boolean mStarted = false; private boolean mStarted = false;
public ConversationHeaderPreferenceController(Context context, DashboardFragment fragment) { public ConversationHeaderPreferenceController(Context context, DashboardFragment fragment) {
super(context, null, PREF_KEY_APP_HEADER); super(context, null);
mFragment = fragment; mFragment = fragment;
} }
@@ -55,8 +55,8 @@ public class ConversationHeaderPreferenceController extends NotificationPreferen
} }
@Override @Override
public int getAvailabilityStatus() { public boolean isAvailable() {
return mAppRow != null ? AVAILABLE : CONDITIONALLY_UNAVAILABLE; return mAppRow != null;
} }
@Override @Override

View File

@@ -34,7 +34,7 @@ public class ConversationPriorityPreferenceController extends NotificationPrefer
public ConversationPriorityPreferenceController(Context context, public ConversationPriorityPreferenceController(Context context,
NotificationBackend backend, NotificationSettings.DependentFieldListener listener) { NotificationBackend backend, NotificationSettings.DependentFieldListener listener) {
super(context, backend, KEY); super(context, backend);
mDependentFieldListener = listener; mDependentFieldListener = listener;
} }
@@ -44,14 +44,14 @@ public class ConversationPriorityPreferenceController extends NotificationPrefer
} }
@Override @Override
public int getAvailabilityStatus() { public boolean isAvailable() {
if (super.getAvailabilityStatus() == CONDITIONALLY_UNAVAILABLE) { if (!super.isAvailable()) {
return CONDITIONALLY_UNAVAILABLE; return false;
} }
if (mAppRow == null || mChannel == null) { if (mAppRow == null || mChannel == null) {
return CONDITIONALLY_UNAVAILABLE; return false;
} }
return AVAILABLE; return true;
} }
@Override @Override

View File

@@ -37,7 +37,7 @@ public class ConversationPromotePreferenceController extends NotificationPrefere
public ConversationPromotePreferenceController(Context context, public ConversationPromotePreferenceController(Context context,
SettingsPreferenceFragment hostFragment, SettingsPreferenceFragment hostFragment,
NotificationBackend backend) { NotificationBackend backend) {
super(context, backend, KEY); super(context, backend);
mHostFragment = hostFragment; mHostFragment = hostFragment;
} }
@@ -47,17 +47,14 @@ public class ConversationPromotePreferenceController extends NotificationPrefere
} }
@Override @Override
public int getAvailabilityStatus() { public boolean isAvailable() {
if (super.getAvailabilityStatus() == CONDITIONALLY_UNAVAILABLE) { if (!super.isAvailable()) {
return CONDITIONALLY_UNAVAILABLE; return false;
} }
if (mAppRow == null || mChannel == null) { if (mAppRow == null || mChannel == null) {
return CONDITIONALLY_UNAVAILABLE; return false;
} }
if (!TextUtils.isEmpty(mChannel.getConversationId()) && mChannel.isDemoted()) { return !TextUtils.isEmpty(mChannel.getConversationId()) && mChannel.isDemoted();
return AVAILABLE;
}
return CONDITIONALLY_UNAVAILABLE;
} }
@Override @Override

View File

@@ -30,7 +30,7 @@ public class DeletedChannelsPreferenceController extends NotificationPreferenceC
private static final String KEY_DELETED = "deleted"; private static final String KEY_DELETED = "deleted";
public DeletedChannelsPreferenceController(Context context, NotificationBackend backend) { public DeletedChannelsPreferenceController(Context context, NotificationBackend backend) {
super(context, backend, KEY_DELETED); super(context, backend);
} }
@Override @Override
@@ -39,19 +39,16 @@ public class DeletedChannelsPreferenceController extends NotificationPreferenceC
} }
@Override @Override
public int getAvailabilityStatus() { public boolean isAvailable() {
if (super.getAvailabilityStatus() == CONDITIONALLY_UNAVAILABLE) { if (!super.isAvailable()) {
return CONDITIONALLY_UNAVAILABLE; return false;
} }
// only visible on app screen // only visible on app screen
if (mChannel != null || hasValidGroup()) { if (mChannel != null || hasValidGroup()) {
return CONDITIONALLY_UNAVAILABLE; return false;
} }
if (mBackend.getDeletedChannelCount(mAppRow.pkg, mAppRow.uid) > 0) { return mBackend.getDeletedChannelCount(mAppRow.pkg, mAppRow.uid) > 0;
return AVAILABLE;
}
return CONDITIONALLY_UNAVAILABLE;
} }
@Override @Override

View File

@@ -29,7 +29,7 @@ public class DescriptionPreferenceController extends NotificationPreferenceContr
private static final String KEY_DESC = "desc"; private static final String KEY_DESC = "desc";
public DescriptionPreferenceController(Context context) { public DescriptionPreferenceController(Context context) {
super(context, null, KEY_DESC); super(context, null);
} }
@Override @Override
@@ -38,20 +38,20 @@ public class DescriptionPreferenceController extends NotificationPreferenceContr
} }
@Override @Override
public int getAvailabilityStatus() { public boolean isAvailable() {
if (super.getAvailabilityStatus() == CONDITIONALLY_UNAVAILABLE) { if (!super.isAvailable()) {
return CONDITIONALLY_UNAVAILABLE; return false;
} }
if (mChannel == null && !hasValidGroup()) { if (mChannel == null && !hasValidGroup()) {
return CONDITIONALLY_UNAVAILABLE; return false;
} }
if (mChannel != null && !TextUtils.isEmpty(mChannel.getDescription())) { if (mChannel != null && !TextUtils.isEmpty(mChannel.getDescription())) {
return AVAILABLE; return true;
} }
if (hasValidGroup() && !TextUtils.isEmpty(mChannelGroup.getDescription())) { if (hasValidGroup() && !TextUtils.isEmpty(mChannelGroup.getDescription())) {
return AVAILABLE; return true;
} }
return CONDITIONALLY_UNAVAILABLE; return false;
} }
@Override @Override

View File

@@ -31,7 +31,7 @@ public class DndPreferenceController extends NotificationPreferenceController
private static final String KEY_BYPASS_DND = "bypass_dnd"; private static final String KEY_BYPASS_DND = "bypass_dnd";
public DndPreferenceController(Context context, NotificationBackend backend) { public DndPreferenceController(Context context, NotificationBackend backend) {
super(context, backend, KEY_BYPASS_DND); super(context, backend);
} }
@Override @Override
@@ -40,11 +40,11 @@ public class DndPreferenceController extends NotificationPreferenceController
} }
@Override @Override
public int getAvailabilityStatus() { public boolean isAvailable() {
if (super.getAvailabilityStatus() == CONDITIONALLY_UNAVAILABLE || mChannel == null) { if (!super.isAvailable() || mChannel == null) {
return CONDITIONALLY_UNAVAILABLE; return false;
} }
return AVAILABLE; return true;
} }
@Override @Override

View File

@@ -45,7 +45,7 @@ public class HeaderPreferenceController extends NotificationPreferenceController
private boolean mStarted = false; private boolean mStarted = false;
public HeaderPreferenceController(Context context, DashboardFragment fragment) { public HeaderPreferenceController(Context context, DashboardFragment fragment) {
super(context, null, PREF_KEY_APP_HEADER); super(context, null);
mFragment = fragment; mFragment = fragment;
} }
@@ -55,8 +55,8 @@ public class HeaderPreferenceController extends NotificationPreferenceController
} }
@Override @Override
public int getAvailabilityStatus() { public boolean isAvailable() {
return mAppRow != null ? AVAILABLE : CONDITIONALLY_UNAVAILABLE; return mAppRow != null;
} }
@Override @Override

View File

@@ -37,7 +37,7 @@ public class HighImportancePreferenceController extends NotificationPreferenceCo
public HighImportancePreferenceController(Context context, public HighImportancePreferenceController(Context context,
NotificationSettings.DependentFieldListener dependentFieldListener, NotificationSettings.DependentFieldListener dependentFieldListener,
NotificationBackend backend) { NotificationBackend backend) {
super(context, backend, KEY_IMPORTANCE); super(context, backend);
mDependentFieldListener = dependentFieldListener; mDependentFieldListener = dependentFieldListener;
} }
@@ -47,19 +47,17 @@ public class HighImportancePreferenceController extends NotificationPreferenceCo
} }
@Override @Override
public int getAvailabilityStatus() { public boolean isAvailable() {
if (super.getAvailabilityStatus() == CONDITIONALLY_UNAVAILABLE) { if (!super.isAvailable()) {
return CONDITIONALLY_UNAVAILABLE; return false;
} }
if (mChannel == null) { if (mChannel == null) {
return CONDITIONALLY_UNAVAILABLE; return false;
} }
if (isDefaultChannel()) { if (isDefaultChannel()) {
return CONDITIONALLY_UNAVAILABLE; return false;
} }
return mChannel.getImportance() >= IMPORTANCE_DEFAULT return mChannel.getImportance() >= IMPORTANCE_DEFAULT;
? AVAILABLE
: CONDITIONALLY_UNAVAILABLE;
} }
@Override @Override

View File

@@ -38,7 +38,7 @@ public class ImportancePreferenceController extends NotificationPreferenceContro
public ImportancePreferenceController(Context context, public ImportancePreferenceController(Context context,
NotificationSettings.DependentFieldListener dependentFieldListener, NotificationSettings.DependentFieldListener dependentFieldListener,
NotificationBackend backend) { NotificationBackend backend) {
super(context, backend, KEY_IMPORTANCE); super(context, backend);
mDependentFieldListener = dependentFieldListener; mDependentFieldListener = dependentFieldListener;
} }
@@ -48,14 +48,14 @@ public class ImportancePreferenceController extends NotificationPreferenceContro
} }
@Override @Override
public int getAvailabilityStatus() { public boolean isAvailable() {
if (super.getAvailabilityStatus() == CONDITIONALLY_UNAVAILABLE) { if (!super.isAvailable()) {
return CONDITIONALLY_UNAVAILABLE; return false;
} }
if (mChannel == null) { if (mChannel == null) {
return CONDITIONALLY_UNAVAILABLE; return false;
} }
return !isDefaultChannel() ? AVAILABLE : CONDITIONALLY_UNAVAILABLE; return !isDefaultChannel();
} }
@Override @Override

View File

@@ -31,7 +31,7 @@ public class InvalidConversationInfoPreferenceController extends NotificationPre
public InvalidConversationInfoPreferenceController(Context context, public InvalidConversationInfoPreferenceController(Context context,
NotificationBackend backend) { NotificationBackend backend) {
super(context, backend, KEY); super(context, backend);
} }
@Override @Override
@@ -40,19 +40,17 @@ public class InvalidConversationInfoPreferenceController extends NotificationPre
} }
@Override @Override
public int getAvailabilityStatus() { public boolean isAvailable() {
if (mAppRow == null) { if (mAppRow == null) {
return CONDITIONALLY_UNAVAILABLE; return false;
} }
if (mAppRow.banned) { if (mAppRow.banned) {
return CONDITIONALLY_UNAVAILABLE; return false;
} }
if (mPreferenceFilter != null && !isIncludedInFilter()) { if (mPreferenceFilter != null && !isIncludedInFilter()) {
return CONDITIONALLY_UNAVAILABLE; return false;
} }
return mBackend.isInInvalidMsgState(mAppRow.pkg, mAppRow.uid) return mBackend.isInInvalidMsgState(mAppRow.pkg, mAppRow.uid);
? AVAILABLE
: CONDITIONALLY_UNAVAILABLE;
} }
@Override @Override

View File

@@ -31,7 +31,7 @@ public class InvalidConversationPreferenceController extends NotificationPrefere
private static final String KEY = "invalid_conversation_switch"; private static final String KEY = "invalid_conversation_switch";
public InvalidConversationPreferenceController(Context context, NotificationBackend backend) { public InvalidConversationPreferenceController(Context context, NotificationBackend backend) {
super(context, backend, KEY); super(context, backend);
} }
@Override @Override
@@ -40,19 +40,17 @@ public class InvalidConversationPreferenceController extends NotificationPrefere
} }
@Override @Override
public int getAvailabilityStatus() { public boolean isAvailable() {
if (mAppRow == null) { if (mAppRow == null) {
return CONDITIONALLY_UNAVAILABLE; return false;
} }
if (mAppRow.banned) { if (mAppRow.banned) {
return CONDITIONALLY_UNAVAILABLE; return false;
} }
if (mPreferenceFilter != null && !isIncludedInFilter()) { if (mPreferenceFilter != null && !isIncludedInFilter()) {
return CONDITIONALLY_UNAVAILABLE; return false;
} }
return mBackend.isInInvalidMsgState(mAppRow.pkg, mAppRow.uid) return mBackend.isInInvalidMsgState(mAppRow.pkg, mAppRow.uid);
? AVAILABLE
: CONDITIONALLY_UNAVAILABLE;
} }
@Override @Override

View File

@@ -33,7 +33,7 @@ public class LightsPreferenceController extends NotificationPreferenceController
private static final String KEY_LIGHTS = "lights"; private static final String KEY_LIGHTS = "lights";
public LightsPreferenceController(Context context, NotificationBackend backend) { public LightsPreferenceController(Context context, NotificationBackend backend) {
super(context, backend, KEY_LIGHTS); super(context, backend);
} }
@Override @Override
@@ -42,18 +42,16 @@ public class LightsPreferenceController extends NotificationPreferenceController
} }
@Override @Override
public int getAvailabilityStatus() { public boolean isAvailable() {
if (super.getAvailabilityStatus() == CONDITIONALLY_UNAVAILABLE) { if (!super.isAvailable()) {
return CONDITIONALLY_UNAVAILABLE; return false;
} }
if (mChannel == null) { if (mChannel == null) {
return CONDITIONALLY_UNAVAILABLE; return false;
} }
if (checkCanBeVisible(NotificationManager.IMPORTANCE_DEFAULT) && canPulseLight() return checkCanBeVisible(NotificationManager.IMPORTANCE_DEFAULT)
&& !isDefaultChannel()) { && canPulseLight()
return AVAILABLE; && !isDefaultChannel();
}
return CONDITIONALLY_UNAVAILABLE;
} }
@Override @Override

View File

@@ -37,7 +37,7 @@ public class MinImportancePreferenceController extends NotificationPreferenceCon
public MinImportancePreferenceController(Context context, public MinImportancePreferenceController(Context context,
NotificationSettings.DependentFieldListener dependentFieldListener, NotificationSettings.DependentFieldListener dependentFieldListener,
NotificationBackend backend) { NotificationBackend backend) {
super(context, backend, KEY_IMPORTANCE); super(context, backend);
mDependentFieldListener = dependentFieldListener; mDependentFieldListener = dependentFieldListener;
} }
@@ -47,17 +47,17 @@ public class MinImportancePreferenceController extends NotificationPreferenceCon
} }
@Override @Override
public int getAvailabilityStatus() { public boolean isAvailable() {
if (super.getAvailabilityStatus() == CONDITIONALLY_UNAVAILABLE) { if (!super.isAvailable()) {
return CONDITIONALLY_UNAVAILABLE; return false;
} }
if (mChannel == null) { if (mChannel == null) {
return CONDITIONALLY_UNAVAILABLE; return false;
} }
if (isDefaultChannel()) { if (isDefaultChannel()) {
return CONDITIONALLY_UNAVAILABLE; return false;
} }
return mChannel.getImportance() <= IMPORTANCE_LOW ? AVAILABLE : CONDITIONALLY_UNAVAILABLE; return mChannel.getImportance() <= IMPORTANCE_LOW;
} }
@Override @Override

View File

@@ -17,24 +17,26 @@
package com.android.settings.notification.app; package com.android.settings.notification.app;
import static android.app.NotificationManager.IMPORTANCE_NONE; import static android.app.NotificationManager.IMPORTANCE_NONE;
import static android.os.UserHandle.USER_SYSTEM;
import android.annotation.Nullable; import android.annotation.Nullable;
import android.app.NotificationChannel; import android.app.NotificationChannel;
import android.app.NotificationChannelGroup; import android.app.NotificationChannelGroup;
import android.app.NotificationManager; import android.app.NotificationManager;
import android.content.Context; import android.content.Context;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager; import android.content.pm.PackageManager;
import android.content.pm.ShortcutInfo; import android.content.pm.ShortcutInfo;
import android.graphics.drawable.Drawable; import android.graphics.drawable.Drawable;
import android.os.UserManager; import android.os.UserManager;
import android.provider.Settings;
import android.util.Log; import android.util.Log;
import android.util.Slog;
import androidx.preference.Preference; import androidx.preference.Preference;
import com.android.settings.core.BasePreferenceController;
import com.android.settings.notification.NotificationBackend; import com.android.settings.notification.NotificationBackend;
import com.android.settingslib.RestrictedLockUtils; import com.android.settingslib.RestrictedLockUtils;
import com.android.settingslib.core.AbstractPreferenceController;
import java.util.Comparator; import java.util.Comparator;
import java.util.List; import java.util.List;
@@ -44,7 +46,7 @@ import java.util.Objects;
* Parent class for preferences appearing on notification setting pages at the app, * Parent class for preferences appearing on notification setting pages at the app,
* notification channel group, or notification channel level. * 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"; private static final String TAG = "ChannelPrefContr";
@Nullable @Nullable
protected NotificationChannel mChannel; protected NotificationChannel mChannel;
@@ -69,11 +71,8 @@ public abstract class NotificationPreferenceController extends BasePreferenceCon
boolean overrideCanBlockValue; boolean overrideCanBlockValue;
boolean overrideCanConfigureValue; boolean overrideCanConfigureValue;
boolean mLoadedChannelState; public NotificationPreferenceController(Context context, NotificationBackend backend) {
super(context);
public NotificationPreferenceController(Context context, NotificationBackend backend,
String key) {
super(context, key);
mContext = context; mContext = context;
mNm = (NotificationManager) mContext.getSystemService(Context.NOTIFICATION_SERVICE); mNm = (NotificationManager) mContext.getSystemService(Context.NOTIFICATION_SERVICE);
mBackend = backend; mBackend = backend;
@@ -82,30 +81,28 @@ public abstract class NotificationPreferenceController extends BasePreferenceCon
} }
/** /**
* Returns available if field's parent object is not blocked. * Returns true if field's parent object is not blocked.
*/ */
@Override @Override
public int getAvailabilityStatus() { public boolean isAvailable() {
if (mAppRow == null) { if (mAppRow == null) {
return CONDITIONALLY_UNAVAILABLE; return false;
} }
if (mAppRow.banned) { if (mAppRow.banned) {
return CONDITIONALLY_UNAVAILABLE; return false;
} }
if (mChannelGroup != null) { if (mChannelGroup != null) {
if (mChannelGroup.isBlocked()) { if (mChannelGroup.isBlocked()) {
return CONDITIONALLY_UNAVAILABLE; return false;
} }
} }
if (mChannel != null) { if (mChannel != null) {
if (mPreferenceFilter != null && !isIncludedInFilter()) { 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, protected void onResume(NotificationBackend.AppRow appRow,

View File

@@ -41,7 +41,6 @@ import android.os.UserHandle;
import android.provider.Settings; import android.provider.Settings;
import android.text.TextUtils; import android.text.TextUtils;
import android.util.Log; import android.util.Log;
import android.util.Slog;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.view.ViewTreeObserver; import android.view.ViewTreeObserver;
@@ -130,52 +129,15 @@ abstract public class NotificationSettings extends DashboardFragment {
} }
} }
mUserId = UserHandle.getUserId(mUid);
mPkgInfo = findPackageInfo(mPkg, 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) { if (mPkgInfo != null) {
mUserId = UserHandle.getUserId(mUid);
mSuspendedAppsAdmin = RestrictedLockUtilsInternal.checkIfApplicationIsSuspended( mSuspendedAppsAdmin = RestrictedLockUtilsInternal.checkIfApplicationIsSuspended(
mContext, mPkg, mUserId); mContext, mPkg, mUserId);
loadAppRow();
if (mAppRow == null) {
toastAndFinish("Can't load package");
return;
}
loadChannel(); loadChannel();
loadConversation(); loadAppRow();
loadChannelGroup(); loadChannelGroup();
loadPreferencesFilter(); loadPreferencesFilter();
collectConfigActivities(); collectConfigActivities();
@@ -195,6 +157,55 @@ 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() { protected void animatePanel() {
if (mPreferenceFilter != null) { if (mPreferenceFilter != null) {
mLayoutView = getActivity().findViewById(R.id.main_content); mLayoutView = getActivity().findViewById(R.id.main_content);
@@ -296,8 +307,7 @@ abstract public class NotificationSettings extends DashboardFragment {
} }
} }
protected void toastAndFinish(String msg) { protected void toastAndFinish() {
Log.w(TAG, msg);
Toast.makeText(mContext, R.string.app_not_found_dlg_text, Toast.LENGTH_SHORT).show(); Toast.makeText(mContext, R.string.app_not_found_dlg_text, Toast.LENGTH_SHORT).show();
getActivity().finish(); getActivity().finish();
} }

View File

@@ -30,7 +30,7 @@ public class NotificationsOffPreferenceController extends NotificationPreference
private static final String KEY_BLOCKED_DESC = "block_desc"; private static final String KEY_BLOCKED_DESC = "block_desc";
public NotificationsOffPreferenceController(Context context) { public NotificationsOffPreferenceController(Context context) {
super(context, null, KEY_BLOCKED_DESC); super(context, null);
} }
@Override @Override
@@ -39,20 +39,16 @@ public class NotificationsOffPreferenceController extends NotificationPreference
} }
@Override @Override
public int getAvailabilityStatus() { public boolean isAvailable() {
if (mAppRow == null) { if (mAppRow == null) {
return CONDITIONALLY_UNAVAILABLE; return false;
} }
if (mPreferenceFilter != null && !isIncludedInFilter()) { if (mPreferenceFilter != null && !isIncludedInFilter()) {
return CONDITIONALLY_UNAVAILABLE; return false;
} }
// Available only when other controllers are unavailable - this UI replaces the UI that // Available only when other controllers are unavailable - this UI replaces the UI that
// would give more detailed notification controls. // would give more detailed notification controls.
if (super.getAvailabilityStatus() == AVAILABLE) { return !super.isAvailable();
return CONDITIONALLY_UNAVAILABLE;
} else {
return AVAILABLE;
}
} }
@Override @Override

View File

@@ -47,7 +47,7 @@ public class SoundPreferenceController extends NotificationPreferenceController
public SoundPreferenceController(Context context, SettingsPreferenceFragment hostFragment, public SoundPreferenceController(Context context, SettingsPreferenceFragment hostFragment,
NotificationSettings.DependentFieldListener dependentFieldListener, NotificationSettings.DependentFieldListener dependentFieldListener,
NotificationBackend backend) { NotificationBackend backend) {
super(context, backend, KEY_SOUND); super(context, backend);
mFragment = hostFragment; mFragment = hostFragment;
mListener = dependentFieldListener; mListener = dependentFieldListener;
} }
@@ -58,17 +58,14 @@ public class SoundPreferenceController extends NotificationPreferenceController
} }
@Override @Override
public int getAvailabilityStatus() { public boolean isAvailable() {
if (super.getAvailabilityStatus() == CONDITIONALLY_UNAVAILABLE) { if (!super.isAvailable()) {
return CONDITIONALLY_UNAVAILABLE; return false;
} }
if (mChannel == null) { if (mChannel == null) {
return CONDITIONALLY_UNAVAILABLE; return false;
} }
if (checkCanBeVisible(NotificationManager.IMPORTANCE_DEFAULT) && !isDefaultChannel()) { return checkCanBeVisible(NotificationManager.IMPORTANCE_DEFAULT) && !isDefaultChannel();
return AVAILABLE;
}
return CONDITIONALLY_UNAVAILABLE;
} }
@Override @Override

View File

@@ -34,7 +34,7 @@ public class VibrationPreferenceController extends NotificationPreferenceControl
private final Vibrator mVibrator; private final Vibrator mVibrator;
public VibrationPreferenceController(Context context, NotificationBackend backend) { public VibrationPreferenceController(Context context, NotificationBackend backend) {
super(context, backend, KEY_VIBRATE); super(context, backend);
mVibrator = context.getSystemService(Vibrator.class); mVibrator = context.getSystemService(Vibrator.class);
} }
@@ -44,15 +44,14 @@ public class VibrationPreferenceController extends NotificationPreferenceControl
} }
@Override @Override
public int getAvailabilityStatus() { public boolean isAvailable() {
if (super.getAvailabilityStatus() == CONDITIONALLY_UNAVAILABLE || mChannel == null) { if (!super.isAvailable() || mChannel == null) {
return CONDITIONALLY_UNAVAILABLE; return false;
} }
if (checkCanBeVisible(NotificationManager.IMPORTANCE_DEFAULT) && !isDefaultChannel() return checkCanBeVisible(NotificationManager.IMPORTANCE_DEFAULT)
&& mVibrator != null && mVibrator.hasVibrator()) { && !isDefaultChannel()
return AVAILABLE; && mVibrator != null
} && mVibrator.hasVibrator();
return CONDITIONALLY_UNAVAILABLE;
} }
@Override @Override

View File

@@ -48,7 +48,7 @@ public class VisibilityPreferenceController extends NotificationPreferenceContro
public VisibilityPreferenceController(Context context, LockPatternUtils utils, public VisibilityPreferenceController(Context context, LockPatternUtils utils,
NotificationBackend backend) { NotificationBackend backend) {
super(context, backend, KEY_VISIBILITY_OVERRIDE); super(context, backend);
mLockPatternUtils = utils; mLockPatternUtils = utils;
} }
@@ -58,18 +58,14 @@ public class VisibilityPreferenceController extends NotificationPreferenceContro
} }
@Override @Override
public int getAvailabilityStatus() { public boolean isAvailable() {
if (super.getAvailabilityStatus() == CONDITIONALLY_UNAVAILABLE) { if (!super.isAvailable()) {
return CONDITIONALLY_UNAVAILABLE; return false;
} }
if (mChannel == null || mAppRow.banned) { if (mChannel == null || mAppRow.banned) {
return CONDITIONALLY_UNAVAILABLE; return false;
} }
if (checkCanBeVisible(NotificationManager.IMPORTANCE_LOW) && isLockScreenSecure()) { return checkCanBeVisible(NotificationManager.IMPORTANCE_LOW) && isLockScreenSecure();
return AVAILABLE;
}
return CONDITIONALLY_UNAVAILABLE;
} }
@Override @Override

View File

@@ -426,7 +426,7 @@ public class NotificationPreferenceControllerTest {
private final class TestPreferenceController extends NotificationPreferenceController { private final class TestPreferenceController extends NotificationPreferenceController {
private TestPreferenceController(Context context, NotificationBackend backend) { private TestPreferenceController(Context context, NotificationBackend backend) {
super(context, backend, "key"); super(context, backend);
} }
@Override @Override