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

Commit bc592e98 authored by Winson's avatar Winson Committed by Winson Chiu
Browse files

Expose remaining PackageState APIs for ART

- isApex temporarily while the underlying flags refactor is ongoing
- getFirstInstallTime so ART can track app use times for an LRU cache
- isOverlay to allow `isLoadableInOtherProcesses` utility, although ART
    will likely not need to worry about this flag

API-Coverage-Bug: 262593427

Bug: 256637152

Change-Id: I748f77f2edd6f6469394f6152f4429b5c92d5101
parent 8462ad18
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -145,6 +145,7 @@ package com.android.server.pm.pkg {
    method public boolean isRequestLegacyExternalStorage();
    method public boolean isRequiredForAllUsers();
    method public boolean isResetEnabledSettingsOnAppDataCleared();
    method public boolean isResourceOverlay();
    method public boolean isRestoreAnyVersion();
    method public boolean isSignedWithPlatformKey();
    method public boolean isSupportsExtraLargeScreens();
@@ -179,12 +180,14 @@ package com.android.server.pm.pkg {
    method @Nullable public String getSecondaryCpuAbi();
    method @NonNull public com.android.server.pm.pkg.PackageUserState getStateForUser(@NonNull android.os.UserHandle);
    method @NonNull public java.util.List<com.android.server.pm.pkg.SharedLibrary> getUsesLibraries();
    method public boolean isApex();
    method public boolean isPrivileged();
    method public boolean isSystem();
    method public boolean isUpdatedSystemApp();
  }

  public interface PackageUserState {
    method public long getFirstInstallTimeMillis();
    method public boolean isInstalled();
  }

+3 −3
Original line number Diff line number Diff line
@@ -1481,8 +1481,8 @@ public class ComputerEngine implements Computer {
                    : mPermissionManager.getGrantedPermissions(ps.getPackageName(), userId);

            PackageInfo packageInfo = PackageInfoUtils.generate(p, gids, flags,
                    state.getFirstInstallTime(), ps.getLastUpdateTime(), permissions, state, userId,
                    ps);
                    state.getFirstInstallTimeMillis(), ps.getLastUpdateTime(), permissions, state,
                    userId, ps);

            if (packageInfo == null) {
                return null;
@@ -1499,7 +1499,7 @@ public class ComputerEngine implements Computer {
            pi.setLongVersionCode(ps.getVersionCode());
            SharedUserApi sharedUser = mSettings.getSharedUserFromPackageName(pi.packageName);
            pi.sharedUserId = (sharedUser != null) ? sharedUser.getName() : null;
            pi.firstInstallTime = state.getFirstInstallTime();
            pi.firstInstallTime = state.getFirstInstallTimeMillis();
            pi.lastUpdateTime = ps.getLastUpdateTime();

            ApplicationInfo ai = new ApplicationInfo();
+1 −1
Original line number Diff line number Diff line
@@ -6460,7 +6460,7 @@ public class PackageManagerService implements PackageSender, TestUtilityService
            List<String> targetPackages = new ArrayList<>();
            PackageManagerService.this.forEachPackageState(snapshot(), packageState -> {
                final AndroidPackage pkg = packageState.getPkg();
                if (pkg != null && !pkg.isOverlay()) {
                if (pkg != null && !pkg.isResourceOverlay()) {
                    targetPackages.add(pkg.getPackageName());
                }
            });
+10 −3
Original line number Diff line number Diff line
@@ -328,7 +328,7 @@ public class PackageSetting extends SettingBase implements PackageStateInternal
            int[] userIds) {
        for (int userId = 0; userId < userIds.length; userId++) {
            final long previousFirstInstallTime =
                    replacedPkgSetting.getUserStateOrDefault(userId).getFirstInstallTime();
                    replacedPkgSetting.getUserStateOrDefault(userId).getFirstInstallTimeMillis();
            if (previousFirstInstallTime != 0) {
                modifyUserState(userId).setFirstInstallTime(previousFirstInstallTime);
            }
@@ -897,7 +897,7 @@ public class PackageSetting extends SettingBase implements PackageStateInternal
                        ? null : otherState.getDisabledComponentsNoCopy().untrackedStorage(),
                otherState.getInstallReason(), otherState.getUninstallReason(),
                otherState.getHarmfulAppWarning(), otherState.getSplashScreenTheme(),
                otherState.getFirstInstallTime());
                otherState.getFirstInstallTimeMillis());
    }

    WatchedArraySet<String> getEnabledComponents(int userId) {
@@ -1091,7 +1091,7 @@ public class PackageSetting extends SettingBase implements PackageStateInternal
                    PackageProto.UserInfoProto.LAST_DISABLED_APP_CALLER,
                    state.getLastDisableAppCaller());
            proto.write(PackageProto.UserInfoProto.FIRST_INSTALL_TIME_MS,
                    state.getFirstInstallTime());
                    state.getFirstInstallTimeMillis());
            proto.end(userToken);
        }
    }
@@ -1386,6 +1386,13 @@ public class PackageSetting extends SettingBase implements PackageStateInternal
        return AndroidPackageUtils.getHiddenApiEnforcementPolicy(getAndroidPackage(), this);
    }

    @Override
    public boolean isApex() {
        // TODO(b/256637152):
        // TODO(b/243839669): Use a flag tracked directly in PackageSetting
        return getAndroidPackage() != null && getAndroidPackage().isApex();
    }



    // Code below generated by codegen v1.0.23.
+1 −1
Original line number Diff line number Diff line
@@ -406,7 +406,7 @@ final class ScanPackageUtils {
        final long scanFileTime = getLastModifiedTime(parsedPackage);
        final long existingFirstInstallTime = userId == UserHandle.USER_ALL
                ? PackageStateUtils.getEarliestFirstInstallTime(pkgSetting.getUserStates())
                : pkgSetting.readUserState(userId).getFirstInstallTime();
                : pkgSetting.readUserState(userId).getFirstInstallTimeMillis();
        if (currentTime != 0) {
            if (existingFirstInstallTime == 0) {
                pkgSetting.setFirstInstallTime(currentTime, userId)
Loading