diff --git a/core/java/android/storage/StorageManager.java b/core/java/android/storage/StorageManager.java index dd8bd63699821..924d169525ca0 100644 --- a/core/java/android/storage/StorageManager.java +++ b/core/java/android/storage/StorageManager.java @@ -254,6 +254,10 @@ public class StorageManager */ public StorageManager(Looper tgtLooper) throws RemoteException { mMountService = IMountService.Stub.asInterface(ServiceManager.getService("mount")); + if (mMountService == null) { + Log.e(TAG, "Unable to connect to mount service! - is it running yet?"); + return; + } mTgtLooper = tgtLooper; mBinderListener = new MountServiceBinderListener(); mMountService.registerListener(mBinderListener); diff --git a/services/java/com/android/server/SystemServer.java b/services/java/com/android/server/SystemServer.java index ee1cc8defa5d5..6e9c21bde0b06 100644 --- a/services/java/com/android/server/SystemServer.java +++ b/services/java/com/android/server/SystemServer.java @@ -272,6 +272,17 @@ class ServerThread extends Thread { Log.e(TAG, "Failure starting Accessibility Manager", e); } + try { + /* + * NotificationManagerService is dependant on MountService, + * (for media / usb notifications) so we must start MountService first. + */ + Log.i(TAG, "Mount Service"); + ServiceManager.addService("mount", new MountService(context)); + } catch (Throwable e) { + Log.e(TAG, "Failure starting Mount Service", e); + } + try { Log.i(TAG, "Notification Manager"); notification = new NotificationManagerService(context, statusBar, lights); @@ -280,14 +291,6 @@ class ServerThread extends Thread { Log.e(TAG, "Failure starting Notification Manager", e); } - try { - // MountService must start after NotificationManagerService - Log.i(TAG, "Mount Service"); - ServiceManager.addService("mount", new MountService(context)); - } catch (Throwable e) { - Log.e(TAG, "Failure starting Mount Service", e); - } - try { Log.i(TAG, "Device Storage Monitor"); ServiceManager.addService(DeviceStorageMonitorService.SERVICE,