Commit 94e982b8 authored by Wink Saville's avatar Wink Saville
Browse files

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)
parent 114bdb26
......@@ -81,6 +81,7 @@
<intent-filter>
<action android:name= "android.intent.action.stk.command" />
<action android:name= "android.intent.action.stk.session_end" />
<action android:name= "qualcomm.intent.action.stk.icc_status_change" />
</intent-filter>
</receiver>
......
......@@ -53,6 +53,8 @@ import com.android.internal.telephony.cat.CatCmdMessage.BrowserSettings;
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 @@ public class StkAppService extends Service implements Runnable {
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 @@ public class StkAppService extends Service implements Runnable {
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 @@ public class StkAppService extends Service implements Runnable {
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;
}
}
}
}
......
......@@ -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 @@ public class StkCmdReceiver extends BroadcastReceiver {
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 @@ public class StkCmdReceiver extends BroadcastReceiver {
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));
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment