From 3c893f5b2ce44519752880baba32d11d675a1e36 Mon Sep 17 00:00:00 2001 From: Ta-wei Yen Date: Thu, 30 Nov 2017 14:29:18 -0800 Subject: [PATCH] Add DIRTY_RETAIN constant Previously the DIRTY flag can only be automatically or explicitly set. There are no option to express "This operation does not change the DIRTY flag". This causes issue when the voicemail source is downloading changes from the server instead of uploading and would clobber the flag. After this CL, if DIRTY is updated with DIRTY_RETAIN, the flag will not be updated for the operation. Change-Id: I4ed430865c28c824cbd13ccf884091637b106d8a Fixes: 64371667 Test: CtsProviderTestCases#VoicemailProviderTest --- api/current.txt | 1 + .../android/provider/VoicemailContract.java | 18 ++++++++++++++++-- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/api/current.txt b/api/current.txt index 7c2249143296b..9c5154f8f1ccb 100644 --- a/api/current.txt +++ b/api/current.txt @@ -35955,6 +35955,7 @@ package android.provider { field public static final java.lang.String DATE = "date"; field public static final java.lang.String DELETED = "deleted"; field public static final java.lang.String DIRTY = "dirty"; + field public static final int DIRTY_RETAIN = -1; // 0xffffffff field public static final java.lang.String DIR_TYPE = "vnd.android.cursor.dir/voicemails"; field public static final java.lang.String DURATION = "duration"; field public static final java.lang.String HAS_CONTENT = "has_content"; diff --git a/core/java/android/provider/VoicemailContract.java b/core/java/android/provider/VoicemailContract.java index 864a0fd7d7c56..6be0e76c552b9 100644 --- a/core/java/android/provider/VoicemailContract.java +++ b/core/java/android/provider/VoicemailContract.java @@ -16,7 +16,6 @@ package android.provider; -import android.Manifest; import android.annotation.SdkConstant; import android.annotation.SdkConstant.SdkConstantType; import android.content.ComponentName; @@ -50,7 +49,7 @@ import java.util.List; * * *

The minimum permission needed to access this content provider is - * {@link Manifest.permission#ADD_VOICEMAIL} + * {@link android.Manifest.permission#ADD_VOICEMAIL} * *

Voicemails are inserted by what is called as a "voicemail source" * application, which is responsible for syncing voicemail data between a remote @@ -293,10 +292,25 @@ public class VoicemailContract { * Flag used to indicate that local, unsynced changes are present. * Currently, this is used to indicate that the voicemail was read or deleted. * The value will be 1 if dirty is true, 0 if false. + * + *

When a caller updates a voicemail row (either with {@link ContentResolver#update} or + * {@link ContentResolver#applyBatch}), and if the {@link ContentValues} doesn't contain + * this column, the voicemail provider implicitly sets it to 0 if the calling package is + * the {@link #SOURCE_PACKAGE} or to 1 otherwise. To prevent this behavior, explicitly set + * {@link #DIRTY_RETAIN} to this column in the {@link ContentValues}. + * *

Type: INTEGER (boolean)

+ * + * @see #DIRTY_RETAIN */ public static final String DIRTY = "dirty"; + /** + * Value of {@link #DIRTY} when updating to indicate that the value should not be updated + * during this operation. + */ + public static final int DIRTY_RETAIN = -1; + /** * Flag used to indicate that the voicemail was deleted but not synced to the server. * A deleted row should be ignored.