Android存储系统源码走读(一),android开发实战经典

本文深入探讨Android的存储管理服务,重点分析了StorageManagerService的启动过程,包括FUSE功能、onStart方法中的服务连接以及onBootPhase的执行流程。讲解了如何初始化和连接到Vold与Storaged服务,以及在不同系统阶段执行的任务。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值