Skip to content

Commit

Permalink
Merge tag 'android-security-11.0.0_r53' into staging/lineage-18.1_mer…
Browse files Browse the repository at this point in the history
…ge-android-security-11.0.0_r53

Android security 11.0.0 release 53

* tag 'android-security-11.0.0_r53':
  Remove PhoneAccountHandle when building the intent to call Voicemail.
  Add a permission to guard receiving intents in StatusSmsFetcher.
  Use an explicit intent to start VoicemailChangePinActivityPeer.
  Hash ICC ID used in the notification tag for voicemail notifications.

Change-Id: Ie5b9b295233b4b6b23d38f07a7914a5354b138bd
  • Loading branch information
haggertk committed Mar 8, 2022
2 parents 6121d3b + 8ff22c5 commit f7ed8dd
Show file tree
Hide file tree
Showing 15 changed files with 76 additions and 37 deletions.
4 changes: 4 additions & 0 deletions AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,10 @@
presses home. -->
<uses-permission android:name="android.permission.STOP_APP_SWITCHES"/>

<!-- Used for sending PendingIntents to dynamically registered receivers -->
<uses-permission android:name="com.android.dialer.permission.DIALER_ORIGIN"
android:protectionLevel="signature" />

<!-- Permissions needed for badger count showing on launch icon. -->

