import android.os.Bundle;
import android.os.Parcel;
import android.os.Parcelable;
+import android.os.UserHandle;
import android.preference.PreferenceManager;
import android.provider.BaseColumns;
import android.provider.Browser;
}
res = ContentUris.withAppendedId(uri, id);
- getContext().getContentResolver().notifyChange(res, null);
+ notifyChange(res);
return res;
}
default:
throw new IllegalArgumentException(TAG + ": delete - unknown URL " + uri);
}
- if (result != 0) {
- getContext().getContentResolver().notifyChange(uri, null);
- }
+ if (result != 0) notifyChange(uri);
return result;
}
default:
throw new IllegalArgumentException(TAG + ": update - unknown URL " + uri);
}
- if (result != 0) {
- getContext().getContentResolver().notifyChange(uri, null);
- }
+ if (result != 0) notifyChange(uri);
return result;
}
@CalledByNative
private void onBookmarkChanged() {
- getContext().getContentResolver().notifyChange(
- buildAPIContentUri(getContext(), BOOKMARKS_PATH), null);
+ notifyChange(buildAPIContentUri(getContext(), BOOKMARKS_PATH));
}
@CalledByNative
private void onSearchTermChanged() {
- getContext().getContentResolver().notifyChange(
- buildAPIContentUri(getContext(), SEARCHES_PATH), null);
+ notifyChange(buildAPIContentUri(getContext(), SEARCHES_PATH));
}
private long addSearchTermFromAPI(ContentValues values) {
context, url, title, favicon, rValue, gValue, bValue);
}
+ private void notifyChange(final Uri uri) {
+ // If the calling user is different than current one, we need to post a
+ // task to notify change, otherwise, a system level hidden permission
+ // INTERACT_ACROSS_USERS_FULL is needed.
+ // The related APIs were added in API 17, it should be safe to fallback to
+ // normal way for notifying change, because caller can't be other users in
+ // devices whose API level is less than API 17.
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
+ UserHandle callingUserHandle = Binder.getCallingUserHandle();
+ if (callingUserHandle != null &&
+ !callingUserHandle.equals(android.os.Process.myUserHandle())) {
+ ThreadUtils.postOnUiThread(new Runnable() {
+ @Override
+ public void run() {
+ getContext().getContentResolver().notifyChange(uri, null);
+ }
+ });
+ return;
+ }
+ }
+ getContext().getContentResolver().notifyChange(uri, null);
+ }
+
private native long nativeInit();
private native void nativeDestroy(long nativeChromeBrowserProvider);