diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/com/android/calllogbackup/CallLogBackupAgent.java (renamed from src/com/android/providers/calllogbackup/CallLogBackupAgent.java) | 27 | ||||
-rw-r--r-- | src/com/android/calllogbackup/CallLogChangeReceiver.java (renamed from src/com/android/providers/calllogbackup/CallLogChangeReceiver.java) | 19 |
2 files changed, 41 insertions, 5 deletions
diff --git a/src/com/android/providers/calllogbackup/CallLogBackupAgent.java b/src/com/android/calllogbackup/CallLogBackupAgent.java index f939d8c..a6f7c85 100644 --- a/src/com/android/providers/calllogbackup/CallLogBackupAgent.java +++ b/src/com/android/calllogbackup/CallLogBackupAgent.java @@ -14,19 +14,21 @@ * limitations under the License */ -package com.android.providers.calllogbackup; +package com.android.calllogbackup; import android.app.backup.BackupAgent; import android.app.backup.BackupDataInput; import android.app.backup.BackupDataOutput; import android.content.ComponentName; import android.content.ContentResolver; +import android.content.Context; import android.database.Cursor; import android.os.ParcelFileDescriptor; import android.os.UserHandle; import android.os.UserManager; import android.provider.CallLog; import android.provider.CallLog.Calls; +import android.provider.Settings; import android.telecom.PhoneAccountHandle; import android.util.Log; @@ -96,6 +98,8 @@ public class CallLogBackupAgent extends BackupAgent { private static final String TAG = "CallLogBackupAgent"; + private static final String USER_FULL_DATA_BACKUP_AWARE = "user_full_data_backup_aware"; + /** Current version of CallLogBackup. Used to track the backup format. */ @VisibleForTesting static final int VERSION = 1002; @@ -109,6 +113,7 @@ public class CallLogBackupAgent extends BackupAgent { static final int END_OEM_DATA_MARKER = 0x60061E; + private static final String[] CALL_LOG_PROJECTION = new String[] { CallLog.Calls._ID, CallLog.Calls.DATE, @@ -130,6 +135,13 @@ public class CallLogBackupAgent extends BackupAgent { public void onBackup(ParcelFileDescriptor oldStateDescriptor, BackupDataOutput data, ParcelFileDescriptor newStateDescriptor) throws IOException { + if (shouldPreventBackup(this)) { + if (isDebug()) { + Log.d(TAG, "Skipping onBackup"); + } + return; + } + // Get the list of the previous calls IDs which were backed up. DataInputStream dataInput = new DataInputStream( new FileInputStream(oldStateDescriptor.getFileDescriptor())); @@ -157,6 +169,13 @@ public class CallLogBackupAgent extends BackupAgent { @Override public void onRestore(BackupDataInput data, int appVersionCode, ParcelFileDescriptor newState) throws IOException { + if (shouldPreventBackup(this)) { + if (isDebug()) { + Log.d(TAG, "Skipping restore"); + } + return; + } + if (isDebug()) { Log.d(TAG, "Performing Restore"); } @@ -486,6 +505,12 @@ public class CallLogBackupAgent extends BackupAgent { } } + static boolean shouldPreventBackup(Context context) { + // Check to see that the user is full-data aware before performing calllog backup. + return Settings.Secure.getInt( + context.getContentResolver(), USER_FULL_DATA_BACKUP_AWARE, 0) == 0; + } + private static boolean isDebug() { return Log.isLoggable(TAG, Log.DEBUG); } diff --git a/src/com/android/providers/calllogbackup/CallLogChangeReceiver.java b/src/com/android/calllogbackup/CallLogChangeReceiver.java index dbd7b00..eaebe5f 100644 --- a/src/com/android/providers/calllogbackup/CallLogChangeReceiver.java +++ b/src/com/android/calllogbackup/CallLogChangeReceiver.java @@ -14,27 +14,38 @@ * limitations under the License */ -package com.android.providers.calllogbackup; +package com.android.calllogbackup; import android.app.backup.BackupManager; import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; +import android.provider.Settings; +import android.util.Log; /** * Call Log Change Broadcast Receiver. Receives an intent when the call log provider changes * so that it triggers backup accordingly. */ public class CallLogChangeReceiver extends BroadcastReceiver { - + private static final String TAG = "CallLogChangeReceiver"; + private static final boolean VDBG = Log.isLoggable(TAG, Log.VERBOSE); private static final String ACTION_CALL_LOG_CHANGE = "android.intent.action.CALL_LOG_CHANGE"; /** ${inheritDoc} */ @Override public void onReceive(Context context, Intent intent) { if (ACTION_CALL_LOG_CHANGE.equals(intent.getAction())) { - BackupManager bm = new BackupManager(context); - bm.dataChanged(); + + if (CallLogBackupAgent.shouldPreventBackup(context)) { + // User is not full-backup-data aware so we skip calllog backup until they are. + if (VDBG) { + Log.v(TAG, "Skipping call log backup due to lack of full-data check."); + } + } else { + BackupManager bm = new BackupManager(context); + bm.dataChanged(); + } } } |