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

Commit 69ff1c42 authored by atrost's avatar atrost
Browse files

Get ApplicationInfo using self UID to make sure we have permission.

Otherwise the caller is checked for permission to get the
ApplicationInfo, and may be denied due to lack of INTERACT_ACROSS_USERS.

Bug: 142942524
Test: patched to internal master,
  1. Install TestDPC via adb
  2. Invoke "Set up Te..." from the launcher to create a work profile and follow "next" button and select "skip adding an account"
  3. Select TestDPC from the "work" tab of the list of all apps in launcher.
  4. Using built-in search look for "Password constraints" and tap it.
  5. tap "Minimum password length" and try to set it to 5.
  Before change: Neither user 1010193 nor current process has android.permission.INTERACT_ACROSS_USERS.
  After Change: password quality should be at least 131072 for setPasswordMinimumLength

Change-Id: I4018fac21c1ce40f4258be0dc39ebe0e8e1bd582
parent 7b577376
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@ package com.android.server.compat;
import android.content.Context;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
import android.os.Process;
import android.util.Slog;
import android.util.StatsLog;

@@ -128,7 +129,8 @@ public class PlatformCompat extends IPlatformCompat.Stub {

    private ApplicationInfo getApplicationInfo(String packageName) {
        try {
            return mContext.getPackageManager().getApplicationInfo(packageName, 0);
            return mContext.getPackageManager().getApplicationInfoAsUser(packageName, 0,
                    Process.myUid());
        } catch (PackageManager.NameNotFoundException e) {
            Slog.e(TAG, "No installed package " + packageName);
        }