summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Martijn Coenen <maco@google.com> 2015-12-23 00:29:19 -0800
committer android-build-merger <android-build-merger@google.com> 2015-12-23 00:29:19 -0800
commit68521a682524c53e6bfd883a3f41b4fe514c2d0c (patch)
tree4781bceb5ce41c9f21f16d19f7338f56ae7aca56
parentc53d159b3e2cf96fe1fcf06c66bdb7011b65f46f (diff)
parentc94df7c685947d8263f3617c3cd352a0bcd9e8c1 (diff)
Merge "Clear calling identify b4 Beam callback." into mnc-dr1.5-dev am: 4bbd3c4819
am: c94df7c685 * commit 'c94df7c685947d8263f3617c3cd352a0bcd9e8c1': Clear calling identify b4 Beam callback.
-rw-r--r--core/java/android/nfc/NfcActivityManager.java64
1 files changed, 34 insertions, 30 deletions
diff --git a/core/java/android/nfc/NfcActivityManager.java b/core/java/android/nfc/NfcActivityManager.java
index d619c0a8e117..c7d4c65d99c0 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);
}