summaryrefslogtreecommitdiff
path: root/services/backup/java
diff options
context:
space:
mode:
author Beatrice Marchegiani <beatricemarch@google.com> 2024-02-28 13:13:14 +0000
committer Beatrice Marchegiani <beatricemarch@google.com> 2024-02-29 17:47:25 +0000
commit8c06fe37dcf7b5a4914bf4f2cfaa066764895266 (patch)
tree0edbfe420644a34d0ab79a3cd7e7ebcf67f066d0 /services/backup/java
parente8deecf6a9cad1f0e17add7b7f0e7be0d2e65d28 (diff)
Add BMM events to V to U restore
Add logs so that we can record the V to U scenario in the backup dumpsys and in clearcut We only print the allowlist/denylist once in the backup dumpsys (at the beginning of system restore) Test: manual (check that the VtoU events appear in the dumpsys - See for an example: https://paste.googleplex.com/4697312460275712#), atest PerformUnifiedRestoreTaskTest, atest BackupManagerMonitorUtilsTest Bug: 324233962 Change-Id: I07c483b80093037e36076bc174ef6d9484f01d65
Diffstat (limited to 'services/backup/java')
-rw-r--r--services/backup/java/com/android/server/backup/restore/PerformUnifiedRestoreTask.java49
-rw-r--r--services/backup/java/com/android/server/backup/utils/BackupManagerMonitorDumpsysUtils.java37
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;