P PPR1.180304.001 merge 803f4267f5a459bf264b4a809974d42b4be99c49 - clean

Change-Id: I957be30e55d86f45918d6ee6545bbca6bf663eb5
diff --git a/res/layout/stk_input.xml b/res/layout/stk_input.xml
index c2a34aa..1a6d23c 100644
--- a/res/layout/stk_input.xml
+++ b/res/layout/stk_input.xml
@@ -19,6 +19,16 @@
     android:layout_width="match_parent"
     android:layout_height="wrap_content"
     android:orientation="vertical">
+    <LinearLayout android:id="@+id/titleBar"
+        android:layout_width="match_parent"
+        android:layout_height="50dp"
+        android:orientation="horizontal">
+        <ImageView android:id="@+id/icon"
+            android:layout_width="25dp"
+            android:layout_height="25dp"
+            android:layout_alignParentLeft="true"
+            android:layout_marginLeft="8dp" />
+    </LinearLayout>
     <ImageButton
         style="@android:style/Widget.Material.ActionButton.Overflow"
         android:id="@+id/more"
@@ -30,6 +40,7 @@
     <ScrollView
         xmlns:android="http://schemas.android.com/apk/res/android"
         android:layout_width="match_parent"
+        android:layoutDirection="locale"
         android:layout_height="wrap_content">
         <LinearLayout
             android:layout_width="match_parent"
diff --git a/src/com/android/stk/StkAppService.java b/src/com/android/stk/StkAppService.java
index a85402c..4c2899e 100644
--- a/src/com/android/stk/StkAppService.java
+++ b/src/com/android/stk/StkAppService.java
@@ -269,6 +269,10 @@
     // system property to set the STK specific default url for launch browser proactive cmds
     private static final String STK_BROWSER_DEFAULT_URL_SYSPROP = "persist.radio.stk.default_url";
 
+    // Description of the Icon that is being dispalyed in a Stk activity.
+    public static final String TEXT_DEFAULT_ICON = "Stk Default Icon";
+    public static final String TEXT_ICON_FROM_COMMAND="Stk Icon from Command";
+
     private static final int NOTIFICATION_ON_KEYGUARD = 1;
     private static final long[] VIBRATION_PATTERN = new long[] { 0, 350, 250, 350 };
     private BroadcastReceiver mUserPresentReceiver = null;
@@ -662,6 +666,7 @@
                 cancelIdleText(slotId);
                 mStkContext[slotId].mCurrentMenu = null;
                 mStkContext[slotId].mMainCmd = null;
