@@ -78,7 +78,7 @@ class ShellInterface : IShellInterface.Stub() {
7878 val installFlags = this ::class .java.getField(" installFlags" )
7979 installFlags.set(
8080 this ,
81- installFlags.getInt(this ) or 0x00000002 , // android.content.pm.PackageManager.INSTALL_REPLACE_EXISTING
81+ installFlags.getInt(this ) or REPLACE_EXISTING_INSTALL_FLAG ,
8282 )
8383
8484 if (Build .VERSION .SDK_INT >= Build .VERSION_CODES .TIRAMISU ) {
@@ -119,18 +119,18 @@ class ShellInterface : IShellInterface.Stub() {
119119 Long ::class .java,
120120 ).invoke(session, " extension" , 0L , apk.length) as ParcelFileDescriptor
121121 ).let { fd ->
122- val revocable = Class .forName(" android.os.SystemProperties" )
123- .getMethod(" getBoolean" , String ::class .java, Boolean ::class .java)
124- .invoke(null , " fw.revocable_fd" , false ) as Boolean
125-
126- if (revocable) {
127- ParcelFileDescriptor .AutoCloseOutputStream (fd)
128- } else {
129- Class .forName($$" android.os.FileBridge$FileBridgeOutputStream " )
130- .getConstructor(ParcelFileDescriptor ::class .java)
131- .newInstance(fd) as OutputStream
122+ val revocable = Class .forName(" android.os.SystemProperties" )
123+ .getMethod(" getBoolean" , String ::class .java, Boolean ::class .java)
124+ .invoke(null , " fw.revocable_fd" , false ) as Boolean
125+
126+ if (revocable) {
127+ ParcelFileDescriptor .AutoCloseOutputStream (fd)
128+ } else {
129+ Class .forName($$" android.os.FileBridge$FileBridgeOutputStream " )
130+ .getConstructor(ParcelFileDescriptor ::class .java)
131+ .newInstance(fd) as OutputStream
132+ }
132133 }
133- }
134134 .use { output ->
135135 apk.createInputStream().use { input -> input.copyTo(output) }
136136 }
@@ -180,3 +180,7 @@ class ShellInterface : IShellInterface.Stub() {
180180 return shellContext.createPackageContext(" com.android.shell" , 0 )
181181 }
182182}
183+
184+ // Constant hidden from the SDK
185+ // https://cs.android.com/android/platform/superproject/main/+/512046e84bcc51cc241bc6599f83ab345e93ab12:frameworks/base/core/java/android/content/pm/PackageManager.java;l=1682-1689
186+ private const val REPLACE_EXISTING_INSTALL_FLAG = 0x00000002
0 commit comments