diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index 5072e677204..c01d162d312 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -1384,40 +1384,6 @@
android:theme="@style/Theme.Settings.NoActionBar">
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/res/values/strings.xml b/res/values/strings.xml
index d752338bc40..294aae37cec 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -8451,28 +8451,6 @@
Duration
-
- Messages, events & reminders
-
- When Do Not Disturb is on, messages, reminders, and events will be muted, except for the items you allow above. You can adjust messages settings to allow your friends, family, or other contacts to reach you.
-
-
- Done
-
- Settings
-
-
- No visuals or sound from notifications
-
- No sound from notifications
-
- You won\u2019t see or hear notifications. Calls from starred contacts and repeat callers are allowed.
-
- (Current setting)
-
-
- Change Do Not Disturb notification settings?
-
Work profile sounds
diff --git a/src/com/android/settings/dashboard/suggestions/SuggestionFeatureProviderImpl.java b/src/com/android/settings/dashboard/suggestions/SuggestionFeatureProviderImpl.java
index 5e8e3740904..c8ce7d82e4a 100644
--- a/src/com/android/settings/dashboard/suggestions/SuggestionFeatureProviderImpl.java
+++ b/src/com/android/settings/dashboard/suggestions/SuggestionFeatureProviderImpl.java
@@ -30,8 +30,6 @@ import com.android.settings.biometrics.fingerprint.FingerprintEnrollSuggestionAc
import com.android.settings.biometrics.fingerprint.FingerprintSuggestionActivity;
import com.android.settings.display.NightDisplayPreferenceController;
import com.android.settings.flags.Flags;
-import com.android.settings.notification.zen.ZenOnboardingActivity;
-import com.android.settings.notification.zen.ZenSuggestionActivity;
import com.android.settings.password.ScreenLockSuggestionActivity;
import com.android.settings.wallpaper.StyleSuggestionActivity;
import com.android.settings.wallpaper.WallpaperSuggestionActivity;
@@ -72,8 +70,6 @@ public class SuggestionFeatureProviderImpl implements SuggestionFeatureProvider
return WifiCallingSuggestionActivity.isSuggestionComplete(context);
} else if (className.equals(NightDisplaySuggestionActivity.class.getName())) {
return NightDisplayPreferenceController.isSuggestionComplete(context);
- } else if (className.equals(ZenSuggestionActivity.class.getName())) {
- return ZenOnboardingActivity.isSuggestionComplete(context);
}
return false;
}
diff --git a/src/com/android/settings/notification/zen/ZenModeBackend.java b/src/com/android/settings/notification/zen/ZenModeBackend.java
index c85b06bef38..2eb87c5c1aa 100644
--- a/src/com/android/settings/notification/zen/ZenModeBackend.java
+++ b/src/com/android/settings/notification/zen/ZenModeBackend.java
@@ -172,9 +172,6 @@ public class ZenModeBackend {
}
protected void saveVisualEffectsPolicy(int category, boolean suppress) {
- Settings.Secure.putInt(mContext.getContentResolver(),
- Settings.Secure.ZEN_SETTINGS_UPDATED, 1);
-
int suppressedEffects = getNewSuppressedEffects(suppress, category);
savePolicy(mPolicy.priorityCategories, mPolicy.priorityCallSenders,
mPolicy.priorityMessageSenders, suppressedEffects,
diff --git a/src/com/android/settings/notification/zen/ZenOnboardingActivity.java b/src/com/android/settings/notification/zen/ZenOnboardingActivity.java
deleted file mode 100644
index 151341cc4e8..00000000000
--- a/src/com/android/settings/notification/zen/ZenOnboardingActivity.java
+++ /dev/null
@@ -1,208 +0,0 @@
-/*
- * Copyright (C) 2018 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.
- */
-
-package com.android.settings.notification.zen;
-
-import android.app.Activity;
-import android.app.Flags;
-import android.app.NotificationManager;
-import android.app.NotificationManager.Policy;
-import android.app.settings.SettingsEnums;
-import android.content.Context;
-import android.content.Intent;
-import android.content.SharedPreferences;
-import android.os.Bundle;
-import android.provider.Settings;
-import android.text.format.DateUtils;
-import android.util.Log;
-import android.view.View;
-import android.widget.RadioButton;
-
-import androidx.annotation.VisibleForTesting;
-
-import com.android.internal.logging.MetricsLogger;
-import com.android.settings.R;
-import com.android.settings.dashboard.suggestions.SuggestionFeatureProvider;
-import com.android.settings.overlay.FeatureFactory;
-
-public class ZenOnboardingActivity extends Activity {
-
- private static final String TAG = "ZenOnboardingActivity";
-
- @VisibleForTesting
- static final String PREF_KEY_SUGGESTION_FIRST_DISPLAY_TIME =
- "pref_zen_suggestion_first_display_time_ms";
- @VisibleForTesting
- static final long ALWAYS_SHOW_THRESHOLD = DateUtils.DAY_IN_MILLIS * 14;
-
- View mNewSetting;
- View mKeepCurrentSetting;
- RadioButton mNewSettingButton;
- RadioButton mKeepCurrentSettingButton;
-
- private NotificationManager mNm;
- private MetricsLogger mMetrics;
-
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setNotificationManager(getSystemService(NotificationManager.class));
- setMetricsLogger(new MetricsLogger());
-
- Context context = getApplicationContext();
- Settings.Secure.putInt(context.getContentResolver(),
- Settings.Secure.ZEN_SETTINGS_SUGGESTION_VIEWED, 1);
-
- setupUI();
- }
-
- @VisibleForTesting
- protected void setupUI() {
- setContentView(R.layout.zen_onboarding);
-
- mNewSetting = findViewById(R.id.zen_onboarding_new_setting);
- mKeepCurrentSetting = findViewById(R.id.zen_onboarding_current_setting);
- mNewSettingButton = findViewById(R.id.zen_onboarding_new_setting_button);
- mKeepCurrentSettingButton = findViewById(R.id.zen_onboarding_current_setting_button);
-
- View.OnClickListener newSettingClickListener = new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- mKeepCurrentSettingButton.setChecked(false);
- mNewSettingButton.setChecked(true);
- }
- };
-
- View.OnClickListener currentSettingClickListener = new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- mKeepCurrentSettingButton.setChecked(true);
- mNewSettingButton.setChecked(false);
- }
- };
-
- mNewSetting.setOnClickListener(newSettingClickListener);
- mNewSettingButton.setOnClickListener(newSettingClickListener);
-
- mKeepCurrentSetting.setOnClickListener(currentSettingClickListener);
- mKeepCurrentSettingButton.setOnClickListener(currentSettingClickListener);
-
- mKeepCurrentSettingButton.setChecked(true);
- mMetrics.visible(SettingsEnums.SETTINGS_ZEN_ONBOARDING);
- }
-
- @VisibleForTesting
- protected void setNotificationManager(NotificationManager nm) {
- mNm = nm;
- }
-
- @VisibleForTesting
- protected void setMetricsLogger(MetricsLogger ml) {
- mMetrics = ml;
- }
-
- public void launchSettings(View button) {
- mMetrics.action(SettingsEnums.ACTION_ZEN_ONBOARDING_SETTINGS);
- Intent settings = new Intent(Settings.ACTION_ZEN_MODE_SETTINGS)
- .setPackage(getPackageName());
- settings.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
- startActivity(settings);
- }
-
- public void save(View button) {
- NotificationManager.Policy policy = mNm.getNotificationPolicy();
-
- if (mNewSettingButton.isChecked()) {
- NotificationManager.Policy newPolicy = new NotificationManager.Policy(
- Policy.PRIORITY_CATEGORY_REPEAT_CALLERS | policy.priorityCategories,
- Policy.PRIORITY_SENDERS_STARRED,
- policy.priorityMessageSenders,
- NotificationManager.Policy.getAllSuppressedVisualEffects());
- if (Flags.modesApi()) {
- mNm.setNotificationPolicy(newPolicy, /* fromUser= */ true);
- } else {
- mNm.setNotificationPolicy(newPolicy);
- }
- mMetrics.action(SettingsEnums.ACTION_ZEN_ONBOARDING_OK);
- } else {
- mMetrics.action(SettingsEnums.ACTION_ZEN_ONBOARDING_KEEP_CURRENT_SETTINGS);
- }
-
- Settings.Secure.putInt(getApplicationContext().getContentResolver(),
- Settings.Secure.ZEN_SETTINGS_UPDATED, 1);
-
- finishAndRemoveTask();
- }
-
- public static boolean isSuggestionComplete(Context context) {
- if (wasZenUpdated(context)) {
- return true;
- }
-
- if (showSuggestion(context) || withinShowTimeThreshold(context)) {
- return false;
- }
-
- return true;
- }
-
- private static boolean wasZenUpdated(Context context) {
- // ZEN_SETTINGS_UPDATED is true for:
- // - fresh P+ device
- // - if zen visual effects values were changed by the user in Settings
- NotificationManager nm = context.getSystemService(NotificationManager.class);
- if (NotificationManager.Policy.areAllVisualEffectsSuppressed(
- nm.getNotificationPolicy().suppressedVisualEffects)) {
- Settings.Secure.putInt(context.getContentResolver(),
- Settings.Secure.ZEN_SETTINGS_UPDATED, 1);
- }
- return Settings.Secure.getInt(context.getContentResolver(),
- Settings.Secure.ZEN_SETTINGS_UPDATED, 0) != 0;
- }
-
- private static boolean showSuggestion(Context context) {
- // SHOW_ZEN_SETTINGS_SUGGESTION is by default true, but false when:
- // - user manually turns on dnd
-
- // SHOW_ZEN_SETTINGS_SUGGESTION is also true when:
- // - automatic rule has started DND and user has not seen the first use dialog
- return Settings.Secure.getInt(context.getContentResolver(),
- Settings.Secure.SHOW_ZEN_SETTINGS_SUGGESTION, 0) != 0;
-
- }
-
- private static boolean withinShowTimeThreshold(Context context) {
- final SuggestionFeatureProvider featureProvider =
- FeatureFactory.getFeatureFactory().getSuggestionFeatureProvider();
- final SharedPreferences prefs = featureProvider.getSharedPrefs(context);
- final long currentTimeMs = System.currentTimeMillis();
- final long firstDisplayTimeMs;
-
- if (!prefs.contains(PREF_KEY_SUGGESTION_FIRST_DISPLAY_TIME)) {
- firstDisplayTimeMs = currentTimeMs;
- prefs.edit().putLong(PREF_KEY_SUGGESTION_FIRST_DISPLAY_TIME, currentTimeMs).commit();
- } else {
- firstDisplayTimeMs = prefs.getLong(PREF_KEY_SUGGESTION_FIRST_DISPLAY_TIME, -1);
- }
-
- final long showTimeMs = firstDisplayTimeMs + ALWAYS_SHOW_THRESHOLD;
- final boolean stillShow = currentTimeMs < showTimeMs;
-
- Log.d(TAG, "still show zen suggestion based on time: " + stillShow + " showTimeMs="
- + showTimeMs);
- return stillShow;
- }
-}
diff --git a/src/com/android/settings/notification/zen/ZenSuggestionActivity.java b/src/com/android/settings/notification/zen/ZenSuggestionActivity.java
deleted file mode 100644
index b535a3e900e..00000000000
--- a/src/com/android/settings/notification/zen/ZenSuggestionActivity.java
+++ /dev/null
@@ -1,26 +0,0 @@
-package com.android.settings.notification.zen;
-
-import android.app.Activity;
-import android.content.Intent;
-import android.os.Bundle;
-import android.provider.Settings;
-
-public class ZenSuggestionActivity extends Activity {
-
- @Override
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
-
- // start up zen settings activity
- Intent settingsIntent = new Intent(Settings.ACTION_ZEN_MODE_SETTINGS)
- .setPackage(getPackageName());
- startActivity(settingsIntent);
-
- // start up onboarding activity
- Intent onboardingActivity = new Intent(Settings.ZEN_MODE_ONBOARDING)
- .setPackage(getPackageName());
- startActivity(onboardingActivity);
-
- finish();
- }
-}
diff --git a/tests/robotests/src/com/android/settings/notification/zen/ZenOnboardingActivityTest.java b/tests/robotests/src/com/android/settings/notification/zen/ZenOnboardingActivityTest.java
deleted file mode 100644
index 01360fdd414..00000000000
--- a/tests/robotests/src/com/android/settings/notification/zen/ZenOnboardingActivityTest.java
+++ /dev/null
@@ -1,231 +0,0 @@
-/*
- * Copyright (C) 2018 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
- */
-
-package com.android.settings.notification.zen;
-
-import static android.app.NotificationManager.Policy.PRIORITY_CATEGORY_ALARMS;
-import static android.app.NotificationManager.Policy.PRIORITY_CATEGORY_REPEAT_CALLERS;
-import static android.app.NotificationManager.Policy.SUPPRESSED_EFFECT_SCREEN_ON;
-
-import static com.android.settings.notification.zen.ZenOnboardingActivity.ALWAYS_SHOW_THRESHOLD;
-import static com.android.settings.notification.zen.ZenOnboardingActivity.PREF_KEY_SUGGESTION_FIRST_DISPLAY_TIME;
-import static com.android.settings.notification.zen.ZenOnboardingActivity.isSuggestionComplete;
-
-import static com.google.common.truth.Truth.assertThat;
-
-import static org.mockito.ArgumentMatchers.any;
-import static org.mockito.ArgumentMatchers.anyBoolean;
-import static org.mockito.ArgumentMatchers.eq;
-import static org.mockito.Mockito.never;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
-
-import android.app.Flags;
-import android.app.NotificationManager;
-import android.app.NotificationManager.Policy;
-import android.content.Context;
-import android.content.SharedPreferences;
-import android.provider.Settings;
-
-import com.android.internal.logging.MetricsLogger;
-import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
-import com.android.settings.testutils.FakeFeatureFactory;
-
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.ArgumentCaptor;
-import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
-import org.robolectric.Robolectric;
-import org.robolectric.RobolectricTestRunner;
-import org.robolectric.RuntimeEnvironment;
-import org.robolectric.shadows.ShadowApplication;
-
-@RunWith(RobolectricTestRunner.class)
-public class ZenOnboardingActivityTest {
-
- @Mock
- private MetricsLogger mMetricsLogger;
- @Mock
- private NotificationManager mNm;
-
- private ZenOnboardingActivity mActivity;
-
- private Context mContext;
- private FakeFeatureFactory mFeatureFactory;
-
- @Before
- public void setUp() {
- MockitoAnnotations.initMocks(this);
- ShadowApplication shadowApplication = ShadowApplication.getInstance();
- shadowApplication.setSystemService(Context.NOTIFICATION_SERVICE, mNm);
-
- mActivity = Robolectric.buildActivity(ZenOnboardingActivity.class)
- .create()
- .get();
- mActivity.setNotificationManager(mNm);
- mActivity.setMetricsLogger(mMetricsLogger);
-
- mActivity.setupUI();
-
- mContext = RuntimeEnvironment.application;
- mFeatureFactory = FakeFeatureFactory.setupForTest();
- when(mFeatureFactory.suggestionsFeatureProvider.getSharedPrefs(any(Context.class)))
- .thenReturn(getSharedPreferences());
- }
-
- @Test
- public void loadUiRecordsEvent() {
- verify(mMetricsLogger).visible(MetricsEvent.SETTINGS_ZEN_ONBOARDING);
- }
-
- @Test
- public void saveNewSetting() {
- Policy policy = new Policy(PRIORITY_CATEGORY_ALARMS, 0, 0, SUPPRESSED_EFFECT_SCREEN_ON);
- when(mNm.getNotificationPolicy()).thenReturn(policy);
-
- mActivity.mNewSetting.performClick();
- mActivity.save(null);
-
- verify(mMetricsLogger).action(MetricsEvent.ACTION_ZEN_ONBOARDING_OK);
-
- ArgumentCaptor captor = ArgumentCaptor.forClass(Policy.class);
- if (android.app.Flags.modesApi()) {
- verify(mNm).setNotificationPolicy(captor.capture(), eq(true));
- } else {
- verify(mNm).setNotificationPolicy(captor.capture());
- }
-
- Policy actual = captor.getValue();
- assertThat(actual.priorityCategories).isEqualTo(PRIORITY_CATEGORY_ALARMS
- | PRIORITY_CATEGORY_REPEAT_CALLERS);
- assertThat(actual.priorityCallSenders).isEqualTo(Policy.PRIORITY_SENDERS_STARRED);
- assertThat(actual.priorityMessageSenders).isEqualTo(Policy.PRIORITY_SENDERS_ANY);
- assertThat(actual.suppressedVisualEffects).isEqualTo(
- Policy.getAllSuppressedVisualEffects());
- }
-
- @Test
- public void keepCurrentSetting() {
- Policy policy = new Policy(PRIORITY_CATEGORY_ALARMS, 0, 0, SUPPRESSED_EFFECT_SCREEN_ON);
- when(mNm.getNotificationPolicy()).thenReturn(policy);
-
- mActivity.mKeepCurrentSetting.performClick();
- mActivity.save(null);
-
- verify(mMetricsLogger).action(MetricsEvent.ACTION_ZEN_ONBOARDING_KEEP_CURRENT_SETTINGS);
- if (Flags.modesApi()) {
- verify(mNm, never()).setNotificationPolicy(any(), anyBoolean());
- } else {
- verify(mNm, never()).setNotificationPolicy(any());
- }
- }
-
- @Test
- public void isSuggestionComplete_zenUpdated() {
- Policy policy = new Policy(0, 0, 0, 0);
- when(mNm.getNotificationPolicy()).thenReturn(policy);
-
- setZenUpdated(true);
- setShowSettingsSuggestion(false);
- setWithinTimeThreshold(true);
- assertThat(isSuggestionComplete(mContext)).isTrue();
- }
-
- @Test
- public void isSuggestionComplete_withinTimeThreshold() {
- Policy policy = new Policy(0, 0, 0, 0);
- when(mNm.getNotificationPolicy()).thenReturn(policy);
-
- setZenUpdated(false);
- setShowSettingsSuggestion(false);
- setWithinTimeThreshold(true);
- assertThat(isSuggestionComplete(mContext)).isFalse();
- }
-
- @Test
- public void isSuggestionComplete_showSettingsSuggestionTrue() {
- Policy policy = new Policy(0, 0, 0, 0);
- when(mNm.getNotificationPolicy()).thenReturn(policy);
-
- setZenUpdated(false);
- setShowSettingsSuggestion(true);
- setWithinTimeThreshold(false);
- assertThat(isSuggestionComplete(mContext)).isFalse();
- }
-
- @Test
- public void isSuggestionComplete_showSettingsSuggestionFalse_notWithinTimeThreshold() {
- Policy policy = new Policy(0, 0, 0, 0);
- when(mNm.getNotificationPolicy()).thenReturn(policy);
-
- setZenUpdated(false);
- setShowSettingsSuggestion(false);
- setWithinTimeThreshold(false);
- assertThat(isSuggestionComplete(mContext)).isTrue();
- }
-
-
- @Test
- public void isSuggestionComplete_visualEffectsUpdated() {
- // all values suppressed
- Policy policy = new Policy(0, 0, 0, 511);
- when(mNm.getNotificationPolicy()).thenReturn(policy);
-
- setZenUpdated(false);
- setShowSettingsSuggestion(true);
- setWithinTimeThreshold(true);
- assertThat(isSuggestionComplete(mContext)).isTrue();
- assertThat(Settings.Secure.getInt(mContext.getContentResolver(),
- Settings.Secure.ZEN_SETTINGS_UPDATED, -1)).isEqualTo(1);
- }
-
-
- private void setZenUpdated(boolean updated) {
- int zenUpdated = updated ? 1 : 0;
-
- Settings.Secure.putInt(mContext.getContentResolver(),
- Settings.Secure.ZEN_SETTINGS_UPDATED, zenUpdated);
- }
-
- private void setWithinTimeThreshold(boolean withinTime) {
- long firstTime = System.currentTimeMillis();
-
- if (withinTime) {
- firstTime -= ALWAYS_SHOW_THRESHOLD / 2;
- } else {
- firstTime -= ALWAYS_SHOW_THRESHOLD * 2;
- }
-
- getSharedPreferences().edit().putLong(PREF_KEY_SUGGESTION_FIRST_DISPLAY_TIME,
- firstTime).commit();
- }
-
- private void setShowSettingsSuggestion(boolean show) {
- int showZenSuggestion = 0;
- if (show) {
- showZenSuggestion = 1;
- }
-
- Settings.Secure.putInt(mContext.getContentResolver(),
- Settings.Secure.SHOW_ZEN_SETTINGS_SUGGESTION, showZenSuggestion);
- }
-
- private SharedPreferences getSharedPreferences() {
- return mContext.getSharedPreferences("test_zen_sugg", Context.MODE_PRIVATE);
- }
-}
diff --git a/tests/robotests/src/com/android/settings/suggestions/SettingsSuggestionsTest.java b/tests/robotests/src/com/android/settings/suggestions/SettingsSuggestionsTest.java
index 9f02f1f762e..ee1872d7210 100644
--- a/tests/robotests/src/com/android/settings/suggestions/SettingsSuggestionsTest.java
+++ b/tests/robotests/src/com/android/settings/suggestions/SettingsSuggestionsTest.java
@@ -29,7 +29,6 @@ import com.android.settings.R;
import com.android.settings.Settings;
import com.android.settings.biometrics.fingerprint.FingerprintEnrollSuggestionActivity;
import com.android.settings.biometrics.fingerprint.FingerprintSuggestionActivity;
-import com.android.settings.notification.zen.ZenSuggestionActivity;
import com.android.settings.wallpaper.WallpaperSuggestionActivity;
import com.android.settings.wifi.calling.WifiCallingSuggestionActivity;
@@ -81,14 +80,6 @@ public class SettingsSuggestionsTest {
R.string.night_display_suggestion_summary);
}
- @Test
- public void zenSuggestion_isValid() {
- assertSuggestionEquals(
- ZenSuggestionActivity.class.getName(),
- R.string.zen_suggestion_title,
- R.string.zen_suggestion_summary);
- }
-
private void assertSuggestionEquals(String activityName, @StringRes int titleRes,
@StringRes int summaryRes) {