Add modes to Settings homepage.

Also moves the modes entrypoints out of the sub-pages it was previously in (notifications and sound settings).

Bug: 353700470
Test: manual by opening the homepage
Flag: android.app.modes_ui
Change-Id: I53124bfed25c43fc2dabaf9c43ce0513bbfc7377
This commit is contained in:
Yuri Lin
2024-08-20 16:58:37 -04:00
parent 8cd5a449dd
commit 3ccbb0ffa5
8 changed files with 33 additions and 20 deletions

View File

@@ -18,6 +18,7 @@ package com.android.settings.notification.modes;
import android.app.Flags;
import android.content.Context;
import android.util.Log;
import androidx.preference.Preference;
import androidx.preference.PreferenceScreen;
@@ -30,6 +31,7 @@ import com.android.settingslib.notification.modes.ZenModesBackend;
public class ZenModesLinkPreferenceController extends BasePreferenceController
implements LifecycleObserver, OnStart, OnStop {
private static final String TAG = "ModesLinkPrefController";
private final ZenModesBackend mBackend;
private final ZenSettingsObserver mSettingObserver;
@@ -71,7 +73,13 @@ public class ZenModesLinkPreferenceController extends BasePreferenceController
@Override
public void updateState(Preference preference) {
preference.setSummary(mSummaryBuilder.getModesSummary(mBackend.getModes()));
try {
preference.setSummary(mSummaryBuilder.getModesSummary(mBackend.getModes()));
} catch (SecurityException e) {
// Standard usage should have the correct permissions to read zen state. But if we don't
// for whatever reason, don't crash.
Log.w(TAG, "No permission to read mode state");
}
}
@Override