summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYoshiaki Naka <yoshiaki.naka@sonymobile.com>2017-09-19 20:14:58 +0900
committerJordan Liu <jminjie@google.com>2018-03-07 13:29:39 -0800
commitfb99725dc3bf9a588ab1fa755fb8b5e1a0076d8d (patch)
treedf403a323f740da310abf0ee4eb0950a5aeec2f5
parentf910614ded28b95b805c3f2d1d12bf3f3ca9a55e (diff)
downloadStk-fb99725dc3bf9a588ab1fa755fb8b5e1a0076d8d.tar.gz
Support ENVELOPE (EVENT DOWNLOAD - User activity) command
The terminal shall send the ENVELOPE (EVENT DOWNLOAD - User activity) command to the UICC when some user activity like a key-press or touch is detected if the user activity event is a part of the current event list. This change allows the SIM Toolkit application to support that event. Please refer to the specification of SET UP EVENT LIST command described in ETSI TS 102.223. Bug: 65884891 Test: Confirmed the expected seq 1.1 of ETSI TS 102.384 TC 27.22.4.16 Change-Id: I7d3faa09cd4625db53bcfe21f90570389a4ea037
-rw-r--r--AndroidManifest.xml1
-rw-r--r--src/com/android/stk/StkAppService.java59
2 files changed, 60 insertions, 0 deletions
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index f4652da..29928eb 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -28,6 +28,7 @@
<uses-permission android:name="android.permission.GET_TASKS"/>
<uses-permission android:name="android.permission.RECEIVE_STK_COMMANDS" />
<uses-permission android:name="android.permission.SET_ACTIVITY_WATCHER" />
+ <uses-permission android:name="android.permission.USER_ACTIVITY" />
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
diff --git a/src/com/android/stk/StkAppService.java b/src/com/android/stk/StkAppService.java
index a85402c..a658763 100644
--- a/src/com/android/stk/StkAppService.java
+++ b/src/com/android/stk/StkAppService.java
@@ -50,6 +50,7 @@ import android.os.Parcel;
import android.os.PersistableBundle;
import android.os.PowerManager;
import android.os.RemoteException;
+import android.os.ServiceManager;
import android.os.SystemProperties;
import android.os.Vibrator;
import android.provider.Settings;
@@ -58,9 +59,11 @@ import android.telephony.CarrierConfigManager;
import android.telephony.TelephonyManager;
import android.text.TextUtils;
import android.view.Gravity;
+import android.view.IWindowManager;
import android.view.LayoutInflater;
import android.view.View;
import android.view.WindowManager;
+import android.view.WindowManagerPolicyConstants;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;
@@ -93,6 +96,8 @@ import static com.android.internal.telephony.cat.CatCmdMessage.
SetupEventListConstants.IDLE_SCREEN_AVAILABLE_EVENT;
import static com.android.internal.telephony.cat.CatCmdMessage.
SetupEventListConstants.LANGUAGE_SELECTION_EVENT;
+import static com.android.internal.telephony.cat.CatCmdMessage.
+ SetupEventListConstants.USER_ACTIVITY_EVENT;
/**
* SIM toolkit application level service. Interacts with Telephopny messages,
@@ -162,6 +167,7 @@ public class StkAppService extends Service implements Runnable {
private IProcessObserver.Stub mProcessObserver = null;
private TonePlayer mTonePlayer = null;
private Vibrator mVibrator = null;
+ private BroadcastReceiver mUserActivityReceiver = null;
// Used for setting FLAG_ACTIVITY_NO_USER_ACTION when
// creating an intent.
@@ -218,6 +224,9 @@ public class StkAppService extends Service implements Runnable {
// Message id to remove stop tone message from queue.
private static final int STOP_TONE_WHAT = 100;
+ // Message id to send user activity event to card.
+ private static final int OP_USER_ACTIVITY = 20;
+
// Response ids
static final int RES_ID_MENU_SELECTION = 11;
static final int RES_ID_INPUT = 12;
@@ -377,6 +386,7 @@ public class StkAppService extends Service implements Runnable {
@Override
public void onDestroy() {
CatLog.d(LOG_TAG, "onDestroy()");
+ unregisterUserActivityReceiver();
unregisterProcessObserver();
sInstance = null;
waitForLooper();
@@ -649,6 +659,11 @@ public class StkAppService extends Service implements Runnable {
CatLog.d(this, "Stop tone");
handleStopTone(msg, slotId);
break;
+ case OP_USER_ACTIVITY:
+ for (int slot = PhoneConstants.SIM_ID_1; slot < mSimCount; slot++) {
+ checkForSetupEvent(USER_ACTIVITY_EVENT, null, slot);
+ }
+ break;
}
}
@@ -1617,6 +1632,9 @@ public class StkAppService extends Service implements Runnable {
private void unregisterEvent(int event, int slotId) {
switch (event) {
+ case USER_ACTIVITY_EVENT:
+ unregisterUserActivityReceiver();
+ break;
case IDLE_SCREEN_AVAILABLE_EVENT:
unregisterProcessObserver(AppInterface.CommandType.SET_UP_EVENT_LIST, slotId);
break;
@@ -1632,6 +1650,9 @@ public class StkAppService extends Service implements Runnable {
}
for (int event : mStkContext[slotId].mSetupEventListSettings.eventList) {
switch (event) {
+ case USER_ACTIVITY_EVENT:
+ registerUserActivityReceiver();
+ break;
case IDLE_SCREEN_AVAILABLE_EVENT:
registerProcessObserver();
break;
@@ -1642,6 +1663,38 @@ public class StkAppService extends Service implements Runnable {
}
}
+ private synchronized void registerUserActivityReceiver() {
+ if (mUserActivityReceiver == null) {
+ mUserActivityReceiver = new BroadcastReceiver() {
+ @Override public void onReceive(Context context, Intent intent) {
+ if (WindowManagerPolicyConstants.ACTION_USER_ACTIVITY_NOTIFICATION.equals(
+ intent.getAction())) {
+ Message message = mServiceHandler.obtainMessage();
+ message.arg1 = OP_USER_ACTIVITY;
+ mServiceHandler.sendMessage(message);
+ unregisterUserActivityReceiver();
+ }
+ }
+ };
+ registerReceiver(mUserActivityReceiver, new IntentFilter(
+ WindowManagerPolicyConstants.ACTION_USER_ACTIVITY_NOTIFICATION));
+ try {
+ IWindowManager wm = IWindowManager.Stub.asInterface(
+ ServiceManager.getService(Context.WINDOW_SERVICE));
+ wm.requestUserActivityNotification();
+ } catch (RemoteException e) {
+ CatLog.e(this, "failed to init WindowManager:" + e);
+ }
+ }
+ }
+
+ private synchronized void unregisterUserActivityReceiver() {
+ if (mUserActivityReceiver != null) {
+ unregisterReceiver(mUserActivityReceiver);
+ mUserActivityReceiver = null;
+ }
+ }
+
private synchronized void registerProcessObserver() {
if (mProcessObserver == null) {
try {
@@ -1741,6 +1794,7 @@ public class StkAppService extends Service implements Runnable {
CatLog.d(this, " Event " + event + "exists in the EventList");
switch (event) {
+ case USER_ACTIVITY_EVENT:
case IDLE_SCREEN_AVAILABLE_EVENT:
sendSetUpEventResponse(event, addedInfo, slotId);
removeSetUpEvent(event, slotId);
@@ -1778,6 +1832,11 @@ public class StkAppService extends Service implements Runnable {
mStkContext[slotId].mSetupEventListSettings.eventList[i] = INVALID_SETUP_EVENT;
switch (event) {
+ case USER_ACTIVITY_EVENT:
+ // The broadcast receiver can be unregistered
+ // as the event has already been sent to the card.
+ unregisterUserActivityReceiver();
+ break;
case IDLE_SCREEN_AVAILABLE_EVENT:
// The process observer can be unregistered
// as the idle screen has already been available.