android 12.0卸载otg设备开机不加载otg设备
1.概述
在12.0定制化开发过程中,客户有功能需求,通过系统属性值控制是否加载挂载otg设备,当设置为卸载模式时,要求不能挂载otg设备,开机也不能挂载otg设备
2.卸载otg设备开机不加载otg设备的核心代码
frameworks/base/services/core/java/com/android/server/StorageManagerService.java
3.卸载otg设备开机不加载otg设备的功能分析和实现
实现思路:
1.StorageManager根据路径来卸载otg设备
2.开机时在 StorageManagerService 中 不挂载otg设备
3.1 分析StorageManagerService.java挂载otg相关方法
class StorageManagerService extends IStorageManager.Stubimplements Watchdog.Monitor, ScreenObserver {
private void start() {connectStoraged();connectVold();}
private final IVoldListener mListener = new IVoldListener.Stub() {@Overridepublic void onDiskCreated(String diskId, int flags) {synchronized (mLock) {final String value = SystemProperties.get(StorageManager.PROP_ADOPTABLE);