if (mFactoryTestMode != FactoryTest.FACTORY_TEST_LOW_LEVEL) {
if (!“0”.equals(SystemProperties.get(“system_init.startmountservice”))) {
t.traceBegin(“StartStorageManagerService”);
try {
/*
- NotificationManagerService is dependant on StorageManagerService,
- (for media / usb notifications) so we must start StorageManagerService first.
*/
mSystemServiceManager.startService(STORAGE_MANAGER_SERVICE_CLASS);
storageManager = IStorageManager.Stub.asInterface(
ServiceManager.getService(“mount”));
} catch (Throwable e) {
reportWtf(“starting StorageManagerService”, e);
}
t.traceEnd();
t.traceBegin(“StartStorageStatsService”);
try {
mSystemServiceManager.startService(STORAGE_STATS_SERVICE_CLASS);
} catch (Throwable e) {
reportWtf(“starting StorageStatsService”, e);
}
t.traceEnd();
}
}
…
}
NotificationManagerService依赖于StorageManagerService,所以必需先启动StroageManagerService。 private static final String STORAGE_MANAGER_SERVICE_CLASS = "com.android.server.StorageManagerService$Lifecycle";
SystemManagerService通过反射构建LifeCycle并调用onStart()方法
@Override
public void onStart() {
mStorageManagerService = new StorageManagerService(getContext());
publishBinderService(“mount”, mStorageManagerService);
mStorageManagerService.start();
}
StorageManagerService
public StorageManagerService(Context context) {
sSelf = this;
// 前面先是读取一些属性状态,其中关于FUSE下面会稍微介绍一下
// Snapshot feature flag used for this boot
SystemProperties.set(StorageManager.PROP_ISOLATED_STORAGE_SNAPSHOT, Boolean.toString(
SystemProperties.getBoolean(StorageManager.PROP_ISOLATED_STORAGE, true)));
// If there is no value in the property yet (first boot after data wipe), this value may be
// incorrect until #updateFusePropFromSettings where we set the correct value and reboot if
// different
mIsFuseEnabled = SystemProperties.getBoolean(PROP_FUSE, DEFAULT_FUSE_ENABLED);
mVoldAppDataIsolationEnabled = mIsFuseEnabled && SystemProperties.getBoolean(
ANDROID_VOLD_APP_DATA_ISOLATION_ENABLED_PROPERTY, false);
mContext = context;
mResolver = mContext.getContentResolver();
mCallbac