The progressions of APK introduce area since Android Oreo

0/5 No votes

Report this app

Description

The progressions of APK introduce area since Android Oreo

In Google’s true record of “Android 8.0 Behavior Changes”, it referenced:

  • You can at this point don’t accept that APKs dwell in indexes whose names end in – 1 or – 2. Applications should usesourceDir to get the catalog, and not depend on the registry design straightforwardly.

Be that as it may, what occurred toward the finish of the APK introduce area?

In Android 7.0 and previously, after an APK is introduced, it will be situated in/information/application way. All the more explicitly, in Android 7.0, the APK record will be introduced into/information/application/-/organizer, where the is the bundle name of the APK, and the num might be 1 or 2. We can introduce a genuine APK of an Android application for instance:

Get an established Android 7.0 telephone (or utilizing an Android 7.0 emulator), introduce an application named “APUS Launcher” from
https://play.google.com/store/applications/details?id=com.apusapps.launcher, and use ADB shell to sign in to the telephone:

apkdig.com

We can see that there are an organizer named “com.apusapps.launcher-1” in/information/application way, and the APK record is situated in that envelope, named “base.apk”.

On the off chance that we have effectively introduced “APUS Launcher” previously, and overhauling it to its new form (which implies the current APK document will be overwritten by the new form), the “com.apusapps.launcher-1” envelope will be renamed to “com.apusapps.launcher-2” after the redesigning:

1_zpCWmGaxZesZPafJppVmMQ

The mystery is in the code of PackageManagerService.java (ref: https://android.googlesource.com/stage/systems/base/+/android-7.1.2_r36/administrations/center/java/com/android/worker/pm/PackageManagerService.java):

private File getNextCodePath(File targetDir, String packageName) {
int suffix = 1;
File result;
do {
result = new File(targetDir, packageName + “-” + suffix);
suffix++;
} while (result.exists());
return result;
}

At the point when PackageManagerService is introducing an APK, it initially introduces it in a brief way (for instance,/information/application/vmdl439623483.tmp/base.apk), and in the last advances, it will rename the impermanent way to the last name (ref to installPackageLI technique). To ensure the last name doesn’t struggle with some current way, it will expand the quantity of addition over and over.
Since Android Oreo, the code has been changed (ref: https://android.googlesource.com/stage/systems/base/+/android-8.0.0_r36/administrations/center/java/com/android/worker/pm/PackageManagerService.java):

private File getNextCodePath(File targetDir, String packageName) {
File result;
SecureRandom random = new SecureRandom();
byte[] bytes = new byte[16];
do {
random.nextBytes(bytes);
String suffix = Base64.encodeToString(bytes, Base64.URL_SAFE | Base64.NO_WRAP);
result = new File(targetDir, packageName + “-” + suffix);
} while (result.exists());
return result;
}

Each time while renaming, it simply takes an irregular base64 string as the postfix. Furthermore, the base64 string will be changed while overhauling the APK to another form.

1_xLNipFdoExC-ZegiNLirNA

Since the introduced area of the APK record has been changed arbitrarily, we can at this point don’t figure the real way of an introduced application. UsingsourceDir to get the index will be the solitary way. Presently we can comprehend the assertion of Google’s archive.

Leave a Reply

Your email address will not be published.