Pm hide adb command - android

I'm trying to hide/disable an app using pm hide com.myapp but I'm getting an error Error: java.lang.SecurityException: Neither user 10225 nor current process has android.permission.MANAGE_USERS.
I'm using an unrooted phone could anyone tell me why I can't use pm hide or if there's another command I can use

In case anyone is still looking for an answer to this, disabling OEM bloatware through adb is still possible on Android M+ using pm uninstall. While its true that uninstalling a system app requires root access, you can however uninstall the app for a particular user (yourself or user 0) without any root like this:
pm uninstall --user 0 com.micromax.trendingapps
But be careful and make absolutely sure that its a bloatware you are uninstalling because the above changes are permanent! You may not undo the damage done to a system app without factory resetting your device again.

Android disabled this feature in some security update in android 6

Related

Device owner not being cleared on Android M

I wrote a device owner kiosk app that I'd like to remove the device owner status on so I can uninstall it without having to factory reset the device. The following works on Nougat and Oreo, but not Marshmallow for Samsung tablets.
The specifics of how I'm coding the device owner stuff:
To set the app as device owner, I am running this adb shell command after installing the app:
adb shell dpm set-device-owner com.dps.myapp/.DeviceAdminReceiver
Then when I am trying to remove device owner status and uninstall the app, I am running these shell commands:
adb shell am force-stop com.dps.myapp
adb shell am start -n com.dps.myapp/.DeactivateDeviceOwnerActivity
adb shell pm uninstall com.dps.myapp
DeactivateDeviceOwnerActivity is an Activity in my app that contains the following code to clear the device owner status:
DevicePolicyManager mDevicePolicyManager = (DevicePolicyManager)getSystemService(Context.DEVICE_POLICY_SERVICE);
mDevicePolicyManager.clearDeviceOwnerApp(getApplicationContext().getPackageName());
if (mDevicePolicyManager.isDeviceOwnerApp(getApplicationContext().getPackageName())) {
Toast.makeText(getApplicationContext(),
"Failure! App is still device owner.",Toast.LENGTH_LONG)
.show();
}
else {
Toast.makeText(getApplicationContext(),
"Success!", Toast.LENGTH_LONG).show();
}
What is so weird is that my Activity is displaying the Toast that the clearDeviceOwnerApp call worked, but when I run the uninstall command immediately after, I get the "Failure [DELETE_FAILED_DEVICE_POLICY_MANAGER]" return from it, so obviously the device owner was not cleared for my app.
Does anyone know of any specific differences between Marshmallow and subsequent APIs, regarding device ownership or DevicePolicyManager that would cause this code, that works on Nougat and Oreo, to not work on Marshmallow? When I issue the start command to have DeactivateDeviceOwnerActivity clear the device owner, I'm looking in the system log and I'm not seeing anything that indicates any exceptions occurring. Any help would be appreciated.
I have not faced such an issue on Marshmallow.
This is strange, although I can't give an answer, I will suggest something
1) This might be a bug. So, you can factory reset device and try again.
2) It is very convenient to use the emulator for this type of testing as you can easily just delete and create a new one.
I hope it helps.

Appium : How to launch app from Android For Work work profile

I need to launch an app which is in different work profile (Android For Work). If install the app in personal profile then I am able to launch the app from the personal profile on the same device.
However, When I install the app only in the work profile then I am not able to launch the app through adb command.
As per my understanding, google keeps two different containers for personal and work profile. I think the work profile has different space and adb does not have any access to that app and workspace of work profile.
I need to launch the app through appium
If anyone has the answer to the above problem, please answer. Thanks in Advance !
Do you mean launching application on different user account ? check this link please : https://stackoverflow.com/a/24093533/5093606
You can get try to get list of accounts using
adb shell pm list users
and if you working account is there, try
adb shell am start --user WORKING_ACCOUNT com.example.MainActivity
Yes, there is way to launch the apps by using Appium/Adb commands. Instead of appium use adb commands to launch the apps.
The app which you have used for AndroidForWork enrollment, it should be in android:debuggable mode. Set debuggable mode to true and build the apk.
Once the device is enrolled/Configured Androidfor work then get the list of users.
adb shell pm list users UserInfo{0:Drew:13} running UserInfo{10:Work profile:30} running
Get the workprofile user id. In this case 10 is the id. Use the user id to launch the apps.
adb shell am start --user 10 -n "com.android.vending/com.google.android.finsky.activities.MainActivity"
Note: If the provision app is not enabled in Debug mode then you don't have the access to the work profile user.
Turns out I was able to accomplish this with Appium Desktop by adding another parameter to the inspector:
optionalIntentArguments text --user 12
Where '12' is the work profile id you'd see from typing this:
adb -d shell pm list users
Users:
UserInfo{0:Ken Corey:13} running
UserInfo{12:Workspace:50100030} running

