Loading core/java/android/app/ActivityThread.java +5 −4 Original line number Diff line number Diff line Loading @@ -47,6 +47,7 @@ import android.app.RemoteServiceException.MissingRequestPasswordComplexityPermis import android.app.assist.AssistContent; import android.app.assist.AssistStructure; import android.app.backup.BackupAgent; import android.app.backup.BackupAnnotations.BackupDestination; import android.app.servertransaction.ActivityLifecycleItem; import android.app.servertransaction.ActivityLifecycleItem.LifecycleState; import android.app.servertransaction.ActivityRelaunchItem; Loading Loading @@ -799,7 +800,7 @@ public final class ActivityThread extends ClientTransactionHandler ApplicationInfo appInfo; int backupMode; int userId; int operationType; @BackupDestination int backupDestination; public String toString() { return "CreateBackupAgentData{appInfo=" + appInfo + " backupAgent=" + appInfo.backupAgentName Loading Loading @@ -1034,12 +1035,12 @@ public final class ActivityThread extends ClientTransactionHandler } public final void scheduleCreateBackupAgent(ApplicationInfo app, int backupMode, int userId, int operationType) { int backupMode, int userId, @BackupDestination int backupDestination) { CreateBackupAgentData d = new CreateBackupAgentData(); d.appInfo = app; d.backupMode = backupMode; d.userId = userId; d.operationType = operationType; d.backupDestination = backupDestination; sendMessage(H.CREATE_BACKUP_AGENT, d); } Loading Loading @@ -4402,7 +4403,7 @@ public final class ActivityThread extends ClientTransactionHandler context.setOuterContext(agent); agent.attach(context); agent.onCreate(UserHandle.of(data.userId), data.operationType); agent.onCreate(UserHandle.of(data.userId), data.backupDestination); binder = agent.onBind(); backupAgents.put(packageName, agent); } catch (Exception e) { Loading core/java/android/app/IActivityManager.aidl +1 −1 Original line number Diff line number Diff line Loading @@ -304,7 +304,7 @@ interface IActivityManager { @UnsupportedAppUsage void resumeAppSwitches(); boolean bindBackupAgent(in String packageName, int backupRestoreMode, int targetUserId, int operationType); int backupDestination); void backupAgentCreated(in String packageName, in IBinder agent, int userId); void unbindBackupAgent(in ApplicationInfo appInfo); int handleIncomingUser(int callingPid, int callingUid, int userId, boolean allowAll, Loading core/java/android/app/backup/BackupAgent.java +11 −12 Original line number Diff line number Diff line Loading @@ -20,7 +20,7 @@ import android.annotation.IntDef; import android.annotation.Nullable; import android.app.IBackupAgent; import android.app.QueuedWork; import android.app.backup.BackupManager.OperationType; import android.app.backup.BackupAnnotations.BackupDestination; import android.app.backup.FullBackup.BackupScheme.PathWithRequiredFlags; import android.content.Context; import android.content.ContextWrapper; Loading Loading @@ -137,7 +137,7 @@ import java.util.concurrent.CountDownLatch; public abstract class BackupAgent extends ContextWrapper { private static final String TAG = "BackupAgent"; private static final boolean DEBUG = false; private static final int DEFAULT_OPERATION_TYPE = OperationType.BACKUP; private static final int DEFAULT_BACKUP_DESTINATION = BackupDestination.CLOUD; /** @hide */ public static final int RESULT_SUCCESS = 0; Loading Loading @@ -207,7 +207,7 @@ public abstract class BackupAgent extends ContextWrapper { @Nullable private UserHandle mUser; // This field is written from the main thread (in onCreate), and read in a Binder thread (in // onFullBackup that is called from system_server via Binder). @OperationType private volatile int mOperationType = DEFAULT_OPERATION_TYPE; @BackupDestination private volatile int mBackupDestination = DEFAULT_BACKUP_DESTINATION; Handler getHandler() { if (mHandler == null) { Loading Loading @@ -268,7 +268,7 @@ public abstract class BackupAgent extends ContextWrapper { * @hide */ public void onCreate(UserHandle user) { onCreate(user, DEFAULT_OPERATION_TYPE); onCreate(user, DEFAULT_BACKUP_DESTINATION); } /** Loading @@ -279,14 +279,13 @@ public abstract class BackupAgent extends ContextWrapper { * * @hide */ public void onCreate(UserHandle user, @OperationType int operationType) { public void onCreate(UserHandle user, @BackupDestination int backupDestination) { // TODO: Instantiate with the correct type using a parameter. mLogger = new BackupRestoreEventLogger(BackupRestoreEventLogger.OperationType.BACKUP); onCreate(); mUser = user; mOperationType = operationType; mBackupDestination = backupDestination; } /** Loading Loading @@ -433,7 +432,7 @@ public abstract class BackupAgent extends ContextWrapper { */ public void onFullBackup(FullBackupDataOutput data) throws IOException { FullBackup.BackupScheme backupScheme = FullBackup.getBackupScheme(this, mOperationType); mBackupDestination); if (!backupScheme.isFullBackupEnabled(data.getTransportFlags())) { return; } Loading Loading @@ -643,7 +642,7 @@ public abstract class BackupAgent extends ContextWrapper { if (includeMap == null || includeMap.size() == 0) { // Do entire sub-tree for the provided token. fullBackupFileTree(packageName, domainToken, FullBackup.getBackupScheme(this, mOperationType) FullBackup.getBackupScheme(this, mBackupDestination) .tokenToDirectoryPath(domainToken), filterSet, traversalExcludeSet, data); } else if (includeMap.get(domainToken) != null) { Loading Loading @@ -815,7 +814,7 @@ public abstract class BackupAgent extends ContextWrapper { ArraySet<String> systemExcludes, FullBackupDataOutput output) { // Pull out the domain and set it aside to use when making the tarball. String domainPath = FullBackup.getBackupScheme(this, mOperationType) String domainPath = FullBackup.getBackupScheme(this, mBackupDestination) .tokenToDirectoryPath(domain); if (domainPath == null) { // Should never happen. Loading Loading @@ -927,7 +926,7 @@ public abstract class BackupAgent extends ContextWrapper { } private boolean isFileEligibleForRestore(File destination) throws IOException { FullBackup.BackupScheme bs = FullBackup.getBackupScheme(this, mOperationType); FullBackup.BackupScheme bs = FullBackup.getBackupScheme(this, mBackupDestination); if (!bs.isFullRestoreEnabled()) { if (Log.isLoggable(FullBackup.TAG_XML_PARSER, Log.VERBOSE)) { Log.v(FullBackup.TAG_XML_PARSER, Loading Loading @@ -1001,7 +1000,7 @@ public abstract class BackupAgent extends ContextWrapper { + " domain=" + domain + " relpath=" + path + " mode=" + mode + " mtime=" + mtime); basePath = FullBackup.getBackupScheme(this, mOperationType).tokenToDirectoryPath( basePath = FullBackup.getBackupScheme(this, mBackupDestination).tokenToDirectoryPath( domain); if (domain.equals(FullBackup.MANAGED_EXTERNAL_TREE_TOKEN)) { mode = -1; // < 0 is a token to skip attempting a chmod() Loading core/java/android/app/backup/BackupAnnotations.java 0 → 100644 +60 −0 Original line number Diff line number Diff line /* * Copyright (C) 2022 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package android.app.backup; import android.annotation.IntDef; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; /** * Annotations related to Android Backup&Restore. * * @hide */ public class BackupAnnotations { /** @hide */ @Retention(RetentionPolicy.SOURCE) @IntDef({ OperationType.BACKUP, OperationType.RESTORE, }) public @interface OperationType { int BACKUP = 0; int RESTORE = 1; } /** * Denotes where the backup data is going (e.g. to the cloud or directly to the other device) * during backup or where it is coming from during restore. * * @hide */ @Retention(RetentionPolicy.SOURCE) @IntDef({ BackupDestination.CLOUD, BackupDestination.DEVICE_TRANSFER, BackupDestination.ADB_BACKUP }) public @interface BackupDestination { // A cloud backup. int CLOUD = 0; // A device to device migration. int DEVICE_TRANSFER = 1; // An adb backup. int ADB_BACKUP = 2; } } core/java/android/app/backup/BackupManager.java +0 −16 Original line number Diff line number Diff line Loading @@ -200,22 +200,6 @@ public class BackupManager { @SystemApi public static final int ERROR_TRANSPORT_INVALID = -2; /** @hide */ @Retention(RetentionPolicy.SOURCE) @IntDef({ OperationType.BACKUP, OperationType.MIGRATION, OperationType.ADB_BACKUP, }) public @interface OperationType { // A backup / restore to / from an off-device location, e.g. cloud. int BACKUP = 0; // A direct transfer to another device. int MIGRATION = 1; // Backup via adb, data saved on the host machine. int ADB_BACKUP = 3; } private Context mContext; @UnsupportedAppUsage private static IBackupManager sService; Loading Loading
core/java/android/app/ActivityThread.java +5 −4 Original line number Diff line number Diff line Loading @@ -47,6 +47,7 @@ import android.app.RemoteServiceException.MissingRequestPasswordComplexityPermis import android.app.assist.AssistContent; import android.app.assist.AssistStructure; import android.app.backup.BackupAgent; import android.app.backup.BackupAnnotations.BackupDestination; import android.app.servertransaction.ActivityLifecycleItem; import android.app.servertransaction.ActivityLifecycleItem.LifecycleState; import android.app.servertransaction.ActivityRelaunchItem; Loading Loading @@ -799,7 +800,7 @@ public final class ActivityThread extends ClientTransactionHandler ApplicationInfo appInfo; int backupMode; int userId; int operationType; @BackupDestination int backupDestination; public String toString() { return "CreateBackupAgentData{appInfo=" + appInfo + " backupAgent=" + appInfo.backupAgentName Loading Loading @@ -1034,12 +1035,12 @@ public final class ActivityThread extends ClientTransactionHandler } public final void scheduleCreateBackupAgent(ApplicationInfo app, int backupMode, int userId, int operationType) { int backupMode, int userId, @BackupDestination int backupDestination) { CreateBackupAgentData d = new CreateBackupAgentData(); d.appInfo = app; d.backupMode = backupMode; d.userId = userId; d.operationType = operationType; d.backupDestination = backupDestination; sendMessage(H.CREATE_BACKUP_AGENT, d); } Loading Loading @@ -4402,7 +4403,7 @@ public final class ActivityThread extends ClientTransactionHandler context.setOuterContext(agent); agent.attach(context); agent.onCreate(UserHandle.of(data.userId), data.operationType); agent.onCreate(UserHandle.of(data.userId), data.backupDestination); binder = agent.onBind(); backupAgents.put(packageName, agent); } catch (Exception e) { Loading
core/java/android/app/IActivityManager.aidl +1 −1 Original line number Diff line number Diff line Loading @@ -304,7 +304,7 @@ interface IActivityManager { @UnsupportedAppUsage void resumeAppSwitches(); boolean bindBackupAgent(in String packageName, int backupRestoreMode, int targetUserId, int operationType); int backupDestination); void backupAgentCreated(in String packageName, in IBinder agent, int userId); void unbindBackupAgent(in ApplicationInfo appInfo); int handleIncomingUser(int callingPid, int callingUid, int userId, boolean allowAll, Loading
core/java/android/app/backup/BackupAgent.java +11 −12 Original line number Diff line number Diff line Loading @@ -20,7 +20,7 @@ import android.annotation.IntDef; import android.annotation.Nullable; import android.app.IBackupAgent; import android.app.QueuedWork; import android.app.backup.BackupManager.OperationType; import android.app.backup.BackupAnnotations.BackupDestination; import android.app.backup.FullBackup.BackupScheme.PathWithRequiredFlags; import android.content.Context; import android.content.ContextWrapper; Loading Loading @@ -137,7 +137,7 @@ import java.util.concurrent.CountDownLatch; public abstract class BackupAgent extends ContextWrapper { private static final String TAG = "BackupAgent"; private static final boolean DEBUG = false; private static final int DEFAULT_OPERATION_TYPE = OperationType.BACKUP; private static final int DEFAULT_BACKUP_DESTINATION = BackupDestination.CLOUD; /** @hide */ public static final int RESULT_SUCCESS = 0; Loading Loading @@ -207,7 +207,7 @@ public abstract class BackupAgent extends ContextWrapper { @Nullable private UserHandle mUser; // This field is written from the main thread (in onCreate), and read in a Binder thread (in // onFullBackup that is called from system_server via Binder). @OperationType private volatile int mOperationType = DEFAULT_OPERATION_TYPE; @BackupDestination private volatile int mBackupDestination = DEFAULT_BACKUP_DESTINATION; Handler getHandler() { if (mHandler == null) { Loading Loading @@ -268,7 +268,7 @@ public abstract class BackupAgent extends ContextWrapper { * @hide */ public void onCreate(UserHandle user) { onCreate(user, DEFAULT_OPERATION_TYPE); onCreate(user, DEFAULT_BACKUP_DESTINATION); } /** Loading @@ -279,14 +279,13 @@ public abstract class BackupAgent extends ContextWrapper { * * @hide */ public void onCreate(UserHandle user, @OperationType int operationType) { public void onCreate(UserHandle user, @BackupDestination int backupDestination) { // TODO: Instantiate with the correct type using a parameter. mLogger = new BackupRestoreEventLogger(BackupRestoreEventLogger.OperationType.BACKUP); onCreate(); mUser = user; mOperationType = operationType; mBackupDestination = backupDestination; } /** Loading Loading @@ -433,7 +432,7 @@ public abstract class BackupAgent extends ContextWrapper { */ public void onFullBackup(FullBackupDataOutput data) throws IOException { FullBackup.BackupScheme backupScheme = FullBackup.getBackupScheme(this, mOperationType); mBackupDestination); if (!backupScheme.isFullBackupEnabled(data.getTransportFlags())) { return; } Loading Loading @@ -643,7 +642,7 @@ public abstract class BackupAgent extends ContextWrapper { if (includeMap == null || includeMap.size() == 0) { // Do entire sub-tree for the provided token. fullBackupFileTree(packageName, domainToken, FullBackup.getBackupScheme(this, mOperationType) FullBackup.getBackupScheme(this, mBackupDestination) .tokenToDirectoryPath(domainToken), filterSet, traversalExcludeSet, data); } else if (includeMap.get(domainToken) != null) { Loading Loading @@ -815,7 +814,7 @@ public abstract class BackupAgent extends ContextWrapper { ArraySet<String> systemExcludes, FullBackupDataOutput output) { // Pull out the domain and set it aside to use when making the tarball. String domainPath = FullBackup.getBackupScheme(this, mOperationType) String domainPath = FullBackup.getBackupScheme(this, mBackupDestination) .tokenToDirectoryPath(domain); if (domainPath == null) { // Should never happen. Loading Loading @@ -927,7 +926,7 @@ public abstract class BackupAgent extends ContextWrapper { } private boolean isFileEligibleForRestore(File destination) throws IOException { FullBackup.BackupScheme bs = FullBackup.getBackupScheme(this, mOperationType); FullBackup.BackupScheme bs = FullBackup.getBackupScheme(this, mBackupDestination); if (!bs.isFullRestoreEnabled()) { if (Log.isLoggable(FullBackup.TAG_XML_PARSER, Log.VERBOSE)) { Log.v(FullBackup.TAG_XML_PARSER, Loading Loading @@ -1001,7 +1000,7 @@ public abstract class BackupAgent extends ContextWrapper { + " domain=" + domain + " relpath=" + path + " mode=" + mode + " mtime=" + mtime); basePath = FullBackup.getBackupScheme(this, mOperationType).tokenToDirectoryPath( basePath = FullBackup.getBackupScheme(this, mBackupDestination).tokenToDirectoryPath( domain); if (domain.equals(FullBackup.MANAGED_EXTERNAL_TREE_TOKEN)) { mode = -1; // < 0 is a token to skip attempting a chmod() Loading
core/java/android/app/backup/BackupAnnotations.java 0 → 100644 +60 −0 Original line number Diff line number Diff line /* * Copyright (C) 2022 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package android.app.backup; import android.annotation.IntDef; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; /** * Annotations related to Android Backup&Restore. * * @hide */ public class BackupAnnotations { /** @hide */ @Retention(RetentionPolicy.SOURCE) @IntDef({ OperationType.BACKUP, OperationType.RESTORE, }) public @interface OperationType { int BACKUP = 0; int RESTORE = 1; } /** * Denotes where the backup data is going (e.g. to the cloud or directly to the other device) * during backup or where it is coming from during restore. * * @hide */ @Retention(RetentionPolicy.SOURCE) @IntDef({ BackupDestination.CLOUD, BackupDestination.DEVICE_TRANSFER, BackupDestination.ADB_BACKUP }) public @interface BackupDestination { // A cloud backup. int CLOUD = 0; // A device to device migration. int DEVICE_TRANSFER = 1; // An adb backup. int ADB_BACKUP = 2; } }
core/java/android/app/backup/BackupManager.java +0 −16 Original line number Diff line number Diff line Loading @@ -200,22 +200,6 @@ public class BackupManager { @SystemApi public static final int ERROR_TRANSPORT_INVALID = -2; /** @hide */ @Retention(RetentionPolicy.SOURCE) @IntDef({ OperationType.BACKUP, OperationType.MIGRATION, OperationType.ADB_BACKUP, }) public @interface OperationType { // A backup / restore to / from an off-device location, e.g. cloud. int BACKUP = 0; // A direct transfer to another device. int MIGRATION = 1; // Backup via adb, data saved on the host machine. int ADB_BACKUP = 3; } private Context mContext; @UnsupportedAppUsage private static IBackupManager sService; Loading