OSDN Git Service

Move LOCK_TO_APP_EXIT_LOCKED from System to Secure
authorJason Monk <jmonk@google.com>
Fri, 31 Oct 2014 17:18:21 +0000 (13:18 -0400)
committerJason Monk <jmonk@google.com>
Fri, 31 Oct 2014 18:47:13 +0000 (14:47 -0400)
To prepare for controlling from settings.

While here, add lock to app settings to backups.

Bug: 16957435
Change-Id: I059140cd07a7a0d5ceb4e0bfe5e0176cb96629d3

core/java/android/provider/Settings.java
packages/SettingsProvider/src/com/android/providers/settings/DatabaseHelper.java
services/core/java/com/android/server/am/ActivityStackSupervisor.java
services/core/java/com/android/server/am/LockToAppRequestDialog.java

index 369efac..ca2c223 100644 (file)
@@ -2625,12 +2625,6 @@ public final class Settings {
         public static final String LOCK_TO_APP_ENABLED = "lock_to_app_enabled";
 
         /**
-         * Whether lock-to-app will lock the keyguard when exiting.
-         * @hide
-         */
-        public static final String LOCK_TO_APP_EXIT_LOCKED = "lock_to_app_exit_locked";
-
-        /**
          * I am the lolrus.
          * <p>
          * Nonzero values indicate that the user has a bukkit.
@@ -2704,6 +2698,7 @@ public final class Settings {
             POINTER_SPEED,
             VIBRATE_WHEN_RINGING,
             RINGTONE,
+            LOCK_TO_APP_ENABLED,
             NOTIFICATION_SOUND
         };
 
@@ -3666,6 +3661,12 @@ public final class Settings {
                 "lock_biometric_weak_flags";
 
         /**
+         * Whether lock-to-app will lock the keyguard when exiting.
+         * @hide
+         */
+        public static final String LOCK_TO_APP_EXIT_LOCKED = "lock_to_app_exit_locked";
+
+        /**
          * Whether autolock is enabled (0 = false, 1 = true)
          */
         public static final String LOCK_PATTERN_ENABLED = "lock_pattern_autolock";
index eea97ea..9bfcadb 100644 (file)
@@ -71,7 +71,7 @@ public class DatabaseHelper extends SQLiteOpenHelper {
     // database gets upgraded properly. At a minimum, please confirm that 'upgradeVersion'
     // is properly propagated through your change.  Not doing so will result in a loss of user
     // settings.
-    private static final int DATABASE_VERSION = 116;
+    private static final int DATABASE_VERSION = 117;
 
     private Context mContext;
     private int mUserHandle;
@@ -1865,6 +1865,20 @@ public class DatabaseHelper extends SQLiteOpenHelper {
             upgradeVersion = 116;
         }
 
+        if (upgradeVersion < 117) {
+            db.beginTransaction();
+            try {
+                String[] systemToSecure = {
+                        Settings.Secure.LOCK_TO_APP_EXIT_LOCKED
+                };
+                moveSettingsToNewTable(db, TABLE_SYSTEM, TABLE_SECURE, systemToSecure, true);
+                db.setTransactionSuccessful();
+            } finally {
+                db.endTransaction();
+            }
+            upgradeVersion = 117;
+        }
+
         // *** Remember to update DATABASE_VERSION above!
 
         if (upgradeVersion != currentVersion) {
index c1bf955..dfbdfce 100644 (file)
@@ -3550,9 +3550,9 @@ public final class ActivityStackSupervisor implements DisplayListener {
                         }
                         mLockTaskNotify.show(false);
                         try {
-                            boolean shouldLockKeyguard = Settings.System.getInt(
+                            boolean shouldLockKeyguard = Settings.Secure.getInt(
                                     mService.mContext.getContentResolver(),
-                                    Settings.System.LOCK_TO_APP_EXIT_LOCKED) != 0;
+                                    Settings.Secure.LOCK_TO_APP_EXIT_LOCKED) != 0;
                             if (!mLockTaskIsLocked && shouldLockKeyguard) {
                                 mWindowManager.lockNow(null);
                                 mWindowManager.dismissKeyguard();
index a1eb31e..739fd0a 100644 (file)
@@ -112,8 +112,8 @@ public class LockToAppRequestDialog implements OnClickListener {
 
             // Remember state.
             try {
-                boolean useLock = Settings.System.getInt(mContext.getContentResolver(),
-                        Settings.System.LOCK_TO_APP_EXIT_LOCKED) != 0;
+                boolean useLock = Settings.Secure.getInt(mContext.getContentResolver(),
+                        Settings.Secure.LOCK_TO_APP_EXIT_LOCKED) != 0;
                 mCheckbox.setChecked(useLock);
             } catch (SettingNotFoundException e) {
             }
@@ -127,8 +127,8 @@ public class LockToAppRequestDialog implements OnClickListener {
         if (DialogInterface.BUTTON_POSITIVE == which) {
             Slog.d(TAG, "accept lock-to-app request");
             // Set whether to use the lock screen when exiting.
-            Settings.System.putInt(mContext.getContentResolver(),
-                    Settings.System.LOCK_TO_APP_EXIT_LOCKED,
+            Settings.Secure.putInt(mContext.getContentResolver(),
+                    Settings.Secure.LOCK_TO_APP_EXIT_LOCKED,
                     mCheckbox != null && mCheckbox.isChecked() ? 1 : 0);
 
             // Start lock-to-app.