Merge "[DO NOT MERGE] Add setting for power menu in lock screen privacy" into rvc-dev
diff --git a/api/test-current.txt b/api/test-current.txt
index d8db1b9..96cefe1 100644
--- a/api/test-current.txt
+++ b/api/test-current.txt
@@ -3087,6 +3087,7 @@
     field public static final String LOCK_SCREEN_SHOW_NOTIFICATIONS = "lock_screen_show_notifications";
     field public static final String NFC_PAYMENT_DEFAULT_COMPONENT = "nfc_payment_default_component";
     field public static final String NOTIFICATION_BADGING = "notification_badging";
+    field public static final String POWER_MENU_LOCKED_SHOW_CONTENT = "power_menu_locked_show_content";
     field @RequiresPermission(android.Manifest.permission.WRITE_SECURE_SETTINGS) public static final String SYNC_PARENT_SOUNDS = "sync_parent_sounds";
     field public static final String USER_SETUP_COMPLETE = "user_setup_complete";
     field public static final String VOICE_INTERACTION_SERVICE = "voice_interaction_service";
diff --git a/core/java/android/provider/Settings.java b/core/java/android/provider/Settings.java
index fe340c4..ac1998a 100755
--- a/core/java/android/provider/Settings.java
+++ b/core/java/android/provider/Settings.java
@@ -8607,6 +8607,16 @@
         public static final String CONTROLS_ENABLED = "controls_enabled";
 
         /**
+         * Whether power menu content (cards, passes, controls) will be shown when device is locked.
+         *
+         * 0 indicates hide and 1 indicates show. A non existent value will be treated as hide.
+         * @hide
+         */
+        @TestApi
+        public static final String POWER_MENU_LOCKED_SHOW_CONTENT =
+                "power_menu_locked_show_content";
+
+        /**
          * Specifies whether the web action API is enabled.
          *
          * @hide
diff --git a/core/proto/android/providers/settings/secure.proto b/core/proto/android/providers/settings/secure.proto
index 075aa97..fe8a0f1 100644
--- a/core/proto/android/providers/settings/secure.proto
+++ b/core/proto/android/providers/settings/secure.proto
@@ -397,6 +397,13 @@
     }
     optional ParentalControl parental_control = 43;
 
+    message PowerMenuPrivacy {
+        option (android.msg_privacy).dest = DEST_EXPLICIT;
+
+        optional SettingProto show = 1 [ (android.privacy).dest = DEST_AUTOMATIC ];
+    }
+    optional PowerMenuPrivacy power_menu_privacy = 81;
+
     message PrintService {
         option (android.msg_privacy).dest = DEST_EXPLICIT;
 
@@ -588,5 +595,5 @@
 
     // Please insert fields in alphabetical order and group them into messages
     // if possible (to avoid reaching the method limit).
-    // Next tag = 80;
+    // Next tag = 82;
 }
diff --git a/packages/SettingsProvider/src/android/provider/settings/backup/SecureSettings.java b/packages/SettingsProvider/src/android/provider/settings/backup/SecureSettings.java
index 736e995..c04a1ba 100644
--- a/packages/SettingsProvider/src/android/provider/settings/backup/SecureSettings.java
+++ b/packages/SettingsProvider/src/android/provider/settings/backup/SecureSettings.java
@@ -97,6 +97,7 @@
         Settings.Secure.SYSTEM_NAVIGATION_KEYS_ENABLED,
         Settings.Secure.QS_TILES,
         Settings.Secure.CONTROLS_ENABLED,
+        Settings.Secure.POWER_MENU_LOCKED_SHOW_CONTENT,
         Settings.Secure.DOZE_ENABLED,
         Settings.Secure.DOZE_ALWAYS_ON,
         Settings.Secure.DOZE_PICK_UP_GESTURE,
diff --git a/packages/SettingsProvider/src/android/provider/settings/validators/SecureSettingsValidators.java b/packages/SettingsProvider/src/android/provider/settings/validators/SecureSettingsValidators.java
index b413e8e..76746e5 100644
--- a/packages/SettingsProvider/src/android/provider/settings/validators/SecureSettingsValidators.java
+++ b/packages/SettingsProvider/src/android/provider/settings/validators/SecureSettingsValidators.java
@@ -142,6 +142,7 @@
         VALIDATORS.put(Secure.SYSTEM_NAVIGATION_KEYS_ENABLED, BOOLEAN_VALIDATOR);
         VALIDATORS.put(Secure.QS_TILES, TILE_LIST_VALIDATOR);
         VALIDATORS.put(Secure.CONTROLS_ENABLED, BOOLEAN_VALIDATOR);
+        VALIDATORS.put(Secure.POWER_MENU_LOCKED_SHOW_CONTENT, BOOLEAN_VALIDATOR);
         VALIDATORS.put(Secure.DOZE_ENABLED, BOOLEAN_VALIDATOR);
         VALIDATORS.put(Secure.DOZE_ALWAYS_ON, BOOLEAN_VALIDATOR);
         VALIDATORS.put(Secure.DOZE_PICK_UP_GESTURE, BOOLEAN_VALIDATOR);
diff --git a/packages/SettingsProvider/src/com/android/providers/settings/SettingsProtoDumpUtil.java b/packages/SettingsProvider/src/com/android/providers/settings/SettingsProtoDumpUtil.java
index 8a7b913..a5dce6d 100644
--- a/packages/SettingsProvider/src/com/android/providers/settings/SettingsProtoDumpUtil.java
+++ b/packages/SettingsProvider/src/com/android/providers/settings/SettingsProtoDumpUtil.java
@@ -2278,6 +2278,12 @@
                 SecureSettingsProto.ParentalControl.REDIRECT_URL);
         p.end(parentalControlToken);
 
+        final long powerMenuPrivacyToken = p.start(SecureSettingsProto.POWER_MENU_PRIVACY);
+        dumpSetting(s, p,
+                Settings.Secure.POWER_MENU_LOCKED_SHOW_CONTENT,
+                SecureSettingsProto.PowerMenuPrivacy.SHOW);
+        p.end(powerMenuPrivacyToken);
+
         final long printServiceToken = p.start(SecureSettingsProto.PRINT_SERVICE);
         dumpSetting(s, p,
                 Settings.Secure.PRINT_SERVICE_SEARCH_URI,
diff --git a/packages/SettingsProvider/src/com/android/providers/settings/SettingsProvider.java b/packages/SettingsProvider/src/com/android/providers/settings/SettingsProvider.java
index d3d04e5..74eee63 100644
--- a/packages/SettingsProvider/src/com/android/providers/settings/SettingsProvider.java
+++ b/packages/SettingsProvider/src/com/android/providers/settings/SettingsProvider.java
@@ -3437,7 +3437,7 @@
         }
 
         private final class UpgradeController {
-            private static final int SETTINGS_VERSION = 189;
+            private static final int SETTINGS_VERSION = 190;
 
             private final int mUserId;
 
@@ -4777,6 +4777,28 @@
                     currentVersion = 189;
                 }
 
+                if (currentVersion == 189) {
+                    final SettingsState secureSettings = getSecureSettingsLocked(userId);
+                    final Setting showNotifications = secureSettings.getSettingLocked(
+                            Secure.LOCK_SCREEN_SHOW_NOTIFICATIONS);
+                    final Setting allowPrivateNotifications = secureSettings.getSettingLocked(
+                            Secure.LOCK_SCREEN_ALLOW_PRIVATE_NOTIFICATIONS);
+                    if ("1".equals(showNotifications.getValue())
+                            && "1".equals(allowPrivateNotifications.getValue())) {
+                        secureSettings.insertSettingLocked(
+                                Secure.POWER_MENU_LOCKED_SHOW_CONTENT,
+                                "1", null /* tag */, false /* makeDefault */,
+                                SettingsState.SYSTEM_PACKAGE_NAME);
+                    } else if ("0".equals(showNotifications.getValue())
+                            || "0".equals(allowPrivateNotifications.getValue())) {
+                        secureSettings.insertSettingLocked(
+                                Secure.POWER_MENU_LOCKED_SHOW_CONTENT,
+                                "0", null /* tag */, false /* makeDefault */,
+                                SettingsState.SYSTEM_PACKAGE_NAME);
+                    }
+                    currentVersion = 190;
+                }
+
                 // vXXX: Add new settings above this point.
 
                 if (currentVersion != newVersion) {