From 2d2bc16f2d2f155a7cf199f06f6149ed404306ec Mon Sep 17 00:00:00 2001 From: Santos Cordon Date: Fri, 27 Feb 2015 15:22:07 -0800 Subject: [PATCH] Hide calllog entries for unregistered phone accounts Cherry-picked from master Change-Id: If1f873dd41c973442fa7a24020e56d13b7b5ad2c --- api/system-current.txt | 1 + core/java/android/provider/CallLog.java | 25 ++++++++++++++++++- .../java/android/telecom/TelecomManager.java | 9 +++++++ 3 files changed, 34 insertions(+), 1 deletion(-) diff --git a/api/system-current.txt b/api/system-current.txt index 08433c22134ff..391ec374ecfaf 100644 --- a/api/system-current.txt +++ b/api/system-current.txt @@ -30394,6 +30394,7 @@ package android.telecom { method public void unregisterPhoneAccount(android.telecom.PhoneAccountHandle); field public static final java.lang.String ACTION_CHANGE_PHONE_ACCOUNTS = "android.telecom.action.CHANGE_PHONE_ACCOUNTS"; field public static final java.lang.String ACTION_CONNECTION_SERVICE_CONFIGURE = "android.telecom.action.CONNECTION_SERVICE_CONFIGURE"; + field public static final java.lang.String ACTION_PHONE_ACCOUNT_REGISTERED = "android.telecom.action.PHONE_ACCOUNT_REGISTERED"; field public static final java.lang.String ACTION_SHOW_CALL_SETTINGS = "android.telecom.action.SHOW_CALL_SETTINGS"; field public static final char DTMF_CHARACTER_PAUSE = 44; // 0x002c ',' field public static final char DTMF_CHARACTER_WAIT = 59; // 0x003b ';' diff --git a/core/java/android/provider/CallLog.java b/core/java/android/provider/CallLog.java index 266922d95dff6..2df9dbfb467bb 100644 --- a/core/java/android/provider/CallLog.java +++ b/core/java/android/provider/CallLog.java @@ -38,6 +38,7 @@ import android.telecom.PhoneAccountHandle; import android.telecom.TelecomManager; import android.telephony.PhoneNumberUtils; import android.text.TextUtils; +import android.util.Log; import com.android.internal.telephony.CallerInfo; import com.android.internal.telephony.PhoneConstants; @@ -48,6 +49,8 @@ import java.util.List; * The CallLog provider contains information about placed and received calls. */ public class CallLog { + private static final String LOG_TAG = "CallLog"; + public static final String AUTHORITY = "call_log"; /** @@ -358,6 +361,15 @@ public class CallLog { */ public static final String PHONE_ACCOUNT_ADDRESS = "phone_account_address"; + /** + * Indicates that the entry will be hidden from all queries until the associated + * {@link android.telecom.PhoneAccount} is registered with the system. + *

Type: INTEGER

+ * + * @hide + */ + public static final String PHONE_ACCOUNT_HIDDEN = "phone_account_hidden"; + /** * The subscription ID used to place this call. This is no longer used and has been * replaced with PHONE_ACCOUNT_COMPONENT_NAME/PHONE_ACCOUNT_ID. @@ -434,6 +446,7 @@ public class CallLog { long start, int duration, Long dataUsage, boolean addForAllUsers) { final ContentResolver resolver = context.getContentResolver(); int numberPresentation = PRESENTATION_ALLOWED; + boolean isHidden = false; TelecomManager tm = null; try { @@ -444,7 +457,16 @@ public class CallLog { if (tm != null && accountHandle != null) { PhoneAccount account = tm.getPhoneAccount(accountHandle); if (account != null) { - accountAddress = account.getSubscriptionAddress().getSchemeSpecificPart(); + Uri address = account.getSubscriptionAddress(); + if (address != null) { + accountAddress = address.getSchemeSpecificPart(); + } + } else { + // We could not find the account through telecom. For call log entries that + // are added with a phone account which is not registered, we automatically + // mark them as hidden. They are unhidden once the account is registered. + Log.i(LOG_TAG, "Marking call log entry as hidden."); + isHidden = true; } } @@ -490,6 +512,7 @@ public class CallLog { values.put(PHONE_ACCOUNT_COMPONENT_NAME, accountComponentString); values.put(PHONE_ACCOUNT_ID, accountId); values.put(PHONE_ACCOUNT_ADDRESS, accountAddress); + values.put(PHONE_ACCOUNT_HIDDEN, Integer.valueOf(isHidden ? 1 : 0)); values.put(NEW, Integer.valueOf(1)); if (callType == MISSED_TYPE) { diff --git a/telecomm/java/android/telecom/TelecomManager.java b/telecomm/java/android/telecom/TelecomManager.java index 6c5f1c62a5395..8be3e66ca331b 100644 --- a/telecomm/java/android/telecom/TelecomManager.java +++ b/telecomm/java/android/telecom/TelecomManager.java @@ -91,6 +91,15 @@ public class TelecomManager { public static final String ACTION_CHANGE_PHONE_ACCOUNTS = "android.telecom.action.CHANGE_PHONE_ACCOUNTS"; + /** + * The {@link android.content.Intent} action used indicate that a new phone account was + * just registered. + * @hide + */ + @SystemApi + public static final String ACTION_PHONE_ACCOUNT_REGISTERED = + "android.telecom.action.PHONE_ACCOUNT_REGISTERED"; + /** * Optional extra for {@link android.content.Intent#ACTION_CALL} containing a boolean that * determines whether the speakerphone should be automatically turned on for an outgoing call.