diff options
| -rw-r--r-- | core/java/android/app/IWallpaperManager.aidl | 10 | ||||
| -rw-r--r-- | core/res/AndroidManifest.xml | 2 | ||||
| -rw-r--r-- | services/java/com/android/server/SystemServer.java | 5 | ||||
| -rw-r--r-- | services/java/com/android/server/appwidget/AppWidgetService.java (renamed from services/java/com/android/server/AppWidgetService.java) | 6 | ||||
| -rw-r--r-- | services/java/com/android/server/appwidget/AppWidgetServiceImpl.java (renamed from services/java/com/android/server/AppWidgetServiceImpl.java) | 2 | ||||
| -rw-r--r-- | services/java/com/android/server/backup/BackupManagerService.java (renamed from services/java/com/android/server/BackupManagerService.java) | 13 | ||||
| -rw-r--r-- | services/java/com/android/server/backup/PackageManagerBackupAgent.java (renamed from services/java/com/android/server/PackageManagerBackupAgent.java) | 2 | ||||
| -rw-r--r-- | services/java/com/android/server/backup/SystemBackupAgent.java (renamed from services/java/com/android/server/SystemBackupAgent.java) | 48 | ||||
| -rw-r--r-- | services/java/com/android/server/clipboard/ClipboardService.java (renamed from services/java/com/android/server/ClipboardService.java) | 2 | ||||
| -rw-r--r-- | services/java/com/android/server/devicepolicy/DevicePolicyManagerService.java (renamed from services/java/com/android/server/DevicePolicyManagerService.java) | 2 | ||||
| -rw-r--r-- | services/java/com/android/server/pm/PreferredActivity.java | 1 | ||||
| -rw-r--r-- | services/java/com/android/server/pm/PreferredComponent.java (renamed from services/java/com/android/server/PreferredComponent.java) | 2 | ||||
| -rw-r--r-- | services/java/com/android/server/wallpaper/WallpaperManagerService.java (renamed from services/java/com/android/server/WallpaperManagerService.java) | 20 |
13 files changed, 80 insertions, 35 deletions
diff --git a/core/java/android/app/IWallpaperManager.aidl b/core/java/android/app/IWallpaperManager.aidl index 3efd3c0ede8b..181eb63bce69 100644 --- a/core/java/android/app/IWallpaperManager.aidl +++ b/core/java/android/app/IWallpaperManager.aidl @@ -71,4 +71,14 @@ interface IWallpaperManager { * Returns the desired minimum height for the wallpaper. */ int getHeightHint(); + + /** + * Returns the name of the wallpaper. Private API. + */ + String getName(); + + /** + * Informs the service that wallpaper settings have been restored. Private API. + */ + void settingsRestored(); } diff --git a/core/res/AndroidManifest.xml b/core/res/AndroidManifest.xml index b198937df18d..e5461178390b 100644 --- a/core/res/AndroidManifest.xml +++ b/core/res/AndroidManifest.xml @@ -2522,7 +2522,7 @@ android:hasCode="false" android:label="@string/android_system_label" android:allowClearUserData="false" - android:backupAgent="com.android.server.SystemBackupAgent" + android:backupAgent="com.android.server.backup.SystemBackupAgent" android:killAfterRestore="false" android:icon="@drawable/ic_launcher_android" android:supportsRtl="true"> diff --git a/services/java/com/android/server/SystemServer.java b/services/java/com/android/server/SystemServer.java index dd1c9047e21c..3a1c747cef77 100644 --- a/services/java/com/android/server/SystemServer.java +++ b/services/java/com/android/server/SystemServer.java @@ -51,7 +51,11 @@ import com.android.server.accessibility.AccessibilityManagerService; import com.android.server.accounts.AccountManagerService; import com.android.server.am.ActivityManagerService; import com.android.server.am.BatteryStatsService; +import com.android.server.appwidget.AppWidgetService; +import com.android.server.backup.BackupManagerService; +import com.android.server.clipboard.ClipboardService; import com.android.server.content.ContentService; +import com.android.server.devicepolicy.DevicePolicyManagerService; import com.android.server.display.DisplayManagerService; import com.android.server.dreams.DreamManagerService; import com.android.server.input.InputManagerService; @@ -67,6 +71,7 @@ import com.android.server.power.ShutdownThread; import com.android.server.print.PrintManagerService; import com.android.server.search.SearchManagerService; import com.android.server.usb.UsbService; +import com.android.server.wallpaper.WallpaperManagerService; import com.android.server.wifi.WifiService; import com.android.server.wm.WindowManagerService; diff --git a/services/java/com/android/server/AppWidgetService.java b/services/java/com/android/server/appwidget/AppWidgetService.java index 203cca692df0..6fd8871c2185 100644 --- a/services/java/com/android/server/AppWidgetService.java +++ b/services/java/com/android/server/appwidget/AppWidgetService.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package com.android.server; +package com.android.server.appwidget; import android.app.ActivityManager; import android.appwidget.AppWidgetProviderInfo; @@ -48,7 +48,7 @@ import java.util.Locale; /** * Redirects calls to this service to the instance of the service for the appropriate user. */ -class AppWidgetService extends IAppWidgetService.Stub +public class AppWidgetService extends IAppWidgetService.Stub { private static final String TAG = "AppWidgetService"; @@ -60,7 +60,7 @@ class AppWidgetService extends IAppWidgetService.Stub private final SparseArray<AppWidgetServiceImpl> mAppWidgetServices; - AppWidgetService(Context context) { + public AppWidgetService(Context context) { mContext = context; mSaveStateHandler = BackgroundThread.getHandler(); diff --git a/services/java/com/android/server/AppWidgetServiceImpl.java b/services/java/com/android/server/appwidget/AppWidgetServiceImpl.java index 69ae846597f7..98dead312469 100644 --- a/services/java/com/android/server/AppWidgetServiceImpl.java +++ b/services/java/com/android/server/appwidget/AppWidgetServiceImpl.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package com.android.server; +package com.android.server.appwidget; import android.app.AlarmManager; import android.app.AppGlobals; diff --git a/services/java/com/android/server/BackupManagerService.java b/services/java/com/android/server/backup/BackupManagerService.java index 00bfee78bfbb..c2b0d10cff49 100644 --- a/services/java/com/android/server/BackupManagerService.java +++ b/services/java/com/android/server/backup/BackupManagerService.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package com.android.server; +package com.android.server.backup; import android.app.ActivityManagerNative; import android.app.AlarmManager; @@ -83,7 +83,8 @@ import com.android.internal.backup.BackupConstants; import com.android.internal.backup.IBackupTransport; import com.android.internal.backup.IObbBackupService; import com.android.internal.backup.LocalTransport; -import com.android.server.PackageManagerBackupAgent.Metadata; +import com.android.server.EventLogTags; +import com.android.server.backup.PackageManagerBackupAgent.Metadata; import java.io.BufferedInputStream; import java.io.BufferedOutputStream; @@ -135,7 +136,7 @@ import javax.crypto.spec.IvParameterSpec; import javax.crypto.spec.PBEKeySpec; import javax.crypto.spec.SecretKeySpec; -class BackupManagerService extends IBackupManager.Stub { +public class BackupManagerService extends IBackupManager.Stub { private static final String TAG = "BackupManagerService"; private static final boolean DEBUG = true; private static final boolean MORE_DEBUG = false; @@ -1178,7 +1179,8 @@ class BackupManagerService extends IBackupManager.Stub { // First, on an encrypted device we require matching the device pw final boolean isEncrypted; try { - isEncrypted = (mMountService.getEncryptionState() != MountService.ENCRYPTION_STATE_NONE); + isEncrypted = (mMountService.getEncryptionState() != + IMountService.ENCRYPTION_STATE_NONE); if (isEncrypted) { if (DEBUG) { Slog.i(TAG, "Device encrypted; verifying against device data pw"); @@ -5437,7 +5439,8 @@ class BackupManagerService extends IBackupManager.Stub { boolean isEncrypted; try { - isEncrypted = (mMountService.getEncryptionState() != MountService.ENCRYPTION_STATE_NONE); + isEncrypted = (mMountService.getEncryptionState() != + IMountService.ENCRYPTION_STATE_NONE); if (isEncrypted) Slog.w(TAG, "Device is encrypted; forcing enc password"); } catch (RemoteException e) { // couldn't contact the mount service; fail "safe" and assume encryption diff --git a/services/java/com/android/server/PackageManagerBackupAgent.java b/services/java/com/android/server/backup/PackageManagerBackupAgent.java index 77bddb0717ec..495da886fa65 100644 --- a/services/java/com/android/server/PackageManagerBackupAgent.java +++ b/services/java/com/android/server/backup/PackageManagerBackupAgent.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package com.android.server; +package com.android.server.backup; import android.app.backup.BackupAgent; import android.app.backup.BackupDataInput; diff --git a/services/java/com/android/server/SystemBackupAgent.java b/services/java/com/android/server/backup/SystemBackupAgent.java index 8cf273dee8cc..26e2e2ac356c 100644 --- a/services/java/com/android/server/SystemBackupAgent.java +++ b/services/java/com/android/server/backup/SystemBackupAgent.java @@ -14,9 +14,10 @@ * limitations under the License. */ -package com.android.server; +package com.android.server.backup; +import android.app.IWallpaperManager; import android.app.backup.BackupDataInput; import android.app.backup.BackupDataOutput; import android.app.backup.BackupAgentHelper; @@ -26,11 +27,11 @@ import android.app.backup.WallpaperBackupHelper; import android.content.Context; import android.os.Environment; import android.os.ParcelFileDescriptor; +import android.os.RemoteException; import android.os.ServiceManager; import android.os.UserHandle; import android.util.Slog; - import java.io.File; import java.io.IOException; @@ -63,16 +64,23 @@ public class SystemBackupAgent extends BackupAgentHelper { public void onBackup(ParcelFileDescriptor oldState, BackupDataOutput data, ParcelFileDescriptor newState) throws IOException { // We only back up the data under the current "wallpaper" schema with metadata - WallpaperManagerService wallpaper = (WallpaperManagerService)ServiceManager.getService( + 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 && wallpaper.getName() != null && wallpaper.getName().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 }; + 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", new WallpaperBackupHelper(SystemBackupAgent.this, files, keys)); super.onBackup(oldState, data, newState); @@ -109,9 +117,15 @@ public class SystemBackupAgent extends BackupAgentHelper { try { super.onRestore(data, appVersionCode, newState); - WallpaperManagerService wallpaper = (WallpaperManagerService)ServiceManager.getService( + IWallpaperManager wallpaper = (IWallpaperManager) ServiceManager.getService( Context.WALLPAPER_SERVICE); - wallpaper.settingsRestored(); + if (wallpaper != null) { + try { + wallpaper.settingsRestored(); + } catch (RemoteException re) { + Slog.e(TAG, "Couldn't restore settings\n" + re); + } + } } catch (IOException ex) { // If there was a failure, delete everything for the wallpaper, this is too aggressive, // but this is hopefully a rare failure. @@ -149,10 +163,16 @@ public class SystemBackupAgent extends BackupAgentHelper { FullBackup.restoreFile(data, size, type, mode, mtime, outFile); if (restoredWallpaper) { - WallpaperManagerService wallpaper = - (WallpaperManagerService)ServiceManager.getService( + IWallpaperManager wallpaper = + (IWallpaperManager)ServiceManager.getService( Context.WALLPAPER_SERVICE); - wallpaper.settingsRestored(); + if (wallpaper != null) { + try { + wallpaper.settingsRestored(); + } catch (RemoteException re) { + Slog.e(TAG, "Couldn't restore settings\n" + re); + } + } } } catch (IOException e) { if (restoredWallpaper) { diff --git a/services/java/com/android/server/ClipboardService.java b/services/java/com/android/server/clipboard/ClipboardService.java index 069ae23f5596..6aa596d9d78e 100644 --- a/services/java/com/android/server/ClipboardService.java +++ b/services/java/com/android/server/clipboard/ClipboardService.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package com.android.server; +package com.android.server.clipboard; import android.app.ActivityManagerNative; import android.app.AppGlobals; diff --git a/services/java/com/android/server/DevicePolicyManagerService.java b/services/java/com/android/server/devicepolicy/DevicePolicyManagerService.java index 2bb99d68ed77..53b8dc412f61 100644 --- a/services/java/com/android/server/DevicePolicyManagerService.java +++ b/services/java/com/android/server/devicepolicy/DevicePolicyManagerService.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package com.android.server; +package com.android.server.devicepolicy; import static android.Manifest.permission.MANAGE_CA_CERTIFICATES; diff --git a/services/java/com/android/server/pm/PreferredActivity.java b/services/java/com/android/server/pm/PreferredActivity.java index f93ba2fe9c59..89169264b0b6 100644 --- a/services/java/com/android/server/pm/PreferredActivity.java +++ b/services/java/com/android/server/pm/PreferredActivity.java @@ -17,7 +17,6 @@ package com.android.server.pm; import com.android.internal.util.XmlUtils; -import com.android.server.PreferredComponent; import org.xmlpull.v1.XmlPullParser; import org.xmlpull.v1.XmlPullParserException; diff --git a/services/java/com/android/server/PreferredComponent.java b/services/java/com/android/server/pm/PreferredComponent.java index a7af252ca2ed..f437372e31a0 100644 --- a/services/java/com/android/server/PreferredComponent.java +++ b/services/java/com/android/server/pm/PreferredComponent.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package com.android.server; +package com.android.server.pm; import com.android.internal.util.XmlUtils; diff --git a/services/java/com/android/server/WallpaperManagerService.java b/services/java/com/android/server/wallpaper/WallpaperManagerService.java index e6b6b93a1d46..97ea52c0a4a2 100644 --- a/services/java/com/android/server/WallpaperManagerService.java +++ b/services/java/com/android/server/wallpaper/WallpaperManagerService.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package com.android.server; +package com.android.server.wallpaper; import static android.os.ParcelFileDescriptor.*; @@ -85,8 +85,8 @@ import com.android.internal.content.PackageMonitor; import com.android.internal.util.FastXmlSerializer; import com.android.internal.util.JournaledFile; -class WallpaperManagerService extends IWallpaperManager.Stub { - static final String TAG = "WallpaperService"; +public class WallpaperManagerService extends IWallpaperManager.Stub { + static final String TAG = "WallpaperManagerService"; static final boolean DEBUG = false; final Object mLock = new Object[0]; @@ -98,7 +98,6 @@ class WallpaperManagerService extends IWallpaperManager.Stub { static final long MIN_WALLPAPER_CRASH_TIME = 10000; static final String WALLPAPER = "wallpaper"; static final String WALLPAPER_INFO = "wallpaper_info.xml"; - /** * Name of the component used to display bitmap wallpapers from either the gallery or * built-in wallpapers. @@ -505,7 +504,12 @@ class WallpaperManagerService extends IWallpaperManager.Stub { } } - String getName() { + /** Called by SystemBackupAgent */ + public String getName() { + // Verify caller is the system + if (Binder.getCallingUid() != android.os.Process.SYSTEM_UID) { + throw new RuntimeException("getName() can only be called from the system process"); + } synchronized (mLock) { return mWallpaperMap.get(0).name; } @@ -1175,7 +1179,11 @@ class WallpaperManagerService extends IWallpaperManager.Stub { } // Called by SystemBackupAgent after files are restored to disk. - void settingsRestored() { + public void settingsRestored() { + // Verify caller is the system + if (Binder.getCallingUid() != android.os.Process.SYSTEM_UID) { + throw new RuntimeException("settingsRestored() can only be called from the system process"); + } // TODO: If necessary, make it work for secondary users as well. This currently assumes // restores only to the primary user if (DEBUG) Slog.v(TAG, "settingsRestored"); |