diff options
| author | 2022-10-27 23:11:03 +0000 | |
|---|---|---|
| committer | 2022-10-27 23:11:03 +0000 | |
| commit | 7b1ce311f496714ef2b9305df3aa626edcda8def (patch) | |
| tree | d2ac4ce6236047aa858f958f52f07c585504e2e6 | |
| parent | 5b370f2285dc928dab7b39b2befd6bfb1db2f73c (diff) | |
| parent | b127850fda23698be0247e5b2110cdd01fff8fd7 (diff) | |
Merge "[SettingsProvider] workaround for DevicePolicyResourcesManager"
| -rw-r--r-- | core/java/android/provider/Settings.java | 23 |
1 files changed, 20 insertions, 3 deletions
diff --git a/core/java/android/provider/Settings.java b/core/java/android/provider/Settings.java index 4502eec9fe4f..897b7c3afe54 100644 --- a/core/java/android/provider/Settings.java +++ b/core/java/android/provider/Settings.java @@ -3374,9 +3374,26 @@ public final class Settings { } } - // Fetch all flags for the namespace at once for caching purposes - Bundle b = cp.call(cr.getAttributionSource(), - mProviderHolder.mUri.getAuthority(), mCallListCommand, null, args); + Bundle b; + // b/252663068: if we're in system server and the caller did not call + // clearCallingIdentity, the read would fail due to mismatched AttributionSources. + // TODO(b/256013480): remove this bypass after fixing the callers in system server. + if (namespace.equals(DeviceConfig.NAMESPACE_DEVICE_POLICY_MANAGER) + && Settings.isInSystemServer() + && Binder.getCallingUid() != Process.myUid()) { + final long token = Binder.clearCallingIdentity(); + try { + // Fetch all flags for the namespace at once for caching purposes + b = cp.call(cr.getAttributionSource(), + mProviderHolder.mUri.getAuthority(), mCallListCommand, null, args); + } finally { + Binder.restoreCallingIdentity(token); + } + } else { + // Fetch all flags for the namespace at once for caching purposes + b = cp.call(cr.getAttributionSource(), + mProviderHolder.mUri.getAuthority(), mCallListCommand, null, args); + } if (b == null) { // Invalid response, return an empty map return keyValues; |