|
65 | 65 | import android.os.RemoteException; |
66 | 66 | import android.os.ServiceManager; |
67 | 67 | import android.os.SystemClock; |
| 68 | +import android.os.UserId; |
68 | 69 | import android.os.WorkSource; |
69 | 70 | import android.os.storage.IMountService; |
70 | 71 | import android.provider.Settings; |
@@ -4845,6 +4846,18 @@ private void writeToJournalLocked(String str) { |
4845 | 4846 | // ----- IBackupManager binder interface ----- |
4846 | 4847 |
|
4847 | 4848 | public void dataChanged(final String packageName) { |
| 4849 | + final int callingUserHandle = UserId.getCallingUserId(); |
| 4850 | + if (callingUserHandle != UserId.USER_OWNER) { |
| 4851 | + // App is running under a non-owner user profile. For now, we do not back |
| 4852 | + // up data from secondary user profiles. |
| 4853 | + // TODO: backups for all user profiles. |
| 4854 | + if (MORE_DEBUG) { |
| 4855 | + Slog.v(TAG, "dataChanged(" + packageName + ") ignored because it's user " |
| 4856 | + + callingUserHandle); |
| 4857 | + } |
| 4858 | + return; |
| 4859 | + } |
| 4860 | + |
4848 | 4861 | final HashSet<String> targets = dataChangedTargets(packageName); |
4849 | 4862 | if (targets == null) { |
4850 | 4863 | Slog.w(TAG, "dataChanged but no participant pkg='" + packageName + "'" |
@@ -4937,6 +4950,11 @@ public void fullBackup(ParcelFileDescriptor fd, boolean includeApks, boolean inc |
4937 | 4950 | boolean doAllApps, boolean includeSystem, String[] pkgList) { |
4938 | 4951 | mContext.enforceCallingPermission(android.Manifest.permission.BACKUP, "fullBackup"); |
4939 | 4952 |
|
| 4953 | + final int callingUserHandle = UserId.getCallingUserId(); |
| 4954 | + if (callingUserHandle != UserId.USER_OWNER) { |
| 4955 | + throw new IllegalStateException("Backup supported only for the device owner"); |
| 4956 | + } |
| 4957 | + |
4940 | 4958 | // Validate |
4941 | 4959 | if (!doAllApps) { |
4942 | 4960 | if (!includeShared) { |
@@ -5001,6 +5019,11 @@ public void fullBackup(ParcelFileDescriptor fd, boolean includeApks, boolean inc |
5001 | 5019 | public void fullRestore(ParcelFileDescriptor fd) { |
5002 | 5020 | mContext.enforceCallingPermission(android.Manifest.permission.BACKUP, "fullRestore"); |
5003 | 5021 |
|
| 5022 | + final int callingUserHandle = UserId.getCallingUserId(); |
| 5023 | + if (callingUserHandle != UserId.USER_OWNER) { |
| 5024 | + throw new IllegalStateException("Restore supported only for the device owner"); |
| 5025 | + } |
| 5026 | + |
5004 | 5027 | long oldId = Binder.clearCallingIdentity(); |
5005 | 5028 |
|
5006 | 5029 | try { |
|
0 commit comments