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

Commit 5514697c authored by Treehugger Robot's avatar Treehugger Robot Committed by Automerger Merge Worker
Browse files

Merge "Fix permission check for system service" into udc-dev am: 04463d67

parents 29543c2d 04463d67
Loading
Loading
Loading
Loading
+1 −2
Original line number Diff line number Diff line
@@ -165,8 +165,7 @@ public final class CredentialProviderInfoFactory {
            Slog.w(TAG, "Context is null in isSystemProviderWithValidPermission");
            return false;
        }
        return PermissionUtils.isSystemApp(context, serviceInfo.packageName)
                && PermissionUtils.hasPermission(context, serviceInfo.packageName,
        return PermissionUtils.hasPermission(context, serviceInfo.packageName,
                Manifest.permission.PROVIDE_DEFAULT_ENABLED_CREDENTIAL_SERVICE);
    }

+0 −17
Original line number Diff line number Diff line
@@ -17,7 +17,6 @@
package android.service.credentials;

import android.content.Context;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;

/**
@@ -33,21 +32,5 @@ public class PermissionUtils {
        return context.getPackageManager().checkPermission(permission, packageName)
                == PackageManager.PERMISSION_GRANTED;
    }

    /** Checks whether the given package name is a system app on the device **/
    public static boolean isSystemApp(Context context, String packageName) {
        try {
            ApplicationInfo appInfo =
                    context.getPackageManager()
                            .getApplicationInfo(packageName,
                                    PackageManager.ApplicationInfoFlags.of(
                                            PackageManager.MATCH_SYSTEM_ONLY));
            if (appInfo != null) {
                return true;
            }
        } catch (PackageManager.NameNotFoundException e) {
        }
        return false;
    }
}