diff options
Diffstat (limited to 'java/com/android/dialer')
8 files changed, 79 insertions, 57 deletions
diff --git a/java/com/android/dialer/app/DevicePolicyResources.java b/java/com/android/dialer/app/DevicePolicyResources.java new file mode 100644 index 000000000..c783f0bb3 --- /dev/null +++ b/java/com/android/dialer/app/DevicePolicyResources.java @@ -0,0 +1,54 @@ +/* + * Copyright (C) 2022 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.app; + +import android.app.admin.DevicePolicyManager; + +/** + * Class containing the required identifiers to update device management resources. + * + * <p>See {@link DevicePolicyManager#getDrawable} and {@link DevicePolicyManager#getString}. + */ +public class DevicePolicyResources { + + private static final String PREFIX = "Dialer."; + + /** + * The title of the in-call notification for an incoming work call. + */ + public static final String NOTIFICATION_INCOMING_WORK_CALL_TITLE = + PREFIX + "NOTIFICATION_INCOMING_WORK_CALL_TITLE"; + + /** + * The title of the in-call notification for an ongoing work call. + */ + public static final String NOTIFICATION_ONGOING_WORK_CALL_TITLE = + PREFIX + "NOTIFICATION_ONGOING_WORK_CALL_TITLE"; + + /** + * Missed call notification label, used when there's exactly one missed call from work + * contact. + */ + public static final String NOTIFICATION_MISSED_WORK_CALL_TITLE = + PREFIX + "NOTIFICATION_MISSED_WORK_CALL_TITLE"; + + /** + * Label for notification indicating that call is being made over wifi. + */ + public static final String NOTIFICATION_WIFI_WORK_CALL_LABEL = + PREFIX + "NOTIFICATION_WIFI_WORK_CALL_LABEL"; +} diff --git a/java/com/android/dialer/app/calllog/LegacyVoicemailNotifier.java b/java/com/android/dialer/app/calllog/LegacyVoicemailNotifier.java index 1388f43a5..62ae748de 100644 --- a/java/com/android/dialer/app/calllog/LegacyVoicemailNotifier.java +++ b/java/com/android/dialer/app/calllog/LegacyVoicemailNotifier.java @@ -36,7 +36,6 @@ import com.android.dialer.common.LogUtil; import com.android.dialer.location.GeoUtil; import com.android.dialer.notification.DialerNotificationManager; import com.android.dialer.notification.NotificationChannelManager; -import com.android.dialer.notification.VoicemailChannelUtils; import com.android.dialer.phonenumberutil.PhoneNumberHelper; import com.android.dialer.telecom.TelecomUtil; import com.android.dialer.theme.base.ThemeComponent; @@ -182,8 +181,8 @@ public final class LegacyVoicemailNotifier { if (context.getSystemService(TelephonyManager.class).getPhoneCount() <= 1) { return NOTIFICATION_TAG; } - return NOTIFICATION_TAG_PREFIX - + VoicemailChannelUtils.getHashedPhoneAccountId(phoneAccountHandle); + + return NOTIFICATION_TAG_PREFIX + phoneAccountHandle.getId(); } private LegacyVoicemailNotifier() {} diff --git a/java/com/android/dialer/app/calllog/MissedCallNotifier.java b/java/com/android/dialer/app/calllog/MissedCallNotifier.java index 4b5bfba8a..f2d2af834 100644 --- a/java/com/android/dialer/app/calllog/MissedCallNotifier.java +++ b/java/com/android/dialer/app/calllog/MissedCallNotifier.java @@ -15,9 +15,12 @@ */ package com.android.dialer.app.calllog; +import static com.android.dialer.app.DevicePolicyResources.NOTIFICATION_MISSED_WORK_CALL_TITLE; + import android.app.Notification; import android.app.Notification.Builder; import android.app.PendingIntent; +import android.app.admin.DevicePolicyManager; import android.content.ComponentName; import android.content.Context; import android.content.Intent; @@ -107,7 +110,7 @@ public class MissedCallNotifier implements Worker<Pair<Integer, String>, Void> { void updateMissedCallNotification(int count, @Nullable String number) { LogUtil.enterBlock("MissedCallNotifier.updateMissedCallNotification"); - final int titleResId; + final String titleText; CharSequence expandedText; // The text in the notification's line 1 and 2. List<NewCall> newCalls = callLogNotificationsQueryHelper.getNewMissedCalls(); @@ -168,10 +171,13 @@ public class MissedCallNotifier implements Worker<Pair<Integer, String>, Void> { ContactInfo contactInfo = callLogNotificationsQueryHelper.getContactInfo( call.number, call.numberPresentation, call.countryIso); - titleResId = - contactInfo.userType == ContactsUtils.USER_TYPE_WORK - ? R.string.notification_missedWorkCallTitle - : R.string.notification_missedCallTitle; + if (contactInfo.userType == ContactsUtils.USER_TYPE_WORK) { + titleText = context.getSystemService(DevicePolicyManager.class).getResources().getString( + NOTIFICATION_MISSED_WORK_CALL_TITLE, + () -> context.getString(R.string.notification_missedWorkCallTitle)); + } else { + titleText = context.getString(R.string.notification_missedCallTitle); + } if (TextUtils.equals(contactInfo.name, contactInfo.formattedNumber) || TextUtils.equals(contactInfo.name, contactInfo.number)) { @@ -189,7 +195,7 @@ public class MissedCallNotifier implements Worker<Pair<Integer, String>, Void> { groupSummary.setLargeIcon(photoIcon); } } else { - titleResId = R.string.notification_missedCallsTitle; + titleText = context.getString(R.string.notification_missedCallsTitle); expandedText = context.getString(R.string.notification_missedCallsMsg, count); } @@ -199,14 +205,14 @@ public class MissedCallNotifier implements Worker<Pair<Integer, String>, Void> { // notification content is hidden. Notification.Builder publicSummaryBuilder = createNotificationBuilder(); publicSummaryBuilder - .setContentTitle(context.getText(titleResId)) + .setContentTitle(titleText) .setContentIntent(createCallLogPendingIntent()) .setDeleteIntent( CallLogNotificationsService.createCancelAllMissedCallsPendingIntent(context)); // Create the notification summary suitable for display when sensitive information is showing. groupSummary - .setContentTitle(context.getText(titleResId)) + .setContentTitle(titleText) .setContentText(expandedText) .setContentIntent(createCallLogPendingIntent()) .setDeleteIntent( diff --git a/java/com/android/dialer/callintent/CallIntent.java b/java/com/android/dialer/callintent/CallIntent.java index ef7aff672..183eb16e7 100644 --- a/java/com/android/dialer/callintent/CallIntent.java +++ b/java/com/android/dialer/callintent/CallIntent.java @@ -152,8 +152,7 @@ public abstract class CallIntent implements Parcelable { .setTimeSinceFirstClick(PerformanceReport.getTimeSinceFirstClick()) .addAllUiActionsSinceAppLaunch(PerformanceReport.getActions()) .addAllUiActionTimestampsSinceAppLaunch(PerformanceReport.getActionTimestamps()) - .setStartingTabIndex(PerformanceReport.getStartingTabIndex()) - .build(); + .setStartingTabIndex(PerformanceReport.getStartingTabIndex()); PerformanceReport.stopRecording(); } diff --git a/java/com/android/dialer/callintent/CallIntentBuilder.java b/java/com/android/dialer/callintent/CallIntentBuilder.java index 7cc589123..b7f7d76a9 100644 --- a/java/com/android/dialer/callintent/CallIntentBuilder.java +++ b/java/com/android/dialer/callintent/CallIntentBuilder.java @@ -77,8 +77,7 @@ public class CallIntentBuilder implements Parcelable { .setTimeSinceFirstClick(PerformanceReport.getTimeSinceFirstClick()) .addAllUiActionsSinceAppLaunch(PerformanceReport.getActions()) .addAllUiActionTimestampsSinceAppLaunch(PerformanceReport.getActionTimestamps()) - .setStartingTabIndex(PerformanceReport.getStartingTabIndex()) - .build(); + .setStartingTabIndex(PerformanceReport.getStartingTabIndex()); PerformanceReport.stopRecording(); } diff --git a/java/com/android/dialer/commandline/impl/CallCommand.java b/java/com/android/dialer/commandline/impl/CallCommand.java index 5bcf78548..d0008a321 100644 --- a/java/com/android/dialer/commandline/impl/CallCommand.java +++ b/java/com/android/dialer/commandline/impl/CallCommand.java @@ -19,8 +19,6 @@ package com.android.dialer.commandline.impl; import android.content.Context; import android.content.Intent; import android.support.annotation.NonNull; -import android.telecom.PhoneAccount; -import android.telecom.PhoneAccountHandle; import android.telecom.TelecomManager; import com.android.dialer.buildtype.BuildType; import com.android.dialer.buildtype.BuildType.Type; @@ -67,8 +65,6 @@ public class CallCommand implements Command { } String number = args.expectPositional(0, "number"); TelecomManager telecomManager = appContext.getSystemService(TelecomManager.class); - PhoneAccountHandle phoneAccountHandle = - telecomManager.getDefaultOutgoingPhoneAccount(PhoneAccount.SCHEME_TEL); CallIntentBuilder callIntentBuilder; if ("voicemail".equals(number)) { callIntentBuilder = diff --git a/java/com/android/dialer/contacts/hiresphoto/HighResolutionPhotoRequesterImpl.java b/java/com/android/dialer/contacts/hiresphoto/HighResolutionPhotoRequesterImpl.java index 9201604be..0c1461313 100644 --- a/java/com/android/dialer/contacts/hiresphoto/HighResolutionPhotoRequesterImpl.java +++ b/java/com/android/dialer/contacts/hiresphoto/HighResolutionPhotoRequesterImpl.java @@ -51,8 +51,8 @@ public class HighResolutionPhotoRequesterImpl implements HighResolutionPhotoRequ @VisibleForTesting static final ComponentName SYNC_HIGH_RESOLUTION_PHOTO_SERVICE = new ComponentName( - "com.google.android.syncadapters.contacts", - "com.google.android.syncadapters.contacts.SyncHighResPhotoIntentService"); + "com.google.android.gms", + "com.google.android.gms.people.sync.focus.SyncHighResPhotoIntentOperation"); private final Context appContext; private final ListeningExecutorService backgroundExecutor; @@ -81,7 +81,8 @@ public class HighResolutionPhotoRequesterImpl implements HighResolutionPhotoRequ private void requestInternal(Uri contactUri) throws RequestFailedException { for (Long rawContactId : getGoogleRawContactIds(getContactId(contactUri))) { Uri rawContactUri = ContentUris.withAppendedId(RawContacts.CONTENT_URI, rawContactId); - Intent intent = new Intent(Intent.ACTION_VIEW); + Intent intent = new Intent(); + intent.setAction("com.google.android.gms.people.sync.focus.SYNC_HIGH_RES_PHOTO"); intent.setComponent(SYNC_HIGH_RESOLUTION_PHOTO_SERVICE); intent.setDataAndType(rawContactUri, RawContacts.CONTENT_ITEM_TYPE); intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); @@ -89,7 +90,7 @@ public class HighResolutionPhotoRequesterImpl implements HighResolutionPhotoRequ LogUtil.i( "HighResolutionPhotoRequesterImpl.requestInternal", "requesting photo for " + rawContactUri); - appContext.startService(intent); + appContext.sendBroadcast(intent); } catch (IllegalStateException | SecurityException e) { throw new RequestFailedException("unable to start sync adapter", e); } diff --git a/java/com/android/dialer/notification/VoicemailChannelUtils.java b/java/com/android/dialer/notification/VoicemailChannelUtils.java index 83bda0f18..ddc0f773c 100644 --- a/java/com/android/dialer/notification/VoicemailChannelUtils.java +++ b/java/com/android/dialer/notification/VoicemailChannelUtils.java @@ -16,8 +16,6 @@ package com.android.dialer.notification; -import static java.nio.charset.StandardCharsets.UTF_8; - import android.Manifest.permission; import android.annotation.TargetApi; import android.app.NotificationChannel; @@ -40,35 +38,15 @@ import android.util.ArraySet; import com.android.dialer.common.Assert; import com.android.dialer.common.LogUtil; import com.android.dialer.util.PermissionsUtil; -import java.security.MessageDigest; -import java.security.NoSuchAlgorithmException; import java.util.ArrayList; import java.util.List; import java.util.Set; /** Utilities for working with voicemail channels. */ @TargetApi(VERSION_CODES.O) -public final class VoicemailChannelUtils { +/* package */ final class VoicemailChannelUtils { @VisibleForTesting static final String GLOBAL_VOICEMAIL_CHANNEL_ID = "phone_voicemail"; private static final String PER_ACCOUNT_VOICEMAIL_CHANNEL_ID_PREFIX = "phone_voicemail_account_"; - private static final char[] hexDigits = "0123456789abcdef".toCharArray(); - - /** - * Returns a String representation of the hashed value of the PhoneAccountHandle's id (the - * Sim ICC ID). - * In case it fails to hash the id it will return an empty string. - */ - public static String getHashedPhoneAccountId(@NonNull PhoneAccountHandle handle) { - byte[] handleBytes = handle.getId().getBytes(UTF_8); - try { - byte[] hashedBytes = MessageDigest.getInstance("SHA-256").digest(handleBytes); - return byteArrayToHexString(hashedBytes); - } catch (NoSuchAlgorithmException e) { - LogUtil.e("VoicemailChannelUtils.getHashedPhoneAccountId", - "NoSuchAlgorithmException throw! Returning empty string!"); - return ""; - } - } @SuppressWarnings("MissingPermission") // isSingleSimDevice() returns true if no permission static Set<String> getAllChannelIds(@NonNull Context context) { @@ -146,17 +124,7 @@ public final class VoicemailChannelUtils { private static String getChannelIdForAccount(@NonNull PhoneAccountHandle handle) { Assert.isNotNull(handle); - return PER_ACCOUNT_VOICEMAIL_CHANNEL_ID_PREFIX - + ":" - + getHashedPhoneAccountId(handle); - } - - private static String byteArrayToHexString(byte[] bytes) { - StringBuilder sb = new StringBuilder(2 * bytes.length); - for (byte b : bytes) { - sb.append(hexDigits[(b >> 4) & 0xf]).append(hexDigits[b & 0xf]); - } - return sb.toString(); + return PER_ACCOUNT_VOICEMAIL_CHANNEL_ID_PREFIX + ":" + handle.getId(); } /** |