PackageInstaller.uninstall() method not working in Android-TV (setup box) - android

For a setup box powered by Android(Q) we want the ability for an app which resides in /priv-app/ section to uninstall packages silently without user interaction.
I have root access to the device.
The app has android.permission.INSTALL_PACKAGES and android.permission.DELETE_PACKAGES permissions declared in the manifest.
When the same code is run on Android phones/ emulators with root access it is able to uninstall the app from the device (when the app is made as device owner).
But in case of Android-TV, there is no provision/section for enabling device admin apps, and if I try to enable it using command adb shell dpm set-device-owner com.tvdevice.deviceadminapp/.DevAdminReceiver
line it throws error
java.lang.RuntimeException: Can't set package ComponentInfo{com.tvdevice.deviceadminapp/com.tvdevice.deviceadminapp.DevAdminReceiver} as device owner.
at com.android.commands.dpm.Dpm.runSetDeviceOwner(Dpm.java:177)
at com.android.commands.dpm.Dpm.onRun(Dpm.java:106)
at com.android.internal.os.BaseCommand.run(BaseCommand.java:54)
at com.android.commands.dpm.Dpm.main(Dpm.java:41)
at com.android.internal.os.RuntimeInit.nativeFinishInit(Native Method)
at com.android.internal.os.RuntimeInit.main(RuntimeInit.java:340)
So as a workaround I directly edited the xml files device_owner_2.xml and device_policies.xml at /data/system/ to include my app as device owner, but still it is not able to uninstall the app installed from some other package (ex: com.android.vending, installer of package for apps installed from play).
Note: The app is able to uninstall the packages which are installed by it (to which the current app is installer of package), but it fails for apps installed from other sources.
Is there any way to make if work?, please help.

Related

Fire OS enable unknown app installation via ADB

I have a specific custom device that has a Fire OS vNext 7.0 (probably some kind of Fire TV type of the OS?) in it and I need to install my own APK into it.
I have an ADB access with root, but Developer Options are not enabled (I cannot access them), so I can't install the APK (adb install throws INSTALL_FAILURE_USER_RESTRICTED). I need to enable Developer Options to be able to enable installation of third party (unknown source) APKs.
I tried to tap the serial number 7 times in Settings - Device and Software - About as mentioned here, but it didn't do anything. I also tried to follow these steps, but the package com.android.settings does not have the shared_prefs directory that is mentioned there (and I didn't find any other settings package that would have such XML). I also tried to push the APK into the device, go to ADB shell (as root) and install via pm (ended up with the same result as adb install)
Is there any way how to either enable Developer Options so that they appear in the Settings menu, or how to directly enable unknown app installation? Or is there any other way how to install my APK?
I know it may sound weird that I have root ADB access without the Developer Options enabled, but that's just how it is, I already got this device in this state.

Removing non-system app using ADB shell in Android device

I removed an app existing in data folder of my device using adb shell , but while installing the app from my code in device its showing error that can not install over already existing signature. As of now, no app or package exist in my device of the same application.
Try to install it with help of "pm install" (not adb install) and post error text here. Possibly it's not fully uninstalled (which is ridiculous but possible in some cases). Also you need to be sure that app signed with production key and (if it's preinstalled app) with vendor key. In other case it's work would be unpredictable.

Android: How do I uninstall a platform-signed package via the command line

I'm running on a device with a custom Android platform for which I have the platform.keystore certificate. I was able to build an application, sign it with the platform key, and install it on my device. However, now that the package has been installed, I can't seem to uninstall it from the command line.
Since the device is running a production build of the OS, I can't run adb root from the command line to gain permissions. Also, I'm unable to run su from adb shell since I don't have permissions, so I can't go into /data/data and force remove the package.
I can think of a couple ways of uninstalling the package NOT from the command line:
Go into Settings->Apps and click Uninstall
Create another platform-signed app that uses reflection to access the uninstall API from PackageManager to uninstall it. Along these same lines, I could have the app send an Intent to PackageManager to prompt the user to uninstall the package.
That's great, but I'd really like to be able to uninstall the package from the command line. It seems like there should be parity here. Is there a way to uninstall a platform-signed package from the command line considering I have access to the signing certificate?
Do you know the app's package? If so, try
adb uninstall *com.name.of.package*
(as documented, for instance, at this site ).

My application wont allow me to open any other application

I created a sample package listener application which get launched when user clicks any other application. But currently I am not able to uninstall old version and even not able install updated version. The application is not allowing me to open settings or task manager or anything else. i am not able to do anything Please help me out. My phone get hacked by the application.
Is there any way to uninstall application?
You can use adb to uninstall your application. Connect your device to your computer, and execute the following command from a terminal or command prompt:
adb uninstall <package name>
(Assuming you have Android SDK installed and adb is in the application PATH)

How to test what will happen when you publish an update to your app to the Market

I'm about to publish a new version of an app to the Market. In order to avoid any potential problems once its been pushed to the Market and people get notified of an update, I'd like to simulate that process on my phone using the .apk for the new version of the app I'll be publishing.
For instance, it has an update to the SQLite DB it's using.
The closest I can find is using the Android Debug Bridge (adb) using the command:
adb install C:\myApplication.apk
with my phone attached to my PC via the usb cable.
(the parameter represents wherever your apk file is on your PC).
When I do this, if the app is already installed on my phone, I get an error message:
Failure INSTALL FAILED ALREADY EXISTS.
If I delete the existing app from my phone, the adb install command works fine.
So, it looks like this can only be used to install an app that doesn't currently exist on your phone.
Is there any way to simulate the update process?
It'd be nice if there was an adb update command, but I don't see that.
Try using option -r to adb install:
adb install [-l] [-r] [-s] -
push this package file to the device
and install it
('-l' means forward-lock the app)
('-r' means reinstall the app, keeping its
data)
('-s' means install on SD card instead of
internal storage)
The closest I think you can get is to put the APK somewhere, and download it on a phone. That is about the closest you can get to the real market situations, with the only difference being that you need to add the "unknown sources" option.
(on a sidenote: you can get an error installing an apk with the same package-name, but a different signing.)
I think your error is because you have the market signed version installed and your trying to install a debug signed version. If you sign it with your market key it should install fine.

Categories

Resources