Fix AppOps exception for SMS quick reply feature.

Sending a quick SMS reply to an incoming phone call was failing
with a SecurityException due to new AppOps code. The root cause
was the insert() call in SmsProvider was calling back into itself
using the UID of the caller (com.android.mms) but the package name
for the callee (com.android.phone).

Wrapped the insert() method of SmsProvider with a helper function
to save the Binder identity and restore it on completion. This
allows the quick response to make its own provider queries using
its own UID as well as package name. Read/write security checks
will be performed by the content provider framework based on the
manifest file, before insert() is called.

Bug: 11006277
Change-Id: I4c0c8041a2505c5aad8db9b2dbab5402728f9221
diff --git a/src/com/android/providers/telephony/SmsProvider.java b/src/com/android/providers/telephony/SmsProvider.java
index d547d59..c36a0d2 100644
--- a/src/com/android/providers/telephony/SmsProvider.java
+++ b/src/com/android/providers/telephony/SmsProvider.java
@@ -347,6 +347,15 @@
 
     @Override
     public Uri insert(Uri url, ContentValues initialValues) {
+        long token = Binder.clearCallingIdentity();
+        try {
+            return insertInner(url, initialValues);
+        } finally {
+            Binder.restoreCallingIdentity(token);
+        }
+    }
+
+    private Uri insertInner(Uri url, ContentValues initialValues) {
         ContentValues values;
         long rowID;
         int type = Sms.MESSAGE_TYPE_ALL;