diff options
-rw-r--r-- | core/java/android/os/storage/IMountService.java | 25 | ||||
-rw-r--r-- | services/core/java/com/android/server/MountService.java | 26 | ||||
-rw-r--r-- | services/java/com/android/server/SystemServer.java | 22 |
3 files changed, 60 insertions, 13 deletions
diff --git a/core/java/android/os/storage/IMountService.java b/core/java/android/os/storage/IMountService.java index 116110e..6209c2a 100644 --- a/core/java/android/os/storage/IMountService.java +++ b/core/java/android/os/storage/IMountService.java @@ -888,6 +888,21 @@ public interface IMountService extends IInterface { } return; } + + @Override + public void waitForAsecScan() throws RemoteException { + Parcel _data = Parcel.obtain(); + Parcel _reply = Parcel.obtain(); + try { + _data.writeInterfaceToken(DESCRIPTOR); + mRemote.transact(Stub.TRANSACTION_waitForAsecScan, _data, _reply, 0); + _reply.readException(); + } finally { + _reply.recycle(); + _data.recycle(); + } + return; + } } private static final String DESCRIPTOR = "IMountService"; @@ -978,6 +993,8 @@ public interface IMountService extends IInterface { static final int TRANSACTION_runMaintenance = IBinder.FIRST_CALL_TRANSACTION + 42; + static final int TRANSACTION_waitForAsecScan = IBinder.FIRST_CALL_TRANSACTION + 43; + /** * Cast an IBinder object into an IMountService interface, generating a * proxy if needed. @@ -1396,6 +1413,12 @@ public interface IMountService extends IInterface { reply.writeNoException(); return true; } + case TRANSACTION_waitForAsecScan: { + data.enforceInterface(DESCRIPTOR); + waitForAsecScan(); + reply.writeNoException(); + return true; + } } return super.onTransact(code, data, reply, flags); } @@ -1680,4 +1703,6 @@ public interface IMountService extends IInterface { * @throws RemoteException */ public void runMaintenance() throws RemoteException; + + public void waitForAsecScan() throws RemoteException; } diff --git a/services/core/java/com/android/server/MountService.java b/services/core/java/com/android/server/MountService.java index 1e3b46b..b8d9ec5 100644 --- a/services/core/java/com/android/server/MountService.java +++ b/services/core/java/com/android/server/MountService.java @@ -123,6 +123,27 @@ class MountService extends IMountService.Stub // TODO: listen for user creation/deletion + public static class Lifecycle extends SystemService { + private MountService mMountService; + + public Lifecycle(Context context) { + super(context); + } + + @Override + public void onStart() { + mMountService = new MountService(getContext()); + publishBinderService("mount", mMountService); + } + + @Override + public void onBootPhase(int phase) { + if (phase == SystemService.PHASE_ACTIVITY_MANAGER_READY) { + mMountService.systemReady(); + } + } + } + private static final boolean LOCAL_LOGD = false; private static final boolean DEBUG_UNMOUNT = false; private static final boolean DEBUG_EVENTS = false; @@ -574,7 +595,8 @@ class MountService extends IMountService.Stub private final Handler mHandler; - void waitForAsecScan() { + @Override + public void waitForAsecScan() { waitForLatch(mAsecsScanned); } @@ -1538,7 +1560,7 @@ class MountService extends IMountService.Stub } } - public void systemReady() { + private void systemReady() { mSystemReady = true; mHandler.obtainMessage(H_SYSTEM_READY).sendToTarget(); } diff --git a/services/java/com/android/server/SystemServer.java b/services/java/com/android/server/SystemServer.java index ed55c56..bcd8d42 100644 --- a/services/java/com/android/server/SystemServer.java +++ b/services/java/com/android/server/SystemServer.java @@ -39,6 +39,7 @@ import android.os.StrictMode; import android.os.SystemClock; import android.os.SystemProperties; import android.os.UserHandle; +import android.os.storage.IMountService; import android.util.DisplayMetrics; import android.util.EventLog; import android.util.Slog; @@ -131,6 +132,8 @@ public final class SystemServer { "com.android.server.ethernet.EthernetService"; private static final String JOB_SCHEDULER_SERVICE_CLASS = "com.android.server.job.JobSchedulerService"; + private static final String MOUNT_SERVICE_CLASS = + "com.android.server.MountService$Lifecycle"; private static final String PERSISTENT_DATA_BLOCK_PROP = "ro.frp.pst"; private final int mFactoryTestMode; @@ -384,7 +387,7 @@ public final class SystemServer { ContentService contentService = null; VibratorService vibrator = null; IAlarmManager alarm = null; - MountService mountService = null; + IMountService mountService = null; NetworkManagementService networkManagement = null; NetworkStatsService networkStats = null; NetworkPolicyManagerService networkPolicy = null; @@ -552,9 +555,9 @@ public final class SystemServer { * NotificationManagerService is dependant on MountService, * (for media / usb notifications) so we must start MountService first. */ - Slog.i(TAG, "Mount Service"); - mountService = new MountService(context); - ServiceManager.addService("mount", mountService); + mSystemServiceManager.startService(MOUNT_SERVICE_CLASS); + mountService = IMountService.Stub.asInterface( + ServiceManager.getService("mount")); } catch (Throwable e) { reportWtf("starting Mount Service", e); } @@ -711,7 +714,10 @@ public final class SystemServer { * first before continuing. */ if (mountService != null && !mOnlyCore) { - mountService.waitForAsecScan(); + try { + mountService.waitForAsecScan(); + } catch (RemoteException ignored) { + } } try { @@ -1039,7 +1045,6 @@ public final class SystemServer { } // These are needed to propagate to the runnable below. - final MountService mountServiceF = mountService; final NetworkManagementService networkManagementF = networkManagement; final NetworkStatsService networkStatsF = networkStats; final NetworkPolicyManagerService networkPolicyF = networkPolicy; @@ -1087,11 +1092,6 @@ public final class SystemServer { reportWtf("starting System UI", e); } try { - if (mountServiceF != null) mountServiceF.systemReady(); - } catch (Throwable e) { - reportWtf("making Mount Service ready", e); - } - try { if (networkScoreF != null) networkScoreF.systemReady(); } catch (Throwable e) { reportWtf("making Network Score Service ready", e); |