[Q] Change/remove lock code with internal class or adb shell - Android Q&A, Help & Troubleshooting

Problem:
I'm an app developer. I have one app that let's you lock the device using Device Administration. One of my users had some conflicts with my app and another. He then removed Device Administration and uninstalled my app, rebooted his phone, and now he cannot access his phone.
He of course cannot use my app to change the password now (since it's uninstalled).
His phone is stock 2.2 LG Optimus V, Virgin Mobile, Rooted.
Question:
I'm needing to find a way that my user can now change his lock code.
I need:
1.) to know an internal class (from com.android.internal) that I could use within an app to change the lock code (just like the system settings do).
OR
2.) to know a command I can use with adb shell to remove or change the phone lock code.
OR
3.) to know the location of the file that stores the lock code information.
Any help is greatly appreciated.

I did actually manage to rewrite a couple pieces of my app, install with adb install, then start it with adb shell am start, and re-enable device admin. So I was able to make it work.
This also worked when my user tried it. Problem Solved.

Related

Find certain user settings on phone via adb without rooting.

Hey!
i have an android phone connected via USB to a PC.
problem is i need to find a way of getting info from it WITHOUT ROOTING!
i need to find out certain user settings/preferences set on the phone currently.
Several such settings like wifi, bluetooth, api version etc are available via the >ADB shell dumpsys command.
However i could locate the GPS settings only in the /data/data/com.android.settings/shared_prefs.xml file. This cant be pulled without rooting as far as i tried. Is there any way to maybe just read this xml file and get the setting?
I am not creating an app..and will mostly be doing this remotely so cant install anything on the phone.
i know the xml/database locations of all variables on a rooted device. Want the same without root permission.
i am totally new to android!

[Q] HTC Flyer Data recovery - Broken screen

Hi everyone
My first post here, hopefully someone can help me.
I have (had) a HTC Flyer P510e tablet. When I got it I went through the process of rooting, unlocking, etc, and if my memory serves was running Andoid 2.3.4.
A while ago I dropped it, broke the screen and rendered it useless. Digitizer not responsive, so I cant unlock the screen, or quite frankly do anything with it.
There is some important info on there I need to get off. I have already managed to pull off the contacts, calender, documents, apk's i needed, etc. The problemis as follows:
I have been using Garmin Mechanic to record all my fuel purchases, and PhoneTrack Explorer to record mileage use, site time, etc. I have backups of these apps and the data from January, but I am needing the Feb & March data from both these apps.
I was previously using TitaniumBackup for this, and from examining the backup files I can see the databases for these apps were stored as follows:
\HTC Backup\External\data\titaniumbackup\co.uk.journeylog.android.phonetrack-20130110-124837.tar.gz\co.uk.journeylog.android.phonetrack-20130110-124837.tar\data\data\co.uk.journeylog.android.phonetrack\.\databases\
\HTC Backup\External\data\titaniumbackup\com.garmin.android.apps.mech-20130110-124624.tar.gz\com.garmin.android.apps.mech-20130110-124624.tar\data\data\com.garmin.android.apps.mech\.\databases\
I have tried various commands, sequences and other suggestions using ADB, none which have worked. Tthe failures I get on ADB commands mainly are Permission Denied when trying to issue the su or root command, read only or read errors trying to mount, browse or copy, etc, etc. I have followed about 15 suggestions from different XDA pages, other sites, and more, with no luck so far.
I have tried Moborobo, MyPhoneExplorer and APK Batch Installer, with not much luck.
Things I do have which could be of use:
I have done a full clockworkmod backup and have the current image files.
I have already downloaded the Android SDK kit.
Is there any way I can get hold of these files so I can submit my expenses? Is there an easy way to pull them using ADB?
I was considering if there was a way to use the Android SDK to create a virtual Android device, add the clockworkmod recovery to the virtual device, then use the image backups I have to restore my broken device's load, then do a backup or export of the information I am needing?
Any help or suggestions would be greatly appreciated!
Thanks very much.
Did you try to re-install the HTC drivers? What is the response if you type:
adb devices
If no device is listed, it might just be a driver problem. Or just try another USB port, or another computer (if available).
redpoint73 said:
Did you try to re-install the HTC drivers? What is the response if you type:
adb devices
If no device is listed, it might just be a driver problem. Or just try another USB port, or another computer (if available).
Click to expand...
Click to collapse
It's not a communication problem. adb devices does list the device serial number. adb shell launches the shell and I can browse around and perform various commands, but I am always getting the permission denied errors when I try to access the system protected folders, and those hidden folders.

