summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAnna Suzuki <anna.x.suzuki@sony.com>2019-02-21 12:52:27 +0900
committerMichael Bestas <mkbestas@lineageos.org>2020-05-23 21:07:36 +0300
commit7989dd9b40436b06dfd01b0b3587ced8c34552f8 (patch)
tree42fed8da10f3147f40089678699afc1ec07be24b
parent7b5e4985d6ce607df9507df3ac5713162853d39d (diff)
downloadandroid_packages_apps_Stk-7989dd9b40436b06dfd01b0b3587ced8c34552f8.tar.gz
android_packages_apps_Stk-7989dd9b40436b06dfd01b0b3587ced8c34552f8.tar.bz2
android_packages_apps_Stk-7989dd9b40436b06dfd01b0b3587ced8c34552f8.zip
Differentiate home screen from others implemented in the same activity
Home screen and overview screen cannot be distinguished if those are implemented in the same activity like Launcher in com.android.launcher3 as the current implementation determines that the foreground screen is the home if it has the home category. Using ACTION_CLOSE_SYSTEM_DIALOGS must be better solution for detecting the home screen. Bug: 130142364 Test: Performed manual test cases which includes regression tests. Change-Id: I2db9181aadbb59fd2ae620cdb41f3e3bcd132e6b
-rw-r--r--src/com/android/stk/StkAppService.java69
1 files changed, 51 insertions, 18 deletions
diff --git a/src/com/android/stk/StkAppService.java b/src/com/android/stk/StkAppService.java
index 9de0ce5..5645013 100644
--- a/src/com/android/stk/StkAppService.java
+++ b/src/com/android/stk/StkAppService.java
@@ -229,6 +229,7 @@ public class StkAppService extends Service implements Runnable {
static final int OP_ALPHA_NOTIFY = 11;
static final int OP_IDLE_SCREEN = 12;
static final int OP_SET_IMMED_DAL_INST = 13;
+ static final int OP_HOME_KEY_PRESSED = 14;
//Invalid SetupEvent
static final int INVALID_SETUP_EVENT = 0xFF;
@@ -300,6 +301,11 @@ public class StkAppService extends Service implements Runnable {
private static final long[] VIBRATION_PATTERN = new long[] { 0, 350, 250, 350 };
private BroadcastReceiver mUserPresentReceiver = null;
+ // The reason based on Intent.ACTION_CLOSE_SYSTEM_DIALOGS.
+ private static final String SYSTEM_DIALOG_REASON_KEY = "reason";
+ private static final String SYSTEM_DIALOG_REASON_HOME_KEY = "homekey";
+ private BroadcastReceiver mHomeKeyEventReceiver = null;
+
@Override
public void onCreate() {
CatLog.d(LOG_TAG, "onCreate()+");
@@ -402,6 +408,7 @@ public class StkAppService extends Service implements Runnable {
unregisterUserActivityReceiver();
unregisterProcessObserver();
unregisterLocaleChangeReceiver();
+ unregisterHomeKeyEventReceiver();
sInstance = null;
waitForLooper();
mServiceLooper.quit();
@@ -692,6 +699,14 @@ public class StkAppService extends Service implements Runnable {
checkForSetupEvent(USER_ACTIVITY_EVENT, null, slot);
}
break;
+ case OP_HOME_KEY_PRESSED:
+ CatLog.d(LOG_TAG, "Process the home key pressed event");
+ for (int slot = 0; slot < mSimCount; slot++) {
+ if (mStkContext[slot] != null) {
+ handleHomeKeyPressed(slot);
+ }
+ }
+ break;
}
}
@@ -777,36 +792,54 @@ public class StkAppService extends Service implements Runnable {
return false;
}
- private void startToObserveIdleScreen(int slotId) {
- if (!mStkContext[slotId].mIsSessionFromUser) {
- if (!isScreenIdle()) {
- synchronized (this) {
- if (mProcessObserver == null && !mServiceHandler.hasMessages(OP_IDLE_SCREEN)) {
- registerProcessObserver();
- }
+ private synchronized void startToObserveHomeKeyEvent(int slotId) {
+ if (mStkContext[slotId].mIsSessionFromUser || mHomeKeyEventReceiver != null) {
+ return;
+ }
+ mHomeKeyEventReceiver = new BroadcastReceiver() {
+ @Override public void onReceive(Context context, Intent intent) {
+ if (SYSTEM_DIALOG_REASON_HOME_KEY.equals(
+ intent.getStringExtra(SYSTEM_DIALOG_REASON_KEY))) {
+ Message message = mServiceHandler.obtainMessage();
+ message.arg1 = OP_HOME_KEY_PRESSED;
+ mServiceHandler.sendMessage(message);
}
- } else {
- handleIdleScreen(slotId);
}
+ };
+ CatLog.d(LOG_TAG, "Started to observe home key event");
+ registerReceiver(mHomeKeyEventReceiver,
+ new IntentFilter(Intent.ACTION_CLOSE_SYSTEM_DIALOGS));
+ }
+
+ private synchronized void unregisterHomeKeyEventReceiver() {
+ if (mHomeKeyEventReceiver != null) {
+ CatLog.d(LOG_TAG, "Stopped to observe home key event");
+ unregisterReceiver(mHomeKeyEventReceiver);
+ mHomeKeyEventReceiver = null;
+ }
+ if (mServiceHandler != null) {
+ mServiceHandler.removeMessages(OP_HOME_KEY_PRESSED);
}
}
- private void handleIdleScreen(int slotId) {
+ private void handleHomeKeyPressed(int slotId) {
// It might be hard for user to recognize that the dialog or screens belong to SIM Toolkit
// application if the current session was not initiated by user but by the SIM card,
- // so it is recommended to send TERMINAL RESPONSE if user goes to the idle screen.
+ // so it is recommended to send TERMINAL RESPONSE if user press the home key.
if (!mStkContext[slotId].mIsSessionFromUser) {
Activity dialog = mStkContext[slotId].getPendingDialogInstance();
+ Activity activity = mStkContext[slotId].getPendingActivityInstance();
if (dialog != null) {
dialog.finish();
mStkContext[slotId].mDialogInstance = null;
- }
- Activity activity = mStkContext[slotId].getPendingActivityInstance();
- if (activity != null) {
+ } else if (activity != null) {
activity.finish();
mStkContext[slotId].mActivityInstance = null;
}
}
+ }
+
+ private void handleIdleScreen(int slotId) {
// If the idle screen event is present in the list need to send the
// response to SIM.
CatLog.d(this, "Need to send IDLE SCREEN Available event to SIM");
@@ -1203,7 +1236,7 @@ public class StkAppService extends Service implements Runnable {
@SuppressWarnings("FallThrough")
private void handleCmdResponse(Bundle args, int slotId) {
CatLog.d(LOG_TAG, "handleCmdResponse, sim id: " + slotId);
- unregisterProcessObserver();
+ unregisterHomeKeyEventReceiver();
if (mStkContext[slotId].mCurrentCmd == null) {
return;
}
@@ -1512,7 +1545,7 @@ public class StkAppService extends Service implements Runnable {
mStkContext[slotId].mMenuState = StkMenuActivity.STATE_SECONDARY;
}
if (mStkContext[slotId].mMenuState == StkMenuActivity.STATE_SECONDARY) {
- startToObserveIdleScreen(slotId);
+ startToObserveHomeKeyEvent(slotId);
}
newIntent.putExtra(SLOT_ID, slotId);
newIntent.setData(uriData);
@@ -1540,7 +1573,7 @@ public class StkAppService extends Service implements Runnable {
notifyUserIfNecessary(slotId, input.text);
}
startActivity(newIntent);
- startToObserveIdleScreen(slotId);
+ startToObserveHomeKeyEvent(slotId);
}
private void launchTextDialog(int slotId) {
@@ -1570,7 +1603,7 @@ public class StkAppService extends Service implements Runnable {
if (!mStkContext[slotId].mCurrentCmd.geTextMessage().responseNeeded) {
sendResponse(RES_ID_CONFIRM, slotId, true);
} else {
- startToObserveIdleScreen(slotId);
+ startToObserveHomeKeyEvent(slotId);
}
}