+                mStkService[slotId] = null;
                 if (isAllOtherCardsAbsent(slotId)) {
                     CatLog.d(LOG_TAG, "All CARDs are ABSENT");
                     StkAppInstaller.unInstall(mContext);
@@ -670,15 +675,18 @@
             } else {
                 IccRefreshResponse state = new IccRefreshResponse();
                 state.refreshResult = args.getInt(AppInterface.REFRESH_RESULT);
+                state.aid = args.getString(AppInterface.AID);
 
-                CatLog.d(LOG_TAG, "Icc Refresh Result: "+ state.refreshResult);
+                CatLog.d(LOG_TAG, "Icc Refresh Result: "+ state.refreshResult
+                        + " aid: " + state.aid);
                 if ((state.refreshResult == IccRefreshResponse.REFRESH_RESULT_INIT) ||
                     (state.refreshResult == IccRefreshResponse.REFRESH_RESULT_RESET)) {
                     // Clear Idle Text
                     cancelIdleText(slotId);
                 }
 
-                if (state.refreshResult == IccRefreshResponse.REFRESH_RESULT_RESET) {
+                if (state.refreshResult == IccRefreshResponse.REFRESH_RESULT_RESET &&
+                        state.aid == null) {
                     // Uninstall STkmenu
                     if (isAllOtherCardsAbsent(slotId)) {
                         StkAppInstaller.unInstall(mContext);
@@ -779,10 +787,12 @@
         switch (cmd.getCmdType()) {
         case SEND_DTMF:
         case SEND_SMS:
+        case RUN_AT:
         case SEND_SS:
         case SEND_USSD:
         case SET_UP_IDLE_MODE_TEXT:
         case SET_UP_MENU:
+        case REFRESH:
         case CLOSE_CHANNEL:
         case RECEIVE_DATA:
         case SEND_DATA:
@@ -1018,11 +1028,26 @@
             break;
         case SEND_DTMF:
         case SEND_SMS:
+        case RUN_AT:
         case SEND_SS:
         case SEND_USSD:
         case GET_CHANNEL_STATUS:
             waitForUsersResponse = false;
             launchEventMessage(slotId);
+            //Reset the mCurrentCmd to mMainCmd, to avoid wrong TR sent for
+            //SEND_SMS/SS/USSD, when user launches STK app next time and do
+            //a menu selection.
+            mStkContext[slotId].mCurrentCmd = mStkContext[slotId].mMainCmd;
+            break;
+        case REFRESH:
+            waitForUsersResponse = false;
+            launchEventMessage(slotId);
+            // Idle mode text needs to be cleared for init or reset modes of refresh
+            if (cmdMsg.isRefreshResetOrInit()) {
+                mNotificationManager.cancel(getNotificationId(slotId));
+                mStkContext[slotId].mIdleModeTextCmd = null;
+                CatLog.d(this, "Clean idle mode text due to refresh");
+            }
             break;
         case LAUNCH_BROWSER:
             // The device setup process should not be interrupted by launching browser.
@@ -1811,6 +1836,7 @@
         ImageView iv = (ImageView) v
                 .findViewById(com.android.internal.R.id.icon);
         if (msg.icon != null) {
+            iv.setContentDescription(TEXT_ICON_FROM_COMMAND);
             iv.setImageBitmap(msg.icon);
         } else {
             iv.setVisibility(View.GONE);
@@ -1933,6 +1959,8 @@
                     .setSmallIcon(com.android.internal.R.drawable.stat_notify_sim_toolkit);
             notificationBuilder.setContentIntent(pendingIntent);
             notificationBuilder.setOngoing(true);
+            notificationBuilder.setStyle(new Notification.BigTextStyle(notificationBuilder)
+                    .bigText(msg.text));
             notificationBuilder.setOnlyAlertOnce(true);
             // Set text and icon for the status bar and notification body.
             if (mStkContext[slotId].mIdleModeTextCmd.hasIconLoadFailed() ||
diff --git a/src/com/android/stk/StkCmdReceiver.java b/src/com/android/stk/StkCmdReceiver.java
index d011eee..715e926 100644
--- a/src/com/android/stk/StkCmdReceiver.java
+++ b/src/com/android/stk/StkCmdReceiver.java
@@ -75,6 +75,7 @@
             args.putInt(AppInterface.REFRESH_RESULT,
                     intent.getIntExtra(AppInterface.REFRESH_RESULT,
                     IccRefreshResponse.REFRESH_RESULT_FILE_UPDATE));
+            args.putString(AppInterface.AID, intent.getStringExtra(AppInterface.AID));
         } else if (StkAppService.OP_ALPHA_NOTIFY == op) {
             String alphaString = intent.getStringExtra(AppInterface.ALPHA_STRING);
             args.putString(AppInterface.ALPHA_STRING, alphaString);
diff --git a/src/com/android/stk/StkInputActivity.java b/src/com/android/stk/StkInputActivity.java
index 5c6087b..6a70b3c 100644
--- a/src/com/android/stk/StkInputActivity.java
+++ b/src/com/android/stk/StkInputActivity.java
@@ -187,6 +187,7 @@
             }
         }
 
+        requestWindowFeature(Window.FEATURE_NO_TITLE);
         // Set the layout for this activity.
         setContentView(R.layout.stk_input);
 
@@ -464,6 +465,8 @@
 
         if (mStkInput.icon != null) {
             ImageView imageView = (ImageView) findViewById(R.id.icon);
+            imageView.setContentDescription(StkAppService.TEXT_ICON_FROM_COMMAND + ": "
+                    + mStkInput.text);
             imageView.setImageBitmap(mStkInput.icon);
             imageView.setVisibility(View.VISIBLE);
         }
diff --git a/src/com/android/stk/StkMenuActivity.java b/src/com/android/stk/StkMenuActivity.java
index 9f268d1..80ad1e9 100644
--- a/src/com/android/stk/StkMenuActivity.java
+++ b/src/com/android/stk/StkMenuActivity.java
@@ -412,6 +412,7 @@
             // Display title & title icon
             if (mStkMenu.titleIcon != null) {
                 mTitleIconView.setImageBitmap(mStkMenu.titleIcon);
+                mTitleIconView.setContentDescription(StkAppService.TEXT_ICON_FROM_COMMAND);
                 mTitleIconView.setVisibility(View.VISIBLE);
                 mTitleTextView.setVisibility(View.INVISIBLE);
                 if (!mStkMenu.titleIconSelfExplanatory) {
diff --git a/src/com/android/stk/StkMenuAdapter.java b/src/com/android/stk/StkMenuAdapter.java
index c53b3ac..4398280 100644
--- a/src/com/android/stk/StkMenuAdapter.java
+++ b/src/com/android/stk/StkMenuAdapter.java
@@ -60,6 +60,8 @@
         } else {
             imageView.setImageBitmap(item.icon);
             imageView.setVisibility(View.VISIBLE);
+            // Add content description for the icon.
+            imageView.setContentDescription(StkAppService.TEXT_ICON_FROM_COMMAND);
         }
 
         return convertView;