Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Same piece of code execued in Oreo Am unable to install updated Apk. #2

Open
Narendrakumar-Vanamala opened this issue Apr 16, 2020 · 7 comments

Comments

@Narendrakumar-Vanamala
Copy link

I tried out this project am unable to updated apk with new version code.

Please illustrate more details how to execute and what is procedure to install updated apk without user interaction.

If possible please provide me the detailed steps to achieve this.

after session.commit() - Nothing happened.

@sixo
Copy link
Owner

sixo commented Apr 16, 2020

The procedure is described in detail here (mentioned in README.md)
https://sisik.eu/blog/android/dev-admin/update-app

It was tested on devices up until Android 10 and working as expected.
Make sure that

  • your app is activated as device owner
  • your build has testOnly flag set to true (or it's a debug build) for device owner activation
  • your build has testOnly flag set to false for the updated.apk
  • you have the necessary permissions to read the update apk file

@Narendrakumar-Vanamala
Copy link
Author

Narendrakumar-Vanamala commented Apr 16, 2020

Thanks for the quick update

Need some clarification on few points.

1.adb shell dpm set-device-owner eu.sisik.devowner/.DevAdminReceiver - This cmd used to set device owner as a first point what you mentioned in the above.
2.Next step am setting testOnly true in the manifest file and run the application on device with version code 4
clarification required here, shall i generated singed build or debug build.
3.Now setting testOnly flag as false and generate new build with version code 5 and make it available from one of the folder - I provided permission for read & write. Now am able to the access the file.
clarification required here, shall i generated singed build or debug build.
4. All required permissions provided.

and one more observation found like
val dpm = getSystemService(Context.DEVICE_POLICY_SERVICE) as DevicePolicyManager
if (dpm.isDeviceOwnerApp(packageName))
Log.d(TAG, "is device owner")
else
Log.d(TAG, "not device owner")
Even am executing above first step, this method returns false always am getting logs as not device owner.

Please advice me on this.

@sixo
Copy link
Owner

sixo commented Apr 16, 2020

Starting since Android 7 (I think), you need to set testOnly flag to true (or use debug build), before you can call adb shell dpm .... Otherwise you'll get an error. So device owner won't be activated without this flag.

Once your app is activated as device owner, all updates (new apks with higher version code) should be build with testOnly=false

But from your last comment it looks like your issue is that you were not able to set your app as device owner. The shell command (adb shell dpm...) usually returns some hint on what's wrong. The usual issue is that you were not following the instructions carefully or you didn't read the error message properly (e.g. the device should have no accounts added before dev owner activation). In rare cases the OEM did something that won't allow you to activate your app as device owner.

@Narendrakumar-Vanamala
Copy link
Author

Thanks a lot for your support.

When am executing this command prompt adb shell dpm...
it's goes to next line and blinking nothing happen not showing any errors as well.

@sixo
Copy link
Owner

sixo commented Apr 16, 2020

So it looks like the issue is with your device. The command has to print out "SUCCESS" after executing. I guess there are some modifications to the standard Android system behaviour on your device. Sorry, can't help you with this.

@Narendrakumar-Vanamala
Copy link
Author

Thanks for your support.

I will try to test another device and if any support required updated here.

Thank you once again

@sixo
Copy link
Owner

sixo commented Apr 17, 2020

Maybe you could write the exact device model that wasn't working. Might help other people that want to create a kiosk device to decide what not to buy.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants