Stk: Support for modem re-start and ICC refresh
Uninstall the STK app, stop StkAppService and remove the idle text
when StkAppService receives the CARD_ABSENT/CARD_ERROR status.
IdleModeText and SETUP_MENU need to be cleared when a card refresh
occurs.
Bug: 12161291
Change-Id: I626ff5196270377d02c570703f46c5b272a115fd
(cherry picked from commit f48e483b46cfec93edc70fa9e39c8a7120b864f8)
(cherry picked from commit 8390bbbbfa8e170e81e8a99ab997fb1406d8e81a)
(cherry picked from commit dc0f924d464dbc093f1168f0e9a8bca8b0aea73c)
diff --git a/src/com/android/stk/StkAppService.java b/src/com/android/stk/StkAppService.java
index d98c14b..4699e04 100644
--- a/src/com/android/stk/StkAppService.java
+++ b/src/com/android/stk/StkAppService.java
@@ -53,6 +53,8 @@
import com.android.internal.telephony.cat.CatLog;
import com.android.internal.telephony.cat.CatResponseMessage;
import com.android.internal.telephony.cat.TextMessage;
+import com.android.internal.telephony.uicc.IccRefreshResponse;
+import com.android.internal.telephony.uicc.IccCardStatus.CardState;
import java.util.LinkedList;
@@ -105,6 +107,7 @@
static final int OP_END_SESSION = 4;
static final int OP_BOOT_COMPLETED = 5;
private static final int OP_DELAYED_MSG = 6;
+ static final int OP_CARD_STATUS_CHANGED = 7;
// Response ids
static final int RES_ID_MENU_SELECTION = 11;
@@ -188,6 +191,7 @@
msg.obj = args.getParcelable(CMD_MSG);
break;
case OP_RESPONSE:
+ case OP_CARD_STATUS_CHANGED:
msg.obj = args;
/* falls through */
case OP_LAUNCH_APP:
@@ -318,6 +322,40 @@
case OP_DELAYED_MSG:
handleDelayedCmd();
break;
+ case OP_CARD_STATUS_CHANGED:
+ CatLog.d(this, "Card/Icc Status change received");
+ handleCardStatusChangeAndIccRefresh((Bundle) msg.obj);
+ break;
+ }
+ }
+
+ private void handleCardStatusChangeAndIccRefresh(Bundle args) {
+ boolean cardStatus = args.getBoolean(AppInterface.CARD_STATUS);
+
+ CatLog.d(this, "CardStatus: " + cardStatus);
+ if (cardStatus == false) {
+ CatLog.d(this, "CARD is ABSENT");
+ // Uninstall STKAPP, Clear Idle text, Stop StkAppService
+ StkAppInstaller.unInstall(mContext);
+ mNotificationManager.cancel(STK_NOTIFICATION_ID);
+ stopSelf();
+ } else {
+ IccRefreshResponse state = new IccRefreshResponse();
+ state.refreshResult = args.getInt(AppInterface.REFRESH_RESULT);
+
+ CatLog.d(this, "Icc Refresh Result: "+ state.refreshResult);
+ if ((state.refreshResult == IccRefreshResponse.REFRESH_RESULT_INIT) ||
+ (state.refreshResult == IccRefreshResponse.REFRESH_RESULT_RESET)) {
+ // Clear Idle Text
+ mNotificationManager.cancel(STK_NOTIFICATION_ID);
+ }
+
+ if (state.refreshResult == IccRefreshResponse.REFRESH_RESULT_RESET) {
+ // Uninstall STkmenu
+ StkAppInstaller.unInstall(mContext);
+ mCurrentMenu = null;
+ mMainCmd = null;
+ }
}
}
}
diff --git a/src/com/android/stk/StkCmdReceiver.java b/src/com/android/stk/StkCmdReceiver.java
index f276611..8e9aae7 100644
--- a/src/com/android/stk/StkCmdReceiver.java
+++ b/src/com/android/stk/StkCmdReceiver.java
@@ -17,6 +17,7 @@
package com.android.stk;
import com.android.internal.telephony.cat.AppInterface;
+import com.android.internal.telephony.uicc.IccRefreshResponse;
import android.content.BroadcastReceiver;
import android.content.Context;
@@ -37,6 +38,8 @@
handleCommandMessage(context, intent);
} else if (action.equals(AppInterface.CAT_SESSION_END_ACTION)) {
handleSessionEnd(context, intent);
+ } else if (action.equals(AppInterface.CAT_ICC_STATUS_CHANGE)) {
+ handleCardStatusChange(context, intent);
}
}
@@ -55,4 +58,22 @@
context.startService(new Intent(context, StkAppService.class)
.putExtras(args));
}
+
+ private void handleCardStatusChange(Context context, Intent intent) {
+ // If the Card is absent then check if the StkAppService is even
+ // running before starting it to stop it right away
+ if ((intent.getBooleanExtra(AppInterface.CARD_STATUS, false) == false)
+ && StkAppService.getInstance() == null) {
+ return;
+ }
+ Bundle args = new Bundle();
+ args.putInt(StkAppService.OPCODE, StkAppService.OP_CARD_STATUS_CHANGED);
+ args.putBoolean(AppInterface.CARD_STATUS,
+ intent.getBooleanExtra(AppInterface.CARD_STATUS, true));
+ args.putInt(AppInterface.REFRESH_RESULT,
+ intent.getIntExtra(AppInterface.REFRESH_RESULT,
+ IccRefreshResponse.REFRESH_RESULT_FILE_UPDATE));
+ context.startService(new Intent(context, StkAppService.class)
+ .putExtras(args));
+ }
}