Singleton providers should post change notifs to all users
Potential fix for secondary users not getting content observer
callbacks for sms updates.
Bug: 16681533
Change-Id: I80353680f5da52ca5a23cde7804e9eaab9516f9a
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index 32c1962..c1c2795 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -21,6 +21,7 @@
<uses-permission android:name="android.permission.RECEIVE_SMS" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
+ <uses-permission android:name="android.permission.INTERACT_ACROSS_USERS" />
<application android:process="com.android.phone"
android:allowClearUserData="false"
diff --git a/src/com/android/providers/telephony/MmsProvider.java b/src/com/android/providers/telephony/MmsProvider.java
index 424ea0e..129c480 100644
--- a/src/com/android/providers/telephony/MmsProvider.java
+++ b/src/com/android/providers/telephony/MmsProvider.java
@@ -30,6 +30,7 @@
import android.net.Uri;
import android.os.FileUtils;
import android.os.ParcelFileDescriptor;
+import android.os.UserHandle;
import android.provider.BaseColumns;
import android.provider.Telephony;
import android.provider.Telephony.CanonicalAddressesColumns;
@@ -41,13 +42,13 @@
import android.text.TextUtils;
import android.util.Log;
-
import com.google.android.mms.pdu.PduHeaders;
import com.google.android.mms.util.DownloadDrmHelper;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
+
import android.provider.Telephony.Threads;
/**
@@ -875,7 +876,7 @@
private void notifyChange() {
getContext().getContentResolver().notifyChange(
- MmsSms.CONTENT_URI, null);
+ MmsSms.CONTENT_URI, null, true, UserHandle.USER_ALL);
}
private final static String TAG = "MmsProvider";
diff --git a/src/com/android/providers/telephony/MmsSmsProvider.java b/src/com/android/providers/telephony/MmsSmsProvider.java
index 1806e01..65b377c 100644
--- a/src/com/android/providers/telephony/MmsSmsProvider.java
+++ b/src/com/android/providers/telephony/MmsSmsProvider.java
@@ -32,6 +32,7 @@
import android.database.sqlite.SQLiteOpenHelper;
import android.database.sqlite.SQLiteQueryBuilder;
import android.net.Uri;
+import android.os.UserHandle;
import android.provider.BaseColumns;
import android.provider.Telephony;
import android.provider.Telephony.CanonicalAddressesColumns;
@@ -611,7 +612,8 @@
Log.d(LOG_TAG, "insertThread: created new thread_id " + result +
" for recipientIds " + /*recipientIds*/ "xxxxxxx");
- getContext().getContentResolver().notifyChange(MmsSms.CONTENT_URI, null);
+ getContext().getContentResolver().notifyChange(MmsSms.CONTENT_URI, null, true,
+ UserHandle.USER_ALL);
}
private static final String THREAD_QUERY =
@@ -1206,7 +1208,8 @@
}
if (affectedRows > 0) {
- context.getContentResolver().notifyChange(MmsSms.CONTENT_URI, null);
+ context.getContentResolver().notifyChange(MmsSms.CONTENT_URI, null, true,
+ UserHandle.USER_ALL);
}
return affectedRows;
}
@@ -1276,7 +1279,7 @@
if (affectedRows > 0) {
getContext().getContentResolver().notifyChange(
- MmsSms.CONTENT_URI, null);
+ MmsSms.CONTENT_URI, null, true, UserHandle.USER_ALL);
}
return affectedRows;
}
diff --git a/src/com/android/providers/telephony/SmsProvider.java b/src/com/android/providers/telephony/SmsProvider.java
index a37c05f..83a4463 100644
--- a/src/com/android/providers/telephony/SmsProvider.java
+++ b/src/com/android/providers/telephony/SmsProvider.java
@@ -22,7 +22,6 @@
import android.content.ContentValues;
import android.content.Context;
import android.content.UriMatcher;
-
import android.database.Cursor;
import android.database.DatabaseUtils;
import android.database.MatrixCursor;
@@ -31,6 +30,7 @@
import android.database.sqlite.SQLiteQueryBuilder;
import android.net.Uri;
import android.os.Binder;
+import android.os.UserHandle;
import android.provider.Contacts;
import android.provider.Telephony;
import android.provider.Telephony.Mms;
@@ -619,7 +619,7 @@
} finally {
ContentResolver cr = getContext().getContentResolver();
- cr.notifyChange(ICC_URI, null);
+ cr.notifyChange(ICC_URI, null, true, UserHandle.USER_ALL);
}
}
@@ -698,9 +698,10 @@
private void notifyChange(Uri uri) {
ContentResolver cr = getContext().getContentResolver();
- cr.notifyChange(uri, null);
- cr.notifyChange(MmsSms.CONTENT_URI, null);
- cr.notifyChange(Uri.parse("content://mms-sms/conversations/"), null);
+ cr.notifyChange(uri, null, true, UserHandle.USER_ALL);
+ cr.notifyChange(MmsSms.CONTENT_URI, null, true, UserHandle.USER_ALL);
+ cr.notifyChange(Uri.parse("content://mms-sms/conversations/"), null, true,
+ UserHandle.USER_ALL);
}
private SQLiteOpenHelper mOpenHelper;