diff options
author | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2024-03-13 20:35:20 +0000 |
---|---|---|
committer | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2024-03-13 20:35:20 +0000 |
commit | d198c5fe9408185018e5b0c12c53ba421ccf520b (patch) | |
tree | 4effc92df2c7505b7331f968863a7371b108e4dc | |
parent | e1e89c780c2e3e940a1f000110131ed4fd26eac7 (diff) | |
parent | 89e411fa80aeb3df3290f2ec9842cdab70752067 (diff) | |
download | Dialer-mirror-car-apps-aosp-release.tar.gz |
Snap for 11566466 from 89e411fa80aeb3df3290f2ec9842cdab70752067 to car-apps-aosp-releaseub-automotive-master-20240314mirror-car-apps-aosp-release
Change-Id: Ida9362512fa6f57ee9e5111bcc60b94e0d3b8fbd
6 files changed, 21 insertions, 35 deletions
diff --git a/framework/Android.bp b/framework/Android.bp index a9390828..9dfa5ec6 100644 --- a/framework/Android.bp +++ b/framework/Android.bp @@ -74,7 +74,7 @@ android_library { "androidx.legacy_legacy-support-v4", "androidx.lifecycle_lifecycle-common-java8", "androidx.lifecycle_lifecycle-extensions", - "gson-prebuilt-jar", + "gson", "guava", "hilt_android", "mockito-target-extended-minus-junit4", diff --git a/res/values-pa/strings.xml b/res/values-pa/strings.xml index 029e9c70..4f1482dc 100644 --- a/res/values-pa/strings.xml +++ b/res/values-pa/strings.xml @@ -72,7 +72,7 @@ <string name="sort_order_title" msgid="975104366728292702">"ਸੰਪਰਕ ਕ੍ਰਮ"</string> <string name="pref_connected_phone_title" msgid="5472866963149472593">"ਕਨੈਕਟ ਕੀਤਾ ਫ਼ੋਨ"</string> <string name="pref_no_incoming_call_hun_title" msgid="2314257779205958332">"ਪਰਦੇਦਾਰੀ"</string> - <string name="pref_no_incoming_call_hun_summary" msgid="8833377984331845097">"ਸਿਰਫ਼ ਕਾਲ ਸੁਚੇਤਨਾਵਾਂ ਨੂੰ ਸਮੂਹ ਵਿੱਚ ਦਿਖਾਓ"</string> + <string name="pref_no_incoming_call_hun_summary" msgid="8833377984331845097">"ਸਿਰਫ਼ ਕਾਲ ਅਲਰਟਾਂ ਨੂੰ ਸਮੂਹ ਵਿੱਚ ਦਿਖਾਓ"</string> <string name="pref_show_fullscreen_active_call_ui_title" msgid="6924304583510509581">"ਕਿਰਿਆਸ਼ੀਲ ਕਾਲ"</string> <string name="pref_show_fullscreen_active_call_ui_summary" msgid="1629142960991476502">"ਕਾਲ ਦਾ ਜਵਾਬ ਦੇਣ ਵੇਲੇ ਕਿਰਿਆਸ਼ੀਲ ਕਾਲ ਦ੍ਰਿਸ਼ ਦਿਖਾਓ"</string> <string name="given_name_first_title" msgid="8072187841056104968">"ਨਾਮ ਦਾ ਪਹਿਲਾ ਭਾਗ"</string> diff --git a/src/com/android/car/dialer/ui/warning/BluetoothErrorStringLiveData.java b/src/com/android/car/dialer/ui/warning/BluetoothErrorStringLiveData.java index 12356e13..6ab9aca5 100644 --- a/src/com/android/car/dialer/ui/warning/BluetoothErrorStringLiveData.java +++ b/src/com/android/car/dialer/ui/warning/BluetoothErrorStringLiveData.java @@ -18,7 +18,6 @@ package com.android.car.dialer.ui.warning; import android.bluetooth.BluetoothAdapter; import android.bluetooth.BluetoothDevice; -import android.content.Context; import androidx.annotation.Nullable; import androidx.lifecycle.LiveData; @@ -34,7 +33,6 @@ import java.util.Set; import javax.inject.Inject; import javax.inject.Named; -import dagger.hilt.android.qualifiers.ApplicationContext; import dagger.hilt.android.scopes.ViewModelScoped; /** @@ -42,12 +40,10 @@ import dagger.hilt.android.scopes.ViewModelScoped; * error. If there is no error, its value will be {@link #NO_BT_ERROR}. */ @ViewModelScoped -public class BluetoothErrorStringLiveData extends MediatorLiveData<String> { +public class BluetoothErrorStringLiveData extends MediatorLiveData<Integer> { private static final String TAG = "CD.BluetoothErrorStringLiveData"; - public static final String NO_BT_ERROR = "NO_ERROR"; - - private Context mContext; + public static final Integer NO_BT_ERROR = Integer.MIN_VALUE; private LiveData<List<BluetoothDevice>> mHfpDeviceListLiveData; private LiveData<Set<BluetoothDevice>> mPairListLiveData; @@ -55,15 +51,12 @@ public class BluetoothErrorStringLiveData extends MediatorLiveData<String> { @Inject BluetoothErrorStringLiveData( - @ApplicationContext Context context, @Named("Hfp") LiveData<List<BluetoothDevice>> hfpDeviceListLiveData, @Named("Bluetooth") LiveData<Set<BluetoothDevice>> pairListLiveData, @Named("Bluetooth") LiveData<Integer> bluetoothStateLiveData, @Nullable BluetoothAdapter bluetoothAdapter) { - mContext = context; - if (bluetoothAdapter == null) { - setValue(mContext.getString(R.string.bluetooth_unavailable)); + setValue(R.string.bluetooth_unavailable); } else { setValue(NO_BT_ERROR); mHfpDeviceListLiveData = hfpDeviceListLiveData; @@ -104,11 +97,11 @@ public class BluetoothErrorStringLiveData extends MediatorLiveData<String> { setValue(NO_BT_ERROR); } } else if (!isBluetoothEnabled) { - setValue(mContext.getString(R.string.bluetooth_disabled)); + setValue(R.string.bluetooth_disabled); } else if (!hasPairedDevices) { - setValue(mContext.getString(R.string.bluetooth_unpaired)); + setValue(R.string.bluetooth_unpaired); } else { - setValue(mContext.getString(R.string.no_hfp)); + setValue(R.string.no_hfp); } } diff --git a/src/com/android/car/dialer/ui/warning/NoHfpFragment.java b/src/com/android/car/dialer/ui/warning/NoHfpFragment.java index f896310c..d59f1a8f 100644 --- a/src/com/android/car/dialer/ui/warning/NoHfpFragment.java +++ b/src/com/android/car/dialer/ui/warning/NoHfpFragment.java @@ -60,14 +60,14 @@ public class NoHfpFragment extends Hilt_NoHfpFragment { View view = inflater.inflate(R.layout.no_hfp, container, false); mErrorMessageView = view.findViewById(R.id.error_string); - LiveData<String> errorStringLiveData = new ViewModelProvider(getActivity()) + LiveData<Integer> errorStringIdLiveData = new ViewModelProvider(getActivity()) .get(NoHfpViewModel.class) .getBluetoothErrorStringLiveData(); - errorStringLiveData.observe(getViewLifecycleOwner(), error -> { + errorStringIdLiveData.observe(getViewLifecycleOwner(), errorStringId -> { // Do not set the NO_BT_ERROR message to avoid UI jankiness - if (!BluetoothErrorStringLiveData.NO_BT_ERROR.equals(error)) { - mErrorMessageView.setText(error); + if (!BluetoothErrorStringLiveData.NO_BT_ERROR.equals(errorStringId)) { + mErrorMessageView.setText(errorStringId); } }); diff --git a/src/com/android/car/dialer/ui/warning/NoHfpViewModel.java b/src/com/android/car/dialer/ui/warning/NoHfpViewModel.java index 462b16c0..501e166c 100644 --- a/src/com/android/car/dialer/ui/warning/NoHfpViewModel.java +++ b/src/com/android/car/dialer/ui/warning/NoHfpViewModel.java @@ -29,12 +29,11 @@ public class NoHfpViewModel extends ViewModel { private final BluetoothErrorStringLiveData mBluetoothErrorStringLiveData; @Inject - NoHfpViewModel( - BluetoothErrorStringLiveData bluetoothErrorStringLiveData) { + NoHfpViewModel(BluetoothErrorStringLiveData bluetoothErrorStringLiveData) { mBluetoothErrorStringLiveData = bluetoothErrorStringLiveData; } - public LiveData<String> getBluetoothErrorStringLiveData() { + public LiveData<Integer> getBluetoothErrorStringLiveData() { return mBluetoothErrorStringLiveData; } } diff --git a/tests/unittests/src/com/android/car/dialer/ui/warning/BluetoothErrorStringLiveDataTest.java b/tests/unittests/src/com/android/car/dialer/ui/warning/BluetoothErrorStringLiveDataTest.java index 14ea4a31..d31c7c9e 100644 --- a/tests/unittests/src/com/android/car/dialer/ui/warning/BluetoothErrorStringLiveDataTest.java +++ b/tests/unittests/src/com/android/car/dialer/ui/warning/BluetoothErrorStringLiveDataTest.java @@ -22,7 +22,6 @@ import static org.mockito.Mockito.mock; import android.bluetooth.BluetoothAdapter; import android.bluetooth.BluetoothDevice; -import android.content.Context; import androidx.lifecycle.MutableLiveData; import androidx.lifecycle.Observer; @@ -46,9 +45,7 @@ import java.util.Set; public class BluetoothErrorStringLiveDataTest { @Mock - private Context mContext; - @Mock - private Observer<String> mMockObserver; + private Observer<Integer> mMockObserver; private BluetoothAdapter mBluetoothAdapter; private MutableLiveData<List<BluetoothDevice>> mHfpDeviceListLiveData; private MutableLiveData<Set<BluetoothDevice>> mPairedListLiveData; @@ -70,8 +67,8 @@ public class BluetoothErrorStringLiveDataTest { initializeBluetoothErrorStringLiveData(); - assertThat(mBluetoothErrorStringLiveData.getValue()).isEqualTo( - mContext.getString(R.string.bluetooth_unavailable)); + assertThat(mBluetoothErrorStringLiveData.getValue()) + .isEqualTo(R.string.bluetooth_unavailable); } @Test @@ -82,8 +79,7 @@ public class BluetoothErrorStringLiveDataTest { initializeBluetoothErrorStringLiveData(); - assertThat(mBluetoothErrorStringLiveData.getValue()).isEqualTo( - mContext.getString(R.string.bluetooth_disabled)); + assertThat(mBluetoothErrorStringLiveData.getValue()).isEqualTo(R.string.bluetooth_disabled); } @Test @@ -95,8 +91,7 @@ public class BluetoothErrorStringLiveDataTest { initializeBluetoothErrorStringLiveData(); - assertThat(mBluetoothErrorStringLiveData.getValue()).isEqualTo( - mContext.getString(R.string.bluetooth_unpaired)); + assertThat(mBluetoothErrorStringLiveData.getValue()).isEqualTo(R.string.bluetooth_unpaired); } @Test @@ -110,8 +105,7 @@ public class BluetoothErrorStringLiveDataTest { initializeBluetoothErrorStringLiveData(); - assertThat(mBluetoothErrorStringLiveData.getValue()).isEqualTo( - mContext.getString(R.string.no_hfp)); + assertThat(mBluetoothErrorStringLiveData.getValue()).isEqualTo(R.string.no_hfp); } @Test @@ -130,7 +124,7 @@ public class BluetoothErrorStringLiveDataTest { } private void initializeBluetoothErrorStringLiveData() { - mBluetoothErrorStringLiveData = new BluetoothErrorStringLiveData(mContext, + mBluetoothErrorStringLiveData = new BluetoothErrorStringLiveData( mHfpDeviceListLiveData, mPairedListLiveData, mBluetoothStateLiveData, mBluetoothAdapter); // Observers needed so that the liveData's internal initialization is triggered |