diff options
author | Sailesh Nepal <sail@google.com> | 2016-02-22 20:35:09 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2016-02-22 20:35:09 +0000 |
commit | fd70e58784fe49e321cd3a5e759da984667f5277 (patch) | |
tree | a766ce4ac2e3ec43b004071bf11f98b2aefab600 | |
parent | 639ed3451d911c9a282d1351b87595f3e1d8aaa4 (diff) | |
parent | 6a4e9d87031f1f803ce9b64844f71c73e9502a7e (diff) |
Merge "Remove Lollipop support for InCallUI" into nyc-dev
14 files changed, 74 insertions, 666 deletions
diff --git a/Android.mk b/Android.mk index 4c67293ad..eb6cbdc37 100644 --- a/Android.mk +++ b/Android.mk @@ -64,9 +64,7 @@ LOCAL_PRIVILEGED_MODULE := true LOCAL_PROGUARD_FLAG_FILES := proguard.flags $(incallui_dir)/proguard.flags -# Uncomment the following line to build against the current SDK -# This is required for building an unbundled app. -LOCAL_SDK_VERSION := system_current +LOCAL_SDK_VERSION := current include $(BUILD_PACKAGE) diff --git a/InCallUI/src/com/android/incallui/Call.java b/InCallUI/src/com/android/incallui/Call.java index aec806f1e..54ec52829 100644 --- a/InCallUI/src/com/android/incallui/Call.java +++ b/InCallUI/src/com/android/incallui/Call.java @@ -19,9 +19,9 @@ package com.android.incallui; import android.content.Context; import android.hardware.camera2.CameraCharacteristics; import android.net.Uri; -import android.os.Build; import android.os.Bundle; import android.os.Trace; +import android.telecom.Call.Details; import android.telecom.Connection; import android.telecom.DisconnectCause; import android.telecom.GatewayInfo; @@ -37,8 +37,6 @@ import com.android.contacts.common.compat.SdkVersionOverride; import com.android.contacts.common.compat.telecom.TelecomManagerCompat; import com.android.contacts.common.testing.NeededForTesting; import com.android.dialer.util.IntentUtil; -import com.android.incallui.compat.telecom.DetailsCompat; -import com.android.incallui.compat.telecom.VideoProfileCompat; import com.android.incallui.util.TelecomCallUtil; import java.util.ArrayList; @@ -291,18 +289,8 @@ public class Call { private static final String ID_PREFIX = Call.class.getSimpleName() + "_"; private static int sIdCounter = 0; - private Object mTelecomCallCallback = newTelecomCallCallback(); - - private Object newTelecomCallCallback() { - if (SdkVersionOverride.getSdkVersion(Build.VERSION_CODES.M) >= Build.VERSION_CODES.M) { - return newMarshmallowTelecomCallCallback(); - } - return newLollipopTelecomCallCallback(); - } - - private Object newMarshmallowTelecomCallCallback() { - Log.i(this, "Using an android.telecom.Call$Callback"); - return new android.telecom.Call.Callback() { + private final android.telecom.Call.Callback mTelecomCallCallback = + new android.telecom.Call.Callback() { @Override public void onStateChanged(android.telecom.Call call, int newState) { Log.d(this, "TelecomCallCallback onStateChanged call=" + call + " newState=" @@ -367,81 +355,7 @@ public class Call { List<android.telecom.Call> conferenceableCalls) { update(); } - }; - } - - private Object newLollipopTelecomCallCallback() { - // This code only runs for Google Experience phones on the pre-M sdk since only the system - // dialer can invoke the InCallUI code. This allows us to safely use the - // android.telecom.Call.Listener interface - Log.i(this, "Using an android.telecom.Call$Listener"); - return new android.telecom.Call.Listener() { - @Override - public void onStateChanged(android.telecom.Call call, int newState) { - Log.d(this, "TelecomCallCallback onStateChanged call=" + call + " newState=" - + newState); - update(); - } - - @Override - public void onParentChanged(android.telecom.Call call, - android.telecom.Call newParent) { - Log.d(this, "TelecomCallCallback onParentChanged call=" + call + " newParent=" - + newParent); - update(); - } - - @Override - public void onChildrenChanged(android.telecom.Call call, - List<android.telecom.Call> children) { - update(); - } - - @Override - public void onDetailsChanged(android.telecom.Call call, - android.telecom.Call.Details details) { - Log.d(this, "TelecomCallCallback onStateChanged call=" + call + " details=" - + details); - update(); - } - - @Override - public void onCannedTextResponsesLoaded(android.telecom.Call call, - List<String> cannedTextResponses) { - Log.d(this, "TelecomCallCallback onStateChanged call=" + call - + " cannedTextResponses=" + cannedTextResponses); - update(); - } - - @Override - public void onPostDialWait(android.telecom.Call call, - String remainingPostDialSequence) { - Log.d(this, "TelecomCallCallback onStateChanged call=" + call - + " remainingPostDialSequence=" + remainingPostDialSequence); - update(); - } - - @Override - public void onVideoCallChanged(android.telecom.Call call, - VideoCall videoCall) { - Log.d(this, "TelecomCallCallback onStateChanged call=" + call + " videoCall=" - + videoCall); - update(); - } - - @Override - public void onCallDestroyed(android.telecom.Call call) { - Log.d(this, "TelecomCallCallback onStateChanged call=" + call); - call.removeListener(this); - } - - @Override - public void onConferenceableCallsChanged(android.telecom.Call call, - List<android.telecom.Call> conferenceableCalls) { - update(); - } - }; - } + }; private android.telecom.Call mTelecomCall; private boolean mIsEmergencyCall; @@ -491,11 +405,7 @@ public class Call { updateFromTelecomCall(); - if (SdkVersionOverride.getSdkVersion(Build.VERSION_CODES.M) >= Build.VERSION_CODES.M) { - mTelecomCall.registerCallback((android.telecom.Call.Callback) mTelecomCallCallback); - } else { - mTelecomCall.addListener((android.telecom.Call.Listener) mTelecomCallCallback); - } + mTelecomCall.registerCallback(mTelecomCallCallback); mTimeAddedMs = System.currentTimeMillis(); } @@ -750,7 +660,7 @@ public class Call { } public Bundle getIntentExtras() { - return DetailsCompat.getIntentExtras(mTelecomCall.getDetails()); + return mTelecomCall.getDetails().getIntentExtras(); } public Bundle getExtras() { @@ -824,7 +734,7 @@ public class Call { } public boolean hasProperty(int property) { - return DetailsCompat.hasProperty(mTelecomCall.getDetails(), property); + return mTelecomCall.getDetails().hasProperty(property); } /** Gets the time when the call first became active. */ @@ -989,11 +899,11 @@ public class Call { "videoState:%s, mSessionModificationState:%d, VideoSettings:%s]", mId, State.toString(getState()), - DetailsCompat.capabilitiesToString(mTelecomCall.getDetails().getCallCapabilities()), + Details.capabilitiesToString(mTelecomCall.getDetails().getCallCapabilities()), mChildCallIds, getParentId(), this.mTelecomCall.getConferenceableCalls(), - VideoProfileCompat.videoStateToString(mTelecomCall.getDetails().getVideoState()), + VideoProfile.videoStateToString(mTelecomCall.getDetails().getVideoState()), mSessionModificationState, getVideoSettings()); } diff --git a/InCallUI/src/com/android/incallui/CallButtonPresenter.java b/InCallUI/src/com/android/incallui/CallButtonPresenter.java index dde62954f..fd0dd7639 100644 --- a/InCallUI/src/com/android/incallui/CallButtonPresenter.java +++ b/InCallUI/src/com/android/incallui/CallButtonPresenter.java @@ -380,7 +380,7 @@ public class CallButtonPresenter extends Presenter<CallButtonPresenter.CallButto && call.can(android.telecom.Call.Details.CAPABILITY_HOLD); final boolean isCallOnHold = call.getState() == Call.State.ONHOLD; - final boolean showAddCall = TelecomAdapter.getInstance().canAddCall(call) + final boolean showAddCall = TelecomAdapter.getInstance().canAddCall() && UserManagerCompat.isUserUnlocked(ui.getContext()); final boolean showMerge = call.can( android.telecom.Call.Details.CAPABILITY_MERGE_CONFERENCE); diff --git a/InCallUI/src/com/android/incallui/CallCardPresenter.java b/InCallUI/src/com/android/incallui/CallCardPresenter.java index 2acdc470f..a77de1e72 100644 --- a/InCallUI/src/com/android/incallui/CallCardPresenter.java +++ b/InCallUI/src/com/android/incallui/CallCardPresenter.java @@ -53,7 +53,6 @@ import com.android.incallui.InCallPresenter.InCallEventListener; import com.android.incallui.InCallPresenter.InCallState; import com.android.incallui.InCallPresenter.InCallStateListener; import com.android.incallui.InCallPresenter.IncomingCallListener; -import com.android.incallui.compat.telecom.DetailsCompat; import com.android.incalluibind.ObjectFactory; import java.lang.ref.WeakReference; @@ -345,7 +344,7 @@ public class CallCardPresenter extends Presenter<CallCardPresenter.CallCardUi> updatePrimaryCallState(); if (call.can(Details.CAPABILITY_MANAGE_CONFERENCE) != - DetailsCompat.can(details, Details.CAPABILITY_MANAGE_CONFERENCE)) { + details.can(Details.CAPABILITY_MANAGE_CONFERENCE)) { maybeShowManageConferenceCallButton(); } } @@ -1112,8 +1111,8 @@ public class CallCardPresenter extends Presenter<CallCardPresenter.CallCardUi> } private static boolean hasCallSubject(Call call) { - return !TextUtils.isEmpty(DetailsCompat.getIntentExtras( - call.getTelecomCall().getDetails()).getString(TelecomManager.EXTRA_CALL_SUBJECT)); + return !TextUtils.isEmpty(call.getTelecomCall().getDetails().getIntentExtras() + .getString(TelecomManager.EXTRA_CALL_SUBJECT)); } public interface CallCardUi extends Ui { diff --git a/InCallUI/src/com/android/incallui/ConferenceParticipantListAdapter.java b/InCallUI/src/com/android/incallui/ConferenceParticipantListAdapter.java index 86002b0d7..9d7069d1c 100644 --- a/InCallUI/src/com/android/incallui/ConferenceParticipantListAdapter.java +++ b/InCallUI/src/com/android/incallui/ConferenceParticipantListAdapter.java @@ -38,7 +38,6 @@ import com.android.contacts.common.compat.PhoneNumberUtilsCompat; import com.android.contacts.common.preference.ContactsPreferences; import com.android.contacts.common.util.ContactDisplayUtils; import com.android.incallui.ContactInfoCache.ContactCacheEntry; -import com.android.incallui.compat.telecom.DetailsCompat; import java.lang.ref.WeakReference; import java.util.ArrayList; @@ -356,10 +355,9 @@ public class ConferenceParticipantListAdapter extends BaseAdapter { new ContactLookupCallback(this)); } - boolean thisRowCanSeparate = mParentCanSeparate && DetailsCompat.can( - call.getTelecomCall().getDetails(), + boolean thisRowCanSeparate = mParentCanSeparate && call.getTelecomCall().getDetails().can( android.telecom.Call.Details.CAPABILITY_SEPARATE_FROM_CONFERENCE); - boolean thisRowCanDisconnect = DetailsCompat.can(call.getTelecomCall().getDetails(), + boolean thisRowCanDisconnect = call.getTelecomCall().getDetails().can( android.telecom.Call.Details.CAPABILITY_DISCONNECT_FROM_CONFERENCE); setCallerInfoForRow(result, contactCache.namePrimary, diff --git a/InCallUI/src/com/android/incallui/InCallActivity.java b/InCallUI/src/com/android/incallui/InCallActivity.java index 73155a460..dec1323b2 100644 --- a/InCallUI/src/com/android/incallui/InCallActivity.java +++ b/InCallUI/src/com/android/incallui/InCallActivity.java @@ -58,7 +58,6 @@ import com.android.contacts.common.widget.SelectPhoneAccountDialogFragment.Selec import com.android.dialer.logging.Logger; import com.android.dialer.logging.ScreenEvent; import com.android.incallui.Call.State; -import com.android.incallui.compat.telecom.DetailsCompat; import com.android.incallui.util.AccessibilityUtil; import com.android.phone.common.animation.AnimUtils; import com.android.phone.common.animation.AnimationListenerAdapter; @@ -573,7 +572,7 @@ public class InCallActivity extends TransactionSafeActivity implements FragmentD Bundle extras = null; if (call != null) { - extras = DetailsCompat.getIntentExtras(call.getTelecomCall().getDetails()); + extras = call.getTelecomCall().getDetails().getIntentExtras(); } if (extras == null) { // Initialize the extras bundle to avoid NPE @@ -610,8 +609,8 @@ public class InCallActivity extends TransactionSafeActivity implements FragmentD Call pendingAccountSelectionCall = CallList.getInstance().getWaitingForAccountCall(); if (pendingAccountSelectionCall != null) { showCallCardFragment(false); - Bundle extras = DetailsCompat.getIntentExtras(pendingAccountSelectionCall - .getTelecomCall().getDetails()); + Bundle extras = + pendingAccountSelectionCall.getTelecomCall().getDetails().getIntentExtras(); final List<PhoneAccountHandle> phoneAccountHandles; if (extras != null) { diff --git a/InCallUI/src/com/android/incallui/InCallPresenter.java b/InCallUI/src/com/android/incallui/InCallPresenter.java index c51a561bf..249071faa 100644 --- a/InCallUI/src/com/android/incallui/InCallPresenter.java +++ b/InCallUI/src/com/android/incallui/InCallPresenter.java @@ -25,7 +25,6 @@ import android.content.Intent; import android.content.res.Resources; import android.database.ContentObserver; import android.graphics.Point; -import android.os.Build; import android.os.Bundle; import android.os.Handler; import android.provider.CallLog; @@ -56,7 +55,6 @@ import com.android.dialer.filterednumber.FilteredNumbersUtil; import com.android.dialer.logging.InteractionEvent; import com.android.dialer.logging.Logger; import com.android.dialer.util.TelecomUtil; -import com.android.incallui.compat.telecom.DetailsCompat; import com.android.incallui.util.TelecomCallUtil; import com.android.incalluibind.ObjectFactory; @@ -139,89 +137,38 @@ public class InCallPresenter implements CallList.Listener, */ private boolean mIsFullScreen = false; - private final Object mCallCallback = newTelecomCallCallback(); - - private Object newTelecomCallCallback() { - if (SdkVersionOverride.getSdkVersion(Build.VERSION_CODES.M) >= Build.VERSION_CODES.M) { - return newMarshmallowTelecomCallCallback(); - } - return newLollipopTelecomCallCallback(); - } - - private Object newMarshmallowTelecomCallCallback() { - Log.i(this, "Using android.telecom.Call.Callback"); - return new android.telecom.Call.Callback() { - @Override - public void onPostDialWait(android.telecom.Call telecomCall, - String remainingPostDialSequence) { - final Call call = mCallList.getCallByTelecomCall(telecomCall); - if (call == null) { - Log.w(this, "Call not found in call list: " + telecomCall); - return; - } - onPostDialCharWait(call.getId(), remainingPostDialSequence); - } - - @Override - public void onDetailsChanged(android.telecom.Call telecomCall, - android.telecom.Call.Details details) { - final Call call = mCallList.getCallByTelecomCall(telecomCall); - if (call == null) { - Log.w(this, "Call not found in call list: " + telecomCall); - return; - } - for (InCallDetailsListener listener : mDetailsListeners) { - listener.onDetailsChanged(call, details); - } - } - - @Override - public void onConferenceableCallsChanged(android.telecom.Call telecomCall, - List<android.telecom.Call> conferenceableCalls) { - Log.i(this, "onConferenceableCallsChanged: " + telecomCall); - onDetailsChanged(telecomCall, telecomCall.getDetails()); + private final android.telecom.Call.Callback mCallCallback = new android.telecom.Call.Callback() { + @Override + public void onPostDialWait(android.telecom.Call telecomCall, + String remainingPostDialSequence) { + final Call call = mCallList.getCallByTelecomCall(telecomCall); + if (call == null) { + Log.w(this, "Call not found in call list: " + telecomCall); + return; } - }; - } + onPostDialCharWait(call.getId(), remainingPostDialSequence); + } - private Object newLollipopTelecomCallCallback() { - // This code only runs for Google Experience phones on the pre-M sdk since only the system - // dialer can invoke the InCallUI code. This allows us to safely use the - // android.telecom.Call.Listener interface - Log.i(this, "Using android.telecom.Call.Listener"); - return new android.telecom.Call.Listener() { - @Override - public void onPostDialWait(android.telecom.Call telecomCall, - String remainingPostDialSequence) { - final Call call = mCallList.getCallByTelecomCall(telecomCall); - if (call == null) { - Log.w(this, "Call not found in call list: " + telecomCall); - return; - } - onPostDialCharWait(call.getId(), remainingPostDialSequence); + @Override + public void onDetailsChanged(android.telecom.Call telecomCall, + android.telecom.Call.Details details) { + final Call call = mCallList.getCallByTelecomCall(telecomCall); + if (call == null) { + Log.w(this, "Call not found in call list: " + telecomCall); + return; } - - @Override - public void onDetailsChanged(android.telecom.Call telecomCall, - android.telecom.Call.Details details) { - final Call call = mCallList.getCallByTelecomCall(telecomCall); - if (call == null) { - Log.w(this, "Call not found in call list: " + telecomCall); - return; - } - for (InCallDetailsListener listener : mDetailsListeners) { - listener.onDetailsChanged(call, details); - } + for (InCallDetailsListener listener : mDetailsListeners) { + listener.onDetailsChanged(call, details); } + } - @Override - public void onConferenceableCallsChanged(android.telecom.Call telecomCall, - List<android.telecom.Call> conferenceableCalls) { - Log.i(this, "onConferenceableCallsChanged: " + telecomCall); - onDetailsChanged(telecomCall, telecomCall.getDetails()); - } - }; - } + @Override + public void onConferenceableCallsChanged(android.telecom.Call telecomCall, + List<android.telecom.Call> conferenceableCalls) { + Log.i(this, "onConferenceableCallsChanged: " + telecomCall); + onDetailsChanged(telecomCall, telecomCall.getDetails()); + } + }; private PhoneStateListener mPhoneStateListener = new PhoneStateListener() { public void onCallStateChanged(int state, String incomingNumber) { @@ -559,11 +506,7 @@ public class InCallPresenter implements CallList.Listener, // Since a call has been added we are no longer waiting for Telecom to send us a call. setBoundAndWaitingForOutgoingCall(false, null); - if (SdkVersionOverride.getSdkVersion(Build.VERSION_CODES.M) >= Build.VERSION_CODES.M) { - call.registerCallback((android.telecom.Call.Callback) mCallCallback); - } else { - call.addListener((android.telecom.Call.Listener) mCallCallback); - } + call.registerCallback(mCallCallback); } /** @@ -632,11 +575,7 @@ public class InCallPresenter implements CallList.Listener, public void onCallRemoved(android.telecom.Call call) { mCallList.onCallRemoved(call); - if (SdkVersionOverride.getSdkVersion(Build.VERSION_CODES.M) >= Build.VERSION_CODES.M) { - call.unregisterCallback((android.telecom.Call.Callback) mCallCallback); - } else { - call.removeListener((android.telecom.Call.Listener) mCallCallback); - } + call.unregisterCallback(mCallCallback); } public void onCanAddCallChanged(boolean canAddCall) { @@ -1470,7 +1409,7 @@ public class InCallPresenter implements CallList.Listener, private void setDisconnectCauseForMissingAccounts(Call call) { android.telecom.Call telecomCall = call.getTelecomCall(); - Bundle extras = DetailsCompat.getIntentExtras(telecomCall.getDetails()); + Bundle extras = telecomCall.getDetails().getIntentExtras(); // Initialize the extras bundle to avoid NPE if (extras == null) { extras = new Bundle(); diff --git a/InCallUI/src/com/android/incallui/InCallServiceImpl.java b/InCallUI/src/com/android/incallui/InCallServiceImpl.java index 31d6efb92..86936973e 100644 --- a/InCallUI/src/com/android/incallui/InCallServiceImpl.java +++ b/InCallUI/src/com/android/incallui/InCallServiceImpl.java @@ -18,15 +18,10 @@ package com.android.incallui; import android.content.Context; import android.content.Intent; -import android.os.Build; import android.os.IBinder; -import android.telecom.AudioState; import android.telecom.Call; import android.telecom.CallAudioState; import android.telecom.InCallService; -import android.telecom.Phone; - -import com.android.contacts.common.compat.SdkVersionOverride; /** * Used to receive updates about calls from the Telecom component. This service is bound to @@ -100,85 +95,4 @@ public class InCallServiceImpl extends InCallService { TelecomAdapter.getInstance().clearInCallService(); InCallPresenter.getInstance().tearDown(); } - - /* - * Compatibility code for devices running the L sdk. In that version of the sdk, InCallService - * callbacks were registered via a android.telecom.Phone$Listener. These callbacks typically - * correspond 1:1 to callbacks now found in android.telecom.InCallService so the compatibility - * code forwards to those methods. - */ - private Phone.Listener mPhoneListener = new Phone.Listener() { - @Override - public void onAudioStateChanged(Phone phone, AudioState audioState) { - /* - * Need to use reflection here; in M these are private fields retrieved through getters, - * but in L they are public fields without getters. - */ - try { - boolean isMuted = AudioState.class.getField("isMuted").getBoolean(audioState); - int route = AudioState.class.getField("route").getInt(audioState); - int supportedRouteMask = AudioState.class.getField("supportedRouteMask") - .getInt(audioState); - AudioModeProvider.getInstance() - .onAudioStateChanged(isMuted, route, supportedRouteMask); - } catch (ReflectiveOperationException e) { - Log.e(this, "Unable to use reflection to retrieve AudioState fields", e); - } - } - - @Override - public void onBringToForeground(Phone phone, boolean showDialpad) { - InCallServiceImpl.this.onBringToForeground(showDialpad); - } - - @Override - public void onCallAdded(Phone phone, Call call) { - InCallServiceImpl.this.onCallAdded(call); - } - - @Override - public void onCallRemoved(Phone phone, Call call) { - InCallServiceImpl.this.onCallRemoved(call); - } - }; - - private Phone mPhone; - - @Override - public void onPhoneCreated(Phone phone) { - if (SdkVersionOverride.getSdkVersion(Build.VERSION_CODES.M) >= Build.VERSION_CODES.M) { - return; - } - mPhone = phone; - mPhone.addListener(mPhoneListener); - } - - @Override - public void onPhoneDestroyed(Phone phone) { - if (SdkVersionOverride.getSdkVersion(Build.VERSION_CODES.M) >= Build.VERSION_CODES.M) { - return; - } - mPhone.removeListener(mPhoneListener); - mPhone = null; - } - - /* - * setMuted and setAudioRoute are final in InCallService so compat methods are - * used to perform the needed branching logic based on sdk version - */ - public void setMutedCompat(boolean state) { - if (SdkVersionOverride.getSdkVersion(Build.VERSION_CODES.M) >= Build.VERSION_CODES.M) { - super.setMuted(state); - return; - } - mPhone.setMuted(state); - } - - public void setAudioRouteCompat(int route) { - if (SdkVersionOverride.getSdkVersion(Build.VERSION_CODES.M) >= Build.VERSION_CODES.M) { - super.setAudioRoute(route); - return; - } - mPhone.setAudioRoute(route); - } } diff --git a/InCallUI/src/com/android/incallui/TelecomAdapter.java b/InCallUI/src/com/android/incallui/TelecomAdapter.java index 0fc2e280a..f172270dd 100644 --- a/InCallUI/src/com/android/incallui/TelecomAdapter.java +++ b/InCallUI/src/com/android/incallui/TelecomAdapter.java @@ -24,9 +24,6 @@ import android.os.Looper; import android.telecom.InCallService; import android.telecom.PhoneAccountHandle; -import com.android.incallui.compat.telecom.DetailsCompat; -import com.android.incallui.compat.telecom.InCallServiceCompat; - import java.util.List; final class TelecomAdapter implements InCallServiceListener { @@ -108,7 +105,7 @@ final class TelecomAdapter implements InCallServiceListener { void mute(boolean shouldMute) { if (mInCallService != null) { - InCallServiceCompat.setMuted(mInCallService, shouldMute); + mInCallService.setMuted(shouldMute); } else { Log.e(this, "error mute, mInCallService is null"); } @@ -116,7 +113,7 @@ final class TelecomAdapter implements InCallServiceListener { void setAudioRoute(int route) { if (mInCallService != null) { - InCallServiceCompat.setAudioRoute(mInCallService, route); + mInCallService.setAudioRoute(route); } else { Log.e(this, "error setAudioRoute, mInCallService is null"); } @@ -138,8 +135,7 @@ final class TelecomAdapter implements InCallServiceListener { if (!conferenceable.isEmpty()) { call.conference(conferenceable.get(0)); } else { - if (DetailsCompat.can(call.getDetails(), - android.telecom.Call.Details.CAPABILITY_MERGE_CONFERENCE)) { + if (call.getDetails().can(android.telecom.Call.Details.CAPABILITY_MERGE_CONFERENCE)) { call.mergeConference(); } } @@ -151,8 +147,7 @@ final class TelecomAdapter implements InCallServiceListener { void swap(String callId) { android.telecom.Call call = getTelecomCallById(callId); if (call != null) { - if (DetailsCompat.can(call.getDetails(), - android.telecom.Call.Details.CAPABILITY_SWAP_CONFERENCE)) { + if (call.getDetails().can(android.telecom.Call.Details.CAPABILITY_SWAP_CONFERENCE)) { call.swapConference(); } } else { @@ -222,7 +217,10 @@ final class TelecomAdapter implements InCallServiceListener { } } - boolean canAddCall(Call call) { - return InCallServiceCompat.canAddCall(mInCallService, call); + boolean canAddCall() { + if (mInCallService != null) { + return mInCallService.canAddCall(); + } + return false; } } diff --git a/InCallUI/src/com/android/incallui/VideoCallPresenter.java b/InCallUI/src/com/android/incallui/VideoCallPresenter.java index 2b6bc09a2..c9a332881 100644 --- a/InCallUI/src/com/android/incallui/VideoCallPresenter.java +++ b/InCallUI/src/com/android/incallui/VideoCallPresenter.java @@ -39,7 +39,6 @@ import com.android.incallui.InCallPresenter.InCallStateListener; import com.android.incallui.InCallPresenter.IncomingCallListener; import com.android.incallui.InCallVideoCallCallbackNotifier.SurfaceChangeListener; import com.android.incallui.InCallVideoCallCallbackNotifier.VideoEventListener; -import com.android.incallui.compat.telecom.VideoProfileCompat; import java.util.Objects; @@ -485,8 +484,8 @@ public class VideoCallPresenter extends Presenter<VideoCallPresenter.VideoCallUi Log.d(this, "checkForVideoStateChange: isVideoCall= " + isVideoCall + " hasVideoStateChanged=" + hasVideoStateChanged + " isVideoMode=" + isVideoMode() + " previousVideoState: " + - VideoProfileCompat.videoStateToString(mCurrentVideoState) + " newVideoState: " - + VideoProfileCompat.videoStateToString(call.getVideoState())); + VideoProfile.videoStateToString(mCurrentVideoState) + " newVideoState: " + + VideoProfile.videoStateToString(call.getVideoState())); if (!hasVideoStateChanged) { return; @@ -656,8 +655,8 @@ public class VideoCallPresenter extends Presenter<VideoCallPresenter.VideoCallUi } private static boolean isCameraRequired(int videoState) { - return VideoProfileCompat.isBidirectional(videoState) || - VideoProfileCompat.isTransmissionEnabled(videoState); + return VideoProfile.isBidirectional(videoState) || + VideoProfile.isTransmissionEnabled(videoState); } private boolean isCameraRequired() { @@ -758,7 +757,7 @@ public class VideoCallPresenter extends Presenter<VideoCallPresenter.VideoCallUi if (showIncomingVideo || showOutgoingVideo) { ui.showVideoViews(showOutgoingVideo, showIncomingVideo); - if (VideoProfileCompat.isReceptionEnabled(videoState)) { + if (VideoProfile.isReceptionEnabled(videoState)) { loadProfilePhotoAsync(); } } else { @@ -766,7 +765,7 @@ public class VideoCallPresenter extends Presenter<VideoCallPresenter.VideoCallUi } InCallPresenter.getInstance().enableScreenTimeout( - VideoProfileCompat.isAudioOnly(videoState)); + VideoProfile.isAudioOnly(videoState)); } /** @@ -783,10 +782,10 @@ public class VideoCallPresenter extends Presenter<VideoCallPresenter.VideoCallUi return false; } - boolean isPaused = VideoProfileCompat.isPaused(videoState); + boolean isPaused = VideoProfile.isPaused(videoState); boolean isCallActive = callState == Call.State.ACTIVE; - return !isPaused && isCallActive && VideoProfileCompat.isReceptionEnabled(videoState); + return !isPaused && isCallActive && VideoProfile.isReceptionEnabled(videoState); } /** @@ -802,7 +801,7 @@ public class VideoCallPresenter extends Presenter<VideoCallPresenter.VideoCallUi return false; } - return VideoProfileCompat.isTransmissionEnabled(videoState); + return VideoProfile.isTransmissionEnabled(videoState); } /** @@ -1178,8 +1177,8 @@ public class VideoCallPresenter extends Presenter<VideoCallPresenter.VideoCallUi } private static int toCameraDirection(int videoState) { - return VideoProfileCompat.isTransmissionEnabled(videoState) && - !VideoProfileCompat.isBidirectional(videoState) + return VideoProfile.isTransmissionEnabled(videoState) && + !VideoProfile.isBidirectional(videoState) ? Call.VideoSettings.CAMERA_DIRECTION_BACK_FACING : Call.VideoSettings.CAMERA_DIRECTION_FRONT_FACING; } diff --git a/InCallUI/src/com/android/incallui/VideoUtils.java b/InCallUI/src/com/android/incallui/VideoUtils.java index 7e0926b46..8641d60ec 100644 --- a/InCallUI/src/com/android/incallui/VideoUtils.java +++ b/InCallUI/src/com/android/incallui/VideoUtils.java @@ -19,7 +19,6 @@ package com.android.incallui; import android.telecom.VideoProfile; import com.android.contacts.common.compat.CompatUtils; -import com.android.incallui.compat.telecom.VideoProfileCompat; import com.google.common.base.Preconditions; @@ -34,8 +33,8 @@ public class VideoUtils { return false; } - return VideoProfileCompat.isTransmissionEnabled(videoState) - || VideoProfileCompat.isReceptionEnabled(videoState); + return VideoProfile.isTransmissionEnabled(videoState) + || VideoProfile.isReceptionEnabled(videoState); } public static boolean isBidirectionalVideoCall(Call call) { @@ -43,7 +42,7 @@ public class VideoUtils { return false; } - return VideoProfileCompat.isBidirectional(call.getVideoState()); + return VideoProfile.isBidirectional(call.getVideoState()); } public static boolean isIncomingVideoCall(Call call) { @@ -72,7 +71,7 @@ public class VideoUtils { return true; } - return call != null && VideoProfileCompat.isAudioOnly(call.getVideoState()); + return call != null && VideoProfile.isAudioOnly(call.getVideoState()); } // TODO (ims-vt) Check if special handling is needed for CONF calls. @@ -82,7 +81,7 @@ public class VideoUtils { public static VideoProfile makeVideoPauseProfile(Call call) { Preconditions.checkNotNull(call); - Preconditions.checkState(!VideoProfileCompat.isAudioOnly(call.getVideoState())); + Preconditions.checkState(!VideoProfile.isAudioOnly(call.getVideoState())); return new VideoProfile(getPausedVideoState(call.getVideoState())); } diff --git a/InCallUI/src/com/android/incallui/compat/telecom/DetailsCompat.java b/InCallUI/src/com/android/incallui/compat/telecom/DetailsCompat.java deleted file mode 100644 index b9f82a9f1..000000000 --- a/InCallUI/src/com/android/incallui/compat/telecom/DetailsCompat.java +++ /dev/null @@ -1,108 +0,0 @@ -/* - * Copyright (C) 2015 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.compat.telecom; - -import android.os.Build; -import android.os.Bundle; -import android.telecom.Call.Details; - -import com.android.contacts.common.compat.CompatUtils; -import com.android.incallui.Log; - -/** - * Compatibility class for {@link Details} - */ -public class DetailsCompat { - - /** - * Constant formerly in L as PhoneCapabilities#ADD_CALL. It was transferred to - * {@link Details#CAPABILITY_UNUSED_1} and hidden - */ - public static final int CAPABILITY_UNUSED_1 = 0x00000010; - - /** - * Returns the intent extras from the given {@link Details} - * For Sdk version L and earlier, this will return {@link Details#getExtras()} - * - * @param details The details whose intent extras should be returned - * @return The given details' intent extras - */ - public static Bundle getIntentExtras(Details details) { - if (CompatUtils.isMarshmallowCompatible()) { - return details.getIntentExtras(); - } - return details.getExtras(); - } - - /** - * Compatibility method to check whether the supplied properties includes the - * specified property. - * - * @param details The details whose properties should be checked. - * @param property The property to check properties for. - * @return Whether the specified property is supported. - */ - public static boolean hasProperty(Details details, int property) { - if (CompatUtils.isMarshmallowCompatible()) { - return details.hasProperty(property); - } - return (details.getCallProperties() & property) != 0; - } - - /** - * Compatibility method to check whether the capabilities of the given {@code Details} - * supports the specified capability. - * - * @param details The details whose capabilities should be checked. - * @param capability The capability to check capabilities for. - * @return Whether the specified capability is supported. - */ - public static boolean can(Details details, int capability) { - if (CompatUtils.isLollipopMr1Compatible()) { - return details.can(capability); - } - return (details.getCallCapabilities() & capability) != 0; - } - - /** - * Render a set of capability bits ({@code CAPABILITY_*}) as a human readable string. - * - * @param capabilities A capability bit field. - * @return A human readable string representation. - */ - public static String capabilitiesToString(int capabilities) { - if (CompatUtils.isLollipopMr1Compatible()) { - return Details.capabilitiesToString(capabilities); - } - return capabilitiesToStringLollipop(capabilities); - } - - /* - * Use reflection to call PhoneCapabilities.toString. InCallUI code is only run on Google - * Experience phones, so we will be the system Dialer and the method will exist - */ - private static String capabilitiesToStringLollipop(int capabilities) { - try { - return (String) Class.forName("android.telecom.PhoneCapabilities") - .getMethod("toString", Integer.TYPE) - .invoke(null, capabilities); - } catch (ReflectiveOperationException e) { - Log.e(DetailsCompat.class, "Unable to use reflection to call " - + "android.telecom.PhoneCapabilities.toString(int)", e); - return String.valueOf(capabilities); - } - } -} diff --git a/InCallUI/src/com/android/incallui/compat/telecom/InCallServiceCompat.java b/InCallUI/src/com/android/incallui/compat/telecom/InCallServiceCompat.java deleted file mode 100644 index 0a3cb26d4..000000000 --- a/InCallUI/src/com/android/incallui/compat/telecom/InCallServiceCompat.java +++ /dev/null @@ -1,97 +0,0 @@ -/* - * Copyright (C) 2015 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.compat.telecom; - -import android.support.annotation.Nullable; -import android.telecom.InCallService; - -import com.android.contacts.common.compat.CompatUtils; -import com.android.incallui.Call; -import com.android.incallui.InCallServiceImpl; - -/** - * Compatibility class for {@link android.telecom.InCallService} - */ -public class InCallServiceCompat { - - /** - * Sets the microphone mute state. When this request is honored, there - * will be a change to the {@link android.telecom.CallAudioState}. - * - * Note: Noop for Sdk versions less than M where inCallService is not of type - * {@link InCallServiceImpl} - * - * @param inCallService the {@link InCallService} to act on - * @param shouldMute {@code true} if the microphone should be muted; {@code false} otherwise. - */ - public static void setMuted(@Nullable InCallService inCallService, boolean shouldMute) { - if (inCallService == null) { - return; - } - if (CompatUtils.isMarshmallowCompatible()) { - inCallService.setMuted(shouldMute); - return; - } - - if (inCallService instanceof InCallServiceImpl) { - ((InCallServiceImpl) inCallService).setMutedCompat(shouldMute); - } - } - - /** - * Sets the audio route (speaker, bluetooth, etc...). When this request is honored, there will - * be change to the {@link android.telecom.CallAudioState}. - * - * Note: Noop for Sdk versions less than M where inCallService is not of type - * {@link InCallServiceImpl} - * - * @param inCallService the {@link InCallService} to act on - * @param route The audio route to use. - */ - public static void setAudioRoute(@Nullable InCallService inCallService, int route) { - if (inCallService == null) { - return; - } - if (CompatUtils.isMarshmallowCompatible()) { - inCallService.setAudioRoute(route); - return; - } - - if (inCallService instanceof InCallServiceImpl) { - ((InCallServiceImpl) inCallService).setAudioRouteCompat(route); - } - } - - /** - * Returns if the device can support additional calls. - * - * @param inCallService the {@link InCallService} to act on - * @param call a {@link Call} to use if needed due to compatibility reasons - * @return Whether the phone supports adding more calls, defaulting to true if inCallService - * is null - */ - public static boolean canAddCall(@Nullable InCallService inCallService, Call call) { - if (inCallService == null) { - return true; - } - - if (CompatUtils.isMarshmallowCompatible()) { - // Default to true if we are not connected to telecom. - return inCallService.canAddCall(); - } - return call.can(DetailsCompat.CAPABILITY_UNUSED_1); - } -} diff --git a/InCallUI/src/com/android/incallui/compat/telecom/VideoProfileCompat.java b/InCallUI/src/com/android/incallui/compat/telecom/VideoProfileCompat.java deleted file mode 100644 index 6e81bd79a..000000000 --- a/InCallUI/src/com/android/incallui/compat/telecom/VideoProfileCompat.java +++ /dev/null @@ -1,140 +0,0 @@ -/* - * Copyright (C) 2015 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.compat.telecom; - -import android.telecom.VideoProfile; - -import com.android.contacts.common.compat.CompatUtils; - -/** - * Compatibility class for {@link android.telecom.VideoProfile} - */ -public class VideoProfileCompat { - - /** - * Generates a string representation of a video state. - * - * @param videoState The video state. - * @return String representation of the video state. - */ - public static String videoStateToString(int videoState) { - if (CompatUtils.isMarshmallowCompatible()) { - return VideoProfile.videoStateToString(videoState); - } - return videoStateToStringLollipop(videoState); - } - - /** - * Copied from {@link android.telecom.VideoProfile#videoStateToString} - */ - private static String videoStateToStringLollipop(int videoState) { - StringBuilder sb = new StringBuilder(); - sb.append("Audio"); - if (isAudioOnly(videoState)) { - sb.append(" Only"); - } else { - if (isTransmissionEnabled(videoState)) { - sb.append(" Tx"); - } - if (isReceptionEnabled(videoState)) { - sb.append(" Rx"); - } - if (isPaused(videoState)) { - sb.append(" Pause"); - } - } - return sb.toString(); - } - - /** - * Indicates whether the video state is audio only. - * - * @param videoState The video state. - * @return {@code true} if the video state is audio only, {@code false} otherwise. - */ - public static boolean isAudioOnly(int videoState) { - if (CompatUtils.isMarshmallowCompatible()) { - return VideoProfile.isAudioOnly(videoState); - } - return !hasState(videoState, VideoProfile.STATE_TX_ENABLED) - && !hasState(videoState, VideoProfile.STATE_RX_ENABLED); - } - - /** - * Indicates whether the video state has video transmission enabled. - * - * @param videoState The video state. - * @return {@code true} if video transmission is enabled, {@code false} otherwise. - */ - public static boolean isTransmissionEnabled(int videoState) { - if (CompatUtils.isMarshmallowCompatible()) { - return VideoProfile.isTransmissionEnabled(videoState); - } - return hasState(videoState, VideoProfile.STATE_TX_ENABLED); - } - - /** - * Indicates whether the video state has video reception enabled. - * - * @param videoState The video state. - * @return {@code true} if video reception is enabled, {@code false} otherwise. - */ - public static boolean isReceptionEnabled(int videoState) { - if (CompatUtils.isMarshmallowCompatible()) { - return VideoProfile.isReceptionEnabled(videoState); - } - return hasState(videoState, VideoProfile.STATE_RX_ENABLED); - } - - /** - * Indicates whether the video state is paused. - * - * @param videoState The video state. - * @return {@code true} if the video is paused, {@code false} otherwise. - */ - public static boolean isPaused(int videoState) { - if (CompatUtils.isMarshmallowCompatible()) { - return VideoProfile.isPaused(videoState); - } - return hasState(videoState, VideoProfile.STATE_PAUSED); - } - - /** - * Copied from {@link android.telecom.VideoProfile} - * - * Determines if a specified state is set in a videoState bit-mask. - * - * @param videoState The video state bit-mask. - * @param state The state to check. - * @return {@code true} if the state is set. - */ - private static boolean hasState(int videoState, int state) { - return (videoState & state) == state; - } - - /** - * Indicates whether the video state is bi-directional. - * - * @param videoState The video state. - * @return {@code True} if the video is bi-directional, {@code false} otherwise. - */ - public static boolean isBidirectional(int videoState) { - if (CompatUtils.isMarshmallowCompatible()) { - return VideoProfile.isBidirectional(videoState); - } - return hasState(videoState, VideoProfile.STATE_BIDIRECTIONAL); - } -} |