Merge remote-tracking branch 'origin/sm7225_r_fp4' into fp4-r-rebase

Change-Id: I35de154f3ba4cea90abf6c4db612c94ce19f558c
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index 063e042..746d89b 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -30,6 +30,7 @@
     <uses-permission android:name="android.permission.USER_ACTIVITY" />
     <uses-permission android:name="android.permission.VIBRATE" />
     <uses-permission android:name="android.permission.WAKE_LOCK" />
+    <uses-permission android:name="android.permission.SUBSTITUTE_NOTIFICATION_APP_NAME" />
 
     <application android:icon="@drawable/ic_launcher_sim_toolkit"
         android:label="@string/app_name"
@@ -115,6 +116,9 @@
                 <action android:name= "com.android.internal.stk.session_end" />
                 <action android:name= "com.android.internal.stk.icc_status_change" />
                 <action android:name= "com.android.internal.stk.alpha_notify" />
+                <!-- add by qingyang.yi 2016.6.21 PR:1137553 add for Browser termination EVENT-->
+                <action android:name= "com.stk.intent.action.browser_terminate_action" />
+                <!-- add end by qingyang.yi -->
             </intent-filter>
         </receiver>
 
diff --git a/src/com/android/stk/StkAppService.java b/src/com/android/stk/StkAppService.java
index 9606a78..0618895 100644
--- a/src/com/android/stk/StkAppService.java
+++ b/src/com/android/stk/StkAppService.java
@@ -19,7 +19,9 @@
 import static com.android.internal.telephony.cat.CatCmdMessage.SetupEventListConstants.IDLE_SCREEN_AVAILABLE_EVENT;
 import static com.android.internal.telephony.cat.CatCmdMessage.SetupEventListConstants.LANGUAGE_SELECTION_EVENT;
 import static com.android.internal.telephony.cat.CatCmdMessage.SetupEventListConstants.USER_ACTIVITY_EVENT;
-
+//add by qingyang.yi 2016.6.21 PR:1137553 add for Browser termination EVENT
+import static com.android.internal.telephony.cat.CatCmdMessage.SetupEventListConstants.BROWSER_TERMINATION_EVENT;
+//add end by qingyang.yi
 import android.app.Activity;
 import android.app.ActivityManager;
 import android.app.ActivityManager.RunningTaskInfo;
@@ -295,6 +297,11 @@
     // 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";
+    //add by qingyang.yi 2016.6.21 PR:1137553 add for Browser termination EVENT
+    static final int OP_BROWSER_TERMINATION = 32;
+    private static final String BROWSER_TERMINATE_ACTION = "com.stk.intent.action.browser_terminate_action";
+    private static final String BROWSER_TERMINATION_CAUSE = "browser_termination_cause";
+    //add end by qingyang.yi
 
     private static final int NOTIFICATION_ON_KEYGUARD = 1;
     private static final long[] VIBRATION_PATTERN = new long[] { 0, 350, 250, 350 };
@@ -390,6 +397,9 @@
         case OP_LOCALE_CHANGED:
         case OP_ALPHA_NOTIFY:
         case OP_IDLE_SCREEN:
+        //add by qingyang.yi 2016.6.21 PR:1137553 add for Browser termination EVENT
+        case OP_BROWSER_TERMINATION:
+        //add end by qingyang.yi
         case OP_STOP_TONE_USER:
             msg.obj = args;
             /* falls through */
@@ -709,6 +719,12 @@
                     checkForSetupEvent(USER_ACTIVITY_EVENT, null, slot);
                 }
                 break;
+            //add by qingyang.yi 2016.6.21 PR:1137553 add for Browser termination EVENT
+            case OP_BROWSER_TERMINATION:
+                 CatLog.d(LOG_TAG, "Browser Closed");
+                 checkForSetupEvent(BROWSER_TERMINATION_EVENT, (Bundle) msg.obj,slotId);
+                 break;
+            //add end by qingyang.yi
             case EVENT_MULTI_SIM_CONFIG_CHANGED:
                 handleMultiSimConfigChanged();
                 break;
@@ -1691,11 +1707,18 @@
         builder.setContentText(message);
 
         Menu menu = getMainMenu(slotId);
-        if (menu == null || TextUtils.isEmpty(menu.title)) {
+        // add by T2M.zhangrenjie for FP4-2257 2021-08-20 begin
+
+        /*if (menu == null || TextUtils.isEmpty(menu.title)) {
             builder.setContentTitle("");
         } else {
             builder.setContentTitle(menu.title);
-        }
+        }*/
+        Bundle extras = new Bundle();
+        extras.putString(Notification.EXTRA_SUBSTITUTE_APP_NAME, " ");
+        builder.addExtras(extras);
+        builder.setContentTitle("");
+        // add by T2M.zhangrenjie for FP4-2257 2021-08-20 end
 
         builder.setSmallIcon(R.drawable.stat_notify_sim_toolkit);
         builder.setOngoing(true);
@@ -1984,6 +2007,16 @@
                         addedInfo = GsmAlphabet.stringToGsm8BitPacked(language);
                         sendSetUpEventResponse(event, addedInfo, slotId);
                         break;
+                    //add by qingyang.yi 2016.6.21 PR:1137553 add for Browser termination EVENT
+                    case BROWSER_TERMINATION_EVENT:
+                         int browserTerminationCause = args.getInt(BROWSER_TERMINATION_CAUSE);
+                         CatLog.d(this, "BrowserTerminationCause: " + browserTerminationCause);
+                         // Single byte is sufficient to represent browser termination cause.
+                         addedInfo = new byte[1];
+                         addedInfo[0] = (byte) browserTerminationCause;
+                         sendSetUpEventResponse(event, addedInfo, slotId);
+                         break;
+                    //add end by qingyang.yi
                     default:
                         break;
                 }
