summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJordan Liu <jminjie@google.com>2021-05-04 21:14:50 +0000
committerAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>2021-05-04 21:14:50 +0000
commit91c7a85ada5938be7d7ee0f5fd999372ada0461f (patch)
tree991adf9c7ad2526f62cbb6edd98eaa841c85146c
parent5e023c00b15cb12526008f0fa88ecdd09cf5d468 (diff)
parentf35598c66d1046388815197764965b6696a77c2f (diff)
downloadStk-91c7a85ada5938be7d7ee0f5fd999372ada0461f.tar.gz
Merge changes from topic "remove_stk_no_menu" am: f35598c66dandroid-s-beta-4android-s-beta-3android-s-beta-4
Original change: https://android-review.googlesource.com/c/platform/packages/apps/Stk/+/1318779 Change-Id: I25c398fb909a53ea67a99b52485f647e9384f0ba
-rw-r--r--src/com/android/stk/StkAppService.java44
1 files changed, 16 insertions, 28 deletions
diff --git a/src/com/android/stk/StkAppService.java b/src/com/android/stk/StkAppService.java
index e3ceabd..c507171 100644
--- a/src/com/android/stk/StkAppService.java
+++ b/src/com/android/stk/StkAppService.java
@@ -119,7 +119,6 @@ public class StkAppService extends Service implements Runnable {
protected LinkedList<DelayedCmd> mCmdsQ = null;
protected boolean mCmdInProgress = false;
protected int mStkServiceState = STATE_UNKNOWN;
- protected int mSetupMenuState = STATE_NOT_EXIST;
protected int mMenuState = StkMenuActivity.STATE_INIT;
protected int mOpCode = -1;
private Activity mActivityInstance = null;
@@ -627,15 +626,7 @@ public class StkAppService extends Service implements Runnable {
break;
case OP_BOOT_COMPLETED:
CatLog.d(LOG_TAG, " OP_BOOT_COMPLETED");
- int i = 0;
- for (i = 0; i < mSimCount; i++) {
- if (mStkContext[i].mMainCmd != null) {
- break;
- }
- }
- if (i == mSimCount) {
- StkAppInstaller.uninstall(StkAppService.this);
- }
+ uninstallIfUnnecessary();
break;
case OP_DELAYED_MSG:
handleDelayedCmd(slotId);
@@ -736,12 +727,12 @@ public class StkAppService extends Service implements Runnable {
== AppInterface.CommandType.PLAY_TONE.value()) {
terminateTone(slotId);
}
+ if (!uninstallIfUnnecessary()) {
+ addToMenuSystemOrUpdateLabel();
+ }
if (isAllOtherCardsAbsent(slotId)) {
CatLog.d(LOG_TAG, "All CARDs are ABSENT");
- StkAppInstaller.uninstall(StkAppService.this);
stopSelf();
- } else {
- addToMenuSystemOrUpdateLabel();
}
} else {
IccRefreshResponse state = new IccRefreshResponse();
@@ -1122,21 +1113,10 @@ public class StkAppService extends Service implements Runnable {
CatLog.d(LOG_TAG, "SET_UP_MENU [" + removeMenu(slotId) + "]");
if (removeMenu(slotId)) {
- int i = 0;
- CatLog.d(LOG_TAG, "removeMenu() - Uninstall App");
mStkContext[slotId].mCurrentMenu = null;
mStkContext[slotId].mMainCmd = null;
//Check other setup menu state. If all setup menu are removed, uninstall apk.
- for (i = 0; i < mSimCount; i++) {
- if (i != slotId && mStkContext[i].mSetupMenuState != STATE_NOT_EXIST) {
- CatLog.d(LOG_TAG, "Not Uninstall App:" + i + ","
- + mStkContext[i].mSetupMenuState);
- break;
- }
- }
- if (i == mSimCount) {
- StkAppInstaller.uninstall(this);
- } else {
+ if (!uninstallIfUnnecessary()) {
addToMenuSystemOrUpdateLabel();
}
} else {
@@ -2456,18 +2436,26 @@ public class StkAppService extends Service implements Runnable {
try {
if (mStkContext[slotId].mCurrentMenu.items.size() == 1 &&
mStkContext[slotId].mCurrentMenu.items.get(0) == null) {
- mStkContext[slotId].mSetupMenuState = STATE_NOT_EXIST;
return true;
}
} catch (NullPointerException e) {
CatLog.d(LOG_TAG, "Unable to get Menu's items size");
- mStkContext[slotId].mSetupMenuState = STATE_NOT_EXIST;
return true;
}
- mStkContext[slotId].mSetupMenuState = STATE_EXIST;
return false;
}
+ private boolean uninstallIfUnnecessary() {
+ for (int slot = 0; slot < mSimCount; slot++) {
+ if (mStkContext[slot].mMainCmd != null) {
+ return false;
+ }
+ }
+ CatLog.d(LOG_TAG, "Uninstall App");
+ StkAppInstaller.uninstall(this);
+ return true;
+ }
+
synchronized StkContext getStkContext(int slotId) {
if (slotId >= 0 && slotId < mSimCount) {
return mStkContext[slotId];