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

Commit 131d0199 authored by Jackal Guo's avatar Jackal Guo
Browse files

Revert "Revert "Add MATCH_ANY_USER flag when get valid package uid""

Now getPackageUid would check if the package is installed on the
given userId. Since we treat calls from a profile as if made by
its parent, using MATCH_ANY_USER to query the uid of the given
package name.

This reverts commit 981d9955.

Bug: 186180067
Test: atest -p core/java/android/view/accessibility
Test: atest -p services/accessibility
Change-Id: Ifd26b2aa2356e3bf197ef4ec638cdc7683d741ac
parent 1a7e40fa
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -444,8 +444,10 @@ public class AccessibilitySecurityPolicy {
    private boolean isValidPackageForUid(String packageName, int uid) {
        final long token = Binder.clearCallingIdentity();
        try {
            // Since we treat calls from a profile as if made by its parent, using
            // MATCH_ANY_USER to query the uid of the given package name.
            return uid == mPackageManager.getPackageUidAsUser(
                    packageName, UserHandle.getUserId(uid));
                    packageName, PackageManager.MATCH_ANY_USER, UserHandle.getUserId(uid));
        } catch (PackageManager.NameNotFoundException e) {
            return false;
        } finally {
+2 −2
Original line number Diff line number Diff line
@@ -261,8 +261,8 @@ public class AccessibilitySecurityPolicyTest {
    @Test
    public void resolveValidReportedPackage_uidAndPkgNameMatched_returnPkgName()
            throws PackageManager.NameNotFoundException {
        when(mMockPackageManager.getPackageUidAsUser(PACKAGE_NAME, TEST_USER_ID))
                .thenReturn(APP_UID);
        when(mMockPackageManager.getPackageUidAsUser(PACKAGE_NAME,
                PackageManager.MATCH_ANY_USER, TEST_USER_ID)).thenReturn(APP_UID);

        assertEquals(mA11ySecurityPolicy.resolveValidReportedPackageLocked(
                PACKAGE_NAME, APP_UID, TEST_USER_ID, APP_PID),