diff options
author | Jeff Brown <jeffbrown@google.com> | 2014-09-30 20:54:30 -0700 |
---|---|---|
committer | Jeff Brown <jeffbrown@google.com> | 2014-10-01 15:01:10 -0700 |
commit | 05af6adb8d4fd5ea069c9aead5a877da9085daa8 (patch) | |
tree | cb9331ddd75e62406ef56874bd3f3d01f5ef3bcc /packages/SettingsProvider | |
parent | 496aeb1a6156f3c089135a7ce4fab550589eaff7 (diff) | |
download | frameworks_base-05af6adb8d4fd5ea069c9aead5a877da9085daa8.zip frameworks_base-05af6adb8d4fd5ea069c9aead5a877da9085daa8.tar.gz frameworks_base-05af6adb8d4fd5ea069c9aead5a877da9085daa8.tar.bz2 |
Implement auto-sleep functionality.
Added a new SLEEP_TIMEOUT setting which governs how long the device will
remain awake or dreaming without user activity. By default this
value is set to -1 which maintains today's existing behavior.
We basically represent the time we are allowed to be dreaming as a new
kind of user activity summary state called DREAM, similar to BRIGHT
and DIM. When the sleep timeout expires, the state is cleared and
the dream ends.
Bug: 17665809
Change-Id: I59aa7648dcec215f1285464fc1134934a09230e5
Diffstat (limited to 'packages/SettingsProvider')
-rw-r--r-- | packages/SettingsProvider/res/values/defaults.xml | 1 | ||||
-rw-r--r-- | packages/SettingsProvider/src/com/android/providers/settings/DatabaseHelper.java | 20 |
2 files changed, 20 insertions, 1 deletions
diff --git a/packages/SettingsProvider/res/values/defaults.xml b/packages/SettingsProvider/res/values/defaults.xml index 934ed38..efba03d 100644 --- a/packages/SettingsProvider/res/values/defaults.xml +++ b/packages/SettingsProvider/res/values/defaults.xml @@ -19,6 +19,7 @@ <resources> <bool name="def_dim_screen">true</bool> <integer name="def_screen_off_timeout">60000</integer> + <integer name="def_sleep_timeout">-1</integer> <bool name="def_airplane_mode_on">false</bool> <!-- Comma-separated list of bluetooth, wifi, and cell. --> <string name="def_airplane_mode_radios" translatable="false">cell,bluetooth,wifi,nfc,wimax</string> diff --git a/packages/SettingsProvider/src/com/android/providers/settings/DatabaseHelper.java b/packages/SettingsProvider/src/com/android/providers/settings/DatabaseHelper.java index 873257c..b17b4cc 100644 --- a/packages/SettingsProvider/src/com/android/providers/settings/DatabaseHelper.java +++ b/packages/SettingsProvider/src/com/android/providers/settings/DatabaseHelper.java @@ -70,7 +70,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 = 112; + private static final int DATABASE_VERSION = 113; private Context mContext; private int mUserHandle; @@ -1811,6 +1811,22 @@ public class DatabaseHelper extends SQLiteOpenHelper { upgradeVersion = 112; } + if (upgradeVersion < 113) { + db.beginTransaction(); + SQLiteStatement stmt = null; + try { + stmt = db.compileStatement("INSERT OR IGNORE INTO secure(name,value)" + + " VALUES(?,?);"); + loadIntegerSetting(stmt, Settings.Secure.SLEEP_TIMEOUT, + R.integer.def_sleep_timeout); + db.setTransactionSuccessful(); + } finally { + db.endTransaction(); + if (stmt != null) stmt.close(); + } + upgradeVersion = 113; + } + // *** Remember to update DATABASE_VERSION above! if (upgradeVersion != currentVersion) { @@ -2382,6 +2398,8 @@ public class DatabaseHelper extends SQLiteOpenHelper { loadBooleanSetting(stmt, Secure.LOCK_SCREEN_ALLOW_PRIVATE_NOTIFICATIONS, R.bool.def_lock_screen_allow_private_notifications); + loadIntegerSetting(stmt, Settings.Secure.SLEEP_TIMEOUT, + R.integer.def_sleep_timeout); } finally { if (stmt != null) stmt.close(); } |