[Settings] Support search of each Sim slot status within about phone
Support searching of each SIM slot status within about phone page. Bug: 260540995 Test: auto and local Change-Id: If905fc595af566665fb1077a5ce11a967f7487aa
This commit is contained in:
@@ -6530,7 +6530,11 @@
|
|||||||
<string name="keywords_face_unlock">face, unlock, auth, sign in</string>
|
<string name="keywords_face_unlock">face, unlock, auth, sign in</string>
|
||||||
<string name="keywords_biometric_unlock">face, unlock, auth, sign in, fingerprint, biometric</string>
|
<string name="keywords_biometric_unlock">face, unlock, auth, sign in, fingerprint, biometric</string>
|
||||||
<string name="keywords_imei_info">imei, meid, min, prl version, imei sv</string>
|
<string name="keywords_imei_info">imei, meid, min, prl version, imei sv</string>
|
||||||
<string name="keywords_sim_status">network, mobile network state, service state, signal strength, mobile network type, roaming, iccid, eid</string>
|
<string name="keywords_sim_status">network, mobile network state, service state, signal strength, mobile network type, roaming</string>
|
||||||
|
<string name="keywords_sim_status_esim">network, mobile network state, service state, signal strength, mobile network type, roaming, eid</string>
|
||||||
|
<string name="keywords_sim_status_iccid">network, mobile network state, service state, signal strength, mobile network type, roaming, iccid</string>
|
||||||
|
<string name="keywords_sim_status_iccid_esim">network, mobile network state, service state, signal strength, mobile network type, roaming, iccid, eid</string>
|
||||||
|
<string name="keywords_esim_eid">eid</string>
|
||||||
<string name="keywords_model_and_hardware">serial number, hardware version</string>
|
<string name="keywords_model_and_hardware">serial number, hardware version</string>
|
||||||
<string name="keywords_android_version">android security patch level, baseband version, kernel version</string>
|
<string name="keywords_android_version">android security patch level, baseband version, kernel version</string>
|
||||||
<!-- Search keywords for dark mode settings [CHAR LIMIT=NONE] -->
|
<!-- Search keywords for dark mode settings [CHAR LIMIT=NONE] -->
|
||||||
|
@@ -31,6 +31,7 @@ import com.android.settings.R;
|
|||||||
import com.android.settings.core.BasePreferenceController;
|
import com.android.settings.core.BasePreferenceController;
|
||||||
import com.android.settings.network.SubscriptionUtil;
|
import com.android.settings.network.SubscriptionUtil;
|
||||||
import com.android.settingslib.Utils;
|
import com.android.settingslib.Utils;
|
||||||
|
import com.android.settingslib.search.SearchIndexableRaw;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -159,4 +160,28 @@ public class SimStatusPreferenceController extends BasePreferenceController {
|
|||||||
Preference createNewPreference(Context context) {
|
Preference createNewPreference(Context context) {
|
||||||
return new Preference(context);
|
return new Preference(context);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void updateDynamicRawDataToIndex(List<SearchIndexableRaw> rawData) {
|
||||||
|
int simSlot = getSimSlotIndex();
|
||||||
|
SubscriptionInfo subInfo = getSubscriptionInfo(simSlot);
|
||||||
|
if (subInfo == null) {
|
||||||
|
/**
|
||||||
|
* Only add to search when SIM is active
|
||||||
|
* (presented in SIM Slot Status as availavle.)
|
||||||
|
*/
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Have different search keywork when comes to eSIM */
|
||||||
|
int keywordId = subInfo.isEmbedded() ?
|
||||||
|
R.string.keywords_sim_status_esim : R.string.keywords_sim_status;
|
||||||
|
|
||||||
|
SearchIndexableRaw data = new SearchIndexableRaw(mContext);
|
||||||
|
data.key = getPreferenceKey();
|
||||||
|
data.title = getPreferenceTitle(simSlot);
|
||||||
|
data.screenTitle = mContext.getString(R.string.about_settings);
|
||||||
|
data.keywords = mContext.getString(keywordId).toString();
|
||||||
|
rawData.add(data);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -16,6 +16,8 @@
|
|||||||
|
|
||||||
package com.android.settings.deviceinfo.simstatus;
|
package com.android.settings.deviceinfo.simstatus;
|
||||||
|
|
||||||
|
import static com.google.common.truth.Truth.assertThat;
|
||||||
|
|
||||||
import static org.mockito.ArgumentMatchers.anyString;
|
import static org.mockito.ArgumentMatchers.anyString;
|
||||||
import static org.mockito.Mockito.doReturn;
|
import static org.mockito.Mockito.doReturn;
|
||||||
import static org.mockito.Mockito.mock;
|
import static org.mockito.Mockito.mock;
|
||||||
@@ -26,6 +28,7 @@ import static org.mockito.Mockito.when;
|
|||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.res.Resources;
|
import android.content.res.Resources;
|
||||||
import android.os.UserManager;
|
import android.os.UserManager;
|
||||||
|
import android.telephony.SubscriptionInfo;
|
||||||
import android.telephony.SubscriptionManager;
|
import android.telephony.SubscriptionManager;
|
||||||
import android.telephony.TelephonyManager;
|
import android.telephony.TelephonyManager;
|
||||||
|
|
||||||
@@ -37,6 +40,7 @@ import androidx.preference.PreferenceScreen;
|
|||||||
|
|
||||||
import com.android.settings.R;
|
import com.android.settings.R;
|
||||||
import com.android.settings.core.BasePreferenceController;
|
import com.android.settings.core.BasePreferenceController;
|
||||||
|
import com.android.settingslib.search.SearchIndexableRaw;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -62,6 +66,10 @@ public class SimStatusPreferenceControllerTest {
|
|||||||
@Mock
|
@Mock
|
||||||
private PreferenceScreen mScreen;
|
private PreferenceScreen mScreen;
|
||||||
@Mock
|
@Mock
|
||||||
|
private SubscriptionManager mSubscriptionManager;
|
||||||
|
@Mock
|
||||||
|
private SubscriptionInfo mSubscriptionInfo;
|
||||||
|
@Mock
|
||||||
private TelephonyManager mTelephonyManager;
|
private TelephonyManager mTelephonyManager;
|
||||||
@Mock
|
@Mock
|
||||||
private UserManager mUserManager;
|
private UserManager mUserManager;
|
||||||
@@ -85,6 +93,8 @@ public class SimStatusPreferenceControllerTest {
|
|||||||
when(mResources.getBoolean(R.bool.config_show_sim_info)).thenReturn(true);
|
when(mResources.getBoolean(R.bool.config_show_sim_info)).thenReturn(true);
|
||||||
|
|
||||||
mockService(Context.TELEPHONY_SERVICE, TelephonyManager.class, mTelephonyManager);
|
mockService(Context.TELEPHONY_SERVICE, TelephonyManager.class, mTelephonyManager);
|
||||||
|
mockService(Context.TELEPHONY_SUBSCRIPTION_SERVICE, SubscriptionManager.class,
|
||||||
|
mSubscriptionManager);
|
||||||
|
|
||||||
mockService(Context.USER_SERVICE, UserManager.class, mUserManager);
|
mockService(Context.USER_SERVICE, UserManager.class, mUserManager);
|
||||||
final List<Preference> preferencePool = new ArrayList<Preference>();
|
final List<Preference> preferencePool = new ArrayList<Preference>();
|
||||||
@@ -96,6 +106,10 @@ public class SimStatusPreferenceControllerTest {
|
|||||||
public Preference createNewPreference(Context context) {
|
public Preference createNewPreference(Context context) {
|
||||||
return preferencePool.remove(0);
|
return preferencePool.remove(0);
|
||||||
}
|
}
|
||||||
|
@Override
|
||||||
|
public int getSimSlotIndex() {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
});
|
});
|
||||||
doReturn(BasePreferenceController.AVAILABLE).when(mController).getAvailabilityStatus();
|
doReturn(BasePreferenceController.AVAILABLE).when(mController).getAvailabilityStatus();
|
||||||
when(mScreen.getContext()).thenReturn(mContext);
|
when(mScreen.getContext()).thenReturn(mContext);
|
||||||
@@ -163,6 +177,47 @@ public class SimStatusPreferenceControllerTest {
|
|||||||
verify(mFragment).getChildFragmentManager();
|
verify(mFragment).getChildFragmentManager();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void updateDynamicRawDataToIndex_notAddToSearch_emptySimSlot() {
|
||||||
|
doReturn(null).when(mSubscriptionManager).getActiveSubscriptionInfoList();
|
||||||
|
SlotSimStatus slotSimStatus = new SlotSimStatus(mContext);
|
||||||
|
List<SearchIndexableRaw> rawData = new ArrayList<SearchIndexableRaw>();
|
||||||
|
|
||||||
|
mController.init(mFragment, slotSimStatus);
|
||||||
|
mController.updateDynamicRawDataToIndex(rawData);
|
||||||
|
|
||||||
|
assertThat(rawData.size()).isEqualTo(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void updateDynamicRawDataToIndex_addToSearch_simInSimSlot() {
|
||||||
|
doReturn(false).when(mSubscriptionInfo).isEmbedded();
|
||||||
|
doReturn(List.of(mSubscriptionInfo)).when(mSubscriptionManager)
|
||||||
|
.getActiveSubscriptionInfoList();
|
||||||
|
SlotSimStatus slotSimStatus = new SlotSimStatus(mContext);
|
||||||
|
List<SearchIndexableRaw> rawData = new ArrayList<SearchIndexableRaw>();
|
||||||
|
|
||||||
|
mController.init(mFragment, slotSimStatus);
|
||||||
|
mController.updateDynamicRawDataToIndex(rawData);
|
||||||
|
|
||||||
|
assertThat(rawData.size()).isEqualTo(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void updateDynamicRawDataToIndex_addEsimToSearch_esimInSimSlot() {
|
||||||
|
doReturn(true).when(mSubscriptionInfo).isEmbedded();
|
||||||
|
doReturn(List.of(mSubscriptionInfo)).when(mSubscriptionManager)
|
||||||
|
.getActiveSubscriptionInfoList();
|
||||||
|
SlotSimStatus slotSimStatus = new SlotSimStatus(mContext);
|
||||||
|
List<SearchIndexableRaw> rawData = new ArrayList<SearchIndexableRaw>();
|
||||||
|
|
||||||
|
mController.init(mFragment, slotSimStatus);
|
||||||
|
mController.updateDynamicRawDataToIndex(rawData);
|
||||||
|
|
||||||
|
assertThat(rawData.size()).isEqualTo(1);
|
||||||
|
assertThat(rawData.get(0).keywords.contains("eid")).isTrue();
|
||||||
|
}
|
||||||
|
|
||||||
private <T> void mockService(String serviceName, Class<T> serviceClass, T service) {
|
private <T> void mockService(String serviceName, Class<T> serviceClass, T service) {
|
||||||
when(mContext.getSystemServiceName(serviceClass)).thenReturn(serviceName);
|
when(mContext.getSystemServiceName(serviceClass)).thenReturn(serviceName);
|
||||||
when(mContext.getSystemService(serviceName)).thenReturn(service);
|
when(mContext.getSystemService(serviceName)).thenReturn(service);
|
||||||
|
Reference in New Issue
Block a user