summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorUmashankar Godachi <umasha@codeaurora.org>2014-03-14 16:26:57 +0530
committerLinux Build Service Account <lnxbuild@localhost>2015-10-06 03:29:34 -0600
commitb7a497d0cf60c997b7cf2a199a212a231b69bd91 (patch)
treeecc5437562eaa7e34f01fcbfa07721fbe5479a1a
parent26814c0cf415d953d9d0243ab06739180bc4de9a (diff)
downloadandroid_packages_apps_Stk-b7a497d0cf60c997b7cf2a199a212a231b69bd91.tar.gz
android_packages_apps_Stk-b7a497d0cf60c997b7cf2a199a212a231b69bd91.tar.bz2
android_packages_apps_Stk-b7a497d0cf60c997b7cf2a199a212a231b69bd91.zip
Do not inform user when the alpha identifier is a null data.
Current code is not in accordance with the spec 3GPP TS 11.14, 6.4.5. Play Tone, as user is informed when the alpha identifier is a null data. With reference to the spec, if there is no alpha identifier, show the text message to the user depending on the config setting. If alpha identifier data is null, play only tone and do not inform the user. Move the code to handle play tone from ToneDialog to StkAppService in cases where only tone needs to be played and no user inform needed. Dismiss the tone dialog from StkAppService after play tone finish. Send the intent to StkAppService from ToneDialog to finish the play tone, when user presses back key. Ref spec: 3GPP TS 11.14, 6.4.5. Play Tone. CRs-Fixed: 631723, 517578 Change-Id: I0acf11e86714138e6d3193b17181c6710d06dfb2
-rw-r--r--res/values/strings.xml2
-rwxr-xr-xsrc/com/android/stk/StkAppService.java152
-rw-r--r--src/com/android/stk/ToneDialog.java96
3 files changed, 167 insertions, 83 deletions
diff --git a/res/values/strings.xml b/res/values/strings.xml
index ea50e85..c33b98f 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -50,6 +50,8 @@
<!-- Title text used for system dialog from STK app -->
<string name="stk_dialog_title">SIM ToolKit</string>
+ <!-- Default message when no alpha tag in Play Tone -->
+ <string name="default_tone_dialog_msg">Playing Tone</string>
<!-- Default message when no alpha in OPEN_CHANNEL -->
<string name="default_open_channel_msg">Open Channel?</string>
<!-- Default message when no alpha in SEND_DATA -->
diff --git a/src/com/android/stk/StkAppService.java b/src/com/android/stk/StkAppService.java
index 30169fe..71c657f 100755
--- a/src/com/android/stk/StkAppService.java
+++ b/src/com/android/stk/StkAppService.java
@@ -32,6 +32,8 @@ import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.res.Configuration;
+import android.content.res.Resources;
+import android.content.res.Resources.NotFoundException;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.net.Uri;
@@ -42,6 +44,7 @@ import android.os.Looper;
import android.os.Message;
import android.os.PowerManager;
import android.os.SystemProperties;
+import android.os.Vibrator;
import android.provider.Settings;
import android.telephony.TelephonyManager;
import android.view.Gravity;
@@ -70,6 +73,7 @@ import com.android.internal.telephony.cat.CatCmdMessage.SetupEventListSettings;
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.cat.ToneSettings;
import com.android.internal.telephony.uicc.IccRefreshResponse;
import com.android.internal.telephony.uicc.IccCardStatus.CardState;
import com.android.internal.telephony.PhoneConstants;
@@ -164,6 +168,8 @@ public class StkAppService extends Service implements Runnable {
private int mSimCount = 0;
private PowerManager mPowerManager = null;
private StkCmdReceiver mStkCmdReceiver = null;
+ private TonePlayer mTonePlayer = null;
+ private Vibrator mVibrator = null;
// Used for setting FLAG_ACTIVITY_NO_USER_ACTION when
// creating an intent.
@@ -187,6 +193,8 @@ public class StkAppService extends Service implements Runnable {
static final String STK_MENU_URI = "stk://com.android.stk/menu/";
static final String STK_INPUT_URI = "stk://com.android.stk/input/";
static final String STK_TONE_URI = "stk://com.android.stk/tone/";
+ static final String FINISH_TONE_ACTIVITY_ACTION =
+ "org.codeaurora.intent.action.stk.finish_activity";
// These below constants are used for SETUP_EVENT_LIST
static final String SETUP_EVENT_TYPE = "event";
@@ -210,6 +218,15 @@ public class StkAppService extends Service implements Runnable {
//Invalid SetupEvent
static final int INVALID_SETUP_EVENT = 0xFF;
+ // Message id to signal tone duration timeout.
+ private static final int OP_STOP_TONE = 16;
+
+ // Message id to signal stop tone on user keyback.
+ static final int OP_STOP_TONE_USER = 17;
+
+ // Message id to remove stop tone message from queue.
+ private static final int STOP_TONE_WHAT = 100;
+
// Response ids
static final int RES_ID_MENU_SELECTION = 11;
static final int RES_ID_INPUT = 12;
@@ -351,6 +368,10 @@ public class StkAppService extends Service implements Runnable {
case OP_END_SESSION:
case OP_BOOT_COMPLETED:
break;
+ case OP_STOP_TONE_USER:
+ msg.obj = args;
+ msg.what = STOP_TONE_WHAT;
+ break;
default:
return;
}
@@ -596,6 +617,11 @@ public class StkAppService extends Service implements Runnable {
}
}
break;
+ case OP_STOP_TONE_USER:
+ case OP_STOP_TONE:
+ CatLog.d(this, "Stop tone");
+ handleStopTone(msg, slotId);
+ break;
}
}
@@ -960,7 +986,7 @@ public class StkAppService extends Service implements Runnable {
launchConfirmationDialog(mesg, slotId);
break;
case PLAY_TONE:
- launchToneDialog(slotId);
+ handlePlayTone(slotId);
break;
case OPEN_CHANNEL:
launchOpenChannelDialog(slotId);
@@ -1593,21 +1619,115 @@ public class StkAppService extends Service implements Runnable {
}
}
- private void launchToneDialog(int slotId) {
- Intent newIntent = new Intent(this, ToneDialog.class);
- String uriString = STK_TONE_URI + slotId;
- Uri uriData = Uri.parse(uriString);
- //Set unique URI to create a new instance of activity for different slotId.
- CatLog.d(LOG_TAG, "launchToneDialog, slotId: " + slotId);
- newIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK
- | Intent.FLAG_ACTIVITY_NO_HISTORY
- | Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS
- | getFlagActivityNoUserAction(InitiatedByUserAction.unknown, slotId));
- newIntent.putExtra("TEXT", mStkContext[slotId].mCurrentCmd.geTextMessage());
- newIntent.putExtra("TONE", mStkContext[slotId].mCurrentCmd.getToneSettings());
- newIntent.putExtra(SLOT_ID, slotId);
- newIntent.setData(uriData);
- startActivity(newIntent);
+ private void handlePlayTone(int slotId) {
+ TextMessage toneMsg = mStkContext[slotId].mCurrentCmd.geTextMessage();
+
+ boolean showUser = true;
+ boolean displayDialog = true;
+ Resources resource = Resources.getSystem();
+ try {
+ displayDialog = !resource.getBoolean(
+ com.android.internal.R.bool.config_stkNoAlphaUsrCnf);
+ } catch (NotFoundException e) {
+ displayDialog = true;
+ }
+
+ // As per the spec 3GPP TS 11.14, 6.4.5. Play Tone.
+ // If there is no alpha identifier tlv present, UE may show the
+ // user information.'config_stkNoAlphaUsrCnf' value will decide
+ // whether to show it or not.
+ // If alpha identifier tlv is present and its data is null, play only tone
+ // without showing user any information.
+ // Alpha Id is Present, but the text data is null.
+ if ((toneMsg.text != null ) && (toneMsg.text.equals(""))) {
+ CatLog.d(this, "Alpha identifier data is null, play only tone");
+ showUser = false;
+ }
+ // Alpha Id is not present AND we need to show info to the user.
+ if (toneMsg.text == null && displayDialog) {
+ CatLog.d(this, "toneMsg.text " + toneMsg.text
+ + " Starting ToneDialog activity with default message.");
+ toneMsg.text = getResources().getString(R.string.default_tone_dialog_msg);
+ showUser = true;
+ }
+ // Dont show user info, if config setting is true.
+ if (toneMsg.text == null && !displayDialog) {
+ CatLog.d(this, "config value stkNoAlphaUsrCnf is true");
+ showUser = false;
+ }
+
+ CatLog.d(this, "toneMsg.text: " + toneMsg.text + "showUser: " +showUser +
+ "displayDialog: " +displayDialog);
+ playTone(showUser, slotId);
+ }
+
+ private void playTone(boolean showUserInfo, int slotId) {
+ // Start playing tone and vibration
+ ToneSettings settings = mStkContext[slotId].mCurrentCmd.getToneSettings();
+ mVibrator = (Vibrator)getSystemService(VIBRATOR_SERVICE);
+ mTonePlayer = new TonePlayer();
+ mTonePlayer.play(settings.tone);
+ int timeout = StkApp.calculateDurationInMilis(settings.duration);
+ if (timeout == 0) {
+ timeout = StkApp.TONE_DFEAULT_TIMEOUT;
+ }
+
+ Message msg = mServiceHandler.obtainMessage();
+ msg.arg1 = OP_STOP_TONE;
+ msg.arg2 = (showUserInfo) ? 1 : 0;
+ msg.what = STOP_TONE_WHAT;
+ mServiceHandler.sendMessageDelayed(msg, timeout);
+ if (settings.vibrate) {
+ mVibrator.vibrate(timeout);
+ }
+
+ // Start Tone dialog Activity to show user the information.
+ if (showUserInfo) {
+ Intent newIntent = new Intent(sInstance, ToneDialog.class);
+ String uriString = STK_TONE_URI + slotId;
+ Uri uriData = Uri.parse(uriString);
+ newIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK
+ | Intent.FLAG_ACTIVITY_NO_HISTORY
+ | Intent.FLAG_ACTIVITY_SINGLE_TOP
+ | Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS
+ | getFlagActivityNoUserAction(InitiatedByUserAction.unknown, slotId));
+ newIntent.putExtra("TEXT", mStkContext[slotId].mCurrentCmd.geTextMessage());
+ newIntent.putExtra(SLOT_ID, slotId);
+ newIntent.setData(uriData);
+ startActivity(newIntent);
+ }
+ }
+
+ private void finishToneDialogActivity() {
+ Intent finishIntent = new Intent(FINISH_TONE_ACTIVITY_ACTION);
+ sendBroadcast(finishIntent);
+ }
+
+ private void handleStopTone(Message msg, int slotId) {
+ int resId = 0;
+
+ // Stop the play tone in following cases,
+ // 1.OP_STOP_TONE: play tone timer expires.
+ // 2.STOP_TONE_USER: user pressed the back key.
+ if (msg.arg1 == OP_STOP_TONE) {
+ resId = RES_ID_DONE;
+ // Dismiss Tone dialog, after finishing off playing the tone.
+ if (msg.arg2 == 1) finishToneDialogActivity();
+ } else if (msg.arg1 == OP_STOP_TONE_USER) {
+ resId = RES_ID_END_SESSION;
+ }
+
+ sendResponse(resId, slotId, true);
+ mServiceHandler.removeMessages(STOP_TONE_WHAT);
+ if (mTonePlayer != null) {
+ mTonePlayer.stop();
+ mTonePlayer.release();
+ mTonePlayer = null;
+ }
+ if (mVibrator != null) {
+ mVibrator.cancel();
+ mVibrator = null;
+ }
}
private void launchOpenChannelDialog(int slotId) {
diff --git a/src/com/android/stk/ToneDialog.java b/src/com/android/stk/ToneDialog.java
index 57a977d..4a88257 100644
--- a/src/com/android/stk/ToneDialog.java
+++ b/src/com/android/stk/ToneDialog.java
@@ -17,11 +17,13 @@
package com.android.stk;
import android.app.Activity;
+import android.content.BroadcastReceiver;
+import android.content.Context;
import android.content.Intent;
+import android.content.IntentFilter;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
-import android.os.Vibrator;
import android.view.KeyEvent;
import android.view.MotionEvent;
import android.view.View;
@@ -29,49 +31,28 @@ import android.widget.ImageView;
import android.widget.TextView;
import com.android.internal.telephony.cat.CatLog;
import com.android.internal.telephony.cat.TextMessage;
-import com.android.internal.telephony.cat.ToneSettings;
+import com.android.internal.telephony.cat.CatLog;
/**
- * Activity used for PLAY TONE command.
+ * Activity used to display tone dialog.
*
*/
public class ToneDialog extends Activity {
TextMessage toneMsg = null;
- ToneSettings settings = null;
- TonePlayer player = null;
int mSlotId = -1;
- boolean mIsResponseSent = false;
private static final String LOG_TAG = new Object(){}.getClass().getEnclosingClass().getName();
- /**
- * Handler used to stop tones from playing when the duration ends.
- */
- Handler mToneStopper = new Handler() {
- @Override
- public void handleMessage(Message msg) {
- switch (msg.what) {
- case MSG_ID_STOP_TONE:
- sendResponse(StkAppService.RES_ID_DONE);
- finish();
- break;
- }
- }
- };
-
- Vibrator mVibrator;
-
- // Message id to signal tone duration timeout.
- private static final int MSG_ID_STOP_TONE = 0xda;
-
@Override
protected void onCreate(Bundle icicle) {
super.onCreate(icicle);
CatLog.d(LOG_TAG, "onCreate");
- mVibrator = (Vibrator)getSystemService(VIBRATOR_SERVICE);
-
initFromIntent(getIntent());
+ // Register receiver
+ IntentFilter filter = new IntentFilter();
+ filter.addAction(StkAppService.FINISH_TONE_ACTIVITY_ACTION);
+ registerReceiver(mFinishActivityReceiver, filter);
// remove window title
View title = findViewById(com.android.internal.R.id.title);
@@ -94,50 +75,21 @@ public class ToneDialog extends Activity {
} else {
iv.setImageBitmap(toneMsg.icon);
}
-
- // Start playing tone and vibration
- if (null == settings) {
- CatLog.d(LOG_TAG, "onCreate - null settings - finish");
- finish();
- return;
- }
-
- player = new TonePlayer();
- player.play(settings.tone);
- int timeout = StkApp.calculateDurationInMilis(settings.duration);
- if (timeout == 0) {
- timeout = StkApp.TONE_DFEAULT_TIMEOUT;
- }
- mToneStopper.sendEmptyMessageDelayed(MSG_ID_STOP_TONE, timeout);
- if (settings.vibrate && mVibrator != null) {
- mVibrator.vibrate(timeout);
- }
}
@Override
protected void onDestroy() {
- super.onDestroy();
CatLog.d(LOG_TAG, "onDestroy");
-
- mToneStopper.removeMessages(MSG_ID_STOP_TONE);
- if (!mIsResponseSent) {
- sendResponse(StkAppService.RES_ID_END_SESSION);
- }
-
- if (null != player) {
- player.stop();
- player.release();
- }
- if (null != mVibrator) {
- mVibrator.cancel();
- }
+ // Unregister receiver
+ unregisterReceiver(mFinishActivityReceiver);
+ super.onDestroy();
}
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
switch (keyCode) {
case KeyEvent.KEYCODE_BACK:
- sendResponse(StkAppService.RES_ID_END_SESSION);
+ sendStopTone();
finish();
break;
}
@@ -148,28 +100,38 @@ public class ToneDialog extends Activity {
public boolean onTouchEvent(MotionEvent event) {
switch (event.getAction()) {
case MotionEvent.ACTION_DOWN:
- sendResponse(StkAppService.RES_ID_END_SESSION);
+ sendStopTone();
finish();
return true;
}
return super.onTouchEvent(event);
}
+ private BroadcastReceiver mFinishActivityReceiver = new BroadcastReceiver() {
+ @Override
+ public void onReceive(Context context, Intent intent) {
+ // Intent received from StkAppService to finish ToneDialog activity,
+ // after finishing off playing the tone.
+ if (intent.getAction().equals(StkAppService.FINISH_TONE_ACTIVITY_ACTION)) {
+ CatLog.d(this, "Finishing Tone dialog activity");
+ finish();
+ }
+ }
+ };
+
private void initFromIntent(Intent intent) {
if (intent == null) {
finish();
}
toneMsg = intent.getParcelableExtra("TEXT");
- settings = intent.getParcelableExtra("TONE");
mSlotId = intent.getIntExtra(StkAppService.SLOT_ID, -1);
}
- private void sendResponse(int resId) {
+ // Send stop playing tone to StkAppService, when user presses back key.
+ private void sendStopTone() {
Bundle args = new Bundle();
- args.putInt(StkAppService.OPCODE, StkAppService.OP_RESPONSE);
+ args.putInt(StkAppService.OPCODE, StkAppService.OP_STOP_TONE_USER);
args.putInt(StkAppService.SLOT_ID, mSlotId);
- args.putInt(StkAppService.RES_ID, resId);
startService(new Intent(this, StkAppService.class).putExtras(args));
- mIsResponseSent = true;
}
}