Android P 禁用OTG U盘使用

public void disableOTG() {
// TODO Auto-generated method stub
Log.v(TAG, “disableOTG<

>” + android.os.Environment.getExternalStorageDirectory().toString());
SystemProperties.set(“persist.sys.disableOTGU”, “true”);
try {
Method method = Class.forName(“android.os.ServiceManager”).getMethod(“getService”, String.class);
IBinder binder = (IBinder) method.invoke(null, “mount”);
IStorageManager mStorageManager = IStorageManager.Stub.asInterface(binder);
mStorageManager.unmount(“public:8,1”);
} catch (Exception e) {
Log.v(TAG, “disableOTG>>Exception”);
e.printStackTrace();
}

你可能感兴趣的:(Android P 禁用OTG U盘使用)