Add null checking to fix NullPointerException while creating mock tag
Bug: 221452261
Test: Test pass
Change-Id: Ie64df0d8d291468b258f92524af10da504c7dade
Merged_In: Ie64df0d8d291468b258f92524af10da504c7dade
(cherry picked from commit dbdc1bd3c7)
This commit is contained in:
@@ -142,9 +142,13 @@ public final class Tag implements Parcelable {
|
|||||||
mTagService = tagService;
|
mTagService = tagService;
|
||||||
|
|
||||||
mConnectedTechnology = -1;
|
mConnectedTechnology = -1;
|
||||||
|
mCookie = SystemClock.elapsedRealtime();
|
||||||
|
|
||||||
|
if (tagService == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
mCookie = SystemClock.elapsedRealtime();
|
|
||||||
tagService.setTagUpToDate(mCookie);
|
tagService.setTagUpToDate(mCookie);
|
||||||
} catch (RemoteException e) {
|
} catch (RemoteException e) {
|
||||||
throw e.rethrowAsRuntimeException();
|
throw e.rethrowAsRuntimeException();
|
||||||
@@ -370,6 +374,10 @@ public final class Tag implements Parcelable {
|
|||||||
/** @hide */
|
/** @hide */
|
||||||
@UnsupportedAppUsage
|
@UnsupportedAppUsage
|
||||||
public INfcTag getTagService() {
|
public INfcTag getTagService() {
|
||||||
|
if (mTagService == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (!mTagService.isTagUpToDate(mCookie)) {
|
if (!mTagService.isTagUpToDate(mCookie)) {
|
||||||
String id_str = "";
|
String id_str = "";
|
||||||
|
|||||||
Reference in New Issue
Block a user