diff options
author | android-build-team Robot <android-build-team-robot@google.com> | 2020-03-12 23:07:42 +0000 |
---|---|---|
committer | android-build-team Robot <android-build-team-robot@google.com> | 2020-03-12 23:07:42 +0000 |
commit | 831094ba7ae71661389a3bd447782d0d6f8473a4 (patch) | |
tree | cf45fbcc205ea05c3949a0942dad3759491e14f7 | |
parent | 1daa59399865a2770437bf7fb66964ee0e22eaef (diff) | |
parent | eabfe7b4038eb9f05b0778169eb361d9a2a774c0 (diff) | |
download | Dialer-831094ba7ae71661389a3bd447782d0d6f8473a4.tar.gz |
Snap for 6290189 from eabfe7b4038eb9f05b0778169eb361d9a2a774c0 to qt-qpr3-release
Change-Id: I4f1163a2549e2fae7d2cf99a20bdfedc8c9102ce
3 files changed, 46 insertions, 20 deletions
diff --git a/src/com/android/car/dialer/telecom/UiCallManager.java b/src/com/android/car/dialer/telecom/UiCallManager.java index 956121cd..6822c2d5 100644 --- a/src/com/android/car/dialer/telecom/UiCallManager.java +++ b/src/com/android/car/dialer/telecom/UiCallManager.java @@ -42,11 +42,6 @@ import com.android.car.telephony.common.TelecomUtils; import com.android.internal.annotations.VisibleForTesting; import com.android.internal.telephony.ITelephony; -import com.google.i18n.phonenumbers.PhoneNumberUtil; -import com.google.i18n.phonenumbers.PhoneNumberUtil.PhoneNumberType; -import com.google.i18n.phonenumbers.PhoneNumberUtil.ValidationResult; -import com.google.i18n.phonenumbers.Phonenumber; - import java.util.ArrayList; import java.util.Collections; import java.util.List; @@ -307,24 +302,13 @@ public class UiCallManager { } /** - * Runs basic validation check of a phone number, to verify it is the correct length - * in an internationalized way. Further validation on whether the number actually exists - * is left for the phone carrier. + * Runs basic validation check of a phone number, to verify it is not empty. */ private boolean isValidNumber(String number) { - Phonenumber.PhoneNumber phoneNumber = TelecomUtils.createI18nPhoneNumber(mContext, - number); - if (phoneNumber != null) { - for (PhoneNumberType type : PhoneNumberType.values()) { - ValidationResult result = - PhoneNumberUtil.getInstance().isPossibleNumberForTypeWithReason(phoneNumber, - type); - if (result != ValidationResult.TOO_SHORT && result != ValidationResult.TOO_LONG) { - return true; - } - } + if (TextUtils.isEmpty(number)) { + return false; } - return false; + return true; } public void callVoicemail() { diff --git a/src/com/android/car/dialer/ui/TelecomActivity.java b/src/com/android/car/dialer/ui/TelecomActivity.java index 8368a9ec..50924500 100644 --- a/src/com/android/car/dialer/ui/TelecomActivity.java +++ b/src/com/android/car/dialer/ui/TelecomActivity.java @@ -17,6 +17,7 @@ package com.android.car.dialer.ui; import android.app.SearchManager; +import android.bluetooth.BluetoothDevice; import android.content.Intent; import android.content.SharedPreferences; import android.graphics.drawable.Drawable; @@ -76,6 +77,7 @@ public class TelecomActivity extends FragmentActivity implements // View objects for this activity. private TelecomPageTab.Factory mTabFactory; private Toolbar mCarUiToolbar; + private BluetoothDevice mBluetoothDevice; @Override protected void onCreate(Bundle savedInstanceState) { @@ -96,6 +98,7 @@ public class TelecomActivity extends FragmentActivity implements dialerAppState -> updateCurrentFragment(dialerAppState)); MutableLiveData<Integer> toolbarTitleMode = viewModel.getToolbarTitleMode(); toolbarTitleMode.setValue(Themes.getAttrInteger(this, R.attr.toolbarTitleMode)); + viewModel.getRefreshTabsLiveData().observe(this, this::refreshTabs); InCallViewModel inCallViewModel = ViewModelProviders.of(this).get(InCallViewModel.class); mOngoingCallListLiveData = inCallViewModel.getOngoingCallList(); @@ -105,6 +108,13 @@ public class TelecomActivity extends FragmentActivity implements handleIntent(); } + private void refreshTabs(boolean refreshTabs) { + L.v(TAG, "hfp connected device list Changes."); + if (refreshTabs) { + setupTabLayout(); + } + } + @Override protected void onNewIntent(Intent i) { super.onNewIntent(i); @@ -245,6 +255,7 @@ public class TelecomActivity extends FragmentActivity implements private void setupTabLayout() { boolean wasContentFragmentRestored = false; mTabFactory = new TelecomPageTab.Factory(this, getSupportFragmentManager()); + mCarUiToolbar.clearAllTabs(); for (int i = 0; i < mTabFactory.getTabCount(); i++) { TelecomPageTab tab = mTabFactory.createTab(getBaseContext(), i); mCarUiToolbar.addTab(tab); diff --git a/src/com/android/car/dialer/ui/TelecomActivityViewModel.java b/src/com/android/car/dialer/ui/TelecomActivityViewModel.java index bf6a051b..cd16402b 100644 --- a/src/com/android/car/dialer/ui/TelecomActivityViewModel.java +++ b/src/com/android/car/dialer/ui/TelecomActivityViewModel.java @@ -27,11 +27,13 @@ import androidx.lifecycle.AndroidViewModel; import androidx.lifecycle.LiveData; import androidx.lifecycle.MediatorLiveData; import androidx.lifecycle.MutableLiveData; +import androidx.lifecycle.Transformations; import com.android.car.dialer.R; import com.android.car.dialer.livedata.BluetoothHfpStateLiveData; import com.android.car.dialer.livedata.BluetoothPairListLiveData; import com.android.car.dialer.livedata.BluetoothStateLiveData; +import com.android.car.dialer.livedata.HfpDeviceListLiveData; import com.android.car.dialer.log.L; import com.android.car.dialer.telecom.UiBluetoothMonitor; @@ -52,10 +54,13 @@ public class TelecomActivityViewModel extends AndroidViewModel { private final Context mApplicationContext; private final LiveData<String> mErrorStringLiveData; private final MutableLiveData<Integer> mDialerAppStateLiveData; + private final LiveData<Boolean> mRefreshTabsLiveData; private final ToolbarTitleLiveData mToolbarTitleLiveData; private final MutableLiveData<Integer> mToolbarTitleMode; + private BluetoothDevice mBluetoothDevice; + /** * App state indicates if bluetooth is connected or it should just show the content fragments. */ @@ -90,6 +95,22 @@ public class TelecomActivityViewModel extends AndroidViewModel { } mDialerAppStateLiveData = new DialerAppStateLiveData(mErrorStringLiveData); + + HfpDeviceListLiveData hfpDeviceListLiveData = new HfpDeviceListLiveData(getApplication()); + mRefreshTabsLiveData = Transformations.map(hfpDeviceListLiveData, (hfpDeviceList) -> { + if (hfpDeviceList != null && !hfpDeviceList.isEmpty()) { + if (!hfpDeviceList.contains(mBluetoothDevice)) { + mBluetoothDevice = hfpDeviceList.get(0); + return true; + } + } else { + if (mBluetoothDevice != null) { + mBluetoothDevice = null; + return true; + } + } + return false; + }); } /** @@ -108,6 +129,9 @@ public class TelecomActivityViewModel extends AndroidViewModel { return mToolbarTitleMode; } + /** + * Returns the state of Dialer App. + */ public MutableLiveData<Integer> getDialerAppState() { return mDialerAppStateLiveData; } @@ -120,6 +144,13 @@ public class TelecomActivityViewModel extends AndroidViewModel { return mErrorStringLiveData; } + /** + * Returns the live data which monitors whether to refresh Dialer. + */ + public LiveData<Boolean> getRefreshTabsLiveData() { + return mRefreshTabsLiveData; + } + private static class DialerAppStateLiveData extends MediatorLiveData<Integer> { private final LiveData<String> mErrorStringLiveData; |