记录adb来给手机授权的流程
原文出自这里
主要就是 先连接到USB调试,然后可以adb了,再执行 – adb devices (press enter)
If the device is shown in the terminal window as shown in the screenshot, you have successfully connected the device.
Rewrite or copy the full command (this is an example of granting permission for BatteryGuru), repeat this step for each.
以及根据实际情况来编辑下面的命令,不同的权限,命令参数不同.DUMP
– adb shell pm grant com.paget96.batteryguru android.permission.DUMP (press enter)
1. PC
2. USB Cable
3. And for sure Android device
Download platform tools for your platform (Windows, Linux, or Mac) from the official Android developer site.
Android SDK Platform-Tools is a component for the Android SDK. It includes tools that interface with the Android platform, such as adb, fastboot, and systrace. These tools are required for Android app development. They’re also needed if you want to unlock your device bootloader and flash it with a new system image.
Although some new features in these tools are available only for recent versions of Android, the tools are backward compatible, so you need only one version of the SDK Platform-Tools.Download:
https://developer.android.com/studio/releases/platform-tools.html
After downloading platform tools for your platform (Windows, Linux, or Mac), you are ready to extract the ZIP file. While doing this we need to prepare our Android device for the USB Debugging to connect it with ADB and grant necessary permissions.
For this part of the guide, you need to perform several steps on your Android device. Steps with screenshots will be posted below. Every screenshot represents one step.
In this example, I’m using a Xiaomi device with MIUI, but steps are similar with any other OS (OneUI, AOSP, Oxygen…)Steps to be done on your phone:
1. Open device settings, and select About.
2. Tap on Build number seven times, until it shows a message similar to one shown in the screenshot
3. Go back, and find Developer options.
4. Scroll down, and check the USB Debugging (some devices also have USB debugging (security settings), enable that also).
5. Plug your device into your computer if you aren’t already.”
6. Popup will appear on your device, you need to allow it. (Last screenshot)
After successful setup and enabled USB debugging we are ready to use platform tools (downloaded in step 1.). We’ll use Windows CMD to run the commands.Steps to be done on your PC:
1. Hold Left Shift on keyboard and press right click on the opened folder and click on Open command window
2. After that run the command
– adb devices (press enter)
If the device is shown in the terminal window as shown in the screenshot, you have successfully connected the device.3. Rewrite or copy the full command (this is an example of granting permission for BatteryGuru), repeat this step for each.
– adb shell pm grant com.paget96.batteryguru android.permission.DUMP (press enter)
If for any reason your PC starts Power shell (just on Windows) instead of CMD, just follow next steps
1. Open Start and search for CMD (Command Prompt), run it as Administrator
2. Copy full path of your platform-tools directory
3. Go back to CMD and run command
– cd (paste full path of your platform-tools directory) (press enter)
4. Do the steps from previous screenshots