Loading java/com/android/dialer/app/calllog/MissedCallNotificationReceiver.java +2 −0 Original line number Diff line number Diff line Loading @@ -46,6 +46,8 @@ public class MissedCallNotificationReceiver extends BroadcastReceiver { return; } LogUtil.enterBlock("MissedCallNotificationReceiver.onReceive"); int count = intent.getIntExtra( EXTRA_NOTIFICATION_COUNT, CallLogNotificationsService.UNKNOWN_MISSED_CALL_COUNT); Loading java/com/android/dialer/app/calllog/MissedCallNotifier.java +8 −0 Original line number Diff line number Diff line Loading @@ -106,6 +106,8 @@ public class MissedCallNotifier implements Worker<Pair<Integer, String>, Void> { @VisibleForTesting @WorkerThread void updateMissedCallNotification(int count, @Nullable String number) { LogUtil.enterBlock("MissedCallNotifier.updateMissedCallNotification"); final int titleResId; CharSequence expandedText; // The text in the notification's line 1 and 2. Loading Loading @@ -137,6 +139,7 @@ public class MissedCallNotifier implements Worker<Pair<Integer, String>, Void> { if (count == CallLogNotificationsService.UNKNOWN_MISSED_CALL_COUNT) { // If the intent did not contain a count, and we are unable to get a count from the // call log, then no notification can be shown. LogUtil.i("MissedCallNotifier.updateMissedCallNotification", "unknown missed call count"); return; } Loading @@ -144,6 +147,9 @@ public class MissedCallNotifier implements Worker<Pair<Integer, String>, Void> { boolean useCallList = newCalls != null; if (count == 1) { LogUtil.i( "MissedCallNotifier.updateMissedCallNotification", "1 missed call, looking up contact info"); NewCall call = useCallList ? newCalls.get(0) Loading Loading @@ -188,6 +194,8 @@ public class MissedCallNotifier implements Worker<Pair<Integer, String>, Void> { expandedText = context.getString(R.string.notification_missedCallsMsg, count); } LogUtil.i("MissedCallNotifier.updateMissedCallNotification", "preparing notification"); // Create a public viewable version of the notification, suitable for display when sensitive // notification content is hidden. Notification.Builder publicSummaryBuilder = createNotificationBuilder(); Loading java/com/android/dialer/assisteddialing/Constraints.java +2 −1 Original line number Diff line number Diff line Loading @@ -25,6 +25,7 @@ import android.text.TextUtils; import com.android.dialer.common.LogUtil; import com.android.dialer.logging.DialerImpression; import com.android.dialer.logging.Logger; import com.android.dialer.phonenumberutil.PhoneNumberHelper; import com.android.dialer.strictmode.StrictModeUtils; import com.google.i18n.phonenumbers.NumberParseException; import com.google.i18n.phonenumbers.PhoneNumberUtil; Loading Loading @@ -209,7 +210,7 @@ final class Constraints { // roaming and out of service. boolean result = !PhoneNumberUtils.isEmergencyNumber(numberToCheck) && !PhoneNumberUtils.isLocalEmergencyNumber(context, numberToCheck); && !PhoneNumberHelper.isLocalEmergencyNumber(context, numberToCheck); LogUtil.i("Constraints.isNotEmergencyNumber", String.valueOf(result)); return result; } Loading java/com/android/dialer/oem/PhoneNumberUtilsAccessor.java 0 → 100644 +47 −0 Original line number Diff line number Diff line /* * Copyright (C) 2018 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.android.dialer.oem; import android.content.Context; import android.telephony.PhoneNumberUtils; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; /** Provides access to hidden APIs in {@link android.telephony.PhoneNumberUtils}. */ public final class PhoneNumberUtilsAccessor { /** * Checks if a given number is an emergency number for the country that the user is in. * * @param subId the subscription ID of the SIM * @param number the number to check * @param context the specific context which the number should be checked against * @return true if the specified number is an emergency number for the country the user is * currently in. */ public static boolean isLocalEmergencyNumber(Context context, int subId, String number) { try { Method method = PhoneNumberUtils.class.getMethod( "isLocalEmergencyNumber", Context.class, int.class, String.class); return (boolean) method.invoke(null, context, subId, number); } catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException e) { throw new RuntimeException(e); } } } java/com/android/dialer/phonenumberutil/PhoneNumberHelper.java +37 −0 Original line number Diff line number Diff line Loading @@ -25,6 +25,7 @@ import android.support.annotation.NonNull; import android.support.annotation.Nullable; import android.telecom.PhoneAccountHandle; import android.telephony.PhoneNumberUtils; import android.telephony.SubscriptionInfo; import android.telephony.TelephonyManager; import android.text.BidiFormatter; import android.text.TextDirectionHeuristics; Loading @@ -34,10 +35,13 @@ import com.android.dialer.common.LogUtil; import com.android.dialer.compat.CompatUtils; import com.android.dialer.compat.telephony.TelephonyManagerCompat; import com.android.dialer.oem.MotorolaUtils; import com.android.dialer.oem.PhoneNumberUtilsAccessor; import com.android.dialer.phonenumbergeoutil.PhoneNumberGeoUtilComponent; import com.android.dialer.telecom.TelecomUtil; import com.google.common.base.Optional; import java.util.Arrays; import java.util.HashSet; import java.util.List; import java.util.Set; public class PhoneNumberHelper { Loading Loading @@ -137,6 +141,39 @@ public class PhoneNumberHelper { return rawNumber1.equals(rawNumber2); } /** * An enhanced version of {@link PhoneNumberUtils#isLocalEmergencyNumber(Context, String)}. * * <p>This methods supports checking the number for all SIMs. * * @param context the context which the number should be checked against * @param number the number to tbe checked * @return true if the specified number is an emergency number for any SIM in the device. */ @SuppressWarnings("Guava") public static boolean isLocalEmergencyNumber(Context context, String number) { List<PhoneAccountHandle> phoneAccountHandles = TelecomUtil.getSubscriptionPhoneAccounts(context); // If the number of phone accounts with a subscription is no greater than 1, only one SIM is // installed in the device. We hand over the job to PhoneNumberUtils#isLocalEmergencyNumber. if (phoneAccountHandles.size() <= 1) { return PhoneNumberUtils.isLocalEmergencyNumber(context, number); } for (PhoneAccountHandle phoneAccountHandle : phoneAccountHandles) { Optional<SubscriptionInfo> subscriptionInfo = TelecomUtil.getSubscriptionInfo(context, phoneAccountHandle); if (subscriptionInfo.isPresent() && PhoneNumberUtilsAccessor.isLocalEmergencyNumber( context, subscriptionInfo.get().getSubscriptionId(), number)) { return true; } } return false; } /** * Returns true if the given number is the number of the configured voicemail. To be able to * mock-out this, it is not a static method. Loading Loading
java/com/android/dialer/app/calllog/MissedCallNotificationReceiver.java +2 −0 Original line number Diff line number Diff line Loading @@ -46,6 +46,8 @@ public class MissedCallNotificationReceiver extends BroadcastReceiver { return; } LogUtil.enterBlock("MissedCallNotificationReceiver.onReceive"); int count = intent.getIntExtra( EXTRA_NOTIFICATION_COUNT, CallLogNotificationsService.UNKNOWN_MISSED_CALL_COUNT); Loading
java/com/android/dialer/app/calllog/MissedCallNotifier.java +8 −0 Original line number Diff line number Diff line Loading @@ -106,6 +106,8 @@ public class MissedCallNotifier implements Worker<Pair<Integer, String>, Void> { @VisibleForTesting @WorkerThread void updateMissedCallNotification(int count, @Nullable String number) { LogUtil.enterBlock("MissedCallNotifier.updateMissedCallNotification"); final int titleResId; CharSequence expandedText; // The text in the notification's line 1 and 2. Loading Loading @@ -137,6 +139,7 @@ public class MissedCallNotifier implements Worker<Pair<Integer, String>, Void> { if (count == CallLogNotificationsService.UNKNOWN_MISSED_CALL_COUNT) { // If the intent did not contain a count, and we are unable to get a count from the // call log, then no notification can be shown. LogUtil.i("MissedCallNotifier.updateMissedCallNotification", "unknown missed call count"); return; } Loading @@ -144,6 +147,9 @@ public class MissedCallNotifier implements Worker<Pair<Integer, String>, Void> { boolean useCallList = newCalls != null; if (count == 1) { LogUtil.i( "MissedCallNotifier.updateMissedCallNotification", "1 missed call, looking up contact info"); NewCall call = useCallList ? newCalls.get(0) Loading Loading @@ -188,6 +194,8 @@ public class MissedCallNotifier implements Worker<Pair<Integer, String>, Void> { expandedText = context.getString(R.string.notification_missedCallsMsg, count); } LogUtil.i("MissedCallNotifier.updateMissedCallNotification", "preparing notification"); // Create a public viewable version of the notification, suitable for display when sensitive // notification content is hidden. Notification.Builder publicSummaryBuilder = createNotificationBuilder(); Loading
java/com/android/dialer/assisteddialing/Constraints.java +2 −1 Original line number Diff line number Diff line Loading @@ -25,6 +25,7 @@ import android.text.TextUtils; import com.android.dialer.common.LogUtil; import com.android.dialer.logging.DialerImpression; import com.android.dialer.logging.Logger; import com.android.dialer.phonenumberutil.PhoneNumberHelper; import com.android.dialer.strictmode.StrictModeUtils; import com.google.i18n.phonenumbers.NumberParseException; import com.google.i18n.phonenumbers.PhoneNumberUtil; Loading Loading @@ -209,7 +210,7 @@ final class Constraints { // roaming and out of service. boolean result = !PhoneNumberUtils.isEmergencyNumber(numberToCheck) && !PhoneNumberUtils.isLocalEmergencyNumber(context, numberToCheck); && !PhoneNumberHelper.isLocalEmergencyNumber(context, numberToCheck); LogUtil.i("Constraints.isNotEmergencyNumber", String.valueOf(result)); return result; } Loading
java/com/android/dialer/oem/PhoneNumberUtilsAccessor.java 0 → 100644 +47 −0 Original line number Diff line number Diff line /* * Copyright (C) 2018 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.android.dialer.oem; import android.content.Context; import android.telephony.PhoneNumberUtils; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; /** Provides access to hidden APIs in {@link android.telephony.PhoneNumberUtils}. */ public final class PhoneNumberUtilsAccessor { /** * Checks if a given number is an emergency number for the country that the user is in. * * @param subId the subscription ID of the SIM * @param number the number to check * @param context the specific context which the number should be checked against * @return true if the specified number is an emergency number for the country the user is * currently in. */ public static boolean isLocalEmergencyNumber(Context context, int subId, String number) { try { Method method = PhoneNumberUtils.class.getMethod( "isLocalEmergencyNumber", Context.class, int.class, String.class); return (boolean) method.invoke(null, context, subId, number); } catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException e) { throw new RuntimeException(e); } } }
java/com/android/dialer/phonenumberutil/PhoneNumberHelper.java +37 −0 Original line number Diff line number Diff line Loading @@ -25,6 +25,7 @@ import android.support.annotation.NonNull; import android.support.annotation.Nullable; import android.telecom.PhoneAccountHandle; import android.telephony.PhoneNumberUtils; import android.telephony.SubscriptionInfo; import android.telephony.TelephonyManager; import android.text.BidiFormatter; import android.text.TextDirectionHeuristics; Loading @@ -34,10 +35,13 @@ import com.android.dialer.common.LogUtil; import com.android.dialer.compat.CompatUtils; import com.android.dialer.compat.telephony.TelephonyManagerCompat; import com.android.dialer.oem.MotorolaUtils; import com.android.dialer.oem.PhoneNumberUtilsAccessor; import com.android.dialer.phonenumbergeoutil.PhoneNumberGeoUtilComponent; import com.android.dialer.telecom.TelecomUtil; import com.google.common.base.Optional; import java.util.Arrays; import java.util.HashSet; import java.util.List; import java.util.Set; public class PhoneNumberHelper { Loading Loading @@ -137,6 +141,39 @@ public class PhoneNumberHelper { return rawNumber1.equals(rawNumber2); } /** * An enhanced version of {@link PhoneNumberUtils#isLocalEmergencyNumber(Context, String)}. * * <p>This methods supports checking the number for all SIMs. * * @param context the context which the number should be checked against * @param number the number to tbe checked * @return true if the specified number is an emergency number for any SIM in the device. */ @SuppressWarnings("Guava") public static boolean isLocalEmergencyNumber(Context context, String number) { List<PhoneAccountHandle> phoneAccountHandles = TelecomUtil.getSubscriptionPhoneAccounts(context); // If the number of phone accounts with a subscription is no greater than 1, only one SIM is // installed in the device. We hand over the job to PhoneNumberUtils#isLocalEmergencyNumber. if (phoneAccountHandles.size() <= 1) { return PhoneNumberUtils.isLocalEmergencyNumber(context, number); } for (PhoneAccountHandle phoneAccountHandle : phoneAccountHandles) { Optional<SubscriptionInfo> subscriptionInfo = TelecomUtil.getSubscriptionInfo(context, phoneAccountHandle); if (subscriptionInfo.isPresent() && PhoneNumberUtilsAccessor.isLocalEmergencyNumber( context, subscriptionInfo.get().getSubscriptionId(), number)) { return true; } } return false; } /** * Returns true if the given number is the number of the configured voicemail. To be able to * mock-out this, it is not a static method. Loading