Snap for 9514198 from c8a6db40ac to tm-qpr3-release

Change-Id: I02688cd7e4aa3a5c2135bc7551ddb35c63a98bd0
This commit is contained in:
Android Build Coastguard Worker
2023-01-21 02:25:54 +00:00
11 changed files with 250 additions and 39 deletions

5
OWNERS
View File

@@ -4,16 +4,19 @@ android-settings-core-eng+gerrit@google.com
# People who can approve changes for submission
arcwang@google.com
chiujason@google.com
cyl@google.com
edgarwang@google.com
emilychuang@google.com
llz@google.com
millchen@google.com
songchenxi@google.com
stanleytfwang@google.com
sunnyshao@google.com
tmfang@google.com
yantingyang@google.com
# Emergency only
luyota@google.com
lijun@google.com
# Exempt resource files (because they are in a flat directory and too hard to manage via OWNERS)
per-file *.xml=*

File diff suppressed because one or more lines are too long

View File

@@ -9414,6 +9414,12 @@
<!-- Configure Notifications: Title for the option controlling notifications for work profile. [CHAR LIMIT=30] -->
<string name="locked_work_profile_notification_title">When work profile is locked</string>
<!-- Configure notifications: Title for the option controlling whether only new notifications are displayed to the user
on the lock screen [CHAR LIMIT=60] -->
<string name="unseen_notifs_lock_screen">Show only new notifications on lock screen</string>
<!-- Configure notifications: Summary for option of showing only new notifications on the lock screen. [CHAR LIMIT=100] -->
<string name="unseen_notifs_lock_screen_summary">After each unlock, remove existing notifications from the lock screen</string>
<!-- Configure notifications: Title for determining which notifications appear on the lock screen [CHAR LIMIT=60] -->
<string name="lock_screen_notifs_title">Notifications on lock screen</string>

View File

@@ -119,9 +119,16 @@
android:fragment="com.android.settings.notification.zen.ZenModeSettings"
settings:controller="com.android.settings.notification.zen.ZenModePreferenceController"
/>
<SwitchPreference
android:key="lock_screen_show_only_unseen_notifs"
android:order="18"
android:title="@string/unseen_notifs_lock_screen"
android:summary="@string/unseen_notifs_lock_screen_summary"
settings:controller="com.android.settings.notification.ShowOnlyUnseenNotificationsOnLockscreenPreferenceController"
/>
<com.android.settingslib.RestrictedPreference
android:key="app_and_notif_cell_broadcast_settings"
android:order="18"
android:order="19"
android:title="@string/cell_broadcast_settings"
settings:useAdminDisabledSummary="true">
<intent
@@ -132,33 +139,33 @@
<SwitchPreference
android:key="silent_icons"
android:order="19"
android:order="20"
android:title="@string/silent_notifications_status_bar"
settings:controller="com.android.settings.notification.SilentStatusBarPreferenceController"/>
<SwitchPreference
android:key="show_snooze_options"
android:order="20"
android:order="21"
android:title="@string/snooze_options_title"
settings:controller="com.android.settings.notification.SnoozeNotificationPreferenceController" />
<!-- Notification badging -->
<SwitchPreference
android:key="notification_badging"
android:order="21"
android:order="22"
android:title="@string/notification_badging_title"
settings:controller="com.android.settings.notification.BadgingNotificationPreferenceController"/>
<!-- Pulse notification light, on devices that support it -->
<SwitchPreference
android:key="notification_pulse"
android:order="22"
android:order="23"
android:title="@string/notification_pulse_title"
settings:controller="com.android.settings.notification.PulseNotificationPreferenceController"/>
<com.android.settingslib.PrimarySwitchPreference
android:key="notification_assistant"
android:order="23"
android:order="24"
android:title="@string/notification_assistant_title"
android:summary="@string/notification_assistant_summary"
settings:controller="com.android.settings.notification.NotificationAssistantPreferenceController"/>

View File

