CMSettingsProvider: Change migration pref.

The previous migration step should've never happened,
  change the default shared pref to a different location to
  force trigger a migration on devices where the previous iteration
  of settings migration already happened.

Change-Id: I6b466d37910c31dbf58d37fd631807d7dd2dbae3
This commit is contained in:
Adnan Begovic 2015-11-18 16:06:36 -08:00
parent e4558b7fc3
commit 2be0eef4dd
1 changed files with 17 additions and 3 deletions

View File

@ -18,6 +18,7 @@ package org.cyanogenmod.cmsettings;
import android.app.ActivityManager;
import android.content.BroadcastReceiver;
import android.content.ComponentName;
import android.content.ContentProvider;
import android.content.ContentResolver;
import android.content.ContentValues;
@ -54,12 +55,12 @@ import java.util.Set;
* The CMSettingsProvider serves as a {@link ContentProvider} for CM specific settings
*/
public class CMSettingsProvider extends ContentProvider {
private static final String TAG = "CMSettingsProvider";
static final String TAG = "CMSettingsProvider";
private static final boolean LOCAL_LOGV = false;
private static final boolean USER_CHECK_THROWS = true;
private static final String PREF_HAS_MIGRATED_CM_SETTINGS = "has_migrated_cm_settings";
static final String PREF_HAS_MIGRATED_CM_SETTINGS = "has_migrated_cm13_settings";
private static final Bundle NULL_SETTING = Bundle.forPair("value", null);
@ -249,7 +250,7 @@ public class CMSettingsProvider extends ContentProvider {
@Override
public Bundle call(String method, String request, Bundle args) {
if (LOCAL_LOGV) Log.d(TAG, "Call method: " + method);
if (LOCAL_LOGV) Log.d(TAG, "Call method: " + method + " " + request);
int callingUserId = UserHandle.getCallingUserId();
if (args != null) {
@ -262,6 +263,19 @@ public class CMSettingsProvider extends ContentProvider {
}
}
boolean hasMigratedCMSettings = mSharedPrefs.getBoolean(PREF_HAS_MIGRATED_CM_SETTINGS,
false);
if (!hasMigratedCMSettings) {
if (LOCAL_LOGV) {
Log.d(TAG, "Reenabling component preboot receiver");
}
getContext().getPackageManager().setComponentEnabledSetting(
new ComponentName("org.cyanogenmod.cmsettings",
"org.cyanogenmod.cmsettings.PreBootReceiver"),
PackageManager.COMPONENT_ENABLED_STATE_ENABLED,
PackageManager.DONT_KILL_APP);
}
// Migrate methods
if (CMSettings.CALL_METHOD_MIGRATE_SETTINGS.equals(method)) {
migrateCMSettingsForExistingUsersIfNeeded();