OSDN Git Service

Enable the PRC compatibility package feature for PRC market
[android-x86/frameworks-base.git] / core / java / com / android / internal / content / NativeLibraryHelper.java
index fee8345..9472a3e 100644 (file)
@@ -78,6 +78,7 @@ public class NativeLibraryHelper {
         final boolean multiArch;
         final boolean extractNativeLibs;
         final boolean debuggable;
+        final String pkgName;
 
         public static Handle create(File packageFile) throws IOException {
             try {
@@ -92,16 +93,16 @@ public class NativeLibraryHelper {
             return create(pkg.getAllCodePaths(),
                     (pkg.applicationInfo.flags & ApplicationInfo.FLAG_MULTIARCH) != 0,
                     (pkg.applicationInfo.flags & ApplicationInfo.FLAG_EXTRACT_NATIVE_LIBS) != 0,
-                    (pkg.applicationInfo.flags & ApplicationInfo.FLAG_DEBUGGABLE) != 0);
+                    (pkg.applicationInfo.flags & ApplicationInfo.FLAG_DEBUGGABLE) != 0, pkg.packageName);
         }
 
         public static Handle create(PackageLite lite) throws IOException {
             return create(lite.getAllCodePaths(), lite.multiArch, lite.extractNativeLibs,
-                    lite.debuggable);
+                    lite.debuggable, lite.packageName);
         }
 
         private static Handle create(List<String> codePaths, boolean multiArch,
-                boolean extractNativeLibs, boolean debuggable) throws IOException {
+                boolean extractNativeLibs, boolean debuggable, String pkgName) throws IOException {
             final int size = codePaths.size();
             final long[] apkHandles = new long[size];
             for (int i = 0; i < size; i++) {
@@ -116,7 +117,7 @@ public class NativeLibraryHelper {
                 }
             }
 
-            return new Handle(apkHandles, multiArch, extractNativeLibs, debuggable);
+            return new Handle(apkHandles, multiArch, extractNativeLibs, debuggable, pkgName);
         }
 
         public static Handle createFd(PackageLite lite, FileDescriptor fd) throws IOException {
@@ -127,15 +128,16 @@ public class NativeLibraryHelper {
                 throw new IOException("Unable to open APK " + path + " from fd " + fd);
             }
 
-            return new Handle(apkHandles, lite.multiArch, lite.extractNativeLibs, lite.debuggable);
+            return new Handle(apkHandles, lite.multiArch, lite.extractNativeLibs, lite.debuggable, lite.packageName);
         }
 
         Handle(long[] apkHandles, boolean multiArch, boolean extractNativeLibs,
-                boolean debuggable) {
+                boolean debuggable, String pkgName) {
             this.apkHandles = apkHandles;
             this.multiArch = multiArch;
             this.extractNativeLibs = extractNativeLibs;
             this.debuggable = debuggable;
+            this.pkgName = pkgName;
             mGuard.open("close");
         }
 
@@ -210,7 +212,13 @@ public class NativeLibraryHelper {
     public static int findSupportedAbi(Handle handle, String[] supportedAbis) {
         int finalRes = NO_NATIVE_LIBRARIES;
         for (long apkHandle : handle.apkHandles) {
-            final int res = nativeFindSupportedAbi(apkHandle, supportedAbis, handle.debuggable);
+            int res;
+            if (true) {
+                res = nativeFindSupportedAbiReplace(apkHandle, supportedAbis, handle.debuggable, handle.pkgName);
+            } else {
+                res = nativeFindSupportedAbi(apkHandle, supportedAbis, handle.debuggable);
+            }
+
             if (res == NO_NATIVE_LIBRARIES) {
                 // No native code, keep looking through all APKs.
             } else if (res == INSTALL_FAILED_NO_MATCHING_ABIS) {
@@ -235,6 +243,9 @@ public class NativeLibraryHelper {
     private native static int nativeFindSupportedAbi(long handle, String[] supportedAbis,
             boolean debuggable);
 
+    private native static int nativeFindSupportedAbiReplace(long handle, String[] supportedAbis,
+            boolean debuggable, String pkgName);
+
     // Convenience method to call removeNativeBinariesFromDirLI(File)
     public static void removeNativeBinariesLI(String nativeLibraryPath) {
         if (nativeLibraryPath == null) return;