Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit caa71192 authored by Narayan Kamath's avatar Narayan Kamath
Browse files

Temporary workaround for getApplicationInfo + multiArch.

Google play services client libraries construct native paths
using pm.getApplicationInfo().nativeLibraryDir.

This is a temporary workaround until we've switched all code
over to pm.createPackageContext().getApplicationInfo() or
whatever API we decide on to surface correct multi-arch
lib paths.

bug: 16013931

Change-Id: Ib719cf6f31da9a29b76e942cd2e28bda1f19b264
parent d8723bd3
Loading
Loading
Loading
Loading
+23 −0
Original line number Diff line number Diff line
@@ -62,6 +62,7 @@ import android.util.ArrayMap;
import android.util.Log;
import android.view.Display;
import com.android.internal.util.Preconditions;
import dalvik.system.VMRuntime;

import java.lang.ref.WeakReference;
import java.util.ArrayList;
@@ -251,6 +252,10 @@ final class ApplicationPackageManager extends PackageManager {
        try {
            ApplicationInfo ai = mPM.getApplicationInfo(packageName, flags, mContext.getUserId());
            if (ai != null) {
                // This is a temporary hack. Callers must use
                // createPackageContext(packageName).getApplicationInfo() to
                // get the right paths.
                maybeAdjustApplicationInfo(ai);
                return ai;
            }
        } catch (RemoteException e) {
@@ -260,6 +265,24 @@ final class ApplicationPackageManager extends PackageManager {
        throw new NameNotFoundException(packageName);
    }

    private static void maybeAdjustApplicationInfo(ApplicationInfo info) {
        // If we're dealing with a multi-arch application that has both
        // 32 and 64 bit shared libraries, we might need to choose the secondary
        // depending on what the current runtime's instruction set is.
        if (info.primaryCpuAbi != null && info.secondaryCpuAbi != null) {
            final String runtimeIsa = VMRuntime.getRuntime().vmInstructionSet();
            final String secondaryIsa = VMRuntime.getInstructionSet(info.secondaryCpuAbi);

            // If the runtimeIsa is the same as the primary isa, then we do nothing.
            // Everything will be set up correctly because info.nativeLibraryDir will
            // correspond to the right ISA.
            if (runtimeIsa.equals(secondaryIsa)) {
                info.nativeLibraryDir = info.secondaryNativeLibraryDir;
            }
        }
    }


    @Override
    public ActivityInfo getActivityInfo(ComponentName className, int flags)
            throws NameNotFoundException {