diff options
| author | Martijn Coenen <maco@google.com> | 2015-12-21 11:29:45 +0100 |
|---|---|---|
| committer | Martijn Coenen <maco@google.com> | 2015-12-21 10:33:06 +0000 |
| commit | 24584f0b34679ab4d378c47ecbfcc990af31c376 (patch) | |
| tree | 7a8d18ad7f8ec13219effb8e5925e65dbcf3e4ac /core | |
| parent | d980b8c7a05a2dc51145c3465c14f1f106a8bc47 (diff) | |
| download | frameworks_base-24584f0b34679ab4d378c47ecbfcc990af31c376.zip frameworks_base-24584f0b34679ab4d378c47ecbfcc990af31c376.tar.gz frameworks_base-24584f0b34679ab4d378c47ecbfcc990af31c376.tar.bz2 | |
Clear calling identify b4 Beam callback.
Fixes AppOps crash, because it notices the calling
package is different from the calling UID.
Bug: 25492633
Change-Id: I55e2d975fd0a7ee94c4623efb3b19b1b54b72da2
Diffstat (limited to 'core')
| -rw-r--r-- | core/java/android/nfc/NfcActivityManager.java | 64 |
1 files changed, 34 insertions, 30 deletions
diff --git a/core/java/android/nfc/NfcActivityManager.java b/core/java/android/nfc/NfcActivityManager.java index d619c0a..c7d4c65 100644 --- a/core/java/android/nfc/NfcActivityManager.java +++ b/core/java/android/nfc/NfcActivityManager.java @@ -371,40 +371,44 @@ public final class NfcActivityManager extends IAppCallback.Stub flags = state.flags; activity = state.activity; } - - // Make callbacks without lock - if (ndefCallback != null) { - message = ndefCallback.createNdefMessage(event); - } - if (urisCallback != null) { - uris = urisCallback.createBeamUris(event); - if (uris != null) { - ArrayList<Uri> validUris = new ArrayList<Uri>(); - for (Uri uri : uris) { - if (uri == null) { - Log.e(TAG, "Uri not allowed to be null."); - continue; - } - String scheme = uri.getScheme(); - if (scheme == null || (!scheme.equalsIgnoreCase("file") && - !scheme.equalsIgnoreCase("content"))) { - Log.e(TAG, "Uri needs to have " + - "either scheme file or scheme content"); - continue; + final long ident = Binder.clearCallingIdentity(); + try { + // Make callbacks without lock + if (ndefCallback != null) { + message = ndefCallback.createNdefMessage(event); + } + if (urisCallback != null) { + uris = urisCallback.createBeamUris(event); + if (uris != null) { + ArrayList<Uri> validUris = new ArrayList<Uri>(); + for (Uri uri : uris) { + if (uri == null) { + Log.e(TAG, "Uri not allowed to be null."); + continue; + } + String scheme = uri.getScheme(); + if (scheme == null || (!scheme.equalsIgnoreCase("file") && + !scheme.equalsIgnoreCase("content"))) { + Log.e(TAG, "Uri needs to have " + + "either scheme file or scheme content"); + continue; + } + uri = ContentProvider.maybeAddUserId(uri, UserHandle.myUserId()); + validUris.add(uri); } - uri = ContentProvider.maybeAddUserId(uri, UserHandle.myUserId()); - validUris.add(uri); - } - uris = validUris.toArray(new Uri[validUris.size()]); + uris = validUris.toArray(new Uri[validUris.size()]); + } } - } - if (uris != null && uris.length > 0) { - for (Uri uri : uris) { - // Grant the NFC process permission to read these URIs - activity.grantUriPermission("com.android.nfc", uri, - Intent.FLAG_GRANT_READ_URI_PERMISSION); + if (uris != null && uris.length > 0) { + for (Uri uri : uris) { + // Grant the NFC process permission to read these URIs + activity.grantUriPermission("com.android.nfc", uri, + Intent.FLAG_GRANT_READ_URI_PERMISSION); + } } + } finally { + Binder.restoreCallingIdentity(ident); } return new BeamShareData(message, uris, new UserHandle(UserHandle.myUserId()), flags); } |
