(OK) Use Android Code to Enable USB Debugging
2017-03-21 10:33
363 查看
https://www.recovery-android.com/tips/enable-usb-debugging-with-android-code.html
--Thursday, Jun.23, 2016
As Android users, you must be familiar with USB debugging mode, which allows you to have a full use of your phone when connecting to computer. To enable it, you can manage the privacy data like contacts, messages, call logs, etc. stored in Android with the
3-party software on computer. You can easily
enable USB debugging in the "Settings" interface in the phone. Here, we are going to share a technical way with you - enable USB debugging with Android code automatically.
Firstly, let’s have a look at the analysis of the code of USB debugging. In the resource code "packages/apps/Settings/src/com/android /settings/DevelopmentSettings.java", you can find the code related to USB Debugging:
In this file, it will save the values in the Settings database according to the user settings. In other places of the settings will perform a corresponding action according to the dynamic change of the values.
After searching, the value in "frameworks/base/services/java/com/android/server/NotificationManagerService.java" is used to judge whether notification should be shown in the status bar. The code is as below:
With the code analysis, we can get the USB debugging automatically turned on relying on the program.
When finished the above steps, you still cannot get USB debugging enabled yet. With Logcat, you can find that the code written in it still have no right to enable USB debugging, because "android.permission.WRITE_SECURE_SETTINGS" disallows common
program to perform, and there must be a system signature or being put in /system/app directory.
You can add two permissions in "AndroidManifest.xml" like follows:
After pushing the Java program code in /system/app directory and add the 0644 permission in the .apk, you can restart your phone. Now, the USB debugging is automatically enabled.
--Thursday, Jun.23, 2016
As Android users, you must be familiar with USB debugging mode, which allows you to have a full use of your phone when connecting to computer. To enable it, you can manage the privacy data like contacts, messages, call logs, etc. stored in Android with the
3-party software on computer. You can easily
enable USB debugging in the "Settings" interface in the phone. Here, we are going to share a technical way with you - enable USB debugging with Android code automatically.
Firstly, let’s have a look at the analysis of the code of USB debugging. In the resource code "packages/apps/Settings/src/com/android /settings/DevelopmentSettings.java", you can find the code related to USB Debugging:
In this file, it will save the values in the Settings database according to the user settings. In other places of the settings will perform a corresponding action according to the dynamic change of the values.
After searching, the value in "frameworks/base/services/java/com/android/server/NotificationManagerService.java" is used to judge whether notification should be shown in the status bar. The code is as below:
With the code analysis, we can get the USB debugging automatically turned on relying on the program.
When finished the above steps, you still cannot get USB debugging enabled yet. With Logcat, you can find that the code written in it still have no right to enable USB debugging, because "android.permission.WRITE_SECURE_SETTINGS" disallows common
program to perform, and there must be a system signature or being put in /system/app directory.
You can add two permissions in "AndroidManifest.xml" like follows:
After pushing the Java program code in /system/app directory and add the 0644 permission in the .apk, you can restart your phone. Now, the USB debugging is automatically enabled.
相关文章推荐
- How to Enable USB-Debugging with Nexus 5 for Android Studio
- How to Enable USB Debugging Mode on Android
- enable usb debugging by code
- 【Android笔记】引用第三方自定义控件出错:Tip: Use View.isInEditMode() in your custom views to skip code when shown in Eclipse
- To use MuPDF source code in Android
- error: exception handling disabled, use -fexceptions to enable under Android NDK enviroement
- (OK) how to compile the source code for Android-x86 (Android 7.1.1)
- Rockie's Android Porting Guide(2)——Add USB WIFI to your system
- how to use the code in ms ssrs
- Use Deblector to debug application to get pseudo source debugging experience
- [tip] Enable Peoplecode debugging
- Howto find native code memory leak in Android
- Using gdbserver and arm-eabi-gdb to debug native code in Android
- use noscript html tag when user disable the javascript in browser, guide user how to enable the js in different browser and retu
- How to create and use SDCard image for Android emulator
- Repo and Git, to get Android source code.
- Use code to approve SPListItem
- Solve problem searching file in Emule and error occurs:Please Use Emule 0.47c And Enable Protocol Obfuscation To Get Results
- The right method to compile android SDK from source code
- All-In-One Code Framework(AIO): 如何编写VC++代码来使用COM组件 (How to use COM in a VC++ client)