From 4f02639a38aa0fe522cfeb4c316d5bdffdeca7cd Mon Sep 17 00:00:00 2001 From: roldenburg Date: Fri, 13 Oct 2017 18:42:20 -0700 Subject: Rename Lightbringer to Duo Now that our Duo integration is public, we no longer need a code name. To avoid any disruption, logging and config related names were not changed. Bug: 63753964 Test: manual, existing tests PiperOrigin-RevId: 172172738 Change-Id: Ib9d3d80761944d850c8c4886def9fef9a28539a4 --- .../contacts/common/list/ContactListItemView.java | 8 +- .../common/list/PhoneNumberListAdapter.java | 8 +- .../common/list/PhoneNumberPickerFragment.java | 9 +- .../android/dialer/app/calllog/CallLogAdapter.java | 33 ++-- .../app/calllog/CallLogListItemViewHolder.java | 42 ++--- .../android/dialer/app/calllog/IntentProvider.java | 6 +- .../dialer/app/list/PhoneFavoritesTileAdapter.java | 8 +- .../binary/aosp/AospDialerRootComponent.java | 4 +- .../basecomponent/BaseDialerRootComponent.java | 4 +- .../google/GoogleStubDialerRootComponent.java | 4 +- .../dialer/calldetails/CallDetailsActivity.java | 13 +- .../dialer/calldetails/CallDetailsAdapter.java | 8 +- .../calldetails/CallDetailsEntryViewHolder.java | 4 +- .../calldetails/CallDetailsHeaderViewHolder.java | 10 +- .../calldetails/proto/call_details_entries.proto | 2 +- .../dialer/calllogutils/CallTypeHelper.java | 34 ++-- .../dialer/calllogutils/CallbackActionHelper.java | 28 ++- .../dialer/constants/ActivityRequestCodes.java | 9 +- java/com/android/dialer/duo/Duo.java | 92 ++++++++++ java/com/android/dialer/duo/DuoComponent.java | 41 +++++ java/com/android/dialer/duo/DuoListener.java | 21 +++ java/com/android/dialer/duo/stub/DuoStub.java | 127 ++++++++++++++ .../com/android/dialer/duo/stub/StubDuoModule.java | 30 ++++ .../android/dialer/lightbringer/Lightbringer.java | 92 ---------- .../dialer/lightbringer/LightbringerComponent.java | 41 ----- .../dialer/lightbringer/LightbringerListener.java | 21 --- .../dialer/lightbringer/stub/LightbringerStub.java | 127 -------------- .../lightbringer/stub/StubLightbringerModule.java | 30 ---- .../cp2/SearchContactViewHolder.java | 4 +- .../dialer/searchfragment/list/SearchAdapter.java | 7 +- java/com/android/incallui/call/DialerCall.java | 11 +- .../incallui/videotech/duo/DuoVideoTech.java | 195 +++++++++++++++++++++ .../videotech/lightbringer/LightbringerTech.java | 195 --------------------- 33 files changed, 625 insertions(+), 643 deletions(-) create mode 100644 java/com/android/dialer/duo/Duo.java create mode 100644 java/com/android/dialer/duo/DuoComponent.java create mode 100644 java/com/android/dialer/duo/DuoListener.java create mode 100644 java/com/android/dialer/duo/stub/DuoStub.java create mode 100644 java/com/android/dialer/duo/stub/StubDuoModule.java delete mode 100644 java/com/android/dialer/lightbringer/Lightbringer.java delete mode 100644 java/com/android/dialer/lightbringer/LightbringerComponent.java delete mode 100644 java/com/android/dialer/lightbringer/LightbringerListener.java delete mode 100644 java/com/android/dialer/lightbringer/stub/LightbringerStub.java delete mode 100644 java/com/android/dialer/lightbringer/stub/StubLightbringerModule.java create mode 100644 java/com/android/incallui/videotech/duo/DuoVideoTech.java delete mode 100644 java/com/android/incallui/videotech/lightbringer/LightbringerTech.java (limited to 'java') diff --git a/java/com/android/contacts/common/list/ContactListItemView.java b/java/com/android/contacts/common/list/ContactListItemView.java index c605f4e87..0a5bf094b 100644 --- a/java/com/android/contacts/common/list/ContactListItemView.java +++ b/java/com/android/contacts/common/list/ContactListItemView.java @@ -81,12 +81,12 @@ public class ContactListItemView extends ViewGroup implements SelectionBoundsAdj /** IntDef for indices of ViewPager tabs. */ @Retention(RetentionPolicy.SOURCE) - @IntDef({NONE, VIDEO, LIGHTBRINGER, CALL_AND_SHARE}) + @IntDef({NONE, VIDEO, DUO, CALL_AND_SHARE}) public @interface CallToAction {} public static final int NONE = 0; public static final int VIDEO = 1; - public static final int LIGHTBRINGER = 2; + public static final int DUO = 2; public static final int CALL_AND_SHARE = 3; private final PhotoPosition mPhotoPosition = getDefaultPhotoPosition(); @@ -341,13 +341,13 @@ public class ContactListItemView extends ViewGroup implements SelectionBoundsAdj drawable.setAutoMirrored(true); description = R.string.description_search_video_call; onClickListener = v -> listener.onVideoCallIconClicked(position); - } else if (action == LIGHTBRINGER) { + } else if (action == DUO) { CallIntentBuilder.increaseLightbringerCallButtonAppearInSearchCount(); drawable = ContextCompat.getDrawable(getContext(), R.drawable.quantum_ic_videocam_vd_theme_24); drawable.setAutoMirrored(true); description = R.string.description_search_video_call; - onClickListener = v -> listener.onLightbringerIconClicked(position); + onClickListener = v -> listener.onDuoVideoIconClicked(position); } else { mCallToActionView.setVisibility(View.GONE); mCallToActionView.setOnClickListener(null); diff --git a/java/com/android/contacts/common/list/PhoneNumberListAdapter.java b/java/com/android/contacts/common/list/PhoneNumberListAdapter.java index 8cf54b96c..58628d2a3 100644 --- a/java/com/android/contacts/common/list/PhoneNumberListAdapter.java +++ b/java/com/android/contacts/common/list/PhoneNumberListAdapter.java @@ -45,11 +45,11 @@ import com.android.dialer.compat.CompatUtils; import com.android.dialer.configprovider.ConfigProviderBindings; import com.android.dialer.contactphoto.ContactPhotoManager.DefaultImageRequest; import com.android.dialer.dialercontact.DialerContact; +import com.android.dialer.duo.DuoComponent; import com.android.dialer.enrichedcall.EnrichedCallCapabilities; import com.android.dialer.enrichedcall.EnrichedCallComponent; import com.android.dialer.enrichedcall.EnrichedCallManager; import com.android.dialer.lettertile.LetterTileDrawable; -import com.android.dialer.lightbringer.LightbringerComponent; import com.android.dialer.phonenumberutil.PhoneNumberHelper; import com.android.dialer.util.CallUtil; import java.util.ArrayList; @@ -405,8 +405,8 @@ public class PhoneNumberListAdapter extends ContactEntryListAdapter { } if (action == ContactListItemView.NONE - && LightbringerComponent.get(mContext).getLightbringer().isReachable(mContext, number)) { - action = ContactListItemView.LIGHTBRINGER; + && DuoComponent.get(mContext).getDuo().isReachable(mContext, number)) { + action = ContactListItemView.DUO; } if (action == ContactListItemView.NONE) { @@ -576,7 +576,7 @@ public class PhoneNumberListAdapter extends ContactEntryListAdapter { void onVideoCallIconClicked(int position); - void onLightbringerIconClicked(int position); + void onDuoVideoIconClicked(int position); void onCallAndShareIconClicked(int position); } diff --git a/java/com/android/contacts/common/list/PhoneNumberPickerFragment.java b/java/com/android/contacts/common/list/PhoneNumberPickerFragment.java index d704e5492..1a3b80f31 100644 --- a/java/com/android/contacts/common/list/PhoneNumberPickerFragment.java +++ b/java/com/android/contacts/common/list/PhoneNumberPickerFragment.java @@ -37,9 +37,9 @@ import com.android.dialer.callintent.CallSpecificAppData; import com.android.dialer.common.Assert; import com.android.dialer.common.LogUtil; import com.android.dialer.dialercontact.DialerContact; +import com.android.dialer.duo.DuoComponent; import com.android.dialer.enrichedcall.EnrichedCallComponent; import com.android.dialer.enrichedcall.EnrichedCallManager; -import com.android.dialer.lightbringer.LightbringerComponent; import com.android.dialer.logging.DialerImpression; import com.android.dialer.logging.Logger; import com.android.dialer.performancereport.PerformanceReport; @@ -91,13 +91,10 @@ public class PhoneNumberPickerFragment extends ContactEntryListFragment loadDataTask = new AsyncTask() { @Override @@ -982,12 +981,12 @@ public class CallLogAdapter extends GroupingListAdapter .setFeatures(cursor.getInt(CallLogQuery.FEATURES)); String phoneAccountComponentName = cursor.getString(CallLogQuery.ACCOUNT_COMPONENT_NAME); - if (getLightbringer().getPhoneAccountComponentName() != null - && getLightbringer() + if (getDuo().getPhoneAccountComponentName() != null + && getDuo() .getPhoneAccountComponentName() .flattenToString() .equals(phoneAccountComponentName)) { - entry.setIsLightbringerCall(true); + entry.setIsDuoCall(true); } entries.addEntries(entry.build()); @@ -1405,12 +1404,12 @@ public class CallLogAdapter extends GroupingListAdapter } @NonNull - private Lightbringer getLightbringer() { - return LightbringerComponent.get(mActivity).getLightbringer(); + private Duo getDuo() { + return DuoComponent.get(mActivity).getDuo(); } @Override - public void onLightbringerStateChanged() { + public void onDuoStateChanged() { notifyDataSetChanged(); } diff --git a/java/com/android/dialer/app/calllog/CallLogListItemViewHolder.java b/java/com/android/dialer/app/calllog/CallLogListItemViewHolder.java index ca846aebb..f0852bdb5 100644 --- a/java/com/android/dialer/app/calllog/CallLogListItemViewHolder.java +++ b/java/com/android/dialer/app/calllog/CallLogListItemViewHolder.java @@ -75,10 +75,10 @@ import com.android.dialer.constants.ActivityRequestCodes; import com.android.dialer.contactphoto.ContactPhotoManager; import com.android.dialer.dialercontact.DialerContact; import com.android.dialer.dialercontact.SimDetails; +import com.android.dialer.duo.Duo; +import com.android.dialer.duo.DuoComponent; import com.android.dialer.lettertile.LetterTileDrawable; import com.android.dialer.lettertile.LetterTileDrawable.ContactType; -import com.android.dialer.lightbringer.Lightbringer; -import com.android.dialer.lightbringer.LightbringerComponent; import com.android.dialer.logging.ContactSource; import com.android.dialer.logging.ContactSource.Type; import com.android.dialer.logging.DialerImpression; @@ -222,7 +222,7 @@ public final class CallLogListItemViewHolder extends RecyclerView.ViewHolder public boolean isSpam; public boolean isCallComposerCapable; - public boolean lightbringerReady; + public boolean duoReady; private View.OnClickListener mExpandCollapseListener; private final OnActionModeStateChangedListener onActionModeStateChangedListener; @@ -533,10 +533,10 @@ public final class CallLogListItemViewHolder extends RecyclerView.ViewHolder primaryActionButtonView.setImageResource(R.drawable.quantum_ic_videocam_vd_theme_24); primaryActionButtonView.setVisibility(View.VISIBLE); break; - case CallbackAction.LIGHTBRINGER: - if (showLightbringerPrimaryButton()) { + case CallbackAction.DUO: + if (showDuoPrimaryButton()) { CallIntentBuilder.increaseLightbringerCallButtonAppearInCollapsedCallLogItemCount(); - primaryActionButtonView.setTag(IntentProvider.getLightbringerIntentProvider(number)); + primaryActionButtonView.setTag(IntentProvider.getDuoVideoIntentProvider(number)); } else { primaryActionButtonView.setTag( IntentProvider.getReturnVideoCallIntentProvider(number, accountHandle)); @@ -644,21 +644,21 @@ public final class CallLogListItemViewHolder extends RecyclerView.ViewHolder switch (callbackAction) { case CallbackAction.IMS_VIDEO: - case CallbackAction.LIGHTBRINGER: - // For an IMS video call or a Lightbringer call, the secondary action should always be a + case CallbackAction.DUO: + // For an IMS video call or a Duo call, the secondary action should always be a // voice callback. callButtonView.setVisibility(View.VISIBLE); videoCallButtonView.setVisibility(View.GONE); break; case CallbackAction.VOICE: // For a voice call, set the secondary callback action to be an IMS video call if it is - // available. Otherwise try to set it as a Lightbringer call. + // available. Otherwise try to set it as a Duo call. if (CallUtil.isVideoEnabled(mContext) && (hasPlacedCarrierVideoCall() || canSupportCarrierVideoCall())) { videoCallButtonView.setTag(IntentProvider.getReturnVideoCallIntentProvider(number)); videoCallButtonView.setVisibility(View.VISIBLE); - } else if (lightbringerReady) { - videoCallButtonView.setTag(IntentProvider.getLightbringerIntentProvider(number)); + } else if (duoReady) { + videoCallButtonView.setTag(IntentProvider.getDuoVideoIntentProvider(number)); videoCallButtonView.setVisibility(View.VISIBLE); } break; @@ -744,10 +744,10 @@ public final class CallLogListItemViewHolder extends RecyclerView.ViewHolder return false; } - private boolean showLightbringerPrimaryButton() { + private boolean showDuoPrimaryButton() { return accountHandle != null - && accountHandle.getComponentName().equals(getLightbringer().getPhoneAccountComponentName()) - && lightbringerReady; + && accountHandle.getComponentName().equals(getDuo().getPhoneAccountComponentName()) + && duoReady; } private static boolean hasDialableChar(CharSequence number) { @@ -958,10 +958,10 @@ public final class CallLogListItemViewHolder extends RecyclerView.ViewHolder return; } - // We check to see if we are starting a Lightbringer intent. The reason is Lightbringer + // We check to see if we are starting a Duo intent. The reason is Duo // intents need to be started using startActivityForResult instead of the usual startActivity String packageName = intent.getPackage(); - if (packageName != null && packageName.equals(getLightbringer().getPackageName())) { + if (packageName != null && packageName.equals(getDuo().getPackageName())) { Logger.get(mContext) .logImpression(DialerImpression.Type.LIGHTBRINGER_VIDEO_REQUESTED_FROM_CALL_LOG); if (isNonContactEntry(info)) { @@ -969,7 +969,7 @@ public final class CallLogListItemViewHolder extends RecyclerView.ViewHolder .logImpression( DialerImpression.Type.LIGHTBRINGER_NON_CONTACT_VIDEO_REQUESTED_FROM_CALL_LOG); } - startLightbringerActivity(intent); + startDuoActivity(intent); } else if (CallDetailsActivity.isLaunchIntent(intent)) { PerformanceReport.recordClick(UiAction.Type.OPEN_CALL_DETAIL); ((Activity) mContext) @@ -993,10 +993,10 @@ public final class CallLogListItemViewHolder extends RecyclerView.ViewHolder return false; } - private void startLightbringerActivity(Intent intent) { + private void startDuoActivity(Intent intent) { try { Activity activity = (Activity) mContext; - activity.startActivityForResult(intent, ActivityRequestCodes.DIALTACTS_LIGHTBRINGER); + activity.startActivityForResult(intent, ActivityRequestCodes.DIALTACTS_DUO); } catch (ActivityNotFoundException e) { Toast.makeText(mContext, R.string.activity_not_available, Toast.LENGTH_SHORT).show(); } @@ -1126,8 +1126,8 @@ public final class CallLogListItemViewHolder extends RecyclerView.ViewHolder } @NonNull - private Lightbringer getLightbringer() { - return LightbringerComponent.get(mContext).getLightbringer(); + private Duo getDuo() { + return DuoComponent.get(mContext).getDuo(); } @Override diff --git a/java/com/android/dialer/app/calllog/IntentProvider.java b/java/com/android/dialer/app/calllog/IntentProvider.java index 5030de5f5..c812bf83b 100644 --- a/java/com/android/dialer/app/calllog/IntentProvider.java +++ b/java/com/android/dialer/app/calllog/IntentProvider.java @@ -31,7 +31,7 @@ import com.android.dialer.calldetails.CallDetailsEntries; import com.android.dialer.callintent.CallInitiationType; import com.android.dialer.callintent.CallIntentBuilder; import com.android.dialer.dialercontact.DialerContact; -import com.android.dialer.lightbringer.LightbringerComponent; +import com.android.dialer.duo.DuoComponent; import com.android.dialer.util.CallUtil; import com.android.dialer.util.IntentUtil; import java.util.ArrayList; @@ -91,11 +91,11 @@ public abstract class IntentProvider { }; } - public static IntentProvider getLightbringerIntentProvider(String number) { + public static IntentProvider getDuoVideoIntentProvider(String number) { return new IntentProvider() { @Override public Intent getIntent(Context context) { - return LightbringerComponent.get(context).getLightbringer().getIntent(context, number); + return DuoComponent.get(context).getDuo().getIntent(context, number); } }; } diff --git a/java/com/android/dialer/app/list/PhoneFavoritesTileAdapter.java b/java/com/android/dialer/app/list/PhoneFavoritesTileAdapter.java index cd5712eed..cd5843c85 100644 --- a/java/com/android/dialer/app/list/PhoneFavoritesTileAdapter.java +++ b/java/com/android/dialer/app/list/PhoneFavoritesTileAdapter.java @@ -41,8 +41,8 @@ import com.android.contacts.common.preference.ContactsPreferences; import com.android.dialer.app.R; import com.android.dialer.common.LogUtil; import com.android.dialer.contactphoto.ContactPhotoManager; -import com.android.dialer.lightbringer.Lightbringer; -import com.android.dialer.lightbringer.LightbringerComponent; +import com.android.dialer.duo.Duo; +import com.android.dialer.duo.DuoComponent; import com.android.dialer.logging.InteractionEvent; import com.android.dialer.logging.Logger; import com.android.dialer.shortcuts.ShortcutRefresher; @@ -303,11 +303,11 @@ public class PhoneFavoritesTileAdapter extends BaseAdapter implements OnDragDrop ShortcutRefresher.refresh(mContext, mContactEntries); notifyDataSetChanged(); - Lightbringer lightbringer = LightbringerComponent.get(mContext).getLightbringer(); + Duo duo = DuoComponent.get(mContext).getDuo(); for (ContactEntry contact : mContactEntries) { if (contact.phoneNumber == null) { multipleNumbersContactsCount++; - } else if (lightbringer.isReachable(mContext, contact.phoneNumber)) { + } else if (duo.isReachable(mContext, contact.phoneNumber)) { lightbringerReachableContactsCount++; } } diff --git a/java/com/android/dialer/binary/aosp/AospDialerRootComponent.java b/java/com/android/dialer/binary/aosp/AospDialerRootComponent.java index d61f71260..3edc73cfe 100644 --- a/java/com/android/dialer/binary/aosp/AospDialerRootComponent.java +++ b/java/com/android/dialer/binary/aosp/AospDialerRootComponent.java @@ -20,9 +20,9 @@ import com.android.dialer.binary.basecomponent.BaseDialerRootComponent; import com.android.dialer.calllog.CallLogModule; import com.android.dialer.common.concurrent.DialerExecutorModule; import com.android.dialer.configprovider.SharedPrefConfigProviderModule; +import com.android.dialer.duo.stub.StubDuoModule; import com.android.dialer.enrichedcall.stub.StubEnrichedCallModule; import com.android.dialer.inject.ContextModule; -import com.android.dialer.lightbringer.stub.StubLightbringerModule; import com.android.dialer.phonenumbergeoutil.impl.PhoneNumberGeoUtilModule; import com.android.dialer.simulator.impl.SimulatorModule; import com.android.dialer.storage.StorageModule; @@ -49,7 +49,7 @@ import javax.inject.Singleton; StubEnrichedCallModule.class, StubMapsModule.class, VoicemailModule.class, - StubLightbringerModule.class + StubDuoModule.class } ) public interface AospDialerRootComponent extends BaseDialerRootComponent {} diff --git a/java/com/android/dialer/binary/basecomponent/BaseDialerRootComponent.java b/java/com/android/dialer/binary/basecomponent/BaseDialerRootComponent.java index 580eb5d34..c3ca56511 100644 --- a/java/com/android/dialer/binary/basecomponent/BaseDialerRootComponent.java +++ b/java/com/android/dialer/binary/basecomponent/BaseDialerRootComponent.java @@ -20,8 +20,8 @@ import com.android.dialer.calllog.CallLogComponent; import com.android.dialer.calllog.database.CallLogDatabaseComponent; import com.android.dialer.common.concurrent.DialerExecutorComponent; import com.android.dialer.configprovider.ConfigProviderComponent; +import com.android.dialer.duo.DuoComponent; import com.android.dialer.enrichedcall.EnrichedCallComponent; -import com.android.dialer.lightbringer.LightbringerComponent; import com.android.dialer.main.MainComponent; import com.android.dialer.phonenumbergeoutil.PhoneNumberGeoUtilComponent; import com.android.dialer.simulator.SimulatorComponent; @@ -49,4 +49,4 @@ public interface BaseDialerRootComponent StorageComponent.HasComponent, StrictModeComponent.HasComponent, VoicemailComponent.HasComponent, - LightbringerComponent.HasComponent {} + DuoComponent.HasComponent {} diff --git a/java/com/android/dialer/binary/google/GoogleStubDialerRootComponent.java b/java/com/android/dialer/binary/google/GoogleStubDialerRootComponent.java index 87f09c8dd..dc8d56316 100644 --- a/java/com/android/dialer/binary/google/GoogleStubDialerRootComponent.java +++ b/java/com/android/dialer/binary/google/GoogleStubDialerRootComponent.java @@ -20,9 +20,9 @@ import com.android.dialer.binary.basecomponent.BaseDialerRootComponent; import com.android.dialer.calllog.CallLogModule; import com.android.dialer.common.concurrent.DialerExecutorModule; import com.android.dialer.configprovider.SharedPrefConfigProviderModule; +import com.android.dialer.duo.stub.StubDuoModule; import com.android.dialer.enrichedcall.stub.StubEnrichedCallModule; import com.android.dialer.inject.ContextModule; -import com.android.dialer.lightbringer.stub.StubLightbringerModule; import com.android.dialer.phonenumbergeoutil.impl.PhoneNumberGeoUtilModule; import com.android.dialer.simulator.impl.SimulatorModule; import com.android.dialer.storage.StorageModule; @@ -52,7 +52,7 @@ import javax.inject.Singleton; StubEnrichedCallModule.class, MapsModule.class, VoicemailModule.class, - StubLightbringerModule.class + StubDuoModule.class } ) public interface GoogleStubDialerRootComponent extends BaseDialerRootComponent {} diff --git a/java/com/android/dialer/calldetails/CallDetailsActivity.java b/java/com/android/dialer/calldetails/CallDetailsActivity.java index d871fce12..3a3c9118a 100644 --- a/java/com/android/dialer/calldetails/CallDetailsActivity.java +++ b/java/com/android/dialer/calldetails/CallDetailsActivity.java @@ -42,11 +42,11 @@ import com.android.dialer.common.LogUtil; import com.android.dialer.common.concurrent.AsyncTaskExecutors; import com.android.dialer.constants.ActivityRequestCodes; import com.android.dialer.dialercontact.DialerContact; +import com.android.dialer.duo.Duo; +import com.android.dialer.duo.DuoComponent; import com.android.dialer.enrichedcall.EnrichedCallComponent; import com.android.dialer.enrichedcall.EnrichedCallManager.HistoricalDataChangedListener; import com.android.dialer.enrichedcall.historyquery.proto.HistoryResult; -import com.android.dialer.lightbringer.Lightbringer; -import com.android.dialer.lightbringer.LightbringerComponent; import com.android.dialer.logging.DialerImpression; import com.android.dialer.logging.Logger; import com.android.dialer.logging.UiAction; @@ -219,17 +219,16 @@ public class CallDetailsActivity extends AppCompatActivity } @Override - public void placeLightbringerCall(String phoneNumber) { + public void placeDuoVideoCall(String phoneNumber) { Logger.get(this).logImpression(DialerImpression.Type.CALL_DETAILS_LIGHTBRINGER_CALL_BACK); - Lightbringer lightbringer = LightbringerComponent.get(this).getLightbringer(); - if (!lightbringer.isReachable(this, phoneNumber)) { + Duo duo = DuoComponent.get(this).getDuo(); + if (!duo.isReachable(this, phoneNumber)) { placeImsVideoCall(phoneNumber); return; } try { - startActivityForResult( - lightbringer.getIntent(this, phoneNumber), ActivityRequestCodes.DIALTACTS_LIGHTBRINGER); + startActivityForResult(duo.getIntent(this, phoneNumber), ActivityRequestCodes.DIALTACTS_DUO); } catch (ActivityNotFoundException e) { Toast.makeText(this, R.string.activity_not_available, Toast.LENGTH_SHORT).show(); } diff --git a/java/com/android/dialer/calldetails/CallDetailsAdapter.java b/java/com/android/dialer/calldetails/CallDetailsAdapter.java index 1f00d9d9a..b39fa0fb3 100644 --- a/java/com/android/dialer/calldetails/CallDetailsAdapter.java +++ b/java/com/android/dialer/calldetails/CallDetailsAdapter.java @@ -29,7 +29,7 @@ import com.android.dialer.calllogutils.CallbackActionHelper; import com.android.dialer.calllogutils.CallbackActionHelper.CallbackAction; import com.android.dialer.common.Assert; import com.android.dialer.dialercontact.DialerContact; -import com.android.dialer.lightbringer.LightbringerComponent; +import com.android.dialer.duo.DuoComponent; import java.util.List; /** Adapter for RecyclerView in {@link CallDetailsActivity}. */ @@ -55,9 +55,7 @@ final class CallDetailsAdapter extends RecyclerView.Adapter supportsUpgrade(@NonNull Context context, @Nullable String number); + + @MainThread + void updateReachability(@NonNull Context context, @NonNull List numbers); + + @MainThread + Intent getIntent(@NonNull Context context, @NonNull String number); + + @MainThread + void requestUpgrade(@NonNull Context context, Call call); + + @MainThread + void registerListener(@NonNull DuoListener listener); + + @MainThread + void unregisterListener(@NonNull DuoListener listener); + + @Nullable + @MainThread + ComponentName getPhoneAccountComponentName(); + + @Nullable + @MainThread + PhoneAccountHandle getPhoneAccountHandle(); + + @Nullable + @MainThread + String getPackageName(); + + @StringRes + @MainThread + int getOutgoingCallTypeText(); + + @StringRes + @MainThread + int getIncomingCallTypeText(); + + /** Reachability information for a number. */ + @AutoValue + abstract class ReachabilityData { + public abstract String number(); + + public abstract boolean videoCallable(); + + public abstract boolean supportsUpgrade(); + + public static ReachabilityData create( + String number, boolean videoCallable, boolean supportsUpgrade) { + return new AutoValue_Duo_ReachabilityData(number, videoCallable, supportsUpgrade); + } + } +} diff --git a/java/com/android/dialer/duo/DuoComponent.java b/java/com/android/dialer/duo/DuoComponent.java new file mode 100644 index 000000000..031ee9e53 --- /dev/null +++ b/java/com/android/dialer/duo/DuoComponent.java @@ -0,0 +1,41 @@ +/* + * 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.duo; + +import android.content.Context; +import android.support.annotation.NonNull; +import com.android.dialer.inject.HasRootComponent; +import dagger.Subcomponent; + +/** + */ +@Subcomponent +public abstract class DuoComponent { + + @NonNull + public abstract Duo getDuo(); + + public static DuoComponent get(Context context) { + return ((HasComponent) ((HasRootComponent) context.getApplicationContext()).component()) + .duoComponent(); + } + + /** Used to refer to the root application component. */ + public interface HasComponent { + DuoComponent duoComponent(); + } +} diff --git a/java/com/android/dialer/duo/DuoListener.java b/java/com/android/dialer/duo/DuoListener.java new file mode 100644 index 000000000..9c660be9c --- /dev/null +++ b/java/com/android/dialer/duo/DuoListener.java @@ -0,0 +1,21 @@ +/* + * 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.duo; + +public interface DuoListener { + void onDuoStateChanged(); +} diff --git a/java/com/android/dialer/duo/stub/DuoStub.java b/java/com/android/dialer/duo/stub/DuoStub.java new file mode 100644 index 000000000..99f03adfd --- /dev/null +++ b/java/com/android/dialer/duo/stub/DuoStub.java @@ -0,0 +1,127 @@ +/* + * 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.duo.stub; + +import android.content.ComponentName; +import android.content.Context; +import android.content.Intent; +import android.support.annotation.MainThread; +import android.support.annotation.NonNull; +import android.support.annotation.Nullable; +import android.support.annotation.StringRes; +import android.telecom.Call; +import android.telecom.PhoneAccountHandle; +import com.android.dialer.common.Assert; +import com.android.dialer.duo.Duo; +import com.android.dialer.duo.DuoListener; +import com.google.common.base.Optional; +import java.util.List; +import javax.inject.Inject; + +public class DuoStub implements Duo { + + @Inject + public DuoStub() {} + + @Override + public boolean isEnabled() { + return false; + } + + @MainThread + @Override + public boolean isReachable(@NonNull Context context, @Nullable String number) { + Assert.isMainThread(); + Assert.isNotNull(context); + return false; + } + + @MainThread + @Override + public Optional supportsUpgrade(@NonNull Context context, @Nullable String number) { + Assert.isMainThread(); + Assert.isNotNull(context); + return Optional.of(false); + } + + @Override + public void updateReachability(@NonNull Context context, @NonNull List numbers) { + Assert.isMainThread(); + Assert.isNotNull(context); + Assert.isNotNull(numbers); + } + + @MainThread + @Override + public Intent getIntent(@NonNull Context context, @NonNull String number) { + Assert.isMainThread(); + Assert.isNotNull(context); + Assert.isNotNull(number); + return null; + } + + @MainThread + @Override + public void requestUpgrade(@NonNull Context context, Call call) { + Assert.isMainThread(); + Assert.isNotNull(call); + } + + @MainThread + @Override + public void registerListener(DuoListener listener) { + Assert.isMainThread(); + Assert.isNotNull(listener); + } + + @MainThread + @Override + public void unregisterListener(DuoListener listener) { + Assert.isMainThread(); + Assert.isNotNull(listener); + } + + @Nullable + @Override + public ComponentName getPhoneAccountComponentName() { + return null; + } + + @Nullable + @Override + public PhoneAccountHandle getPhoneAccountHandle() { + return null; + } + + @Nullable + @Override + public String getPackageName() { + return null; + } + + @StringRes + @Override + public int getOutgoingCallTypeText() { + return -1; + } + + @StringRes + @Override + public int getIncomingCallTypeText() { + return -1; + } +} diff --git a/java/com/android/dialer/duo/stub/StubDuoModule.java b/java/com/android/dialer/duo/stub/StubDuoModule.java new file mode 100644 index 000000000..604406a94 --- /dev/null +++ b/java/com/android/dialer/duo/stub/StubDuoModule.java @@ -0,0 +1,30 @@ +/* + * 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.duo.stub; + +import com.android.dialer.duo.Duo; +import dagger.Binds; +import dagger.Module; +import javax.inject.Singleton; + +@Module +public abstract class StubDuoModule { + + @Binds + @Singleton + public abstract Duo bindsDuo(DuoStub duoStub); +} diff --git a/java/com/android/dialer/lightbringer/Lightbringer.java b/java/com/android/dialer/lightbringer/Lightbringer.java deleted file mode 100644 index 2318ef5fd..000000000 --- a/java/com/android/dialer/lightbringer/Lightbringer.java +++ /dev/null @@ -1,92 +0,0 @@ -/* - * 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.lightbringer; - -import android.content.ComponentName; -import android.content.Context; -import android.content.Intent; -import android.support.annotation.MainThread; -import android.support.annotation.NonNull; -import android.support.annotation.Nullable; -import android.support.annotation.StringRes; -import android.telecom.Call; -import android.telecom.PhoneAccountHandle; -import com.google.auto.value.AutoValue; -import com.google.common.base.Optional; -import java.util.List; - -public interface Lightbringer { - - boolean isEnabled(); - - @MainThread - boolean isReachable(@NonNull Context context, @Nullable String number); - - /** @return {@code null} if result is unknown. */ - @MainThread - Optional supportsUpgrade(@NonNull Context context, @Nullable String number); - - @MainThread - void updateReachability(@NonNull Context context, @NonNull List numbers); - - @MainThread - Intent getIntent(@NonNull Context context, @NonNull String number); - - @MainThread - void requestUpgrade(@NonNull Context context, Call call); - - @MainThread - void registerListener(@NonNull LightbringerListener listener); - - @MainThread - void unregisterListener(@NonNull LightbringerListener listener); - - @Nullable - @MainThread - ComponentName getPhoneAccountComponentName(); - - @Nullable - @MainThread - PhoneAccountHandle getPhoneAccountHandle(); - - @Nullable - @MainThread - String getPackageName(); - - @StringRes - @MainThread - int getOutgoingCallTypeText(); - - @StringRes - @MainThread - int getIncomingCallTypeText(); - - /** Reachability information for a number. */ - @AutoValue - abstract class ReachabilityData { - public abstract String number(); - - public abstract boolean videoCallable(); - - public abstract boolean supportsUpgrade(); - - public static ReachabilityData create( - String number, boolean videoCallable, boolean supportsUpgrade) { - return new AutoValue_Lightbringer_ReachabilityData(number, videoCallable, supportsUpgrade); - } - } -} diff --git a/java/com/android/dialer/lightbringer/LightbringerComponent.java b/java/com/android/dialer/lightbringer/LightbringerComponent.java deleted file mode 100644 index 5bb342406..000000000 --- a/java/com/android/dialer/lightbringer/LightbringerComponent.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * 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.lightbringer; - -import android.content.Context; -import android.support.annotation.NonNull; -import com.android.dialer.inject.HasRootComponent; -import dagger.Subcomponent; - -/** - */ -@Subcomponent -public abstract class LightbringerComponent { - - @NonNull - public abstract Lightbringer getLightbringer(); - - public static LightbringerComponent get(Context context) { - return ((HasComponent) ((HasRootComponent) context.getApplicationContext()).component()) - .lightbringerComponent(); - } - - /** Used to refer to the root application component. */ - public interface HasComponent { - LightbringerComponent lightbringerComponent(); - } -} diff --git a/java/com/android/dialer/lightbringer/LightbringerListener.java b/java/com/android/dialer/lightbringer/LightbringerListener.java deleted file mode 100644 index 90fffb349..000000000 --- a/java/com/android/dialer/lightbringer/LightbringerListener.java +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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.lightbringer; - -public interface LightbringerListener { - void onLightbringerStateChanged(); -} diff --git a/java/com/android/dialer/lightbringer/stub/LightbringerStub.java b/java/com/android/dialer/lightbringer/stub/LightbringerStub.java deleted file mode 100644 index e66739113..000000000 --- a/java/com/android/dialer/lightbringer/stub/LightbringerStub.java +++ /dev/null @@ -1,127 +0,0 @@ -/* - * 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.lightbringer.stub; - -import android.content.ComponentName; -import android.content.Context; -import android.content.Intent; -import android.support.annotation.MainThread; -import android.support.annotation.NonNull; -import android.support.annotation.Nullable; -import android.support.annotation.StringRes; -import android.telecom.Call; -import android.telecom.PhoneAccountHandle; -import com.android.dialer.common.Assert; -import com.android.dialer.lightbringer.Lightbringer; -import com.android.dialer.lightbringer.LightbringerListener; -import com.google.common.base.Optional; -import java.util.List; -import javax.inject.Inject; - -public class LightbringerStub implements Lightbringer { - - @Inject - public LightbringerStub() {} - - @Override - public boolean isEnabled() { - return false; - } - - @MainThread - @Override - public boolean isReachable(@NonNull Context context, @Nullable String number) { - Assert.isMainThread(); - Assert.isNotNull(context); - return false; - } - - @MainThread - @Override - public Optional supportsUpgrade(@NonNull Context context, @Nullable String number) { - Assert.isMainThread(); - Assert.isNotNull(context); - return Optional.of(false); - } - - @Override - public void updateReachability(@NonNull Context context, @NonNull List numbers) { - Assert.isMainThread(); - Assert.isNotNull(context); - Assert.isNotNull(numbers); - } - - @MainThread - @Override - public Intent getIntent(@NonNull Context context, @NonNull String number) { - Assert.isMainThread(); - Assert.isNotNull(context); - Assert.isNotNull(number); - return null; - } - - @MainThread - @Override - public void requestUpgrade(@NonNull Context context, Call call) { - Assert.isMainThread(); - Assert.isNotNull(call); - } - - @MainThread - @Override - public void registerListener(LightbringerListener listener) { - Assert.isMainThread(); - Assert.isNotNull(listener); - } - - @MainThread - @Override - public void unregisterListener(LightbringerListener listener) { - Assert.isMainThread(); - Assert.isNotNull(listener); - } - - @Nullable - @Override - public ComponentName getPhoneAccountComponentName() { - return null; - } - - @Nullable - @Override - public PhoneAccountHandle getPhoneAccountHandle() { - return null; - } - - @Nullable - @Override - public String getPackageName() { - return null; - } - - @StringRes - @Override - public int getOutgoingCallTypeText() { - return -1; - } - - @StringRes - @Override - public int getIncomingCallTypeText() { - return -1; - } -} diff --git a/java/com/android/dialer/lightbringer/stub/StubLightbringerModule.java b/java/com/android/dialer/lightbringer/stub/StubLightbringerModule.java deleted file mode 100644 index e0be0a270..000000000 --- a/java/com/android/dialer/lightbringer/stub/StubLightbringerModule.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * 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.lightbringer.stub; - -import com.android.dialer.lightbringer.Lightbringer; -import dagger.Binds; -import dagger.Module; -import javax.inject.Singleton; - -@Module -public abstract class StubLightbringerModule { - - @Binds - @Singleton - public abstract Lightbringer bindsLightbringer(LightbringerStub lightbringer); -} diff --git a/java/com/android/dialer/searchfragment/cp2/SearchContactViewHolder.java b/java/com/android/dialer/searchfragment/cp2/SearchContactViewHolder.java index 327fe5303..b162a5e52 100644 --- a/java/com/android/dialer/searchfragment/cp2/SearchContactViewHolder.java +++ b/java/com/android/dialer/searchfragment/cp2/SearchContactViewHolder.java @@ -34,11 +34,11 @@ import android.widget.TextView; import com.android.dialer.common.Assert; import com.android.dialer.contactphoto.ContactPhotoManager; import com.android.dialer.dialercontact.DialerContact; +import com.android.dialer.duo.DuoComponent; import com.android.dialer.enrichedcall.EnrichedCallCapabilities; import com.android.dialer.enrichedcall.EnrichedCallComponent; import com.android.dialer.enrichedcall.EnrichedCallManager; import com.android.dialer.lettertile.LetterTileDrawable; -import com.android.dialer.lightbringer.LightbringerComponent; import com.android.dialer.searchfragment.common.Projections; import com.android.dialer.searchfragment.common.QueryBoldingUtil; import com.android.dialer.searchfragment.common.R; @@ -194,7 +194,7 @@ public final class SearchContactViewHolder extends ViewHolder implements OnClick return CallToAction.VIDEO_CALL; } - if (LightbringerComponent.get(context).getLightbringer().isReachable(context, number)) { + if (DuoComponent.get(context).getDuo().isReachable(context, number)) { return CallToAction.DUO_CALL; } diff --git a/java/com/android/dialer/searchfragment/list/SearchAdapter.java b/java/com/android/dialer/searchfragment/list/SearchAdapter.java index 1ca29e072..29e4e2320 100644 --- a/java/com/android/dialer/searchfragment/list/SearchAdapter.java +++ b/java/com/android/dialer/searchfragment/list/SearchAdapter.java @@ -35,7 +35,7 @@ import com.android.dialer.callintent.CallSpecificAppData; import com.android.dialer.common.Assert; import com.android.dialer.constants.ActivityRequestCodes; import com.android.dialer.dialercontact.DialerContact; -import com.android.dialer.lightbringer.LightbringerComponent; +import com.android.dialer.duo.DuoComponent; import com.android.dialer.logging.DialerImpression; import com.android.dialer.logging.Logger; import com.android.dialer.searchfragment.common.RowClickListener; @@ -244,9 +244,8 @@ public final class SearchAdapter extends RecyclerView.Adapter public void placeDuoCall(String phoneNumber) { Logger.get(activity) .logImpression(DialerImpression.Type.LIGHTBRINGER_VIDEO_REQUESTED_FROM_SEARCH); - Intent intent = - LightbringerComponent.get(activity).getLightbringer().getIntent(activity, phoneNumber); - activity.startActivityForResult(intent, ActivityRequestCodes.DIALTACTS_LIGHTBRINGER); + Intent intent = DuoComponent.get(activity).getDuo().getIntent(activity, phoneNumber); + activity.startActivityForResult(intent, ActivityRequestCodes.DIALTACTS_DUO); } @Override diff --git a/java/com/android/incallui/call/DialerCall.java b/java/com/android/incallui/call/DialerCall.java index 47a4a70f5..d911a4c4f 100644 --- a/java/com/android/incallui/call/DialerCall.java +++ b/java/com/android/incallui/call/DialerCall.java @@ -51,6 +51,7 @@ import com.android.dialer.common.Assert; import com.android.dialer.common.LogUtil; import com.android.dialer.compat.telephony.TelephonyManagerCompat; import com.android.dialer.configprovider.ConfigProviderBindings; +import com.android.dialer.duo.DuoComponent; import com.android.dialer.enrichedcall.EnrichedCallCapabilities; import com.android.dialer.enrichedcall.EnrichedCallComponent; import com.android.dialer.enrichedcall.EnrichedCallManager; @@ -58,7 +59,6 @@ import com.android.dialer.enrichedcall.EnrichedCallManager.CapabilitiesListener; import com.android.dialer.enrichedcall.EnrichedCallManager.Filter; import com.android.dialer.enrichedcall.EnrichedCallManager.StateChangedListener; import com.android.dialer.enrichedcall.Session; -import com.android.dialer.lightbringer.LightbringerComponent; import com.android.dialer.location.GeoUtil; import com.android.dialer.logging.ContactLookupResult; import com.android.dialer.logging.ContactLookupResult.Type; @@ -72,9 +72,9 @@ import com.android.incallui.latencyreport.LatencyReport; import com.android.incallui.util.TelecomCallUtil; import com.android.incallui.videotech.VideoTech; import com.android.incallui.videotech.VideoTech.VideoTechListener; +import com.android.incallui.videotech.duo.DuoVideoTech; import com.android.incallui.videotech.empty.EmptyVideoTech; import com.android.incallui.videotech.ims.ImsVideoTech; -import com.android.incallui.videotech.lightbringer.LightbringerTech; import com.android.incallui.videotech.utils.VideoUtils; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; @@ -1614,11 +1614,8 @@ public class DialerCall implements VideoTechListener, StateChangedListener, Capa } videoTechs.add( - new LightbringerTech( - LightbringerComponent.get(call.mContext).getLightbringer(), - call, - call.mTelecomCall, - phoneNumber)); + new DuoVideoTech( + DuoComponent.get(call.mContext).getDuo(), call, call.mTelecomCall, phoneNumber)); } VideoTech getVideoTech() { diff --git a/java/com/android/incallui/videotech/duo/DuoVideoTech.java b/java/com/android/incallui/videotech/duo/DuoVideoTech.java new file mode 100644 index 000000000..c858ae1f2 --- /dev/null +++ b/java/com/android/incallui/videotech/duo/DuoVideoTech.java @@ -0,0 +1,195 @@ +/* + * 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.incallui.videotech.duo; + +import android.content.Context; +import android.support.annotation.NonNull; +import android.support.annotation.Nullable; +import android.telecom.Call; +import com.android.dialer.common.Assert; +import com.android.dialer.common.LogUtil; +import com.android.dialer.configprovider.ConfigProviderBindings; +import com.android.dialer.duo.Duo; +import com.android.dialer.duo.DuoListener; +import com.android.dialer.logging.DialerImpression; +import com.android.incallui.video.protocol.VideoCallScreen; +import com.android.incallui.video.protocol.VideoCallScreenDelegate; +import com.android.incallui.videotech.VideoTech; +import com.android.incallui.videotech.utils.SessionModificationState; +import com.google.common.base.Optional; +import com.google.common.collect.ImmutableList; + +public class DuoVideoTech implements VideoTech, DuoListener { + private final Duo duo; + private final VideoTechListener listener; + private final Call call; + private final String callingNumber; + private int callState = Call.STATE_NEW; + private boolean isRemoteUpgradeAvailabilityQueried; + + public DuoVideoTech( + @NonNull Duo duo, + @NonNull VideoTechListener listener, + @NonNull Call call, + @NonNull String callingNumber) { + this.duo = Assert.isNotNull(duo); + this.listener = Assert.isNotNull(listener); + this.call = Assert.isNotNull(call); + this.callingNumber = Assert.isNotNull(callingNumber); + + duo.registerListener(this); + } + + @Override + public boolean isAvailable(Context context) { + if (!ConfigProviderBindings.get(context) + .getBoolean("enable_lightbringer_video_upgrade", true)) { + LogUtil.v("DuoVideoTech.isAvailable", "upgrade disabled by flag"); + return false; + } + + if (callState != Call.STATE_ACTIVE) { + LogUtil.v("DuoVideoTech.isAvailable", "upgrade unavailable, call must be active"); + return false; + } + Optional localResult = duo.supportsUpgrade(context, callingNumber); + if (localResult.isPresent()) { + LogUtil.v( + "DuoVideoTech.isAvailable", "upgrade supported in local cache: " + localResult.get()); + return localResult.get(); + } + + if (!isRemoteUpgradeAvailabilityQueried) { + LogUtil.v("DuoVideoTech.isAvailable", "reachability unknown, starting remote query"); + isRemoteUpgradeAvailabilityQueried = true; + duo.updateReachability(context, ImmutableList.of(callingNumber)); + } + + return false; + } + + @Override + public boolean isTransmittingOrReceiving() { + return false; + } + + @Override + public boolean isSelfManagedCamera() { + return false; + } + + @Override + public boolean shouldUseSurfaceView() { + return false; + } + + @Override + public boolean isPaused() { + return false; + } + + @Override + public VideoCallScreenDelegate createVideoCallScreenDelegate( + Context context, VideoCallScreen videoCallScreen) { + throw Assert.createUnsupportedOperationFailException(); + } + + @Override + public void onCallStateChanged(Context context, int newState) { + if (newState == Call.STATE_DISCONNECTING) { + duo.unregisterListener(this); + } + + callState = newState; + } + + @Override + public void onRemovedFromCallList() { + duo.unregisterListener(this); + } + + @Override + public int getSessionModificationState() { + return SessionModificationState.NO_REQUEST; + } + + @Override + public void upgradeToVideo(@NonNull Context context) { + listener.onImpressionLoggingNeeded(DialerImpression.Type.LIGHTBRINGER_UPGRADE_REQUESTED); + duo.requestUpgrade(context, call); + } + + @Override + public void acceptVideoRequest(@NonNull Context context) { + throw Assert.createUnsupportedOperationFailException(); + } + + @Override + public void acceptVideoRequestAsAudio() { + throw Assert.createUnsupportedOperationFailException(); + } + + @Override + public void declineVideoRequest() { + throw Assert.createUnsupportedOperationFailException(); + } + + @Override + public boolean isTransmitting() { + return false; + } + + @Override + public void stopTransmission() { + throw Assert.createUnsupportedOperationFailException(); + } + + @Override + public void resumeTransmission(@NonNull Context context) { + throw Assert.createUnsupportedOperationFailException(); + } + + @Override + public void pause() {} + + @Override + public void unpause() {} + + @Override + public void setCamera(@Nullable String cameraId) { + throw Assert.createUnsupportedOperationFailException(); + } + + @Override + public void becomePrimary() { + listener.onImpressionLoggingNeeded( + DialerImpression.Type.UPGRADE_TO_VIDEO_CALL_BUTTON_SHOWN_FOR_LIGHTBRINGER); + } + + @Override + public void setDeviceOrientation(int rotation) {} + + @Override + public void onDuoStateChanged() { + listener.onVideoTechStateChanged(); + } + + @Override + public com.android.dialer.logging.VideoTech.Type getVideoTechType() { + return com.android.dialer.logging.VideoTech.Type.LIGHTBRINGER_VIDEO_TECH; + } +} diff --git a/java/com/android/incallui/videotech/lightbringer/LightbringerTech.java b/java/com/android/incallui/videotech/lightbringer/LightbringerTech.java deleted file mode 100644 index eb2e92e85..000000000 --- a/java/com/android/incallui/videotech/lightbringer/LightbringerTech.java +++ /dev/null @@ -1,195 +0,0 @@ -/* - * 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.incallui.videotech.lightbringer; - -import android.content.Context; -import android.support.annotation.NonNull; -import android.support.annotation.Nullable; -import android.telecom.Call; -import com.android.dialer.common.Assert; -import com.android.dialer.common.LogUtil; -import com.android.dialer.configprovider.ConfigProviderBindings; -import com.android.dialer.lightbringer.Lightbringer; -import com.android.dialer.lightbringer.LightbringerListener; -import com.android.dialer.logging.DialerImpression; -import com.android.incallui.video.protocol.VideoCallScreen; -import com.android.incallui.video.protocol.VideoCallScreenDelegate; -import com.android.incallui.videotech.VideoTech; -import com.android.incallui.videotech.utils.SessionModificationState; -import com.google.common.base.Optional; -import com.google.common.collect.ImmutableList; - -public class LightbringerTech implements VideoTech, LightbringerListener { - private final Lightbringer lightbringer; - private final VideoTechListener listener; - private final Call call; - private final String callingNumber; - private int callState = Call.STATE_NEW; - private boolean isRemoteUpgradeAvailabilityQueried; - - public LightbringerTech( - @NonNull Lightbringer lightbringer, - @NonNull VideoTechListener listener, - @NonNull Call call, - @NonNull String callingNumber) { - this.lightbringer = Assert.isNotNull(lightbringer); - this.listener = Assert.isNotNull(listener); - this.call = Assert.isNotNull(call); - this.callingNumber = Assert.isNotNull(callingNumber); - - lightbringer.registerListener(this); - } - - @Override - public boolean isAvailable(Context context) { - if (!ConfigProviderBindings.get(context) - .getBoolean("enable_lightbringer_video_upgrade", true)) { - LogUtil.v("LightbringerTech.isAvailable", "upgrade disabled by flag"); - return false; - } - - if (callState != Call.STATE_ACTIVE) { - LogUtil.v("LightbringerTech.isAvailable", "upgrade unavailable, call must be active"); - return false; - } - Optional localResult = lightbringer.supportsUpgrade(context, callingNumber); - if (localResult.isPresent()) { - LogUtil.v( - "LightbringerTech.isAvailable", "upgrade supported in local cache: " + localResult.get()); - return localResult.get(); - } - - if (!isRemoteUpgradeAvailabilityQueried) { - LogUtil.v("LightbringerTech.isAvailable", "reachability unknown, starting remote query"); - isRemoteUpgradeAvailabilityQueried = true; - lightbringer.updateReachability(context, ImmutableList.of(callingNumber)); - } - - return false; - } - - @Override - public boolean isTransmittingOrReceiving() { - return false; - } - - @Override - public boolean isSelfManagedCamera() { - return false; - } - - @Override - public boolean shouldUseSurfaceView() { - return false; - } - - @Override - public boolean isPaused() { - return false; - } - - @Override - public VideoCallScreenDelegate createVideoCallScreenDelegate( - Context context, VideoCallScreen videoCallScreen) { - throw Assert.createUnsupportedOperationFailException(); - } - - @Override - public void onCallStateChanged(Context context, int newState) { - if (newState == Call.STATE_DISCONNECTING) { - lightbringer.unregisterListener(this); - } - - callState = newState; - } - - @Override - public void onRemovedFromCallList() { - lightbringer.unregisterListener(this); - } - - @Override - public int getSessionModificationState() { - return SessionModificationState.NO_REQUEST; - } - - @Override - public void upgradeToVideo(@NonNull Context context) { - listener.onImpressionLoggingNeeded(DialerImpression.Type.LIGHTBRINGER_UPGRADE_REQUESTED); - lightbringer.requestUpgrade(context, call); - } - - @Override - public void acceptVideoRequest(@NonNull Context context) { - throw Assert.createUnsupportedOperationFailException(); - } - - @Override - public void acceptVideoRequestAsAudio() { - throw Assert.createUnsupportedOperationFailException(); - } - - @Override - public void declineVideoRequest() { - throw Assert.createUnsupportedOperationFailException(); - } - - @Override - public boolean isTransmitting() { - return false; - } - - @Override - public void stopTransmission() { - throw Assert.createUnsupportedOperationFailException(); - } - - @Override - public void resumeTransmission(@NonNull Context context) { - throw Assert.createUnsupportedOperationFailException(); - } - - @Override - public void pause() {} - - @Override - public void unpause() {} - - @Override - public void setCamera(@Nullable String cameraId) { - throw Assert.createUnsupportedOperationFailException(); - } - - @Override - public void becomePrimary() { - listener.onImpressionLoggingNeeded( - DialerImpression.Type.UPGRADE_TO_VIDEO_CALL_BUTTON_SHOWN_FOR_LIGHTBRINGER); - } - - @Override - public void setDeviceOrientation(int rotation) {} - - @Override - public void onLightbringerStateChanged() { - listener.onVideoTechStateChanged(); - } - - @Override - public com.android.dialer.logging.VideoTech.Type getVideoTechType() { - return com.android.dialer.logging.VideoTech.Type.LIGHTBRINGER_VIDEO_TECH; - } -} -- cgit v1.2.3