@@ -18,9 +18,7 @@ package com.android.settings.accessibility;
import android.content.Context;
import android.content.res.Resources;
import android.view.Display;
import com.android.settingslib.display.DisplayDensityConfiguration;
import com.android.settingslib.display.DisplayDensityUtils;
import java.util.Arrays;
@@ -31,11 +29,13 @@ import java.util.stream.Collectors;
* Data class for storing the configurations related to the display size.
*/
class DisplaySizeData extends PreviewSizeData<Integer> {
private final DisplayDensityUtils mDensity;
DisplaySizeData(Context context) {
super(context);
final DisplayDensityUtils density = new DisplayDensityUtils(getContext());
final int initialIndex = density.getCurrentIndex();
mDensity = new DisplayDensityUtils(getContext());
final int initialIndex = mDensity.getCurrentIndexForDefaultDisplay();
if (initialIndex < 0) {
// Failed to obtain default density, which means we failed to
// connect to the window manager service. Just use the current
@@ -46,9 +46,10 @@ class DisplaySizeData extends PreviewSizeData<Integer> {
setInitialIndex(0);
setValues(Collections.singletonList(densityDpi));
} else {
setDefaultValue(density.getDefaultDensity());
setDefaultValue(mDensity.getDefaultDensityForDefaultDisplay());
setInitialIndex(initialIndex);
setValues(Arrays.stream(density.getValues()).boxed().collect(Collectors.toList()));
setValues(Arrays.stream(mDensity.getDefaultDisplayDensityValues()).boxed()
.collect(Collectors.toList()));
}
}
@@ -56,10 +57,9 @@ class DisplaySizeData extends PreviewSizeData<Integer> {
void commit(int currentProgress) {
final int densityDpi = getValues().get(currentProgress);
if (densityDpi == getDefaultValue()) {
DisplayDensityConfiguration.clearForcedDisplayDensity(Display.DEFAULT_DISPLAY);
mDensity.clearForcedDisplayDensity();
} else {
DisplayDensityConfiguration.setForcedDisplayDensity(Display.DEFAULT_DISPLAY,
densityDpi);
mDensity.setForcedDisplayDensity(currentProgress);
}
}
}

View File

@@ -192,9 +192,10 @@ public class FingerprintEnrollEnrolling extends BiometricsEnrollEnrolling {
@VisibleForTesting
protected boolean shouldShowLottie() {
DisplayDensityUtils displayDensity = new DisplayDensityUtils(getApplicationContext());
int currentDensityIndex = displayDensity.getCurrentIndex();
final int currentDensity = displayDensity.getValues()[currentDensityIndex];
final int defaultDensity = displayDensity.getDefaultDensity();
int currentDensityIndex = displayDensity.getCurrentIndexForDefaultDisplay();
final int currentDensity = displayDensity.getDefaultDisplayDensityValues()
[currentDensityIndex];
final int defaultDensity = displayDensity.getDefaultDensityForDefaultDisplay();
return defaultDensity == currentDensity;
}

View File

@@ -307,10 +307,11 @@ public class ScreenResolutionFragment extends RadioButtonPickerFragment {
}
final DisplayDensityUtils density = new DisplayDensityUtils(mContext);
final int currentIndex = density.getCurrentIndex();
final int defaultDensity = density.getDefaultDensity();
final int currentIndex = density.getCurrentIndexForDefaultDisplay();
final int defaultDensity = density.getDefaultDensityForDefaultDisplay();
if (density.getValues()[mCurrentIndex] == density.getDefaultDensity()) {
if (density.getDefaultDisplayDensityValues()[mCurrentIndex]
== density.getDefaultDensityForDefaultDisplay()) {
return;
}
@@ -351,17 +352,17 @@ public class ScreenResolutionFragment extends RadioButtonPickerFragment {
private void restoreDensity() {
final DisplayDensityUtils density = new DisplayDensityUtils(mContext);
if (density.getValues()[mCurrentIndex] != density.getDefaultDensity()) {
DisplayDensityUtils.setForcedDisplayDensity(
Display.DEFAULT_DISPLAY, density.getValues()[mCurrentIndex]);
if (density.getDefaultDisplayDensityValues()[mCurrentIndex]
!= density.getDefaultDensityForDefaultDisplay()) {
density.setForcedDisplayDensity(mCurrentIndex);
}
mDefaultDensity = density.getDefaultDensity();
mDefaultDensity = density.getDefaultDensityForDefaultDisplay();
}
private boolean isDensityChanged() {
final DisplayDensityUtils density = new DisplayDensityUtils(mContext);
if (density.getDefaultDensity() == mDefaultDensity) {
if (density.getDefaultDensityForDefaultDisplay() == mDefaultDensity) {
return false;
}

View File

@@ -36,13 +36,13 @@ public class ScreenZoomPreference extends Preference {
android.R.attr.preferenceStyle));
final DisplayDensityUtils density = new DisplayDensityUtils(context);
final int defaultIndex = density.getCurrentIndex();
final int defaultIndex = density.getCurrentIndexForDefaultDisplay();
if (defaultIndex < 0) {
setVisible(false);
setEnabled(false);
} else if (TextUtils.isEmpty(getSummary())) {
final String[] entries = density.getEntries();
final int currentIndex = density.getCurrentIndex();
final String[] entries = density.getDefaultDisplayDensityEntries();
final int currentIndex = density.getCurrentIndexForDefaultDisplay();
setSummary(entries[currentIndex]);
}
}

View File

@@ -21,11 +21,9 @@ import android.app.settings.SettingsEnums;
import android.content.Context;
import android.content.res.Configuration;
import android.os.Bundle;
import android.view.Display;
import com.android.settings.R;
import com.android.settings.search.BaseSearchIndexProvider;
import com.android.settingslib.display.DisplayDensityConfiguration;
import com.android.settingslib.display.DisplayDensityUtils;
import com.android.settingslib.search.SearchIndexable;
@@ -37,6 +35,7 @@ public class ScreenZoomSettings extends PreviewSeekBarPreferenceFragment {
private int mDefaultDensity;
private int[] mValues;
private DisplayDensityUtils mDensity;
@Override
protected int getActivityLayoutResId() {
@@ -58,9 +57,9 @@ public class ScreenZoomSettings extends PreviewSeekBarPreferenceFragment {
public void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
final DisplayDensityUtils density = new DisplayDensityUtils(getContext());
mDensity = new DisplayDensityUtils(getContext());
final int initialIndex = density.getCurrentIndex();
final int initialIndex = mDensity.getCurrentIndexForDefaultDisplay();
if (initialIndex < 0) {
// Failed to obtain default density, which means we failed to
// connect to the window manager service. Just use the current
@@ -71,10 +70,10 @@ public class ScreenZoomSettings extends PreviewSeekBarPreferenceFragment {
mInitialIndex = 0;
mDefaultDensity = densityDpi;
} else {
mValues = density.getValues();
mEntries = density.getEntries();
mValues = mDensity.getDefaultDisplayDensityValues();
mEntries = mDensity.getDefaultDisplayDensityEntries();
mInitialIndex = initialIndex;
mDefaultDensity = density.getDefaultDensity();
mDefaultDensity = mDensity.getDefaultDensityForDefaultDisplay();
}
getActivity().setTitle(R.string.screen_zoom_title);
@@ -95,9 +94,9 @@ public class ScreenZoomSettings extends PreviewSeekBarPreferenceFragment {
protected void commit() {
final int densityDpi = mValues[mCurrentIndex];
if (densityDpi == mDefaultDensity) {
DisplayDensityConfiguration.clearForcedDisplayDensity(Display.DEFAULT_DISPLAY);
mDensity.clearForcedDisplayDensity();
} else {
DisplayDensityConfiguration.setForcedDisplayDensity(Display.DEFAULT_DISPLAY, densityDpi);
mDensity.setForcedDisplayDensity(densityDpi);
}
}

View File

@@ -0,0 +1,71 @@
/*
* Copyright (C) 2023 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;
import static android.provider.Settings.Secure.LOCK_SCREEN_SHOW_ONLY_UNSEEN_NOTIFICATIONS;
import android.content.Context;
import android.provider.Settings;
import androidx.annotation.VisibleForTesting;
import com.android.settings.R;
import com.android.settings.core.TogglePreferenceController;
public class ShowOnlyUnseenNotificationsOnLockscreenPreferenceController
extends TogglePreferenceController {
private static final int UNSET = 0;
@VisibleForTesting
static final int ON = 1;
@VisibleForTesting
static final int OFF = 2;
public ShowOnlyUnseenNotificationsOnLockscreenPreferenceController(
Context context,
String preferenceKey) {
super(context, preferenceKey);
}
@Override
public boolean isChecked() {
return Settings.Secure.getInt(mContext.getContentResolver(),
LOCK_SCREEN_SHOW_ONLY_UNSEEN_NOTIFICATIONS, UNSET) == ON;
}
@Override
public boolean setChecked(boolean isChecked) {
return Settings.Secure.putInt(mContext.getContentResolver(),
LOCK_SCREEN_SHOW_ONLY_UNSEEN_NOTIFICATIONS, isChecked ? ON : OFF);
}
@Override
public int getAvailabilityStatus() {
int setting = Settings.Secure.getInt(mContext.getContentResolver(),
LOCK_SCREEN_SHOW_ONLY_UNSEEN_NOTIFICATIONS, UNSET);
if (setting == UNSET) {
return CONDITIONALLY_UNAVAILABLE;
} else {
return AVAILABLE;
}
}
@Override
public int getSliceHighlightMenuRes() {
return R.string.menu_key_notifications;
}
}

View File

@@ -0,0 +1,122 @@
/*
* Copyright (C) 2023 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;
import static android.provider.Settings.Secure.LOCK_SCREEN_SHOW_ONLY_UNSEEN_NOTIFICATIONS;
import static com.android.settings.notification.ShowOnlyUnseenNotificationsOnLockscreenPreferenceController.OFF;
import static com.android.settings.notification.ShowOnlyUnseenNotificationsOnLockscreenPreferenceController.ON;
import static com.google.common.truth.Truth.assertThat;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import android.app.admin.DevicePolicyManager;
import android.content.Context;
import android.provider.Settings;
import androidx.preference.Preference;
import androidx.preference.PreferenceScreen;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Answers;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.RuntimeEnvironment;
@RunWith(RobolectricTestRunner.class)
public class ShowOnlyUnseenNotificationsOnLockscreenPreferenceControllerTest {
@Mock(answer = Answers.RETURNS_DEEP_STUBS)
private Context mContext;
@Mock(answer = Answers.RETURNS_DEEP_STUBS)
private PreferenceScreen mScreen;
private ShowOnlyUnseenNotificationsOnLockscreenPreferenceController mController;
private Preference mPreference;
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
doReturn(mock(DevicePolicyManager.class)).when(mContext)
.getSystemService(Context.DEVICE_POLICY_SERVICE);
mController = new ShowOnlyUnseenNotificationsOnLockscreenPreferenceController(mContext,
"key");
mPreference = new Preference(RuntimeEnvironment.application);
mPreference.setKey(mController.getPreferenceKey());
when(mScreen.findPreference(mPreference.getKey())).thenReturn(mPreference);
}
@Test
public void display_configUnset_shouldNotDisplay() {
mController.displayPreference(mScreen);
assertThat(mPreference.isVisible()).isFalse();
}
@Test
public void display_configSet_showDisplay() {
Settings.Secure.putInt(mContext.getContentResolver(),
LOCK_SCREEN_SHOW_ONLY_UNSEEN_NOTIFICATIONS, OFF);
mController.displayPreference(mScreen);
assertThat(mPreference.isVisible()).isTrue();
}
@Test
public void isChecked_settingIsOff_shouldReturnFalse() {
Settings.Secure.putInt(mContext.getContentResolver(),
LOCK_SCREEN_SHOW_ONLY_UNSEEN_NOTIFICATIONS, OFF);
assertThat(mController.isChecked()).isFalse();
}
@Test
public void isChecked_settingIsOn_shouldReturnTrue() {
Settings.Secure.putInt(mContext.getContentResolver(),
LOCK_SCREEN_SHOW_ONLY_UNSEEN_NOTIFICATIONS, ON);
assertThat(mController.isChecked()).isTrue();
}
@Test
public void setChecked_setFalse_disablesSetting() {
Settings.Secure.putInt(mContext.getContentResolver(),
LOCK_SCREEN_SHOW_ONLY_UNSEEN_NOTIFICATIONS, ON);
mController.setChecked(false);
int updatedValue = Settings.Secure.getInt(mContext.getContentResolver(),
LOCK_SCREEN_SHOW_ONLY_UNSEEN_NOTIFICATIONS, -1);
assertThat(updatedValue).isEqualTo(OFF);
}
@Test
public void setChecked_setTrue_enablesSetting() {
Settings.Secure.putInt(mContext.getContentResolver(),
LOCK_SCREEN_SHOW_ONLY_UNSEEN_NOTIFICATIONS, OFF);
mController.setChecked(true);
int updatedValue = Settings.Secure.getInt(mContext.getContentResolver(),
LOCK_SCREEN_SHOW_ONLY_UNSEEN_NOTIFICATIONS, -1);
assertThat(updatedValue).isEqualTo(ON);
}
}