From d88eb719ace9412c7e21968628206a10ab192be7 Mon Sep 17 00:00:00 2001 From: Jay Shrauner Date: Mon, 10 Jun 2013 10:10:11 -0700 Subject: [PATCH] Add number presentation column to call log Change call log so instead of overloading the phone number with special strings "-1", "-2", etc to denote private phone numbers, payphones, etc, put presentation type in its own column and expose in the public API these type values. Bug:6948882 Change-Id: I230c26aa0428d605a0e83169a635b5bbf1aa4e3f --- api/current.txt | 5 +++ core/java/android/provider/CallLog.java | 45 ++++++++++++++----- .../internal/telephony/CallerInfo.java | 4 -- 3 files changed, 40 insertions(+), 14 deletions(-) diff --git a/api/current.txt b/api/current.txt index 7484e704a4785..36b878c8443f5 100644 --- a/api/current.txt +++ b/api/current.txt @@ -18757,8 +18757,13 @@ package android.provider { field public static final int MISSED_TYPE = 3; // 0x3 field public static final java.lang.String NEW = "new"; field public static final java.lang.String NUMBER = "number"; + field public static final java.lang.String NUMBER_PRESENTATION = "presentation"; field public static final java.lang.String OFFSET_PARAM_KEY = "offset"; field public static final int OUTGOING_TYPE = 2; // 0x2 + field public static final int PRESENTATION_ALLOWED = 1; // 0x1 + field public static final int PRESENTATION_PAYPHONE = 4; // 0x4 + field public static final int PRESENTATION_RESTRICTED = 2; // 0x2 + field public static final int PRESENTATION_UNKNOWN = 3; // 0x3 field public static final java.lang.String TYPE = "type"; } diff --git a/core/java/android/provider/CallLog.java b/core/java/android/provider/CallLog.java index 5dca67ff6f989..9d52c8385725d 100644 --- a/core/java/android/provider/CallLog.java +++ b/core/java/android/provider/CallLog.java @@ -136,6 +136,22 @@ public class CallLog { */ public static final String NUMBER = "number"; + /** + * The number presenting rules set by the network for "allowed", + * "payphone", "restricted" or "unknown". + *

Type: INTEGER

+ */ + public static final String NUMBER_PRESENTATION = "presentation"; + + /** Number is allowed to display for caller id. */ + public static final int PRESENTATION_ALLOWED = 1; + /** Number is blocked by user. */ + public static final int PRESENTATION_RESTRICTED = 2; + /** Number is not specified or unknown by network. */ + public static final int PRESENTATION_UNKNOWN = 3; + /** Number is a pay phone. */ + public static final int PRESENTATION_PAYPHONE = 4; + /** * The ISO 3166-1 two letters country code of the country where the * user received or made the call. @@ -267,7 +283,8 @@ public class CallLog { * if the contact is unknown. * @param context the context used to get the ContentResolver * @param number the phone number to be added to the calls db - * @param presentation the number presenting rules set by the network for + * @param presentation enum value from PhoneConstants.PRESENTATION_xxx, which + * is set by the network and denotes the number presenting rules for * "allowed", "payphone", "restricted" or "unknown" * @param callType enumerated values for "incoming", "outgoing", or "missed" * @param start time stamp for the call in milliseconds @@ -278,24 +295,32 @@ public class CallLog { public static Uri addCall(CallerInfo ci, Context context, String number, int presentation, int callType, long start, int duration) { final ContentResolver resolver = context.getContentResolver(); + int numberPresentation = PRESENTATION_ALLOWED; - // If this is a private number then set the number to Private, otherwise check - // if the number field is empty and set the number to Unavailable + // Remap network specified number presentation types + // PhoneConstants.PRESENTATION_xxx to calllog number presentation types + // Calls.PRESENTATION_xxx, in order to insulate the persistent calllog + // from any future radio changes. + // If the number field is empty set the presentation type to Unknown. if (presentation == PhoneConstants.PRESENTATION_RESTRICTED) { - number = CallerInfo.PRIVATE_NUMBER; - if (ci != null) ci.name = ""; + numberPresentation = PRESENTATION_RESTRICTED; } else if (presentation == PhoneConstants.PRESENTATION_PAYPHONE) { - number = CallerInfo.PAYPHONE_NUMBER; - if (ci != null) ci.name = ""; + numberPresentation = PRESENTATION_PAYPHONE; } else if (TextUtils.isEmpty(number) || presentation == PhoneConstants.PRESENTATION_UNKNOWN) { - number = CallerInfo.UNKNOWN_NUMBER; - if (ci != null) ci.name = ""; + numberPresentation = PRESENTATION_UNKNOWN; + } + if (numberPresentation != PRESENTATION_ALLOWED) { + number = ""; + if (ci != null) { + ci.name = ""; + } } - ContentValues values = new ContentValues(5); + ContentValues values = new ContentValues(6); values.put(NUMBER, number); + values.put(NUMBER_PRESENTATION, Integer.valueOf(numberPresentation)); values.put(TYPE, Integer.valueOf(callType)); values.put(DATE, Long.valueOf(start)); values.put(DURATION, Long.valueOf(duration)); diff --git a/telephony/java/com/android/internal/telephony/CallerInfo.java b/telephony/java/com/android/internal/telephony/CallerInfo.java index 228a630e40d8f..69785510789c1 100644 --- a/telephony/java/com/android/internal/telephony/CallerInfo.java +++ b/telephony/java/com/android/internal/telephony/CallerInfo.java @@ -49,10 +49,6 @@ public class CallerInfo { private static final String TAG = "CallerInfo"; private static final boolean VDBG = Rlog.isLoggable(TAG, Log.VERBOSE); - public static final String UNKNOWN_NUMBER = "-1"; - public static final String PRIVATE_NUMBER = "-2"; - public static final String PAYPHONE_NUMBER = "-3"; - /** * Please note that, any one of these member variables can be null, * and any accesses to them should be prepared to handle such a case.