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
This commit is contained in:
Hendrik Hagendorn
2017-01-15 08:45:51 +01:00
committed by Bruno Martins
parent 70f6d6b61e
commit 5ded0fcf6c
4 changed files with 48 additions and 17 deletions

View File

@@ -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
*/

View File

@@ -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>

View File

@@ -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!
}

View File

@@ -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 %