How to hide/unhide app without root device 5.0 +

I make application that hide other apps. I succeed to hide and unhide other apps with rooted device. But when i was trying on unrooted device, not succeeded. I also tried with nfs, Device owner but not getting success. Followed these links. tried with manage permission also but not working. Please help me if anyone getting success without rooted device.
Error: root require:
E/hide: java.lang.SecurityException: Permission Denial: attempt to change component state from pid=23999, uid=10263, package uid=10264
followed these links below:
http://www.eoeandroid.com/thread-288229-1-1.html Install / Unistall from shell command in Android
You have to take device owner in order to use the hide/unhide api. You can use this guide to understand about the device owner
Once you have achieved device owner, you can use the following apis: setApplicationHidden.

Android uninstall device administrator using adb [duplicate]

This question already has answers here:
Disable DeviceAdmin from shell?
(3 answers)
Closed 4 years ago.
I have installed quick heal mobile security on my android device(Micromax Canvas A110) android version 4.1.4. I am trying to uninstall it, but not able to do so. After further googling, I found out that we would have to deactivate it from device administrator menu in settings.
I tried doing it, only to find that the window with options "cancel" and "deactivate" does not go away on clicking the "deactivate" button.
I tried to uninstall the app using the adb uninstall command after finding out the installed packages using: adb shell pm list packages which gave quick heal's package name as com.quickheal.platform.
But adb uninstall com.quickheal.platform command gives Failure
So how do I do it using adb?
I'm afraid there is no way to deactivate the device admin via adb. There has been made a proposal to open the device admin settings for quicker access in this post:
adb shell am start -S "com.android.settings/.Settings\$DeviceAdminSettingsActivity"
... however there is still some interaction needed.
On some devices the device administrator activity is not properly updated after confirmation in the dialog. So try to exit the settings menu completely and check whether it was just an UI issue.
Addition: according to comments below, it is possible to remove the device admin, if android:testOnly="true" or is missing from the AndroidManifest.xml file. Thx for the note!
just execute this code in your app!
DevicePolicyManager mDPM = (DevicePolicyManager) this.getSystemService(Context.DEVICE_POLICY_SERVICE);
mDPM.clearDeviceOwnerApp(getPackage());
This is possible, although it requires a rooted device (su access), and is a little messy. It involves doing a search for the app via its fully qualified name, and manually removing (rm -f) each found entry.
See articulated answer here: https://stackoverflow.com/a/29093349/3063884

Disable supersu permission dialog

Is it possible to disable the "grant/deny" popup dialog when my app needs to perform tasks that require root access? I have full control of the device the app will run on (internal project), the device is rooted and it has supersu 2.x app.
This tells me that I need to declare the android.permission.ACCESS_SUPERUSER permission for my app to disable the popup, but it has no effect.
Is there a simple way to solve this (without changing the option i supersu app settings)?
Remove the SuperSU APK (usually either /system/app/Superuser.apk or /data/app/eu.chainfire.supersu*.apk or /system/app/SuperSU/SuperSU.apk) and rm -rf the /data/data/eu.chainfire.supersu directory, and the su command will always grant access without showing the prompt.
If you're making a custom firmware image for your project, just exclude the APK.
Note that pm path eu.chainfire.supersu from an adb shell will give you the exact path for the APK.
You can't decide in you app to disable the prompt. That's a security measure which no app can change.
If your device is rooted and you have supersu, you can still get rid of the dialog. You have to change a setting in supersu: Settings --> Access --> Default access --> Grant
This is not possible, you can't interfere with the logic of another app, i.e. the one showing the popup when su is accessed (for example Superuser).

Categories

Resources