From 13375e5f44bac2d66cab6111339c1c5a95869d9d Mon Sep 17 00:00:00 2001 From: Hugh Chen Date: Fri, 5 Nov 2021 09:22:13 +0000 Subject: [PATCH 1/5] Fix phone shows incorrect pairing code in pairing dialog Add PendingIntent.FLAG_UPDATE_CURRENT to let peding intent can be updated the intent extra. Bug: 204133175 Test: make -j64 RunSettingsRoboTests Change-Id: I42966432dacc3727d31231d10aa07b782bb1d92e --- .../android/settings/bluetooth/BluetoothPairingService.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/com/android/settings/bluetooth/BluetoothPairingService.java b/src/com/android/settings/bluetooth/BluetoothPairingService.java index 4c3c9a9be94..bc5dc6695d1 100644 --- a/src/com/android/settings/bluetooth/BluetoothPairingService.java +++ b/src/com/android/settings/bluetooth/BluetoothPairingService.java @@ -188,7 +188,8 @@ public final class BluetoothPairingService extends Service { } PendingIntent pairIntent = PendingIntent.getService(this, 0, pairingDialogIntent, - PendingIntent.FLAG_ONE_SHOT | PendingIntent.FLAG_IMMUTABLE); + PendingIntent.FLAG_ONE_SHOT | PendingIntent.FLAG_UPDATE_CURRENT + | PendingIntent.FLAG_IMMUTABLE); Intent serviceIntent = new Intent(ACTION_DISMISS_PAIRING); serviceIntent.setClass(this, BluetoothPairingService.class); From 42896d7fe195531aec68111de021e7e1f307c186 Mon Sep 17 00:00:00 2001 From: Julia Reynolds Date: Fri, 5 Nov 2021 14:06:10 -0400 Subject: [PATCH 2/5] Check if pref is disabled by admin Test: robotests Fixes: 137638270 Change-Id: I39953d5b7466281cff7a9a7ffaeb5ba99ab12934 --- .../RedactNotificationPreferenceController.java | 3 ++- .../RedactNotificationPreferenceControllerTest.java | 12 ++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/com/android/settings/notification/RedactNotificationPreferenceController.java b/src/com/android/settings/notification/RedactNotificationPreferenceController.java index db34e5e960a..2d2718478c2 100644 --- a/src/com/android/settings/notification/RedactNotificationPreferenceController.java +++ b/src/com/android/settings/notification/RedactNotificationPreferenceController.java @@ -178,7 +178,8 @@ public class RedactNotificationPreferenceController extends TogglePreferenceCont private boolean getAllowPrivateNotifications(int userId) { return Settings.Secure.getIntForUser(mContext.getContentResolver(), - LOCK_SCREEN_ALLOW_PRIVATE_NOTIFICATIONS, 1, userId) != 0; + LOCK_SCREEN_ALLOW_PRIVATE_NOTIFICATIONS, 1, userId) != 0 + && getEnforcedAdmin(userId) == null; } private boolean getLockscreenNotificationsEnabled(int userId) { diff --git a/tests/robotests/src/com/android/settings/notification/RedactNotificationPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/notification/RedactNotificationPreferenceControllerTest.java index ae25474f81b..72a2c2451ee 100644 --- a/tests/robotests/src/com/android/settings/notification/RedactNotificationPreferenceControllerTest.java +++ b/tests/robotests/src/com/android/settings/notification/RedactNotificationPreferenceControllerTest.java @@ -292,6 +292,18 @@ public class RedactNotificationPreferenceControllerTest { assertThat(mWorkController.isChecked()).isFalse(); } + @Test + public void isChecked_admin() { + Settings.Secure.putIntForUser(mContext.getContentResolver(), + LOCK_SCREEN_ALLOW_PRIVATE_NOTIFICATIONS, + 1, 0); + + ShadowRestrictedLockUtilsInternal.setKeyguardDisabledFeatures( + KEYGUARD_DISABLE_SECURE_NOTIFICATIONS); + + assertThat(mController.isChecked()).isFalse(); + } + @Test public void setChecked_false() throws Exception { Settings.Secure.putIntForUser(mContext.getContentResolver(), From 98cc4f1302f9eb438abd1be650999012f06a51ad Mon Sep 17 00:00:00 2001 From: Julia Reynolds Date: Fri, 5 Nov 2021 14:37:20 -0400 Subject: [PATCH 3/5] Some updates for better localization Test: manual Fixes: 190021494 Fixes: 185203196 Fixes: 190088372 Change-Id: Ia2871814870a1f0e5c5f2deed06dcbef7b2bd967 --- res/values/strings.xml | 8 ++++++-- .../ShowOnLockScreenNotificationPreferenceController.java | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/res/values/strings.xml b/res/values/strings.xml index aa484835065..949b6758d94 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -9073,6 +9073,10 @@ Notifications on lock screen + + Show conversations, default, and silent + Show conversations, default, and silent @@ -9324,11 +9328,11 @@ ~%d notification per day - ~%d notifications per day + ~%,d notifications per day ~%d notification per week - ~%d notifications per week + ~%,d notifications per week Never diff --git a/src/com/android/settings/notification/ShowOnLockScreenNotificationPreferenceController.java b/src/com/android/settings/notification/ShowOnLockScreenNotificationPreferenceController.java index f8f76caecbd..f7dc3913775 100644 --- a/src/com/android/settings/notification/ShowOnLockScreenNotificationPreferenceController.java +++ b/src/com/android/settings/notification/ShowOnLockScreenNotificationPreferenceController.java @@ -116,7 +116,7 @@ public class ShowOnLockScreenNotificationPreferenceController extends AbstractPr } else if (!getLockscreenSilentNotificationsEnabled()) { return mContext.getString(R.string.lock_screen_notifs_show_alerting); } else { - return mContext.getString(R.string.lock_screen_notifs_show_all); + return mContext.getString(R.string.lock_screen_notifs_show_all_summary); } } From dc816116c5fa7fc4e74682de7e4d42cf3c791004 Mon Sep 17 00:00:00 2001 From: Ahaan Ugale Date: Sun, 7 Nov 2021 22:59:50 -0800 Subject: [PATCH 4/5] AF passwords settings: Start activity as new task. Settings app has a new 2-pane layout for larger screens. Activities that belong to other apps must now be started as a new task. Fix: 197702325 Test: manual Change-Id: Iaf800b7f9e6bf5d925047fed49d848f4d3973df7 --- .../applications/autofill/PasswordsPreferenceController.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/com/android/settings/applications/autofill/PasswordsPreferenceController.java b/src/com/android/settings/applications/autofill/PasswordsPreferenceController.java index 1d67fb7539d..cb8b73d2896 100644 --- a/src/com/android/settings/applications/autofill/PasswordsPreferenceController.java +++ b/src/com/android/settings/applications/autofill/PasswordsPreferenceController.java @@ -16,6 +16,7 @@ package com.android.settings.applications.autofill; +import static android.content.Intent.FLAG_ACTIVITY_NEW_TASK; import static android.service.autofill.AutofillService.EXTRA_RESULT; import static androidx.lifecycle.Lifecycle.Event.ON_CREATE; @@ -133,7 +134,8 @@ public class PasswordsPreferenceController extends BasePreferenceController new Intent(Intent.ACTION_MAIN) .setClassName( serviceInfo.packageName, - service.getPasswordsActivity()); + service.getPasswordsActivity()) + .setFlags(FLAG_ACTIVITY_NEW_TASK); prefContext.startActivityAsUser(intent, UserHandle.of(user)); return true; }); From dc18e85e411063d0188da93d2a7e63da3ffa4b02 Mon Sep 17 00:00:00 2001 From: Julia Reynolds Date: Fri, 5 Nov 2021 14:17:43 -0400 Subject: [PATCH 5/5] Fix broken tests Remove group conditions - we don't have a group page and so don't need to test what its header would be Test: this Fixes: 201021319 Change-Id: I22049bc7ea2153a574ed5aa5428a5dfb295447a5 --- .../notification/app/HeaderPreferenceControllerTest.java | 7 ------- 1 file changed, 7 deletions(-) diff --git a/tests/robotests/src/com/android/settings/notification/app/HeaderPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/notification/app/HeaderPreferenceControllerTest.java index a8628c42c47..c7c21a7f3d2 100644 --- a/tests/robotests/src/com/android/settings/notification/app/HeaderPreferenceControllerTest.java +++ b/tests/robotests/src/com/android/settings/notification/app/HeaderPreferenceControllerTest.java @@ -40,7 +40,6 @@ import com.android.settings.notification.NotificationBackend; import com.android.settingslib.widget.LayoutPreference; import org.junit.Before; -import org.junit.Ignore; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Mock; @@ -132,7 +131,6 @@ public class HeaderPreferenceControllerTest { } @Test - @Ignore public void testGetSummary() { NotificationBackend.AppRow appRow = new NotificationBackend.AppRow(); appRow.label = "bananas"; @@ -140,8 +138,6 @@ public class HeaderPreferenceControllerTest { assertEquals("", mController.getSummary()); NotificationChannelGroup group = new NotificationChannelGroup("id", "name"); - mController.onResume(appRow, null, group, null, null, null, null); - assertEquals(appRow.label, mController.getSummary()); NotificationChannel channel = new NotificationChannel("cid", "cname", IMPORTANCE_NONE); mController.onResume(appRow, channel, group, null, null, null, null); @@ -159,7 +155,6 @@ public class HeaderPreferenceControllerTest { } @Test - @Ignore public void testGetSecondSummary() { NotificationBackend.AppRow appRow = new NotificationBackend.AppRow(); appRow.label = "bananas"; @@ -167,8 +162,6 @@ public class HeaderPreferenceControllerTest { assertEquals("", mController.getSecondSummary()); NotificationChannelGroup group = new NotificationChannelGroup("id", "name"); - mController.onResume(appRow, null, group, null, null, null, null); - assertEquals("", mController.getSecondSummary()); NotificationChannel channel = new NotificationChannel("cid", "cname", IMPORTANCE_NONE); mController.onResume(appRow, channel, group, null, null, null, null);