java usb 断开_Android P开发者选项中的USB调试关闭
根据字符查找到开发者选项的字符是:reset_dashboard_title
packages/apps/Settings/res/xml/system_dashboard_fragment.xml
找到对应system_dashboard_fragment.xml调用的Java文件是:
packages/apps/Settings/src/com/android/settings/system/SystemDashboardFragment.java
进而找到:
packages/apps/Settings/src/com/android/settings/system/DashboardFragmentRegistry.java
static {
PARENT_TO_CATEGORY_KEY_MAP = new ArrayMap<>();
PARENT_TO_CATEGORY_KEY_MAP.put(
NetworkDashboardFragment.class.getName(), CategoryKey.CATEGORY_NETWORK);
PARENT_TO_CATEGORY_KEY_MAP.put(ConnectedDeviceDashboardFragment.class.getName(),
CategoryKey.CATEGORY_CONNECT);
PARENT_TO_CATEGORY_KEY_MAP.put(AdvancedConnectedDeviceDashboardFragment.class.getName(),
CategoryKey.CATEGORY_DEVICE);
PARENT_TO_CATEGORY_KEY_MAP.put(AppAndNotificationDashboardFragment.class.getName(),
CategoryKey.CATEGORY_APPS);
PARENT_TO_CATEGORY_KEY_MAP.put(PowerUsageSummary.class.getName(),
CategoryKey.CATEGORY_BATTERY);
PARENT_TO_CATEGORY_KEY_MAP.put(DefaultAppSettings.class.getName(),
CategoryKey.CATEGORY_APPS_DEFAULT);
PARENT_TO_CATEGORY_KEY_MAP.put(DisplaySettings.class.getName(),
CategoryKey.CATEGORY_DISPLAY);
PARENT_TO_CATEGORY_KEY_MAP.put(SoundSettings.class.getName(),
CategoryKey.CATEGORY_SOUND);
PARENT_TO_CATEGORY_KEY_MAP.put(StorageDashboardFragment.class.getName(),
CategoryKey.CATEGORY_STORAGE);
PARENT_TO_CATEGORY_KEY_MAP.put(SecuritySettings.class.getName(),
CategoryKey.CATEGORY_SECURITY);
PARENT_TO_CATEGORY_KEY_MAP.put(AccountDetailDashboardFragment.class.getName(),
CategoryKey.CATEGORY_ACCOUNT_DETAIL);
PARENT_TO_CATEGORY_KEY_MAP.put(AccountDashboardFragment.class.getName(),
CategoryKey.CATEGORY_ACCOUNT);
PARENT_TO_CATEGORY_KEY_MAP.put(
SystemDashboardFragment.class.getName(), CategoryKey.CATEGORY_SYSTEM);
PARENT_TO_CATEGORY_KEY_MAP.put(LanguageAndInputSettings.class.getName(),
CategoryKey.CATEGORY_SYSTEM_LANGUAGE);
PARENT_TO_CATEGORY_KEY_MAP.put(DevelopmentSettingsDashboardFragment.class.getName(),
CategoryKey.CATEGORY_SYSTEM_DEVELOPMENT);
PARENT_TO_CATEGORY_KEY_MAP.put(ConfigureNotificationSettings.class.getName(),
CategoryKey.CATEGORY_NOTIFICATIONS);
PARENT_TO_CATEGORY_KEY_MAP.put(LockscreenDashboardFragment.class.getName(),
CategoryKey.CATEGORY_SECURITY_LOCKSCREEN);
PARENT_TO_CATEGORY_KEY_MAP.put(ZenModeSettings.class.getName(),
CategoryKey.CATEGORY_DO_NOT_DISTURB);
PARENT_TO_CATEGORY_KEY_MAP.put(GestureSettings.class.getName(),
CategoryKey.CATEGORY_GESTURES);
PARENT_TO_CATEGORY_KEY_MAP.put(NightDisplaySettings.class.getName(),
CategoryKey.CATEGORY_NIGHT_DISPLAY);
CATEGORY_KEY_TO_PARENT_MAP = new ArrayMap<>(PARENT_TO_CATEGORY_KEY_MAP.size());
for (Map.Entry parentToKey : PARENT_TO_CATEGORY_KEY_MAP.entrySet()) {
CATEGORY_KEY_TO_PARENT_MAP.put(parentToKey.getValue(), parentToKey.getKey());
}
}
以上见名知意,可以查看到DevelopmentSettingsDashboardFragment.java即为开发者选项的文件。
进入菜单时候初始化是否是开发者模式:
@Override
public void onActivityCreated(Bundle icicle) {
super.onActivityCreated(icicle);
// Apply page-level restrictions
setIfOnlyAvailableForAdmins(true);
if (isUiRestricted() || !Utils.isDeviceProvisioned(getActivity())) {
// Block access to developer options if the user is not the owner, if user policy
// restricts it, or if the device has not been provisioned
mIsAvailable = false;
// Show error message
if (!isUiRestrictedByOnlyAdmin()) {
getEmptyTextView().setText(R.string.development_settings_not_available);
}
getPreferenceScreen().removeAll();
return;
}
// Set up master switch
mSwitchBar = ((SettingsActivity) getActivity()).getSwitchBar();
mSwitchBarController = new DevelopmentSwitchBarController(
this /* DevelopmentSettings */, mSwitchBar, mIsAvailable, getLifecycle());
mSwitchBar.show();
// Restore UI state based on whether developer options is enabled
if (DevelopmentSettingsEnabler.isDevelopmentSettingsEnabled(getContext())) {
enableDeveloperOptions();
} else {
disableDeveloperOptions();
}
}
private void enableDeveloperOptions() {
if (Utils.isMonkeyRunning()) {
return;
}
DevelopmentSettingsEnabler.setDevelopmentSettingsEnabled(getContext(), true);
for (AbstractPreferenceController controller : mPreferenceControllers) {
if (controller instanceof DeveloperOptionsPreferenceController) {
((DeveloperOptionsPreferenceController) controller).onDeveloperOptionsEnabled();
}
}
}
private void disableDeveloperOptions() {
if (Utils.isMonkeyRunning()) {
return;
}
DevelopmentSettingsEnabler.setDevelopmentSettingsEnabled(getContext(), false);
final SystemPropPoker poker = SystemPropPoker.getInstance();
poker.blockPokes();
for (AbstractPreferenceController controller : mPreferenceControllers) {
if (controller instanceof DeveloperOptionsPreferenceController) {
((DeveloperOptionsPreferenceController) controller)
.onDeveloperOptionsDisabled();
}
}
poker.unblockPokes();
poker.poke();
}
DevelopmentSettingsEnabler.java文件中:
判断开发者模式是否开启:
public static final String DEVELOPMENT_SETTINGS_CHANGED_ACTION =
"com.android.settingslib.development.DevelopmentSettingsEnabler.SETTINGS_CHANGED";
private DevelopmentSettingsEnabler() {
}
public static void setDevelopmentSettingsEnabled(Context context, boolean enable) {
Settings.Global.putInt(context.getContentResolver(),
Settings.Global.DEVELOPMENT_SETTINGS_ENABLED, enable ? 1 : 0);
LocalBroadcastManager.getInstance(context)
.sendBroadcast(new Intent(DEVELOPMENT_SETTINGS_CHANGED_ACTION));
}
public static boolean isDevelopmentSettingsEnabled(Context context) {
final UserManager um = (UserManager) context.getSystemService(Context.USER_SERVICE);
final boolean settingEnabled = Settings.Global.getInt(context.getContentResolver(),
Settings.Global.DEVELOPMENT_SETTINGS_ENABLED,
Build.TYPE.equals("eng") ? 1 : 0) != 0;
final boolean hasRestriction = um.hasUserRestriction(
UserManager.DISALLOW_DEBUGGING_FEATURES);
final boolean isAdminOrDemo = um.isAdminUser() || um.isDemoUser();
return isAdminOrDemo && !hasRestriction && settingEnabled;
}
对应的布局文件是:packages/apps/Settings/res/xml/development_settings.xml
android:key="debug_debugging_category"
android:title="@string/debug_debugging_category"
android:order="200">
android:key="enable_adb"
android:title="@string/enable_adb"
android:summary="@string/enable_adb_summary" />
android:title="@string/clear_adb_keys" />
android:key="enable_terminal"
android:title="@string/enable_terminal_title"
android:summary="@string/enable_terminal_summary" />
....省略较多代码
其对应的实现位于:
frameworks/base/packages/SettingsLib/src/com/android/settingslib/development/AbstractEnableAdbPreferenceController.java
对应ADB的开关如下:
private boolean isAdbEnabled() {
final ContentResolver cr = mContext.getContentResolver();
return Settings.Global.getInt(cr, Settings.Global.ADB_ENABLED, ADB_SETTING_OFF)
!= ADB_SETTING_OFF;
}
然后在设置中查找对应的默认参数即可。
frameworks/base/packages/SettingsProvider/src/com/android/providers/settings/DatabaseHelper.java
private void loadSecureSettings(SQLiteDatabase db) {
SQLiteStatement stmt = null;
try {
stmt = db.compileStatement("INSERT OR IGNORE INTO secure(name,value)"
+ " VALUES(?,?);");
loadStringSetting(stmt, Settings.Secure.LOCATION_PROVIDERS_ALLOWED,
R.string.def_location_providers_allowed);
// Don't do this. The SystemServer will initialize ADB_ENABLED from a
// persistent system property instead.
//loadSetting(stmt, Settings.Secure.ADB_ENABLED, 0);
// Allow mock locations default, based on build
loadSetting(stmt, Settings.Secure.ALLOW_MOCK_LOCATION,
"1".equals(SystemProperties.get("ro.allow.mock.location")) ? 1 : 0);
....//省略较多代码
根据以上注释重新查找persistent 中属性的位置:
build/make/core/main.mk
user_variant := $(filter user userdebug,$(TARGET_BUILD_VARIANT))
enable_target_debugging := true
tags_to_install :=
ifneq (,$(user_variant))
# Target is secure in user builds.
ADDITIONAL_DEFAULT_PROPERTIES += ro.secure=1
ADDITIONAL_DEFAULT_PROPERTIES += security.perf_harden=1
ifeq ($(user_variant),user)
ADDITIONAL_DEFAULT_PROPERTIES += ro.adb.secure=1
endif
ifeq ($(user_variant),userdebug)
# Pick up some extra useful tools
tags_to_install += debug
else
# Disable debugging in plain user builds.
enable_target_debugging :=
endif
# Disallow mock locations by default for user builds
ADDITIONAL_DEFAULT_PROPERTIES += ro.allow.mock.location=0
else # !user_variant
# Turn on checkjni for non-user builds.
ADDITIONAL_BUILD_PROPERTIES += ro.kernel.android.checkjni=0
# Set device insecure for non-user builds.
ADDITIONAL_DEFAULT_PROPERTIES += ro.secure=0
# Allow mock locations by default for non user builds
ADDITIONAL_DEFAULT_PROPERTIES += ro.allow.mock.location=1
endif # !user_variant
ifeq (true,$(strip $(enable_target_debugging)))
# Target is more debuggable and adbd is on by default
ifeq ($(user_variant),user)
ADDITIONAL_DEFAULT_PROPERTIES += ro.debuggable=0
else
ADDITIONAL_DEFAULT_PROPERTIES += ro.debuggable=1
endif
# Enable Dalvik lock contention logging.
ADDITIONAL_BUILD_PROPERTIES += dalvik.vm.lockprof.threshold=500
# Include the debugging/testing OTA keys in this build.
INCLUDE_TEST_OTA_KEYS := true
else # !enable_target_debugging
# Target is less debuggable and adbd is off by default
ADDITIONAL_DEFAULT_PROPERTIES += ro.debuggable=0
endif # !enable_target_debugging
此处应该就是默认是否debug的位置;
本文地址:https://blog.csdn.net/liuminx/article/details/107174848
如您对本文有疑问或者有任何想说的,请点击进行留言回复,万千网友为您解惑!
java usb 断开_Android P开发者选项中的USB调试关闭相关推荐
- [RK3568 Android11] 开发之开发者选项中添加USB OTG模式切换(二)
目录 前言 一.开发者选项中添加USB OTG模式切换按钮 二.按钮添加功能 前言 上一篇已讲解创建OTG模式的系统全局变量,此篇讲解怎么在 设置应用->开发者选项中 添加USB OTG切换按钮 ...
- [RK3568 Android11] 开发之开发者选项中添加USB OTG模式切换(一)
目录 前言 一.创建全局变量 前言 上一篇已讲底层是怎么设置USB OTG模式<[RK3568 Android11] 教程之USB OTG模式切换>,此篇开始讲解怎么在设置应用->开 ...
- Android开发者选项中,这29个功能你忽略了吗?
前言 1.Android的开发者选项对于每个开发人员来说,肯定再熟悉不过了. 一个设备,如果你不打开开发者选项中的USB调试,那么连接到电脑上是不显示该设备的,也无法直接把程序运行到设备上,没法调试, ...
- Android9.0默认将开发者选项中的OEM锁开关打开
做项目时偶尔会遇到客户需求中有这样的要求:默认将开发者选项中的OEM锁开关打开 修改这个需求可以: 到frameworks/base/services/usb/java/com/android/ser ...
- Android系统默认打开开发者选项中的TP触摸开关
在定制系统开发中,有时会遇到客户为了方便生产测试硬件主板,客户会提出生产测试软件需要默认打开开发者选项中的TP触摸开关,也就是show_touches和pointer_location 具体实现方法如 ...
- 手机usb连接电脑失败(开发者选项、usb调试)
场景 vivo手机usb连接电脑,提示驱动安装失败.otp设备无法识别. 解决方案 一般来说是没有启动开发者选项. 设置 | 我的设备 | 更多参数 | 双击 软件版本号 即可打开开发者模式. 然后 ...
- java s1 s2 s3 s4_电源选项中S1,S2,S3,S4,S5
电源选项中S1,S2,S3,S4,S5的含义 以 ACPI 的规格来说吧!ACPI(Advanced Configuration and Power Interface),即高级配置与电源接口.这种新 ...
- Android - 开发者选项中的一些必知必懂必会
唠叨 开发者选项中有很多功能,到作为一个开发者,常用常见的就是 USB 调试了.但熟不知,里面还有很几个有意思的东西. 1. 不锁定屏幕 在开发中进行 USB 调试,开启后,不会熄灭屏幕,但屏幕亮度会 ...
- MTK6757 9.0 USB debugger 默认打开, 开发者选项无法打开
一. USB debugger 默认打开 1. build\make\core\main.mk 将ro.debuggable 值改为1 ADDITIONAL_DEFAULT_PROPERTIES += ...
最新文章
- OpenCV 读取一张图片并显示和保存
- html 中embed标签使用
- UImageview加边框 加阴影
- maven多profile环境打包下-P参数和-D参数
- linux脚本多个条件比较大小,shell脚本-比较两个整数大小
- Vue、element-ui的resetFields()方法重置表单无效问题及解决办法
- Spring Boot Mybatis入门示例
- 传说中的马尔科夫链到底是个什么鬼?
- JS魔法堂:元素克隆、剪切技术研究
- Cocos2d-x开发---改变父节点颜色、透明度影响子节点
- Oracle PL / SQL – UPDATE触发器之前的示例
- 信息技术助推智能建造和建筑企业数字化转型
- 黑马程序员—String类常用方法
- js中对象的可枚举和不可枚举属性
- CSDN是什么???
- java xmap_xml和java Bean的直接转换,Xmap
- Android10读写权限
- 阿翔编程学-Java杂文
- 视觉引导定位带领视觉行业高速发展!
- charge animation 充电管理u-boot(rk817)详解