diff options
author | Steve Kondik <shade@chemlab.org> | 2013-06-22 23:49:28 -0700 |
---|---|---|
committer | Steve Kondik <shade@chemlab.org> | 2013-06-22 23:49:28 -0700 |
commit | 2a654f8713cc3af108192dd33517d363e20b9984 (patch) | |
tree | 6684040b62ce7fd9619239c9e263bfe40d1ec191 | |
parent | c844e938771b1fad878755002e9b9a5128d47551 (diff) | |
download | packages_apps_browser-2a654f8713cc3af108192dd33517d363e20b9984.zip packages_apps_browser-2a654f8713cc3af108192dd33517d363e20b9984.tar.gz packages_apps_browser-2a654f8713cc3af108192dd33517d363e20b9984.tar.bz2 |
browser: Privacy Guard support
* Return empty lists for query of bookmarks and history when privacy
guard is active for the calling process.
Change-Id: I6a20ad481ae60d1e062833db43d1c2fdfe43c687
-rw-r--r-- | src/com/android/browser/provider/BrowserProvider2.java | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/src/com/android/browser/provider/BrowserProvider2.java b/src/com/android/browser/provider/BrowserProvider2.java index 014a32d..b76cb9f 100644 --- a/src/com/android/browser/provider/BrowserProvider2.java +++ b/src/com/android/browser/provider/BrowserProvider2.java @@ -32,10 +32,12 @@ import android.database.ContentObserver; import android.database.Cursor; import android.database.DatabaseUtils; import android.database.MatrixCursor; +import android.database.MemoryCursor; import android.database.sqlite.SQLiteDatabase; import android.database.sqlite.SQLiteOpenHelper; import android.database.sqlite.SQLiteQueryBuilder; import android.net.Uri; +import android.os.Binder; import android.provider.BaseColumns; import android.provider.Browser; import android.provider.Browser.BookmarkColumns; @@ -52,6 +54,7 @@ import android.provider.BrowserContract.SyncState; import android.provider.ContactsContract.RawContacts; import android.provider.SyncStateContract; import android.text.TextUtils; +import android.util.Log; import com.android.browser.R; import com.android.browser.UrlUtils; @@ -68,6 +71,8 @@ import java.util.HashMap; public class BrowserProvider2 extends SQLiteContentProvider { + private static final String TAG = "BrowserProvider2"; + public static final String PARAM_GROUP_BY = "groupBy"; public static final String PARAM_ALLOW_EMPTY_ACCOUNTS = "allowEmptyAccounts"; @@ -876,6 +881,20 @@ public class BrowserProvider2 extends SQLiteContentProvider { @Override public Cursor query(Uri uri, String[] projection, String selection, String[] selectionArgs, String sortOrder) { + Cursor c = queryInternal(uri, projection, selection, selectionArgs, sortOrder); + + if (getContext().isPrivacyGuardEnabled()) { + Log.d(TAG, "Browser query from application using privacy guard! pid=" + Binder.getCallingPid()); + MemoryCursor mc = new MemoryCursor(null, c.getColumnNames()); + c.close(); + return mc; + } + + return c; + } + + private Cursor queryInternal(Uri uri, String[] projection, String selection, String[] selectionArgs, + String sortOrder) { SQLiteDatabase db = mOpenHelper.getReadableDatabase(); final int match = URI_MATCHER.match(uri); SQLiteQueryBuilder qb = new SQLiteQueryBuilder(); @@ -1222,6 +1241,9 @@ public class BrowserProvider2 extends SQLiteContentProvider { @Override public int deleteInTransaction(Uri uri, String selection, String[] selectionArgs, boolean callerIsSyncAdapter) { + if (getContext().isPrivacyGuardEnabled()) { + return 0; + } final int match = URI_MATCHER.match(uri); final SQLiteDatabase db = mOpenHelper.getWritableDatabase(); int deleted = 0; @@ -1365,6 +1387,9 @@ public class BrowserProvider2 extends SQLiteContentProvider { @Override public Uri insertInTransaction(Uri uri, ContentValues values, boolean callerIsSyncAdapter) { + if (getContext().isPrivacyGuardEnabled()) { + return null; + } int match = URI_MATCHER.match(uri); final SQLiteDatabase db = mOpenHelper.getWritableDatabase(); long id = -1; @@ -1615,6 +1640,9 @@ public class BrowserProvider2 extends SQLiteContentProvider { @Override public int updateInTransaction(Uri uri, ContentValues values, String selection, String[] selectionArgs, boolean callerIsSyncAdapter) { + if (getContext().isPrivacyGuardEnabled()) { + return 0; + } int match = URI_MATCHER.match(uri); final SQLiteDatabase db = mOpenHelper.getWritableDatabase(); if (match == LEGACY || match == LEGACY_ID) { |