Merge "Bring MountService into the SystemService world."

This commit is contained in:
Jeff Sharkey
2015-03-22 20:03:54 +00:00
committed by Android (Google) Code Review
3 changed files with 60 additions and 13 deletions

View File

@@ -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;
}

View File

@@ -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();
}

View File

@@ -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;
@@ -1086,11 +1091,6 @@ public final class SystemServer {
} catch (Throwable e) {
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) {