[automerger skipped] Remove PhoneAccountHandle when building the intent to call Voicemail. am: ccb08c6030 am: f12f761886 am: 4b2716ba5f am: 303d842706 am: dbb013816a am: ca7dc68ca8 am: ed052391df am: cc9bd0d058 am: e0d3d4c25c -s ours
am skip reason: Merged-In If4463a24af2feb23d033190236e314b535d10fd6 with SHA-1 360d2eb8d9 is already in history
Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/apps/Dialer/+/16199291
Change-Id: If24a263fce7a63377dd88c233bf4e89df161c53b
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index 723cecf..f48c425 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -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-->
diff --git a/java/com/android/contacts/common/model/ContactLoader.java b/java/com/android/contacts/common/model/ContactLoader.java
index 12cca4f..a3a3b9d 100644
--- a/java/com/android/contacts/common/model/ContactLoader.java
+++ b/java/com/android/contacts/common/model/ContactLoader.java
@@ -39,6 +39,7 @@
import com.android.contacts.common.GroupMetaData;
import com.android.contacts.common.model.account.AccountType;
import com.android.contacts.common.model.account.AccountTypeWithDataSet;
+import com.android.contacts.common.model.account.GoogleAccountType;
import com.android.contacts.common.model.dataitem.DataItem;
import com.android.contacts.common.model.dataitem.PhoneDataItem;
import com.android.contacts.common.model.dataitem.PhotoDataItem;
@@ -727,6 +728,10 @@
final String servicePackageName = accountType.getViewContactNotifyServicePackageName();
if (!TextUtils.isEmpty(serviceName) && !TextUtils.isEmpty(servicePackageName)) {
final Uri uri = ContentUris.withAppendedId(RawContacts.CONTENT_URI, rawContactId);
+ if (accountType instanceof GoogleAccountType) {
+ ((GoogleAccountType) accountType).handleRawContactViewed(context, uri);
+ continue;
+ }
final Intent intent = new Intent();
intent.setClassName(servicePackageName, serviceName);
intent.setAction(Intent.ACTION_VIEW);
diff --git a/java/com/android/contacts/common/model/account/GoogleAccountType.java b/java/com/android/contacts/common/model/account/GoogleAccountType.java
index a25544b..e10ade4 100644
--- a/java/com/android/contacts/common/model/account/GoogleAccountType.java
+++ b/java/com/android/contacts/common/model/account/GoogleAccountType.java
@@ -18,6 +18,8 @@
import android.content.ContentValues;
import android.content.Context;
+import android.content.Intent;
+import android.net.Uri;
import android.provider.ContactsContract.CommonDataKinds.Email;
import android.provider.ContactsContract.CommonDataKinds.Event;
import android.provider.ContactsContract.CommonDataKinds.Phone;
@@ -196,11 +198,28 @@
@Override
public String getViewContactNotifyServiceClassName() {
- return "com.google.android.syncadapters.contacts." + "SyncHighResPhotoIntentService";
+ return PLUS_EXTENSION_PACKAGE_NAME + ".people.sync.focus.SyncHighResPhotoIntentOperation";
}
@Override
public String getViewContactNotifyServicePackageName() {
- return "com.google.android.syncadapters.contacts";
+ return PLUS_EXTENSION_PACKAGE_NAME;
+ }
+
+ /**
+ * Sends a broadcast to the sync adapter to trigger a high res photo sync for the contact which
+ * was viewed
+ * @param context context to send broadcast in
+ * @param rawContactUri Uri of the raw contact viewed
+ */
+ public void handleRawContactViewed(Context context, Uri rawContactUri) {
+ final Intent intent = new Intent();
+ intent.setData(rawContactUri);
+ // New broadcast for syncing high res photo.
+ intent.setPackage(GoogleAccountType.PLUS_EXTENSION_PACKAGE_NAME);
+ intent.setAction(
+ "com.google.android.gms.people.sync.focus.SYNC_HIGH_RES_PHOTO");
+
+ context.sendBroadcast(intent);
}
}
diff --git a/java/com/android/dialer/app/calllog/LegacyVoicemailNotifier.java b/java/com/android/dialer/app/calllog/LegacyVoicemailNotifier.java
index 31e9edc..62ae748 100644
--- a/java/com/android/dialer/app/calllog/LegacyVoicemailNotifier.java
+++ b/java/com/android/dialer/app/calllog/LegacyVoicemailNotifier.java
@@ -181,6 +181,7 @@
if (context.getSystemService(TelephonyManager.class).getPhoneCount() <= 1) {
return NOTIFICATION_TAG;
}
+
return NOTIFICATION_TAG_PREFIX + phoneAccountHandle.getId();
}
diff --git a/java/com/android/dialer/commandline/impl/CallCommand.java b/java/com/android/dialer/commandline/impl/CallCommand.java
index b3ea860..d0008a3 100644
--- a/java/com/android/dialer/commandline/impl/CallCommand.java
+++ b/java/com/android/dialer/commandline/impl/CallCommand.java
@@ -19,8 +19,6 @@
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,12 +65,10 @@
}
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 =
- CallIntentBuilder.forVoicemail(phoneAccountHandle, CallInitiationType.Type.DIALPAD);
+ CallIntentBuilder.forVoicemail(CallInitiationType.Type.DIALPAD);
} else {
callIntentBuilder = new CallIntentBuilder(number, CallInitiationType.Type.DIALPAD);
}
diff --git a/java/com/android/dialer/contacts/hiresphoto/HighResolutionPhotoRequesterImpl.java b/java/com/android/dialer/contacts/hiresphoto/HighResolutionPhotoRequesterImpl.java
index 9201604..0c14613 100644
--- a/java/com/android/dialer/contacts/hiresphoto/HighResolutionPhotoRequesterImpl.java
+++ b/java/com/android/dialer/contacts/hiresphoto/HighResolutionPhotoRequesterImpl.java
@@ -51,8 +51,8 @@
@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 @@
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 @@
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/voicemail/listui/error/VoicemailErrorMessage.java b/java/com/android/dialer/voicemail/listui/error/VoicemailErrorMessage.java
index 9accc32..e22f306 100644
--- a/java/com/android/dialer/voicemail/listui/error/VoicemailErrorMessage.java
+++ b/java/com/android/dialer/voicemail/listui/error/VoicemailErrorMessage.java
@@ -150,7 +150,7 @@
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);
}
diff --git a/java/com/android/dialer/voicemail/settings/AndroidManifest.xml b/java/com/android/dialer/voicemail/settings/AndroidManifest.xml
index 8506ddd..f25858e 100644
--- a/java/com/android/dialer/voicemail/settings/AndroidManifest.xml
+++ b/java/com/android/dialer/voicemail/settings/AndroidManifest.xml
@@ -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"
diff --git a/java/com/android/dialer/voicemail/settings/VoicemailChangePinActivity.java b/java/com/android/dialer/voicemail/settings/VoicemailChangePinActivity.java
index 4e22fb3..ebebdf7 100644
--- a/java/com/android/dialer/voicemail/settings/VoicemailChangePinActivity.java
+++ b/java/com/android/dialer/voicemail/settings/VoicemailChangePinActivity.java
@@ -67,7 +67,6 @@
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;
diff --git a/java/com/android/voicemail/impl/sms/StatusSmsFetcher.java b/java/com/android/voicemail/impl/sms/StatusSmsFetcher.java
index 7ddf646..dd945e9 100644
--- a/java/com/android/voicemail/impl/sms/StatusSmsFetcher.java
+++ b/java/com/android/voicemail/impl/sms/StatusSmsFetcher.java
@@ -53,8 +53,12 @@
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<>();
@@ -67,7 +71,7 @@
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
@@ -89,7 +93,10 @@
// 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