Loading core/java/android/app/IWallpaperManager.aidl +7 −1 Original line number Diff line number Diff line Loading @@ -43,7 +43,8 @@ interface IWallpaperManager { * new wallpaper content is ready to display. */ ParcelFileDescriptor setWallpaper(String name, in String callingPackage, in Rect cropHint, out Bundle extras, int which, IWallpaperManagerCallback completion); in Rect cropHint, boolean allowBackup, out Bundle extras, int which, IWallpaperManagerCallback completion); /** * Set the live wallpaper. This only affects the system wallpaper. Loading Loading @@ -124,6 +125,11 @@ interface IWallpaperManager { */ boolean isWallpaperSettingAllowed(in String callingPackage); /* * Backup: is the current system wallpaper image eligible for off-device backup? */ boolean isWallpaperBackupEligible(int userId); /* * Keyguard: register a callback for being notified that lock-state relevant * wallpaper content has changed. Loading core/java/android/app/WallpaperManager.java +25 −4 Original line number Diff line number Diff line /* h * Copyright (C) 2009 The Android Open Source Project * Copyright (C) 2009 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. Loading Loading @@ -875,7 +875,7 @@ public class WallpaperManager { /* Set the wallpaper to the default values */ ParcelFileDescriptor fd = sGlobals.mService.setWallpaper( "res:" + resources.getResourceName(resid), mContext.getOpPackageName(), null, result, which, completion); mContext.getOpPackageName(), null, false, result, which, completion); if (fd != null) { FileOutputStream fos = null; boolean ok = false; Loading Loading @@ -985,7 +985,8 @@ public class WallpaperManager { final WallpaperSetCompletion completion = new WallpaperSetCompletion(); try { ParcelFileDescriptor fd = sGlobals.mService.setWallpaper(null, mContext.getOpPackageName(), visibleCropHint, result, which, completion); mContext.getOpPackageName(), visibleCropHint, allowBackup, result, which, completion); if (fd != null) { FileOutputStream fos = null; try { Loading Loading @@ -1102,7 +1103,8 @@ public class WallpaperManager { final WallpaperSetCompletion completion = new WallpaperSetCompletion(); try { ParcelFileDescriptor fd = sGlobals.mService.setWallpaper(null, mContext.getOpPackageName(), visibleCropHint, result, which, completion); mContext.getOpPackageName(), visibleCropHint, allowBackup, result, which, completion); if (fd != null) { FileOutputStream fos = null; try { Loading Loading @@ -1565,6 +1567,25 @@ public class WallpaperManager { } } /** * Is the current system wallpaper eligible for backup? * * Only the OS itself may use this method. * @hide */ public boolean isWallpaperBackupEligible() { if (sGlobals.mService == null) { Log.w(TAG, "WallpaperService not running"); return false; } try { return sGlobals.mService.isWallpaperBackupEligible(mContext.getUserId()); } catch (RemoteException e) { Log.e(TAG, "Exception querying wallpaper backup eligibility: " + e.getMessage()); } return false; } // Private completion callback for setWallpaper() synchronization private class WallpaperSetCompletion extends IWallpaperManagerCallback.Stub { final CountDownLatch mLatch; Loading core/java/com/android/server/backup/SystemBackupAgent.java +4 −34 Original line number Diff line number Diff line Loading @@ -76,26 +76,6 @@ public class SystemBackupAgent extends BackupAgentHelper { @Override public void onBackup(ParcelFileDescriptor oldState, BackupDataOutput data, ParcelFileDescriptor newState) throws IOException { // We only back up the data under the current "wallpaper" schema with metadata IWallpaperManager wallpaper = (IWallpaperManager)ServiceManager.getService( Context.WALLPAPER_SERVICE); String[] files = new String[] { WALLPAPER_IMAGE, WALLPAPER_INFO }; String[] keys = new String[] { WALLPAPER_IMAGE_KEY, WALLPAPER_INFO_KEY }; if (wallpaper != null) { try { final String wallpaperName = wallpaper.getName(); if (wallpaperName != null && wallpaperName.length() > 0) { // When the wallpaper has a name, back up the info by itself. // TODO: Don't rely on the innards of the service object like this! // TODO: Send a delete for any stored wallpaper image in this case? files = new String[] { WALLPAPER_INFO }; keys = new String[] { WALLPAPER_INFO_KEY }; } } catch (RemoteException re) { Slog.e(TAG, "Couldn't get wallpaper name\n" + re); } } addHelper(WALLPAPER_HELPER, new WallpaperBackupHelper(this, files, keys)); addHelper(SYNC_SETTINGS_HELPER, new AccountSyncSettingsBackupHelper(this)); addHelper(PREFERRED_HELPER, new PreferredActivityBackupHelper()); addHelper(NOTIFICATION_HELPER, new NotificationBackupHelper(this)); Loading @@ -107,30 +87,20 @@ public class SystemBackupAgent extends BackupAgentHelper { @Override public void onFullBackup(FullBackupDataOutput data) throws IOException { // At present we back up only the wallpaper fullWallpaperBackup(data); } private void fullWallpaperBackup(FullBackupDataOutput output) { // Back up the data files directly. We do them in this specific order -- // info file followed by image -- because then we need take no special // steps during restore; the restore will happen properly when the individual // files are restored piecemeal. FullBackup.backupToTar(getPackageName(), FullBackup.ROOT_TREE_TOKEN, null, WALLPAPER_INFO_DIR, WALLPAPER_INFO, output); FullBackup.backupToTar(getPackageName(), FullBackup.ROOT_TREE_TOKEN, null, WALLPAPER_IMAGE_DIR, WALLPAPER_IMAGE, output); // At present we don't back up anything } @Override public void onRestore(BackupDataInput data, int appVersionCode, ParcelFileDescriptor newState) throws IOException { // Slot in a restore helper for the older wallpaper backup schema to support restore // from devices still generating data in that format. mWallpaperHelper = new WallpaperBackupHelper(this, new String[] { WALLPAPER_IMAGE, WALLPAPER_INFO }, new String[] { WALLPAPER_IMAGE_KEY, WALLPAPER_INFO_KEY} ); addHelper(WALLPAPER_HELPER, mWallpaperHelper); // On restore, we also support a previous data schema "system_files" // On restore, we also support a long-ago wallpaper data schema "system_files" addHelper("system_files", new WallpaperBackupHelper(this, new String[] { WALLPAPER_IMAGE }, new String[] { WALLPAPER_IMAGE_KEY} )); Loading packages/WallpaperBackup/Android.mk 0 → 100644 +34 −0 Original line number Diff line number Diff line # # Copyright (C) 2016 The Android Open Source Project # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # LOCAL_PATH := $(call my-dir) include $(CLEAR_VARS) LOCAL_MODULE_TAGS := optional LOCAL_SRC_FILES := $(call all-java-files-under, src) LOCAL_PROGUARD_FLAG_FILES := proguard.flags LOCAL_PACKAGE_NAME := WallpaperBackup LOCAL_CERTIFICATE := platform LOCAL_PRIVILEGED_MODULE := false include $(BUILD_PACKAGE) ######################## include $(call all-makefiles-under,$(LOCAL_PATH)) packages/WallpaperBackup/AndroidManifest.xml 0 → 100644 +30 −0 Original line number Diff line number Diff line <?xml version="1.0" encoding="utf-8"?> <!-- /* * Copyright (c) 2016 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ --> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.android.wallpaperbackup" android:sharedUserId="android.uid.system" > <application android:allowClearUserData="false" android:process="system" android:killAfterRestore="false" android:allowBackup="true" android:backupAgent=".WallpaperBackupAgent" android:fullBackupOnly="true" > </application> </manifest> Loading
core/java/android/app/IWallpaperManager.aidl +7 −1 Original line number Diff line number Diff line Loading @@ -43,7 +43,8 @@ interface IWallpaperManager { * new wallpaper content is ready to display. */ ParcelFileDescriptor setWallpaper(String name, in String callingPackage, in Rect cropHint, out Bundle extras, int which, IWallpaperManagerCallback completion); in Rect cropHint, boolean allowBackup, out Bundle extras, int which, IWallpaperManagerCallback completion); /** * Set the live wallpaper. This only affects the system wallpaper. Loading Loading @@ -124,6 +125,11 @@ interface IWallpaperManager { */ boolean isWallpaperSettingAllowed(in String callingPackage); /* * Backup: is the current system wallpaper image eligible for off-device backup? */ boolean isWallpaperBackupEligible(int userId); /* * Keyguard: register a callback for being notified that lock-state relevant * wallpaper content has changed. Loading
core/java/android/app/WallpaperManager.java +25 −4 Original line number Diff line number Diff line /* h * Copyright (C) 2009 The Android Open Source Project * Copyright (C) 2009 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. Loading Loading @@ -875,7 +875,7 @@ public class WallpaperManager { /* Set the wallpaper to the default values */ ParcelFileDescriptor fd = sGlobals.mService.setWallpaper( "res:" + resources.getResourceName(resid), mContext.getOpPackageName(), null, result, which, completion); mContext.getOpPackageName(), null, false, result, which, completion); if (fd != null) { FileOutputStream fos = null; boolean ok = false; Loading Loading @@ -985,7 +985,8 @@ public class WallpaperManager { final WallpaperSetCompletion completion = new WallpaperSetCompletion(); try { ParcelFileDescriptor fd = sGlobals.mService.setWallpaper(null, mContext.getOpPackageName(), visibleCropHint, result, which, completion); mContext.getOpPackageName(), visibleCropHint, allowBackup, result, which, completion); if (fd != null) { FileOutputStream fos = null; try { Loading Loading @@ -1102,7 +1103,8 @@ public class WallpaperManager { final WallpaperSetCompletion completion = new WallpaperSetCompletion(); try { ParcelFileDescriptor fd = sGlobals.mService.setWallpaper(null, mContext.getOpPackageName(), visibleCropHint, result, which, completion); mContext.getOpPackageName(), visibleCropHint, allowBackup, result, which, completion); if (fd != null) { FileOutputStream fos = null; try { Loading Loading @@ -1565,6 +1567,25 @@ public class WallpaperManager { } } /** * Is the current system wallpaper eligible for backup? * * Only the OS itself may use this method. * @hide */ public boolean isWallpaperBackupEligible() { if (sGlobals.mService == null) { Log.w(TAG, "WallpaperService not running"); return false; } try { return sGlobals.mService.isWallpaperBackupEligible(mContext.getUserId()); } catch (RemoteException e) { Log.e(TAG, "Exception querying wallpaper backup eligibility: " + e.getMessage()); } return false; } // Private completion callback for setWallpaper() synchronization private class WallpaperSetCompletion extends IWallpaperManagerCallback.Stub { final CountDownLatch mLatch; Loading
core/java/com/android/server/backup/SystemBackupAgent.java +4 −34 Original line number Diff line number Diff line Loading @@ -76,26 +76,6 @@ public class SystemBackupAgent extends BackupAgentHelper { @Override public void onBackup(ParcelFileDescriptor oldState, BackupDataOutput data, ParcelFileDescriptor newState) throws IOException { // We only back up the data under the current "wallpaper" schema with metadata IWallpaperManager wallpaper = (IWallpaperManager)ServiceManager.getService( Context.WALLPAPER_SERVICE); String[] files = new String[] { WALLPAPER_IMAGE, WALLPAPER_INFO }; String[] keys = new String[] { WALLPAPER_IMAGE_KEY, WALLPAPER_INFO_KEY }; if (wallpaper != null) { try { final String wallpaperName = wallpaper.getName(); if (wallpaperName != null && wallpaperName.length() > 0) { // When the wallpaper has a name, back up the info by itself. // TODO: Don't rely on the innards of the service object like this! // TODO: Send a delete for any stored wallpaper image in this case? files = new String[] { WALLPAPER_INFO }; keys = new String[] { WALLPAPER_INFO_KEY }; } } catch (RemoteException re) { Slog.e(TAG, "Couldn't get wallpaper name\n" + re); } } addHelper(WALLPAPER_HELPER, new WallpaperBackupHelper(this, files, keys)); addHelper(SYNC_SETTINGS_HELPER, new AccountSyncSettingsBackupHelper(this)); addHelper(PREFERRED_HELPER, new PreferredActivityBackupHelper()); addHelper(NOTIFICATION_HELPER, new NotificationBackupHelper(this)); Loading @@ -107,30 +87,20 @@ public class SystemBackupAgent extends BackupAgentHelper { @Override public void onFullBackup(FullBackupDataOutput data) throws IOException { // At present we back up only the wallpaper fullWallpaperBackup(data); } private void fullWallpaperBackup(FullBackupDataOutput output) { // Back up the data files directly. We do them in this specific order -- // info file followed by image -- because then we need take no special // steps during restore; the restore will happen properly when the individual // files are restored piecemeal. FullBackup.backupToTar(getPackageName(), FullBackup.ROOT_TREE_TOKEN, null, WALLPAPER_INFO_DIR, WALLPAPER_INFO, output); FullBackup.backupToTar(getPackageName(), FullBackup.ROOT_TREE_TOKEN, null, WALLPAPER_IMAGE_DIR, WALLPAPER_IMAGE, output); // At present we don't back up anything } @Override public void onRestore(BackupDataInput data, int appVersionCode, ParcelFileDescriptor newState) throws IOException { // Slot in a restore helper for the older wallpaper backup schema to support restore // from devices still generating data in that format. mWallpaperHelper = new WallpaperBackupHelper(this, new String[] { WALLPAPER_IMAGE, WALLPAPER_INFO }, new String[] { WALLPAPER_IMAGE_KEY, WALLPAPER_INFO_KEY} ); addHelper(WALLPAPER_HELPER, mWallpaperHelper); // On restore, we also support a previous data schema "system_files" // On restore, we also support a long-ago wallpaper data schema "system_files" addHelper("system_files", new WallpaperBackupHelper(this, new String[] { WALLPAPER_IMAGE }, new String[] { WALLPAPER_IMAGE_KEY} )); Loading
packages/WallpaperBackup/Android.mk 0 → 100644 +34 −0 Original line number Diff line number Diff line # # Copyright (C) 2016 The Android Open Source Project # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # LOCAL_PATH := $(call my-dir) include $(CLEAR_VARS) LOCAL_MODULE_TAGS := optional LOCAL_SRC_FILES := $(call all-java-files-under, src) LOCAL_PROGUARD_FLAG_FILES := proguard.flags LOCAL_PACKAGE_NAME := WallpaperBackup LOCAL_CERTIFICATE := platform LOCAL_PRIVILEGED_MODULE := false include $(BUILD_PACKAGE) ######################## include $(call all-makefiles-under,$(LOCAL_PATH))
packages/WallpaperBackup/AndroidManifest.xml 0 → 100644 +30 −0 Original line number Diff line number Diff line <?xml version="1.0" encoding="utf-8"?> <!-- /* * Copyright (c) 2016 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ --> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.android.wallpaperbackup" android:sharedUserId="android.uid.system" > <application android:allowClearUserData="false" android:process="system" android:killAfterRestore="false" android:allowBackup="true" android:backupAgent=".WallpaperBackupAgent" android:fullBackupOnly="true" > </application> </manifest>