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

Commit 3af08a79 authored by Winson Chiu's avatar Winson Chiu
Browse files

Fix VerifyingSession disabled check

Passes the verifierUser and updates the Computer APIs to take in
a UserHandle to avoid future confusion of the ints.

Bug: 272585343

Change-Id: I579ae2e8584f40ebb5fb695ea27fc4acd915da15
parent e334986d
Loading
Loading
Loading
Loading
+4 −2
Original line number Diff line number Diff line
@@ -41,6 +41,7 @@ import android.content.pm.SharedLibraryInfo;
import android.content.pm.SigningDetails;
import android.content.pm.UserInfo;
import android.content.pm.VersionedPackage;
import android.os.UserHandle;
import android.util.ArrayMap;
import android.util.ArraySet;
import android.util.Pair;
@@ -519,14 +520,15 @@ public interface Computer extends PackageDataSnapshot {
     * returns false.
     */
    boolean isComponentEffectivelyEnabled(@NonNull ComponentInfo componentInfo,
            @UserIdInt int userId);
            @NonNull UserHandle userHandle);

    /**
     * @return true if the runtime app user enabled state and the install-time app manifest enabled
     * state are both effectively enabled for the given app. Or if the app cannot be found,
     * returns false.
     */
    boolean isApplicationEffectivelyEnabled(@NonNull String packageName, @UserIdInt int userId);
    boolean isApplicationEffectivelyEnabled(@NonNull String packageName,
            @NonNull UserHandle userHandle);

    @Nullable
    KeySet getKeySetByAlias(@NonNull String packageName, @NonNull String alias);
+5 −3
Original line number Diff line number Diff line
@@ -5129,9 +5129,10 @@ public class ComputerEngine implements Computer {

    @Override
    public boolean isComponentEffectivelyEnabled(@NonNull ComponentInfo componentInfo,
            @UserIdInt int userId) {
            @NonNull UserHandle userHandle) {
        try {
            String packageName = componentInfo.packageName;
            int userId = userHandle.getIdentifier();
            int appEnabledSetting =
                    mSettings.getApplicationEnabledSetting(packageName, userId);
            if (appEnabledSetting == COMPONENT_ENABLED_STATE_DEFAULT) {
@@ -5154,9 +5155,10 @@ public class ComputerEngine implements Computer {

    @Override
    public boolean isApplicationEffectivelyEnabled(@NonNull String packageName,
            @UserIdInt int userId) {
            @NonNull UserHandle userHandle) {
        try {
            int appEnabledSetting = mSettings.getApplicationEnabledSetting(packageName, userId);
            int appEnabledSetting = mSettings.getApplicationEnabledSetting(packageName,
                    userHandle.getIdentifier());
            if (appEnabledSetting == COMPONENT_ENABLED_STATE_DEFAULT) {
                final AndroidPackage pkg = getPackage(packageName);
                if (pkg == null) {
+1 −1
Original line number Diff line number Diff line
@@ -2569,7 +2569,7 @@ public class PackageManagerService implements PackageSender, TestUtilityService

            if (best == null || cur.priority > best.priority) {
                if (computer.isComponentEffectivelyEnabled(cur.getComponentInfo(),
                        UserHandle.USER_SYSTEM)) {
                        UserHandle.SYSTEM)) {
                    best = cur;
                } else {
                    Slog.w(TAG, "Domain verification agent found but not enabled");
+1 −2
Original line number Diff line number Diff line
@@ -26,7 +26,6 @@ import static android.content.pm.PackageManager.MATCH_DEBUG_TRIAGED_MISSING;
import static android.content.pm.SigningDetails.SignatureSchemeVersion.SIGNING_BLOCK_V4;
import static android.os.PowerWhitelistManager.REASON_PACKAGE_VERIFIER;
import static android.os.PowerWhitelistManager.TEMPORARY_ALLOWLIST_TYPE_FOREGROUND_SERVICE_ALLOWED;
import static android.os.Process.SYSTEM_UID;
import static android.os.Trace.TRACE_TAG_PACKAGE_MANAGER;

import static com.android.server.pm.PackageManagerService.CHECK_PENDING_INTEGRITY_VERIFICATION;
@@ -408,7 +407,7 @@ final class VerifyingSession {
        final int numRequiredVerifierPackages = requiredVerifierPackages.size();
        for (int i = numRequiredVerifierPackages - 1; i >= 0; i--) {
            if (!snapshot.isApplicationEffectivelyEnabled(requiredVerifierPackages.get(i),
                    SYSTEM_UID)) {
                    verifierUser)) {
                Slog.w(TAG,
                        "Required verifier: " + requiredVerifierPackages.get(i) + " is disabled");
                requiredVerifierPackages.remove(i);