From 4b293f0f08030c97e1bb54d2f79ac2fb1a6e29ae Mon Sep 17 00:00:00 2001 From: Tyler Gunn Date: Fri, 12 Sep 2014 22:16:48 -0700 Subject: Renaming Telecomm to Telecom. - Changing package from android.telecomm to android.telecom - Changing package from com.android.telecomm to com.android.server.telecomm. - Renaming TelecommManager to TelecomManager. Bug: 17364651 Change-Id: Ie5ae18f51baa5da2eb9793785ad0c9d83b6343d1 --- .../src/com/android/incallui/AnswerPresenter.java | 8 +- .../com/android/incallui/AudioModeProvider.java | 4 +- InCallUI/src/com/android/incallui/Call.java | 62 +++--- .../com/android/incallui/CallButtonFragment.java | 2 +- .../com/android/incallui/CallButtonPresenter.java | 22 +- .../src/com/android/incallui/CallCardFragment.java | 2 +- .../com/android/incallui/CallCardPresenter.java | 43 ++-- InCallUI/src/com/android/incallui/CallList.java | 10 +- .../src/com/android/incallui/CallerInfoUtils.java | 18 +- .../incallui/ConferenceManagerPresenter.java | 6 +- .../src/com/android/incallui/ContactInfoCache.java | 12 +- .../src/com/android/incallui/DialpadPresenter.java | 4 +- .../src/com/android/incallui/GlowPadWrapper.java | 2 +- .../src/com/android/incallui/InCallActivity.java | 5 +- InCallUI/src/com/android/incallui/InCallApp.java | 2 +- .../com/android/incallui/InCallPhoneListener.java | 2 +- .../src/com/android/incallui/InCallPresenter.java | 44 ++-- .../com/android/incallui/InCallServiceImpl.java | 15 +- .../android/incallui/InCallVideoCallListener.java | 8 +- InCallUI/src/com/android/incallui/Log.java | 2 +- .../android/incallui/PostCharDialogFragment.java | 5 +- .../src/com/android/incallui/ProximitySensor.java | 8 +- .../incallui/SelectPhoneAccountDialogFragment.java | 17 +- .../com/android/incallui/StatusBarNotifier.java | 2 +- .../src/com/android/incallui/TelecomAdapter.java | 235 +++++++++++++++++++++ .../src/com/android/incallui/TelecommAdapter.java | 235 --------------------- .../com/android/incallui/VideoCallPresenter.java | 12 +- 27 files changed, 390 insertions(+), 397 deletions(-) create mode 100644 InCallUI/src/com/android/incallui/TelecomAdapter.java delete mode 100644 InCallUI/src/com/android/incallui/TelecommAdapter.java diff --git a/InCallUI/src/com/android/incallui/AnswerPresenter.java b/InCallUI/src/com/android/incallui/AnswerPresenter.java index aeb0bc3c5..2d861f2dd 100644 --- a/InCallUI/src/com/android/incallui/AnswerPresenter.java +++ b/InCallUI/src/com/android/incallui/AnswerPresenter.java @@ -16,7 +16,7 @@ package com.android.incallui; -import android.telecomm.PhoneCapabilities; +import android.telecom.PhoneCapabilities; import android.app.KeyguardManager; import android.content.Context; @@ -158,7 +158,7 @@ public class AnswerPresenter extends Presenter == Call.SessionModificationState.RECEIVED_UPGRADE_TO_VIDEO_REQUEST) { InCallPresenter.getInstance().acceptUpgradeRequest(context); } else { - TelecommAdapter.getInstance().answerCall(mCall.getId(), videoState); + TelecomAdapter.getInstance().answerCall(mCall.getId(), videoState); } } @@ -168,7 +168,7 @@ public class AnswerPresenter extends Presenter */ public void onDecline() { Log.d(this, "onDecline " + mCallId); - TelecommAdapter.getInstance().rejectCall(mCall.getId(), false, null); + TelecomAdapter.getInstance().rejectCall(mCall.getId(), false, null); } public void onText() { @@ -179,7 +179,7 @@ public class AnswerPresenter extends Presenter public void rejectCallWithMessage(String message) { Log.d(this, "sendTextToDefaultActivity()..."); - TelecommAdapter.getInstance().rejectCall(mCall.getId(), true, message); + TelecomAdapter.getInstance().rejectCall(mCall.getId(), true, message); onDismissDialog(); } diff --git a/InCallUI/src/com/android/incallui/AudioModeProvider.java b/InCallUI/src/com/android/incallui/AudioModeProvider.java index 31ce9ebd7..de22ccb0e 100644 --- a/InCallUI/src/com/android/incallui/AudioModeProvider.java +++ b/InCallUI/src/com/android/incallui/AudioModeProvider.java @@ -18,8 +18,8 @@ package com.android.incallui; import com.google.common.collect.Lists; -import android.telecomm.AudioState; -import android.telecomm.Phone; +import android.telecom.AudioState; +import android.telecom.Phone; import java.util.List; diff --git a/InCallUI/src/com/android/incallui/Call.java b/InCallUI/src/com/android/incallui/Call.java index 36dd16291..fe3feea55 100644 --- a/InCallUI/src/com/android/incallui/Call.java +++ b/InCallUI/src/com/android/incallui/Call.java @@ -20,12 +20,12 @@ import com.android.contacts.common.CallUtil; import android.content.Context; import android.net.Uri; -import android.telecomm.CallProperties; -import android.telecomm.PhoneCapabilities; -import android.telecomm.GatewayInfo; -import android.telecomm.InCallService.VideoCall; -import android.telecomm.PhoneAccountHandle; -import android.telecomm.VideoProfile; +import android.telecom.CallProperties; +import android.telecom.PhoneCapabilities; +import android.telecom.GatewayInfo; +import android.telecom.InCallService.VideoCall; +import android.telecom.PhoneAccountHandle; +import android.telecom.VideoProfile; import android.telephony.DisconnectCause; import java.util.ArrayList; @@ -120,56 +120,56 @@ public final class Call { private static final String ID_PREFIX = Call.class.getSimpleName() + "_"; private static int sIdCounter = 0; - private android.telecomm.Call.Listener mTelecommCallListener = - new android.telecomm.Call.Listener() { + private android.telecom.Call.Listener mTelecommCallListener = + new android.telecom.Call.Listener() { @Override - public void onStateChanged(android.telecomm.Call call, int newState) { + public void onStateChanged(android.telecom.Call call, int newState) { update(); } @Override - public void onParentChanged(android.telecomm.Call call, - android.telecomm.Call newParent) { + public void onParentChanged(android.telecom.Call call, + android.telecom.Call newParent) { update(); } @Override - public void onChildrenChanged(android.telecomm.Call call, - List children) { + public void onChildrenChanged(android.telecom.Call call, + List children) { update(); } @Override - public void onDetailsChanged(android.telecomm.Call call, - android.telecomm.Call.Details details) { + public void onDetailsChanged(android.telecom.Call call, + android.telecom.Call.Details details) { update(); } @Override - public void onCannedTextResponsesLoaded(android.telecomm.Call call, + public void onCannedTextResponsesLoaded(android.telecom.Call call, List cannedTextResponses) { update(); } @Override - public void onPostDialWait(android.telecomm.Call call, + public void onPostDialWait(android.telecom.Call call, String remainingPostDialSequence) { update(); } @Override - public void onVideoCallChanged(android.telecomm.Call call, + public void onVideoCallChanged(android.telecom.Call call, VideoCall videoCall) { update(); } @Override - public void onCallDestroyed(android.telecomm.Call call) { + public void onCallDestroyed(android.telecom.Call call) { call.removeListener(mTelecommCallListener); } }; - private final android.telecomm.Call mTelecommCall; + private final android.telecom.Call mTelecommCall; private final String mId; private int mState = State.INVALID; private int mDisconnectCause; @@ -178,14 +178,14 @@ public final class Call { private InCallVideoCallListener mVideoCallListener; - public Call(android.telecomm.Call telecommCall) { + public Call(android.telecom.Call telecommCall) { mTelecommCall = telecommCall; mId = ID_PREFIX + Integer.toString(sIdCounter++); updateFromTelecommCall(); mTelecommCall.addListener(mTelecommCallListener); } - public android.telecomm.Call getTelecommCall() { + public android.telecom.Call getTelecommCall() { return mTelecommCall; } @@ -221,20 +221,20 @@ public final class Call { private static int translateState(int state) { switch (state) { - case android.telecomm.Call.STATE_CONNECTING: + case android.telecom.Call.STATE_CONNECTING: return Call.State.CONNECTING; - case android.telecomm.Call.STATE_PRE_DIAL_WAIT: + case android.telecom.Call.STATE_PRE_DIAL_WAIT: return Call.State.PRE_DIAL_WAIT; - case android.telecomm.Call.STATE_DIALING: - case android.telecomm.Call.STATE_NEW: + case android.telecom.Call.STATE_DIALING: + case android.telecom.Call.STATE_NEW: return Call.State.DIALING; - case android.telecomm.Call.STATE_RINGING: + case android.telecom.Call.STATE_RINGING: return Call.State.INCOMING; - case android.telecomm.Call.STATE_ACTIVE: + case android.telecom.Call.STATE_ACTIVE: return Call.State.ACTIVE; - case android.telecomm.Call.STATE_HOLDING: + case android.telecom.Call.STATE_HOLDING: return Call.State.ONHOLD; - case android.telecomm.Call.STATE_DISCONNECTED: + case android.telecom.Call.STATE_DISCONNECTED: return Call.State.DISCONNECTED; default: return Call.State.INVALID; @@ -346,7 +346,7 @@ public final class Call { } public String getParentId() { - android.telecomm.Call parentCall = mTelecommCall.getParent(); + android.telecom.Call parentCall = mTelecommCall.getParent(); if (parentCall != null) { return CallList.getInstance().getCallByTelecommCall(parentCall).getId(); } diff --git a/InCallUI/src/com/android/incallui/CallButtonFragment.java b/InCallUI/src/com/android/incallui/CallButtonFragment.java index 2dae7a444..64f74ff6f 100644 --- a/InCallUI/src/com/android/incallui/CallButtonFragment.java +++ b/InCallUI/src/com/android/incallui/CallButtonFragment.java @@ -19,7 +19,7 @@ package com.android.incallui; import android.content.Context; import android.graphics.drawable.LayerDrawable; import android.os.Bundle; -import android.telecomm.AudioState; +import android.telecom.AudioState; import android.view.ContextThemeWrapper; import android.view.LayoutInflater; import android.view.Menu; diff --git a/InCallUI/src/com/android/incallui/CallButtonPresenter.java b/InCallUI/src/com/android/incallui/CallButtonPresenter.java index 57c90be29..f6228bc23 100644 --- a/InCallUI/src/com/android/incallui/CallButtonPresenter.java +++ b/InCallUI/src/com/android/incallui/CallButtonPresenter.java @@ -17,10 +17,10 @@ package com.android.incallui; import android.content.Context; -import android.telecomm.AudioState; -import android.telecomm.InCallService.VideoCall; -import android.telecomm.PhoneCapabilities; -import android.telecomm.VideoProfile; +import android.telecom.AudioState; +import android.telecom.InCallService.VideoCall; +import android.telecom.PhoneCapabilities; +import android.telecom.VideoProfile; import com.android.incallui.AudioModeProvider.AudioModeListener; @@ -134,7 +134,7 @@ public class CallButtonPresenter extends Presenter private ContactCacheEntry mSecondaryContactInfo; private CallTimer mCallTimer; private Context mContext; - private TelecommManager mTelecommManager; + private TelecomManager mTelecomManager; public static class ContactLookupCallback implements ContactInfoCacheCallback { private final WeakReference mCallCardPresenter; @@ -259,7 +258,7 @@ public class CallCardPresenter extends Presenter } @Override - public void onDetailsChanged(Call call, android.telecomm.Call.Details details) { + public void onDetailsChanged(Call call, android.telecom.Call.Details details) { updatePrimaryCallState(); } @@ -269,8 +268,8 @@ public class CallCardPresenter extends Presenter // number directly from the telephony layer). PhoneAccountHandle accountHandle = mPrimary.getAccountHandle(); if (accountHandle != null) { - TelecommManager mgr = - (TelecommManager) mContext.getSystemService(Context.TELECOMM_SERVICE); + TelecomManager mgr = + (TelecomManager) mContext.getSystemService(Context.TELECOM_SERVICE); PhoneAccount account = mgr.getPhoneAccount(accountHandle); if (account != null) { return getNumberFromHandle(account.getSubscriptionAddress()); @@ -318,7 +317,7 @@ public class CallCardPresenter extends Presenter if (statusHints != null) { Bundle extras = statusHints.getExtras(); if (extras != null) { - callbackNumber = extras.getString(TelecommManager.EXTRA_CALL_BACK_NUMBER); + callbackNumber = extras.getString(TelecomManager.EXTRA_CALL_BACK_NUMBER); } } } @@ -503,7 +502,7 @@ public class CallCardPresenter extends Presenter if (accountHandle == null) { return null; } - return getTelecommManager().getPhoneAccount(accountHandle); + return getTelecomManager().getPhoneAccount(accountHandle); } /** @@ -521,7 +520,7 @@ public class CallCardPresenter extends Presenter */ private Drawable getCallProviderIcon(Call call) { PhoneAccount account = getAccountForCall(call); - if (account != null && getTelecommManager().hasMultipleEnabledAccounts()) { + if (account != null && getTelecomManager().hasMultipleEnabledAccounts()) { return account.getIcon(mContext); } return null; @@ -532,7 +531,7 @@ public class CallCardPresenter extends Presenter */ private String getCallProviderLabel(Call call) { PhoneAccount account = getAccountForCall(call); - if (account != null && getTelecommManager().hasMultipleEnabledAccounts()) { + if (account != null && getTelecomManager().hasMultipleEnabledAccounts()) { return account.getLabel().toString(); } return null; @@ -616,7 +615,7 @@ public class CallCardPresenter extends Presenter } Log.i(this, "Swapping call to foreground: " + mSecondary); - TelecommAdapter.getInstance().unholdCall(mSecondary.getId()); + TelecomAdapter.getInstance().unholdCall(mSecondary.getId()); } public void endCallClicked() { @@ -625,7 +624,7 @@ public class CallCardPresenter extends Presenter } Log.i(this, "Disconnecting call: " + mPrimary); - TelecommAdapter.getInstance().disconnectCall(mPrimary.getId()); + TelecomAdapter.getInstance().disconnectCall(mPrimary.getId()); } private String getNumberFromHandle(Uri handle) { @@ -669,11 +668,11 @@ public class CallCardPresenter extends Presenter void showManageConferenceCallButton(boolean visible); } - private TelecommManager getTelecommManager() { - if (mTelecommManager == null) { - mTelecommManager = - (TelecommManager) mContext.getSystemService(Context.TELECOMM_SERVICE); + private TelecomManager getTelecomManager() { + if (mTelecomManager == null) { + mTelecomManager = + (TelecomManager) mContext.getSystemService(Context.TELECOM_SERVICE); } - return mTelecommManager; + return mTelecomManager; } } diff --git a/InCallUI/src/com/android/incallui/CallList.java b/InCallUI/src/com/android/incallui/CallList.java index 8c5b467ec..7e3ec21e4 100644 --- a/InCallUI/src/com/android/incallui/CallList.java +++ b/InCallUI/src/com/android/incallui/CallList.java @@ -22,7 +22,7 @@ import com.google.common.base.Preconditions; import android.os.Handler; import android.os.Message; -import android.telecomm.Phone; +import android.telecom.Phone; import android.telephony.DisconnectCause; import java.util.Collections; @@ -48,7 +48,7 @@ public class CallList implements InCallPhoneListener { private static CallList sInstance = new CallList(); private final HashMap mCallById = new HashMap<>(); - private final HashMap mCallByTelecommCall = new HashMap<>(); + private final HashMap mCallByTelecommCall = new HashMap<>(); private final HashMap> mCallTextReponsesMap = Maps.newHashMap(); /** * ConcurrentHashMap constructor params: 8 is initial table size, 0.9f is @@ -71,7 +71,7 @@ public class CallList implements InCallPhoneListener { private Phone.Listener mPhoneListener = new Phone.Listener() { @Override - public void onCallAdded(Phone phone, android.telecomm.Call telecommCall) { + public void onCallAdded(Phone phone, android.telecom.Call telecommCall) { Call call = new Call(telecommCall); if (call.getState() == Call.State.INCOMING) { onIncoming(call, call.getCannedSmsResponses()); @@ -80,7 +80,7 @@ public class CallList implements InCallPhoneListener { } } @Override - public void onCallRemoved(Phone phone, android.telecomm.Call telecommCall) { + public void onCallRemoved(Phone phone, android.telecom.Call telecommCall) { if (mCallByTelecommCall.containsKey(telecommCall)) { Call call = mCallByTelecommCall.get(telecommCall); call.setState(Call.State.DISCONNECTED); @@ -313,7 +313,7 @@ public class CallList implements InCallPhoneListener { return mCallById.get(callId); } - public Call getCallByTelecommCall(android.telecomm.Call telecommCall) { + public Call getCallByTelecommCall(android.telecom.Call telecommCall) { return mCallByTelecommCall.get(telecommCall); } diff --git a/InCallUI/src/com/android/incallui/CallerInfoUtils.java b/InCallUI/src/com/android/incallui/CallerInfoUtils.java index cc38a0e96..9fd45e413 100644 --- a/InCallUI/src/com/android/incallui/CallerInfoUtils.java +++ b/InCallUI/src/com/android/incallui/CallerInfoUtils.java @@ -4,8 +4,8 @@ import android.content.Context; import android.content.Loader; import android.content.Loader.OnLoadCompleteListener; import android.net.Uri; -import android.telecomm.PhoneAccount; -import android.telecomm.TelecommManager; +import android.telecom.PhoneAccount; +import android.telecom.TelecomManager; import android.text.TextUtils; import android.util.Log; @@ -41,7 +41,7 @@ public class CallerInfoUtils { // TODO: Have phoneapp send a Uri when it knows the contact that triggered this call. - if (info.numberPresentation == TelecommManager.PRESENTATION_ALLOWED) { + if (info.numberPresentation == TelecomManager.PRESENTATION_ALLOWED) { // Start the query with the number provided from the call. Log.d(TAG, "==> Actually starting CallerInfoAsyncQuery.startQuery()..."); CallerInfoAsyncQuery.startQuery(QUERY_TOKEN, context, info, listener, call); @@ -107,9 +107,9 @@ public class CallerInfoUtils { final String[] absentNumberValues = context.getResources().getStringArray(R.array.absent_num); if (Arrays.asList(absentNumberValues).contains(number) - && presentation == TelecommManager.PRESENTATION_ALLOWED) { + && presentation == TelecomManager.PRESENTATION_ALLOWED) { number = context.getString(R.string.unknown); - ci.numberPresentation = TelecommManager.PRESENTATION_UNKNOWN; + ci.numberPresentation = TelecomManager.PRESENTATION_UNKNOWN; } // Check for other special "corner cases" for CNAP and fix them similarly. Corner @@ -117,16 +117,16 @@ public class CallerInfoUtils { // if we think we have an allowed presentation, or if the CallerInfo presentation doesn't // match the presentation passed in for verification (meaning we changed it previously // because it's a corner case and we're being called from a different entry point). - if (ci.numberPresentation == TelecommManager.PRESENTATION_ALLOWED + if (ci.numberPresentation == TelecomManager.PRESENTATION_ALLOWED || (ci.numberPresentation != presentation - && presentation == TelecommManager.PRESENTATION_ALLOWED)) { + && presentation == TelecomManager.PRESENTATION_ALLOWED)) { // For all special strings, change number & numberPrentation. if (isCnapSpecialCaseRestricted(number)) { number = context.getString(R.string.private_num); - ci.numberPresentation = TelecommManager.PRESENTATION_RESTRICTED; + ci.numberPresentation = TelecomManager.PRESENTATION_RESTRICTED; } else if (isCnapSpecialCaseUnknown(number)) { number = context.getString(R.string.unknown); - ci.numberPresentation = TelecommManager.PRESENTATION_UNKNOWN; + ci.numberPresentation = TelecomManager.PRESENTATION_UNKNOWN; } Log.d(TAG, "SpecialCnap: number=" + toLogSafePhoneNumber(number) + "; presentation now=" + ci.numberPresentation); diff --git a/InCallUI/src/com/android/incallui/ConferenceManagerPresenter.java b/InCallUI/src/com/android/incallui/ConferenceManagerPresenter.java index ba01e7597..269f37d9c 100644 --- a/InCallUI/src/com/android/incallui/ConferenceManagerPresenter.java +++ b/InCallUI/src/com/android/incallui/ConferenceManagerPresenter.java @@ -18,7 +18,7 @@ package com.android.incallui; import android.content.Context; import android.net.Uri; -import android.telecomm.PhoneCapabilities; +import android.telecom.PhoneCapabilities; import android.text.TextUtils; import com.android.incallui.ContactInfoCache.ContactCacheEntry; @@ -166,13 +166,13 @@ public class ConferenceManagerPresenter public void separateConferenceConnection(int rowId) { if (rowId < mCallerIds.length) { - TelecommAdapter.getInstance().separateCall(mCallerIds[rowId]); + TelecomAdapter.getInstance().separateCall(mCallerIds[rowId]); } } public void endConferenceConnection(int rowId) { if (rowId < mCallerIds.length) { - TelecommAdapter.getInstance().disconnectCall(mCallerIds[rowId]); + TelecomAdapter.getInstance().disconnectCall(mCallerIds[rowId]); } } diff --git a/InCallUI/src/com/android/incallui/ContactInfoCache.java b/InCallUI/src/com/android/incallui/ContactInfoCache.java index 570b2de4f..4623c3b0f 100644 --- a/InCallUI/src/com/android/incallui/ContactInfoCache.java +++ b/InCallUI/src/com/android/incallui/ContactInfoCache.java @@ -24,7 +24,7 @@ import android.net.Uri; import android.os.Looper; import android.provider.ContactsContract.Contacts; import android.provider.ContactsContract.CommonDataKinds.Phone; -import android.telecomm.TelecommManager; +import android.telecom.TelecomManager; import android.text.TextUtils; import com.android.contacts.common.util.PhoneNumberHelper; @@ -153,7 +153,7 @@ public class ContactInfoCache implements ContactsAsyncHelper.OnImageLoadComplete int presentationMode = call.getNumberPresentation(); if (callerInfo.contactExists || callerInfo.isEmergencyNumber() || callerInfo.isVoiceMailNumber()) { - presentationMode = TelecommManager.PRESENTATION_ALLOWED; + presentationMode = TelecomManager.PRESENTATION_ALLOWED; } final ContactCacheEntry cacheEntry = buildEntry(mContext, callId, @@ -389,7 +389,7 @@ public class ContactInfoCache implements ContactsAsyncHelper.OnImageLoadComplete // (or potentially some other default based on the presentation.) displayName = getPresentationString(context, presentation); Log.d(TAG, " ==> no name *or* number! displayName = " + displayName); - } else if (presentation != TelecommManager.PRESENTATION_ALLOWED) { + } else if (presentation != TelecomManager.PRESENTATION_ALLOWED) { // This case should never happen since the network should never send a phone # // AND a restricted presentation. However we leave it here in case of weird // network behavior @@ -426,7 +426,7 @@ public class ContactInfoCache implements ContactsAsyncHelper.OnImageLoadComplete } else { // We do have a valid "name" in the CallerInfo. Display that // in the "name" slot, and the phone number in the "number" slot. - if (presentation != TelecommManager.PRESENTATION_ALLOWED) { + if (presentation != TelecomManager.PRESENTATION_ALLOWED) { // This case should never happen since the network should never send a name // AND a restricted presentation. However we leave it here in case of weird // network behavior @@ -479,9 +479,9 @@ public class ContactInfoCache implements ContactsAsyncHelper.OnImageLoadComplete */ private static String getPresentationString(Context context, int presentation) { String name = context.getString(R.string.unknown); - if (presentation == TelecommManager.PRESENTATION_RESTRICTED) { + if (presentation == TelecomManager.PRESENTATION_RESTRICTED) { name = context.getString(R.string.private_num); - } else if (presentation == TelecommManager.PRESENTATION_PAYPHONE) { + } else if (presentation == TelecomManager.PRESENTATION_PAYPHONE) { name = context.getString(R.string.payphone); } return name; diff --git a/InCallUI/src/com/android/incallui/DialpadPresenter.java b/InCallUI/src/com/android/incallui/DialpadPresenter.java index c36ead7a8..d76e6e9b7 100644 --- a/InCallUI/src/com/android/incallui/DialpadPresenter.java +++ b/InCallUI/src/com/android/incallui/DialpadPresenter.java @@ -61,7 +61,7 @@ public class DialpadPresenter extends Presenter // Append this key to the "digits" widget. getUi().appendDigitsToField(c); // Plays the tone through Telecomm. - TelecommAdapter.getInstance().playDtmfTone(mCall.getId(), c); + TelecomAdapter.getInstance().playDtmfTone(mCall.getId(), c); } else { Log.d(this, "ignoring dtmf request for '" + c + "'"); } @@ -73,7 +73,7 @@ public class DialpadPresenter extends Presenter public void stopDtmf() { if (mCall != null) { Log.d(this, "stopping remote tone"); - TelecommAdapter.getInstance().stopDtmfTone(mCall.getId()); + TelecomAdapter.getInstance().stopDtmfTone(mCall.getId()); } } diff --git a/InCallUI/src/com/android/incallui/GlowPadWrapper.java b/InCallUI/src/com/android/incallui/GlowPadWrapper.java index 1a14f0b84..47547125b 100644 --- a/InCallUI/src/com/android/incallui/GlowPadWrapper.java +++ b/InCallUI/src/com/android/incallui/GlowPadWrapper.java @@ -19,7 +19,7 @@ package com.android.incallui; import android.content.Context; import android.os.Handler; import android.os.Message; -import android.telecomm.VideoProfile; +import android.telecom.VideoProfile; import android.util.AttributeSet; import android.view.View; diff --git a/InCallUI/src/com/android/incallui/InCallActivity.java b/InCallUI/src/com/android/incallui/InCallActivity.java index db161a563..f4f8ca602 100644 --- a/InCallUI/src/com/android/incallui/InCallActivity.java +++ b/InCallUI/src/com/android/incallui/InCallActivity.java @@ -32,7 +32,6 @@ import android.os.Bundle; import android.telephony.DisconnectCause; import android.text.TextUtils; import android.view.MenuItem; -import android.view.ViewTreeObserver; import android.view.animation.Animation; import android.view.animation.AnimationUtils; import android.view.KeyEvent; @@ -380,7 +379,7 @@ public class InCallActivity extends Activity { case KeyEvent.KEYCODE_MUTE: // toggle mute - TelecommAdapter.getInstance().mute(!AudioModeProvider.getInstance().getMute()); + TelecomAdapter.getInstance().mute(!AudioModeProvider.getInstance().getMute()); return true; // Various testing/debugging features, enabled ONLY when VERBOSE == true. @@ -515,7 +514,7 @@ public class InCallActivity extends Activity { // wants to use the dialpad toward the exact line, so un-hold the holding line. final Call call = CallList.getInstance().getActiveOrBackgroundCall(); if (call != null && call.getState() == State.ONHOLD) { - TelecommAdapter.getInstance().unholdCall(call.getId()); + TelecomAdapter.getInstance().unholdCall(call.getId()); } } } diff --git a/InCallUI/src/com/android/incallui/InCallApp.java b/InCallUI/src/com/android/incallui/InCallApp.java index d645ca110..d6f4f42de 100644 --- a/InCallUI/src/com/android/incallui/InCallApp.java +++ b/InCallUI/src/com/android/incallui/InCallApp.java @@ -21,7 +21,7 @@ import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; import android.content.res.Configuration; -import android.telecomm.VideoProfile; +import android.telecom.VideoProfile; /** * Top-level Application class for the InCall app. diff --git a/InCallUI/src/com/android/incallui/InCallPhoneListener.java b/InCallUI/src/com/android/incallui/InCallPhoneListener.java index c2be3e6f8..2fd6afe22 100644 --- a/InCallUI/src/com/android/incallui/InCallPhoneListener.java +++ b/InCallUI/src/com/android/incallui/InCallPhoneListener.java @@ -16,7 +16,7 @@ package com.android.incallui; -import android.telecomm.Phone; +import android.telecom.Phone; /** * Interface implemented by In-Call components that maintain a reference to the Telecomm API diff --git a/InCallUI/src/com/android/incallui/InCallPresenter.java b/InCallUI/src/com/android/incallui/InCallPresenter.java index ad78708cc..241056d89 100644 --- a/InCallUI/src/com/android/incallui/InCallPresenter.java +++ b/InCallUI/src/com/android/incallui/InCallPresenter.java @@ -21,10 +21,10 @@ import android.app.PendingIntent; import android.content.Context; import android.content.Intent; import android.content.pm.ActivityInfo; -import android.telecomm.PhoneCapabilities; -import android.telecomm.Phone; -import android.telecomm.PhoneAccountHandle; -import android.telecomm.VideoProfile; +import android.telecom.PhoneCapabilities; +import android.telecom.Phone; +import android.telecom.PhoneAccountHandle; +import android.telecom.VideoProfile; import android.text.TextUtils; import android.view.Surface; import android.view.View; @@ -90,27 +90,27 @@ public class InCallPresenter implements CallList.Listener, InCallPhoneListener { bringToForeground(showDialpad); } @Override - public void onCallAdded(Phone phone, android.telecomm.Call call) { + public void onCallAdded(Phone phone, android.telecom.Call call) { call.addListener(mCallListener); } @Override - public void onCallRemoved(Phone phone, android.telecomm.Call call) { + public void onCallRemoved(Phone phone, android.telecom.Call call) { call.removeListener(mCallListener); } }; - private final android.telecomm.Call.Listener mCallListener = - new android.telecomm.Call.Listener() { + private final android.telecom.Call.Listener mCallListener = + new android.telecom.Call.Listener() { @Override - public void onPostDialWait(android.telecomm.Call call, String remainingPostDialSequence) { + public void onPostDialWait(android.telecom.Call call, String remainingPostDialSequence) { onPostDialCharWait( CallList.getInstance().getCallByTelecommCall(call).getId(), remainingPostDialSequence); } @Override - public void onDetailsChanged(android.telecomm.Call call, - android.telecomm.Call.Details details) { + public void onDetailsChanged(android.telecom.Call call, + android.telecom.Call.Details details) { for (InCallDetailsListener listener : mDetailsListeners) { listener.onDetailsChanged(CallList.getInstance().getCallByTelecommCall(call), details); @@ -119,7 +119,7 @@ public class InCallPresenter implements CallList.Listener, InCallPhoneListener { @Override public void onConferenceableCallsChanged( - android.telecomm.Call call, List conferenceableCalls) { + android.telecom.Call call, List conferenceableCalls) { Log.i(this, "onConferenceableCallsChanged: " + call); for (InCallDetailsListener listener : mDetailsListeners) { listener.onDetailsChanged(CallList.getInstance().getCallByTelecommCall(call), @@ -462,7 +462,7 @@ public class InCallPresenter implements CallList.Listener, InCallPhoneListener { Call call = mCallList.getWaitingForAccountCall(); if (call != null) { String callId = call.getId(); - TelecommAdapter.getInstance().phoneAccountSelected(callId, accountHandle); + TelecomAdapter.getInstance().phoneAccountSelected(callId, accountHandle); } } @@ -471,7 +471,7 @@ public class InCallPresenter implements CallList.Listener, InCallPhoneListener { Call call = mCallList.getWaitingForAccountCall(); if (call != null) { String callId = call.getId(); - TelecommAdapter.getInstance().disconnectCall(callId); + TelecomAdapter.getInstance().disconnectCall(callId); } } @@ -496,7 +496,7 @@ public class InCallPresenter implements CallList.Listener, InCallPhoneListener { } if (call != null) { - TelecommAdapter.getInstance().disconnectCall(call.getId()); + TelecomAdapter.getInstance().disconnectCall(call.getId()); } } @@ -513,7 +513,7 @@ public class InCallPresenter implements CallList.Listener, InCallPhoneListener { Call call = mCallList.getIncomingCall(); if (call != null) { - TelecommAdapter.getInstance().answerCall(call.getId(), videoState); + TelecomAdapter.getInstance().answerCall(call.getId(), videoState); showInCall(false, false/* newOutgoingCall */); } } @@ -531,7 +531,7 @@ public class InCallPresenter implements CallList.Listener, InCallPhoneListener { Call call = mCallList.getIncomingCall(); if (call != null) { - TelecommAdapter.getInstance().rejectCall(call.getId(), false, null); + TelecomAdapter.getInstance().rejectCall(call.getId(), false, null); } } @@ -654,7 +654,7 @@ public class InCallPresenter implements CallList.Listener, InCallPhoneListener { // (1) Attempt to answer a call if (incomingCall != null) { - TelecommAdapter.getInstance().answerCall( + TelecomAdapter.getInstance().answerCall( incomingCall.getId(), VideoProfile.VideoState.AUDIO_ONLY); return true; } @@ -674,10 +674,10 @@ public class InCallPresenter implements CallList.Listener, InCallPhoneListener { // (2) Attempt actions on conference calls if (canMerge) { - TelecommAdapter.getInstance().merge(activeCall.getId()); + TelecomAdapter.getInstance().merge(activeCall.getId()); return true; } else if (canSwap) { - TelecommAdapter.getInstance().swap(activeCall.getId()); + TelecomAdapter.getInstance().swap(activeCall.getId()); return true; } } @@ -695,7 +695,7 @@ public class InCallPresenter implements CallList.Listener, InCallPhoneListener { // (4) unhold call if (heldCall.getState() == Call.State.ONHOLD && canHold) { - TelecommAdapter.getInstance().unholdCall(heldCall.getId()); + TelecomAdapter.getInstance().unholdCall(heldCall.getId()); return true; } } @@ -1094,7 +1094,7 @@ public class InCallPresenter implements CallList.Listener, InCallPhoneListener { } public interface InCallDetailsListener { - public void onDetailsChanged(Call call, android.telecomm.Call.Details details); + public void onDetailsChanged(Call call, android.telecom.Call.Details details); } public interface InCallOrientationListener { diff --git a/InCallUI/src/com/android/incallui/InCallServiceImpl.java b/InCallUI/src/com/android/incallui/InCallServiceImpl.java index f19220199..37e16a3bf 100644 --- a/InCallUI/src/com/android/incallui/InCallServiceImpl.java +++ b/InCallUI/src/com/android/incallui/InCallServiceImpl.java @@ -16,11 +16,8 @@ package com.android.incallui; -import android.app.Service; -import android.content.Intent; -import android.os.IBinder; -import android.telecomm.InCallService; -import android.telecomm.Phone; +import android.telecom.InCallService; +import android.telecom.Phone; /** * Used to receive updates about calls from the Telecomm component. This service is bound to @@ -35,13 +32,13 @@ public class InCallServiceImpl extends InCallService { Log.v(this, "onPhoneCreated"); CallList.getInstance().setPhone(phone); AudioModeProvider.getInstance().setPhone(phone); - TelecommAdapter.getInstance().setPhone(phone); + TelecomAdapter.getInstance().setPhone(phone); InCallPresenter.getInstance().setPhone(phone); InCallPresenter.getInstance().setUp( getApplicationContext(), CallList.getInstance(), AudioModeProvider.getInstance()); - TelecommAdapter.getInstance().setContext(InCallServiceImpl.this); + TelecomAdapter.getInstance().setContext(InCallServiceImpl.this); } @Override @@ -50,8 +47,8 @@ public class InCallServiceImpl extends InCallService { // Tear down the InCall system CallList.getInstance().clearPhone(); AudioModeProvider.getInstance().clearPhone(); - TelecommAdapter.getInstance().clearPhone(); - TelecommAdapter.getInstance().setContext(null); + TelecomAdapter.getInstance().clearPhone(); + TelecomAdapter.getInstance().setContext(null); CallList.getInstance().clearOnDisconnect(); InCallPresenter.getInstance().tearDown(); } diff --git a/InCallUI/src/com/android/incallui/InCallVideoCallListener.java b/InCallUI/src/com/android/incallui/InCallVideoCallListener.java index 62817d29c..363bd4144 100644 --- a/InCallUI/src/com/android/incallui/InCallVideoCallListener.java +++ b/InCallUI/src/com/android/incallui/InCallVideoCallListener.java @@ -16,10 +16,10 @@ package com.android.incallui; -import android.telecomm.CameraCapabilities; -import android.telecomm.Connection; -import android.telecomm.InCallService.VideoCall; -import android.telecomm.VideoProfile; +import android.telecom.CameraCapabilities; +import android.telecom.Connection; +import android.telecom.InCallService.VideoCall; +import android.telecom.VideoProfile; /** * Implements the InCallUI Video Call Listener. diff --git a/InCallUI/src/com/android/incallui/Log.java b/InCallUI/src/com/android/incallui/Log.java index f609c549c..5e13c790b 100644 --- a/InCallUI/src/com/android/incallui/Log.java +++ b/InCallUI/src/com/android/incallui/Log.java @@ -17,7 +17,7 @@ package com.android.incallui; import android.net.Uri; -import android.telecomm.PhoneAccount; +import android.telecom.PhoneAccount; import android.telephony.PhoneNumberUtils; import java.security.MessageDigest; diff --git a/InCallUI/src/com/android/incallui/PostCharDialogFragment.java b/InCallUI/src/com/android/incallui/PostCharDialogFragment.java index 5925acee7..e1edbc75b 100644 --- a/InCallUI/src/com/android/incallui/PostCharDialogFragment.java +++ b/InCallUI/src/com/android/incallui/PostCharDialogFragment.java @@ -16,7 +16,6 @@ package com.android.incallui; -import android.app.Activity; import android.app.AlertDialog; import android.app.Dialog; import android.app.DialogFragment; @@ -52,7 +51,7 @@ public class PostCharDialogFragment extends DialogFragment { builder.setPositiveButton(R.string.pause_prompt_yes, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int whichButton) { - TelecommAdapter.getInstance().postDialContinue(mCallId, true); + TelecomAdapter.getInstance().postDialContinue(mCallId, true); } }); builder.setNegativeButton(R.string.pause_prompt_no, new DialogInterface.OnClickListener() { @@ -71,6 +70,6 @@ public class PostCharDialogFragment extends DialogFragment { public void onCancel(DialogInterface dialog) { super.onCancel(dialog); - TelecommAdapter.getInstance().postDialContinue(mCallId, false); + TelecomAdapter.getInstance().postDialContinue(mCallId, false); } } diff --git a/InCallUI/src/com/android/incallui/ProximitySensor.java b/InCallUI/src/com/android/incallui/ProximitySensor.java index 5bde190c1..5b9a5eca7 100644 --- a/InCallUI/src/com/android/incallui/ProximitySensor.java +++ b/InCallUI/src/com/android/incallui/ProximitySensor.java @@ -19,7 +19,7 @@ package com.android.incallui; import android.content.Context; import android.content.res.Configuration; import android.os.PowerManager; -import android.telecomm.AudioState; +import android.telecom.AudioState; import com.android.incallui.AudioModeProvider.AudioModeListener; import com.android.incallui.InCallPresenter.InCallState; @@ -63,7 +63,7 @@ public class ProximitySensor implements AccelerometerListener.OrientationListene mAccelerometerListener.enable(false); - TelecommAdapter.getInstance().turnOffProximitySensor(true); + TelecomAdapter.getInstance().turnOffProximitySensor(true); } /** @@ -210,12 +210,12 @@ public class ProximitySensor implements AccelerometerListener.OrientationListene Log.d(this, "Turning on proximity sensor"); // Phone is in use! Arrange for the screen to turn off // automatically when the sensor detects a close object. - TelecommAdapter.getInstance().turnOnProximitySensor(); + TelecomAdapter.getInstance().turnOnProximitySensor(); } else { Log.d(this, "Turning off proximity sensor"); // Phone is either idle, or ringing. We don't want any special proximity sensor // behavior in either case. - TelecommAdapter.getInstance().turnOffProximitySensor(screenOnImmediately); + TelecomAdapter.getInstance().turnOffProximitySensor(screenOnImmediately); } } } diff --git a/InCallUI/src/com/android/incallui/SelectPhoneAccountDialogFragment.java b/InCallUI/src/com/android/incallui/SelectPhoneAccountDialogFragment.java index d44047d67..aeb14dfbf 100644 --- a/InCallUI/src/com/android/incallui/SelectPhoneAccountDialogFragment.java +++ b/InCallUI/src/com/android/incallui/SelectPhoneAccountDialogFragment.java @@ -16,8 +16,8 @@ package com.android.incallui; -import android.telecomm.PhoneAccount; -import android.telecomm.PhoneAccountHandle; +import android.telecom.PhoneAccount; +import android.telecom.PhoneAccountHandle; import android.app.AlertDialog; import android.app.Dialog; @@ -26,7 +26,7 @@ import android.app.FragmentManager; import android.content.Context; import android.content.DialogInterface; import android.os.Bundle; -import android.telecomm.TelecommManager; +import android.telecom.TelecomManager; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; @@ -36,7 +36,6 @@ import android.widget.ListAdapter; import android.widget.TextView; import com.android.contacts.common.R; -import com.android.contacts.common.editor.SelectAccountDialogFragment; import java.util.List; @@ -46,7 +45,7 @@ import java.util.List; public class SelectPhoneAccountDialogFragment extends DialogFragment { private List mAccountHandles; private boolean mIsSelected; - private TelecommManager mTelecommManager; + private TelecomManager mTelecomManager; private final String mUriScheme; /** @@ -69,9 +68,9 @@ public class SelectPhoneAccountDialogFragment extends DialogFragment { @Override public Dialog onCreateDialog(Bundle savedInstanceState) { mIsSelected = false; - mTelecommManager = - (TelecommManager) getActivity().getSystemService(Context.TELECOMM_SERVICE); - mAccountHandles = mTelecommManager.getPhoneAccountsSupportingScheme(mUriScheme); + mTelecomManager = + (TelecomManager) getActivity().getSystemService(Context.TELECOM_SERVICE); + mAccountHandles = mTelecomManager.getPhoneAccountsSupportingScheme(mUriScheme); final DialogInterface.OnClickListener selectionListener = new DialogInterface.OnClickListener() { @@ -128,7 +127,7 @@ public class SelectPhoneAccountDialogFragment extends DialogFragment { } PhoneAccountHandle accountHandle = getItem(position); - PhoneAccount account = mTelecommManager.getPhoneAccount(accountHandle); + PhoneAccount account = mTelecomManager.getPhoneAccount(accountHandle); holder.textView.setText(account.getLabel()); holder.imageView.setImageDrawable(account.getIcon(mContext)); return rowView; diff --git a/InCallUI/src/com/android/incallui/StatusBarNotifier.java b/InCallUI/src/com/android/incallui/StatusBarNotifier.java index 752283646..4fa9c39ff 100644 --- a/InCallUI/src/com/android/incallui/StatusBarNotifier.java +++ b/InCallUI/src/com/android/incallui/StatusBarNotifier.java @@ -29,7 +29,7 @@ import android.graphics.BitmapFactory; import android.graphics.drawable.BitmapDrawable; import android.os.Handler; import android.os.Message; -import android.telecomm.PhoneAccount; +import android.telecom.PhoneAccount; import android.text.TextUtils; import com.android.incallui.ContactInfoCache.ContactCacheEntry; diff --git a/InCallUI/src/com/android/incallui/TelecomAdapter.java b/InCallUI/src/com/android/incallui/TelecomAdapter.java new file mode 100644 index 000000000..5f32c7e47 --- /dev/null +++ b/InCallUI/src/com/android/incallui/TelecomAdapter.java @@ -0,0 +1,235 @@ +/* + * Copyright (C) 2014 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; + +import android.content.ActivityNotFoundException; +import android.content.Context; +import android.content.Intent; +import android.os.Looper; +import android.telecom.InCallAdapter; +import android.telecom.Phone; +import android.telecom.PhoneAccountHandle; + +import android.telecom.PhoneCapabilities; + +import com.google.common.base.Preconditions; + +import java.util.List; + +/** Wrapper around {@link InCallAdapter} that only forwards calls to the adapter when it's valid. */ +final class TelecomAdapter implements InCallPhoneListener { + private static final String ADD_CALL_MODE_KEY = "add_call_mode"; + + private static TelecomAdapter sInstance; + private Context mContext; + private Phone mPhone; + + static TelecomAdapter getInstance() { + Preconditions.checkState(Looper.getMainLooper().getThread() == Thread.currentThread()); + if (sInstance == null) { + sInstance = new TelecomAdapter(); + } + return sInstance; + } + + private TelecomAdapter() { + } + + void setContext(Context context) { + mContext = context; + } + + @Override + public void setPhone(Phone phone) { + mPhone = phone; + } + + @Override + public void clearPhone() { + mPhone = null; + } + + private android.telecom.Call getTelecommCallById(String callId) { + return CallList.getInstance().getCallById(callId).getTelecommCall(); + } + + void answerCall(String callId, int videoState) { + if (mPhone != null) { + getTelecommCallById(callId).answer(videoState); + } else { + Log.e(this, "error answerCall, mPhone is null"); + } + } + + void rejectCall(String callId, boolean rejectWithMessage, String message) { + if (mPhone != null) { + getTelecommCallById(callId).reject(rejectWithMessage, message); + } else { + Log.e(this, "error rejectCall, mPhone is null"); + } + } + + void disconnectCall(String callId) { + if (mPhone != null) { + getTelecommCallById(callId).disconnect(); + } else { + Log.e(this, "error disconnectCall, mPhone is null"); + } + } + + void holdCall(String callId) { + if (mPhone != null) { + getTelecommCallById(callId).hold(); + } else { + Log.e(this, "error holdCall, mPhone is null"); + } + } + + void unholdCall(String callId) { + if (mPhone != null) { + getTelecommCallById(callId).unhold(); + } else { + Log.e(this, "error unholdCall, mPhone is null"); + } + } + + void mute(boolean shouldMute) { + if (mPhone != null) { + mPhone.setMuted(shouldMute); + } else { + Log.e(this, "error mute, mPhone is null"); + } + } + + void setAudioRoute(int route) { + if (mPhone != null) { + mPhone.setAudioRoute(route); + } else { + Log.e(this, "error setAudioRoute, mPhone is null"); + } + } + + void turnOnProximitySensor() { + if (mPhone != null) { + mPhone.setProximitySensorOn(); + } else { + Log.e(this, "error setProximitySensorOn, mPhone is null"); + } + } + + void turnOffProximitySensor(boolean screenOnImmediately) { + if (mPhone != null) { + mPhone.setProximitySensorOff(screenOnImmediately); + } else { + Log.e(this, "error setProximitySensorOff, mPhone is null"); + } + } + + void separateCall(String callId) { + if (mPhone != null) { + getTelecommCallById(callId).splitFromConference(); + } else { + Log.e(this, "error separateCall, mPhone is null."); + } + } + + void merge(String callId) { + if (mPhone != null) { + android.telecom.Call call = getTelecommCallById(callId); + List conferenceable = call.getConferenceableCalls(); + if (!conferenceable.isEmpty()) { + call.conference(conferenceable.get(0)); + } else { + int capabilities = call.getDetails().getCallCapabilities(); + if (0 != (capabilities & PhoneCapabilities.MERGE_CONFERENCE)) { + call.mergeConference(); + } + } + } else { + Log.e(this, "error merge, mPhone is null."); + } + } + + void swap(String callId) { + if (mPhone != null) { + android.telecom.Call call = getTelecommCallById(callId); + int capabilities = call.getDetails().getCallCapabilities(); + if (0 != (capabilities & PhoneCapabilities.SWAP_CONFERENCE)) { + call.swapConference(); + } + } else { + Log.e(this, "Error swap, mPhone is null."); + } + } + + void addCall() { + if (mContext != null) { + Intent intent = new Intent(Intent.ACTION_DIAL); + intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); + + // when we request the dialer come up, we also want to inform + // it that we're going through the "add call" option from the + // InCallScreen / PhoneUtils. + intent.putExtra(ADD_CALL_MODE_KEY, true); + try { + Log.d(this, "Sending the add Call intent"); + mContext.startActivity(intent); + } catch (ActivityNotFoundException e) { + // This is rather rare but possible. + // Note: this method is used even when the phone is encrypted. At that moment + // the system may not find any Activity which can accept this Intent. + Log.e(this, "Activity for adding calls isn't found.", e); + } + } + } + + void playDtmfTone(String callId, char digit) { + if (mPhone != null) { + getTelecommCallById(callId).playDtmfTone(digit); + } else { + Log.e(this, "error playDtmfTone, mPhone is null"); + } + } + + void stopDtmfTone(String callId) { + if (mPhone != null) { + getTelecommCallById(callId).stopDtmfTone(); + } else { + Log.e(this, "error stopDtmfTone, mPhone is null"); + } + } + + void postDialContinue(String callId, boolean proceed) { + if (mPhone != null) { + getTelecommCallById(callId).postDialContinue(proceed); + } else { + Log.e(this, "error postDialContinue, mPhone is null"); + } + } + + void phoneAccountSelected(String callId, PhoneAccountHandle accountHandle) { + if (mPhone != null) { + getTelecommCallById(callId).phoneAccountSelected(accountHandle); + } else { + Log.e(this, "error phoneAccountSelected, mAdapter is null"); + } + + if (accountHandle == null) { + Log.e(this, "error phoneAccountSelected, accountHandle is null"); + } + } +} diff --git a/InCallUI/src/com/android/incallui/TelecommAdapter.java b/InCallUI/src/com/android/incallui/TelecommAdapter.java deleted file mode 100644 index bf7f51d07..000000000 --- a/InCallUI/src/com/android/incallui/TelecommAdapter.java +++ /dev/null @@ -1,235 +0,0 @@ -/* - * Copyright (C) 2014 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; - -import android.content.ActivityNotFoundException; -import android.content.Context; -import android.content.Intent; -import android.os.Looper; -import android.telecomm.InCallAdapter; -import android.telecomm.Phone; -import android.telecomm.PhoneAccountHandle; - -import android.telecomm.PhoneCapabilities; - -import com.google.common.base.Preconditions; - -import java.util.List; - -/** Wrapper around {@link InCallAdapter} that only forwards calls to the adapter when it's valid. */ -final class TelecommAdapter implements InCallPhoneListener { - private static final String ADD_CALL_MODE_KEY = "add_call_mode"; - - private static TelecommAdapter sInstance; - private Context mContext; - private Phone mPhone; - - static TelecommAdapter getInstance() { - Preconditions.checkState(Looper.getMainLooper().getThread() == Thread.currentThread()); - if (sInstance == null) { - sInstance = new TelecommAdapter(); - } - return sInstance; - } - - private TelecommAdapter() { - } - - void setContext(Context context) { - mContext = context; - } - - @Override - public void setPhone(Phone phone) { - mPhone = phone; - } - - @Override - public void clearPhone() { - mPhone = null; - } - - private android.telecomm.Call getTelecommCallById(String callId) { - return CallList.getInstance().getCallById(callId).getTelecommCall(); - } - - void answerCall(String callId, int videoState) { - if (mPhone != null) { - getTelecommCallById(callId).answer(videoState); - } else { - Log.e(this, "error answerCall, mPhone is null"); - } - } - - void rejectCall(String callId, boolean rejectWithMessage, String message) { - if (mPhone != null) { - getTelecommCallById(callId).reject(rejectWithMessage, message); - } else { - Log.e(this, "error rejectCall, mPhone is null"); - } - } - - void disconnectCall(String callId) { - if (mPhone != null) { - getTelecommCallById(callId).disconnect(); - } else { - Log.e(this, "error disconnectCall, mPhone is null"); - } - } - - void holdCall(String callId) { - if (mPhone != null) { - getTelecommCallById(callId).hold(); - } else { - Log.e(this, "error holdCall, mPhone is null"); - } - } - - void unholdCall(String callId) { - if (mPhone != null) { - getTelecommCallById(callId).unhold(); - } else { - Log.e(this, "error unholdCall, mPhone is null"); - } - } - - void mute(boolean shouldMute) { - if (mPhone != null) { - mPhone.setMuted(shouldMute); - } else { - Log.e(this, "error mute, mPhone is null"); - } - } - - void setAudioRoute(int route) { - if (mPhone != null) { - mPhone.setAudioRoute(route); - } else { - Log.e(this, "error setAudioRoute, mPhone is null"); - } - } - - void turnOnProximitySensor() { - if (mPhone != null) { - mPhone.setProximitySensorOn(); - } else { - Log.e(this, "error setProximitySensorOn, mPhone is null"); - } - } - - void turnOffProximitySensor(boolean screenOnImmediately) { - if (mPhone != null) { - mPhone.setProximitySensorOff(screenOnImmediately); - } else { - Log.e(this, "error setProximitySensorOff, mPhone is null"); - } - } - - void separateCall(String callId) { - if (mPhone != null) { - getTelecommCallById(callId).splitFromConference(); - } else { - Log.e(this, "error separateCall, mPhone is null."); - } - } - - void merge(String callId) { - if (mPhone != null) { - android.telecomm.Call call = getTelecommCallById(callId); - List conferenceable = call.getConferenceableCalls(); - if (!conferenceable.isEmpty()) { - call.conference(conferenceable.get(0)); - } else { - int capabilities = call.getDetails().getCallCapabilities(); - if (0 != (capabilities & PhoneCapabilities.MERGE_CONFERENCE)) { - call.mergeConference(); - } - } - } else { - Log.e(this, "error merge, mPhone is null."); - } - } - - void swap(String callId) { - if (mPhone != null) { - android.telecomm.Call call = getTelecommCallById(callId); - int capabilities = call.getDetails().getCallCapabilities(); - if (0 != (capabilities & PhoneCapabilities.SWAP_CONFERENCE)) { - call.swapConference(); - } - } else { - Log.e(this, "Error swap, mPhone is null."); - } - } - - void addCall() { - if (mContext != null) { - Intent intent = new Intent(Intent.ACTION_DIAL); - intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); - - // when we request the dialer come up, we also want to inform - // it that we're going through the "add call" option from the - // InCallScreen / PhoneUtils. - intent.putExtra(ADD_CALL_MODE_KEY, true); - try { - Log.d(this, "Sending the add Call intent"); - mContext.startActivity(intent); - } catch (ActivityNotFoundException e) { - // This is rather rare but possible. - // Note: this method is used even when the phone is encrypted. At that moment - // the system may not find any Activity which can accept this Intent. - Log.e(this, "Activity for adding calls isn't found.", e); - } - } - } - - void playDtmfTone(String callId, char digit) { - if (mPhone != null) { - getTelecommCallById(callId).playDtmfTone(digit); - } else { - Log.e(this, "error playDtmfTone, mPhone is null"); - } - } - - void stopDtmfTone(String callId) { - if (mPhone != null) { - getTelecommCallById(callId).stopDtmfTone(); - } else { - Log.e(this, "error stopDtmfTone, mPhone is null"); - } - } - - void postDialContinue(String callId, boolean proceed) { - if (mPhone != null) { - getTelecommCallById(callId).postDialContinue(proceed); - } else { - Log.e(this, "error postDialContinue, mPhone is null"); - } - } - - void phoneAccountSelected(String callId, PhoneAccountHandle accountHandle) { - if (mPhone != null) { - getTelecommCallById(callId).phoneAccountSelected(accountHandle); - } else { - Log.e(this, "error phoneAccountSelected, mAdapter is null"); - } - - if (accountHandle == null) { - Log.e(this, "error phoneAccountSelected, accountHandle is null"); - } - } -} diff --git a/InCallUI/src/com/android/incallui/VideoCallPresenter.java b/InCallUI/src/com/android/incallui/VideoCallPresenter.java index 452360554..ed0024126 100644 --- a/InCallUI/src/com/android/incallui/VideoCallPresenter.java +++ b/InCallUI/src/com/android/incallui/VideoCallPresenter.java @@ -19,9 +19,9 @@ package com.android.incallui; import android.content.Context; import android.content.res.Configuration; import android.os.Handler; -import android.telecomm.AudioState; -import android.telecomm.CameraCapabilities; -import android.telecomm.InCallService.VideoCall; +import android.telecom.AudioState; +import android.telecom.CameraCapabilities; +import android.telecom.InCallService.VideoCall; import android.view.Surface; import com.android.contacts.common.CallUtil; @@ -340,7 +340,7 @@ public class VideoCallPresenter extends Presenter