From 29c01f36e9381b7bad135a9701aa3dffaf495b2f Mon Sep 17 00:00:00 2001 From: Nancy Chen Date: Tue, 22 Dec 2015 14:30:59 -0800 Subject: Make TelecomManager APIs compatible with Lollipop (3/3). Convert TelecomManager direct usages to using TelecomManagerCompat instead. Bug: 25776171 Change-Id: I534eb9ff72968f4351aaa0a3856769226c2f1941 --- InCallUI/src/com/android/incallui/Call.java | 5 ++++- InCallUI/src/com/android/incallui/CallCardPresenter.java | 8 +++++--- InCallUI/src/com/android/incallui/InCallPresenter.java | 4 +++- 3 files changed, 12 insertions(+), 5 deletions(-) (limited to 'InCallUI') diff --git a/InCallUI/src/com/android/incallui/Call.java b/InCallUI/src/com/android/incallui/Call.java index f47a4c39a..d82346ebb 100644 --- a/InCallUI/src/com/android/incallui/Call.java +++ b/InCallUI/src/com/android/incallui/Call.java @@ -34,6 +34,7 @@ import android.text.TextUtils; import com.android.contacts.common.CallUtil; 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; @@ -176,6 +177,7 @@ public class Call { return mCameraDirection; } + @Override public String toString() { return "(CameraDir:" + getCameraDir() + ")"; } @@ -608,7 +610,8 @@ public class Call { if (mPhoneAccountHandle != null) { TelecomManager mgr = InCallPresenter.getInstance().getTelecomManager(); - PhoneAccount phoneAccount = mgr.getPhoneAccount(mPhoneAccountHandle); + PhoneAccount phoneAccount = + TelecomManagerCompat.getPhoneAccount(mgr, mPhoneAccountHandle); if (phoneAccount != null) { mIsCallSubjectSupported = phoneAccount.hasCapabilities( PhoneAccount.CAPABILITY_CALL_SUBJECT); diff --git a/InCallUI/src/com/android/incallui/CallCardPresenter.java b/InCallUI/src/com/android/incallui/CallCardPresenter.java index 47b63c0f9..a0c1cef86 100644 --- a/InCallUI/src/com/android/incallui/CallCardPresenter.java +++ b/InCallUI/src/com/android/incallui/CallCardPresenter.java @@ -385,7 +385,7 @@ public class CallCardPresenter extends Presenter PhoneAccountHandle accountHandle = mPrimary.getAccountHandle(); if (accountHandle != null) { TelecomManager mgr = InCallPresenter.getInstance().getTelecomManager(); - PhoneAccount account = mgr.getPhoneAccount(accountHandle); + PhoneAccount account = TelecomManagerCompat.getPhoneAccount(mgr, accountHandle); if (account != null) { return getNumberFromHandle(account.getSubscriptionAddress()); } @@ -823,7 +823,9 @@ public class CallCardPresenter extends Presenter if (accountHandle == null) { return null; } - return InCallPresenter.getInstance().getTelecomManager().getPhoneAccount(accountHandle); + return TelecomManagerCompat.getPhoneAccount( + InCallPresenter.getInstance().getTelecomManager(), + accountHandle); } /** @@ -843,7 +845,7 @@ public class CallCardPresenter extends Presenter PhoneAccount account = getAccountForCall(call); TelecomManager mgr = InCallPresenter.getInstance().getTelecomManager(); if (account != null && !TextUtils.isEmpty(account.getLabel()) - && mgr.getCallCapablePhoneAccounts().size() > 1) { + && TelecomManagerCompat.getCallCapablePhoneAccounts(mgr).size() > 1) { return account.getLabel().toString(); } return null; diff --git a/InCallUI/src/com/android/incallui/InCallPresenter.java b/InCallUI/src/com/android/incallui/InCallPresenter.java index d4dbda82a..f50da8dbd 100644 --- a/InCallUI/src/com/android/incallui/InCallPresenter.java +++ b/InCallUI/src/com/android/incallui/InCallPresenter.java @@ -44,6 +44,7 @@ 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.compat.telecom.TelecomManagerCompat; import com.android.contacts.common.interactions.TouchPointManager; import com.android.contacts.common.testing.NeededForTesting; import com.android.contacts.common.util.MaterialColorMapUtils.MaterialPalette; @@ -1791,7 +1792,8 @@ public class InCallPresenter implements CallList.Listener, final TelecomManager tm = getTelecomManager(); if (tm != null) { - final PhoneAccount account = tm.getPhoneAccount(phoneAccountHandle); + final PhoneAccount account = + TelecomManagerCompat.getPhoneAccount(tm, 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 && CompatUtils.isLollipopMr1Compatible()) { -- cgit v1.2.3