diff options
author | Jordan Liu <jminjie@google.com> | 2021-05-04 20:51:39 +0000 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2021-05-04 20:51:39 +0000 |
commit | f35598c66d1046388815197764965b6696a77c2f (patch) | |
tree | 991adf9c7ad2526f62cbb6edd98eaa841c85146c | |
parent | 22d92add67350a763ecf4658c36db5dae50ca1b7 (diff) | |
parent | 2d10bbb2f0a4e6c8e51e1ef2f3405e0f7b0e42bf (diff) | |
download | Stk-f35598c66d1046388815197764965b6696a77c2f.tar.gz |
Merge changes from topic "remove_stk_no_menu"android-s-beta-2android-s-beta-1
* changes:
Remove SIM Tookit from the launcher screen if no main menu is available
Add new function to show or hide SIM Toolkit on the launcher screen
-rw-r--r-- | src/com/android/stk/StkAppService.java | 44 |
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]; |