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

Commit d6bd9dc0 authored by Jackal Guo's avatar Jackal Guo
Browse files

Remove binderClearCallingIdentity()

Clearing calling identity results in subsequent package visibility
filtering useless.

Bug: 187042120
Test: atest MixedDeviceOwnerTest#testApplicationRestrictions
Test: atest MixedManagedProfileOwnerTest#testDelegation
Test: atest SilentPackageInstallTest#testUninstallBlocked
Test: atest DevicePolicyManagerTest\
        #testSetUninstallBlocked_succeedForNotInstalledApps
Test: manually using the PoC in the buganizer to ensure the symptom
      no longer exists.
Change-Id: Ie0e2daa70eb76e455b2546f96c9a9c8bb3eabd34
parent 7badfa35
Loading
Loading
Loading
Loading
+6 −1
Original line number Diff line number Diff line
@@ -10596,11 +10596,16 @@ public class DevicePolicyManager {
     * behavior of this API is changed such that passing {@code null} as the {@code admin} parameter
     * will return if any admin has blocked the uninstallation. Before L MR1, passing {@code null}
     * will cause a NullPointerException to be raised.
     * <p>
     * <strong>Note:</strong> If your app targets Android 11 (API level 30) or higher,
     * this method returns a filtered result. Learn more about how to
     * <a href="/training/basics/intents/package-visibility">manage package visibility</a>.
     *
     * @param admin The name of the admin component whose blocking policy will be checked, or
     *            {@code null} to check whether any admin has blocked the uninstallation.
     * @param packageName package to check.
     * @return true if uninstallation is blocked.
     * @return true if uninstallation is blocked and the given package is visible to you, false
     *         otherwise if uninstallation isn't blocked or the given package isn't visible to you.
     * @throws SecurityException if {@code admin} is not a device or profile owner.
     */
    public boolean isUninstallBlocked(@Nullable ComponentName admin, String packageName) {
+0 −3
Original line number Diff line number Diff line
@@ -11596,14 +11596,11 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager {
                Preconditions.checkCallAuthorization(
                        isProfileOwner(caller) || isDeviceOwner(caller));
            }
            long id = mInjector.binderClearCallingIdentity();
            try {
                return mIPackageManager.getBlockUninstallForUser(packageName, userId);
            } catch (RemoteException re) {
                // Shouldn't happen.
                Slogf.e(LOG_TAG, "Failed to getBlockUninstallForUser", re);
            } finally {
                mInjector.binderRestoreCallingIdentity(id);
            }
        }
        return false;