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:
chloedai
2022-03-03 03:22:43 +08:00
committed by Chloe Dai
parent 113f3a4a1d
commit d52c4c3e83

View File

@@ -142,9 +142,13 @@ public final class Tag implements Parcelable {
mTagService = tagService;
mConnectedTechnology = -1;
mCookie = SystemClock.elapsedRealtime();
if (tagService == null) {
return;
}
try {
mCookie = SystemClock.elapsedRealtime();
tagService.setTagUpToDate(mCookie);
} catch (RemoteException e) {
throw e.rethrowAsRuntimeException();
@@ -370,6 +374,10 @@ public final class Tag implements Parcelable {
/** @hide */
@UnsupportedAppUsage
public INfcTag getTagService() {
if (mTagService == null) {
return null;
}
try {
if (!mTagService.isTagUpToDate(mCookie)) {
String id_str = "";