Following scenario:
I have a unrooted (stock) android phone (Samsung) and I need to enable adb, but I don't have access to the device (forgot the lock code).
Is it possible to enable adb debugging via adb sideload from recovery?
For example creating a update.zip, that enables adb or installs an app, that enables adb on boot?
Thanks
Is it possible to enable adb debugging via adb sideload from recovery?
No. Your app would need special permissions to do such a thing. Obviously if an arbitrary app was able to turn on adb debugging without asking the user that'd be a bad thing.
As a side note, this sounds like what someone would ask if they had acquired a phone that didn't belong to them. Not that this would change the validity of my answer.
Related
I'm using scrcpy to mirror the phone screen to computer, which uses adb.
I've followed the steps and it works:
# connect via USB
adb devices
adb tcpip 5555
# now unplug USB, and the following will work over WiFi
adb connect 192.168.1.14:5555
scrcpy
But when you reboot the phone or computer, doing adb connect 192.168.1.14:5555 and scrcpy doesn't work anymore (NB: the phone IP hasn't changed, it's fixed).
Reading the answers from Run/install/debug Android applications over Wi-Fi?, I see 3 options:
plug the USB cable each time before doing a wireless connection, but this is annoying, and somehow reduces the interest of wireless...
Use "ADB over network" (main answer's screenshot), but as noted by many people in comments: "i do not have the "ADB over network" option in debugging option"; so this option doesn't work for me
other techniques that need root (not possible for me)
Question: how to pair the phone and computer with a USB cable only once, and then be able to use adb between them without having to use a USB connection first, after each reboot?
Note: I don't use Android Studio, but only scrcpy.
It's not possible without root the phone. If your phone has rooted. You can use this app. https://play.google.com/store/apps/details?id=com.ttxapps.wifiadb&hl=en. With this app you can easily debugs android apps with only wifi. Don't want USB cable even only first time.
Based on all the information I have the next conclusion. Just for reference, how a low-level setup with changing add routes works inside, described here. It comes up, there is a pretty straight thing inside changing navigation with adb tcpip <port>.
The first thing we need to do, it's setup system property with tcp port with name setprop service.adb.tcp.port (and values with a port number) By default, there is not such property.
And then just restart adb with few commands. stop adbd and start adbd on a device in order to debug bridge listen new port. What is the trick here, that you don't have access to this service and stop/start it without root. But it could be easily done, via Developer setting with stop/start debugging.
This few simple action hidden inside adb tcpip <port>. And the problem, that you cannot change system properties (point 1). That is why all application requires root access, it's just to change the single option. That is why, we need to connect with USB to debug bridge, which can change properties with his sepolicy.
So answering your question. I don't understand either, what is the problem or enabling this small setup in Developer options. But right now, it's possible to do so on some Roms, or devices with root access.
I have rooted pixel device with android pie, I am trying to automate few things with ADB and I am struggling with an authorization issue.
manually it works, I connect to the device through ADB then I approve the auth key manually in the device.
when I am trying to automate this scenario I don't have any option to approve manually this. is there some way to disable this authorization? or maybe do some programmatically/adb manipulation?
well, my problem is: I have an application which is set as the device owner of a device (my tablet in this case). I did it from the terminal in Ubuntu, connecting the tablet to my PC and executting this line in the adb shell:
dpm set-device-owner my.app.package/my.app.route.MyAdmin
So, I want to disable the device owner app without restoring the device, just executing a line similar to the last one. Me and my coworker have been researching for a long time and we've never found anything about this, so I would like to know if it is possible or not, and if it is, how to do that.
Thanks!
you can use the following ADB shell command to remove device owner
adb shell dpm remove-active-admin com.example.app/.AdminReceiver
Disables an active admin, the admin must have declared android:testOnly in the application in its manifest. This will also remove device owner and profile owners
You can use DevicePolicyManager.clearDeviceOwnerApp() from your device owner app.
However note that this method has been deprecated in Android Oreo, you can still use it on Oreo devices but it might be removed in future Android versions.
I was testing out the Glass quickstart and chose COMPASS to "re-upload" as a test (tutorial: https://developers.google.com/glass/develop/gdk/quick-start#for_android_beginners)
Now that it worked, I'm stuck with 2x "Compass - sample" and can't call either one by voice commands.
Compass isn't important to me but I am in the process of making an apps for the medical field and I would like to be able to remove it.
Is it possible to remove an .apk from Glass without rooting the device? I have Glass in debug mode and I'm capable of uploading apk's.
Thanks for the help!
You can remove it via the standard way over ADB:
adb shell pm uninstall com.example.MyApp
(where com.example.MyApp is the package name defined in the manifest).
If you have more than one device connected the command will fail - you can direct it to the only attached emulator via the -e flag, the only attached USB device via the -d flag, or a specific device via its serial number and the -s flag (serial numbers as listed in adb devices).
I'm trying to write an app that can turn my mobile data connection on and off.
Already got the source and built my own sdk, where I removed the #hide statements so I can use the relevant function
cm = (ConnectivityManager) getSystemService(CONNECTIVITY_SERVICE);
cm.setMobileDataEnabled(true);
Also found out which permissions I need, in particular WRITE_SECURE_SETTINGS, which is only available to system apps. I read adamk's comment and now need to know how to do what he suggested (add the app to system or sign it with the platform key).
At first I would like to do that on the emulator only, and then on my phone (which is rooted and using a custom ROM).
I tried pushing it to the system directory on the emulator:
adb remount
adb push app.apk /system/app/
adb sync
which did not work, the app was not found and installed.
What did I forget? How is the proper way to do this?
So, I finally found the problem and solved it.
I was actually quite close:
adb remount
adb push app.apk /system/app/
This is the correct way to do it on the emulator (no adb sync needed). I watched the logcat, and found out that you need to sign your .apk file so the system does not reject it, even if that does not add any validity in this case.
If you push a signed .apk this way, it will get the needed permissions and work as expected — in my case, turning the mobile data connection on and off.
For the phone part (using ClockworkMod):
Boot into recovery mode, mount the /system folder and enable USB storage. Then proceed in the same way as with the emulator, reboot the phone, and you are good to go.
Hope this helps someone who encounters the same problem.