diff options
author | Ruslan Tkhakokhov <rthakohov@google.com> | 2020-03-18 15:09:49 +0000 |
---|---|---|
committer | Ruslan Tkhakokhov <rthakohov@google.com> | 2020-03-18 23:22:11 +0000 |
commit | 0b97fbdb309519d5776041c9fc98cb7a06ba7be0 (patch) | |
tree | 3e76de1e86b825083135bbb663caa10f90e646d1 /packages/WallpaperBackup | |
parent | 91604c213897f6349e49943efb6d1f7b311d3feb (diff) |
Log important events in WallpaperBackupAgent
Bug: 151817908
Test: atest WallpaperBackupAgentTest
In most situations logs are either missing or under 'DEBUG' flag. Log
important events uncoditionally.
Change-Id: I6a7f772336b364839e2cb38f23b2ef26d0bd0cd6
Diffstat (limited to 'packages/WallpaperBackup')
-rw-r--r-- | packages/WallpaperBackup/src/com/android/wallpaperbackup/WallpaperBackupAgent.java | 39 |
1 files changed, 22 insertions, 17 deletions
diff --git a/packages/WallpaperBackup/src/com/android/wallpaperbackup/WallpaperBackupAgent.java b/packages/WallpaperBackup/src/com/android/wallpaperbackup/WallpaperBackupAgent.java index 8a4a1c666c3c..93bffe9f54e4 100644 --- a/packages/WallpaperBackup/src/com/android/wallpaperbackup/WallpaperBackupAgent.java +++ b/packages/WallpaperBackup/src/com/android/wallpaperbackup/WallpaperBackupAgent.java @@ -164,6 +164,9 @@ public class WallpaperBackupAgent extends BackupAgent { } if (DEBUG) Slog.v(TAG, "Storing wallpaper metadata"); backupFile(infoStage, data); + } else { + Slog.w(TAG, "Wallpaper metadata file doesn't exist: " + + mWallpaperFile.getPath()); } if (sysEligible && mWallpaperFile.exists()) { if (sysChanged || !imageStage.exists()) { @@ -173,6 +176,10 @@ public class WallpaperBackupAgent extends BackupAgent { if (DEBUG) Slog.v(TAG, "Storing system wallpaper image"); backupFile(imageStage, data); prefs.edit().putInt(SYSTEM_GENERATION, sysGeneration).apply(); + } else { + Slog.w(TAG, "Not backing up wallpaper as one of conditions is not " + + "met: sysEligible = " + sysEligible + " wallpaperFileExists = " + + mWallpaperFile.exists()); } // If there's no lock wallpaper, then we have nothing to add to the backup. @@ -181,7 +188,7 @@ public class WallpaperBackupAgent extends BackupAgent { if (DEBUG) Slog.v(TAG, "Removed lock wallpaper; deleting"); lockImageStage.delete(); } - if (DEBUG) Slog.v(TAG, "No lock paper set, add nothing to backup"); + Slog.d(TAG, "No lockscreen wallpaper set, add nothing to backup"); prefs.edit().putInt(LOCK_GENERATION, lockGeneration).apply(); return; } @@ -195,6 +202,12 @@ public class WallpaperBackupAgent extends BackupAgent { if (DEBUG) Slog.v(TAG, "Storing lock wallpaper image"); backupFile(lockImageStage, data); prefs.edit().putInt(LOCK_GENERATION, lockGeneration).apply(); + } else { + Slog.w(TAG, "Not backing up lockscreen wallpaper as one of conditions is not " + + "met: lockEligible = " + lockEligible + " hasLockWallpaper = " + + hasLockWallpaper + " lockWallpaperFileExists = " + + mLockWallpaperFile.exists() + " quotaExceeded (last time) = " + + mQuotaExceeded); } } catch (Exception e) { Slog.e(TAG, "Unable to back up wallpaper", e); @@ -216,9 +229,7 @@ public class WallpaperBackupAgent extends BackupAgent { @Override public void onQuotaExceeded(long backupDataBytes, long quotaBytes) { - if (DEBUG) { - Slog.i(TAG, "Quota exceeded (" + backupDataBytes + " vs " + quotaBytes + ')'); - } + Slog.i(TAG, "Quota exceeded (" + backupDataBytes + " vs " + quotaBytes + ')'); try (FileOutputStream f = new FileOutputStream(mQuotaFile)) { f.write(0); } catch (Exception e) { @@ -230,9 +241,7 @@ public class WallpaperBackupAgent extends BackupAgent { // then post-process in onRestoreFinished() to apply the new wallpaper. @Override public void onRestoreFinished() { - if (DEBUG) { - Slog.v(TAG, "onRestoreFinished()"); - } + Slog.v(TAG, "onRestoreFinished()"); final File filesDir = getFilesDir(); final File infoStage = new File(filesDir, INFO_STAGE); final File imageStage = new File (filesDir, IMAGE_STAGE); @@ -253,9 +262,7 @@ public class WallpaperBackupAgent extends BackupAgent { // And reset to the wallpaper service we should be using ComponentName wpService = parseWallpaperComponent(infoStage, "wp"); if (servicePackageExists(wpService)) { - if (DEBUG) { - Slog.i(TAG, "Using wallpaper service " + wpService); - } + Slog.i(TAG, "Using wallpaper service " + wpService); mWm.setWallpaperComponent(wpService, UserHandle.USER_SYSTEM); if (!lockImageStage.exists()) { // We have a live wallpaper and no static lock image, @@ -273,9 +280,7 @@ public class WallpaperBackupAgent extends BackupAgent { } catch (Exception e) { Slog.e(TAG, "Unable to restore wallpaper: " + e.getMessage()); } finally { - if (DEBUG) { - Slog.v(TAG, "Restore finished; clearing backup bookkeeping"); - } + Slog.v(TAG, "Restore finished; clearing backup bookkeeping"); infoStage.delete(); imageStage.delete(); lockImageStage.delete(); @@ -295,14 +300,14 @@ public class WallpaperBackupAgent extends BackupAgent { // relies on a priori knowledge of the wallpaper info file schema. Rect cropHint = parseCropHint(info, hintTag); if (cropHint != null) { - Slog.i(TAG, "Got restored wallpaper; applying which=" + which); - if (DEBUG) { - Slog.v(TAG, "Restored crop hint " + cropHint); - } + Slog.i(TAG, "Got restored wallpaper; applying which=" + which + + "; cropHint = " + cropHint); try (FileInputStream in = new FileInputStream(stage)) { mWm.setStream(in, cropHint.isEmpty() ? null : cropHint, true, which); } finally {} // auto-closes 'in' } + } else { + Slog.d(TAG, "Restore data doesn't exist for file " + stage.getPath()); } } |