summaryrefslogtreecommitdiff
path: root/java/com/android/dialer
diff options
context:
space:
mode:
authorTreehugger Robot <treehugger-gerrit@google.com>2017-11-12 00:55:34 +0000
committerGerrit Code Review <noreply-gerritcodereview@google.com>2017-11-12 00:55:34 +0000
commit2b52d2a3cdcb0ac00d87d2c2cbd1d6b750ea036d (patch)
treec87ae220455edeac1c6fb5b12e033e37a07c9ed4 /java/com/android/dialer
parent5e20ba7b1c6a9644da034b345000b37856d78125 (diff)
parentb7dba5aaa8c477d97121fc6e3411332e66cbabe8 (diff)
Merge changes I0ed4fa1b,Ie03ce41e,If41868df,Iba2e9092
* changes: Expose tab index to protected Added temporary logging to debug problem with null phone numbers from remote contacts. Hook up pre-call actions Implement CallingAccountSelector and AssistedDialAction
Diffstat (limited to 'java/com/android/dialer')
-rw-r--r--java/com/android/dialer/app/DialtactsActivity.java14
-rw-r--r--java/com/android/dialer/app/calllog/IntentProvider.java29
-rw-r--r--java/com/android/dialer/app/calllog/MissedCallNotifier.java6
-rw-r--r--java/com/android/dialer/app/voicemail/error/VoicemailErrorMessage.java7
-rw-r--r--java/com/android/dialer/assisteddialing/ConcreteCreator.java3
-rw-r--r--java/com/android/dialer/callcomposer/CallComposerActivity.java6
-rw-r--r--java/com/android/dialer/calldetails/CallDetailsActivity.java9
-rw-r--r--java/com/android/dialer/callintent/CallIntentBuilder.java5
-rw-r--r--java/com/android/dialer/calllog/ui/NewCallLogViewHolder.java2
-rw-r--r--java/com/android/dialer/calllog/ui/menu/PrimaryAction.java2
-rw-r--r--java/com/android/dialer/calllogutils/CallLogIntents.java16
-rw-r--r--java/com/android/dialer/contactactions/IntentModule.java17
-rw-r--r--java/com/android/dialer/dialpadview/DialpadFragment.java11
-rw-r--r--java/com/android/dialer/interactions/PhoneNumberInteraction.java12
-rw-r--r--java/com/android/dialer/precall/PreCall.java9
-rw-r--r--java/com/android/dialer/precall/PreCallCoordinator.java3
-rw-r--r--java/com/android/dialer/precall/impl/AssistedDialAction.java73
-rw-r--r--java/com/android/dialer/precall/impl/CallingAccountSelector.java114
-rw-r--r--java/com/android/dialer/precall/impl/PreCallCoordinatorImpl.java2
-rw-r--r--java/com/android/dialer/precall/impl/PreCallImpl.java5
-rw-r--r--java/com/android/dialer/precall/impl/res/values/strings.xml22
-rw-r--r--java/com/android/dialer/searchfragment/list/NewSearchFragment.java8
-rw-r--r--java/com/android/dialer/searchfragment/list/SearchActionViewHolder.java5
-rw-r--r--java/com/android/dialer/searchfragment/list/SearchAdapter.java36
-rw-r--r--java/com/android/dialer/searchfragment/nearbyplaces/NearbyPlaceViewHolder.java5
-rw-r--r--java/com/android/dialer/searchfragment/remote/RemoteContactViewHolder.java5
-rw-r--r--java/com/android/dialer/searchfragment/remote/RemoteDirectoriesCursorLoader.java17
27 files changed, 366 insertions, 77 deletions
diff --git a/java/com/android/dialer/app/DialtactsActivity.java b/java/com/android/dialer/app/DialtactsActivity.java
index 089ffd389..4c2634184 100644
--- a/java/com/android/dialer/app/DialtactsActivity.java
+++ b/java/com/android/dialer/app/DialtactsActivity.java
@@ -121,6 +121,7 @@ import com.android.dialer.p13n.logging.P13nLogger;
import com.android.dialer.p13n.logging.P13nLogging;
import com.android.dialer.performancereport.PerformanceReport;
import com.android.dialer.postcall.PostCall;
+import com.android.dialer.precall.PreCall;
import com.android.dialer.proguard.UsedByReflection;
import com.android.dialer.searchfragment.list.NewSearchFragment;
import com.android.dialer.searchfragment.list.NewSearchFragment.SearchFragmentListener;
@@ -1515,14 +1516,12 @@ public class DialtactsActivity extends TransactionSafeActivity
// an error message.
phoneNumber = "";
}
-
- Intent intent =
+ PreCall.start(
+ this,
new CallIntentBuilder(phoneNumber, callSpecificAppData)
.setIsVideoCall(isVideoCall)
- .setAllowAssistedDial(callSpecificAppData.getAllowAssistedDialing())
- .build();
+ .setAllowAssistedDial(callSpecificAppData.getAllowAssistedDialing()));
- DialerUtils.startActivityWithErrorToast(this, intent);
mClearSearchOnPause = true;
}
@@ -1555,6 +1554,7 @@ public class DialtactsActivity extends TransactionSafeActivity
if (tabIndex != mPreviouslySelectedTabIndex) {
mFloatingActionButtonController.scaleIn();
}
+ LogUtil.i("DialtactsActivity.onPageSelected", "tabIndex: %d", tabIndex);
mPreviouslySelectedTabIndex = tabIndex;
timeTabSelected = SystemClock.elapsedRealtime();
}
@@ -1676,6 +1676,10 @@ public class DialtactsActivity extends TransactionSafeActivity
exitSearchUi();
}
+ protected int getPreviouslySelectedTabIndex() {
+ return mPreviouslySelectedTabIndex;
+ }
+
/** Popup menu accessible from the search bar */
protected class OptionsPopupMenu extends PopupMenu {
diff --git a/java/com/android/dialer/app/calllog/IntentProvider.java b/java/com/android/dialer/app/calllog/IntentProvider.java
index 5180651da..0835d894c 100644
--- a/java/com/android/dialer/app/calllog/IntentProvider.java
+++ b/java/com/android/dialer/app/calllog/IntentProvider.java
@@ -32,6 +32,7 @@ import com.android.dialer.callintent.CallInitiationType;
import com.android.dialer.callintent.CallIntentBuilder;
import com.android.dialer.dialercontact.DialerContact;
import com.android.dialer.duo.DuoComponent;
+import com.android.dialer.precall.PreCall;
import com.android.dialer.util.IntentUtil;
import java.util.ArrayList;
@@ -53,9 +54,10 @@ public abstract class IntentProvider {
return new IntentProvider() {
@Override
public Intent getIntent(Context context) {
- return new CallIntentBuilder(number, CallInitiationType.Type.CALL_LOG)
- .setPhoneAccountHandle(accountHandle)
- .build();
+ return PreCall.getIntent(
+ context,
+ new CallIntentBuilder(number, CallInitiationType.Type.CALL_LOG)
+ .setPhoneAccountHandle(accountHandle));
}
};
}
@@ -65,9 +67,10 @@ public abstract class IntentProvider {
return new IntentProvider() {
@Override
public Intent getIntent(Context context) {
- return new CallIntentBuilder(number, CallInitiationType.Type.CALL_LOG)
- .setAllowAssistedDial(true)
- .build();
+ return PreCall.getIntent(
+ context,
+ new CallIntentBuilder(number, CallInitiationType.Type.CALL_LOG)
+ .setAllowAssistedDial(true));
}
};
}
@@ -81,10 +84,11 @@ public abstract class IntentProvider {
return new IntentProvider() {
@Override
public Intent getIntent(Context context) {
- return new CallIntentBuilder(number, CallInitiationType.Type.CALL_LOG)
- .setPhoneAccountHandle(accountHandle)
- .setIsVideoCall(true)
- .build();
+ return PreCall.getIntent(
+ context,
+ new CallIntentBuilder(number, CallInitiationType.Type.CALL_LOG)
+ .setPhoneAccountHandle(accountHandle)
+ .setIsVideoCall(true));
}
};
}
@@ -103,8 +107,9 @@ public abstract class IntentProvider {
return new IntentProvider() {
@Override
public Intent getIntent(Context context) {
- return CallIntentBuilder.forVoicemail(phoneAccountHandle, CallInitiationType.Type.CALL_LOG)
- .build();
+ return PreCall.getIntent(
+ context,
+ CallIntentBuilder.forVoicemail(phoneAccountHandle, CallInitiationType.Type.CALL_LOG));
}
};
}
diff --git a/java/com/android/dialer/app/calllog/MissedCallNotifier.java b/java/com/android/dialer/app/calllog/MissedCallNotifier.java
index 8e09cf8df..dd92bb4e2 100644
--- a/java/com/android/dialer/app/calllog/MissedCallNotifier.java
+++ b/java/com/android/dialer/app/calllog/MissedCallNotifier.java
@@ -60,6 +60,7 @@ import com.android.dialer.notification.NotificationChannelId;
import com.android.dialer.notification.NotificationManagerUtils;
import com.android.dialer.phonenumbercache.ContactInfo;
import com.android.dialer.phonenumberutil.PhoneNumberHelper;
+import com.android.dialer.precall.PreCall;
import com.android.dialer.util.DialerUtils;
import com.android.dialer.util.IntentUtil;
import java.util.Iterator;
@@ -438,8 +439,9 @@ public class MissedCallNotifier implements Worker<Pair<Integer, String>, Void> {
cancelSingleMissedCallNotification(context, callUri);
DialerUtils.startActivityWithErrorToast(
context,
- new CallIntentBuilder(number, CallInitiationType.Type.MISSED_CALL_NOTIFICATION)
- .build()
+ PreCall.getIntent(
+ context,
+ new CallIntentBuilder(number, CallInitiationType.Type.MISSED_CALL_NOTIFICATION))
.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK));
}
diff --git a/java/com/android/dialer/app/voicemail/error/VoicemailErrorMessage.java b/java/com/android/dialer/app/voicemail/error/VoicemailErrorMessage.java
index 7cc6cda45..be7dccda8 100644
--- a/java/com/android/dialer/app/voicemail/error/VoicemailErrorMessage.java
+++ b/java/com/android/dialer/app/voicemail/error/VoicemailErrorMessage.java
@@ -31,6 +31,7 @@ import com.android.dialer.common.Assert;
import com.android.dialer.common.PerAccountSharedPreferences;
import com.android.dialer.logging.DialerImpression;
import com.android.dialer.logging.Logger;
+import com.android.dialer.precall.PreCall;
import com.android.dialer.voicemail.settings.VoicemailChangePinActivity;
import com.android.voicemail.VoicemailClient;
import com.android.voicemail.VoicemailComponent;
@@ -165,10 +166,10 @@ public class VoicemailErrorMessage {
@Override
public void onClick(View v) {
Logger.get(context).logImpression(DialerImpression.Type.VVM_CALL_VOICEMAIL_CLICKED);
- context.startActivity(
+ PreCall.start(
+ context,
CallIntentBuilder.forVoicemail(
- phoneAccountHandle, CallInitiationType.Type.VOICEMAIL_ERROR_MESSAGE)
- .build());
+ phoneAccountHandle, CallInitiationType.Type.VOICEMAIL_ERROR_MESSAGE));
}
});
}
diff --git a/java/com/android/dialer/assisteddialing/ConcreteCreator.java b/java/com/android/dialer/assisteddialing/ConcreteCreator.java
index c3721a7a8..806764567 100644
--- a/java/com/android/dialer/assisteddialing/ConcreteCreator.java
+++ b/java/com/android/dialer/assisteddialing/ConcreteCreator.java
@@ -22,6 +22,7 @@ import android.os.Build;
import android.os.Build.VERSION_CODES;
import android.preference.PreferenceManager;
import android.support.annotation.NonNull;
+import android.support.annotation.VisibleForTesting;
import android.support.v4.os.UserManagerCompat;
import android.telephony.TelephonyManager;
import com.android.dialer.assisteddialing.ui.R;
@@ -41,7 +42,7 @@ public final class ConcreteCreator {
// Floor set at N due to use of Optional.
protected static final int BUILD_CODE_FLOOR = Build.VERSION_CODES.N;
// Ceiling set at O because this feature will ship as part of the framework in P.
- protected static final int BUILD_CODE_CEILING = Build.VERSION_CODES.O;
+ @VisibleForTesting public static final int BUILD_CODE_CEILING = Build.VERSION_CODES.O;
/**
* Creates a new AssistedDialingMediator
diff --git a/java/com/android/dialer/callcomposer/CallComposerActivity.java b/java/com/android/dialer/callcomposer/CallComposerActivity.java
index cd0c74124..0d47c7007 100644
--- a/java/com/android/dialer/callcomposer/CallComposerActivity.java
+++ b/java/com/android/dialer/callcomposer/CallComposerActivity.java
@@ -72,6 +72,7 @@ import com.android.dialer.enrichedcall.extensions.StateExtension;
import com.android.dialer.logging.DialerImpression;
import com.android.dialer.logging.Logger;
import com.android.dialer.multimedia.MultimediaData;
+import com.android.dialer.precall.PreCall;
import com.android.dialer.protos.ProtoParsers;
import com.android.dialer.storage.StorageComponent;
import com.android.dialer.telecom.TelecomUtil;
@@ -479,9 +480,8 @@ public class CallComposerActivity extends AppCompatActivity
}
private void placeTelecomCall() {
- TelecomUtil.placeCall(
- this,
- new CallIntentBuilder(contact.getNumber(), CallInitiationType.Type.CALL_COMPOSER).build());
+ PreCall.start(
+ this, new CallIntentBuilder(contact.getNumber(), CallInitiationType.Type.CALL_COMPOSER));
setResult(RESULT_OK);
finish();
}
diff --git a/java/com/android/dialer/calldetails/CallDetailsActivity.java b/java/com/android/dialer/calldetails/CallDetailsActivity.java
index 6ba31e624..7a117a3f1 100644
--- a/java/com/android/dialer/calldetails/CallDetailsActivity.java
+++ b/java/com/android/dialer/calldetails/CallDetailsActivity.java
@@ -50,8 +50,8 @@ import com.android.dialer.logging.Logger;
import com.android.dialer.logging.UiAction;
import com.android.dialer.performancereport.PerformanceReport;
import com.android.dialer.postcall.PostCall;
+import com.android.dialer.precall.PreCall;
import com.android.dialer.protos.ProtoParsers;
-import com.android.dialer.util.DialerUtils;
import java.util.Collections;
import java.util.List;
import java.util.Map;
@@ -209,11 +209,10 @@ public class CallDetailsActivity extends AppCompatActivity
@Override
public void placeImsVideoCall(String phoneNumber) {
Logger.get(this).logImpression(DialerImpression.Type.CALL_DETAILS_IMS_VIDEO_CALL_BACK);
- DialerUtils.startActivityWithErrorToast(
+ PreCall.start(
this,
new CallIntentBuilder(phoneNumber, CallInitiationType.Type.CALL_DETAILS)
- .setIsVideoCall(true)
- .build());
+ .setIsVideoCall(true));
}
@Override
@@ -244,7 +243,7 @@ public class CallDetailsActivity extends AppCompatActivity
callIntentBuilder.setAllowAssistedDial(true);
}
- DialerUtils.startActivityWithErrorToast(this, callIntentBuilder.build());
+ PreCall.start(this, callIntentBuilder);
}
@NonNull
diff --git a/java/com/android/dialer/callintent/CallIntentBuilder.java b/java/com/android/dialer/callintent/CallIntentBuilder.java
index aabeabdc8..ff490c296 100644
--- a/java/com/android/dialer/callintent/CallIntentBuilder.java
+++ b/java/com/android/dialer/callintent/CallIntentBuilder.java
@@ -172,6 +172,11 @@ public class CallIntentBuilder implements Parcelable {
return outgoingCallExtras;
}
+ /**
+ * @deprecated Use {@link com.android.dialer.precall.PreCall#getIntent(android.content.Context,
+ * CallIntentBuilder)} instead.
+ */
+ @Deprecated
public Intent build() {
Intent intent = new Intent(Intent.ACTION_CALL, uri);
diff --git a/java/com/android/dialer/calllog/ui/NewCallLogViewHolder.java b/java/com/android/dialer/calllog/ui/NewCallLogViewHolder.java
index 9ddb65df4..16147f604 100644
--- a/java/com/android/dialer/calllog/ui/NewCallLogViewHolder.java
+++ b/java/com/android/dialer/calllog/ui/NewCallLogViewHolder.java
@@ -138,7 +138,7 @@ final class NewCallLogViewHolder extends RecyclerView.ViewHolder {
private void setOnClickListenerForRow(CoalescedRow row) {
itemView.setOnClickListener(
(view) -> {
- Intent callbackIntent = CallLogIntents.getCallBackIntent(row);
+ Intent callbackIntent = CallLogIntents.getCallBackIntent(context, row);
if (callbackIntent != null) {
context.startActivity(callbackIntent);
}
diff --git a/java/com/android/dialer/calllog/ui/menu/PrimaryAction.java b/java/com/android/dialer/calllog/ui/menu/PrimaryAction.java
index 7077d0231..404c41787 100644
--- a/java/com/android/dialer/calllog/ui/menu/PrimaryAction.java
+++ b/java/com/android/dialer/calllog/ui/menu/PrimaryAction.java
@@ -42,7 +42,7 @@ final class PrimaryAction {
.build())
.setPrimaryText(CallLogEntryText.buildPrimaryText(context, row))
.setSecondaryText(CallLogEntryText.buildSecondaryTextForBottomSheet(context, row))
- .setIntent(CallLogIntents.getCallBackIntent(row))
+ .setIntent(CallLogIntents.getCallBackIntent(context, row))
.build();
}
}
diff --git a/java/com/android/dialer/calllogutils/CallLogIntents.java b/java/com/android/dialer/calllogutils/CallLogIntents.java
index 11308e607..b06fe6e93 100644
--- a/java/com/android/dialer/calllogutils/CallLogIntents.java
+++ b/java/com/android/dialer/calllogutils/CallLogIntents.java
@@ -15,6 +15,7 @@
*/
package com.android.dialer.calllogutils;
+import android.content.Context;
import android.content.Intent;
import android.provider.CallLog.Calls;
import android.support.annotation.Nullable;
@@ -22,6 +23,7 @@ import android.text.TextUtils;
import com.android.dialer.callintent.CallInitiationType;
import com.android.dialer.callintent.CallIntentBuilder;
import com.android.dialer.calllog.model.CoalescedRow;
+import com.android.dialer.precall.PreCall;
/** Provides intents related to call log entries. */
public final class CallLogIntents {
@@ -35,10 +37,9 @@ public final class CallLogIntents {
* @return null if the provided {@code row} doesn't have a number
*/
@Nullable
- public static Intent getCallBackIntent(CoalescedRow row) {
+ public static Intent getCallBackIntent(Context context, CoalescedRow row) {
// TODO(zachh): Do something with parsed values to make more dialable?
String originalNumber = row.number().getRawInput().getNumber();
-
// TODO(zachh): Make this more sophisticated, e.g. return null for non-dialable numbers?
if (TextUtils.isEmpty(originalNumber)) {
return null;
@@ -46,10 +47,11 @@ public final class CallLogIntents {
// TODO(zachh): More granular logging?
// TODO(zachh): Support assisted dialing.
- return new CallIntentBuilder(originalNumber, CallInitiationType.Type.CALL_LOG)
- .setPhoneAccountHandle(
- PhoneAccountUtils.getAccount(row.phoneAccountComponentName(), row.phoneAccountId()))
- .setIsVideoCall((row.features() & Calls.FEATURES_VIDEO) == Calls.FEATURES_VIDEO)
- .build();
+ return PreCall.getIntent(
+ context,
+ new CallIntentBuilder(originalNumber, CallInitiationType.Type.CALL_LOG)
+ .setPhoneAccountHandle(
+ PhoneAccountUtils.getAccount(row.phoneAccountComponentName(), row.phoneAccountId()))
+ .setIsVideoCall((row.features() & Calls.FEATURES_VIDEO) == Calls.FEATURES_VIDEO));
}
}
diff --git a/java/com/android/dialer/contactactions/IntentModule.java b/java/com/android/dialer/contactactions/IntentModule.java
index 5a4870cbe..57eb50a9b 100644
--- a/java/com/android/dialer/contactactions/IntentModule.java
+++ b/java/com/android/dialer/contactactions/IntentModule.java
@@ -24,6 +24,7 @@ import android.support.annotation.StringRes;
import android.telecom.PhoneAccountHandle;
import com.android.dialer.callintent.CallInitiationType.Type;
import com.android.dialer.callintent.CallIntentBuilder;
+import com.android.dialer.precall.PreCall;
/**
* {@link ContactActionModule} useful for making easy to build modules based on starting an intent.
@@ -66,9 +67,10 @@ public class IntentModule implements ContactActionModule {
// TODO(zachh): Support post-dial digits; consider using DialerPhoneNumber.
return new IntentModule(
context,
- new CallIntentBuilder(number, initiationType)
- .setPhoneAccountHandle(phoneAccountHandle)
- .build(),
+ PreCall.getIntent(
+ context,
+ new CallIntentBuilder(number, initiationType)
+ .setPhoneAccountHandle(phoneAccountHandle)),
R.string.call,
R.drawable.quantum_ic_call_white_24);
}
@@ -81,10 +83,11 @@ public class IntentModule implements ContactActionModule {
// TODO(zachh): Support post-dial digits; consider using DialerPhoneNumber.
return new IntentModule(
context,
- new CallIntentBuilder(number, initiationType)
- .setPhoneAccountHandle(phoneAccountHandle)
- .setIsVideoCall(true)
- .build(),
+ PreCall.getIntent(
+ context,
+ new CallIntentBuilder(number, initiationType)
+ .setPhoneAccountHandle(phoneAccountHandle)
+ .setIsVideoCall(true)),
R.string.video_call,
R.drawable.quantum_ic_videocam_white_24);
}
diff --git a/java/com/android/dialer/dialpadview/DialpadFragment.java b/java/com/android/dialer/dialpadview/DialpadFragment.java
index 659d120b1..e85b57e33 100644
--- a/java/com/android/dialer/dialpadview/DialpadFragment.java
+++ b/java/com/android/dialer/dialpadview/DialpadFragment.java
@@ -83,10 +83,10 @@ import com.android.dialer.location.GeoUtil;
import com.android.dialer.logging.UiAction;
import com.android.dialer.oem.MotorolaUtils;
import com.android.dialer.performancereport.PerformanceReport;
+import com.android.dialer.precall.PreCall;
import com.android.dialer.proguard.UsedByReflection;
import com.android.dialer.telecom.TelecomUtil;
import com.android.dialer.util.CallUtil;
-import com.android.dialer.util.DialerUtils;
import com.android.dialer.util.PermissionsUtil;
import com.android.dialer.widget.FloatingActionButtonController;
import java.util.HashSet;
@@ -997,9 +997,8 @@ public class DialpadFragment extends Fragment
}
public void callVoicemail() {
- DialerUtils.startActivityWithErrorToast(
- getActivity(),
- CallIntentBuilder.forVoicemail(null, CallInitiationType.Type.DIALPAD).build());
+ PreCall.start(
+ getContext(), CallIntentBuilder.forVoicemail(null, CallInitiationType.Type.DIALPAD));
hideAndClearDialpad();
}
@@ -1049,9 +1048,7 @@ public class DialpadFragment extends Fragment
// Clear the digits just in case.
clearDialpad();
} else {
- final Intent intent =
- new CallIntentBuilder(number, CallInitiationType.Type.DIALPAD).build();
- DialerUtils.startActivityWithErrorToast(getActivity(), intent);
+ PreCall.start(getContext(), new CallIntentBuilder(number, CallInitiationType.Type.DIALPAD));
hideAndClearDialpad();
}
}
diff --git a/java/com/android/dialer/interactions/PhoneNumberInteraction.java b/java/com/android/dialer/interactions/PhoneNumberInteraction.java
index 255f6c380..15c6ce899 100644
--- a/java/com/android/dialer/interactions/PhoneNumberInteraction.java
+++ b/java/com/android/dialer/interactions/PhoneNumberInteraction.java
@@ -60,6 +60,7 @@ import com.android.dialer.common.Assert;
import com.android.dialer.common.LogUtil;
import com.android.dialer.logging.InteractionEvent;
import com.android.dialer.logging.Logger;
+import com.android.dialer.precall.PreCall;
import com.android.dialer.util.DialerUtils;
import com.android.dialer.util.PermissionsUtil;
import com.android.dialer.util.TransactionSafeActivity;
@@ -183,10 +184,11 @@ public class PhoneNumberInteraction implements OnLoadCompleteListener<Cursor> {
break;
default:
intent =
- new CallIntentBuilder(phoneNumber, callSpecificAppData)
- .setIsVideoCall(isVideoCall)
- .setAllowAssistedDial(callSpecificAppData.getAllowAssistedDialing())
- .build();
+ PreCall.getIntent(
+ context,
+ new CallIntentBuilder(phoneNumber, callSpecificAppData)
+ .setIsVideoCall(isVideoCall)
+ .setAllowAssistedDial(callSpecificAppData.getAllowAssistedDialing()));
break;
}
DialerUtils.startActivityWithErrorToast(context, intent);
@@ -224,7 +226,7 @@ public class PhoneNumberInteraction implements OnLoadCompleteListener<Cursor> {
// crash when the user tries to use such a shortcut, check for this condition and ask the user
// for the permission.
if (!PermissionsUtil.hasPhonePermissions(mContext)) {
- LogUtil.i("PhoneNumberInteraction.startInteraction", "Need phone permissions: CALL_PHONE");
+ LogUtil.i("PhoneNumberInteraction.startInteraction", "Need phone permission: CALL_PHONE");
ActivityCompat.requestPermissions(
(Activity) mContext, new String[] {permission.CALL_PHONE}, REQUEST_CALL_PHONE);
return;
diff --git a/java/com/android/dialer/precall/PreCall.java b/java/com/android/dialer/precall/PreCall.java
index 93fd8e9b6..4f021f142 100644
--- a/java/com/android/dialer/precall/PreCall.java
+++ b/java/com/android/dialer/precall/PreCall.java
@@ -21,6 +21,7 @@ import android.content.Intent;
import android.support.annotation.MainThread;
import android.support.annotation.NonNull;
import com.android.dialer.callintent.CallIntentBuilder;
+import com.android.dialer.util.DialerUtils;
import com.google.common.collect.ImmutableList;
/** Interface to prepare a {@link CallIntentBuilder} before placing the call with telecom. */
@@ -41,4 +42,12 @@ public interface PreCall {
@NonNull
@MainThread
Intent buildIntent(Context context, CallIntentBuilder builder);
+
+ static Intent getIntent(Context context, CallIntentBuilder builder) {
+ return PreCallComponent.get(context).getPreCall().buildIntent(context, builder);
+ }
+
+ static void start(Context context, CallIntentBuilder builder) {
+ DialerUtils.startActivityWithErrorToast(context, getIntent(context, builder));
+ }
}
diff --git a/java/com/android/dialer/precall/PreCallCoordinator.java b/java/com/android/dialer/precall/PreCallCoordinator.java
index b5e9e8594..40b909a51 100644
--- a/java/com/android/dialer/precall/PreCallCoordinator.java
+++ b/java/com/android/dialer/precall/PreCallCoordinator.java
@@ -19,6 +19,7 @@ package com.android.dialer.precall;
import android.app.Activity;
import android.support.annotation.MainThread;
import android.support.annotation.NonNull;
+import android.support.annotation.VisibleForTesting;
import com.android.dialer.callintent.CallIntentBuilder;
/**
@@ -27,6 +28,8 @@ import com.android.dialer.callintent.CallIntentBuilder;
*/
public interface PreCallCoordinator {
+ @VisibleForTesting public String EXTRA_CALL_INTENT_BUILDER = "extra_call_intent_builder";
+
@NonNull
CallIntentBuilder getBuilder();
diff --git a/java/com/android/dialer/precall/impl/AssistedDialAction.java b/java/com/android/dialer/precall/impl/AssistedDialAction.java
new file mode 100644
index 000000000..edf97cce3
--- /dev/null
+++ b/java/com/android/dialer/precall/impl/AssistedDialAction.java
@@ -0,0 +1,73 @@
+/*
+ * Copyright (C) 2017 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.precall.impl;
+
+import android.annotation.TargetApi;
+import android.os.Build;
+import android.os.Bundle;
+import android.telecom.PhoneAccount;
+import android.telephony.TelephonyManager;
+import com.android.dialer.assisteddialing.AssistedDialingMediator;
+import com.android.dialer.assisteddialing.ConcreteCreator;
+import com.android.dialer.assisteddialing.TransformationInfo;
+import com.android.dialer.callintent.CallIntentBuilder;
+import com.android.dialer.common.Assert;
+import com.android.dialer.compat.telephony.TelephonyManagerCompat;
+import com.android.dialer.precall.PreCallAction;
+import com.android.dialer.precall.PreCallCoordinator;
+import com.android.dialer.util.CallUtil;
+import java.util.Optional;
+
+/** Rewrites the call URI with country code. TODO(erfanian): use phone account for multi SIM */
+public class AssistedDialAction implements PreCallAction {
+
+ @SuppressWarnings("AndroidApiChecker") // Use of optional
+ @TargetApi(Build.VERSION_CODES.N)
+ @Override
+ public void run(PreCallCoordinator coordinator) {
+ CallIntentBuilder builder = coordinator.getBuilder();
+ if (!builder.isAssistedDialAllowed()) {
+ return;
+ }
+ AssistedDialingMediator assistedDialingMediator =
+ ConcreteCreator.createNewAssistedDialingMediator(
+ coordinator.getActivity().getSystemService(TelephonyManager.class),
+ coordinator.getActivity());
+ if (!assistedDialingMediator.isPlatformEligible()) {
+ return;
+ }
+ builder.getOutgoingCallExtras().putBoolean(TelephonyManagerCompat.ALLOW_ASSISTED_DIAL, true);
+ String phoneNumber =
+ builder.getUri().getScheme().equals(PhoneAccount.SCHEME_TEL)
+ ? builder.getUri().getSchemeSpecificPart()
+ : "";
+ Optional<TransformationInfo> transformedNumber =
+ assistedDialingMediator.attemptAssistedDial(phoneNumber);
+ if (transformedNumber.isPresent()) {
+ Bundle assistedDialingExtras = transformedNumber.get().toBundle();
+ builder.getOutgoingCallExtras().putBoolean(TelephonyManagerCompat.IS_ASSISTED_DIALED, true);
+ builder
+ .getOutgoingCallExtras()
+ .putBundle(TelephonyManagerCompat.ASSISTED_DIALING_EXTRAS, assistedDialingExtras);
+ builder.setUri(
+ CallUtil.getCallUri(Assert.isNotNull(transformedNumber.get().transformedNumber())));
+ }
+ }
+
+ @Override
+ public void onDiscard() {}
+}
diff --git a/java/com/android/dialer/precall/impl/CallingAccountSelector.java b/java/com/android/dialer/precall/impl/CallingAccountSelector.java
new file mode 100644
index 000000000..ca8798c5d
--- /dev/null
+++ b/java/com/android/dialer/precall/impl/CallingAccountSelector.java
@@ -0,0 +1,114 @@
+/*
+ * Copyright (C) 2017 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.precall.impl;
+
+import android.app.Activity;
+import android.support.annotation.MainThread;
+import android.support.annotation.NonNull;
+import android.support.annotation.Nullable;
+import android.support.annotation.VisibleForTesting;
+import android.telecom.PhoneAccount;
+import android.telecom.PhoneAccountHandle;
+import android.telecom.TelecomManager;
+import com.android.contacts.common.widget.SelectPhoneAccountDialogFragment;
+import com.android.contacts.common.widget.SelectPhoneAccountDialogFragment.SelectPhoneAccountListener;
+import com.android.dialer.callintent.CallIntentBuilder;
+import com.android.dialer.common.Assert;
+import com.android.dialer.precall.PreCallAction;
+import com.android.dialer.precall.PreCallCoordinator;
+import java.util.List;
+
+/** PreCallAction to select which phone account to call with. Ignored if there's only one account */
+@SuppressWarnings("MissingPermission")
+public class CallingAccountSelector implements PreCallAction {
+
+ @VisibleForTesting static final String TAG_CALLING_ACCOUNT_SELECTOR = "CallingAccountSelector";
+
+ private SelectPhoneAccountDialogFragment selectPhoneAccountDialogFragment;
+
+ private boolean isDiscarding;
+
+ @Override
+ public void run(PreCallCoordinator coordinator) {
+ CallIntentBuilder builder = coordinator.getBuilder();
+ if (builder.getPhoneAccountHandle() != null) {
+ return;
+ }
+ Activity activity = coordinator.getActivity();
+ TelecomManager telecomManager = activity.getSystemService(TelecomManager.class);
+ List<PhoneAccountHandle> accounts = telecomManager.getCallCapablePhoneAccounts();
+ if (accounts.size() <= 1) {
+ return;
+ }
+ boolean isVoicemail = builder.getUri().getScheme().equals(PhoneAccount.SCHEME_VOICEMAIL);
+
+ if (!isVoicemail) {
+ PhoneAccountHandle defaultPhoneAccount =
+ telecomManager.getDefaultOutgoingPhoneAccount(builder.getUri().getScheme());
+ if (defaultPhoneAccount != null) {
+ builder.setPhoneAccountHandle(defaultPhoneAccount);
+ return;
+ }
+ }
+
+ selectPhoneAccountDialogFragment =
+ SelectPhoneAccountDialogFragment.newInstance(
+ R.string.pre_call_select_phone_account,
+ false /* canSetDefault */, // TODO(twyen): per contact defaults
+ accounts,
+ new SelectedListener(coordinator, coordinator.startPendingAction()),
+ null /* call ID */);
+ selectPhoneAccountDialogFragment.show(
+ activity.getFragmentManager(), TAG_CALLING_ACCOUNT_SELECTOR);
+ }
+
+ @Override
+ public void onDiscard() {
+ isDiscarding = true;
+ selectPhoneAccountDialogFragment.dismiss();
+ }
+
+ private class SelectedListener extends SelectPhoneAccountListener {
+
+ private final PreCallCoordinator coordinator;
+ private final PreCallCoordinator.PendingAction listener;
+
+ public SelectedListener(
+ @NonNull PreCallCoordinator builder, @NonNull PreCallCoordinator.PendingAction listener) {
+ this.coordinator = Assert.isNotNull(builder);
+ this.listener = Assert.isNotNull(listener);
+ }
+
+ @MainThread
+ @Override
+ public void onPhoneAccountSelected(
+ PhoneAccountHandle selectedAccountHandle, boolean setDefault, @Nullable String callId) {
+ coordinator.getBuilder().setPhoneAccountHandle(selectedAccountHandle);
+ listener.finish();
+ }
+
+ @MainThread
+ @Override
+ public void onDialogDismissed(@Nullable String callId) {
+ if (isDiscarding) {
+ return;
+ }
+ coordinator.abortCall();
+ listener.finish();
+ }
+ }
+}
diff --git a/java/com/android/dialer/precall/impl/PreCallCoordinatorImpl.java b/java/com/android/dialer/precall/impl/PreCallCoordinatorImpl.java
index 25083ef0b..6302a2395 100644
--- a/java/com/android/dialer/precall/impl/PreCallCoordinatorImpl.java
+++ b/java/com/android/dialer/precall/impl/PreCallCoordinatorImpl.java
@@ -38,8 +38,6 @@ public class PreCallCoordinatorImpl implements PreCallCoordinator {
private static final String SAVED_STATE_CURRENT_ACTION = "current_action";
- static final String EXTRA_CALL_INTENT_BUILDER = "extra_call_intent_builder";
-
@NonNull private final Activity activity;
private CallIntentBuilder builder;
diff --git a/java/com/android/dialer/precall/impl/PreCallImpl.java b/java/com/android/dialer/precall/impl/PreCallImpl.java
index ac9750ef2..21c5dc9e2 100644
--- a/java/com/android/dialer/precall/impl/PreCallImpl.java
+++ b/java/com/android/dialer/precall/impl/PreCallImpl.java
@@ -22,6 +22,7 @@ import android.support.annotation.NonNull;
import com.android.dialer.callintent.CallIntentBuilder;
import com.android.dialer.precall.PreCall;
import com.android.dialer.precall.PreCallAction;
+import com.android.dialer.precall.PreCallCoordinator;
import com.google.common.collect.ImmutableList;
import javax.inject.Inject;
@@ -33,14 +34,14 @@ public class PreCallImpl implements PreCall {
@Override
public ImmutableList<PreCallAction> getActions() {
- return ImmutableList.of();
+ return ImmutableList.of(new CallingAccountSelector(), new AssistedDialAction());
}
@NonNull
@Override
public Intent buildIntent(Context context, CallIntentBuilder builder) {
Intent intent = new Intent(context, PreCallActivity.class);
- intent.putExtra(PreCallCoordinatorImpl.EXTRA_CALL_INTENT_BUILDER, builder);
+ intent.putExtra(PreCallCoordinator.EXTRA_CALL_INTENT_BUILDER, builder);
return intent;
}
}
diff --git a/java/com/android/dialer/precall/impl/res/values/strings.xml b/java/com/android/dialer/precall/impl/res/values/strings.xml
new file mode 100644
index 000000000..894394662
--- /dev/null
+++ b/java/com/android/dialer/precall/impl/res/values/strings.xml
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ ~ Copyright (C) 2017 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
+ -->
+<resources>
+ <!-- Title of the dialog to select which SIM to call with before making a call, if the device has
+ multiple SIMs [CHAR LIMIT=40]-->
+ <string name="pre_call_select_phone_account">Call with</string>
+
+</resources> \ No newline at end of file
diff --git a/java/com/android/dialer/searchfragment/list/NewSearchFragment.java b/java/com/android/dialer/searchfragment/list/NewSearchFragment.java
index c0a6700eb..e797a0390 100644
--- a/java/com/android/dialer/searchfragment/list/NewSearchFragment.java
+++ b/java/com/android/dialer/searchfragment/list/NewSearchFragment.java
@@ -58,6 +58,7 @@ import com.android.dialer.enrichedcall.EnrichedCallComponent;
import com.android.dialer.enrichedcall.EnrichedCallManager.CapabilitiesListener;
import com.android.dialer.logging.DialerImpression;
import com.android.dialer.logging.Logger;
+import com.android.dialer.precall.PreCall;
import com.android.dialer.searchfragment.common.RowClickListener;
import com.android.dialer.searchfragment.common.SearchCursor;
import com.android.dialer.searchfragment.cp2.SearchContactsCursorLoader;
@@ -483,12 +484,11 @@ public final class NewSearchFragment extends Fragment
.setCharactersInSearchString(query == null ? 0 : query.length())
.setAllowAssistedDialing(allowAssistedDial)
.build();
- Intent intent =
+ PreCall.start(
+ getContext(),
new CallIntentBuilder(phoneNumber, callSpecificAppData)
.setIsVideoCall(isVideoCall)
- .setAllowAssistedDial(allowAssistedDial)
- .build();
- DialerUtils.startActivityWithErrorToast(getActivity(), intent);
+ .setAllowAssistedDial(allowAssistedDial));
FragmentUtils.getParentUnsafe(this, SearchFragmentListener.class).onCallPlaced();
}
diff --git a/java/com/android/dialer/searchfragment/list/SearchActionViewHolder.java b/java/com/android/dialer/searchfragment/list/SearchActionViewHolder.java
index 62e5c72b0..b557a8259 100644
--- a/java/com/android/dialer/searchfragment/list/SearchActionViewHolder.java
+++ b/java/com/android/dialer/searchfragment/list/SearchActionViewHolder.java
@@ -31,6 +31,7 @@ import com.android.dialer.callintent.CallSpecificAppData;
import com.android.dialer.common.Assert;
import com.android.dialer.logging.DialerImpression;
import com.android.dialer.logging.Logger;
+import com.android.dialer.precall.PreCall;
import com.android.dialer.util.DialerUtils;
import com.android.dialer.util.IntentUtil;
import java.lang.annotation.Retention;
@@ -128,8 +129,8 @@ final class SearchActionViewHolder extends RecyclerView.ViewHolder implements On
.setPositionOfSelectedSearchResult(position)
.setCharactersInSearchString(query.length())
.build();
- intent = new CallIntentBuilder(query, callSpecificAppData).setIsVideoCall(true).build();
- DialerUtils.startActivityWithErrorToast(context, intent);
+ PreCall.start(
+ context, new CallIntentBuilder(query, callSpecificAppData).setIsVideoCall(true));
break;
case Action.SEND_SMS:
diff --git a/java/com/android/dialer/searchfragment/list/SearchAdapter.java b/java/com/android/dialer/searchfragment/list/SearchAdapter.java
index dc78953b5..cc090ac47 100644
--- a/java/com/android/dialer/searchfragment/list/SearchAdapter.java
+++ b/java/com/android/dialer/searchfragment/list/SearchAdapter.java
@@ -17,6 +17,7 @@
package com.android.dialer.searchfragment.list;
import android.content.Context;
+import android.database.Cursor;
import android.support.annotation.VisibleForTesting;
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.RecyclerView.ViewHolder;
@@ -26,12 +27,15 @@ import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import com.android.dialer.common.Assert;
+import com.android.dialer.common.LogUtil;
+import com.android.dialer.searchfragment.common.Projections;
import com.android.dialer.searchfragment.common.RowClickListener;
import com.android.dialer.searchfragment.common.SearchCursor;
import com.android.dialer.searchfragment.cp2.SearchContactViewHolder;
import com.android.dialer.searchfragment.list.SearchCursorManager.RowType;
import com.android.dialer.searchfragment.nearbyplaces.NearbyPlaceViewHolder;
import com.android.dialer.searchfragment.remote.RemoteContactViewHolder;
+import com.android.dialer.searchfragment.remote.RemoteDirectoriesCursorLoader;
import java.util.List;
/** RecyclerView adapter for {@link NewSearchFragment}. */
@@ -99,6 +103,23 @@ public final class SearchAdapter extends RecyclerView.Adapter<ViewHolder> {
} else if (holder instanceof NearbyPlaceViewHolder) {
((NearbyPlaceViewHolder) holder).bind(searchCursorManager.getCursor(position), query);
} else if (holder instanceof RemoteContactViewHolder) {
+ Cursor cursor = searchCursorManager.getCursor(position);
+ // Temporary logging to identify cause of a bug:
+ if (cursor.getString(Projections.PHONE_NUMBER) == null) {
+ LogUtil.e(
+ "SearchAdapter.onBindViewHolder", "cursor class: %s", cursor.getClass().getName());
+ LogUtil.e("SearchAdapter.onBindViewHolder", "position: %d", position);
+ LogUtil.e(
+ "SearchAdapter.onBindViewHolder",
+ "query length: %s",
+ query == null ? "null" : query.length());
+ logDirectories();
+ LogUtil.e(
+ "SearchAdapter.onBindViewHolder",
+ "directory id: %d",
+ ((SearchCursor) cursor).getDirectoryId());
+ throw new IllegalStateException("Null phone number reading remote contact");
+ }
((RemoteContactViewHolder) holder).bind(searchCursorManager.getCursor(position), query);
} else if (holder instanceof HeaderViewHolder) {
String header =
@@ -114,6 +135,21 @@ public final class SearchAdapter extends RecyclerView.Adapter<ViewHolder> {
}
}
+ private void logDirectories() {
+ try (Cursor directories = new RemoteDirectoriesCursorLoader(context).loadInBackground()) {
+ if (directories.moveToFirst()) {
+ do {
+ LogUtil.e(
+ "SearchAdapter.logDirectories",
+ "directory: %s",
+ RemoteDirectoriesCursorLoader.readDirectory(directories));
+ } while (directories.moveToNext());
+ } else {
+ LogUtil.e("SearchAdapter.logDirectories", "no directories found");
+ }
+ }
+ }
+
public void setContactsCursor(SearchCursor cursor) {
if (searchCursorManager.setContactsCursor(cursor)) {
// Since this is a new contacts cursor, we need to reapply the filter.
diff --git a/java/com/android/dialer/searchfragment/nearbyplaces/NearbyPlaceViewHolder.java b/java/com/android/dialer/searchfragment/nearbyplaces/NearbyPlaceViewHolder.java
index 2e1fd5e9d..f15b236dd 100644
--- a/java/com/android/dialer/searchfragment/nearbyplaces/NearbyPlaceViewHolder.java
+++ b/java/com/android/dialer/searchfragment/nearbyplaces/NearbyPlaceViewHolder.java
@@ -29,11 +29,11 @@ import com.android.dialer.callintent.CallInitiationType;
import com.android.dialer.callintent.CallIntentBuilder;
import com.android.dialer.contactphoto.ContactPhotoManager;
import com.android.dialer.lettertile.LetterTileDrawable;
+import com.android.dialer.precall.PreCall;
import com.android.dialer.searchfragment.common.Projections;
import com.android.dialer.searchfragment.common.QueryBoldingUtil;
import com.android.dialer.searchfragment.common.R;
import com.android.dialer.searchfragment.common.SearchCursor;
-import com.android.dialer.telecom.TelecomUtil;
/** ViewHolder for a nearby place row. */
public final class NearbyPlaceViewHolder extends RecyclerView.ViewHolder
@@ -93,7 +93,6 @@ public final class NearbyPlaceViewHolder extends RecyclerView.ViewHolder
@Override
public void onClick(View v) {
- TelecomUtil.placeCall(
- context, new CallIntentBuilder(number, CallInitiationType.Type.REGULAR_SEARCH).build());
+ PreCall.start(context, new CallIntentBuilder(number, CallInitiationType.Type.REGULAR_SEARCH));
}
}
diff --git a/java/com/android/dialer/searchfragment/remote/RemoteContactViewHolder.java b/java/com/android/dialer/searchfragment/remote/RemoteContactViewHolder.java
index 339855fbb..9d369003d 100644
--- a/java/com/android/dialer/searchfragment/remote/RemoteContactViewHolder.java
+++ b/java/com/android/dialer/searchfragment/remote/RemoteContactViewHolder.java
@@ -32,11 +32,11 @@ import com.android.dialer.callintent.CallInitiationType;
import com.android.dialer.callintent.CallIntentBuilder;
import com.android.dialer.contactphoto.ContactPhotoManager;
import com.android.dialer.lettertile.LetterTileDrawable;
+import com.android.dialer.precall.PreCall;
import com.android.dialer.searchfragment.common.Projections;
import com.android.dialer.searchfragment.common.QueryBoldingUtil;
import com.android.dialer.searchfragment.common.R;
import com.android.dialer.searchfragment.common.SearchCursor;
-import com.android.dialer.telecom.TelecomUtil;
/** ViewHolder for a nearby place row. */
public final class RemoteContactViewHolder extends RecyclerView.ViewHolder
@@ -132,7 +132,6 @@ public final class RemoteContactViewHolder extends RecyclerView.ViewHolder
@Override
public void onClick(View v) {
- TelecomUtil.placeCall(
- context, new CallIntentBuilder(number, CallInitiationType.Type.REGULAR_SEARCH).build());
+ PreCall.start(context, new CallIntentBuilder(number, CallInitiationType.Type.REGULAR_SEARCH));
}
}
diff --git a/java/com/android/dialer/searchfragment/remote/RemoteDirectoriesCursorLoader.java b/java/com/android/dialer/searchfragment/remote/RemoteDirectoriesCursorLoader.java
index de71025cd..3d16c4351 100644
--- a/java/com/android/dialer/searchfragment/remote/RemoteDirectoriesCursorLoader.java
+++ b/java/com/android/dialer/searchfragment/remote/RemoteDirectoriesCursorLoader.java
@@ -36,12 +36,14 @@ public final class RemoteDirectoriesCursorLoader extends CursorLoader {
private static final int DISPLAY_NAME = 1;
private static final int PHOTO_SUPPORT = 2;
+ private static final int AUTHORITY = 3;
@VisibleForTesting
static final String[] PROJECTION = {
ContactsContract.Directory._ID,
ContactsContract.Directory.DISPLAY_NAME,
ContactsContract.Directory.PHOTO_SUPPORT,
+ ContactsContract.Directory.DIRECTORY_AUTHORITY,
};
public RemoteDirectoriesCursorLoader(Context context) {
@@ -51,7 +53,10 @@ public final class RemoteDirectoriesCursorLoader extends CursorLoader {
/** @return current cursor row represented as a {@link Directory}. */
public static Directory readDirectory(Cursor cursor) {
return Directory.create(
- cursor.getInt(ID), cursor.getString(DISPLAY_NAME), cursor.getInt(PHOTO_SUPPORT) != 0);
+ cursor.getInt(ID),
+ cursor.getString(DISPLAY_NAME),
+ cursor.getInt(PHOTO_SUPPORT) != 0,
+ cursor.getString(AUTHORITY));
}
private static Uri getContentUri() {
@@ -63,8 +68,14 @@ public final class RemoteDirectoriesCursorLoader extends CursorLoader {
/** POJO representing the results returned from {@link RemoteDirectoriesCursorLoader}. */
@AutoValue
public abstract static class Directory {
+ public static Directory create(
+ int id, @Nullable String displayName, boolean supportsPhotos, @Nullable String authority) {
+ return new AutoValue_RemoteDirectoriesCursorLoader_Directory(
+ id, displayName, supportsPhotos, authority);
+ }
+
public static Directory create(int id, @Nullable String displayName, boolean supportsPhotos) {
- return new AutoValue_RemoteDirectoriesCursorLoader_Directory(id, displayName, supportsPhotos);
+ return create(id, displayName, supportsPhotos, null);
}
public abstract int getId();
@@ -73,5 +84,7 @@ public final class RemoteDirectoriesCursorLoader extends CursorLoader {
abstract @Nullable String getDisplayName();
abstract boolean supportsPhotos();
+
+ abstract @Nullable String authority();
}
}