summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTakanori Nakano <takanori.nakano@sony.com>2017-10-19 20:36:50 +0900
committerJordan Liu <jminjie@google.com>2018-03-07 15:40:22 -0800
commit6c2d468d153031c7b1ba619cab039cd7dcc73466 (patch)
treeb01c6c2accd233ce1082cac3897894f7b63cba4b
parentf910614ded28b95b805c3f2d1d12bf3f3ca9a55e (diff)
downloadStk-6c2d468d153031c7b1ba619cab039cd7dcc73466.tar.gz
Secondary menu sends unexpected TERMINAL RESPONSE for subsequent command
The instance state of StkMenuActivity is not correctly saved and restored now. That can cause several issues while the activity is recreated. For example, onDestroy() can mistakenly returns TERMINAL RESPONSE for the subsequent command in a particular situation. Fixes: 67991501 Test: Confirmed the expected behavior in manual test cases Change-Id: I0f56ed5ad0b7fb635a35f4f3e9c3d8c32bd67f6f Merged-In: I0f56ed5ad0b7fb635a35f4f3e9c3d8c32bd67f6f
-rw-r--r--src/com/android/stk/StkMenuActivity.java38
1 files changed, 28 insertions, 10 deletions
diff --git a/src/com/android/stk/StkMenuActivity.java b/src/com/android/stk/StkMenuActivity.java
index 9f268d1..bc12eee 100644
--- a/src/com/android/stk/StkMenuActivity.java
+++ b/src/com/android/stk/StkMenuActivity.java
@@ -68,6 +68,12 @@ public class StkMenuActivity extends ListActivity implements View.OnCreateContex
private StkAppService appService = StkAppService.getInstance();
+ // Keys for saving the state of the dialog in the bundle
+ private static final String STATE_KEY = "state";
+ private static final String MENU_KEY = "menu";
+ private static final String ACCEPT_USERS_INPUT_KEY = "accept_users_input";
+ private static final String RESPONSE_SENT_KEY = "response_sent";
+
// Internal state values
static final int STATE_INIT = 0;
static final int STATE_MAIN = 1;
@@ -99,8 +105,8 @@ public class StkMenuActivity extends ListActivity implements View.OnCreateContex
};
@Override
- public void onCreate(Bundle icicle) {
- super.onCreate(icicle);
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
CatLog.d(LOG_TAG, "onCreate");
@@ -242,6 +248,12 @@ public class StkMenuActivity extends ListActivity implements View.OnCreateContex
public void onStop() {
super.onStop();
CatLog.d(LOG_TAG, "onStop, slot id: " + mSlotId + "," + mIsResponseSent + "," + mState);
+
+ // Nothing should be done here if this activity is being restarted now.
+ if (isChangingConfigurations()) {
+ return;
+ }
+
//The menu should stay in background, if
//1. the dialog is pop up in the screen, but the user does not response to the dialog.
//2. the menu activity enters Stop state (e.g pressing HOME key) but mIsResponseSent is false.
@@ -280,8 +292,12 @@ public class StkMenuActivity extends ListActivity implements View.OnCreateContex
//isMenuPending: if input act is finish by stkappservice when OP_LAUNCH_APP again,
//we can not send TR here, since the input cmd is waiting user to process.
if (mState == STATE_SECONDARY && !mIsResponseSent && !appService.isMenuPending(mSlotId)) {
- CatLog.d(LOG_TAG, "handleDestroy - Send End Session");
- sendResponse(StkAppService.RES_ID_END_SESSION);
+ // Avoid sending the terminal response while the activty is being restarted
+ // due to some kind of configuration change.
+ if (!isChangingConfigurations()) {
+ CatLog.d(LOG_TAG, "handleDestroy - Send End Session");
+ sendResponse(StkAppService.RES_ID_END_SESSION);
+ }
}
LocalBroadcastManager.getInstance(this).unregisterReceiver(mLocalBroadcastReceiver);
}
@@ -368,17 +384,18 @@ public class StkMenuActivity extends ListActivity implements View.OnCreateContex
@Override
protected void onSaveInstanceState(Bundle outState) {
CatLog.d(LOG_TAG, "onSaveInstanceState: " + mSlotId);
- outState.putInt("STATE", mState);
- outState.putParcelable("MENU", mStkMenu);
- outState.putBoolean("ACCEPT_USERS_INPUT", mAcceptUsersInput);
+ outState.putInt(STATE_KEY, mState);
+ outState.putParcelable(MENU_KEY, mStkMenu);
+ outState.putBoolean(ACCEPT_USERS_INPUT_KEY, mAcceptUsersInput);
+ outState.putBoolean(RESPONSE_SENT_KEY, mIsResponseSent);
}
@Override
protected void onRestoreInstanceState(Bundle savedInstanceState) {
CatLog.d(LOG_TAG, "onRestoreInstanceState: " + mSlotId);
- mState = savedInstanceState.getInt("STATE");
- mStkMenu = savedInstanceState.getParcelable("MENU");
- mAcceptUsersInput = savedInstanceState.getBoolean("ACCEPT_USERS_INPUT");
+ mState = savedInstanceState.getInt(STATE_KEY);
+ mStkMenu = savedInstanceState.getParcelable(MENU_KEY);
+ mAcceptUsersInput = savedInstanceState.getBoolean(ACCEPT_USERS_INPUT_KEY);
if (!mAcceptUsersInput) {
// Check the latest information as the saved instance state can be outdated.
if ((mState == STATE_MAIN) && appService.isMainMenuAvailable(mSlotId)) {
@@ -387,6 +404,7 @@ public class StkMenuActivity extends ListActivity implements View.OnCreateContex
showProgressBar(true);
}
}
+ mIsResponseSent = savedInstanceState.getBoolean(RESPONSE_SENT_KEY);
}
private void cancelTimeOut() {