diff options
author | Brandon Maxwell <maxwelb@google.com> | 2015-12-18 23:24:35 +0000 |
---|---|---|
committer | android-build-merger <android-build-merger@google.com> | 2015-12-18 23:24:35 +0000 |
commit | c5fd76acabbc1cec512d1174b703748721476042 (patch) | |
tree | 48b91a79d4d32e2f345f268e5545060b92b9d20e /InCallUI | |
parent | 2480c4ae71a0d18ec22e43a0720ce0ff5bd68a9b (diff) | |
parent | 9b70c293ad0a2bf343a93701a37a5f152c6a4214 (diff) |
Backporting InCallUI so to allow calls on nonOEM devices
am: 376d6c3927
* commit '376d6c3927bb3f86878a60027ec769b21c176033':
Backporting InCallUI so to allow calls on nonOEM devices
Diffstat (limited to 'InCallUI')
5 files changed, 151 insertions, 12 deletions
diff --git a/InCallUI/src/com/android/incallui/Call.java b/InCallUI/src/com/android/incallui/Call.java index 54b0799a0..161c641dd 100644 --- a/InCallUI/src/com/android/incallui/Call.java +++ b/InCallUI/src/com/android/incallui/Call.java @@ -37,6 +37,7 @@ import com.android.contacts.common.compat.SdkVersionOverride; 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; @@ -959,7 +960,7 @@ public class Call { mChildCallIds, getParentId(), this.mTelecomCall.getConferenceableCalls(), - VideoProfile.videoStateToString(mTelecomCall.getDetails().getVideoState()), + VideoProfileCompat.videoStateToString(mTelecomCall.getDetails().getVideoState()), mSessionModificationState, getVideoSettings()); } diff --git a/InCallUI/src/com/android/incallui/CallCardPresenter.java b/InCallUI/src/com/android/incallui/CallCardPresenter.java index 5c9fc40e3..82d83d4f4 100644 --- a/InCallUI/src/com/android/incallui/CallCardPresenter.java +++ b/InCallUI/src/com/android/incallui/CallCardPresenter.java @@ -50,6 +50,7 @@ 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.dialer.compat.telecom.TelecomManagerCompat; import com.android.incalluibind.ObjectFactory; import java.lang.ref.WeakReference; @@ -494,8 +495,10 @@ public class CallCardPresenter extends Presenter<CallCardPresenter.CallCardUi> } } - TelecomManager mgr = InCallPresenter.getInstance().getTelecomManager(); - String simNumber = mgr.getLine1Number(mPrimary.getAccountHandle()); + final String simNumber = TelecomManagerCompat.getLine1Number( + InCallPresenter.getInstance().getTelecomManager(), + InCallPresenter.getInstance().getTelephonyManager(), + mPrimary.getAccountHandle()); if (!showCallbackNumber && PhoneNumberUtils.compare(callbackNumber, simNumber)) { Log.d(this, "Numbers are the same (and callback number is not being forced to show);" + " not showing the callback number"); diff --git a/InCallUI/src/com/android/incallui/CallerInfoUtils.java b/InCallUI/src/com/android/incallui/CallerInfoUtils.java index eab99ea8a..76f2f4f34 100644 --- a/InCallUI/src/com/android/incallui/CallerInfoUtils.java +++ b/InCallUI/src/com/android/incallui/CallerInfoUtils.java @@ -11,6 +11,7 @@ import android.util.Log; import com.android.contacts.common.model.Contact; import com.android.contacts.common.model.ContactLoader; +import com.android.dialer.compat.telecom.TelecomManagerCompat; import java.util.Arrays; @@ -88,10 +89,10 @@ public class CallerInfoUtils { } public static boolean isVoiceMailNumber(Context context, Call call) { - TelecomManager telecomManager = - (TelecomManager) context.getSystemService(Context.TELECOM_SERVICE); - return telecomManager.isVoiceMailNumber( - call.getTelecomCall().getDetails().getAccountHandle(), call.getNumber()); + return TelecomManagerCompat.isVoiceMailNumber( + (TelecomManager) context.getSystemService(Context.TELECOM_SERVICE), + call.getTelecomCall().getDetails().getAccountHandle(), + call.getNumber()); } /** diff --git a/InCallUI/src/com/android/incallui/InCallPresenter.java b/InCallUI/src/com/android/incallui/InCallPresenter.java index 637b4aa93..4bb86d004 100644 --- a/InCallUI/src/com/android/incallui/InCallPresenter.java +++ b/InCallUI/src/com/android/incallui/InCallPresenter.java @@ -16,11 +16,12 @@ package com.android.incallui; +import com.google.common.base.Preconditions; + import android.app.ActivityManager.TaskDescription; import android.app.FragmentManager; import android.content.Context; import android.content.Intent; -import android.content.pm.ActivityInfo; import android.content.res.Resources; import android.database.ContentObserver; import android.graphics.Point; @@ -36,12 +37,12 @@ import android.telecom.VideoProfile; import android.telephony.PhoneStateListener; import android.telephony.TelephonyManager; import android.text.TextUtils; -import android.view.Surface; import android.view.View; import android.view.Window; import android.view.WindowManager; import com.android.contacts.common.GeoUtil; +import com.android.contacts.common.compat.CompatUtils; import com.android.contacts.common.compat.SdkVersionOverride; import com.android.contacts.common.interactions.TouchPointManager; import com.android.contacts.common.testing.NeededForTesting; @@ -56,15 +57,14 @@ import com.android.dialer.logging.Logger; import com.android.incallui.compat.telecom.DetailsCompat; import com.android.incallui.util.TelecomCallUtil; import com.android.incalluibind.ObjectFactory; -import com.google.common.base.Preconditions; import java.util.Collections; import java.util.List; import java.util.Locale; import java.util.Set; -import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.CopyOnWriteArrayList; +import java.util.concurrent.atomic.AtomicBoolean; /** * Takes updates from the CallList and notifies the InCallActivity (UI) @@ -1793,7 +1793,7 @@ public class InCallPresenter implements CallList.Listener, final PhoneAccount account = tm.getPhoneAccount(phoneAccountHandle); // For single-sim devices, there will be no selected highlight color, so the phone // account will default to NO_HIGHLIGHT_COLOR. - if (account != null) { + if (account != null && CompatUtils.isLollipopMr1Compatible()) { highlightColor = account.getHighlightColor(); } } @@ -1813,6 +1813,13 @@ public class InCallPresenter implements CallList.Listener, return mTelecomManager; } + /** + * @return An instance of TelephonyManager + */ + public TelephonyManager getTelephonyManager() { + return mTelephonyManager; + } + InCallActivity getActivity() { return mInCallActivity; } diff --git a/InCallUI/src/com/android/incallui/compat/telecom/VideoProfileCompat.java b/InCallUI/src/com/android/incallui/compat/telecom/VideoProfileCompat.java new file mode 100644 index 000000000..54d8eed65 --- /dev/null +++ b/InCallUI/src/com/android/incallui/compat/telecom/VideoProfileCompat.java @@ -0,0 +1,127 @@ +/* + * 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; + } +} |