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

Commit 31569a17 authored by JW Wang's avatar JW Wang
Browse files

Migrate from ApexManager#getPackageInfo

We will store all package information in PMS and ApexManager#getPackageInfo
will be removed. All queries about package information should be done
via PM.

Bug: 225756739
Test: presubmit
Change-Id: Ic40c3f4eff97b53e6ec4c733b3f68cf264db103f
parent 31d7d856
Loading
Loading
Loading
Loading
+6 −4
Original line number Diff line number Diff line
@@ -23,6 +23,7 @@ import android.app.ActivityManager;
import android.content.Context;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.content.pm.UserInfo;
import android.os.Environment;
import android.os.SystemClock;
@@ -162,16 +163,17 @@ public final class SystemServiceManager implements Dumpable {
    /**
     * Returns true if the jar is in a test APEX.
     */
    private static boolean isJarInTestApex(String pathStr) {
    private boolean isJarInTestApex(String pathStr) {
        Path path = Paths.get(pathStr);
        if (path.getNameCount() >= 2 && path.getName(0).toString().equals("apex")) {
            String apexModuleName = path.getName(1).toString();
            ApexManager apexManager = ApexManager.getInstance();
            String packageName = apexManager.getActivePackageNameForApexModuleName(apexModuleName);
            PackageInfo packageInfo = apexManager.getPackageInfo(
                    packageName, ApexManager.MATCH_ACTIVE_PACKAGE);
            if (packageInfo != null) {
            try {
                PackageInfo packageInfo =  mContext.getPackageManager().getPackageInfo(packageName,
                        PackageManager.PackageInfoFlags.of(PackageManager.MATCH_APEX));
                return (packageInfo.applicationInfo.flags & ApplicationInfo.FLAG_TEST_ONLY) != 0;
            } catch (Exception ignore) {
            }
        }
        return false;