CMSettings: Move Global settings to CMSettings

Change-Id: Ib054409d5ad790e011e12ecbc6786bf3562a1b80
This commit is contained in:
d34d 2015-11-12 13:04:42 -08:00 committed by Danesh M
parent e3950819b3
commit b59538ccd0
4 changed files with 139 additions and 0 deletions

View File

@ -54,4 +54,12 @@
1==on -->
<integer name="def_heads_up_enabled">1</integer>
<!-- Default for CMSettings.Global.POWER_NOTIFICATIONS_ENABLED -->
<bool name="def_power_notifications_enabled">false</bool>
<!-- Default for CMSettings.Global.POWER_NOTIFICATIONS_VIBRATE -->
<bool name="def_power_notifications_vibrate">false</bool>
<!-- Default for CMSettings.Global.POWER_NOTIFICATIONS_RINGTONE -->
<string name="def_power_notifications_ringtone" translatable="false">content://settings/system/notification_sound</string>
</resources>

View File

@ -228,6 +228,18 @@ public class CMDatabaseHelper extends SQLiteOpenHelper{
loadBooleanSetting(db, CMTableNames.TABLE_SECURE, CMSettings.Secure.STATS_COLLECTION,
R.bool.def_stats_collection);
loadBooleanSetting(db, CMTableNames.TABLE_GLOBAL,
CMSettings.Global.POWER_NOTIFICATIONS_ENABLED,
R.bool.def_power_notifications_enabled);
loadBooleanSetting(db, CMTableNames.TABLE_GLOBAL,
CMSettings.Global.POWER_NOTIFICATIONS_VIBRATE,
R.bool.def_power_notifications_vibrate);
loadStringSetting(db, CMTableNames.TABLE_GLOBAL,
CMSettings.Global.POWER_NOTIFICATIONS_RINGTONE,
R.string.def_power_notifications_ringtone);
}
/**

View File

@ -887,6 +887,54 @@ public class CMSettingsProvider extends ContentProvider {
*/
public static final String NOTIFICATION_LIGHT_PULSE_CUSTOM_VALUES =
CMSettings.System.NOTIFICATION_LIGHT_PULSE_CUSTOM_VALUES;
/**
* Whether to wake the display when plugging or unplugging the charger
*
* @hide
*/
public static final String WAKE_WHEN_PLUGGED_OR_UNPLUGGED =
CMSettings.Global.WAKE_WHEN_PLUGGED_OR_UNPLUGGED;
/** {@hide} */
public static final String BLUETOOTH_A2DP_SRC_PRIORITY_PREFIX =
CMSettings.Global.BLUETOOTH_A2DP_SRC_PRIORITY_PREFIX;
/**
* Whether to sound when charger power is connected/disconnected
* @hide
*/
public static final String POWER_NOTIFICATIONS_ENABLED =
CMSettings.Global.POWER_NOTIFICATIONS_ENABLED;
/**
* Whether to vibrate when charger power is connected/disconnected
* @hide
*/
public static final String POWER_NOTIFICATIONS_VIBRATE =
CMSettings.Global.POWER_NOTIFICATIONS_VIBRATE;
/**
* URI for power notification sounds
* @hide
*/
public static final String POWER_NOTIFICATIONS_RINGTONE =
CMSettings.Global.POWER_NOTIFICATIONS_RINGTONE;
/**
* @hide
*/
public static final String ZEN_DISABLE_DUCKING_DURING_MEDIA_PLAYBACK =
CMSettings.Global.ZEN_DISABLE_DUCKING_DURING_MEDIA_PLAYBACK;
/**
* Whether the system auto-configure the priority of the wifi ap's or use
* the manual settings established by the user.
* <> 0 to autoconfigure, 0 to manual settings. Default is <> 0.
* @hide
*/
public static final String WIFI_AUTO_PRIORITIES_CONFIGURATION =
CMSettings.Global.WIFI_AUTO_PRIORITIES_CONFIGURATION;
}
/**
@ -1118,6 +1166,27 @@ public class CMSettingsProvider extends ContentProvider {
rowsMigrated = migrateCMSettingsForTable(userId,
CMDatabaseHelper.CMTableNames.TABLE_SECURE, secureToCmSettingsMap);
if (LOCAL_LOGV) Log.d(TAG, "Migrated " + rowsMigrated + " to CM secure table");
// Migrate global settings
HashMap<String, String> globalToCmSettingsMap = new HashMap<String, String>();
globalToCmSettingsMap.put(LegacyCMSettings.WAKE_WHEN_PLUGGED_OR_UNPLUGGED,
CMSettings.Global.WAKE_WHEN_PLUGGED_OR_UNPLUGGED);
globalToCmSettingsMap.put(LegacyCMSettings.BLUETOOTH_A2DP_SRC_PRIORITY_PREFIX,
CMSettings.Global.BLUETOOTH_A2DP_SRC_PRIORITY_PREFIX);
globalToCmSettingsMap.put(LegacyCMSettings.POWER_NOTIFICATIONS_ENABLED,
CMSettings.Global.POWER_NOTIFICATIONS_ENABLED);
globalToCmSettingsMap.put(LegacyCMSettings.POWER_NOTIFICATIONS_VIBRATE,
CMSettings.Global.POWER_NOTIFICATIONS_VIBRATE);
globalToCmSettingsMap.put(LegacyCMSettings.POWER_NOTIFICATIONS_RINGTONE,
CMSettings.Global.POWER_NOTIFICATIONS_RINGTONE);
globalToCmSettingsMap.put(LegacyCMSettings.ZEN_DISABLE_DUCKING_DURING_MEDIA_PLAYBACK,
CMSettings.Global.ZEN_DISABLE_DUCKING_DURING_MEDIA_PLAYBACK);
globalToCmSettingsMap.put(LegacyCMSettings.WIFI_AUTO_PRIORITIES_CONFIGURATION,
CMSettings.Global.WIFI_AUTO_PRIORITIES_CONFIGURATION);
rowsMigrated = migrateCMSettingsForTable(userId,
CMDatabaseHelper.CMTableNames.TABLE_GLOBAL, globalToCmSettingsMap);
if (LOCAL_LOGV) Log.d(TAG, "Migrated " + rowsMigrated + " to CM global table");
}
}

View File

@ -32,6 +32,7 @@ import android.util.Log;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Locale;
import java.util.regex.Pattern;
/**
@ -2223,10 +2224,59 @@ public final class CMSettings {
return putStringForUser(cr, name, Float.toString(value), userId);
}
/**
* Get the key that retrieves a bluetooth a2dp src's priority.
* @hide
*/
public static final String getBluetoothA2dpSrcPriorityKey(String address) {
return BLUETOOTH_A2DP_SRC_PRIORITY_PREFIX + address.toUpperCase(Locale.ROOT);
}
// endregion
// region Global Settings
/**
* Whether to wake the display when plugging or unplugging the charger
*
* @hide
*/
public static final String WAKE_WHEN_PLUGGED_OR_UNPLUGGED =
"wake_when_plugged_or_unplugged";
/** {@hide} */
public static final String
BLUETOOTH_A2DP_SRC_PRIORITY_PREFIX = "bluetooth_a2dp_src_priority_";
/**
* Whether to sound when charger power is connected/disconnected
* @hide
*/
public static final String POWER_NOTIFICATIONS_ENABLED = "power_notifications_enabled";
/**
* Whether to vibrate when charger power is connected/disconnected
* @hide
*/
public static final String POWER_NOTIFICATIONS_VIBRATE = "power_notifications_vibrate";
/**
* URI for power notification sounds
* @hide
*/
public static final String POWER_NOTIFICATIONS_RINGTONE = "power_notifications_ringtone";
/**
* @hide
*/
public static final String ZEN_DISABLE_DUCKING_DURING_MEDIA_PLAYBACK =
"zen_disable_ducking_during_media_playback";
/**
* Whether the system auto-configure the priority of the wifi ap's or use
* the manual settings established by the user.
* <> 0 to autoconfigure, 0 to manual settings. Default is <> 0.
* @hide
*/
public static final String WIFI_AUTO_PRIORITIES_CONFIGURATION = "wifi_auto_priority";
// endregion
}
}