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

Commit 21c1729b authored by Jonathan Klee's avatar Jonathan Klee Committed by Mohammed Althaf T
Browse files

Allow to install Google signed Android Auto APK



- on top of our empty Android Auto stubs.

Signed-off-by: default avataralthafvly <althafvly@gmail.com>
parent 47f05c69
Loading
Loading
Loading
Loading
+7 −3
Original line number Diff line number Diff line
@@ -2495,7 +2495,7 @@
    <!-- The name of the package that will hold the system gallery role. -->
    <string name="config_systemGallery" translatable="false">com.android.gallery3d</string>
    <!-- The names of the packages that will hold the automotive projection role. -->
    <string name="config_systemAutomotiveProjection" translatable="false"></string>
    <string name="config_systemAutomotiveProjection" translatable="false">com.google.android.projection.gearhead:fdb00c43dbde8b51cb312aa81d3b5fa17713adb94b28f598d77f8eb89daceedf</string>
    <!-- The name of the package that will hold the system cluster service role. -->
    <string name="config_systemAutomotiveCluster" translatable="false"></string>
    <!-- The name of the package that will hold the system shell role. -->
@@ -5033,7 +5033,9 @@
         Note that config_companionDevicePackages and config_companionDeviceCerts are
         parallel arrays.
     -->
    <string-array name="config_companionDevicePackages" translatable="false"></string-array>
    <string-array name="config_companionDevicePackages" translatable="false">
        <item>com.google.android.projection.gearhead</item>
    </string-array>

    <!-- A list of SHA256 Certificates managing companion device(s) by the same manufacturers as
         the main device. It will fall back to showing a prompt if the association has been called
@@ -5042,7 +5044,9 @@
         arrays.
         Example: "1A:2B:3C:4D"
     -->
    <string-array name="config_companionDeviceCerts" translatable="false"></string-array>
    <string-array name="config_companionDeviceCerts" translatable="false">
        <item>FD:B0:0C:43:DB:DE:8B:51:CB:31:2A:A8:1D:3B:5F:A1:77:13:AD:B9:4B:28:F5:98:D7:7F:8E:B8:9D:AC:EE:DF</item>
    </string-array>

    <!-- A list of packages that auto-enable permissions sync feature.
         Note that config_companionPermSyncEnabledPackages and config_companionPermSyncEnabledCerts
+11 −3
Original line number Diff line number Diff line
@@ -234,6 +234,9 @@ final class InstallPackageHelper {
    // List of packages being installed
    private final Set<String> mInstallingPackages;

    public static final String PACKAGE_ANDROID_AUTO = "com.google.android.projection.gearhead";
    private static final String SIGNATURE_ANDROID_AUTO = "FDB00C43DBDE8B51CB312AA81D3B5FA17713ADB94B28F598D77F8EB89DACEEDF";
    public static final Set<String> ANDROID_AUTO_CERTS = new HashSet(Arrays.asList(SIGNATURE_ANDROID_AUTO));

    // TODO(b/198166813): remove PMS dependency
    InstallPackageHelper(PackageManagerService pm,
@@ -1844,7 +1847,7 @@ final class InstallPackageHelper {
                }

                // Check whether the newly-scanned package wants to define an already-defined perm
                if (bp != null) {
                if (bp != null && !isAndroidAutoApk(parsedPackage)) {
                    final String sourcePackageName = bp.getPackageName();

                    if (!doesSignatureMatchForPermissions(sourcePackageName, parsedPackage,
@@ -2071,8 +2074,8 @@ final class InstallPackageHelper {
                        // of the old package; this allows a rollback to a previously installed
                        // version after an app's signing key has been rotated without requiring
                        // the rollback capability on the previous signing key.
                        if (!isRollback || !oldPkgSigningDetails.hasAncestorOrSelf(
                                parsedPkgSigningDetails)) {
                        if (!isAndroidAutoApk(parsedPackage) && (!isRollback || !oldPkgSigningDetails.hasAncestorOrSelf(
                                parsedPkgSigningDetails))) {
                            throw new PrepareFailure(INSTALL_FAILED_UPDATE_INCOMPATIBLE,
                                    "New package has a different signature: " + pkgName11);
                        }
@@ -5058,4 +5061,9 @@ final class InstallPackageHelper {

        return scanFlags;
    }

    private boolean isAndroidAutoApk(ParsedPackage parsedPackage) {
        return parsedPackage.getPackageName().equals(PACKAGE_ANDROID_AUTO)
            && parsedPackage.getSigningDetails().hasAncestorOrSelfWithDigest(ANDROID_AUTO_CERTS);
    }
}
+10 −3
Original line number Diff line number Diff line
@@ -27,6 +27,8 @@ import static android.system.OsConstants.O_RDWR;
import static com.android.internal.content.NativeLibraryHelper.LIB64_DIR_NAME;
import static com.android.internal.content.NativeLibraryHelper.LIB_DIR_NAME;
import static com.android.server.LocalManagerRegistry.ManagerNotFoundException;
import static com.android.server.pm.InstallPackageHelper.PACKAGE_ANDROID_AUTO;
import static com.android.server.pm.InstallPackageHelper.ANDROID_AUTO_CERTS;
import static com.android.server.pm.PackageInstallerSession.APP_METADATA_FILE_ACCESS_MODE;
import static com.android.server.pm.PackageInstallerSession.getAppMetadataSizeLimit;
import static com.android.server.pm.PackageManagerService.COMPRESSED_EXTENSION;
@@ -524,7 +526,7 @@ public class PackageManagerServiceUtils {
                match = pkgSetting.getSigningDetails().hasAncestorOrSelf(parsedSignatures);
            }

            if (!match) {
            if (!match && !isAndroidAutoApk(packageName, parsedSignatures)) {
                throw new PackageManagerException(INSTALL_FAILED_UPDATE_INCOMPATIBLE,
                        "Existing package " + packageName
                                + " signatures do not match newer version; ignoring!");
@@ -557,7 +559,7 @@ public class PackageManagerServiceUtils {
                                SigningDetails.CertCapabilities.SHARED_USER_ID);
                compatMatch |= match;
            }
            if (!match) {
            if (!match && !isAndroidAutoApk(packageName, parsedSignatures)) {
                throw new PackageManagerException(INSTALL_FAILED_SHARED_USER_INCOMPATIBLE,
                        "Package " + packageName
                        + " has no signatures that match those in shared user "
@@ -566,7 +568,7 @@ public class PackageManagerServiceUtils {
            // If the lineage of this package diverges from the lineage of the sharedUserId then
            // do not allow the installation to proceed.
            if (!parsedSignatures.hasCommonAncestor(
                    sharedUserSetting.signatures.mSigningDetails)) {
                    sharedUserSetting.signatures.mSigningDetails) && !isAndroidAutoApk(packageName, parsedSignatures)) {
                throw new PackageManagerException(INSTALL_FAILED_SHARED_USER_INCOMPATIBLE,
                        "Package " + packageName + " has a signing lineage "
                                + "that diverges from the lineage of the sharedUserId");
@@ -1604,4 +1606,9 @@ public class PackageManagerServiceUtils {
            }
        }
    }

    private static boolean isAndroidAutoApk(String packageName, SigningDetails signingDetails) {
        return packageName.equals(PACKAGE_ANDROID_AUTO)
                && signingDetails.hasAncestorOrSelfWithDigest(ANDROID_AUTO_CERTS);
    }
}