summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorYoshiaki Naka <yoshiaki.naka@sony.com>2019-04-26 17:58:52 +0900
committerYoshiaki Naka <yoshiaki.naka@sony.com>2021-04-21 18:42:27 +0900
commit58e076505425bfce5455dd36824b598ee8f36329 (patch)
treeaf0822fa2ecfe448b71eb4774bc0c054c01a4b7e /src
parent22d92add67350a763ecf4658c36db5dae50ca1b7 (diff)
downloadStk-58e076505425bfce5455dd36824b598ee8f36329.tar.gz
Add new function to show or hide SIM Toolkit on the launcher screen
There are several places we can find similar logics to show or hide SIM Toolkit application on the launcher screen. Some are a kind of code clone and another one is a bit different logic. That is not good for future code maintenance. Bug: 159662728 Test: Manually confirmed all the possible SIM removal scenarios. Change-Id: Iaea976aa772b2d07a162619ba089839bb465e83a
Diffstat (limited to 'src')
-rw-r--r--src/com/android/stk/StkAppService.java38
1 files changed, 13 insertions, 25 deletions
diff --git a/src/com/android/stk/StkAppService.java b/src/com/android/stk/StkAppService.java
index e3ceabd..e86c138 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);
@@ -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];