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

Commit eed5bcbf authored by Victor Hsieh's avatar Victor Hsieh
Browse files

Match APEX by module name instead of package name

Bug: 264925790
Test: confirm the fix by comparing `cmd transparency get apex_info -v`
      before and after
Change-Id: I7a6f6f57d534da2f0708400142db25a5d5099925
parent 9de0548a
Loading
Loading
Loading
Loading
+7 −1
Original line number Diff line number Diff line
@@ -64,6 +64,7 @@ import android.util.apk.ApkSigningBlockUtils;
import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.os.IBinaryTransparencyService;
import com.android.internal.util.FrameworkStatsLog;
import com.android.server.pm.ApexManager;

import libcore.util.HexEncoding;

@@ -1238,10 +1239,15 @@ public class BinaryTransparencyService extends SystemService {
    private String getOriginalApexPreinstalledLocation(String packageName,
            String currentInstalledLocation) {
        try {
            // It appears that only apexd knows the preinstalled location, and it uses module name
            // as the identifier instead of package name. Given the input is a package name, we
            // need to covert to module name.
            final String moduleName = ApexManager.getInstance().getApexModuleNameForPackageName(
                    packageName);
            IApexService apexService = IApexService.Stub.asInterface(
                    Binder.allowBlocking(ServiceManager.waitForService("apexservice")));
            for (ApexInfo info : apexService.getAllPackages()) {
                if (packageName.equals(info.moduleName)) {
                if (moduleName.equals(info.moduleName)) {
                    return info.preinstalledModulePath;
                }
            }