diff options
author | Hendrik Hagendorn <finnq@lineageos.org> | 2017-01-15 08:45:51 +0100 |
---|---|---|
committer | Bruno Martins <bgcngm@gmail.com> | 2019-06-02 22:27:30 +0100 |
commit | 5ded0fcf6c14caab00f00f62e50ac4acd028802a (patch) | |
tree | c1381b8e46ffb28b5931f2bf782bc5d2526b57f7 | |
parent | 70f6d6b61ee17d6fd0310b17fd6aaacbb3272de2 (diff) | |
download | lineage-sdk-5ded0fcf6c14caab00f00f62e50ac4acd028802a.tar.gz lineage-sdk-5ded0fcf6c14caab00f00f62e50ac4acd028802a.tar.bz2 lineage-sdk-5ded0fcf6c14caab00f00f62e50ac4acd028802a.zip |
sdk: Update for refactored battery icon options
* Handle the migration for old settings and default
to Android's stock battery style.
* Hiding battery icon is now achieved using icon blacklist
via system tuner settings.
Change-Id: Ie41d71c774a34abe225e2c0a6a0a9fd4316189cd
4 files changed, 48 insertions, 17 deletions
diff --git a/host/migration/src/LineageSettings.java b/host/migration/src/LineageSettings.java index dabe8344..13540967 100644 --- a/host/migration/src/LineageSettings.java +++ b/host/migration/src/LineageSettings.java @@ -80,10 +80,8 @@ public final class LineageSettings { /** * Display style of the status bar battery information * 0: Display the battery an icon in portrait mode - * 2: Display the battery as a circle - * 4: Hide the battery status information - * 5: Display the battery an icon in landscape mode - * 6: Display the battery as plain text + * 1: Display the battery as a circle + * 2: Display the battery as plain text * default: 0 * @hide */ diff --git a/packages/LineageSettingsProvider/res/values/defaults.xml b/packages/LineageSettingsProvider/res/values/defaults.xml index 3a23f523..8c993720 100644 --- a/packages/LineageSettingsProvider/res/values/defaults.xml +++ b/packages/LineageSettingsProvider/res/values/defaults.xml @@ -1,6 +1,7 @@ <?xml version="1.0" encoding="utf-8"?> <!-- Copyright (C) 2014-2015 The CyanogenMod Project + 2019 The LineageOS Project Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -36,13 +37,10 @@ <!-- Default for LineageSettings.System.STATUS_BAR_BATTERY_STYLE * 0: Display the battery as icon in portrait mode - * 2: Display the battery as a circle - * 4: Hide the battery status information - * 5: Display the battery as icon in landscape mode - * 6: Display the battery as plain text - * default: 2 - --> - <integer name="def_battery_style">2</integer> + * 1: Display the battery as a circle + * 2: Display the battery as plain text + --> + <integer name="def_battery_style">0</integer> <!-- Default for LineageSettings.Secure.LOCKSCREEN_VISUALIZER_ENABLED --> <bool name="def_lockscreen_visualizer">true</bool> diff --git a/packages/LineageSettingsProvider/src/org/lineageos/lineagesettings/LineageDatabaseHelper.java b/packages/LineageSettingsProvider/src/org/lineageos/lineagesettings/LineageDatabaseHelper.java index b4563276..670b402f 100644 --- a/packages/LineageSettingsProvider/src/org/lineageos/lineagesettings/LineageDatabaseHelper.java +++ b/packages/LineageSettingsProvider/src/org/lineageos/lineagesettings/LineageDatabaseHelper.java @@ -51,7 +51,7 @@ public class LineageDatabaseHelper extends SQLiteOpenHelper{ private static final boolean LOCAL_LOGV = false; private static final String DATABASE_NAME = "lineagesettings.db"; - private static final int DATABASE_VERSION = 11; + private static final int DATABASE_VERSION = 12; private static final String DATABASE_NAME_OLD = "cmsettings.db"; @@ -392,6 +392,43 @@ public class LineageDatabaseHelper extends SQLiteOpenHelper{ } upgradeVersion = 11; } + + if (upgradeVersion < 12) { + if (mUserHandle == UserHandle.USER_OWNER) { + db.beginTransaction(); + SQLiteStatement stmt = null; + try { + stmt = db.compileStatement("SELECT value FROM system WHERE name=?"); + stmt.bindString(1, LineageSettings.System.STATUS_BAR_BATTERY_STYLE); + long value = stmt.simpleQueryForLong(); + + long newValue = 0; + switch ((int) value) { + case 2: + newValue = 1; + break; + case 5: + newValue = 0; + break; + case 6: + newValue = 2; + break; + } + + stmt = db.compileStatement("UPDATE system SET value=? WHERE name=?"); + stmt.bindLong(1, newValue); + stmt.bindString(2, LineageSettings.System.STATUS_BAR_BATTERY_STYLE); + stmt.execute(); + db.setTransactionSuccessful(); + } catch (SQLiteDoneException ex) { + // LineageSettings.System.STATUS_BAR_BATTERY_STYLE is not set + } finally { + if (stmt != null) stmt.close(); + db.endTransaction(); + } + } + upgradeVersion = 12; + } // *** Remember to update DATABASE_VERSION above! } diff --git a/sdk/src/java/lineageos/providers/LineageSettings.java b/sdk/src/java/lineageos/providers/LineageSettings.java index 9d121024..e7336fa5 100644 --- a/sdk/src/java/lineageos/providers/LineageSettings.java +++ b/sdk/src/java/lineageos/providers/LineageSettings.java @@ -923,17 +923,15 @@ public final class LineageSettings { /** * Display style of the status bar battery information * 0: Display the battery an icon in portrait mode - * 2: Display the battery as a circle - * 4: Hide the battery status information - * 5: Display the battery an icon in landscape mode - * 6: Display the battery as plain text + * 1: Display the battery as a circle + * 2: Display the battery as plain text * default: 0 */ public static final String STATUS_BAR_BATTERY_STYLE = "status_bar_battery_style"; /** @hide */ public static final Validator STATUS_BAR_BATTERY_STYLE_VALIDATOR = - new DiscreteValueValidator(new String[] {"0", "2", "4", "5", "6"}); + new InclusiveIntegerRangeValidator(0, 2); /** * Status bar battery % |