summaryrefslogtreecommitdiffstats
path: root/packages/SettingsProvider
diff options
context:
space:
mode:
Diffstat (limited to 'packages/SettingsProvider')
-rw-r--r--packages/SettingsProvider/Android.mk2
-rw-r--r--packages/SettingsProvider/res/mipmap-hdpi/ic_launcher_settings.pngbin8822 -> 5946 bytes
-rw-r--r--packages/SettingsProvider/res/mipmap-mdpi/ic_launcher_settings.pngbin5362 -> 3589 bytes
-rw-r--r--packages/SettingsProvider/res/mipmap-xhdpi/ic_launcher_settings.pngbin12096 -> 8605 bytes
-rw-r--r--packages/SettingsProvider/res/mipmap-xxhdpi/ic_launcher_settings.pngbin20300 -> 14731 bytes
-rw-r--r--packages/SettingsProvider/res/mipmap-xxxhdpi/ic_launcher_settings.pngbin27997 -> 21728 bytes
-rw-r--r--packages/SettingsProvider/res/values-ast-rES/strings.xml22
-rw-r--r--packages/SettingsProvider/res/values-be/strings.xml22
-rw-r--r--packages/SettingsProvider/res/values-ku/strings.xml22
-rw-r--r--packages/SettingsProvider/res/values-lb/strings.xml22
-rw-r--r--packages/SettingsProvider/res/values-ug/strings.xml22
-rw-r--r--packages/SettingsProvider/res/values/customize.xml63
-rw-r--r--packages/SettingsProvider/res/values/defaults.xml23
-rw-r--r--packages/SettingsProvider/src/com/android/providers/settings/DatabaseHelper.java308
-rw-r--r--packages/SettingsProvider/src/com/android/providers/settings/SettingsBackupAgent.java41
-rw-r--r--packages/SettingsProvider/src/com/android/providers/settings/SettingsProvider.java235
-rw-r--r--packages/SettingsProvider/src/com/android/providers/settings/SettingsState.java48
17 files changed, 777 insertions, 53 deletions
diff --git a/packages/SettingsProvider/Android.mk b/packages/SettingsProvider/Android.mk
index 2b833b2..9c7bcb3 100644
--- a/packages/SettingsProvider/Android.mk
+++ b/packages/SettingsProvider/Android.mk
@@ -7,7 +7,7 @@ LOCAL_SRC_FILES := $(call all-subdir-java-files) \
src/com/android/providers/settings/EventLogTags.logtags
LOCAL_JAVA_LIBRARIES := telephony-common ims-common
-
+LOCAL_STATIC_JAVA_LIBRARIES := org.cyanogenmod.platform.sdk
LOCAL_PACKAGE_NAME := SettingsProvider
LOCAL_CERTIFICATE := platform
LOCAL_PRIVILEGED_MODULE := true
diff --git a/packages/SettingsProvider/res/mipmap-hdpi/ic_launcher_settings.png b/packages/SettingsProvider/res/mipmap-hdpi/ic_launcher_settings.png
index a8ccc89..252e6b4 100644
--- a/packages/SettingsProvider/res/mipmap-hdpi/ic_launcher_settings.png
+++ b/packages/SettingsProvider/res/mipmap-hdpi/ic_launcher_settings.png
Binary files differ
diff --git a/packages/SettingsProvider/res/mipmap-mdpi/ic_launcher_settings.png b/packages/SettingsProvider/res/mipmap-mdpi/ic_launcher_settings.png
index 69709a8..d2ecee9 100644
--- a/packages/SettingsProvider/res/mipmap-mdpi/ic_launcher_settings.png
+++ b/packages/SettingsProvider/res/mipmap-mdpi/ic_launcher_settings.png
Binary files differ
diff --git a/packages/SettingsProvider/res/mipmap-xhdpi/ic_launcher_settings.png b/packages/SettingsProvider/res/mipmap-xhdpi/ic_launcher_settings.png
index c3adce61..fa8c813 100644
--- a/packages/SettingsProvider/res/mipmap-xhdpi/ic_launcher_settings.png
+++ b/packages/SettingsProvider/res/mipmap-xhdpi/ic_launcher_settings.png
Binary files differ
diff --git a/packages/SettingsProvider/res/mipmap-xxhdpi/ic_launcher_settings.png b/packages/SettingsProvider/res/mipmap-xxhdpi/ic_launcher_settings.png
index 52fe978..3fa69e9 100644
--- a/packages/SettingsProvider/res/mipmap-xxhdpi/ic_launcher_settings.png
+++ b/packages/SettingsProvider/res/mipmap-xxhdpi/ic_launcher_settings.png
Binary files differ
diff --git a/packages/SettingsProvider/res/mipmap-xxxhdpi/ic_launcher_settings.png b/packages/SettingsProvider/res/mipmap-xxxhdpi/ic_launcher_settings.png
index 6b92795..72946b7 100644
--- a/packages/SettingsProvider/res/mipmap-xxxhdpi/ic_launcher_settings.png
+++ b/packages/SettingsProvider/res/mipmap-xxxhdpi/ic_launcher_settings.png
Binary files differ
diff --git a/packages/SettingsProvider/res/values-ast-rES/strings.xml b/packages/SettingsProvider/res/values-ast-rES/strings.xml
new file mode 100644
index 0000000..e4b0106
--- /dev/null
+++ b/packages/SettingsProvider/res/values-ast-rES/strings.xml
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--Generated by crowdin.com-->
+<!--
+/**
+ * Copyright (c) 2007, The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+-->
+<resources>
+ <string name="app_label">Axustes d\'almacenamientu</string>
+</resources>
diff --git a/packages/SettingsProvider/res/values-be/strings.xml b/packages/SettingsProvider/res/values-be/strings.xml
new file mode 100644
index 0000000..2c3d4d7
--- /dev/null
+++ b/packages/SettingsProvider/res/values-be/strings.xml
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--Generated by crowdin.com-->
+<!--
+/**
+ * Copyright (c) 2007, The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+-->
+<resources>
+ <string name="app_label">Захоўванне налад</string>
+</resources>
diff --git a/packages/SettingsProvider/res/values-ku/strings.xml b/packages/SettingsProvider/res/values-ku/strings.xml
new file mode 100644
index 0000000..097b8b7
--- /dev/null
+++ b/packages/SettingsProvider/res/values-ku/strings.xml
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--Generated by crowdin.com-->
+<!--
+/**
+ * Copyright (c) 2007, The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+-->
+<resources>
+ <string name="app_label">ڕێکخستنی بیرگە</string>
+</resources>
diff --git a/packages/SettingsProvider/res/values-lb/strings.xml b/packages/SettingsProvider/res/values-lb/strings.xml
new file mode 100644
index 0000000..c55b311
--- /dev/null
+++ b/packages/SettingsProvider/res/values-lb/strings.xml
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--Generated by crowdin.com-->
+<!--
+/**
+ * Copyright (c) 2007, The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+-->
+<resources>
+ <string name="app_label">Astellungsspäicher</string>
+</resources>
diff --git a/packages/SettingsProvider/res/values-ug/strings.xml b/packages/SettingsProvider/res/values-ug/strings.xml
new file mode 100644
index 0000000..28b9541
--- /dev/null
+++ b/packages/SettingsProvider/res/values-ug/strings.xml
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--Generated by crowdin.com-->
+<!--
+/**
+ * Copyright (c) 2007, The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+-->
+<resources>
+ <string name="app_label">ساقلىغۇچ تەڭشىكى</string>
+</resources>
diff --git a/packages/SettingsProvider/res/values/customize.xml b/packages/SettingsProvider/res/values/customize.xml
new file mode 100644
index 0000000..9085d2d
--- /dev/null
+++ b/packages/SettingsProvider/res/values/customize.xml
@@ -0,0 +1,63 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+Copyright (c) 2014, The Linux Foundation. All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are
+met:
+ * Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above
+ copyright notice, this list of conditions and the following
+ disclaimer in the documentation and/or other materials provided
+ with the distribution.
+ * Neither the name of The Linux Foundation nor the names of its
+ contributors may be used to endorse or promote products derived
+ from this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
+WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
+ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
+BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+-->
+<resources>
+
+ <!-- Time format,default vlaue is 24 : 24 format,other value is 12 format -->
+ <string name="def_time_format" translatable="false"></string>
+
+ <!-- Date format,yyyy-MM-dd: 2013/07/30; MM-dd-yyyy:07/30/2013; dd-MM-yyyy:30/07/2013 -->
+ <string name="def_date_format" translatable="false"></string>
+
+ <!--
+ Default Input Method, its value is from inputmethod's package name and main class name
+ such as "com.android.inputmethod.pinyin/.PinyinIME"
+ -->
+ <string name="def_input_method" translatable="false"></string>
+
+ <!-- Default for Settings.Global.DATA_ROAMING -->
+ <bool name="def_enable_data_roaming">false</bool>
+
+ <!-- Default for Settings.Global.MOBILE_DATA -->
+ <bool name="def_enable_mobile_data">true</bool>
+
+ <!--
+ Default Enable InputMethods, its value is from inputmethod's package name and main class name
+ such as "com.android.inputmethod.pinyin/.PinyinIME" ;This is a string
+ containing the IDs of all enabled input methods, each ID separated by ':'.
+ -->
+ <string name="def_enable_input_methods" translatable="false"></string>
+
+ <!-- enable accessiblity or not,1:enable;0:disable -->
+ <integer name="def_enable_accessiblity" translatable="false">0</integer>
+
+ <!-- for enable accessiblity services,split by ":" ,example "com.google.android.marvin.talkback/com.google.android.marvin.talkback.TalkBackService" -->
+ <string name="def_enable_accessiblity_services" translatable="false"></string>
+
+</resources>
diff --git a/packages/SettingsProvider/res/values/defaults.xml b/packages/SettingsProvider/res/values/defaults.xml
index ef32c19..76b7d6f 100644
--- a/packages/SettingsProvider/res/values/defaults.xml
+++ b/packages/SettingsProvider/res/values/defaults.xml
@@ -29,12 +29,20 @@
<bool name="def_auto_time">true</bool>
<bool name="def_auto_time_zone">true</bool>
<bool name="def_accelerometer_rotation">true</bool>
+ <!-- Bitmask of allowed display rotation angles:
+ ROTATION_0_MODE: 1
+ ROTATION_90_MODE: 2
+ ROTATION_180_MODE: 4
+ ROTATION_270_MODE: 8
+ Default to 0, 90, 270. -->
+ <integer name="def_accelerometer_rotation_angles">11</integer>
<!-- Default screen brightness, from 0 to 255. 102 is 40%. -->
<integer name="def_screen_brightness">102</integer>
<bool name="def_screen_brightness_automatic_mode">false</bool>
<fraction name="def_window_animation_scale">100%</fraction>
<fraction name="def_window_transition_scale">100%</fraction>
<bool name="def_haptic_feedback">true</bool>
+ <bool name="def_dozeEnabledByDefault">false</bool>
<bool name="def_bluetooth_on">false</bool>
<bool name="def_wifi_display_on">false</bool>
@@ -178,6 +186,9 @@
>0 is milliseconds of screen-off time after which battery sounds will not play -->
<integer name="def_low_battery_sound_timeout">0</integer>
+ <!-- Default for Settings.System.VIBRATE_WHEN_RINGING enabled -->
+ <bool name="def_vibrate_when_ringing_enabled">false</bool>
+
<!-- Initial value for the Settings.Secure.IMMERSIVE_MODE_CONFIRMATIONS setting,
which is a comma separated list of packages that no longer need confirmation
for immersive mode.
@@ -193,6 +204,9 @@
<!-- Default for Settings.Secure.LOCK_SCREEN_ALLOW_PRIVATE_NOTIFICATIONS -->
<bool name="def_lock_screen_allow_private_notifications">true</bool>
+ <!-- Default for Settings.Global.SEND_ACTION_APP_ERROR -->
+ <integer name="def_send_action_app_error">0</integer>
+
<!-- Default for Settings.Global.HEADS_UP_NOTIFICATIONS_ENABLED, 1==on -->
<integer name="def_heads_up_enabled">1</integer>
@@ -213,4 +227,13 @@
<!-- Default for Settings.Secure.NFC_PAYMENT_COMPONENT -->
<string name="def_nfc_payment_component"></string>
+
+ <!-- Default for Settings.System.STATUS_BAR_NOTIF_COUNT. -->
+ <integer name="def_notif_count">0</integer>
+
+ <!-- Default protected sms originating address values of Settings.Secure.PROTECTED_SMS_ADDRESSES -->
+ <string-array name="def_protected_sms_list_values"></string-array>
+
+ <!-- Default for Settings.Global.CAPTIVE_PORTAL_DETECTION_ENABLED -->
+ <integer name="def_captive_portal_detection_enabled" translatable="false">1</integer>
</resources>
diff --git a/packages/SettingsProvider/src/com/android/providers/settings/DatabaseHelper.java b/packages/SettingsProvider/src/com/android/providers/settings/DatabaseHelper.java
index 5a14967..f5f8ce6 100644
--- a/packages/SettingsProvider/src/com/android/providers/settings/DatabaseHelper.java
+++ b/packages/SettingsProvider/src/com/android/providers/settings/DatabaseHelper.java
@@ -23,6 +23,7 @@ import android.content.Intent;
import android.content.pm.ActivityInfo;
import android.content.pm.IPackageManager;
import android.content.pm.PackageManager;
+import android.content.res.ThemeConfig;
import android.content.res.XmlResourceParser;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
@@ -40,6 +41,7 @@ import android.os.UserHandle;
import android.provider.Settings;
import android.provider.Settings.Global;
import android.provider.Settings.Secure;
+import android.telephony.TelephonyManager;
import android.text.TextUtils;
import android.util.Log;
@@ -51,11 +53,13 @@ import com.android.internal.util.XmlUtils;
import com.android.internal.widget.LockPatternUtils;
import com.android.internal.widget.LockPatternView;
+import cyanogenmod.providers.CMSettings;
import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
import java.io.File;
import java.io.IOException;
+import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
@@ -76,11 +80,16 @@ class DatabaseHelper extends SQLiteOpenHelper {
private static final String TAG = "SettingsProvider";
private static final String DATABASE_NAME = "settings.db";
+ private static final int TYPE_NONE = -1;
+
// Please, please please. If you update the database version, check to make sure the
// 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 = 118;
+ private static final int DATABASE_VERSION = 125;
+
+ //Maximum number of phones
+ private static final int MAX_PHONE_COUNT = 3;
private Context mContext;
private int mUserHandle;
@@ -717,6 +726,10 @@ class DatabaseHelper extends SQLiteOpenHelper {
Secure.LOCK_PATTERN_ENABLED,
Secure.LOCK_PATTERN_VISIBLE,
Secure.LOCK_PATTERN_TACTILE_FEEDBACK_ENABLED,
+ CMSettings.Secure.LOCK_PASS_TO_SECURITY_VIEW,
+ Secure.LOCK_PATTERN_SIZE,
+ Secure.LOCK_DOTS_VISIBLE,
+ Secure.LOCK_SHOW_ERROR_PATH,
"lockscreen.password_type",
"lockscreen.lockoutattemptdeadline",
"lockscreen.patterneverchosen",
@@ -1388,6 +1401,7 @@ class DatabaseHelper extends SQLiteOpenHelper {
if (upgradeVersion == 88) {
if (mUserHandle == UserHandle.USER_OWNER) {
db.beginTransaction();
+ SQLiteStatement stmt = null;
try {
String[] settingsToMove = {
Settings.Global.BATTERY_DISCHARGE_DURATION_THRESHOLD,
@@ -1407,7 +1421,6 @@ class DatabaseHelper extends SQLiteOpenHelper {
Settings.Global.SYS_STORAGE_FULL_THRESHOLD_BYTES,
Settings.Global.SYNC_MAX_RETRY_DELAY_IN_SECONDS,
Settings.Global.CONNECTIVITY_CHANGE_DELAY,
- Settings.Global.CAPTIVE_PORTAL_DETECTION_ENABLED,
Settings.Global.CAPTIVE_PORTAL_SERVER,
Settings.Global.NSD_ON,
Settings.Global.SET_INSTALL_LOCATION,
@@ -1423,9 +1436,16 @@ class DatabaseHelper extends SQLiteOpenHelper {
Settings.Global.DEFAULT_DNS_SERVER,
};
moveSettingsToNewTable(db, TABLE_SECURE, TABLE_GLOBAL, settingsToMove, true);
+
+ stmt = db.compileStatement("INSERT OR REPLACE INTO global(name,value)"
+ + " VALUES(?,?);");
+ loadIntegerSetting(stmt, Settings.Global.CAPTIVE_PORTAL_DETECTION_ENABLED,
+ R.integer.def_captive_portal_detection_enabled);
+ stmt.close();
db.setTransactionSuccessful();
} finally {
db.endTransaction();
+ if (stmt != null) stmt.close();
}
}
upgradeVersion = 89;
@@ -1871,9 +1891,34 @@ class DatabaseHelper extends SQLiteOpenHelper {
upgradeVersion = 113;
}
- // We skipped 114 to handle a merge conflict with the introduction of theater mode.
+ // We skipped 114 to handle a merge conflict with the introduction of theater mode. Except
+ // in CM we didn't, soooooo...
+ if (upgradeVersion < 114) {
+ // Artificially bump our upgrade version to handle
+ // migration path from cm-11.0 to cm-12.0
+ // without this, heads up would never work if
+ // a user did not wipe data
+ /** CM-13, this option was moved to CMSettings, artificially bump, skip default load.**/
+// upgradeHeadsUpSettingFromNone(db);
+// upgradeDeviceNameFromNone(db);
+
+ // Removal of back/recents is no longer supported
+ // due to pinned apps
+ db.beginTransaction();
+ try {
+ db.execSQL("DELETE FROM system WHERE name='"
+ + CMSettings.System.NAV_BUTTONS + "'");
+ db.setTransactionSuccessful();
+ } finally {
+ db.endTransaction();
+ }
+
+ upgradeVersion = 114;
+ }
if (upgradeVersion < 115) {
+ moveSettingsToNewTable(db, TABLE_SYSTEM, TABLE_SECURE,
+ new String[] { CMSettings.Secure.STATS_COLLECTION }, true);
if (mUserHandle == UserHandle.USER_OWNER) {
db.beginTransaction();
SQLiteStatement stmt = null;
@@ -1892,6 +1937,8 @@ class DatabaseHelper extends SQLiteOpenHelper {
}
if (upgradeVersion < 116) {
+ moveSettingsToNewTable(db, TABLE_SYSTEM, TABLE_SECURE,
+ new String[]{Settings.Secure.VOLUME_LINK_NOTIFICATION}, true);
if (mUserHandle == UserHandle.USER_OWNER) {
db.beginTransaction();
SQLiteStatement stmt = null;
@@ -1920,10 +1967,44 @@ class DatabaseHelper extends SQLiteOpenHelper {
} finally {
db.endTransaction();
}
+
+ // CM11 used "holo" as a system default theme. For CM12 and up its been
+ // switched to "system". So change all "holo" references in themeConfig to "system"
+ final String NAME_THEME_CONFIG = "themeConfig";
+ Cursor c = null;
+ try {
+ String[] projection = new String[]{"value"};
+ String selection = "name=?";
+ String[] selectionArgs = new String[] { NAME_THEME_CONFIG };
+ c = db.query(TABLE_SECURE, projection, selection,
+ selectionArgs, null, null, null);
+ if (c != null && c.moveToFirst()) {
+ String jsonConfig = c.getString(0);
+ if (jsonConfig != null) {
+ jsonConfig = jsonConfig.replace(
+ "\"holo\"", '"' + ThemeConfig.SYSTEM_DEFAULT + '"');
+
+ // Now update the entry
+ SQLiteStatement stmt = db.compileStatement(
+ "UPDATE " + TABLE_SECURE + " SET value = ? "
+ + " WHERE name = ?");
+ stmt.bindString(1, jsonConfig);
+ stmt.bindString(2, NAME_THEME_CONFIG);
+ stmt.execute();
+ }
+ }
+ } finally {
+ if (c != null) c.close();
+ }
upgradeVersion = 117;
}
if (upgradeVersion < 118) {
+ String[] settingsToMove = new String[] {
+ CMSettings.Secure.QS_SHOW_BRIGHTNESS_SLIDER,
+ };
+ moveSettingsToNewTable(db, TABLE_SYSTEM, TABLE_SECURE,
+ settingsToMove, true);
// Reset rotation-lock-for-accessibility on upgrade, since it now hides the display
// setting.
db.beginTransaction();
@@ -1940,6 +2021,110 @@ class DatabaseHelper extends SQLiteOpenHelper {
upgradeVersion = 118;
}
+ /** CM-13 CHANGES -- THIS IS TO SUPPORT LEGACY UPGRADES, DO NOT ADD ANY NEW DEFAULTS HERE
+ * INSTEAD UTILIZE THE CMSETTINGS PROVIDER
+ */
+ if (upgradeVersion == 119) {
+ /** CM-13, this option was moved to CMSettings, artificially bump, skip default load.**/
+// db.beginTransaction();
+// SQLiteStatement stmt = null;
+// try {
+// stmt = db.compileStatement("INSERT OR IGNORE INTO secure(name,value) VALUES(?,?);");
+// loadDefaultThemeSettings(stmt);
+// db.setTransactionSuccessful();
+// } finally {
+// db.endTransaction();
+// if (stmt != null) stmt.close();
+// }
+ upgradeVersion = 120;
+ }
+
+ if (upgradeVersion < 121) {
+ String[] settingsToMove = CMSettings.Secure.NAVIGATION_RING_TARGETS;
+
+ moveSettingsToNewTable(db, TABLE_SYSTEM, TABLE_SECURE,
+ settingsToMove, true);
+ upgradeVersion = 121;
+ }
+
+ if (upgradeVersion < 122) {
+ /** CM-13, this option was moved to CMSettings, artificially bump, skip default load.**/
+// db.beginTransaction();
+// SQLiteStatement stmt = null;
+// try {
+// stmt = db.compileStatement("INSERT OR IGNORE INTO secure(name,value)"
+// + " VALUES(?,?);");
+// loadBooleanSetting(stmt, CMSettings.Secure.ADVANCED_MODE,
+// com.android.internal.R.bool.config_advancedSettingsMode);
+// db.setTransactionSuccessful();
+// } finally {
+// db.endTransaction();
+// if (stmt != null) stmt.close();
+// }
+ upgradeVersion = 122;
+ }
+
+ if (upgradeVersion < 123) {
+ // only the owner has access to global table, so we need to check that here
+ if (mUserHandle == UserHandle.USER_OWNER) {
+ String[] globalToSecure = new String[] { CMSettings.Secure.POWER_MENU_ACTIONS };
+
+ moveSettingsToNewTable(db, TABLE_GLOBAL, TABLE_SECURE, globalToSecure, true);
+ }
+
+ String[] systemToSecure = new String[] {
+ CMSettings.Secure.DEV_FORCE_SHOW_NAVBAR,
+ CMSettings.Secure.KEYBOARD_BRIGHTNESS,
+ CMSettings.Secure.BUTTON_BRIGHTNESS,
+ CMSettings.Secure.BUTTON_BACKLIGHT_TIMEOUT
+ };
+ moveSettingsToNewTable(db, TABLE_SYSTEM, TABLE_SECURE, systemToSecure, true);
+
+ upgradeVersion = 123;
+ }
+
+ if (upgradeVersion < 124) {
+ // Migrate from cm-12.0 if there is no entry from cm-11.0
+ /** CM-13, this option was moved to CMSettings, artificially bump, skip default load.**/
+// db.beginTransaction();
+// SQLiteStatement stmt = null;
+// try {
+// stmt = db.compileStatement("INSERT OR IGNORE INTO secure(name,value)"
+// + " VALUES(?,?);");
+// int quickPulldown = getIntValueFromSystem(db,
+// CMSettings.System.STATUS_BAR_QUICK_QS_PULLDOWN,
+// R.integer.def_qs_quick_pulldown);
+// loadSetting(stmt, CMSettings.System.QS_QUICK_PULLDOWN, quickPulldown);
+// db.setTransactionSuccessful();
+// } finally {
+// db.endTransaction();
+// if (stmt != null) stmt.close();
+// }
+ upgradeVersion = 124;
+ }
+
+ if (upgradeVersion < 125) {
+ // Force enable advanced settings if the overlay defaults to true
+ /** CM-13, this option was moved to CMSettings, artificially bump, skip default load.**/
+// if (mContext.getResources().getBoolean(
+// com.android.internal.R.bool.config_advancedSettingsMode)) {
+// db.beginTransaction();
+// SQLiteStatement stmt = null;
+// try {
+// stmt = db.compileStatement("INSERT OR REPLACE INTO secure(name,value)"
+// + " VALUES(?,?);");
+// loadBooleanSetting(stmt, CMSettings.Secure.ADVANCED_MODE,
+// com.android.internal.R.bool.config_advancedSettingsMode);
+// db.setTransactionSuccessful();
+// } finally {
+// db.endTransaction();
+// if (stmt != null) stmt.close();
+// }
+// }
+ upgradeVersion = 125;
+ }
+ /** END CM-13 CHANGES */
+
/*
* IMPORTANT: Do not add any more upgrade steps here as the global,
* secure, and system settings are no longer stored in a database
@@ -2065,7 +2250,7 @@ class DatabaseHelper extends SQLiteOpenHelper {
try {
LockPatternUtils lpu = new LockPatternUtils(mContext);
List<LockPatternView.Cell> cellPattern =
- LockPatternUtils.stringToPattern(lockPattern);
+ LockPatternUtils.stringToPattern(lockPattern, lpu.getLockPatternSize());
lpu.saveLockPattern(cellPattern, null, UserHandle.USER_OWNER);
} catch (IllegalArgumentException e) {
// Don't want corrupted lock pattern to hang the reboot process
@@ -2334,12 +2519,26 @@ class DatabaseHelper extends SQLiteOpenHelper {
try {
stmt = db.compileStatement("INSERT OR IGNORE INTO system(name,value)"
+ " VALUES(?,?);");
- loadSetting(stmt, Settings.System.VIBRATE_WHEN_RINGING, vibrateWhenRinging ? 1 : 0);
+ if (mContext.getResources().getBoolean(R.bool.def_vibrate_when_ringing_enabled)) {
+ loadSetting(stmt, Settings.System.VIBRATE_WHEN_RINGING, 1);
+ } else {
+ loadSetting(stmt, Settings.System.VIBRATE_WHEN_RINGING, vibrateWhenRinging ? 1 : 0);
+ }
} finally {
if (stmt != null) stmt.close();
}
}
+ private void loadProtectedSmsSetting(SQLiteStatement stmt) {
+ String[] regAddresses = mContext.getResources()
+ .getStringArray(R.array.def_protected_sms_list_values);
+ if (regAddresses.length > 0) {
+ loadSetting(stmt,
+ Settings.Secure.PROTECTED_SMS_ADDRESSES,
+ TextUtils.join("|", regAddresses));
+ }
+ }
+
private void loadSettings(SQLiteDatabase db) {
loadSystemSettings(db);
loadSecureSettings(db);
@@ -2380,6 +2579,9 @@ class DatabaseHelper extends SQLiteOpenHelper {
loadBooleanSetting(stmt, Settings.System.ACCELEROMETER_ROTATION,
R.bool.def_accelerometer_rotation);
+ loadIntegerSetting(stmt, Settings.System.ACCELEROMETER_ROTATION_ANGLES,
+ R.integer.def_accelerometer_rotation_angles);
+
loadDefaultHapticSettings(stmt);
loadBooleanSetting(stmt, Settings.System.NOTIFICATION_LIGHT_PULSE,
@@ -2397,6 +2599,17 @@ class DatabaseHelper extends SQLiteOpenHelper {
*
* See: SettingsProvider.UpgradeController#onUpgradeLocked
*/
+
+ //LEGACY CAF CHANGES
+ if (!TextUtils.isEmpty(mContext.getResources().getString(R.string.def_time_format))) {
+ loadStringSetting(stmt, Settings.System.TIME_12_24,
+ R.string.def_time_format);
+ }
+
+ if (!TextUtils.isEmpty(mContext.getResources().getString(R.string.def_date_format))) {
+ loadStringSetting(stmt, Settings.System.DATE_FORMAT,
+ R.string.def_date_format);
+ }
} finally {
if (stmt != null) stmt.close();
}
@@ -2446,7 +2659,7 @@ class DatabaseHelper extends SQLiteOpenHelper {
// Allow mock locations default, based on build
loadSetting(stmt, Settings.Secure.ALLOW_MOCK_LOCATION,
- "1".equals(SystemProperties.get("ro.allow.mock.location")) ? 1 : 0);
+ "1".equals(SystemProperties.get("persist.env.c.allow.enable")) ? 1 : 0);
loadSecure35Settings(stmt);
@@ -2497,6 +2710,8 @@ class DatabaseHelper extends SQLiteOpenHelper {
com.android.internal.R.string.config_dreamsDefaultComponent);
loadStringSetting(stmt, Settings.Secure.SCREENSAVER_DEFAULT_COMPONENT,
com.android.internal.R.string.config_dreamsDefaultComponent);
+ loadBooleanSetting(stmt, Settings.Secure.DOZE_ENABLED,
+ R.bool.def_dozeEnabledByDefault);
loadBooleanSetting(stmt, Settings.Secure.ACCESSIBILITY_DISPLAY_MAGNIFICATION_ENABLED,
R.bool.def_accessibility_display_magnification_enabled);
@@ -2536,6 +2751,24 @@ class DatabaseHelper extends SQLiteOpenHelper {
*
* See: SettingsProvider.UpgradeController#onUpgradeLocked
*/
+
+ //LEGACY CAF CHANGES
+ if (!TextUtils.isEmpty(mContext.getResources().getString(R.string.def_input_method))) {
+ loadStringSetting(stmt, Settings.Secure.DEFAULT_INPUT_METHOD,
+ R.string.def_input_method);
+ }
+
+ if (!TextUtils.isEmpty(mContext.getResources().getString(
+ R.string.def_enable_input_methods))) {
+ loadStringSetting(stmt, Settings.Secure.ENABLED_INPUT_METHODS,
+ R.string.def_enable_input_methods);
+ }
+
+ // for accessibility enabled
+ loadStringSetting(stmt, Settings.Secure.ACCESSIBILITY_ENABLED,
+ R.integer.def_enable_accessiblity);
+ loadStringSetting(stmt, Settings.Secure.ENABLED_ACCESSIBILITY_SERVICES,
+ R.string.def_enable_accessiblity_services);
} finally {
if (stmt != null) stmt.close();
}
@@ -2606,10 +2839,8 @@ class DatabaseHelper extends SQLiteOpenHelper {
RILConstants.CDMA_CELL_BROADCAST_SMS_DISABLED);
// Data roaming default, based on build
- loadSetting(stmt, Settings.Global.DATA_ROAMING,
- "true".equalsIgnoreCase(
- SystemProperties.get("ro.com.android.dataroaming",
- "false")) ? 1 : 0);
+ loadBooleanSetting(stmt, Settings.Global.DATA_ROAMING,
+ R.bool.def_enable_data_roaming);
loadBooleanSetting(stmt, Settings.Global.DEVICE_PROVISIONED,
R.bool.def_device_provisioned);
@@ -2629,10 +2860,20 @@ class DatabaseHelper extends SQLiteOpenHelper {
}
// Mobile Data default, based on build
- loadSetting(stmt, Settings.Global.MOBILE_DATA,
- "true".equalsIgnoreCase(
- SystemProperties.get("ro.com.android.mobiledata",
- "true")) ? 1 : 0);
+ loadBooleanSetting(stmt, Settings.Global.MOBILE_DATA,
+ R.bool.def_enable_mobile_data);
+
+ int phoneCount = TelephonyManager.getDefault().getPhoneCount();
+ // SUB specific flags for Multisim devices
+ for (int phoneId = 0; phoneId < MAX_PHONE_COUNT; phoneId++) {
+ // Mobile Data default, based on build
+ loadBooleanSetting(stmt, Settings.Global.MOBILE_DATA + phoneId,
+ R.bool.def_enable_mobile_data);
+
+ // Data roaming default, based on build
+ loadBooleanSetting(stmt, Settings.Global.DATA_ROAMING + phoneId,
+ R.bool.def_enable_data_roaming);
+ }
loadBooleanSetting(stmt, Settings.Global.NETSTATS_ENABLED,
R.bool.def_netstats_enabled);
@@ -2668,6 +2909,8 @@ class DatabaseHelper extends SQLiteOpenHelper {
R.string.def_car_undock_sound);
loadStringSetting(stmt, Settings.Global.WIRELESS_CHARGING_STARTED_SOUND,
R.string.def_wireless_charging_started_sound);
+ loadIntegerSetting(stmt, Settings.Global.DOCK_AUDIO_MEDIA_ENABLED,
+ R.integer.def_dock_audio_media_enabled);
loadIntegerSetting(stmt, Settings.Global.DOCK_AUDIO_MEDIA_ENABLED,
R.integer.def_dock_audio_media_enabled);
@@ -2684,13 +2927,36 @@ class DatabaseHelper extends SQLiteOpenHelper {
// Set the preferred network mode to target desired value or Default
// value defined in RILConstants
- int type;
- type = RILConstants.PREFERRED_NETWORK_MODE;
- loadSetting(stmt, Settings.Global.PREFERRED_NETWORK_MODE, type);
+ final String defVal = SystemProperties.get("ro.telephony.default_network", "");
+ final String[] defNetworkSettings = defVal.split(",");
+ final String[] networkSettings = new String[phoneCount];
+ boolean error = defNetworkSettings.length != phoneCount;
+
+ for (int i = 0; i < phoneCount; i++) {
+ if (i < defNetworkSettings.length) {
+ try {
+ networkSettings[i] = String.valueOf(
+ Integer.parseInt(defNetworkSettings[i]));
+ } catch (NumberFormatException ex) {
+ networkSettings[i] = String.valueOf(RILConstants.PREFERRED_NETWORK_MODE);
+ error = true;
+ }
+ } else {
+ networkSettings[i] = String.valueOf(RILConstants.PREFERRED_NETWORK_MODE);
+ error = true;
+ }
+ }
+
+ if (error) {
+ Log.w(TAG, "Invalid ro.telephony.default_network: " + defVal);
+ }
+
+ loadSetting(stmt, Settings.Global.PREFERRED_NETWORK_MODE, TextUtils.join(",",
+ networkSettings));
// Set the preferred cdma subscription source to target desired value or default
// value defined in CdmaSubscriptionSourceManager
- type = SystemProperties.getInt("ro.telephony.default_cdma_sub",
+ int type = SystemProperties.getInt("ro.telephony.default_cdma_sub",
CdmaSubscriptionSourceManager.PREFERRED_CDMA_SUBSCRIPTION);
loadSetting(stmt, Settings.Global.CDMA_SUBSCRIPTION_MODE, type);
@@ -2705,11 +2971,13 @@ class DatabaseHelper extends SQLiteOpenHelper {
loadSetting(stmt, Settings.Global.DEVICE_NAME, getDefaultDeviceName());
+ loadIntegerSetting(stmt, Settings.Global.SEND_ACTION_APP_ERROR,
+ R.integer.def_send_action_app_error);
+
loadBooleanSetting(stmt, Settings.Global.GUEST_USER_ENABLED,
R.bool.def_guest_user_enabled);
loadSetting(stmt, Settings.Global.ENHANCED_4G_MODE_ENABLED,
ImsConfig.FeatureValueConstants.ON);
-
/*
* IMPORTANT: Do not add any more upgrade steps here as the global,
* secure, and system settings are no longer stored in a database
@@ -2717,6 +2985,8 @@ class DatabaseHelper extends SQLiteOpenHelper {
*
* See: SettingsProvider.UpgradeController#onUpgradeLocked
*/
+ loadIntegerSetting(stmt, Settings.Global.CAPTIVE_PORTAL_DETECTION_ENABLED,
+ R.integer.def_captive_portal_detection_enabled);
} finally {
if (stmt != null) stmt.close();
}
diff --git a/packages/SettingsProvider/src/com/android/providers/settings/SettingsBackupAgent.java b/packages/SettingsProvider/src/com/android/providers/settings/SettingsBackupAgent.java
index 2e96f18..ffe7623 100644
--- a/packages/SettingsProvider/src/com/android/providers/settings/SettingsBackupAgent.java
+++ b/packages/SettingsProvider/src/com/android/providers/settings/SettingsBackupAgent.java
@@ -36,8 +36,10 @@ import android.os.UserHandle;
import android.provider.Settings;
import android.util.Log;
+import com.android.internal.util.ArrayUtils;
import com.android.internal.widget.LockPatternUtils;
+import cyanogenmod.providers.CMSettings;
import libcore.io.IoUtils;
import java.io.BufferedOutputStream;
@@ -261,13 +263,13 @@ public class SettingsBackupAgent extends BackupAgentHelper {
// Now build the canonical config key paralleling the WifiConfiguration semantics
final String key;
if (types.get(KeyMgmt.WPA_PSK)) {
- key = bareSsid + KeyMgmt.strings[KeyMgmt.WPA_PSK];
+ key = bareSsid + "-" + KeyMgmt.strings[KeyMgmt.WPA_PSK];
} else if (types.get(KeyMgmt.WPA_EAP) || types.get(KeyMgmt.IEEE8021X)) {
- key = bareSsid + KeyMgmt.strings[KeyMgmt.WPA_EAP];
+ key = bareSsid + "-" + KeyMgmt.strings[KeyMgmt.WPA_EAP];
} else if (hasWepKey) {
- key = bareSsid + "WEP"; // hardcoded this way in WifiConfiguration
+ key = bareSsid + "-WEP"; // hardcoded this way in WifiConfiguration
} else {
- key = bareSsid + KeyMgmt.strings[KeyMgmt.NONE];
+ key = bareSsid + "-" + KeyMgmt.strings[KeyMgmt.NONE];
}
return key;
}
@@ -902,6 +904,37 @@ public class SettingsBackupAgent extends BackupAgentHelper {
Log.d(TAG, "Restored setting: " + destination + " : "+ key + "=" + value);
}
}
+
+ restoreCMSetting(cachedEntries);
+ }
+
+ private void restoreCMSetting(Map<String, String> cachedEntries) {
+ ContentValues cmSettingsValues = new ContentValues();
+ ContentResolver cr = getContentResolver();
+ for (String key : cachedEntries.keySet()) {
+ Uri uri = null;
+ if (ArrayUtils.contains(CMSettings.System.LEGACY_SYSTEM_SETTINGS, key)) {
+ uri = CMSettings.System.CONTENT_URI;
+ } else if (ArrayUtils.contains(CMSettings.Secure.LEGACY_SECURE_SETTINGS, key)) {
+ uri = CMSettings.Secure.CONTENT_URI;
+ } else if (ArrayUtils.contains(CMSettings.Global.LEGACY_GLOBAL_SETTINGS, key)) {
+ uri = CMSettings.Global.CONTENT_URI;
+ }
+ if (uri != null) {
+ String value = cachedEntries.get(key);
+ cmSettingsValues.clear();
+ cmSettingsValues.put(Settings.NameValueTable.NAME, key);
+ cmSettingsValues.put(Settings.NameValueTable.VALUE, value);
+ try {
+ cr.insert(uri, cmSettingsValues);
+ if (DEBUG) {
+ Log.d(TAG, "Restored cm setting: " + key + " : " + key + "=" + value);
+ }
+ } catch (IllegalArgumentException e) {
+ Log.e(TAG, "Failed to migrate " + key + " due to " + e.toString());
+ }
+ }
+ }
}
/**
diff --git a/packages/SettingsProvider/src/com/android/providers/settings/SettingsProvider.java b/packages/SettingsProvider/src/com/android/providers/settings/SettingsProvider.java
index aa00f7d..5c871ca 100644
--- a/packages/SettingsProvider/src/com/android/providers/settings/SettingsProvider.java
+++ b/packages/SettingsProvider/src/com/android/providers/settings/SettingsProvider.java
@@ -22,10 +22,12 @@ import android.app.AppOpsManager;
import android.app.backup.BackupManager;
import android.content.BroadcastReceiver;
import android.content.ContentProvider;
+import android.content.ContentResolver;
import android.content.ContentValues;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
+import android.content.SharedPreferences;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
@@ -50,6 +52,7 @@ import android.os.Process;
import android.os.SystemProperties;
import android.os.UserHandle;
import android.os.UserManager;
+import android.preference.PreferenceManager;
import android.provider.Settings;
import android.text.TextUtils;
import android.util.ArrayMap;
@@ -72,7 +75,9 @@ import java.util.Map;
import java.util.Set;
import java.util.regex.Pattern;
+import com.android.providers.settings.SettingsState.BaseSetting;
import com.android.providers.settings.SettingsState.Setting;
+import cyanogenmod.providers.CMSettings;
/**
* <p>
@@ -124,6 +129,8 @@ public class SettingsProvider extends ContentProvider {
private static final String TABLE_BOOKMARKS = "bookmarks";
private static final String TABLE_ANDROID_METADATA = "android_metadata";
+ private static final String HAS_REPLAYED_DEFAULTS_FROM_L = "has_replayed_defaults_from_L";
+
// The set of removed legacy tables.
private static final Set<String> REMOVED_LEGACY_TABLES = new ArraySet<>();
static {
@@ -226,17 +233,17 @@ public class SettingsProvider extends ContentProvider {
final int requestingUserId = getRequestingUserId(args);
switch (method) {
case Settings.CALL_METHOD_GET_GLOBAL: {
- Setting setting = getGlobalSetting(name);
+ BaseSetting setting = getGlobalSetting(name);
return packageValueForCallResult(setting);
}
case Settings.CALL_METHOD_GET_SECURE: {
- Setting setting = getSecureSetting(name, requestingUserId);
+ BaseSetting setting = getSecureSetting(name, requestingUserId);
return packageValueForCallResult(setting);
}
case Settings.CALL_METHOD_GET_SYSTEM: {
- Setting setting = getSystemSetting(name, requestingUserId);
+ BaseSetting setting = getSystemSetting(name, requestingUserId);
return packageValueForCallResult(setting);
}
@@ -294,7 +301,10 @@ public class SettingsProvider extends ContentProvider {
switch (args.table) {
case TABLE_GLOBAL: {
if (args.name != null) {
- Setting setting = getGlobalSetting(args.name);
+ BaseSetting setting = getGlobalSetting(args.name);
+ if (CMSettings.Global.shouldInterceptSystemProvider(args.name)) {
+ return forwardedQuery(setting, normalizedProjection, args.table);
+ }
return packageSettingForQuery(setting, normalizedProjection);
} else {
return getAllGlobalSettings(projection);
@@ -304,7 +314,10 @@ public class SettingsProvider extends ContentProvider {
case TABLE_SECURE: {
final int userId = UserHandle.getCallingUserId();
if (args.name != null) {
- Setting setting = getSecureSetting(args.name, userId);
+ BaseSetting setting = getSecureSetting(args.name, userId);
+ if (CMSettings.Secure.shouldInterceptSystemProvider(args.name)) {
+ return forwardedQuery(setting, normalizedProjection, args.table);
+ }
return packageSettingForQuery(setting, normalizedProjection);
} else {
return getAllSecureSettings(userId, projection);
@@ -314,7 +327,10 @@ public class SettingsProvider extends ContentProvider {
case TABLE_SYSTEM: {
final int userId = UserHandle.getCallingUserId();
if (args.name != null) {
- Setting setting = getSystemSetting(args.name, userId);
+ BaseSetting setting = getSystemSetting(args.name, userId);
+ if (CMSettings.System.shouldInterceptSystemProvider(args.name)) {
+ return forwardedQuery(setting, normalizedProjection, args.table);
+ }
return packageSettingForQuery(setting, normalizedProjection);
} else {
return getAllSystemSettings(userId, projection);
@@ -604,16 +620,32 @@ public class SettingsProvider extends ContentProvider {
}
}
- private Setting getGlobalSetting(String name) {
+ private BaseSetting getGlobalSetting(String name) {
if (DEBUG) {
Slog.v(LOG_TAG, "getGlobalSetting(" + name + ")");
}
// Get the value.
+ BaseSetting setting;
synchronized (mLock) {
- return mSettingsRegistry.getSettingLocked(SettingsRegistry.SETTINGS_TYPE_GLOBAL,
+ setting = mSettingsRegistry.getSettingLocked(SettingsRegistry.SETTINGS_TYPE_GLOBAL,
UserHandle.USER_OWNER, name);
}
+
+ // If CMSettingsProvider owns this key, override the value
+ if (CMSettings.Global.shouldInterceptSystemProvider(name)) {
+ final ContentResolver cr = getContext().getContentResolver();
+ final String value = CMSettings.Global.
+ getStringForUser(cr, name, UserHandle.USER_OWNER);
+
+ if (setting == null) {
+ setting = new BaseSetting(name, value, null);
+ } else {
+ setting.update(value, null);
+ }
+ }
+
+ return setting;
}
private boolean updateGlobalSetting(String name, String value, int requestingUserId) {
@@ -650,6 +682,20 @@ public class SettingsProvider extends ContentProvider {
return false;
}
+ // If CMSettingsProvider wants to own this key, let it.
+ if (CMSettings.Global.shouldInterceptSystemProvider(name)) {
+ switch (operation) {
+ case MUTATION_OPERATION_INSERT:
+ case MUTATION_OPERATION_UPDATE:
+ final ContentResolver cr = getContext().getContentResolver();
+ return CMSettings.Global.putStringForUser(cr, name, value,
+ UserHandle.USER_OWNER);
+ case MUTATION_OPERATION_DELETE:
+ // unsupported
+ return false;
+ }
+ }
+
// Perform the mutation.
synchronized (mLock) {
switch (operation) {
@@ -713,7 +759,7 @@ public class SettingsProvider extends ContentProvider {
}
}
- private Setting getSecureSetting(String name, int requestingUserId) {
+ private BaseSetting getSecureSetting(String name, int requestingUserId) {
if (DEBUG) {
Slog.v(LOG_TAG, "getSecureSetting(" + name + ", " + requestingUserId + ")");
}
@@ -730,10 +776,25 @@ public class SettingsProvider extends ContentProvider {
}
// Get the value.
+ BaseSetting setting;
synchronized (mLock) {
- return mSettingsRegistry.getSettingLocked(SettingsRegistry.SETTINGS_TYPE_SECURE,
+ setting = mSettingsRegistry.getSettingLocked(SettingsRegistry.SETTINGS_TYPE_SECURE,
owningUserId, name);
}
+
+ // If CMSettingsProvider owns this key, override the value
+ if (CMSettings.Secure.shouldInterceptSystemProvider(name)) {
+ final ContentResolver cr = getContext().getContentResolver();
+ final String value = CMSettings.Secure.getStringForUser(cr, name, owningUserId);
+
+ if (setting == null) {
+ setting = new BaseSetting(name, value, null);
+ } else {
+ setting.update(value, null);
+ }
+ }
+
+ return setting;
}
private boolean insertSecureSetting(String name, String value, int requestingUserId) {
@@ -788,6 +849,19 @@ public class SettingsProvider extends ContentProvider {
return updateLocationProvidersAllowedLocked(value, owningUserId);
}
+ // If CMSettingsProvider wants to own this key, let it.
+ if (CMSettings.Secure.shouldInterceptSystemProvider(name)) {
+ switch (operation) {
+ case MUTATION_OPERATION_INSERT:
+ case MUTATION_OPERATION_UPDATE:
+ final ContentResolver cr = getContext().getContentResolver();
+ return CMSettings.Secure.putStringForUser(cr, name, value, owningUserId);
+ case MUTATION_OPERATION_DELETE:
+ // unsupported
+ return false;
+ }
+ }
+
// Mutate the value.
synchronized (mLock) {
switch (operation) {
@@ -847,7 +921,7 @@ public class SettingsProvider extends ContentProvider {
}
}
- private Setting getSystemSetting(String name, int requestingUserId) {
+ private BaseSetting getSystemSetting(String name, int requestingUserId) {
if (DEBUG) {
Slog.v(LOG_TAG, "getSystemSetting(" + name + ", " + requestingUserId + ")");
}
@@ -859,10 +933,25 @@ public class SettingsProvider extends ContentProvider {
final int owningUserId = resolveOwningUserIdForSystemSettingLocked(callingUserId, name);
// Get the value.
+ BaseSetting setting;
synchronized (mLock) {
- return mSettingsRegistry.getSettingLocked(SettingsRegistry.SETTINGS_TYPE_SYSTEM,
+ setting = mSettingsRegistry.getSettingLocked(SettingsRegistry.SETTINGS_TYPE_SYSTEM,
owningUserId, name);
}
+
+ // If CMSettingsProvider owns this key, override the value
+ if (CMSettings.System.shouldInterceptSystemProvider(name)) {
+ final ContentResolver cr = getContext().getContentResolver();
+ final String value = CMSettings.System.getStringForUser(cr, name, owningUserId);
+
+ if (setting == null) {
+ setting = new BaseSetting(name, value, null);
+ } else {
+ setting.update(value, null);
+ }
+ }
+
+ return setting;
}
private boolean insertSystemSetting(String name, String value, int requestingUserId) {
@@ -916,6 +1005,19 @@ public class SettingsProvider extends ContentProvider {
return false;
}
+ // If CMSettingsProvider wants to own this key, let it.
+ if (CMSettings.System.shouldInterceptSystemProvider(name)) {
+ switch (operation) {
+ case MUTATION_OPERATION_INSERT:
+ case MUTATION_OPERATION_UPDATE:
+ final ContentResolver cr = getContext().getContentResolver();
+ return CMSettings.System.putStringForUser(cr, name, value, owningUserId);
+ case MUTATION_OPERATION_DELETE:
+ // unsupported
+ return false;
+ }
+ }
+
// Mutate the value.
synchronized (mLock) {
switch (operation) {
@@ -1010,6 +1112,11 @@ public class SettingsProvider extends ContentProvider {
return;
}
+ if (CMSettings.System.shouldInterceptSystemProvider(name)) {
+ // this setting will be forwarded to CMSettingsProvider
+ return;
+ }
+
switch (operation) {
case MUTATION_OPERATION_INSERT:
// Insert updates.
@@ -1107,7 +1214,7 @@ public class SettingsProvider extends ContentProvider {
// skip prefix
value = value.substring(1);
- Setting settingValue = getSecureSetting(
+ BaseSetting settingValue = getSecureSetting(
Settings.Secure.LOCATION_PROVIDERS_ALLOWED, owningUserId);
String oldProviders = (settingValue != null) ? settingValue.getValue() : "";
@@ -1187,7 +1294,7 @@ public class SettingsProvider extends ContentProvider {
"get/set setting for user", null);
}
- private static Bundle packageValueForCallResult(Setting setting) {
+ private static Bundle packageValueForCallResult(BaseSetting setting) {
if (setting == null) {
return NULL_SETTING;
}
@@ -1215,7 +1322,31 @@ public class SettingsProvider extends ContentProvider {
throw new IllegalArgumentException("Invalid URI:" + uri);
}
- private static MatrixCursor packageSettingForQuery(Setting setting, String[] projection) {
+ private MatrixCursor forwardedQuery(BaseSetting setting, String[] projection, String table) {
+ if (setting == null) {
+ return new MatrixCursor(projection, 0);
+ }
+ MatrixCursor cursor = new MatrixCursor(projection, 1);
+ switch (table) {
+ case TABLE_SYSTEM:
+ setting.update(CMSettings.System.getString(getContext().getContentResolver(),
+ setting.getName()), setting.getPackageName());
+ break;
+ case TABLE_GLOBAL:
+ setting.update(CMSettings.Global.getString(getContext().getContentResolver(),
+ setting.getName()), setting.getPackageName());
+ break;
+ case TABLE_SECURE:
+ setting.update(CMSettings.Secure.getString(getContext().getContentResolver(),
+ setting.getName()), setting.getPackageName());
+ break;
+
+ }
+ appendSettingToCursor(cursor, setting);
+ return cursor;
+ }
+
+ private static MatrixCursor packageSettingForQuery(BaseSetting setting, String[] projection) {
if (setting == null) {
return new MatrixCursor(projection, 0);
}
@@ -1240,7 +1371,7 @@ public class SettingsProvider extends ContentProvider {
return projection;
}
- private static void appendSettingToCursor(MatrixCursor cursor, Setting setting) {
+ private static void appendSettingToCursor(MatrixCursor cursor, BaseSetting setting) {
final int columnCount = cursor.getColumnCount();
String[] values = new String[columnCount];
@@ -1856,6 +1987,10 @@ public class SettingsProvider extends ContentProvider {
private final class UpgradeController {
private static final int SETTINGS_VERSION = 123;
+ /**
+ * This is the 12.1 database version (DO NOT INCREMENT)
+ */
+ private static final int CM_SETTINGS_DB_VERSION = 125;
private final int mUserId;
@@ -1869,11 +2004,27 @@ public class SettingsProvider extends ContentProvider {
SettingsRegistry.SETTINGS_TYPE_SECURE, mUserId);
// Try an update from the current state.
- final int oldVersion = secureSettings.getVersionLocked();
+ final int oldVersion = secureSettings.getVersionLocked(); //125
final int newVersion = SETTINGS_VERSION;
// If up do date - done.
- if (oldVersion == newVersion) {
+ //
+ // CYANOGENMOD
+ // We moved our settings out to another settings provider (CMSettingsProvider)
+ // however, we still have a problem of being a few versions ahead of AOSP.
+ // We could approach this in the manner we have previously, and bump the version
+ // to replay the defaults for specific os upgrade changes and have that maintenance
+ // overhead forever OR we can take the approach below:
+ //
+ // Logic as follows:
+ // Until version 125 of this "DATABASE"
+ // force replay AOSP defaults as they get introduced
+ // once 125 is hit, we never have to maintain this again.
+ if ((oldVersion == newVersion || oldVersion == CM_SETTINGS_DB_VERSION)) {
+ if (oldVersion == CM_SETTINGS_DB_VERSION && !hasReplayedDefaultsFromL()) {
+ forceReplayAOSPDefaults(mUserId);
+ setDefaultsReplayedFromLFlag();
+ }
return;
}
@@ -1913,6 +2064,18 @@ public class SettingsProvider extends ContentProvider {
systemSettings.setVersionLocked(newVersion);
}
+ private boolean hasReplayedDefaultsFromL() {
+ SharedPreferences sharedPreferences = PreferenceManager
+ .getDefaultSharedPreferences(getContext());
+ return sharedPreferences.getBoolean(HAS_REPLAYED_DEFAULTS_FROM_L, false);
+ }
+
+ private void setDefaultsReplayedFromLFlag() {
+ SharedPreferences sharedPreferences = PreferenceManager
+ .getDefaultSharedPreferences(getContext());
+ sharedPreferences.edit().putBoolean(HAS_REPLAYED_DEFAULTS_FROM_L, true).apply();
+ }
+
private SettingsState getGlobalSettingsLocked() {
return getSettingsLocked(SETTINGS_TYPE_GLOBAL, UserHandle.USER_OWNER);
}
@@ -2022,6 +2185,42 @@ public class SettingsProvider extends ContentProvider {
// Return the current version.
return currentVersion;
}
+
+ private void forceReplayAOSPDefaults(int userId) {
+ // v119: Reset zen + ringer mode.
+ if (userId == UserHandle.USER_OWNER) {
+ final SettingsState globalSettings = getGlobalSettingsLocked();
+ globalSettings.updateSettingLocked(Settings.Global.ZEN_MODE,
+ Integer.toString(Settings.Global.ZEN_MODE_OFF),
+ SettingsState.SYSTEM_PACKAGE_NAME);
+ globalSettings.updateSettingLocked(Settings.Global.MODE_RINGER,
+ Integer.toString(AudioManager.RINGER_MODE_NORMAL),
+ SettingsState.SYSTEM_PACKAGE_NAME);
+ }
+
+ // v120: Add double tap to wake setting.
+ SettingsState secureSettings = getSecureSettingsLocked(userId);
+ secureSettings.insertSettingLocked(Settings.Secure.DOUBLE_TAP_TO_WAKE,
+ getContext().getResources().getBoolean(
+ R.bool.def_double_tap_to_wake) ? "1" : "0",
+ SettingsState.SYSTEM_PACKAGE_NAME);
+
+ // Version 122: allow OEMs to set a default payment component in resources.
+ // Note that we only write the default if no default has been set;
+ // if there is, we just leave the default at whatever it currently is.
+ String defaultComponent = (getContext().getResources().getString(
+ R.string.def_nfc_payment_component));
+ Setting currentSetting = secureSettings.getSettingLocked(
+ Settings.Secure.NFC_PAYMENT_DEFAULT_COMPONENT);
+ if (defaultComponent != null && !defaultComponent.isEmpty() &&
+ currentSetting == null) {
+ secureSettings.insertSettingLocked(
+ Settings.Secure.NFC_PAYMENT_DEFAULT_COMPONENT,
+ defaultComponent,
+ SettingsState.SYSTEM_PACKAGE_NAME);
+ }
+ }
+
}
}
}
diff --git a/packages/SettingsProvider/src/com/android/providers/settings/SettingsState.java b/packages/SettingsProvider/src/com/android/providers/settings/SettingsState.java
index 95d7772..8a25c65 100644
--- a/packages/SettingsProvider/src/com/android/providers/settings/SettingsState.java
+++ b/packages/SettingsProvider/src/com/android/providers/settings/SettingsState.java
@@ -552,22 +552,21 @@ final class SettingsState {
}
}
- public final class Setting {
- private String name;
- private String value;
- private String packageName;
- private String id;
+ public static class BaseSetting {
+ protected String name;
+ protected String value;
+ protected String packageName;
+ protected String id;
- public Setting(String name, String value, String packageName) {
- init(name, value, packageName, String.valueOf(mNextId++));
+ protected BaseSetting() {
+ // for sub classes
}
- public Setting(String name, String value, String packageName, String id) {
- mNextId = Math.max(mNextId, Long.valueOf(id) + 1);
- init(name, value, packageName, id);
+ public BaseSetting(String name, String value, String packageName) {
+ init(name, value, packageName, null);
}
- private void init(String name, String value, String packageName, String id) {
+ protected void init(String name, String value, String packageName, String id) {
this.name = name;
this.value = value;
this.packageName = packageName;
@@ -596,6 +595,33 @@ final class SettingsState {
}
this.value = value;
this.packageName = packageName;
+ return true;
+ }
+ }
+
+ public final class Setting extends BaseSetting {
+
+ public Setting(String name, String value, String packageName) {
+ init(name, value, packageName, String.valueOf(mNextId++));
+ }
+
+ public Setting(String name, String value, String packageName, String id) {
+ mNextId = Math.max(mNextId, Long.valueOf(id) + 1);
+ init(name, value, packageName, id);
+ }
+
+ @Override
+ public String getId() {
+ return id;
+ }
+
+ @Override
+ public boolean update(String value, String packageName) {
+ if (Objects.equal(value, this.value)) {
+ return false;
+ }
+ this.value = value;
+ this.packageName = packageName;
this.id = String.valueOf(mNextId++);
return true;
}