Stk: Icon related changes

Return appropriate result code, if icon is not displayed
and display text msg only if icon display fails or if icon is not
self explanatory.

BUG=22637125
Change-Id: If4b10f267cbbb1385701b0e97210d369f9e61cea
diff --git a/src/com/android/stk/StkAppService.java b/src/com/android/stk/StkAppService.java
index 937acec..0f4107c 100644
--- a/src/com/android/stk/StkAppService.java
+++ b/src/com/android/stk/StkAppService.java
@@ -1003,7 +1003,8 @@
                 if (helpRequired) {
                     resMsg.setResultCode(ResultCode.HELP_INFO_REQUIRED);
                 } else {
-                    resMsg.setResultCode(ResultCode.OK);
+                    resMsg.setResultCode(mStkContext[slotId].mCurrentCmd.hasIconLoadFailed() ?
+                            ResultCode.PRFRMD_ICON_NOT_DISPLAYED : ResultCode.OK);
                 }
                 resMsg.setMenuSelection(menuSelection);
                 break;
@@ -1021,7 +1022,8 @@
                 if (helpRequired) {
                     resMsg.setResultCode(ResultCode.HELP_INFO_REQUIRED);
                 } else {
-                    resMsg.setResultCode(ResultCode.OK);
+                    resMsg.setResultCode(mStkContext[slotId].mCurrentCmd.hasIconLoadFailed() ?
+                            ResultCode.PRFRMD_ICON_NOT_DISPLAYED : ResultCode.OK);
                     resMsg.setInput(input);
                 }
             }
@@ -1031,8 +1033,12 @@
             confirmed = args.getBoolean(CONFIRMATION);
             switch (mStkContext[slotId].mCurrentCmd.getCmdType()) {
             case DISPLAY_TEXT:
-                resMsg.setResultCode(confirmed ? ResultCode.OK
-                    : ResultCode.UICC_SESSION_TERM_BY_USER);
+                if (confirmed) {
+                    resMsg.setResultCode(mStkContext[slotId].mCurrentCmd.hasIconLoadFailed() ?
+                            ResultCode.PRFRMD_ICON_NOT_DISPLAYED : ResultCode.OK);
+                } else {
+                    resMsg.setResultCode(ResultCode.UICC_SESSION_TERM_BY_USER);
+                }
                 break;
             case LAUNCH_BROWSER:
                 resMsg.setResultCode(confirmed ? ResultCode.OK
@@ -1406,7 +1412,14 @@
         } else {
             iv.setVisibility(View.GONE);
         }
-        if (!msg.iconSelfExplanatory) {
+        /* In case of 'self explanatory' stkapp should display the specified
+         * icon in proactive command (but not the alpha string).
+         * If icon is non-self explanatory and if the icon could not be displayed
+         * then alpha string or text data should be displayed
+         * Ref: ETSI 102.223,section 6.5.4
+         */
+        if (mStkContext[slotId].mCurrentCmd.hasIconLoadFailed() ||
+                msg.icon == null || !msg.iconSelfExplanatory) {
             tv.setText(msg.text);
         }
 
@@ -1517,7 +1530,8 @@
             notificationBuilder.setContentIntent(pendingIntent);
             notificationBuilder.setOngoing(true);
             // Set text and icon for the status bar and notification body.
-            if (!msg.iconSelfExplanatory) {
+            if (mStkContext[slotId].mIdleModeTextCmd.hasIconLoadFailed() ||
+                    !msg.iconSelfExplanatory) {
                 notificationBuilder.setContentText(msg.text);
                 notificationBuilder.setTicker(msg.text);
             }