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

Commit e5613ecf authored by Pavel Grafov's avatar Pavel Grafov
Browse files

Add temporary debug logging.

This is to investigate Permission Denial: broadcast from android asks to
run as user X but is calling from uid Y. The exception is seen in many
tests using various DPM APIs, which don't result in any broadcasts
except for DEVICE_POLICY_MANAGER_STATE_CHANGED, so this seems to be the
most likely source. Normally withCleanCallingIdentity() should make it
look as if it is broadcast from uid 0.

Bug: 387259698
Test: TH
Flag: EXEMPT only logging in exceptional circumstances
Change-Id: I7242003f9c07a07e1e163fc9d32657e5781116e7
parent d4815549
Loading
Loading
Loading
Loading
+9 −2
Original line number Diff line number Diff line
@@ -3286,8 +3286,15 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub {
                .setDeliveryGroupPolicy(BroadcastOptions.DELIVERY_GROUP_POLICY_MOST_RECENT)
                .setDeferralPolicy(BroadcastOptions.DEFERRAL_POLICY_UNTIL_ACTIVE)
                .toBundle();
        mInjector.binderWithCleanCallingIdentity(() ->
                mContext.sendBroadcastAsUser(intent, new UserHandle(userHandle), null, options));
        mInjector.binderWithCleanCallingIdentity(() -> {
            try {
                mContext.sendBroadcastAsUser(intent, new UserHandle(userHandle), null, options);
            } catch (SecurityException e) {
                // TODO(b/387259698) remove debug logging.
                Slog.d(LOG_TAG, "Exception broadcasting as UID " + Binder.getCallingUid(), e);
                throw e;
            }
        });
    }
    private void loadSettingsLocked(DevicePolicyData policy, int userHandle) {