Remove deprecated settings migration code
This was used for cm 12.1 to 13.0 migration. Change-Id: I4a074b15ed54d7b64d7f14e66bd4d2036b09e4cb
This commit is contained in:
@@ -42,15 +42,5 @@
|
||||
android:writePermission="lineageos.permission.WRITE_SETTINGS"
|
||||
android:singleUser="true"
|
||||
android:initOrder="100" />
|
||||
|
||||
<receiver android:name="PreBootReceiver" android:enabled="true" android:exported="true">
|
||||
<!-- This broadcast is sent after the core system has finished
|
||||
booting, before the home app is launched or BOOT_COMPLETED
|
||||
is sent. -->
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.PRE_BOOT_COMPLETED"/>
|
||||
</intent-filter>
|
||||
</receiver>
|
||||
|
||||
</application>
|
||||
</manifest>
|
||||
|
||||
@@ -59,9 +59,6 @@ public class LineageSettingsProvider extends ContentProvider {
|
||||
|
||||
private static final boolean USER_CHECK_THROWS = true;
|
||||
|
||||
public static final String PREF_HAS_MIGRATED_LINEAGE_SETTINGS =
|
||||
"migrated_settings_to_lineage_17_0";
|
||||
|
||||
private static final Bundle NULL_SETTING = Bundle.forPair("value", null);
|
||||
|
||||
// Each defined user has their own settings
|
||||
@@ -138,132 +135,6 @@ public class LineageSettingsProvider extends ContentProvider {
|
||||
return true;
|
||||
}
|
||||
|
||||
// region Migration Methods
|
||||
|
||||
/**
|
||||
* Migrates Lineage settings for all existing users if this has not been run before.
|
||||
*/
|
||||
private void migrateLineageSettingsForExistingUsersIfNeeded() {
|
||||
boolean hasMigratedLineageSettings = mSharedPrefs.getBoolean(PREF_HAS_MIGRATED_LINEAGE_SETTINGS,
|
||||
false);
|
||||
|
||||
if (!hasMigratedLineageSettings) {
|
||||
long startTime = System.currentTimeMillis();
|
||||
|
||||
for (UserInfo user : mUserManager.getUsers()) {
|
||||
migrateLineageSettingsForUser(user.id);
|
||||
}
|
||||
|
||||
mSharedPrefs.edit().putBoolean(PREF_HAS_MIGRATED_LINEAGE_SETTINGS, true).commit();
|
||||
|
||||
// TODO: Add this as part of a boot message to the UI
|
||||
long timeDiffMillis = System.currentTimeMillis() - startTime;
|
||||
if (LOCAL_LOGV) Log.d(TAG, "Migration finished in " + timeDiffMillis + " milliseconds");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Migrates Lineage settings for a specific user.
|
||||
* @param userId The id of the user to run Lineage settings migration for.
|
||||
*/
|
||||
private void migrateLineageSettingsForUser(int userId) {
|
||||
synchronized (this) {
|
||||
if (LOCAL_LOGV) Log.d(TAG, "Lineage settings will be migrated for user id: " + userId);
|
||||
|
||||
// Migrate system settings
|
||||
int rowsMigrated = migrateLineageSettingsForTable(userId,
|
||||
LineageDatabaseHelper.LineageTableNames.TABLE_SYSTEM, LineageSettings.System.LEGACY_SYSTEM_SETTINGS);
|
||||
if (LOCAL_LOGV) Log.d(TAG, "Migrated " + rowsMigrated + " to Lineage system table");
|
||||
|
||||
// Migrate secure settings
|
||||
rowsMigrated = migrateLineageSettingsForTable(userId,
|
||||
LineageDatabaseHelper.LineageTableNames.TABLE_SECURE, LineageSettings.Secure.LEGACY_SECURE_SETTINGS);
|
||||
if (LOCAL_LOGV) Log.d(TAG, "Migrated " + rowsMigrated + " to Lineage secure table");
|
||||
|
||||
// Migrate global settings
|
||||
rowsMigrated = migrateLineageSettingsForTable(userId,
|
||||
LineageDatabaseHelper.LineageTableNames.TABLE_GLOBAL, LineageSettings.Global.LEGACY_GLOBAL_SETTINGS);
|
||||
if (LOCAL_LOGV) Log.d(TAG, "Migrated " + rowsMigrated + " to Lineage global table");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Migrates Lineage settings for a specific table and user id.
|
||||
* @param userId The id of the user to run Lineage settings migration for.
|
||||
* @param tableName The name of the table to run Lineage settings migration on.
|
||||
* @param settings An array of keys to migrate from {@link Settings} to {@link LineageSettings}
|
||||
* @return Number of rows migrated.
|
||||
*/
|
||||
private int migrateLineageSettingsForTable(int userId, String tableName, String[] settings) {
|
||||
ContentResolver contentResolver = getContext().getContentResolver();
|
||||
ContentValues[] contentValues = new ContentValues[settings.length];
|
||||
|
||||
int migrateSettingsCount = 0;
|
||||
for (String settingsKey : settings) {
|
||||
String settingsValue = null;
|
||||
|
||||
if (tableName.equals(LineageDatabaseHelper.LineageTableNames.TABLE_SYSTEM)) {
|
||||
settingsValue = Settings.System.getStringForUser(contentResolver, settingsKey,
|
||||
userId);
|
||||
}
|
||||
else if (tableName.equals(LineageDatabaseHelper.LineageTableNames.TABLE_SECURE)) {
|
||||
settingsValue = Settings.Secure.getStringForUser(contentResolver, settingsKey,
|
||||
userId);
|
||||
if (settingsValue != null && settingsKey.equals(LineageSettings.Secure.STATS_COLLECTION)
|
||||
&& LineageSettings.Secure.getStringForUser(contentResolver, settingsKey, userId)
|
||||
!= null) {
|
||||
// incorrect migration from YOG4P -> YOG7D failed to remove
|
||||
// Settings.Secure.STATS_COLLECTION after migration; so it may exist in both
|
||||
// providers; so if it exists in the new database, prefer it.
|
||||
continue;
|
||||
}
|
||||
}
|
||||
else if (tableName.equals(LineageDatabaseHelper.LineageTableNames.TABLE_GLOBAL)) {
|
||||
settingsValue = Settings.Global.getStringForUser(contentResolver, settingsKey,
|
||||
userId);
|
||||
}
|
||||
|
||||
if (LOCAL_LOGV) Log.d(TAG, "Table: " + tableName + ", Key: " + settingsKey + ", Value: "
|
||||
+ settingsValue);
|
||||
|
||||
// Don't trample defaults with null values. This is the only scenario where defaults
|
||||
// take precedence over migration values.
|
||||
if (settingsValue == null) {
|
||||
if (LOCAL_LOGV) Log.d(TAG, "Skipping migrating " + settingsKey
|
||||
+ " because of null value");
|
||||
continue;
|
||||
}
|
||||
|
||||
ContentValues contentValue = new ContentValues();
|
||||
contentValue.put(Settings.NameValueTable.NAME, settingsKey);
|
||||
contentValue.put(Settings.NameValueTable.VALUE, settingsValue);
|
||||
contentValues[migrateSettingsCount++] = contentValue;
|
||||
}
|
||||
|
||||
int rowsInserted = 0;
|
||||
if (contentValues.length > 0) {
|
||||
Uri uri = mUriBuilder.build();
|
||||
uri = uri.buildUpon().appendPath(tableName).build();
|
||||
rowsInserted = bulkInsertForUser(userId, uri, contentValues);
|
||||
}
|
||||
|
||||
return rowsInserted;
|
||||
}
|
||||
|
||||
private List<String> delimitedStringToList(String s, String delimiter) {
|
||||
List<String> list = new ArrayList<String>();
|
||||
if (!TextUtils.isEmpty(s)) {
|
||||
final String[] array = TextUtils.split(s, Pattern.quote(delimiter));
|
||||
for (String item : array) {
|
||||
if (TextUtils.isEmpty(item)) {
|
||||
continue;
|
||||
}
|
||||
list.add(item);
|
||||
}
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
/**
|
||||
* Performs cleanup for the removed user.
|
||||
* @param userId The id of the user that is removed.
|
||||
@@ -279,8 +150,6 @@ public class LineageSettingsProvider extends ContentProvider {
|
||||
}
|
||||
}
|
||||
|
||||
// endregion Migration Methods
|
||||
|
||||
// region Content Provider Methods
|
||||
|
||||
@Override
|
||||
@@ -299,14 +168,6 @@ public class LineageSettingsProvider extends ContentProvider {
|
||||
}
|
||||
|
||||
switch (method) {
|
||||
// Migrate methods
|
||||
case LineageSettings.CALL_METHOD_MIGRATE_SETTINGS:
|
||||
migrateLineageSettingsForExistingUsersIfNeeded();
|
||||
return null;
|
||||
case LineageSettings.CALL_METHOD_MIGRATE_SETTINGS_FOR_USER:
|
||||
migrateLineageSettingsForUser(callingUserId);
|
||||
return null;
|
||||
|
||||
// Get methods
|
||||
case LineageSettings.CALL_METHOD_GET_SYSTEM:
|
||||
return lookupSingleValue(callingUserId, LineageSettings.System.CONTENT_URI,
|
||||
|
||||
@@ -1,51 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) 2015, The CyanogenMod 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.
|
||||
*/
|
||||
|
||||
package org.lineageos.lineagesettings;
|
||||
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.ContentResolver;
|
||||
import android.content.Context;
|
||||
import android.content.IContentProvider;
|
||||
import android.content.Intent;
|
||||
import android.os.RemoteException;
|
||||
import android.util.Log;
|
||||
|
||||
import lineageos.providers.LineageSettings;
|
||||
|
||||
public class PreBootReceiver extends BroadcastReceiver{
|
||||
private static final String TAG = "LineageSettingsReceiver";
|
||||
private static final boolean LOCAL_LOGV = false;
|
||||
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
if (LOCAL_LOGV) {
|
||||
Log.d(TAG, "Received pre boot intent. Attempting to migrate Lineage settings.");
|
||||
}
|
||||
|
||||
ContentResolver contentResolver = context.getContentResolver();
|
||||
IContentProvider contentProvider = contentResolver.acquireProvider(
|
||||
LineageSettings.AUTHORITY);
|
||||
|
||||
try {
|
||||
contentProvider.call(contentResolver.getAttributionSource(),
|
||||
LineageSettings.AUTHORITY,
|
||||
LineageSettings.CALL_METHOD_MIGRATE_SETTINGS, null, null);
|
||||
} catch (RemoteException ex) {
|
||||
Log.w(TAG, "Failed to trigger settings migration due to RemoteException");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2102,98 +2102,6 @@ public final class LineageSettings {
|
||||
public static final Validator __MAGICAL_TEST_PASSING_ENABLER_VALIDATOR =
|
||||
sAlwaysTrueValidator;
|
||||
|
||||
/**
|
||||
* @hide
|
||||
*/
|
||||
public static final String[] LEGACY_SYSTEM_SETTINGS = new String[]{
|
||||
LineageSettings.System.NAV_BUTTONS,
|
||||
LineageSettings.System.KEY_BACK_LONG_PRESS_ACTION,
|
||||
LineageSettings.System.KEY_HOME_LONG_PRESS_ACTION,
|
||||
LineageSettings.System.KEY_HOME_DOUBLE_TAP_ACTION,
|
||||
LineageSettings.System.BACK_WAKE_SCREEN,
|
||||
LineageSettings.System.MENU_WAKE_SCREEN,
|
||||
LineageSettings.System.VOLUME_WAKE_SCREEN,
|
||||
LineageSettings.System.KEY_MENU_ACTION,
|
||||
LineageSettings.System.KEY_MENU_LONG_PRESS_ACTION,
|
||||
LineageSettings.System.KEY_ASSIST_ACTION,
|
||||
LineageSettings.System.KEY_ASSIST_LONG_PRESS_ACTION,
|
||||
LineageSettings.System.KEY_APP_SWITCH_ACTION,
|
||||
LineageSettings.System.KEY_APP_SWITCH_LONG_PRESS_ACTION,
|
||||
LineageSettings.System.HOME_WAKE_SCREEN,
|
||||
LineageSettings.System.ASSIST_WAKE_SCREEN,
|
||||
LineageSettings.System.APP_SWITCH_WAKE_SCREEN,
|
||||
LineageSettings.System.CAMERA_WAKE_SCREEN,
|
||||
LineageSettings.System.CAMERA_SLEEP_ON_RELEASE,
|
||||
LineageSettings.System.CAMERA_LAUNCH,
|
||||
LineageSettings.System.STYLUS_ICON_ENABLED,
|
||||
LineageSettings.System.SWAP_VOLUME_KEYS_ON_ROTATION,
|
||||
LineageSettings.System.BATTERY_LIGHT_ENABLED,
|
||||
LineageSettings.System.BATTERY_LIGHT_FULL_CHARGE_DISABLED,
|
||||
LineageSettings.System.BATTERY_LIGHT_PULSE,
|
||||
LineageSettings.System.BATTERY_LIGHT_LOW_COLOR,
|
||||
LineageSettings.System.BATTERY_LIGHT_MEDIUM_COLOR,
|
||||
LineageSettings.System.BATTERY_LIGHT_FULL_COLOR,
|
||||
LineageSettings.System.ENABLE_MWI_NOTIFICATION,
|
||||
LineageSettings.System.PROXIMITY_ON_WAKE,
|
||||
LineageSettings.System.DISPLAY_TEMPERATURE_DAY,
|
||||
LineageSettings.System.DISPLAY_TEMPERATURE_NIGHT,
|
||||
LineageSettings.System.DISPLAY_TEMPERATURE_MODE,
|
||||
LineageSettings.System.DISPLAY_AUTO_OUTDOOR_MODE,
|
||||
LineageSettings.System.DISPLAY_ANTI_FLICKER,
|
||||
LineageSettings.System.DISPLAY_READING_MODE,
|
||||
LineageSettings.System.DISPLAY_CABC,
|
||||
LineageSettings.System.DISPLAY_COLOR_ENHANCE,
|
||||
LineageSettings.System.DISPLAY_COLOR_ADJUSTMENT,
|
||||
LineageSettings.System.LIVE_DISPLAY_HINTED,
|
||||
LineageSettings.System.DOUBLE_TAP_SLEEP_GESTURE,
|
||||
LineageSettings.System.RECENTS_SHOW_SEARCH_BAR,
|
||||
LineageSettings.System.NAVBAR_LEFT_IN_LANDSCAPE,
|
||||
LineageSettings.System.T9_SEARCH_INPUT_LOCALE,
|
||||
LineageSettings.System.BLUETOOTH_ACCEPT_ALL_FILES,
|
||||
LineageSettings.System.LOCKSCREEN_PIN_SCRAMBLE_LAYOUT,
|
||||
LineageSettings.System.SHOW_ALARM_ICON,
|
||||
LineageSettings.System.STATUS_BAR_IME_SWITCHER,
|
||||
LineageSettings.System.QS_SHOW_BRIGHTNESS_SLIDER,
|
||||
LineageSettings.System.STATUS_BAR_BRIGHTNESS_CONTROL,
|
||||
LineageSettings.System.VOLBTN_MUSIC_CONTROLS,
|
||||
LineageSettings.System.USE_EDGE_SERVICE_FOR_GESTURES,
|
||||
LineageSettings.System.CALL_RECORDING_FORMAT,
|
||||
LineageSettings.System.NOTIFICATION_LIGHT_BRIGHTNESS_LEVEL,
|
||||
LineageSettings.System.NOTIFICATION_LIGHT_SCREEN_ON,
|
||||
LineageSettings.System.NOTIFICATION_LIGHT_PULSE_DEFAULT_COLOR,
|
||||
LineageSettings.System.NOTIFICATION_LIGHT_PULSE_DEFAULT_LED_ON,
|
||||
LineageSettings.System.NOTIFICATION_LIGHT_PULSE_DEFAULT_LED_OFF,
|
||||
LineageSettings.System.NOTIFICATION_LIGHT_PULSE_CALL_COLOR,
|
||||
LineageSettings.System.NOTIFICATION_LIGHT_PULSE_CALL_LED_ON,
|
||||
LineageSettings.System.NOTIFICATION_LIGHT_PULSE_CALL_LED_OFF,
|
||||
LineageSettings.System.NOTIFICATION_LIGHT_PULSE_VMAIL_COLOR,
|
||||
LineageSettings.System.NOTIFICATION_LIGHT_PULSE_VMAIL_LED_ON,
|
||||
LineageSettings.System.NOTIFICATION_LIGHT_PULSE_VMAIL_LED_OFF,
|
||||
LineageSettings.System.NOTIFICATION_LIGHT_PULSE_CUSTOM_ENABLE,
|
||||
LineageSettings.System.NOTIFICATION_LIGHT_PULSE_CUSTOM_VALUES,
|
||||
LineageSettings.System.STATUS_BAR_QUICK_QS_PULLDOWN,
|
||||
LineageSettings.System.VOLUME_ADJUST_SOUNDS_ENABLED,
|
||||
LineageSettings.System.SYSTEM_PROFILES_ENABLED,
|
||||
LineageSettings.System.INCREASING_RING,
|
||||
LineageSettings.System.INCREASING_RING_START_VOLUME,
|
||||
LineageSettings.System.INCREASING_RING_RAMP_UP_TIME,
|
||||
LineageSettings.System.STATUS_BAR_CLOCK,
|
||||
LineageSettings.System.STATUS_BAR_AM_PM,
|
||||
LineageSettings.System.STATUS_BAR_BATTERY_STYLE,
|
||||
LineageSettings.System.STATUS_BAR_SHOW_BATTERY_PERCENT,
|
||||
LineageSettings.System.NAVIGATION_BAR_MENU_ARROW_KEYS,
|
||||
LineageSettings.System.HEADSET_CONNECT_PLAYER,
|
||||
LineageSettings.System.ZEN_ALLOW_LIGHTS,
|
||||
LineageSettings.System.TOUCHSCREEN_GESTURE_HAPTIC_FEEDBACK,
|
||||
};
|
||||
|
||||
/**
|
||||
* @hide
|
||||
*/
|
||||
public static boolean isLegacySetting(String key) {
|
||||
return ArrayUtils.contains(LEGACY_SYSTEM_SETTINGS, key);
|
||||
}
|
||||
|
||||
/**
|
||||
* Mapping of validators for all system settings. This map is used to validate both valid
|
||||
* keys as well as validating the values for those keys.
|
||||
@@ -3061,37 +2969,6 @@ public final class LineageSettings {
|
||||
public static final String __MAGICAL_TEST_PASSING_ENABLER =
|
||||
"___magical_test_passing_enabler";
|
||||
|
||||
/**
|
||||
* @hide
|
||||
*/
|
||||
public static final String[] LEGACY_SECURE_SETTINGS = new String[]{
|
||||
LineageSettings.Secure.BUTTON_BACKLIGHT_TIMEOUT,
|
||||
LineageSettings.Secure.BUTTON_BRIGHTNESS,
|
||||
LineageSettings.Secure.KEYBOARD_BRIGHTNESS,
|
||||
LineageSettings.Secure.POWER_MENU_ACTIONS,
|
||||
LineageSettings.Secure.STATS_COLLECTION,
|
||||
LineageSettings.Secure.QS_SHOW_BRIGHTNESS_SLIDER,
|
||||
LineageSettings.Secure.NAVIGATION_RING_TARGETS[0],
|
||||
LineageSettings.Secure.NAVIGATION_RING_TARGETS[1],
|
||||
LineageSettings.Secure.NAVIGATION_RING_TARGETS[2],
|
||||
LineageSettings.Secure.RECENTS_LONG_PRESS_ACTIVITY,
|
||||
LineageSettings.Secure.LIVE_DISPLAY_COLOR_MATRIX,
|
||||
LineageSettings.Secure.ADVANCED_REBOOT,
|
||||
LineageSettings.Secure.LOCKSCREEN_TARGETS,
|
||||
LineageSettings.Secure.RING_HOME_BUTTON_BEHAVIOR,
|
||||
LineageSettings.Secure.DEVELOPMENT_SHORTCUT,
|
||||
LineageSettings.Secure.QS_LOCATION_ADVANCED,
|
||||
LineageSettings.Secure.LOCKSCREEN_VISUALIZER_ENABLED,
|
||||
LineageSettings.Secure.LOCK_PASS_TO_SECURITY_VIEW
|
||||
};
|
||||
|
||||
/**
|
||||
* @hide
|
||||
*/
|
||||
public static boolean isLegacySetting(String key) {
|
||||
return ArrayUtils.contains(LEGACY_SECURE_SETTINGS, key);
|
||||
}
|
||||
|
||||
/**
|
||||
* Mapping of validators for all secure settings. This map is used to validate both valid
|
||||
* keys as well as validating the values for those keys.
|
||||
@@ -3549,22 +3426,6 @@ public final class LineageSettings {
|
||||
public static final Validator __MAGICAL_TEST_PASSING_ENABLER_VALIDATOR =
|
||||
sAlwaysTrueValidator;
|
||||
|
||||
/**
|
||||
* @hide
|
||||
*/
|
||||
public static final String[] LEGACY_GLOBAL_SETTINGS = new String[]{
|
||||
LineageSettings.Global.WAKE_WHEN_PLUGGED_OR_UNPLUGGED,
|
||||
LineageSettings.Global.ZEN_DISABLE_DUCKING_DURING_MEDIA_PLAYBACK,
|
||||
LineageSettings.Global.WIFI_AUTO_PRIORITIES_CONFIGURATION
|
||||
};
|
||||
|
||||
/**
|
||||
* @hide
|
||||
*/
|
||||
public static boolean isLegacySetting(String key) {
|
||||
return ArrayUtils.contains(LEGACY_GLOBAL_SETTINGS, key);
|
||||
}
|
||||
|
||||
/**
|
||||
* Mapping of validators for all global settings. This map is used to validate both valid
|
||||
* keys as well as validating the values for those keys.
|
||||
|
||||
Reference in New Issue
Block a user