Sunday, 27 October 2019

Why does my application roll back to a previous version after device shutdown?

Observed this very strange behavior with Android application. Approximate scenario:

  1. Version A installed on the device
  2. Application works alright
  3. Version B installed on the device (B > A)
  4. Application works alright
  5. Device shuts down due to battery drain
  6. Device turned on
  7. Version A of the application runs on the device again

Additional info:

  • The application isn't distributed through Google Play, but installed on-premise via USB connection.
  • Kiosk
  • Android 5.1 (API 22)

I guess I've got two questions:

  • Why the device cached the older version of the APK (and where did it cache it)?
  • Under which circumstances can applications roll back to previous versions like that?

Edit (more information):

  • It looks like after the APK is rolled back, the application loses some permissions (maybe even all). Functionality that worked before the roll-back stops working due to SecurityException being thrown from Android's APIs. This happens even though this version of Android doesn't have runtime permissions yet!
  • After browsing tablet's filesystem, I indeed see several app's APKs residing under similar paths: /data/app/com.myapp-2/base.apk, /data/app/com.myapp-3/base.apk, etc.

My current hypothesis is that battery drain causes the tablet to "reset" its state (for example, the clock is also reset), and when it's powered again it confuses between app's APKs and loads the wrong one.

However, I have no clue why would it do that, or how to prevent this behavior.



from Why does my application roll back to a previous version after device shutdown?

No comments:

Post a Comment