rooted phone user changes & dir permissions

Is there a way, once rooting is done, and i have customized my phone a bit (a change in one of the config files of linux), to change the user accounts and permissions? To create a new user account and change the user that is used by the phone to be a non-root, non-sudo, standard user. And all apps to use this or another standard user account.
And my app (that i installed after rooting) use another account. Only this account will have permission to read and write my app's directory.
Finally change the root user password, so that others cannot get into it unless they have that password.
So in effect protect my apps directory and allow the phone to work with a non sudo user from then on?
Next time phone re boots it uses another user say A (non sudo); without access to my apps directory. And when my app runs it uses user B (also non sudo) which has access to its dir. Others cannot read or list files in it or change permissions. So in effect my apps directory cannot be read by the user of the phone, in this new set up. I understand there will be ways around this.
But is this possible and how?
Rooted using https://forum.xda-developers.com/android/general/root-samsung-galaxy-on5-t3435457 but i can do systemless root if that is the way.
Phone model : Samsung On 5 Pro SM-G5550FY. Thank you much.

Tasker 'Secure Settings' ADB access - How 'safe' is it ??

Ok lets first explain the situation
I've been dabbling with Tasker (Paid for version)- getting some automation depending on certain situations (mainly stuff like 'If I'm @ {location} get volumes set high' or ' If Unread msg then vibrate my Amazefit bip watch' - Nothing too complicated using variables / javascript etc)
One situation I want to attempt though is 'If Gpay app is started - turn on NFC, but when I leave the app - turn NFC off'
Now I already know there are 2 'main' ways I can turn on/off NFC in Tasker.. either use 'AutoInput plugin' or use 'Secure Settings'
- I've tried with Autoinput plugin but the problem is that with the free option, you need to watch an Ad every day to use it but of course I can pay for it (its only a couple of quid)
However you can't Install it & pay for it directly from within the plugin - you need to install yet another App (AutoApps) first - & although this one is free - I just don't like adding more bloat to my phone than necessary. Adding both the plugin & this additional App adds (although only a 'minor' amount) up to 20Mb
The other method is give Tasker 'Secure settings' permission
- So I read the 'What to do to give 'Write Secure Settings Permission' to Tasker' (enable Developer mode > Usb Debugging > Install ADB on PC etc etc) & it looks simple enough,
But (a loooong time ago) I tried other 'hacks' & it ended up disastrously (probably I did something wrong with missing a step or something) & I just want to make sure that it IS as simple as it seems and also ask how safe is it
for example
* If I type in the command in ADB - could something go wrong & could it crash/brick the phone ?
* Is this permanent - ie if I turn off/on phone or if I get an OTA update & phone restarts - will it stay, or will I have to repeat the ADB command each time ?
* Will this 'break' official OTA updates (whether security &/or Android firmware) - I once did a firmware update with a step that used ADB (IIRC) & it broke something that prevented any updates from happening
- official OR manual firmware updates
Any help/advice would be appreciated
Cannon_Foddr said:
* If I type in the command in ADB - could something go wrong & could it crash/brick the phone ?
* Is this permanent - ie if I turn off/on phone or if I get an OTA update & phone restarts - will it stay, or will I have to repeat the ADB command each time ?
* Will this 'break' official OTA updates (whether security &/or Android firmware) - I once did a firmware update with a step that used ADB (IIRC) & it broke something that prevented any updates from happening
- official OR manual firmware updates
Click to expand...
Click to collapse
ADB is the door to your phone's Android. It's a tool not meant to be used by John Doe. Wrongly used you can brick your phone. Hence it's by default disabled.
1. Yes, using ADB you can render your phone absolutely useless. If you e.g. enter
Code:
adb shell rm -rf /
then phone gets totally wiped ( really all gets destroyed, it gets naked ) - you can throw it into electric waste.
2. ADB commands aren't persistent, but their results may be.
3. ADB itself breaks nothing: it's a driver installed on your computer that let you access Android's files and launch Android executables.
Thanks for the reply
I doubt I'll use THAT command.
I forgot to mention what tasker's command is
adb shell pm grant net.dinglisch.android.taskerm android.permission.WRITE_SECURE_SETTINGS
Not 100% sure about your last comment though.
ADB allows access to android files so changing android files could break things, which I'm worried about especially with OTA updates etc. (my last phone stopped getting OTA updates when I rooted it despite using official firmware)
However IF I understand the above command all this does is tell the android operating system ('android') to only give the tasker app (which 'Real' name is 'net.dinglisch.android.taskerm') the rights ('permission') to access the required settings ('WRITE_SECURE_SETTINGS') which the NFC on/off toggle is part of (settings >connected devices > connection preferences> nfc) & 'shouldn' t' affect any other files such as OTA (unless OTA is also part of secure setting?)
@Cannon_Foddr
As I can see you until now haven't understood what ADB is, how it works.
Same probably your understanding of what an OTA is.
Personally never would allow 3rd-party apps ( like Tasker ) to modify sensible system settings: Tasker isn't an open-source app, so you can't control what it does in the last run.
It's simply on you to decide whether Tasker is given that right, or not ...
Can't see why 'open-source' has to do with this
IMHO if Open-source - anyone can release similar apps with added extra hidden code that could spy's on you/steal info etc, but a 'closed sourced' app from a long running developer (tasker been around for 10yrs with over 1mil downloads) must mean people seem to trust him/them & if he was 'dodgy' surely he would've been caught out by now
Anyway the Bottom line seems to be
Safe route: pay for plugin & live with extra bloatware
Or
Risky route: give access to secure system resources, see what happens & keep fingers cross nothing does
Thanks for your replies.. I think I may have to sit down & have a long hard think which route I feel more comfortable with
I have been using Automate for about 4 months now. I granted it WRITE_SECURE_SETTINGS and I have not noticed any modifications in my system. Granted I may have not looked specifically for them but as far as braking the system or disruption of OTAs no issues so far
DennisHarrows said:
I have been using Automate for about 4 months now. I granted it WRITE_SECURE_SETTINGS and I have not noticed any modifications in my system. Granted I may have not looked specifically for them but as far as braking the system or disruption of OTAs no issues so far
Click to expand...
Click to collapse
I assume you had to do something like Taskers command then to grant the secure settings
( "adb shell pm grant net.dinglisch.android.taskerm android.permission.WRITE_SECURE_SETTINGS" )
Cannon_Foddr said:
I assume you had to do something like Taskers command then to grant the secure settings
( "adb shell pm grant net.dinglisch.android.taskerm android.permission.WRITE_SECURE_SETTINGS" )
Click to expand...
Click to collapse
Automate is straight forward, there is a toggle for "modify system settings" needed for some tasks to run and one you run the ADB command, it's done

How To Guide Dark room (i.e. icebox for bloatware)

Xiaomi, while way better than Huawei in terms of bootloader unlock support etc, still has an issue of bloatware. This is where Dark room comes in. It is a simple app that can run in various modes to disable apps that refuse to be disabled. This would be a nice GUI to disable apps. No more finding package names and uninstalling from adb!
Requirements: another computer or terminal emulator with adb
icebox app:https://www.coolapk.com/apk/web1n.stopapp
You DO NOT need to unlock your bootloader. This can all be done from adb. Just enable it in developer settings.
It supports multiple modes, including shizuku mode.
Be aware that while using device owner mode means it survives restarts, you would have to log out of all accounts on the device including the Xiaomi account, and other users (also called second space) will be deleted. You would have to log back in manually. The app developer has also included a support page for a GUI application which can set device owner (basically it inputs adb commands that delete accounts and then sets device owner)
https://stopapp.https.gs/nonroot.html
Bugs: DO NOT disable critical system apps. You will end up soft bricking your device. System reset is your only option now.

Categories

Resources