From 9986f8e85a095320afbdebb2d0dfee9a2e19e510 Mon Sep 17 00:00:00 2001 From: Brian Attwell Date: Thu, 22 Jan 2015 12:52:00 -0800 Subject: Expose ContentProviderOperation type CHANGE isInsert, isDelete, isUpdate, isAssertQuery JUSTIFICATION The use of getType() in lots of unit tests means that ContentProviderOperation#getType() can't practically be removed. Why not make it public? This allows 3p to use getType() in unit tests. Plus it allows the unbundled contacts app to continue using getType() in order to handle TYPE_INSERT specially, without needing to awkwardly pass isInsert values around. Bug: 18777272 Change-Id: I3265193cda0c9405f6df896cd96a10df7225445a --- api/current.txt | 4 ++++ core/java/android/content/ContentProviderOperation.java | 16 ++++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/api/current.txt b/api/current.txt index fd452913a04b..4f8a68f9a641 100644 --- a/api/current.txt +++ b/api/current.txt @@ -6951,7 +6951,11 @@ package android.content { method public android.content.ContentProviderResult apply(android.content.ContentProvider, android.content.ContentProviderResult[], int) throws android.content.OperationApplicationException; method public int describeContents(); method public android.net.Uri getUri(); + method public boolean isAssertQuery(); + method public boolean isDelete(); + method public boolean isInsert(); method public boolean isReadOperation(); + method public boolean isUpdate(); method public boolean isWriteOperation(); method public boolean isYieldAllowed(); method public static android.content.ContentProviderOperation.Builder newAssertQuery(android.net.Uri); diff --git a/core/java/android/content/ContentProviderOperation.java b/core/java/android/content/ContentProviderOperation.java index 136e54da5cbe..49ac06271983 100644 --- a/core/java/android/content/ContentProviderOperation.java +++ b/core/java/android/content/ContentProviderOperation.java @@ -208,6 +208,22 @@ public class ContentProviderOperation implements Parcelable { return mType; } + public boolean isInsert() { + return mType == TYPE_INSERT; + } + + public boolean isDelete() { + return mType == TYPE_DELETE; + } + + public boolean isUpdate() { + return mType == TYPE_UPDATE; + } + + public boolean isAssertQuery() { + return mType == TYPE_ASSERT; + } + public boolean isWriteOperation() { return mType == TYPE_DELETE || mType == TYPE_INSERT || mType == TYPE_UPDATE; } -- cgit v1.2.3-59-g8ed1b