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

Commit a84c7a7b authored by Guojing Yuan's avatar Guojing Yuan Committed by Android (Google) Code Review
Browse files

Merge "Catch NameNotFoundException during onPackageModified" into tm-qpr-dev

parents 802120c8 6061bdb2
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -1152,6 +1152,9 @@ public class CompanionDeviceManagerService extends SystemService {
    }

    private void updateSpecialAccessPermissionAsSystem(PackageInfo packageInfo) {
        if (packageInfo == null) {
            return;
        }
        if (containsEither(packageInfo.requestedPermissions,
                android.Manifest.permission.RUN_IN_BACKGROUND,
                android.Manifest.permission.REQUEST_COMPANION_RUN_IN_BACKGROUND)) {
+10 −3
Original line number Diff line number Diff line
@@ -54,12 +54,19 @@ final class PackageUtils {
    private static final String PROPERTY_PRIMARY_TAG =
            "android.companion.PROPERTY_PRIMARY_COMPANION_DEVICE_SERVICE";

    static @Nullable PackageInfo getPackageInfo(@NonNull Context context,
    @Nullable
    static PackageInfo getPackageInfo(@NonNull Context context,
            @UserIdInt int userId, @NonNull String packageName) {
        final PackageManager pm = context.getPackageManager();
        final PackageInfoFlags flags = PackageInfoFlags.of(GET_PERMISSIONS | GET_CONFIGURATIONS);
        return Binder.withCleanCallingIdentity(() ->
                pm.getPackageInfoAsUser(packageName, flags , userId));
        return Binder.withCleanCallingIdentity(() -> {
            try {
                return pm.getPackageInfoAsUser(packageName, flags, userId);
            } catch (PackageManager.NameNotFoundException e) {
                Slog.e(TAG, "Package [" + packageName + "] is not found.");
                return null;
            }
        });
    }

    static void enforceUsesCompanionDeviceFeature(@NonNull Context context,