resolve merge conflicts of b171e5675b
to ub-launcher3-calgary.
Change-Id: I329c7518d8c3f0f43e96c6446d5b53a6f4439211
This commit is contained in:
commit
ad37152c14
|
@ -20,6 +20,7 @@ import android.app.backup.BackupAgentHelper;
|
|||
import android.app.backup.BackupDataInput;
|
||||
import android.app.backup.BackupManager;
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
import android.database.Cursor;
|
||||
import android.os.ParcelFileDescriptor;
|
||||
import android.util.Log;
|
||||
|
@ -32,13 +33,13 @@ public class LauncherBackupAgentHelper extends BackupAgentHelper {
|
|||
|
||||
private static final String TAG = "LauncherBAHelper";
|
||||
|
||||
private static final String KEY_LAST_NOTIFIED_TIME = "backup_manager_last_notified";
|
||||
|
||||
private static final String LAUNCHER_DATA_PREFIX = "L";
|
||||
|
||||
static final boolean VERBOSE = false;
|
||||
static final boolean DEBUG = false;
|
||||
|
||||
private static BackupManager sBackupManager;
|
||||
|
||||
/**
|
||||
* Notify the backup manager that out database is dirty.
|
||||
*
|
||||
|
@ -47,10 +48,29 @@ public class LauncherBackupAgentHelper extends BackupAgentHelper {
|
|||
* @param context application context
|
||||
*/
|
||||
public static void dataChanged(Context context) {
|
||||
if (sBackupManager == null) {
|
||||
sBackupManager = new BackupManager(context);
|
||||
dataChanged(context, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Notify the backup manager that out database is dirty.
|
||||
*
|
||||
* <P>This does not force an immediate backup.
|
||||
*
|
||||
* @param context application context
|
||||
* @param throttleMs duration in ms for which two consecutive calls to backup manager should
|
||||
* not be made.
|
||||
*/
|
||||
public static void dataChanged(Context context, long throttleMs) {
|
||||
SharedPreferences prefs = Utilities.getPrefs(context);
|
||||
long now = System.currentTimeMillis();
|
||||
long lastTime = prefs.getLong(KEY_LAST_NOTIFIED_TIME, 0);
|
||||
|
||||
// User can manually change the system time, which could lead to now < lastTime.
|
||||
// Re-backup in that case, as the backup will have a wrong lastModifiedTime.
|
||||
if (now < lastTime || now >= (lastTime + throttleMs)) {
|
||||
BackupManager.dataChanged(context.getPackageName());
|
||||
prefs.edit().putLong(KEY_LAST_NOTIFIED_TIME, now).apply();
|
||||
}
|
||||
sBackupManager.dataChanged();
|
||||
}
|
||||
|
||||
private LauncherBackupHelper mHelper;
|
||||
|
|
|
@ -278,6 +278,9 @@ public class LauncherProvider extends ContentProvider {
|
|||
mListener.onSettingsChanged(arg, value);
|
||||
}
|
||||
}
|
||||
if (extras.getBoolean(LauncherSettings.Settings.NOTIFY_BACKUP)) {
|
||||
LauncherBackupAgentHelper.dataChanged(getContext());
|
||||
}
|
||||
Bundle result = new Bundle();
|
||||
result.putBoolean(LauncherSettings.Settings.EXTRA_VALUE, value);
|
||||
return result;
|
||||
|
|
|
@ -341,6 +341,8 @@ public class LauncherSettings {
|
|||
|
||||
public static final String EXTRA_VALUE = "value";
|
||||
public static final String EXTRA_DEFAULT_VALUE = "default_value";
|
||||
// Extra for set_boolean method to also notify the backup manager of the change.
|
||||
public static final String NOTIFY_BACKUP = "notify_backup";
|
||||
|
||||
public static Bundle call(ContentResolver cr, String method) {
|
||||
return cr.call(CONTENT_URI, method, null, null);
|
||||
|
|
Loading…
Reference in New Issue