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

Commit acd81de5 authored by Winson's avatar Winson
Browse files

Clean up and expose simple AndroidPackage APIs

The remaining simple APIs were exposed except:
- Anything that is based on known derived state that may be overlaid
    in the PackageState or PackageUserState (isEnabled)
- The other non-target SDK versions, which are probably better tracked
    in the PackageState, and are unlikely to be useful as API
- Anything not inherently immutable, the path for which is not finalized
- Complex APIs spanning multiple methods (resizeable)
- APIs that might be better served by other surfaces
    (overlays, SDKs, shared libraries)

API-Coverage-Bug: 262593427

Bug: 235462722

Test: atest AndroidPackageTest

Change-Id: Id08cb58dcf9715ce8771ec203dc395ac4fe0a88e
parent 7c0634d9
Loading
Loading
Loading
Loading
+74 −0
Original line number Diff line number Diff line
@@ -72,16 +72,90 @@ package com.android.server.pm {
package com.android.server.pm.pkg {

  public interface AndroidPackage {
    method @Nullable public String getAppComponentFactory();
    method @Nullable public String getApplicationClassName();
    method @Nullable public String getBackupAgentName();
    method @DrawableRes public int getBannerRes();
    method public int getBaseRevisionCode();
    method public int getCategory();
    method @Nullable public String getClassLoaderName();
    method @Dimension(unit=android.annotation.Dimension.DP) public int getCompatibleWidthLimitDp();
    method @XmlRes public int getDataExtractionRulesRes();
    method @StringRes public int getDescriptionRes();
    method @XmlRes public int getFullBackupContentRes();
    method public int getGwpAsanMode();
    method @DrawableRes public int getIconRes();
    method @StringRes public int getLabelRes();
    method @Dimension(unit=android.annotation.Dimension.DP) public int getLargestWidthLimitDp();
    method @NonNull public java.util.List<java.lang.String> getLibraryNames();
    method @XmlRes public int getLocaleConfigRes();
    method @DrawableRes public int getLogoRes();
    method public long getLongVersionCode();
    method public float getMaxAspectRatio();
    method public float getMinAspectRatio();
    method public int getNativeHeapZeroInitialized();
    method @XmlRes public int getNetworkSecurityConfigRes();
    method @Nullable public String getRequiredAccountType();
    method @Dimension(unit=android.annotation.Dimension.DP) public int getRequiresSmallestWidthDp();
    method @Nullable public String getRestrictedAccountType();
    method @DrawableRes public int getRoundIconRes();
    method @Nullable public String getSdkLibraryName();
    method @Nullable public String getSharedUserId();
    method @StringRes public int getSharedUserLabelRes();
    method @NonNull public java.util.List<com.android.server.pm.pkg.AndroidPackageSplit> getSplits();
    method @Nullable public String getStaticSharedLibraryName();
    method @NonNull public java.util.UUID getStorageUuid();
    method public int getTargetSdkVersion();
    method @StyleRes public int getThemeRes();
    method public int getUiOptions();
    method @Nullable public String getVersionName();
    method @Nullable public String getZygotePreloadName();
    method public boolean isAllowAudioPlaybackCapture();
    method public boolean isAllowBackup();
    method public boolean isAllowClearUserData();
    method public boolean isAllowClearUserDataOnFailedRestore();
    method public boolean isAllowNativeHeapPointerTagging();
    method public boolean isAllowTaskReparenting();
    method public boolean isAnyDensity();
    method public boolean isAttributionsUserVisible();
    method public boolean isBackupInForeground();
    method public boolean isCantSaveState();
    method public boolean isCoreApp();
    method public boolean isCrossProfile();
    method public boolean isDebuggable();
    method public boolean isDefaultToDeviceProtectedStorage();
    method public boolean isDirectBootAware();
    method public boolean isExtractNativeLibs();
    method public boolean isFactoryTest();
    method public boolean isForceQueryable();
    method public boolean isFullBackupOnly();
    method public boolean isHardwareAccelerated();
    method public boolean isHasCode();
    method public boolean isHasFragileUserData();
    method public boolean isIsolatedSplitLoading();
    method public boolean isKillAfterRestore();
    method public boolean isLargeHeap();
    method public boolean isLeavingSharedUser();
    method public boolean isMultiArch();
    method public boolean isNativeLibraryRootRequiresIsa();
    method public boolean isOnBackInvokedCallbackEnabled();
    method public boolean isPersistent();
    method public boolean isProfileable();
    method public boolean isProfileableByShell();
    method public boolean isRequestLegacyExternalStorage();
    method public boolean isRequiredForAllUsers();
    method public boolean isResetEnabledSettingsOnAppDataCleared();
    method public boolean isRestoreAnyVersion();
    method public boolean isSignedWithPlatformKey();
    method public boolean isSupportsExtraLargeScreens();
    method public boolean isSupportsLargeScreens();
    method public boolean isSupportsNormalScreens();
    method public boolean isSupportsRtl();
    method public boolean isSupportsSmallScreens();
    method public boolean isTestOnly();
    method public boolean isUse32BitAbi();
    method public boolean isUseEmbeddedDex();
    method public boolean isUsesCleartextTraffic();
    method public boolean isUsesNonSdkApi();
    method public boolean isVmSafeMode();
  }
+2 −1
Original line number Diff line number Diff line
@@ -2045,7 +2045,8 @@ public class ComputerEngine implements Computer {
        }

        final SharedLibraryInfo libraryInfo = getSharedLibraryInfo(
                ps.getPkg().getStaticSharedLibraryName(), ps.getPkg().getStaticSharedLibVersion());
                ps.getPkg().getStaticSharedLibraryName(),
                ps.getPkg().getStaticSharedLibraryVersion());
        if (libraryInfo == null) {
            return false;
        }
+1 −1
Original line number Diff line number Diff line
@@ -186,7 +186,7 @@ final class DeletePackageHelper {
                SharedLibraryInfo libraryInfo = null;
                if (pkg.getStaticSharedLibraryName() != null) {
                    libraryInfo = computer.getSharedLibraryInfo(pkg.getStaticSharedLibraryName(),
                            pkg.getStaticSharedLibVersion());
                            pkg.getStaticSharedLibraryVersion());
                } else if (pkg.getSdkLibraryName() != null) {
                    libraryInfo = computer.getSharedLibraryInfo(pkg.getSdkLibraryName(),
                            pkg.getSdkLibVersionMajor());
+5 −5
Original line number Diff line number Diff line
@@ -297,7 +297,7 @@ final class InstallPackageHelper {
        SharedUserSetting sharedUserSetting = mPm.mSettings.getSharedUserSettingLPr(pkgSetting);
        if (sharedUserSetting != null) {
            sharedUserSetting.addPackage(pkgSetting);
            if (parsedPackage.isLeavingSharedUid()
            if (parsedPackage.isLeavingSharedUser()
                    && SharedUidMigration.applyStrategy(BEST_EFFORT)
                    && sharedUserSetting.isSingleUser()) {
                // Attempt the transparent shared UID migration
@@ -1552,7 +1552,7 @@ final class InstallPackageHelper {
                    }

                    // APK should not re-join shared UID
                    if (oldPackage.isLeavingSharedUid() && !parsedPackage.isLeavingSharedUid()) {
                    if (oldPackage.isLeavingSharedUser() && !parsedPackage.isLeavingSharedUser()) {
                        throw new PrepareFailure(INSTALL_FAILED_UID_CHANGED,
                                "Package " + parsedPackage.getPackageName()
                                        + " attempting to rejoin " + newSharedUid);
@@ -3801,7 +3801,7 @@ final class InstallPackageHelper {
            if (installedPkgSetting == null || !installedPkgSetting.hasSharedUser()) {
                // Directly ignore sharedUserSetting for new installs, or if the app has
                // already left shared UID
                ignoreSharedUserId = parsedPackage.isLeavingSharedUid();
                ignoreSharedUserId = parsedPackage.isLeavingSharedUser();
            }

            if (!ignoreSharedUserId && parsedPackage.getSharedUserId() != null) {
@@ -4324,10 +4324,10 @@ final class InstallPackageHelper {
                SharedLibraryInfo libInfo = versionedLib.valueAt(i);
                final long libVersionCode = libInfo.getDeclaringPackage()
                        .getLongVersionCode();
                if (libInfo.getLongVersion() < pkg.getStaticSharedLibVersion()) {
                if (libInfo.getLongVersion() < pkg.getStaticSharedLibraryVersion()) {
                    minVersionCode = Math.max(minVersionCode, libVersionCode + 1);
                } else if (libInfo.getLongVersion()
                        > pkg.getStaticSharedLibVersion()) {
                        > pkg.getStaticSharedLibraryVersion()) {
                    maxVersionCode = Math.min(maxVersionCode, libVersionCode - 1);
                } else {
                    minVersionCode = maxVersionCode = libVersionCode;
+1 −1
Original line number Diff line number Diff line
@@ -2878,7 +2878,7 @@ public class PackageManagerService implements PackageSender, TestUtilityService
    static void renameStaticSharedLibraryPackage(ParsedPackage parsedPackage) {
        // Derive the new package synthetic package name
        parsedPackage.setPackageName(toStaticSharedLibraryPackageName(
                parsedPackage.getPackageName(), parsedPackage.getStaticSharedLibVersion()));
                parsedPackage.getPackageName(), parsedPackage.getStaticSharedLibraryVersion()));
    }

    private static String toStaticSharedLibraryPackageName(
Loading