Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 203145e5 authored by Makoto Onuki's avatar Makoto Onuki
Browse files

Don't expose raw usage stats to clients; return "low-res" values.

Test: run-all-tests.sh
Test: cts-tradefed run cts-dev --skip-device-info --skip-preconditions --skip-system-status-check \
  com.android.compatibility.common.tradefed.targetprep.NetworkConnectivityChecker -a armeabi-v7a \
  -m CtsProviderTestCases

Bug 31753890

Change-Id: Ie71af1ab31d74fed69342f91304d3718e3ccd133
parent 49a513b5
Loading
Loading
Loading
Loading
+2 −12
Original line number Diff line number Diff line
@@ -438,21 +438,11 @@ public class Contacts {
        public static final String PRIMARY_ORGANIZATION_ID = "primary_organization";

        /**
         * Mark a person as having been contacted.
         *
         * @param resolver the ContentResolver to use
         * @param personId the person who was contacted
         * @deprecated see {@link android.provider.ContactsContract}
         * This API is no longer supported as of O.
         */
        @Deprecated
        public static void markAsContacted(ContentResolver resolver, long personId) {
            Uri uri = ContentUris.withAppendedId(CONTENT_URI, personId);
            uri = Uri.withAppendedPath(uri, "update_contact_time");
            ContentValues values = new ContentValues();
            // There is a trigger in place that will update TIMES_CONTACTED when
            // LAST_TIME_CONTACTED is modified.
            values.put(LAST_TIME_CONTACTED, System.currentTimeMillis());
            resolver.update(uri, values, null, null);
            // No longer supported.
        }

        /**
+44 −4
Original line number Diff line number Diff line
@@ -19,8 +19,6 @@ package android.provider;
import android.accounts.Account;
import android.annotation.SystemApi;
import android.app.Activity;
import android.app.admin.DevicePolicyManager;
import android.content.ActivityNotFoundException;
import android.content.ContentProviderClient;
import android.content.ContentProviderOperation;
import android.content.ContentResolver;
@@ -44,7 +42,6 @@ import android.text.TextUtils;
import android.util.DisplayMetrics;
import android.util.Pair;
import android.view.View;
import android.widget.Toast;

import java.io.ByteArrayInputStream;
import java.io.IOException;
@@ -117,6 +114,12 @@ public final class ContactsContract {
    /** A content:// style uri to the authority for the contacts provider */
    public static final Uri AUTHORITY_URI = Uri.parse("content://" + AUTHORITY);

    /**
     * Prefix for column names that are not visible to client apps.
     * @hide
     */
    public static final String HIDDEN_COLUMN_PREFIX = "x_";

    /**
     * An optional URI parameter for insert, update, or delete queries
     * that allows the caller
@@ -863,6 +866,25 @@ public final class ContactsContract {
         */
        public static final String LAST_TIME_CONTACTED = "last_time_contacted";

        /** @hide Raw value. */
        public static final String RAW_TIMES_CONTACTED = HIDDEN_COLUMN_PREFIX + TIMES_CONTACTED;

        /** @hide Raw value. */
        public static final String RAW_LAST_TIME_CONTACTED =
                HIDDEN_COLUMN_PREFIX + LAST_TIME_CONTACTED;

        /**
         * @hide
         * Low res version.  Same as {@link #TIMES_CONTACTED} but use it in CP2 for clarification.
         */
        public static final String LR_TIMES_CONTACTED = TIMES_CONTACTED;

        /**
         * @hide
         * Low res version.  Same as {@link #TIMES_CONTACTED} but use it in CP2 for clarification.
         */
        public static final String LR_LAST_TIME_CONTACTED = LAST_TIME_CONTACTED;

        /**
         * Is the contact starred?
         * <P>Type: INTEGER (boolean)</P>
@@ -1669,7 +1691,7 @@ public final class ContactsContract {
            Uri uri = ContentUris.withAppendedId(CONTENT_URI, contactId);
            ContentValues values = new ContentValues();
            // TIMES_CONTACTED will be incremented when LAST_TIME_CONTACTED is modified.
            values.put(LAST_TIME_CONTACTED, System.currentTimeMillis());
            values.put(LR_LAST_TIME_CONTACTED, System.currentTimeMillis());
            resolver.update(uri, values, null, null);
        }

@@ -4224,6 +4246,24 @@ public final class ContactsContract {

        /** The number of times the referenced {@link Data} has been used. */
        public static final String TIMES_USED = "times_used";

        /** @hide Raw value. */
        public static final String RAW_LAST_TIME_USED = HIDDEN_COLUMN_PREFIX + LAST_TIME_USED;

        /** @hide Raw value. */
        public static final String RAW_TIMES_USED = HIDDEN_COLUMN_PREFIX + TIMES_USED;

        /**
         * @hide
         * Low res version.  Same as {@link #LAST_TIME_USED} but use it in CP2 for clarification.
         */
        public static final String LR_LAST_TIME_USED = LAST_TIME_USED;

        /**
         * @hide
         * Low res version.  Same as {@link #TIMES_USED} but use it in CP2 for clarification.
         */
        public static final String LR_TIMES_USED = TIMES_USED;
    }

    /**