summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Christopher Tate <ctate@google.com> 2012-08-13 17:58:39 -0700
committer Android (Google) Code Review <android-gerrit@google.com> 2012-08-13 17:58:40 -0700
commitbf7d222011bcb417a2d6ab0f086b25e1608445cb (patch)
treef92f75219ad3b12fb22ef6d507d9629daaf9ae9d
parentae5ac108b03214e02781a92592f7913ada8ef2d4 (diff)
parentaac71ff465399251fa8e830407f2917b986988d9 (diff)
Merge "Don't back up / restore non-primary users' data" into jb-mr1-dev
-rw-r--r--core/java/android/os/UserId.java2
-rw-r--r--services/java/com/android/server/BackupManagerService.java23
2 files changed, 25 insertions, 0 deletions
diff --git a/core/java/android/os/UserId.java b/core/java/android/os/UserId.java
index 7e611df9f086..18a3062df575 100644
--- a/core/java/android/os/UserId.java
+++ b/core/java/android/os/UserId.java
@@ -33,6 +33,8 @@ public final class UserId {
/** A user id to indicate the currently active user */
public static final int USER_CURRENT = -2;
+ /** A user id constant to indicate the "owner" user of the device */
+ public static final int USER_OWNER = 0;
/**
* Enable multi-user related side effects. Set this to false if there are problems with single
diff --git a/services/java/com/android/server/BackupManagerService.java b/services/java/com/android/server/BackupManagerService.java
index 2167c492e5a9..45428402d8d4 100644
--- a/services/java/com/android/server/BackupManagerService.java
+++ b/services/java/com/android/server/BackupManagerService.java
@@ -65,6 +65,7 @@ import android.os.Process;
import android.os.RemoteException;
import android.os.ServiceManager;
import android.os.SystemClock;
+import android.os.UserId;
import android.os.WorkSource;
import android.os.storage.IMountService;
import android.provider.Settings;
@@ -4845,6 +4846,18 @@ class BackupManagerService extends IBackupManager.Stub {
// ----- IBackupManager binder interface -----
public void dataChanged(final String packageName) {
+ final int callingUserHandle = UserId.getCallingUserId();
+ if (callingUserHandle != UserId.USER_OWNER) {
+ // App is running under a non-owner user profile. For now, we do not back
+ // up data from secondary user profiles.
+ // TODO: backups for all user profiles.
+ if (MORE_DEBUG) {
+ Slog.v(TAG, "dataChanged(" + packageName + ") ignored because it's user "
+ + callingUserHandle);
+ }
+ return;
+ }
+
final HashSet<String> targets = dataChangedTargets(packageName);
if (targets == null) {
Slog.w(TAG, "dataChanged but no participant pkg='" + packageName + "'"
@@ -4937,6 +4950,11 @@ class BackupManagerService extends IBackupManager.Stub {
boolean doAllApps, boolean includeSystem, String[] pkgList) {
mContext.enforceCallingPermission(android.Manifest.permission.BACKUP, "fullBackup");
+ final int callingUserHandle = UserId.getCallingUserId();
+ if (callingUserHandle != UserId.USER_OWNER) {
+ throw new IllegalStateException("Backup supported only for the device owner");
+ }
+
// Validate
if (!doAllApps) {
if (!includeShared) {
@@ -5001,6 +5019,11 @@ class BackupManagerService extends IBackupManager.Stub {
public void fullRestore(ParcelFileDescriptor fd) {
mContext.enforceCallingPermission(android.Manifest.permission.BACKUP, "fullRestore");
+ final int callingUserHandle = UserId.getCallingUserId();
+ if (callingUserHandle != UserId.USER_OWNER) {
+ throw new IllegalStateException("Restore supported only for the device owner");
+ }
+
long oldId = Binder.clearCallingIdentity();
try {