<!--for Samsung-->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -563,7 +563,7 @@ private void updatePrimaryActionButton(boolean isExpanded) {
case CallbackAction.VOICE:
if (callLogCache.isVoicemailNumber(accountHandle, number)) {
// Call to generic voicemail number, in case there are multiple accounts
primaryActionButtonView.setTag(IntentProvider.getReturnVoicemailCallIntentProvider(null));
primaryActionButtonView.setTag(IntentProvider.getReturnVoicemailCallIntentProvider());
} else if (canSupportAssistedDialing()) {
primaryActionButtonView.setTag(
IntentProvider.getAssistedDialIntentProvider(
Expand Down
5 changes: 2 additions & 3 deletions java/com/android/dialer/app/calllog/IntentProvider.java
Original file line number Diff line number Diff line change
Expand Up @@ -169,14 +169,13 @@ public void logInteraction(Context context) {
};
}

public static IntentProvider getReturnVoicemailCallIntentProvider(
@Nullable PhoneAccountHandle phoneAccountHandle) {
public static IntentProvider getReturnVoicemailCallIntentProvider() {
return new IntentProvider() {
@Override
public Intent getClickIntent(Context context) {
return PreCall.getIntent(
context,
CallIntentBuilder.forVoicemail(phoneAccountHandle, CallInitiationType.Type.CALL_LOG));
CallIntentBuilder.forVoicemail(CallInitiationType.Type.CALL_LOG));
}
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
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;
Expand Down Expand Up @@ -181,7 +182,8 @@ private static String getNotificationTag(
if (context.getSystemService(TelephonyManager.class).getPhoneCount() <= 1) {
return NOTIFICATION_TAG;
}
return NOTIFICATION_TAG_PREFIX + phoneAccountHandle.getId();
return NOTIFICATION_TAG_PREFIX
+ VoicemailChannelUtils.getHashedPhoneAccountId(phoneAccountHandle);
}

private LegacyVoicemailNotifier() {}
Expand Down
4 changes: 2 additions & 2 deletions java/com/android/dialer/callintent/CallIntentBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -117,10 +117,10 @@ public CallIntentBuilder(@NonNull Parcel parcel) {
}

public static CallIntentBuilder forVoicemail(
@Nullable PhoneAccountHandle phoneAccountHandle, CallInitiationType.Type callInitiationType) {
CallInitiationType.Type callInitiationType) {
return new CallIntentBuilder(
Uri.fromParts(PhoneAccount.SCHEME_VOICEMAIL, "", null), callInitiationType)
.setPhoneAccountHandle(phoneAccountHandle);
.setPhoneAccountHandle(null);
}

public void setUri(@NonNull Uri uri) {
Expand Down
2 changes: 1 addition & 1 deletion java/com/android/dialer/commandline/impl/CallCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public ListenableFuture<String> run(Arguments args) throws IllegalCommandLineArg
CallIntentBuilder callIntentBuilder;
if ("voicemail".equals(number)) {
callIntentBuilder =
CallIntentBuilder.forVoicemail(phoneAccountHandle, CallInitiationType.Type.DIALPAD);
CallIntentBuilder.forVoicemail(CallInitiationType.Type.DIALPAD);
} else {
callIntentBuilder = new CallIntentBuilder(number, CallInitiationType.Type.DIALPAD);
}
Expand Down
2 changes: 1 addition & 1 deletion java/com/android/dialer/dialpadview/DialpadFragment.java
Original file line number Diff line number Diff line change
Expand Up @@ -1171,7 +1171,7 @@ private void removePreviousDigitIfPossible(char digit) {

public void callVoicemail() {
PreCall.start(
getContext(), CallIntentBuilder.forVoicemail(null, CallInitiationType.Type.DIALPAD));
getContext(), CallIntentBuilder.forVoicemail(CallInitiationType.Type.DIALPAD));
hideAndClearDialpad();
}

Expand Down
36 changes: 34 additions & 2 deletions java/com/android/dialer/notification/VoicemailChannelUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@

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;
Expand All @@ -38,15 +40,35 @@
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)
/* package */ final class VoicemailChannelUtils {
public 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) {
Expand Down Expand Up @@ -124,7 +146,17 @@ private static boolean doesChannelExist(@NonNull Context context, @NonNull Strin

private static String getChannelIdForAccount(@NonNull PhoneAccountHandle handle) {
Assert.isNotNull(handle);
return PER_ACCOUNT_VOICEMAIL_CHANNEL_ID_PREFIX + ":" + handle.getId();
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();
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public static VoicemailErrorMessage create(
return new VoicemailErrorMessage(
context.getString(R.string.voicemail_error_activating_title),
context.getString(R.string.voicemail_error_activating_message),
VoicemailErrorMessage.createCallVoicemailAction(context, status.getPhoneAccountHandle()));
VoicemailErrorMessage.createCallVoicemailAction(context));
}

if (Status.NOTIFICATION_CHANNEL_STATE_NO_CONNECTION == status.notificationChannelState) {
Expand All @@ -77,55 +77,55 @@ public static VoicemailErrorMessage create(
return new VoicemailErrorMessage(
context.getString(R.string.voicemail_error_activation_failed_title),
context.getString(R.string.voicemail_error_activation_failed_message),
VoicemailErrorMessage.createCallVoicemailAction(context, status.getPhoneAccountHandle()),
VoicemailErrorMessage.createCallVoicemailAction(context),
VoicemailErrorMessage.createRetryAction(context, status));
}

if (Status.DATA_CHANNEL_STATE_NO_CONNECTION == status.dataChannelState) {
return new VoicemailErrorMessage(
context.getString(R.string.voicemail_error_no_data_title),
context.getString(R.string.voicemail_error_no_data_message),
VoicemailErrorMessage.createCallVoicemailAction(context, status.getPhoneAccountHandle()),
VoicemailErrorMessage.createCallVoicemailAction(context),
VoicemailErrorMessage.createRetryAction(context, status));
}

if (Status.DATA_CHANNEL_STATE_NO_CONNECTION_CELLULAR_REQUIRED == status.dataChannelState) {
return new VoicemailErrorMessage(
context.getString(R.string.voicemail_error_no_data_title),
context.getString(R.string.voicemail_error_no_data_cellular_required_message),
VoicemailErrorMessage.createCallVoicemailAction(context, status.getPhoneAccountHandle()),
VoicemailErrorMessage.createCallVoicemailAction(context),
VoicemailErrorMessage.createRetryAction(context, status));
}

if (Status.DATA_CHANNEL_STATE_BAD_CONFIGURATION == status.dataChannelState) {
return new VoicemailErrorMessage(
context.getString(R.string.voicemail_error_bad_config_title),
context.getString(R.string.voicemail_error_bad_config_message),
VoicemailErrorMessage.createCallVoicemailAction(context, status.getPhoneAccountHandle()),
VoicemailErrorMessage.createCallVoicemailAction(context),
VoicemailErrorMessage.createRetryAction(context, status));
}

if (Status.DATA_CHANNEL_STATE_COMMUNICATION_ERROR == status.dataChannelState) {
return new VoicemailErrorMessage(
context.getString(R.string.voicemail_error_communication_title),
context.getString(R.string.voicemail_error_communication_message),
VoicemailErrorMessage.createCallVoicemailAction(context, status.getPhoneAccountHandle()),
VoicemailErrorMessage.createCallVoicemailAction(context),
VoicemailErrorMessage.createRetryAction(context, status));
}

if (Status.DATA_CHANNEL_STATE_SERVER_ERROR == status.dataChannelState) {
return new VoicemailErrorMessage(
context.getString(R.string.voicemail_error_server_title),
context.getString(R.string.voicemail_error_server_message),
VoicemailErrorMessage.createCallVoicemailAction(context, status.getPhoneAccountHandle()),
VoicemailErrorMessage.createCallVoicemailAction(context),
VoicemailErrorMessage.createRetryAction(context, status));
}

if (Status.DATA_CHANNEL_STATE_SERVER_CONNECTION_ERROR == status.dataChannelState) {
return new VoicemailErrorMessage(
context.getString(R.string.voicemail_error_server_connection_title),
context.getString(R.string.voicemail_error_server_connection_message),
VoicemailErrorMessage.createCallVoicemailAction(context, status.getPhoneAccountHandle()),
VoicemailErrorMessage.createCallVoicemailAction(context),
VoicemailErrorMessage.createRetryAction(context, status));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ public static Action createSetPinAction(
public void onClick(View v) {
Logger.get(context)
.logImpression(DialerImpression.Type.VOICEMAIL_ALERT_SET_PIN_CLICKED);
Intent intent = new Intent(VoicemailChangePinActivity.ACTION_CHANGE_PIN);
Intent intent = new Intent(context, VoicemailChangePinActivity.class);
intent.putExtra(VoicemailClient.PARAM_PHONE_ACCOUNT_HANDLE, phoneAccountHandle);
context.startActivity(intent);
}
Expand All @@ -159,7 +159,7 @@ public void onClick(View v) {

@NonNull
public static Action createCallVoicemailAction(
final Context context, final PhoneAccountHandle phoneAccountHandle) {
final Context context) {
return new Action(
context.getString(R.string.voicemail_action_call_voicemail),
new OnClickListener() {
Expand All @@ -169,7 +169,7 @@ public void onClick(View v) {
PreCall.start(
context,
CallIntentBuilder.forVoicemail(
phoneAccountHandle, CallInitiationType.Type.VOICEMAIL_ERROR_MESSAGE));
CallInitiationType.Type.VOICEMAIL_ERROR_MESSAGE));
}
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,23 +167,23 @@ public static VoicemailErrorMessage create(
return new VoicemailErrorMessage(
context.getString(R.string.vvm3_error_unknown_user_title),
getCustomerSupportString(context, R.string.vvm3_error_unknown_user_message),
VoicemailErrorMessage.createCallVoicemailAction(context, status.getPhoneAccountHandle()),
VoicemailErrorMessage.createCallVoicemailAction(context),
createCallCustomerSupportAction(context));
}

if (UNKNOWN_DEVICE == status.configurationState) {
return new VoicemailErrorMessage(
context.getString(R.string.vvm3_error_unknown_device_title),
getCustomerSupportString(context, R.string.vvm3_error_unknown_device_message),
VoicemailErrorMessage.createCallVoicemailAction(context, status.getPhoneAccountHandle()),
VoicemailErrorMessage.createCallVoicemailAction(context),
createCallCustomerSupportAction(context));
}

if (INVALID_PASSWORD == status.configurationState) {
return new VoicemailErrorMessage(
context.getString(R.string.vvm3_error_invalid_password_title),
getCustomerSupportString(context, R.string.vvm3_error_invalid_password_message),
VoicemailErrorMessage.createCallVoicemailAction(context, status.getPhoneAccountHandle()),
VoicemailErrorMessage.createCallVoicemailAction(context),
createCallCustomerSupportAction(context));
}

Expand Down Expand Up @@ -219,31 +219,31 @@ public static VoicemailErrorMessage create(
return new VoicemailErrorMessage(
context.getString(R.string.vvm3_error_subscriber_unknown_title),
getCustomerSupportString(context, R.string.vvm3_error_subscriber_unknown_message),
VoicemailErrorMessage.createCallVoicemailAction(context, status.getPhoneAccountHandle()),
VoicemailErrorMessage.createCallVoicemailAction(context),
createCallCustomerSupportAction(context));
}

if (IMAP_GETQUOTA_ERROR == status.dataChannelState) {
return new VoicemailErrorMessage(
context.getString(R.string.vvm3_error_imap_getquota_error_title),
getCustomerSupportString(context, R.string.vvm3_error_imap_getquota_error_message),
VoicemailErrorMessage.createCallVoicemailAction(context, status.getPhoneAccountHandle()),
VoicemailErrorMessage.createCallVoicemailAction(context),
createCallCustomerSupportAction(context));
}

if (IMAP_SELECT_ERROR == status.dataChannelState) {
return new VoicemailErrorMessage(
context.getString(R.string.vvm3_error_imap_select_error_title),
getCustomerSupportString(context, R.string.vvm3_error_imap_select_error_message),
VoicemailErrorMessage.createCallVoicemailAction(context, status.getPhoneAccountHandle()),
VoicemailErrorMessage.createCallVoicemailAction(context),
createCallCustomerSupportAction(context));
}

if (IMAP_ERROR == status.dataChannelState) {
return new VoicemailErrorMessage(
context.getString(R.string.vvm3_error_imap_error_title),
getCustomerSupportString(context, R.string.vvm3_error_imap_error_message),
VoicemailErrorMessage.createCallVoicemailAction(context, status.getPhoneAccountHandle()),
VoicemailErrorMessage.createCallVoicemailAction(context),
createCallCustomerSupportAction(context));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,6 @@
android:parentActivityName="com.android.dialer.app.settings.DialerSettingsActivity"
android:theme="@style/SettingsStyle"
android:windowSoftInputMode="stateVisible|adjustResize">
<intent-filter>
<action android:name="com.android.dialer.action.CHANGE_PIN"/>
<category android:name="android.intent.category.DEFAULT"/>
</intent-filter>
</activity>
<activity
android:name=".RecordVoicemailGreetingActivity"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ public class VoicemailChangePinActivity extends Activity
implements OnClickListener, OnEditorActionListener, TextWatcher {

private static final String TAG = "VmChangePinActivity";
public static final String ACTION_CHANGE_PIN = "com.android.dialer.action.CHANGE_PIN";

private static final int MESSAGE_HANDLE_RESULT = 1;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ private static void sendLegacyVoicemailNotification(
PreCall.getIntent(
context,
CallIntentBuilder.forVoicemail(
phoneAccountHandle, CallInitiationType.Type.LEGACY_VOICEMAIL_NOTIFICATION)),
CallInitiationType.Type.LEGACY_VOICEMAIL_NOTIFICATION)),
PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_IMMUTABLE);
} else {
Intent launchVoicemailSettingsIntent =
Expand Down
11 changes: 9 additions & 2 deletions java/com/android/voicemail/impl/sms/StatusSmsFetcher.java
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,12 @@ public class StatusSmsFetcher extends BroadcastReceiver implements Closeable {

private static final long STATUS_SMS_TIMEOUT_MILLIS = 60_000;

private static final String PERMISSION_DIALER_ORIGIN =
"com.android.dialer.permission.DIALER_ORIGIN";

private static final String ACTION_REQUEST_SENT_INTENT =
"com.android.voicemailomtp.sms.REQUEST_SENT";

private static final int ACTION_REQUEST_SENT_REQUEST_CODE = 0;

private CompletableFuture<Bundle> future = new CompletableFuture<>();
Expand All @@ -67,7 +71,7 @@ public StatusSmsFetcher(Context context, PhoneAccountHandle phoneAccountHandle)
this.phoneAccountHandle = phoneAccountHandle;
IntentFilter filter = new IntentFilter(ACTION_REQUEST_SENT_INTENT);
filter.addAction(OmtpService.ACTION_SMS_RECEIVED);
context.registerReceiver(this, filter);
context.registerReceiver(this, filter, PERMISSION_DIALER_ORIGIN, /* scheduler= */ null);
}

@Override
Expand All @@ -89,7 +93,10 @@ public PendingIntent getSentIntent() {
// Because the receiver is registered dynamically, implicit intent must be used.
// There should only be a single status SMS request at a time.
return PendingIntent.getBroadcast(
context, ACTION_REQUEST_SENT_REQUEST_CODE, intent, PendingIntent.FLAG_CANCEL_CURRENT);
context,
ACTION_REQUEST_SENT_REQUEST_CODE,
intent,
PendingIntent.FLAG_CANCEL_CURRENT | PendingIntent.FLAG_IMMUTABLE);
}

@Override
Expand Down

0 comments on commit f7ed8dd

Please sign in to comment.