Repository navigation
Throw error if DELETE_FAILED_DEVICE_POLICY_MANAGER is sent - #513
Merged
koral-- merged 1 commit intoOct 20, 2023
Merged
Conversation
koral--
approved these changes
Oct 20, 2023
Member
|
LGTM, but the sign-off is missing. |
Signed-off-by: Burak Demir <[email protected]>
tburakdemir
force-pushed
the
handle-uninstalling-failure
branch
from
October 20, 2023 15:29
4e119a0 to
c3b102d
Compare
Author
|
signed off, thank you |
Author
|
How can I get this pr from npm. Is there any planning of version update? |
Member
|
Sorry for the delay, I've just released version 3.2.6. |
UrielCh
added a commit
to UrielCh/adbkit
that referenced
this pull request
Jan 27, 2024
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Hi,
Some of our client's apk can not be installed due to DELETE_FAILED_DEVICE_POLICY_MANAGER error of adb. In codebase returns true either way so we can't catch the apk is actually uninstalled.
This apk has device admin permission. If it is authorized then it can not be uninstalled regular way. First we must disable policy with "adb shell pm disable-user pkg" then uninstall it with normal way.
I share you an example apk has this permission:
https://apkcombo.com/device-administrator/io.ebeck.jacob.deviceadmin/download/apk
After the installation apk;
Open the app
Click the Enable Device Admin
It opens android permision pop-up
Click activate.
Then you could not uninstall the apk in normal way. It responds with "Failure [DELETE_FAILED_DEVICE_POLICY_MANAGER]"
So In the code i made some changes that throws an error if this event occurs. So in my workspace i can catch it then solved like above solution.
`import { Adb } from './src';
const client = Adb.createClient();
const udid = 'emulator-5554';
const element = 'io.ebeck.jacob.deviceadmin';
const device = client.getDevice(udid);
async function uninstall() {
try {
const result = await device.uninstall(element);
console.log(result);
} catch (error: any) {
console.log(error.message);
await device.shell("pm disable-user " + element)
.then(Adb.util.readAll)
.then((output) => {
console.log('[%s] %s', device.serial, output.toString().trim());
})
const result = await device.uninstall(element);
console.log(result);
}
}
uninstall();
`
https://developer.android.com/reference/android/app/admin/DevicePolicyManager
https://stackoverflow.com/questions/13911444/disable-deviceadmin-from-shell