diff --git a/OWNERS b/OWNERS index c008e287cf1..bd1f0adb534 100644 --- a/OWNERS +++ b/OWNERS @@ -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=* diff --git a/res/raw-sw600dp/extra_dim_banner.json b/res/raw-sw600dp/extra_dim_banner.json new file mode 100644 index 00000000000..0d150ae8f6f --- /dev/null +++ b/res/raw-sw600dp/extra_dim_banner.json @@ -0,0 +1 @@ +{"v":"5.10.0","fr":60,"ip":0,"op":300,"w":412,"h":300,"nm":"Extra_Dim_Tablet_DT","ddd":0,"assets":[],"layers":[{"ddd":0,"ind":1,"ty":4,"nm":".grey600","cl":"grey600","sr":1,"ks":{"o":{"a":0,"k":100,"ix":11},"r":{"a":0,"k":0,"ix":10},"p":{"a":0,"k":[206,149.71,0],"ix":2,"l":2},"a":{"a":0,"k":[206,149.71,0],"ix":1,"l":2},"s":{"a":0,"k":[100,100,100],"ix":6,"l":2}},"ao":0,"shapes":[{"ty":"gr","it":[{"ty":"gr","it":[{"ind":0,"ty":"sh","ix":1,"ks":{"a":0,"k":{"i":[[0,0],[0,-1.417],[0,0],[0,0],[1.411,0]],"o":[[-1.411,0],[0,0],[0,0],[0,-1.417],[0,0]],"v":[[-4.603,-1.797],[-7.16,0.77],[1.023,1.797],[7.16,0.77],[4.603,-1.797]],"c":true},"ix":2},"nm":"Path 1","mn":"ADBE Vector Shape - Group","hd":false},{"ty":"fl","c":{"a":0,"k":[0.501960784314,0.525490196078,0.545098039216,1],"ix":4},"o":{"a":0,"k":100,"ix":5},"r":1,"bm":0,"nm":"Fill 1","mn":"ADBE Vector Graphic - Fill","hd":false},{"ty":"tr","p":{"a":0,"k":[0,0],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[100,100],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"Transform"}],"nm":"Vector","np":2,"cix":2,"bm":0,"ix":1,"mn":"ADBE Vector Group","hd":false},{"ty":"tr","p":{"a":0,"k":[322.062,46.777],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[100,100],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"Transform"}],"nm":"button2","np":1,"cix":2,"bm":0,"ix":1,"mn":"ADBE Vector Group","hd":false},{"ty":"gr","it":[{"ty":"gr","it":[{"ind":0,"ty":"sh","ix":1,"ks":{"a":0,"k":{"i":[[0,0],[0,-1.417],[0,0],[0,0],[1.411,0]],"o":[[-1.411,0],[0,0],[0,0],[0,-1.417],[0,0]],"v":[[-11.251,-1.797],[-13.808,0.77],[0.511,1.797],[13.808,0.77],[11.251,-1.797]],"c":true},"ix":2},"nm":"Path 1","mn":"ADBE Vector Shape - Group","hd":false},{"ty":"fl","c":{"a":0,"k":[0.501960784314,0.525490196078,0.545098039216,1],"ix":4},"o":{"a":0,"k":100,"ix":5},"r":1,"bm":0,"nm":"Fill 1","mn":"ADBE Vector Graphic - Fill","hd":false},{"ty":"tr","p":{"a":0,"k":[0,0],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[100,100],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"Transform"}],"nm":"Vector","np":2,"cix":2,"bm":0,"ix":1,"mn":"ADBE Vector Group","hd":false},{"ty":"tr","p":{"a":0,"k":[279.283,46.777],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[100,100],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"Transform"}],"nm":"button1","np":1,"cix":2,"bm":0,"ix":2,"mn":"ADBE Vector Group","hd":false},{"ty":"gr","it":[{"ty":"gr","it":[{"ty":"rc","d":1,"s":{"a":0,"k":[208.56,330],"ix":2},"p":{"a":0,"k":[0,0],"ix":3},"r":{"a":0,"k":16,"ix":4},"nm":"Rectangle Path 1","mn":"ADBE Vector Shape - Rect","hd":false},{"ty":"op","nm":"Offset Paths 1","a":{"a":0,"k":-1.5,"ix":1},"lj":1,"ml":{"a":0,"k":4,"ix":3},"ix":2,"mn":"ADBE Vector Filter - Offset","hd":false},{"ty":"st","c":{"a":0,"k":[0.501960784314,0.525490196078,0.545098039216,1],"ix":3},"o":{"a":0,"k":100,"ix":4},"w":{"a":0,"k":3,"ix":5},"lc":1,"lj":1,"ml":4,"bm":0,"nm":"Stroke 1","mn":"ADBE Vector Graphic - Stroke","hd":false},{"ty":"tr","p":{"a":0,"k":[0,0],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[100,100],"ix":3},"r":{"a":0,"k":-90,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"Transform"}],"nm":"Frame","np":3,"cix":2,"bm":0,"ix":1,"mn":"ADBE Vector Group","hd":false},{"ty":"tr","p":{"a":0,"k":[206,151.661],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[-100,-100],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"Transform"}],"nm":"frame","np":1,"cix":2,"bm":0,"ix":3,"mn":"ADBE Vector Group","hd":false}],"ip":0,"op":300,"st":0,"ct":1,"bm":0},{"ddd":0,"ind":2,"ty":4,"nm":".black","cl":"black","sr":1,"ks":{"o":{"a":1,"k":[{"i":{"x":[0.833],"y":[0.833]},"o":{"x":[0.167],"y":[0.167]},"t":52,"s":[0]},{"i":{"x":[0.833],"y":[0.833]},"o":{"x":[0.167],"y":[0.167]},"t":72,"s":[60]},{"i":{"x":[0.833],"y":[0.833]},"o":{"x":[0.167],"y":[0.167]},"t":252,"s":[60]},{"t":272,"s":[0]}],"ix":11},"r":{"a":0,"k":0,"ix":10},"p":{"a":0,"k":[205.5,152,0],"ix":2,"l":2},"a":{"a":0,"k":[0,0,0],"ix":1,"l":2},"s":{"a":0,"k":[100,100,100],"ix":6,"l":2}},"ao":0,"shapes":[{"ty":"gr","it":[{"ind":0,"ty":"sh","ix":1,"ks":{"a":0,"k":{"i":[[0,0],[-0.5,9.5],[0,0],[21.342,-2.5],[0,0],[0,-4.354],[0,0],[-14.842,0]],"o":[[13.324,0],[0,0],[0,-4.354],[0,0],[-17.842,-1.5],[0,0],[0,4.354],[0,0]],"v":[[140.908,103.168],[163.75,88.168],[163.75,-88.832],[140.908,-102.832],[-139.408,-102.832],[-163.75,-90.832],[-163.75,91.168],[-141.25,103.168]],"c":true},"ix":2},"nm":"Path 1","mn":"ADBE Vector Shape - Group","hd":false},{"ty":"fl","c":{"a":0,"k":[0,0,0,1],"ix":4},"o":{"a":0,"k":100,"ix":5},"r":1,"bm":0,"nm":"Fill 1","mn":"ADBE Vector Graphic - Fill","hd":false},{"ty":"tr","p":{"a":0,"k":[0,0],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[100,100],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"Transform"}],"nm":"dim","np":2,"cix":2,"bm":0,"ix":1,"mn":"ADBE Vector Group","hd":false}],"ip":0,"op":300,"st":0,"ct":1,"bm":0},{"ddd":0,"ind":3,"ty":4,"nm":".grey600","cl":"grey600","sr":1,"ks":{"o":{"a":0,"k":100,"ix":11},"r":{"a":0,"k":0,"ix":10},"p":{"a":0,"k":[128.75,177.168,0],"ix":2,"l":2},"a":{"a":0,"k":[128.75,177.168,0],"ix":1,"l":2},"s":{"a":0,"k":[100,100,100],"ix":6,"l":2}},"ao":0,"shapes":[{"ty":"gr","it":[{"ty":"gr","it":[{"ty":"rc","d":1,"s":{"a":0,"k":[144,37],"ix":2},"p":{"a":0,"k":[0,0],"ix":3},"r":{"a":0,"k":10,"ix":4},"nm":"Rectangle Path 1","mn":"ADBE Vector Shape - Rect","hd":false},{"ty":"fl","c":{"a":0,"k":[0.501960813999,0.525490224361,0.54509806633,1],"ix":4},"o":{"a":0,"k":100,"ix":5},"r":1,"bm":0,"nm":"Fill 1","mn":"ADBE Vector Graphic - Fill","hd":false},{"ty":"tr","p":{"a":0,"k":[0,0],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[100,100],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"Transform"}],"nm":"Rectangle 12321","np":2,"cix":2,"bm":0,"ix":1,"mn":"ADBE Vector Group","hd":false},{"ty":"tr","p":{"a":0,"k":[128.75,192.668],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[100,100],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"Transform"}],"nm":"left rect - 1","np":1,"cix":2,"bm":0,"ix":1,"mn":"ADBE Vector Group","hd":false},{"ty":"gr","it":[{"ty":"gr","it":[{"ty":"rc","d":1,"s":{"a":0,"k":[144,26],"ix":2},"p":{"a":0,"k":[0,0],"ix":3},"r":{"a":0,"k":10,"ix":4},"nm":"Rectangle Path 1","mn":"ADBE Vector Shape - Rect","hd":false},{"ty":"fl","c":{"a":0,"k":[0.501960813999,0.525490224361,0.54509806633,1],"ix":4},"o":{"a":0,"k":100,"ix":5},"r":1,"bm":0,"nm":"Fill 1","mn":"ADBE Vector Graphic - Fill","hd":false},{"ty":"tr","p":{"a":0,"k":[0,0],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[100,100],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"Transform"}],"nm":"Rectangle 12320","np":2,"cix":2,"bm":0,"ix":1,"mn":"ADBE Vector Group","hd":false},{"ty":"tr","p":{"a":0,"k":[128.75,156.168],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[100,100],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"Transform"}],"nm":"left rect - 2","np":1,"cix":2,"bm":0,"ix":2,"mn":"ADBE Vector Group","hd":false}],"ip":0,"op":300,"st":0,"ct":1,"bm":0},{"ddd":0,"ind":4,"ty":4,"nm":".grey400","cl":"grey400","sr":1,"ks":{"o":{"a":0,"k":100,"ix":11},"r":{"a":0,"k":0,"ix":10},"p":{"a":0,"k":[285.75,102.168,0],"ix":2,"l":2},"a":{"a":0,"k":[285.75,102.168,0],"ix":1,"l":2},"s":{"a":0,"k":[100,100,100],"ix":6,"l":2}},"ao":0,"shapes":[{"ty":"gr","it":[{"ty":"gr","it":[{"ty":"rc","d":1,"s":{"a":0,"k":[144,37],"ix":2},"p":{"a":0,"k":[0,0],"ix":3},"r":{"a":0,"k":10,"ix":4},"nm":"Rectangle Path 1","mn":"ADBE Vector Shape - Rect","hd":false},{"ty":"fl","c":{"a":0,"k":[0.741176486015,0.75686275959,0.776470601559,1],"ix":4},"o":{"a":0,"k":100,"ix":5},"r":1,"bm":0,"nm":"Fill 1","mn":"ADBE Vector Graphic - Fill","hd":false},{"ty":"tr","p":{"a":0,"k":[0,0],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[100,100],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"Transform"}],"nm":"Rectangle 12323","np":2,"cix":2,"bm":0,"ix":1,"mn":"ADBE Vector Group","hd":false},{"ty":"tr","p":{"a":0,"k":[285.75,117.668],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[100,100],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"Transform"}],"nm":"right rect - 1","np":1,"cix":2,"bm":0,"ix":1,"mn":"ADBE Vector Group","hd":false},{"ty":"gr","it":[{"ty":"gr","it":[{"ty":"rc","d":1,"s":{"a":0,"k":[144,26],"ix":2},"p":{"a":0,"k":[0,0],"ix":3},"r":{"a":0,"k":10,"ix":4},"nm":"Rectangle Path 1","mn":"ADBE Vector Shape - Rect","hd":false},{"ty":"fl","c":{"a":0,"k":[0.741176486015,0.75686275959,0.776470601559,1],"ix":4},"o":{"a":0,"k":100,"ix":5},"r":1,"bm":0,"nm":"Fill 1","mn":"ADBE Vector Graphic - Fill","hd":false},{"ty":"tr","p":{"a":0,"k":[0,0],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[100,100],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"Transform"}],"nm":"Rectangle 12322","np":2,"cix":2,"bm":0,"ix":1,"mn":"ADBE Vector Group","hd":false},{"ty":"tr","p":{"a":0,"k":[285.75,81.168],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[100,100],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"Transform"}],"nm":"right rect - 2","np":1,"cix":2,"bm":0,"ix":2,"mn":"ADBE Vector Group","hd":false}],"ip":0,"op":300,"st":0,"ct":1,"bm":0},{"ddd":0,"ind":5,"ty":4,"nm":".blue600","cl":"blue600","sr":1,"ks":{"o":{"a":0,"k":100,"ix":11},"r":{"a":0,"k":0,"ix":10},"p":{"a":0,"k":[340.75,223.168,0],"ix":2,"l":2},"a":{"a":0,"k":[0,0,0],"ix":1,"l":2},"s":{"a":0,"k":[100,100,100],"ix":6,"l":2}},"ao":0,"shapes":[{"ty":"gr","it":[{"ind":0,"ty":"sh","ix":1,"ks":{"a":0,"k":{"i":[[-6.627,0],[0,6.627],[6.627,0],[0,-6.627]],"o":[[6.627,0],[0,-6.627],[-6.627,0],[0,6.627]],"v":[[0,12],[12,0],[0,-12],[-12,0]],"c":true},"ix":2},"nm":"Path 1","mn":"ADBE Vector Shape - Group","hd":false},{"ty":"fl","c":{"a":0,"k":[0.101960785687,0.450980395079,0.909803926945,1],"ix":4},"o":{"a":0,"k":100,"ix":5},"r":1,"bm":0,"nm":"Fill 1","mn":"ADBE Vector Graphic - Fill","hd":false},{"ty":"tr","p":{"a":0,"k":[0,0],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[100,100],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"Transform"}],"nm":"Vector","np":2,"cix":2,"bm":0,"ix":1,"mn":"ADBE Vector Group","hd":false}],"ip":0,"op":300,"st":0,"ct":1,"bm":0}],"markers":[]} \ No newline at end of file diff --git a/res/values/strings.xml b/res/values/strings.xml index 63cbfb26409..fb383ba6e68 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -9414,6 +9414,12 @@ When work profile is locked + + Show only new notifications on lock screen + + + After each unlock, remove existing notifications from the lock screen Notifications on lock screen diff --git a/res/xml/configure_notification_settings.xml b/res/xml/configure_notification_settings.xml index 96a3f85a46a..27d5760992c 100644 --- a/res/xml/configure_notification_settings.xml +++ b/res/xml/configure_notification_settings.xml @@ -119,9 +119,16 @@ android:fragment="com.android.settings.notification.zen.ZenModeSettings" settings:controller="com.android.settings.notification.zen.ZenModePreferenceController" /> + diff --git a/src/com/android/settings/accessibility/DisplaySizeData.java b/src/com/android/settings/accessibility/DisplaySizeData.java index 42a8c4678c8..77ae8977085 100644 --- a/src/com/android/settings/accessibility/DisplaySizeData.java +++ b/src/com/android/settings/accessibility/DisplaySizeData.java @@ -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 { + 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 { 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 { 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); } } } diff --git a/src/com/android/settings/biometrics/fingerprint/FingerprintEnrollEnrolling.java b/src/com/android/settings/biometrics/fingerprint/FingerprintEnrollEnrolling.java index e044ab0ada7..0b30f879bc6 100644 --- a/src/com/android/settings/biometrics/fingerprint/FingerprintEnrollEnrolling.java +++ b/src/com/android/settings/biometrics/fingerprint/FingerprintEnrollEnrolling.java @@ -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; } diff --git a/src/com/android/settings/display/ScreenResolutionFragment.java b/src/com/android/settings/display/ScreenResolutionFragment.java index 7c4b3aeef03..9a615951dd7 100644 --- a/src/com/android/settings/display/ScreenResolutionFragment.java +++ b/src/com/android/settings/display/ScreenResolutionFragment.java @@ -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; } diff --git a/src/com/android/settings/display/ScreenZoomPreference.java b/src/com/android/settings/display/ScreenZoomPreference.java index f47d7da4384..af77a0edb98 100644 --- a/src/com/android/settings/display/ScreenZoomPreference.java +++ b/src/com/android/settings/display/ScreenZoomPreference.java @@ -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]); } } diff --git a/src/com/android/settings/display/ScreenZoomSettings.java b/src/com/android/settings/display/ScreenZoomSettings.java index 4c46f018937..ac10664f45e 100644 --- a/src/com/android/settings/display/ScreenZoomSettings.java +++ b/src/com/android/settings/display/ScreenZoomSettings.java @@ -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); } } diff --git a/src/com/android/settings/notification/ShowOnlyUnseenNotificationsOnLockscreenPreferenceController.java b/src/com/android/settings/notification/ShowOnlyUnseenNotificationsOnLockscreenPreferenceController.java new file mode 100644 index 00000000000..a37e29d2347 --- /dev/null +++ b/src/com/android/settings/notification/ShowOnlyUnseenNotificationsOnLockscreenPreferenceController.java @@ -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; + } +} diff --git a/tests/robotests/src/com/android/settings/notification/ShowOnlyUnseenNotificationsOnLockscreenPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/notification/ShowOnlyUnseenNotificationsOnLockscreenPreferenceControllerTest.java new file mode 100644 index 00000000000..cc26e542dc4 --- /dev/null +++ b/tests/robotests/src/com/android/settings/notification/ShowOnlyUnseenNotificationsOnLockscreenPreferenceControllerTest.java @@ -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); + } +}