@@ -2158,12 +2191,18 @@
             createAllChannels();
             final Notification.Builder notificationBuilder = new Notification.Builder(
                     StkAppService.this, STK_NOTIFICATION_CHANNEL_ID);
-            if (mStkContext[slotId].mMainCmd != null &&
+            // add by T2M.zhangrenjie for FP4-2257 2021-08-20 begin
+            /*if (mStkContext[slotId].mMainCmd != null &&
                     mStkContext[slotId].mMainCmd.getMenu() != null) {
                 notificationBuilder.setContentTitle(mStkContext[slotId].mMainCmd.getMenu().title);
             } else {
                 notificationBuilder.setContentTitle("");
-            }
+            }*/
+            Bundle extras = new Bundle();
+            extras.putString(Notification.EXTRA_SUBSTITUTE_APP_NAME, " ");
+            notificationBuilder.addExtras(extras);
+            notificationBuilder.setContentTitle("");
+            // add by T2M.zhangrenjie for FP4-2257 2021-08-20 end
             notificationBuilder
                     .setSmallIcon(R.drawable.stat_notify_sim_toolkit);
             notificationBuilder.setContentIntent(pendingIntent);
diff --git a/src/com/android/stk/StkCmdReceiver.java b/src/com/android/stk/StkCmdReceiver.java
index 517c70a..b6355ea 100644
--- a/src/com/android/stk/StkCmdReceiver.java
+++ b/src/com/android/stk/StkCmdReceiver.java
@@ -26,6 +26,10 @@
 
 import com.android.internal.telephony.cat.AppInterface;
 
+//add by qingyang.yi 2016.6.21 PR:1137553 add for Browser termination EVENT
+import static com.android.internal.telephony.cat.CatCmdMessage.SetupEventListConstants.*;
+import static com.android.internal.telephony.cat.CatCmdMessage.BrowserTerminationCauses.*;
+//add end by qingyang.yi
 /**
  * Receiver class to get STK intents, broadcasted by telephony layer.
  *
@@ -34,6 +38,20 @@
     private static final String LOG_TAG =
             new Object(){}.getClass().getEnclosingClass().getSimpleName();
 
+        //add by qingyang.yi 2016.6.21 PR:1137553 add for Browser termination EVENT
+        private static final String BROWSER_TERMINATE_ACTION = "com.stk.intent.action.browser_terminate_action";
+        // This is used if Browser termination was erroneous
+        private static final String BROWSER_TERMINATION_CAUSE = "browser_termination_cause";
+
+        private void handleBrowserTerminationEvent(Context context, Intent intent) {
+            Bundle args = new Bundle();
+            int browserTerminationCause = USER_TERMINATION;
+            args.putInt(StkAppService.OPCODE, StkAppService.OP_BROWSER_TERMINATION);
+            browserTerminationCause = intent.getIntExtra(BROWSER_TERMINATION_CAUSE, USER_TERMINATION);
+            args.putInt(BROWSER_TERMINATION_CAUSE, browserTerminationCause);
+            context.startService(new Intent(context, StkAppService.class).putExtras(args));
+        }
+        //add end by qingyang.yi
     @Override
     public void onReceive(Context context, Intent intent) {
         String action = intent.getAction();
@@ -50,6 +68,11 @@
         } else if (action.equals(AppInterface.CAT_ALPHA_NOTIFY_ACTION)) {
             handleAction(context, intent, StkAppService.OP_ALPHA_NOTIFY);
         }
+        //add by qingyang.yi 2016.6.21 PR:1137553 add for Browser termination EVENT
+        else if (action.equals(BROWSER_TERMINATE_ACTION)) {
+            handleBrowserTerminationEvent(context, intent);
+        }
+        //add end by qingyang.yi
     }
 
     private void handleAction(Context context, Intent intent, int op) {
diff --git a/src/com/android/stk/StkInputActivity.java b/src/com/android/stk/StkInputActivity.java
index 8a36a53..7833430 100644
--- a/src/com/android/stk/StkInputActivity.java
+++ b/src/com/android/stk/StkInputActivity.java
@@ -471,8 +471,9 @@
         case STATE_TEXT:
             mTextIn.setFilters(new InputFilter[] {new InputFilter.LengthFilter(mStkInput.maxLen)});
 
-            textInput.setCounterMaxLength(mStkInput.maxLen);
-            textInput.setCounterEnabled(true);
+            // modify by T2M.dengxiangyu for FP4-2259 2021-08-11
+            //textInput.setCounterMaxLength(mStkInput.maxLen);
+            //textInput.setCounterEnabled(true);
 
             if (!mStkInput.echo) {
                 mTextIn.setTransformationMethod(PasswordTransformationMethod