公司终于有Android7.0的项目了,上层禁用usb模式:
Settings添加bool属性
bools.xml(/packages/apps/Settings/res/values)
<bool name="config_usb_only_show_charging_mode" translatable="false">truebool>
UsbBackend.java(/packages/apps/Settings/src/com/android/settings/deviceinfo)
public boolean isModeSupported(int mode) {
if (mContext.getResources().getBoolean(R.bool.config_usb_only_show_charging_mode)
&& (((mode & MODE_DATA_MASK) == MODE_DATA_MTP)
|| ((mode & MODE_DATA_MASK) == MODE_DATA_PTP)
|| ((mode & MODE_DATA_MASK) == MODE_DATA_MIDI))) {
return false;
}
}