Loading services/backup/java/com/android/server/backup/BackupAgentTimeoutParameters.java +41 −2 Original line number Original line Diff line number Diff line Loading @@ -19,6 +19,7 @@ package com.android.server.backup; import android.content.ContentResolver; import android.content.ContentResolver; import android.os.Handler; import android.os.Handler; import android.os.UserHandle; import android.provider.Settings; import android.provider.Settings; import android.util.KeyValueListParser; import android.util.KeyValueListParser; import android.util.KeyValueSettingObserver; import android.util.KeyValueSettingObserver; Loading Loading @@ -52,10 +53,18 @@ public class BackupAgentTimeoutParameters extends KeyValueSettingObserver { public static final String SETTING_RESTORE_AGENT_TIMEOUT_MILLIS = public static final String SETTING_RESTORE_AGENT_TIMEOUT_MILLIS = "restore_agent_timeout_millis"; "restore_agent_timeout_millis"; @VisibleForTesting public static final String SETTING_RESTORE_SYSTEM_AGENT_TIMEOUT_MILLIS = "restore_system_agent_timeout_millis"; @VisibleForTesting @VisibleForTesting public static final String SETTING_RESTORE_AGENT_FINISHED_TIMEOUT_MILLIS = public static final String SETTING_RESTORE_AGENT_FINISHED_TIMEOUT_MILLIS = "restore_agent_finished_timeout_millis"; "restore_agent_finished_timeout_millis"; @VisibleForTesting public static final String SETTING_RESTORE_SESSION_TIMEOUT_MILLIS = "restore_session_timeout_millis"; @VisibleForTesting @VisibleForTesting public static final String SETTING_QUOTA_EXCEEDED_TIMEOUT_MILLIS = public static final String SETTING_QUOTA_EXCEEDED_TIMEOUT_MILLIS = "quota_exceeded_timeout_millis"; "quota_exceeded_timeout_millis"; Loading @@ -71,9 +80,14 @@ public class BackupAgentTimeoutParameters extends KeyValueSettingObserver { @VisibleForTesting public static final long DEFAULT_RESTORE_AGENT_TIMEOUT_MILLIS = 60 * 1000; @VisibleForTesting public static final long DEFAULT_RESTORE_AGENT_TIMEOUT_MILLIS = 60 * 1000; @VisibleForTesting public static final long DEFAULT_RESTORE_SYSTEM_AGENT_TIMEOUT_MILLIS = 180 * 1000; @VisibleForTesting @VisibleForTesting public static final long DEFAULT_RESTORE_AGENT_FINISHED_TIMEOUT_MILLIS = 30 * 1000; public static final long DEFAULT_RESTORE_AGENT_FINISHED_TIMEOUT_MILLIS = 30 * 1000; @VisibleForTesting public static final long DEFAULT_RESTORE_SESSION_TIMEOUT_MILLIS = 60 * 1000; @VisibleForTesting @VisibleForTesting public static final long DEFAULT_QUOTA_EXCEEDED_TIMEOUT_MILLIS = 3 * 1000; public static final long DEFAULT_QUOTA_EXCEEDED_TIMEOUT_MILLIS = 3 * 1000; Loading @@ -89,6 +103,12 @@ public class BackupAgentTimeoutParameters extends KeyValueSettingObserver { @GuardedBy("mLock") @GuardedBy("mLock") private long mRestoreAgentTimeoutMillis; private long mRestoreAgentTimeoutMillis; @GuardedBy("mLock") private long mRestoreSystemAgentTimeoutMillis; @GuardedBy("mLock") private long mRestoreSessionTimeoutMillis; @GuardedBy("mLock") @GuardedBy("mLock") private long mRestoreAgentFinishedTimeoutMillis; private long mRestoreAgentFinishedTimeoutMillis; Loading Loading @@ -123,10 +143,18 @@ public class BackupAgentTimeoutParameters extends KeyValueSettingObserver { parser.getLong( parser.getLong( SETTING_RESTORE_AGENT_TIMEOUT_MILLIS, SETTING_RESTORE_AGENT_TIMEOUT_MILLIS, DEFAULT_RESTORE_AGENT_TIMEOUT_MILLIS); DEFAULT_RESTORE_AGENT_TIMEOUT_MILLIS); mRestoreSystemAgentTimeoutMillis = parser.getLong( SETTING_RESTORE_SYSTEM_AGENT_TIMEOUT_MILLIS, DEFAULT_RESTORE_SYSTEM_AGENT_TIMEOUT_MILLIS); mRestoreAgentFinishedTimeoutMillis = mRestoreAgentFinishedTimeoutMillis = parser.getLong( parser.getLong( SETTING_RESTORE_AGENT_FINISHED_TIMEOUT_MILLIS, SETTING_RESTORE_AGENT_FINISHED_TIMEOUT_MILLIS, DEFAULT_RESTORE_AGENT_FINISHED_TIMEOUT_MILLIS); DEFAULT_RESTORE_AGENT_FINISHED_TIMEOUT_MILLIS); mRestoreSessionTimeoutMillis = parser.getLong( SETTING_RESTORE_SESSION_TIMEOUT_MILLIS, DEFAULT_RESTORE_SESSION_TIMEOUT_MILLIS); mQuotaExceededTimeoutMillis = mQuotaExceededTimeoutMillis = parser.getLong( parser.getLong( SETTING_QUOTA_EXCEEDED_TIMEOUT_MILLIS, SETTING_QUOTA_EXCEEDED_TIMEOUT_MILLIS, Loading @@ -152,9 +180,20 @@ public class BackupAgentTimeoutParameters extends KeyValueSettingObserver { } } } } public long getRestoreAgentTimeoutMillis() { /** * @param applicationUid UID of the application for which to get restore timeout * @return restore timeout in milliseconds */ public long getRestoreAgentTimeoutMillis(int applicationUid) { synchronized (mLock) { return UserHandle.isCore(applicationUid) ? mRestoreSystemAgentTimeoutMillis : mRestoreAgentTimeoutMillis; } } public long getRestoreSessionTimeoutMillis() { synchronized (mLock) { synchronized (mLock) { return mRestoreAgentTimeoutMillis; return mRestoreSessionTimeoutMillis; } } } } Loading services/backup/java/com/android/server/backup/UserBackupManagerService.java +1 −1 Original line number Original line Diff line number Diff line Loading @@ -4088,7 +4088,7 @@ public class UserBackupManagerService { mActiveRestoreSession = new ActiveRestoreSession(this, packageName, transport, mActiveRestoreSession = new ActiveRestoreSession(this, packageName, transport, getEligibilityRulesForOperation(operationType)); getEligibilityRulesForOperation(operationType)); mBackupHandler.sendEmptyMessageDelayed(MSG_RESTORE_SESSION_TIMEOUT, mBackupHandler.sendEmptyMessageDelayed(MSG_RESTORE_SESSION_TIMEOUT, mAgentTimeoutParameters.getRestoreAgentTimeoutMillis()); mAgentTimeoutParameters.getRestoreSessionTimeoutMillis()); } } return mActiveRestoreSession; return mActiveRestoreSession; } } Loading services/backup/java/com/android/server/backup/internal/BackupHandler.java +1 −1 Original line number Original line Diff line number Diff line Loading @@ -390,7 +390,7 @@ public class BackupHandler extends Handler { // Done: reset the session timeout clock // Done: reset the session timeout clock removeMessages(MSG_RESTORE_SESSION_TIMEOUT); removeMessages(MSG_RESTORE_SESSION_TIMEOUT); sendEmptyMessageDelayed(MSG_RESTORE_SESSION_TIMEOUT, sendEmptyMessageDelayed(MSG_RESTORE_SESSION_TIMEOUT, mAgentTimeoutParameters.getRestoreAgentTimeoutMillis()); mAgentTimeoutParameters.getRestoreSessionTimeoutMillis()); params.listener.onFinished(callerLogString); params.listener.onFinished(callerLogString); } } Loading services/backup/java/com/android/server/backup/restore/FullRestoreEngine.java +2 −1 Original line number Original line Diff line number Diff line Loading @@ -403,7 +403,8 @@ public class FullRestoreEngine extends RestoreEngine { final boolean isSharedStorage = pkg.equals(SHARED_BACKUP_AGENT_PACKAGE); final boolean isSharedStorage = pkg.equals(SHARED_BACKUP_AGENT_PACKAGE); final long timeout = isSharedStorage ? final long timeout = isSharedStorage ? mAgentTimeoutParameters.getSharedBackupAgentTimeoutMillis() : mAgentTimeoutParameters.getSharedBackupAgentTimeoutMillis() : mAgentTimeoutParameters.getRestoreAgentTimeoutMillis(); mAgentTimeoutParameters.getRestoreAgentTimeoutMillis( mTargetApp.uid); try { try { mBackupManagerService.prepareOperationTimeout(token, mBackupManagerService.prepareOperationTimeout(token, timeout, timeout, Loading services/backup/java/com/android/server/backup/restore/PerformUnifiedRestoreTask.java +7 −2 Original line number Original line Diff line number Diff line Loading @@ -46,6 +46,7 @@ import android.content.pm.PackageManagerInternal; import android.os.Bundle; import android.os.Bundle; import android.os.Message; import android.os.Message; import android.os.ParcelFileDescriptor; import android.os.ParcelFileDescriptor; import android.os.Process; import android.os.RemoteException; import android.os.RemoteException; import android.os.SystemClock; import android.os.SystemClock; import android.os.UserHandle; import android.os.UserHandle; Loading Loading @@ -433,6 +434,8 @@ public class PerformUnifiedRestoreTask implements BackupRestoreTask { // Pull the Package Manager metadata from the restore set first // Pull the Package Manager metadata from the restore set first mCurrentPackage = new PackageInfo(); mCurrentPackage = new PackageInfo(); mCurrentPackage.packageName = PACKAGE_MANAGER_SENTINEL; mCurrentPackage.packageName = PACKAGE_MANAGER_SENTINEL; mCurrentPackage.applicationInfo = new ApplicationInfo(); mCurrentPackage.applicationInfo.uid = Process.SYSTEM_UID; mPmAgent = backupManagerService.makeMetadataAgent(null); mPmAgent = backupManagerService.makeMetadataAgent(null); mAgent = IBackupAgent.Stub.asInterface(mPmAgent.onBind()); mAgent = IBackupAgent.Stub.asInterface(mPmAgent.onBind()); if (MORE_DEBUG) { if (MORE_DEBUG) { Loading Loading @@ -760,7 +763,8 @@ public class PerformUnifiedRestoreTask implements BackupRestoreTask { // Kick off the restore, checking for hung agents. The timeout or // Kick off the restore, checking for hung agents. The timeout or // the operationComplete() callback will schedule the next step, // the operationComplete() callback will schedule the next step, // so we do not do that here. // so we do not do that here. long restoreAgentTimeoutMillis = mAgentTimeoutParameters.getRestoreAgentTimeoutMillis(); long restoreAgentTimeoutMillis = mAgentTimeoutParameters.getRestoreAgentTimeoutMillis( app.applicationInfo.uid); backupManagerService.prepareOperationTimeout( backupManagerService.prepareOperationTimeout( mEphemeralOpToken, restoreAgentTimeoutMillis, this, OP_TYPE_RESTORE_WAIT); mEphemeralOpToken, restoreAgentTimeoutMillis, this, OP_TYPE_RESTORE_WAIT); startedAgentRestore = true; startedAgentRestore = true; Loading Loading @@ -1122,7 +1126,8 @@ public class PerformUnifiedRestoreTask implements BackupRestoreTask { } else { } else { // We were invoked via an active restore session, not by the Package // We were invoked via an active restore session, not by the Package // Manager, so start up the session timeout again. // Manager, so start up the session timeout again. long restoreAgentTimeoutMillis = mAgentTimeoutParameters.getRestoreAgentTimeoutMillis(); long restoreAgentTimeoutMillis = mAgentTimeoutParameters.getRestoreSessionTimeoutMillis(); backupManagerService.getBackupHandler().sendEmptyMessageDelayed( backupManagerService.getBackupHandler().sendEmptyMessageDelayed( MSG_RESTORE_SESSION_TIMEOUT, MSG_RESTORE_SESSION_TIMEOUT, restoreAgentTimeoutMillis); restoreAgentTimeoutMillis); Loading Loading
services/backup/java/com/android/server/backup/BackupAgentTimeoutParameters.java +41 −2 Original line number Original line Diff line number Diff line Loading @@ -19,6 +19,7 @@ package com.android.server.backup; import android.content.ContentResolver; import android.content.ContentResolver; import android.os.Handler; import android.os.Handler; import android.os.UserHandle; import android.provider.Settings; import android.provider.Settings; import android.util.KeyValueListParser; import android.util.KeyValueListParser; import android.util.KeyValueSettingObserver; import android.util.KeyValueSettingObserver; Loading Loading @@ -52,10 +53,18 @@ public class BackupAgentTimeoutParameters extends KeyValueSettingObserver { public static final String SETTING_RESTORE_AGENT_TIMEOUT_MILLIS = public static final String SETTING_RESTORE_AGENT_TIMEOUT_MILLIS = "restore_agent_timeout_millis"; "restore_agent_timeout_millis"; @VisibleForTesting public static final String SETTING_RESTORE_SYSTEM_AGENT_TIMEOUT_MILLIS = "restore_system_agent_timeout_millis"; @VisibleForTesting @VisibleForTesting public static final String SETTING_RESTORE_AGENT_FINISHED_TIMEOUT_MILLIS = public static final String SETTING_RESTORE_AGENT_FINISHED_TIMEOUT_MILLIS = "restore_agent_finished_timeout_millis"; "restore_agent_finished_timeout_millis"; @VisibleForTesting public static final String SETTING_RESTORE_SESSION_TIMEOUT_MILLIS = "restore_session_timeout_millis"; @VisibleForTesting @VisibleForTesting public static final String SETTING_QUOTA_EXCEEDED_TIMEOUT_MILLIS = public static final String SETTING_QUOTA_EXCEEDED_TIMEOUT_MILLIS = "quota_exceeded_timeout_millis"; "quota_exceeded_timeout_millis"; Loading @@ -71,9 +80,14 @@ public class BackupAgentTimeoutParameters extends KeyValueSettingObserver { @VisibleForTesting public static final long DEFAULT_RESTORE_AGENT_TIMEOUT_MILLIS = 60 * 1000; @VisibleForTesting public static final long DEFAULT_RESTORE_AGENT_TIMEOUT_MILLIS = 60 * 1000; @VisibleForTesting public static final long DEFAULT_RESTORE_SYSTEM_AGENT_TIMEOUT_MILLIS = 180 * 1000; @VisibleForTesting @VisibleForTesting public static final long DEFAULT_RESTORE_AGENT_FINISHED_TIMEOUT_MILLIS = 30 * 1000; public static final long DEFAULT_RESTORE_AGENT_FINISHED_TIMEOUT_MILLIS = 30 * 1000; @VisibleForTesting public static final long DEFAULT_RESTORE_SESSION_TIMEOUT_MILLIS = 60 * 1000; @VisibleForTesting @VisibleForTesting public static final long DEFAULT_QUOTA_EXCEEDED_TIMEOUT_MILLIS = 3 * 1000; public static final long DEFAULT_QUOTA_EXCEEDED_TIMEOUT_MILLIS = 3 * 1000; Loading @@ -89,6 +103,12 @@ public class BackupAgentTimeoutParameters extends KeyValueSettingObserver { @GuardedBy("mLock") @GuardedBy("mLock") private long mRestoreAgentTimeoutMillis; private long mRestoreAgentTimeoutMillis; @GuardedBy("mLock") private long mRestoreSystemAgentTimeoutMillis; @GuardedBy("mLock") private long mRestoreSessionTimeoutMillis; @GuardedBy("mLock") @GuardedBy("mLock") private long mRestoreAgentFinishedTimeoutMillis; private long mRestoreAgentFinishedTimeoutMillis; Loading Loading @@ -123,10 +143,18 @@ public class BackupAgentTimeoutParameters extends KeyValueSettingObserver { parser.getLong( parser.getLong( SETTING_RESTORE_AGENT_TIMEOUT_MILLIS, SETTING_RESTORE_AGENT_TIMEOUT_MILLIS, DEFAULT_RESTORE_AGENT_TIMEOUT_MILLIS); DEFAULT_RESTORE_AGENT_TIMEOUT_MILLIS); mRestoreSystemAgentTimeoutMillis = parser.getLong( SETTING_RESTORE_SYSTEM_AGENT_TIMEOUT_MILLIS, DEFAULT_RESTORE_SYSTEM_AGENT_TIMEOUT_MILLIS); mRestoreAgentFinishedTimeoutMillis = mRestoreAgentFinishedTimeoutMillis = parser.getLong( parser.getLong( SETTING_RESTORE_AGENT_FINISHED_TIMEOUT_MILLIS, SETTING_RESTORE_AGENT_FINISHED_TIMEOUT_MILLIS, DEFAULT_RESTORE_AGENT_FINISHED_TIMEOUT_MILLIS); DEFAULT_RESTORE_AGENT_FINISHED_TIMEOUT_MILLIS); mRestoreSessionTimeoutMillis = parser.getLong( SETTING_RESTORE_SESSION_TIMEOUT_MILLIS, DEFAULT_RESTORE_SESSION_TIMEOUT_MILLIS); mQuotaExceededTimeoutMillis = mQuotaExceededTimeoutMillis = parser.getLong( parser.getLong( SETTING_QUOTA_EXCEEDED_TIMEOUT_MILLIS, SETTING_QUOTA_EXCEEDED_TIMEOUT_MILLIS, Loading @@ -152,9 +180,20 @@ public class BackupAgentTimeoutParameters extends KeyValueSettingObserver { } } } } public long getRestoreAgentTimeoutMillis() { /** * @param applicationUid UID of the application for which to get restore timeout * @return restore timeout in milliseconds */ public long getRestoreAgentTimeoutMillis(int applicationUid) { synchronized (mLock) { return UserHandle.isCore(applicationUid) ? mRestoreSystemAgentTimeoutMillis : mRestoreAgentTimeoutMillis; } } public long getRestoreSessionTimeoutMillis() { synchronized (mLock) { synchronized (mLock) { return mRestoreAgentTimeoutMillis; return mRestoreSessionTimeoutMillis; } } } } Loading
services/backup/java/com/android/server/backup/UserBackupManagerService.java +1 −1 Original line number Original line Diff line number Diff line Loading @@ -4088,7 +4088,7 @@ public class UserBackupManagerService { mActiveRestoreSession = new ActiveRestoreSession(this, packageName, transport, mActiveRestoreSession = new ActiveRestoreSession(this, packageName, transport, getEligibilityRulesForOperation(operationType)); getEligibilityRulesForOperation(operationType)); mBackupHandler.sendEmptyMessageDelayed(MSG_RESTORE_SESSION_TIMEOUT, mBackupHandler.sendEmptyMessageDelayed(MSG_RESTORE_SESSION_TIMEOUT, mAgentTimeoutParameters.getRestoreAgentTimeoutMillis()); mAgentTimeoutParameters.getRestoreSessionTimeoutMillis()); } } return mActiveRestoreSession; return mActiveRestoreSession; } } Loading
services/backup/java/com/android/server/backup/internal/BackupHandler.java +1 −1 Original line number Original line Diff line number Diff line Loading @@ -390,7 +390,7 @@ public class BackupHandler extends Handler { // Done: reset the session timeout clock // Done: reset the session timeout clock removeMessages(MSG_RESTORE_SESSION_TIMEOUT); removeMessages(MSG_RESTORE_SESSION_TIMEOUT); sendEmptyMessageDelayed(MSG_RESTORE_SESSION_TIMEOUT, sendEmptyMessageDelayed(MSG_RESTORE_SESSION_TIMEOUT, mAgentTimeoutParameters.getRestoreAgentTimeoutMillis()); mAgentTimeoutParameters.getRestoreSessionTimeoutMillis()); params.listener.onFinished(callerLogString); params.listener.onFinished(callerLogString); } } Loading
services/backup/java/com/android/server/backup/restore/FullRestoreEngine.java +2 −1 Original line number Original line Diff line number Diff line Loading @@ -403,7 +403,8 @@ public class FullRestoreEngine extends RestoreEngine { final boolean isSharedStorage = pkg.equals(SHARED_BACKUP_AGENT_PACKAGE); final boolean isSharedStorage = pkg.equals(SHARED_BACKUP_AGENT_PACKAGE); final long timeout = isSharedStorage ? final long timeout = isSharedStorage ? mAgentTimeoutParameters.getSharedBackupAgentTimeoutMillis() : mAgentTimeoutParameters.getSharedBackupAgentTimeoutMillis() : mAgentTimeoutParameters.getRestoreAgentTimeoutMillis(); mAgentTimeoutParameters.getRestoreAgentTimeoutMillis( mTargetApp.uid); try { try { mBackupManagerService.prepareOperationTimeout(token, mBackupManagerService.prepareOperationTimeout(token, timeout, timeout, Loading
services/backup/java/com/android/server/backup/restore/PerformUnifiedRestoreTask.java +7 −2 Original line number Original line Diff line number Diff line Loading @@ -46,6 +46,7 @@ import android.content.pm.PackageManagerInternal; import android.os.Bundle; import android.os.Bundle; import android.os.Message; import android.os.Message; import android.os.ParcelFileDescriptor; import android.os.ParcelFileDescriptor; import android.os.Process; import android.os.RemoteException; import android.os.RemoteException; import android.os.SystemClock; import android.os.SystemClock; import android.os.UserHandle; import android.os.UserHandle; Loading Loading @@ -433,6 +434,8 @@ public class PerformUnifiedRestoreTask implements BackupRestoreTask { // Pull the Package Manager metadata from the restore set first // Pull the Package Manager metadata from the restore set first mCurrentPackage = new PackageInfo(); mCurrentPackage = new PackageInfo(); mCurrentPackage.packageName = PACKAGE_MANAGER_SENTINEL; mCurrentPackage.packageName = PACKAGE_MANAGER_SENTINEL; mCurrentPackage.applicationInfo = new ApplicationInfo(); mCurrentPackage.applicationInfo.uid = Process.SYSTEM_UID; mPmAgent = backupManagerService.makeMetadataAgent(null); mPmAgent = backupManagerService.makeMetadataAgent(null); mAgent = IBackupAgent.Stub.asInterface(mPmAgent.onBind()); mAgent = IBackupAgent.Stub.asInterface(mPmAgent.onBind()); if (MORE_DEBUG) { if (MORE_DEBUG) { Loading Loading @@ -760,7 +763,8 @@ public class PerformUnifiedRestoreTask implements BackupRestoreTask { // Kick off the restore, checking for hung agents. The timeout or // Kick off the restore, checking for hung agents. The timeout or // the operationComplete() callback will schedule the next step, // the operationComplete() callback will schedule the next step, // so we do not do that here. // so we do not do that here. long restoreAgentTimeoutMillis = mAgentTimeoutParameters.getRestoreAgentTimeoutMillis(); long restoreAgentTimeoutMillis = mAgentTimeoutParameters.getRestoreAgentTimeoutMillis( app.applicationInfo.uid); backupManagerService.prepareOperationTimeout( backupManagerService.prepareOperationTimeout( mEphemeralOpToken, restoreAgentTimeoutMillis, this, OP_TYPE_RESTORE_WAIT); mEphemeralOpToken, restoreAgentTimeoutMillis, this, OP_TYPE_RESTORE_WAIT); startedAgentRestore = true; startedAgentRestore = true; Loading Loading @@ -1122,7 +1126,8 @@ public class PerformUnifiedRestoreTask implements BackupRestoreTask { } else { } else { // We were invoked via an active restore session, not by the Package // We were invoked via an active restore session, not by the Package // Manager, so start up the session timeout again. // Manager, so start up the session timeout again. long restoreAgentTimeoutMillis = mAgentTimeoutParameters.getRestoreAgentTimeoutMillis(); long restoreAgentTimeoutMillis = mAgentTimeoutParameters.getRestoreSessionTimeoutMillis(); backupManagerService.getBackupHandler().sendEmptyMessageDelayed( backupManagerService.getBackupHandler().sendEmptyMessageDelayed( MSG_RESTORE_SESSION_TIMEOUT, MSG_RESTORE_SESSION_TIMEOUT, restoreAgentTimeoutMillis); restoreAgentTimeoutMillis); Loading