diff options
author | Yoshiaki Naka <yoshiaki.naka@sony.com> | 2017-08-31 19:25:33 +0900 |
---|---|---|
committer | Jordan Liu <jminjie@google.com> | 2018-03-07 15:38:20 -0800 |
commit | 9018313c3c614230e57de974f702901911af65b5 (patch) | |
tree | b9d7eae9a91662e309f8ee7c37d1458d72023784 | |
parent | f910614ded28b95b805c3f2d1d12bf3f3ca9a55e (diff) | |
download | Stk-9018313c3c614230e57de974f702901911af65b5.tar.gz |
Close the dialog activity before new one is displayed
It is recommended to close the dialog displayed for DISPLAY TEXT command
with an immediate response object before new one is displayed in
accordance with the requirement described in GSMA PDATA.12 - SIM Toolkit
Device Requirements to improve Mobile Connect Customer Experience to
avoid confusion.
ETSI 102.223 also says that the terminal shall continue to display the
text until it receives a subsequent proactive command containing display
data in this scenario, so there is no reason to keep displaying the
former one.
Fixes: 70912340
Test: Confirmed the expected behaviors in the relevant scenarios.
Change-Id: Ia87cb3f410f6c95dcc820450c3792b920556bb56
Merged-In: Ia87cb3f410f6c95dcc820450c3792b920556bb56
-rw-r--r-- | src/com/android/stk/StkAppService.java | 39 | ||||
-rw-r--r-- | src/com/android/stk/StkDialogActivity.java | 17 |
2 files changed, 52 insertions, 4 deletions
diff --git a/src/com/android/stk/StkAppService.java b/src/com/android/stk/StkAppService.java index a85402c..fb157f0 100644 --- a/src/com/android/stk/StkAppService.java +++ b/src/com/android/stk/StkAppService.java @@ -55,6 +55,7 @@ import android.os.Vibrator; import android.provider.Settings; import android.support.v4.content.LocalBroadcastManager; import android.telephony.CarrierConfigManager; +import android.telephony.SubscriptionManager; import android.telephony.TelephonyManager; import android.text.TextUtils; import android.view.Gravity; @@ -124,6 +125,7 @@ public class StkAppService extends Service implements Runnable { protected int mOpCode = -1; private Activity mActivityInstance = null; private Activity mDialogInstance = null; + private Activity mImmediateDialogInstance = null; private int mSlotId = 0; private SetupEventListSettings mSetupEventListSettings = null; private boolean mClearSelectItem = false; @@ -149,6 +151,15 @@ public class StkAppService extends Service implements Runnable { mDialogInstance); return mDialogInstance; } + final synchronized void setImmediateDialogInstance(Activity act) { + CatLog.d(this, "setImmediateDialogInstance act : " + mSlotId + ", " + act); + callSetActivityInstMsg(OP_SET_IMMED_DAL_INST, mSlotId, act); + } + final synchronized Activity getImmediateDialogInstance() { + CatLog.d(this, "getImmediateDialogInstance act : " + mSlotId + ", " + + mImmediateDialogInstance); + return mImmediateDialogInstance; + } } private volatile Looper mServiceLooper; @@ -205,6 +216,7 @@ public class StkAppService extends Service implements Runnable { static final int OP_LOCALE_CHANGED = 10; static final int OP_ALPHA_NOTIFY = 11; static final int OP_IDLE_SCREEN = 12; + static final int OP_SET_IMMED_DAL_INST = 13; //Invalid SetupEvent static final int INVALID_SETUP_EVENT = 0xFF; @@ -621,11 +633,15 @@ public class StkAppService extends Service implements Runnable { } break; case OP_SET_DAL_INST: - Activity dal = new Activity(); + Activity dal = (Activity) msg.obj; CatLog.d(LOG_TAG, "Set dialog instance. " + dal); - dal = (Activity) msg.obj; mStkContext[slotId].mDialogInstance = dal; break; + case OP_SET_IMMED_DAL_INST: + Activity immedDal = (Activity) msg.obj; + CatLog.d(LOG_TAG, "Set dialog instance for immediate response. " + immedDal); + mStkContext[slotId].mImmediateDialogInstance = immedDal; + break; case OP_LOCALE_CHANGED: CatLog.d(this, "Locale Changed"); for (int slot = PhoneConstants.SIM_ID_1; slot < mSimCount; slot++) { @@ -1377,6 +1393,21 @@ public class StkAppService extends Service implements Runnable { } } + @Override + public void startActivity(Intent intent) { + int slotId = intent.getIntExtra(SLOT_ID, SubscriptionManager.INVALID_SIM_SLOT_INDEX); + // Close the dialog displayed for DISPLAY TEXT command with an immediate response object + // before new dialog is displayed. + if (SubscriptionManager.isValidSlotIndex(slotId)) { + Activity dialog = mStkContext[slotId].getImmediateDialogInstance(); + if (dialog != null) { + CatLog.d(LOG_TAG, "finish dialog for immediate response."); + dialog.finish(); + } + } + super.startActivity(intent); + } + private void launchMenuActivity(Menu menu, int slotId) { Intent newIntent = new Intent(Intent.ACTION_VIEW); String targetActivity = STK_MENU_ACTIVITY_NAME; @@ -1411,7 +1442,7 @@ public class StkAppService extends Service implements Runnable { newIntent.putExtra(SLOT_ID, slotId); newIntent.setData(uriData); newIntent.setFlags(intentFlags); - mContext.startActivity(newIntent); + startActivity(newIntent); } private void launchInputActivity(int slotId) { @@ -1433,7 +1464,7 @@ public class StkAppService extends Service implements Runnable { if (input != null) { notifyUserIfNecessary(slotId, input.text); } - mContext.startActivity(newIntent); + startActivity(newIntent); } private void launchTextDialog(int slotId) { diff --git a/src/com/android/stk/StkDialogActivity.java b/src/com/android/stk/StkDialogActivity.java index cdc3c17..be43747 100644 --- a/src/com/android/stk/StkDialogActivity.java +++ b/src/com/android/stk/StkDialogActivity.java @@ -32,6 +32,7 @@ import android.content.DialogInterface; import android.os.Build; import android.os.Bundle; import android.os.SystemClock; +import android.telephony.SubscriptionManager; import android.text.TextUtils; import android.view.LayoutInflater; import android.view.View; @@ -125,6 +126,10 @@ public class StkDialogActivity extends Activity { if (!mTextMsg.responseNeeded) { alertDialogBuilder.setNegativeButton(null, null); + // Register the instance of this activity because the dialog displayed for DISPLAY TEXT + // command with an immediate response object should disappear when the terminal receives + // a subsequent proactive command containing display data. + appService.getStkContext(mSlotId).setImmediateDialogInstance(this); } alertDialogBuilder.setTitle(mTextMsg.title); @@ -301,6 +306,18 @@ public class StkDialogActivity extends Activity { setIntent(intent); } + @Override + public void finish() { + super.finish(); + // Unregister the instance for DISPLAY TEXT command with an immediate response object + // as it is unnecessary to ask the service to finish this anymore. + if ((appService != null) && (mTextMsg != null) && !mTextMsg.responseNeeded) { + if (SubscriptionManager.isValidSlotIndex(mSlotId)) { + appService.getStkContext(mSlotId).setImmediateDialogInstance(null); + } + } + } + private void sendResponse(int resId, boolean confirmed) { if (mSlotId == -1) { CatLog.d(LOG_TAG, "sim id is invalid"); |