Source:
public static void upgrade(boolean initialized, Context context) { synchronized (context.getApplicationContext()) { SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); int oldVersion = prefs.getInt("version", -1); int newVersion = Util.getSelfVersionCode(context); if (oldVersion == newVersion) return; Log.i(TAG, "Upgrading from version " + oldVersion + " to " + newVersion); SharedPreferences.Editor editor = prefs.edit(); if (initialized) { if (oldVersion < 38) { Log.i(TAG, "Converting screen wifi/mobile"); editor.putBoolean("screen_wifi", prefs.getBoolean("unused", false)); editor.putBoolean("screen_other", prefs.getBoolean("unused", false)); editor.remove("unused"); SharedPreferences unused = context.getSharedPreferences("unused", Context.MODE_PRIVATE); SharedPreferences screen_wifi = context.getSharedPreferences("screen_wifi", Context.MODE_PRIVATE); SharedPreferences screen_other = context.getSharedPreferences("screen_other", Context.MODE_PRIVATE); Map<String, ?> punused = unused.getAll(); SharedPreferences.Editor edit_screen_wifi = screen_wifi.edit(); SharedPreferences.Editor edit_screen_other = screen_other.edit(); for (String key : punused.keySet()) { edit_screen_wifi.putBoolean(key, (Boolean) punused.get(key)); edit_screen_other.putBoolean(key, (Boolean) punused.get(key)); } edit_screen_wifi.apply(); edit_screen_other.apply(); } } else { Log.i(TAG, "Initializing sdk=" + Build.VERSION.SDK_INT); editor.putBoolean("whitelist_wifi", false); editor.putBoolean("whitelist_other", false); } if (Build.VERSION.SDK_INT < VERSION_CODES.LOLLIPOP_MR1) { Log.i(TAG, "Forcing filter mode sdk=" + Build.VERSION.SDK_INT); editor.putBoolean("filter", true); editor.putBoolean("filter_allowed", true); } editor.putInt("version", newVersion); editor.apply(); } }

Target:
public static void upgrade(boolean initialized, Context context) { synchronized (context.getApplicationContext()) { SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); int oldVersion = prefs.getInt("version", -1); int newVersion = Util.getSelfVersionCode(context); if (oldVersion == newVersion) return; Log.i(TAG, "Upgrading from version " + oldVersion + " to " + newVersion); SharedPreferences.Editor editor = prefs.edit(); if (initialized) { if (oldVersion < 38) { Log.i(TAG, "Converting screen wifi/mobile"); editor.putBoolean("screen_wifi", prefs.getBoolean("unused", false)); editor.putBoolean("screen_other", prefs.getBoolean("unused", false)); editor.remove("unused"); SharedPreferences unused = context.getSharedPreferences("unused", Context.MODE_PRIVATE); SharedPreferences screen_wifi = context.getSharedPreferences("screen_wifi", Context.MODE_PRIVATE); SharedPreferences screen_other = context.getSharedPreferences("screen_other", Context.MODE_PRIVATE); Map<String, ?> punused = unused.getAll(); SharedPreferences.Editor edit_screen_wifi = screen_wifi.edit(); SharedPreferences.Editor edit_screen_other = screen_other.edit(); for (String key : punused.keySet()) { edit_screen_wifi.putBoolean(key, (Boolean) punused.get(key)); edit_screen_other.putBoolean(key, (Boolean) punused.get(key)); } edit_screen_wifi.apply(); edit_screen_other.apply(); } } else { Log.i(TAG, "Initializing sdk=" + Build.VERSION.SDK_INT); editor.putBoolean("whitelist_wifi", false); editor.putBoolean("whitelist_other", false); } if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP_MR1) { Log.i(TAG, "Forcing filter mode sdk=" + Build.VERSION.SDK_INT); editor.putBoolean("filter", true); editor.putBoolean("filter_allowed", true); } editor.putInt("version", newVersion); editor.apply(); } }