rcs-service: PCI-RCS fix recent bugs

 - Add group_status update triggers for delete sms
 - RichScreen force close occasionally

Change-Id: Ib6a5f6821afbb43428821d88a4cf67c94328bce3
CRs-Fixed: 964447
diff --git a/rcs_ui_common/src/com/suntek/rcs/ui/common/RcsRichScreen.java b/rcs_ui_common/src/com/suntek/rcs/ui/common/RcsRichScreen.java
index 5d67af5..1e09571 100644
--- a/rcs_ui_common/src/com/suntek/rcs/ui/common/RcsRichScreen.java
+++ b/rcs_ui_common/src/com/suntek/rcs/ui/common/RcsRichScreen.java
@@ -231,14 +231,14 @@
             }
         }
         refreshUI(result);
-        if (!TextUtils.isEmpty(result.getGreeting())) {
+        if (result != null && !TextUtils.isEmpty(result.getGreeting())) {
             mGreeting.setVisibility(View.VISIBLE);
             StringBuilder greetingString = new StringBuilder();
             greetingString.append(RCS_GREETING_STRING_EN);
             greetingString.append(result.getGreeting());
             mGreeting.setText(greetingString.toString());
         }
-        if (!TextUtils.isEmpty(result.getMissdnAddress())) {
+        if (result != null && !TextUtils.isEmpty(result.getMissdnAddress())) {
             missdnAddress.setVisibility(View.VISIBLE);
             StringBuilder missdnAddressString = new StringBuilder();
             missdnAddressString.append(RCS_MISSDNADDRESS_STRING_EN);
diff --git a/rcs_ui_common/src/com/suntek/rcs/ui/common/provider/RcsMessageProviderUtils.java b/rcs_ui_common/src/com/suntek/rcs/ui/common/provider/RcsMessageProviderUtils.java
index 18d2c5d..48f11b7 100644
--- a/rcs_ui_common/src/com/suntek/rcs/ui/common/provider/RcsMessageProviderUtils.java
+++ b/rcs_ui_common/src/com/suntek/rcs/ui/common/provider/RcsMessageProviderUtils.java
@@ -520,4 +520,15 @@
             }
         }
     }
+
+    public static void createGroupStatusUpdateTriggers(SQLiteDatabase db) {
+        db.execSQL("CREATE TRIGGER sms_update_group_on_delete AFTER DELETE ON "
+                + RcsMessageProviderConstants.TABLE_SMS
+                + " BEGIN"
+                + " DELETE FROM " + RcsMessageProviderConstants.TABLE_GROUP_STATUS
+                + " WHERE "
+                + RcsColumns.GroupStatusColumns.MSG_ID
+                + " = old._id;"
+                + " END");
+    }
 }