Loading core/java/android/app/IWallpaperManager.aidl +1 −1 Original line number Diff line number Diff line Loading @@ -128,7 +128,7 @@ interface IWallpaperManager { /* * Backup: is the current system wallpaper image eligible for off-device backup? */ boolean isWallpaperBackupEligible(int userId); boolean isWallpaperBackupEligible(int which, int userId); /* * Keyguard: register a callback for being notified that lock-state relevant Loading core/java/android/app/WallpaperManager.java +2 −2 Original line number Diff line number Diff line Loading @@ -1680,13 +1680,13 @@ public class WallpaperManager { * Only the OS itself may use this method. * @hide */ public boolean isWallpaperBackupEligible() { public boolean isWallpaperBackupEligible(int which) { if (sGlobals.mService == null) { Log.w(TAG, "WallpaperService not running"); throw new RuntimeException(new DeadSystemException()); } try { return sGlobals.mService.isWallpaperBackupEligible(mContext.getUserId()); return sGlobals.mService.isWallpaperBackupEligible(which, mContext.getUserId()); } catch (RemoteException e) { Log.e(TAG, "Exception querying wallpaper backup eligibility: " + e.getMessage()); } Loading packages/WallpaperBackup/src/com/android/wallpaperbackup/WallpaperBackupAgent.java +39 −44 Original line number Diff line number Diff line Loading @@ -114,12 +114,6 @@ public class WallpaperBackupAgent extends BackupAgent { touch.close(); fullBackupFile(empty, data); // only back up the wallpaper if we've been told it's allowed if (mWm.isWallpaperBackupEligible()) { if (DEBUG) { Slog.v(TAG, "Wallpaper is backup-eligible"); } SharedPreferences prefs = getSharedPreferences(PREFS_NAME, Context.MODE_PRIVATE); final int lastSysGeneration = prefs.getInt(SYSTEM_GENERATION, -1); final int lastLockGeneration = prefs.getInt(LOCK_GENERATION, -1); Loading @@ -131,6 +125,9 @@ public class WallpaperBackupAgent extends BackupAgent { final boolean sysChanged = (sysGeneration != lastSysGeneration); final boolean lockChanged = (lockGeneration != lastLockGeneration); final boolean sysEligible = mWm.isWallpaperBackupEligible(FLAG_SYSTEM); final boolean lockEligible = mWm.isWallpaperBackupEligible(FLAG_LOCK); // There might be a latent lock wallpaper file present but unused: don't // include it in the backup if that's the case. ParcelFileDescriptor lockFd = mWm.getWallpaperFile(FLAG_LOCK, UserHandle.USER_SYSTEM); Loading @@ -140,16 +137,19 @@ public class WallpaperBackupAgent extends BackupAgent { if (DEBUG) { Slog.v(TAG, "sysGen=" + sysGeneration + " : sysChanged=" + sysChanged); Slog.v(TAG, "lockGen=" + lockGeneration + " : lockChanged=" + lockChanged); Slog.v(TAG, "hasLockWallpaper=" + hasLockWallpaper); Slog.v(TAG, "sysEligble=" + sysEligible); Slog.v(TAG, "lockEligible=" + lockEligible); } if (mWallpaperInfo.exists()) { // only back up the wallpapers if we've been told they're eligible if ((sysEligible || lockEligible) && mWallpaperInfo.exists()) { if (sysChanged || lockChanged || !infoStage.exists()) { if (DEBUG) Slog.v(TAG, "New wallpaper configuration; copying"); FileUtils.copyFileOrThrow(mWallpaperInfo, infoStage); } fullBackupFile(infoStage, data); } if (mWallpaperFile.exists()) { if (sysEligible && mWallpaperFile.exists()) { if (sysChanged || !imageStage.exists()) { if (DEBUG) Slog.v(TAG, "New system wallpaper; copying"); FileUtils.copyFileOrThrow(mWallpaperFile, imageStage); Loading @@ -159,7 +159,7 @@ public class WallpaperBackupAgent extends BackupAgent { } // Don't try to store the lock image if we overran our quota last time if (hasLockWallpaper && mLockWallpaperFile.exists() && !mQuotaExceeded) { if (lockEligible && hasLockWallpaper && mLockWallpaperFile.exists() && !mQuotaExceeded) { if (lockChanged || !lockImageStage.exists()) { if (DEBUG) Slog.v(TAG, "New lock wallpaper; copying"); FileUtils.copyFileOrThrow(mLockWallpaperFile, lockImageStage); Loading @@ -167,11 +167,6 @@ public class WallpaperBackupAgent extends BackupAgent { fullBackupFile(lockImageStage, data); prefs.edit().putInt(LOCK_GENERATION, lockGeneration).apply(); } } else { if (DEBUG) { Slog.v(TAG, "Wallpaper not backup-eligible; writing no data"); } } } catch (Exception e) { Slog.e(TAG, "Unable to back up wallpaper", e); } finally { Loading services/core/java/com/android/server/wallpaper/WallpaperManagerService.java +4 −2 Original line number Diff line number Diff line Loading @@ -1753,12 +1753,14 @@ public class WallpaperManagerService extends IWallpaperManager.Stub { } @Override public boolean isWallpaperBackupEligible(int userId) { public boolean isWallpaperBackupEligible(int which, int userId) { if (Binder.getCallingUid() != Process.SYSTEM_UID) { throw new SecurityException("Only the system may call isWallpaperBackupEligible"); } WallpaperData wallpaper = getWallpaperSafeLocked(userId, FLAG_SYSTEM); WallpaperData wallpaper = (which == FLAG_LOCK) ? mWallpaperMap.get(userId) : mLockWallpaperMap.get(userId); return (wallpaper != null) ? wallpaper.allowBackup : false; } Loading Loading
core/java/android/app/IWallpaperManager.aidl +1 −1 Original line number Diff line number Diff line Loading @@ -128,7 +128,7 @@ interface IWallpaperManager { /* * Backup: is the current system wallpaper image eligible for off-device backup? */ boolean isWallpaperBackupEligible(int userId); boolean isWallpaperBackupEligible(int which, int userId); /* * Keyguard: register a callback for being notified that lock-state relevant Loading
core/java/android/app/WallpaperManager.java +2 −2 Original line number Diff line number Diff line Loading @@ -1680,13 +1680,13 @@ public class WallpaperManager { * Only the OS itself may use this method. * @hide */ public boolean isWallpaperBackupEligible() { public boolean isWallpaperBackupEligible(int which) { if (sGlobals.mService == null) { Log.w(TAG, "WallpaperService not running"); throw new RuntimeException(new DeadSystemException()); } try { return sGlobals.mService.isWallpaperBackupEligible(mContext.getUserId()); return sGlobals.mService.isWallpaperBackupEligible(which, mContext.getUserId()); } catch (RemoteException e) { Log.e(TAG, "Exception querying wallpaper backup eligibility: " + e.getMessage()); } Loading
packages/WallpaperBackup/src/com/android/wallpaperbackup/WallpaperBackupAgent.java +39 −44 Original line number Diff line number Diff line Loading @@ -114,12 +114,6 @@ public class WallpaperBackupAgent extends BackupAgent { touch.close(); fullBackupFile(empty, data); // only back up the wallpaper if we've been told it's allowed if (mWm.isWallpaperBackupEligible()) { if (DEBUG) { Slog.v(TAG, "Wallpaper is backup-eligible"); } SharedPreferences prefs = getSharedPreferences(PREFS_NAME, Context.MODE_PRIVATE); final int lastSysGeneration = prefs.getInt(SYSTEM_GENERATION, -1); final int lastLockGeneration = prefs.getInt(LOCK_GENERATION, -1); Loading @@ -131,6 +125,9 @@ public class WallpaperBackupAgent extends BackupAgent { final boolean sysChanged = (sysGeneration != lastSysGeneration); final boolean lockChanged = (lockGeneration != lastLockGeneration); final boolean sysEligible = mWm.isWallpaperBackupEligible(FLAG_SYSTEM); final boolean lockEligible = mWm.isWallpaperBackupEligible(FLAG_LOCK); // There might be a latent lock wallpaper file present but unused: don't // include it in the backup if that's the case. ParcelFileDescriptor lockFd = mWm.getWallpaperFile(FLAG_LOCK, UserHandle.USER_SYSTEM); Loading @@ -140,16 +137,19 @@ public class WallpaperBackupAgent extends BackupAgent { if (DEBUG) { Slog.v(TAG, "sysGen=" + sysGeneration + " : sysChanged=" + sysChanged); Slog.v(TAG, "lockGen=" + lockGeneration + " : lockChanged=" + lockChanged); Slog.v(TAG, "hasLockWallpaper=" + hasLockWallpaper); Slog.v(TAG, "sysEligble=" + sysEligible); Slog.v(TAG, "lockEligible=" + lockEligible); } if (mWallpaperInfo.exists()) { // only back up the wallpapers if we've been told they're eligible if ((sysEligible || lockEligible) && mWallpaperInfo.exists()) { if (sysChanged || lockChanged || !infoStage.exists()) { if (DEBUG) Slog.v(TAG, "New wallpaper configuration; copying"); FileUtils.copyFileOrThrow(mWallpaperInfo, infoStage); } fullBackupFile(infoStage, data); } if (mWallpaperFile.exists()) { if (sysEligible && mWallpaperFile.exists()) { if (sysChanged || !imageStage.exists()) { if (DEBUG) Slog.v(TAG, "New system wallpaper; copying"); FileUtils.copyFileOrThrow(mWallpaperFile, imageStage); Loading @@ -159,7 +159,7 @@ public class WallpaperBackupAgent extends BackupAgent { } // Don't try to store the lock image if we overran our quota last time if (hasLockWallpaper && mLockWallpaperFile.exists() && !mQuotaExceeded) { if (lockEligible && hasLockWallpaper && mLockWallpaperFile.exists() && !mQuotaExceeded) { if (lockChanged || !lockImageStage.exists()) { if (DEBUG) Slog.v(TAG, "New lock wallpaper; copying"); FileUtils.copyFileOrThrow(mLockWallpaperFile, lockImageStage); Loading @@ -167,11 +167,6 @@ public class WallpaperBackupAgent extends BackupAgent { fullBackupFile(lockImageStage, data); prefs.edit().putInt(LOCK_GENERATION, lockGeneration).apply(); } } else { if (DEBUG) { Slog.v(TAG, "Wallpaper not backup-eligible; writing no data"); } } } catch (Exception e) { Slog.e(TAG, "Unable to back up wallpaper", e); } finally { Loading
services/core/java/com/android/server/wallpaper/WallpaperManagerService.java +4 −2 Original line number Diff line number Diff line Loading @@ -1753,12 +1753,14 @@ public class WallpaperManagerService extends IWallpaperManager.Stub { } @Override public boolean isWallpaperBackupEligible(int userId) { public boolean isWallpaperBackupEligible(int which, int userId) { if (Binder.getCallingUid() != Process.SYSTEM_UID) { throw new SecurityException("Only the system may call isWallpaperBackupEligible"); } WallpaperData wallpaper = getWallpaperSafeLocked(userId, FLAG_SYSTEM); WallpaperData wallpaper = (which == FLAG_LOCK) ? mWallpaperMap.get(userId) : mLockWallpaperMap.get(userId); return (wallpaper != null) ? wallpaper.allowBackup : false; } Loading