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

Commit e1da3aea authored by Joanne Chung's avatar Joanne Chung
Browse files

Introduce a new use-sdk-lib attribute: optional, default false

1. Add a new use-sdk-lib attribute: optional`
2. Update the app install logic for checking sdk-lib dependency
3. Update the sdk-lib unintall logic if there are app dependencies

Bug: 295827951
Test: atest PackageManagerShellCommandInstallTest for the
flag/enable case
Test: atest PackageManagerSettingsTests
Test: atest ScanTests
Test: atest PackageParserTest
Test: atest AndroidPackageTest

Change-Id: Ib8a2056324d3007838c0953ad8b96c6353d2196b
parent 2b6ba138
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -1216,6 +1216,7 @@ package android {
    field public static final int opticalInsetLeft = 16844168; // 0x1010588
    field public static final int opticalInsetRight = 16844170; // 0x101058a
    field public static final int opticalInsetTop = 16844169; // 0x1010589
    field @FlaggedApi("android.content.pm.sdk_lib_independence") public static final int optional;
    field public static final int order = 16843242; // 0x10101ea
    field public static final int orderInCategory = 16843231; // 0x10101df
    field public static final int ordering = 16843490; // 0x10102e2
+4 −2
Original line number Diff line number Diff line
@@ -142,8 +142,10 @@ public final class SharedLibraryInfo implements Parcelable {
        mName = parcel.readString8();
        mVersion = parcel.readLong();
        mType = parcel.readInt();
        mDeclaringPackage = parcel.readParcelable(null, android.content.pm.VersionedPackage.class);
        mDependentPackages = parcel.readArrayList(null, android.content.pm.VersionedPackage.class);
        mDeclaringPackage =
                parcel.readParcelable(null, android.content.pm.VersionedPackage.class);
        mDependentPackages =
                parcel.readArrayList(null, android.content.pm.VersionedPackage.class);
        mDependencies = parcel.createTypedArrayList(SharedLibraryInfo.CREATOR);
        mIsNative = parcel.readBoolean();
    }
+1 −1
Original line number Diff line number Diff line
@@ -112,7 +112,7 @@ public interface ParsingPackage {
    ParsingPackage addUsesOptionalNativeLibrary(String libraryName);

    ParsingPackage addUsesSdkLibrary(String libraryName, long versionMajor,
            String[] certSha256Digests);
            String[] certSha256Digests, boolean usesSdkLibrariesOptional);

    ParsingPackage addUsesStaticLibrary(String libraryName, long version,
            String[] certSha256Digests);
+9 −0
Original line number Diff line number Diff line
@@ -1340,6 +1340,15 @@ public interface AndroidPackage {
    @Nullable
    long[] getUsesSdkLibrariesVersionsMajor();


    /**
     * @see R.styleable#AndroidManifestUsesSdkLibrary_optional
     * @hide
     */
    @Immutable.Ignore
    @Nullable
    boolean[] getUsesSdkLibrariesOptional();

    /**
     * TODO(b/135203078): Move static library stuff to an inner data class
     *
+4 −0
Original line number Diff line number Diff line
@@ -2515,6 +2515,10 @@
        <attr name="versionMajor" format="integer" />
        <!-- The SHA-256 digest of the SDK library signing certificate. -->
        <attr name="certDigest" format="string" />
        <!-- Specify whether the SDK is optional. The default is false, false means app can be
        installed even if the SDK library doesn't exist, and the SDK library can be uninstalled
        when the app is still installed. -->
        <attr name="optional" format="boolean" />
    </declare-styleable>

    <!-- The <code>static-library</code> tag declares that this apk is providing itself
Loading