summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorandroid-build-team Robot <android-build-team-robot@google.com>2019-12-19 02:01:22 +0000
committerandroid-build-team Robot <android-build-team-robot@google.com>2019-12-19 02:01:22 +0000
commita82fff3f6128d900f8854a3041ae381daa282f46 (patch)
tree3b5092d4cd1ba4c2401ba41812cec9bad28e85fb
parent8043f68422ab79fad14cad367fb52ea2d20f9f0a (diff)
parentc8bed3da8e11603752204bae4f79e616a4d08bfd (diff)
downloadplatform_packages_apps_Nfc-android10-qpr2-s1-release.tar.gz
platform_packages_apps_Nfc-android10-qpr2-s1-release.tar.bz2
platform_packages_apps_Nfc-android10-qpr2-s1-release.zip
Change-Id: I61160dc5984c2461d9dd26749c8dca09ee8be786
-rw-r--r--src/com/android/nfc/NfcService.java84
1 files changed, 47 insertions, 37 deletions
diff --git a/src/com/android/nfc/NfcService.java b/src/com/android/nfc/NfcService.java
index 96134cc6..6699a8ba 100644
--- a/src/com/android/nfc/NfcService.java
+++ b/src/com/android/nfc/NfcService.java
@@ -1577,9 +1577,14 @@ public class NfcService implements DeviceHostListener {
tag.removeTechnology(TagTechnology.NDEF_FORMATABLE);
tag.findAndReadNdef();
// Build a new Tag object to return
- Tag newTag = new Tag(tag.getUid(), tag.getTechList(),
- tag.getTechExtras(), tag.getHandle(), this);
- return newTag;
+ try {
+ Tag newTag = new Tag(tag.getUid(), tag.getTechList(),
+ tag.getTechExtras(), tag.getHandle(), this);
+ return newTag;
+ } catch (Exception e) {
+ Log.e(TAG, "Tag creation exception.", e);
+ return null;
+ }
}
return null;
}
@@ -2529,45 +2534,50 @@ public class NfcService implements DeviceHostListener {
}
private void dispatchTagEndpoint(TagEndpoint tagEndpoint, ReaderModeParams readerParams) {
- Tag tag = new Tag(tagEndpoint.getUid(), tagEndpoint.getTechList(),
- tagEndpoint.getTechExtras(), tagEndpoint.getHandle(), mNfcTagService);
- registerTagObject(tagEndpoint);
- if (readerParams != null) {
- try {
- if ((readerParams.flags & NfcAdapter.FLAG_READER_NO_PLATFORM_SOUNDS) == 0) {
- mVibrator.vibrate(mVibrationEffect);
- playSound(SOUND_END);
- }
- if (readerParams.callback != null) {
- readerParams.callback.onTagDiscovered(tag);
+ try {
+ Tag tag = new Tag(tagEndpoint.getUid(), tagEndpoint.getTechList(),
+ tagEndpoint.getTechExtras(), tagEndpoint.getHandle(), mNfcTagService);
+ registerTagObject(tagEndpoint);
+ if (readerParams != null) {
+ try {
+ if ((readerParams.flags & NfcAdapter.FLAG_READER_NO_PLATFORM_SOUNDS) == 0) {
+ mVibrator.vibrate(mVibrationEffect);
+ playSound(SOUND_END);
+ }
+ if (readerParams.callback != null) {
+ readerParams.callback.onTagDiscovered(tag);
+ return;
+ } else {
+ // Follow normal dispatch below
+ }
+ } catch (RemoteException e) {
+ Log.e(TAG, "Reader mode remote has died, falling back.", e);
+ // Intentional fall-through
+ } catch (Exception e) {
+ // Catch any other exception
+ Log.e(TAG, "App exception, not dispatching.", e);
return;
- } else {
- // Follow normal dispatch below
}
- } catch (RemoteException e) {
- Log.e(TAG, "Reader mode remote has died, falling back.", e);
- // Intentional fall-through
- } catch (Exception e) {
- // Catch any other exception
- Log.e(TAG, "App exception, not dispatching.", e);
- return;
}
- }
- int dispatchResult = mNfcDispatcher.dispatchTag(tag);
- if (dispatchResult == NfcDispatcher.DISPATCH_FAIL && !mInProvisionMode) {
- unregisterObject(tagEndpoint.getHandle());
- if (mScreenState == ScreenStateHelper.SCREEN_STATE_ON_UNLOCKED) {
- if (mToast != null) {
- if (mToast.getView().isShown()) mToast.cancel();
+ int dispatchResult = mNfcDispatcher.dispatchTag(tag);
+ if (dispatchResult == NfcDispatcher.DISPATCH_FAIL && !mInProvisionMode) {
+ unregisterObject(tagEndpoint.getHandle());
+ if (mScreenState == ScreenStateHelper.SCREEN_STATE_ON_UNLOCKED) {
+ if (mToast != null) {
+ if (mToast.getView().isShown()) mToast.cancel();
+ }
+ mToast = Toast.makeText(mContext, R.string.tag_dispatch_failed,
+ Toast.LENGTH_SHORT);
+ mToast.show();
}
- mToast = Toast.makeText(mContext, R.string.tag_dispatch_failed,
- Toast.LENGTH_SHORT);
- mToast.show();
+ playSound(SOUND_ERROR);
+ } else if (dispatchResult == NfcDispatcher.DISPATCH_SUCCESS) {
+ mVibrator.vibrate(mVibrationEffect);
+ playSound(SOUND_END);
}
- playSound(SOUND_ERROR);
- } else if (dispatchResult == NfcDispatcher.DISPATCH_SUCCESS) {
- mVibrator.vibrate(mVibrationEffect);
- playSound(SOUND_END);
+ } catch (Exception e) {
+ Log.e(TAG, "Tag creation exception, not dispatching.", e);
+ return;
}
}
}