diff options
Diffstat (limited to 'services/backup/java')
2 files changed, 80 insertions, 6 deletions
diff --git a/services/backup/java/com/android/server/backup/restore/PerformUnifiedRestoreTask.java b/services/backup/java/com/android/server/backup/restore/PerformUnifiedRestoreTask.java index 5c1007c17ba0..8fece8257b89 100644 --- a/services/backup/java/com/android/server/backup/restore/PerformUnifiedRestoreTask.java +++ b/services/backup/java/com/android/server/backup/restore/PerformUnifiedRestoreTask.java @@ -667,12 +667,23 @@ public class PerformUnifiedRestoreTask implements BackupRestoreTask { backupManagerService.getContext().getContentResolver(), Settings.Secure.V_TO_U_RESTORE_DENYLIST, mUserId)); + logVToUListsToBMM(); mAreVToUListsSet = true; } if (isPackageEligibleForVToURestore(mCurrentPackage)) { + mBackupManagerMonitorEventSender.monitorEvent( + BackupManagerMonitor.LOG_EVENT_ID_V_TO_U_RESTORE_PKG_ELIGIBLE, + mCurrentPackage, + BackupManagerMonitor.LOG_EVENT_CATEGORY_BACKUP_MANAGER_POLICY, + addRestoreOperationTypeToEvent(/* extras= */null)); Slog.i(TAG, "Package " + pkgName + " is eligible for V to U downgrade scenario"); } else { + mBackupManagerMonitorEventSender.monitorEvent( + BackupManagerMonitor.LOG_EVENT_ID_V_TO_U_RESTORE_PKG_NOT_ELIGIBLE, + mCurrentPackage, + BackupManagerMonitor.LOG_EVENT_CATEGORY_BACKUP_MANAGER_POLICY, + addRestoreOperationTypeToEvent(/* extras= */null)); String message = "Package not eligible for V to U downgrade scenario"; Slog.i(TAG, pkgName + " : " + message); EventLog.writeEvent(EventLogTags.RESTORE_AGENT_FAILURE, pkgName, message); @@ -1703,14 +1714,25 @@ public class PerformUnifiedRestoreTask implements BackupRestoreTask { // (and not in the denylist) // - The package has restoreAnyVersion set to true and is not part of the denylist if (mVToUDenylist.contains(mCurrentPackage.packageName)){ + if (DEBUG) { + Slog.i(TAG, mCurrentPackage.packageName + " : Package is in V to U denylist"); + } return false; } else if ((mCurrentPackage.applicationInfo.flags & ApplicationInfo.FLAG_RESTORE_ANY_VERSION) == 0) { // package has restoreAnyVersion set to false + if (DEBUG) { + Slog.i(TAG, mCurrentPackage.packageName + + " : Package has restoreAnyVersion=false and is in V to U allowlist"); + } return mVToUAllowlist.contains(mCurrentPackage.packageName); } else { // package has restoreAnyVersion set to true and is nor in denylist + if (DEBUG) { + Slog.i(TAG, mCurrentPackage.packageName + + " : Package has restoreAnyVersion=true and is not in V to U denylist"); + } return true; } } @@ -1755,4 +1777,31 @@ public class PerformUnifiedRestoreTask implements BackupRestoreTask { monitoringExtras); } + private void logVToUListsToBMM() { + // send a BMM event with the allowlist + Bundle monitoringExtrasAllowlist = + mBackupManagerMonitorEventSender.putMonitoringExtra( + null, + BackupManagerMonitor.EXTRA_LOG_V_TO_U_ALLOWLIST, + mVToUAllowlist.toString()); + monitoringExtrasAllowlist = addRestoreOperationTypeToEvent(monitoringExtrasAllowlist); + mBackupManagerMonitorEventSender.monitorEvent( + BackupManagerMonitor.LOG_EVENT_ID_V_TO_U_RESTORE_SET_LIST, + null, + BackupManagerMonitor.LOG_EVENT_CATEGORY_BACKUP_MANAGER_POLICY, + monitoringExtrasAllowlist); + // send a BMM event with the denylist + Bundle monitoringExtrasDenylist = + mBackupManagerMonitorEventSender.putMonitoringExtra( + null, + BackupManagerMonitor.EXTRA_LOG_V_TO_U_DENYLIST, + mVToUDenylist.toString()); + monitoringExtrasDenylist = addRestoreOperationTypeToEvent(monitoringExtrasDenylist); + mBackupManagerMonitorEventSender.monitorEvent( + BackupManagerMonitor.LOG_EVENT_ID_V_TO_U_RESTORE_SET_LIST, + null, + BackupManagerMonitor.LOG_EVENT_CATEGORY_BACKUP_MANAGER_POLICY, + monitoringExtrasDenylist); + } + } diff --git a/services/backup/java/com/android/server/backup/utils/BackupManagerMonitorDumpsysUtils.java b/services/backup/java/com/android/server/backup/utils/BackupManagerMonitorDumpsysUtils.java index 797aed9297a3..6d315ba38b31 100644 --- a/services/backup/java/com/android/server/backup/utils/BackupManagerMonitorDumpsysUtils.java +++ b/services/backup/java/com/android/server/backup/utils/BackupManagerMonitorDumpsysUtils.java @@ -146,7 +146,6 @@ public class BackupManagerMonitorDumpsysUtils { + eventBundle.getString(BackupManagerMonitor.EXTRA_LOG_EVENT_PACKAGE_NAME)); } - // TODO(b/296818666): add extras to the events addAgentLogsIfAvailable(eventBundle, pw); addExtrasIfAvailable(eventBundle, pw); } catch (java.io.IOException e) { @@ -203,6 +202,11 @@ public class BackupManagerMonitorDumpsysUtils { * EXTRA_LOG_RESTORE_VERSION [int]: the version of the package on the source * EXTRA_LOG_RESTORE_ANYWAY [bool]: if the package allows restore any version * EXTRA_LOG_RESTORE_VERSION_TARGET [int]: an extra to record the package version on the target + * + * When we are performing a V to U downgrade (event with id V_TO_U_RESTORE_SET_LIST) we record + * the value of the V to U allowlist and denylist: + * EXTRA_LOG_V_TO_U_ALLOWLIST[string] + * EXTRA_LOG_V_TO_U_DENYLIST[string] */ private void addExtrasIfAvailable(Bundle eventBundle, PrintWriter pw) { if (eventBundle.getInt(BackupManagerMonitor.EXTRA_LOG_EVENT_ID) == @@ -216,12 +220,29 @@ public class BackupManagerMonitorDumpsysUtils { + eventBundle.getLong(BackupManagerMonitor.EXTRA_LOG_RESTORE_VERSION)); } if (eventBundle.containsKey( - BackupManagerMonitor.EXTRA_LOG_EVENT_PACKAGE_LONG_VERSION)) { + BackupManagerMonitor.EXTRA_LOG_EVENT_PACKAGE_LONG_VERSION)) { pw.println("\t\tPackage version on target: " + eventBundle.getLong( BackupManagerMonitor.EXTRA_LOG_EVENT_PACKAGE_LONG_VERSION)); } } + + if (eventBundle.getInt(BackupManagerMonitor.EXTRA_LOG_EVENT_ID) + == BackupManagerMonitor.LOG_EVENT_ID_V_TO_U_RESTORE_SET_LIST) { + if (eventBundle.containsKey( + BackupManagerMonitor.EXTRA_LOG_V_TO_U_DENYLIST)) { + pw.println("\t\tV to U Denylist : " + + eventBundle.getString( + BackupManagerMonitor.EXTRA_LOG_V_TO_U_DENYLIST)); + } + + if (eventBundle.containsKey( + BackupManagerMonitor.EXTRA_LOG_V_TO_U_ALLOWLIST)) { + pw.println("\t\tV to U Allowllist : " + + eventBundle.getString( + BackupManagerMonitor.EXTRA_LOG_V_TO_U_ALLOWLIST)); + } + } } /* @@ -342,10 +363,14 @@ public class BackupManagerMonitorDumpsysUtils { case BackupManagerMonitor.LOG_EVENT_ID_TRANSPORT_ERROR_FULL_RESTORE -> "Transport error full restore"; case BackupManagerMonitor.LOG_EVENT_ID_RESTORE_COMPLETE -> "Restore complete"; - case BackupManagerMonitor.LOG_EVENT_ID_START_PACKAGE_RESTORE -> - "Start package restore"; - case BackupManagerMonitor.LOG_EVENT_ID_AGENT_FAILURE -> - "Agent failure"; + case BackupManagerMonitor.LOG_EVENT_ID_START_PACKAGE_RESTORE -> "Start package restore"; + case BackupManagerMonitor.LOG_EVENT_ID_AGENT_FAILURE -> "Agent failure"; + case BackupManagerMonitor.LOG_EVENT_ID_V_TO_U_RESTORE_PKG_ELIGIBLE -> + "V to U restore pkg eligible"; + case BackupManagerMonitor.LOG_EVENT_ID_V_TO_U_RESTORE_PKG_NOT_ELIGIBLE -> + "V to U restore pkg not eligible"; + case BackupManagerMonitor.LOG_EVENT_ID_V_TO_U_RESTORE_SET_LIST -> + "V to U restore lists"; default -> "Unknown log event ID: " + code; }; return id; |