Snap for 7532392 from 630448d833 to sc-v2-release
Change-Id: Ia6123f6845c19e207f65d12f3f8d5ac32c680147
This commit is contained in:
@@ -64,7 +64,7 @@
|
||||
android:id="@*android:id/seekbar"
|
||||
android:minHeight="?android:attr/listPreferredItemHeightSmall"
|
||||
android:paddingStart="0dp"
|
||||
android:paddingEnd="0dp"
|
||||
android:paddingEnd="12dp"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"/>
|
||||
|
||||
@@ -44,7 +44,7 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="48dp"
|
||||
android:paddingStart="0dp"
|
||||
android:paddingEnd="0dp"
|
||||
android:paddingEnd="12dp"
|
||||
style="@android:style/Widget.Material.SeekBar.Discrete" />
|
||||
|
||||
<LinearLayout
|
||||
|
||||
@@ -64,7 +64,7 @@
|
||||
android:id="@*android:id/seekbar"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:paddingStart="0dp"
|
||||
android:paddingEnd="0dp"
|
||||
android:paddingEnd="12dp"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="48dp"/>
|
||||
|
||||
|
||||
@@ -62,7 +62,7 @@
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_width="match_parent"
|
||||
android:paddingStart="0dp"
|
||||
android:paddingEnd="0dp"
|
||||
android:paddingEnd="12dp"
|
||||
android:layout_height="48dp"/>
|
||||
</LinearLayout>
|
||||
|
||||
|
||||
@@ -5258,6 +5258,8 @@
|
||||
<string name="accessibility_captioning_title">Caption preferences</string>
|
||||
<!-- Title for the accessibility preference screen to enable screen magnification. [CHAR LIMIT=35] -->
|
||||
<string name="accessibility_screen_magnification_title">Magnification</string>
|
||||
<!-- Title for accessibility shortcut preference for magnification. [CHAR LIMIT=60] -->
|
||||
<string name="accessibility_screen_magnification_shortcut_title">Magnification shortcut</string>
|
||||
<!-- Title for the accessibility preference screen to edit magnification area. [CHAR LIMIT=35] -->
|
||||
<string name="accessibility_magnification_mode_title">Magnification type</string>
|
||||
<!-- Message for the accessibility preference screen to edit magnification area dialog. [CHAR LIMIT=none] -->
|
||||
@@ -5480,6 +5482,8 @@
|
||||
<string name="accessibility_display_inversion_preference_title">Color inversion</string>
|
||||
<!-- Used in the accessibility service settings to control turning display color inversion on/off entirely. [CHAR LIMIT=NONE] -->
|
||||
<string name="accessibility_display_inversion_switch_title">Use color inversion</string>
|
||||
<!-- Title for accessibility shortcut preference for color inversion. [CHAR LIMIT=60] -->
|
||||
<string name="accessibility_display_inversion_shortcut_title">Color inversion shortcut</string>
|
||||
<!-- Subtitle for the accessibility preference to configure display color inversion. [CHAR LIMIT=NONE] -->
|
||||
<string name="accessibility_display_inversion_preference_subtitle">
|
||||
<![CDATA[Color inversion turns light screens dark.<br/><br/>
|
||||
@@ -5531,6 +5535,8 @@
|
||||
<string name="accessibility_service_primary_open_title">Open <xliff:g id="accessibility_app_name" example="TalkBack">%1$s</xliff:g></string>
|
||||
<!-- Used in the Color correction settings screen to control turning on/off the feature entirely [CHAR LIMIT=60] -->
|
||||
<string name="accessibility_daltonizer_primary_switch_title">Use color correction</string>
|
||||
<!-- Title for accessibility shortcut preference for color correction. [CHAR LIMIT=60] -->
|
||||
<string name="accessibility_daltonizer_shortcut_title">Color correction shortcut</string>
|
||||
<!-- Title for Captions settings screen to control turning on/off the feature entirely [CHAR LIMIT=60] -->
|
||||
<string name="accessibility_caption_primary_switch_title">Show captions</string>
|
||||
<!-- Summary for Captions settings screen to control turning on/off the feature entirely [CHAR LIMIT=NONE] -->
|
||||
@@ -5610,6 +5616,8 @@
|
||||
<string name="reduce_bright_colors_preference_title">Extra dim</string>
|
||||
<!-- Title for the activation switch of the Reduce Brightness feature. [CHAR LIMIT=NONE] -->
|
||||
<string name="reduce_bright_colors_switch_title">Make screen extra dim</string>
|
||||
<!-- Title for accessibility shortcut preference for Reduce Brightness. [CHAR LIMIT=60] -->
|
||||
<string name="reduce_bright_colors_shortcut_title">Extra dim shortcut</string>
|
||||
<!-- Summary for the accessibility preference to configure Reduce Brightness feature. [CHAR LIMIT=NONE] -->
|
||||
<string name="reduce_bright_colors_preference_summary" product="default">Dim screen beyond your phone\u2019s minimum brightness</string>
|
||||
<!-- Summary for the accessibility preference to configure Reduce Brightness feature. [CHAR LIMIT=NONE] -->
|
||||
|
||||
@@ -55,7 +55,6 @@ import com.android.internal.widget.LockPatternUtils;
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.accessibility.AccessibilityUtil.UserShortcutType;
|
||||
import com.android.settings.password.ConfirmDeviceCredentialActivity;
|
||||
import com.android.settings.widget.SettingsMainSwitchPreference;
|
||||
import com.android.settingslib.accessibility.AccessibilityUtils;
|
||||
|
||||
import java.util.List;
|
||||
@@ -221,15 +220,6 @@ public class ToggleAccessibilityServicePreferenceFragment extends
|
||||
mComponentName);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void updateToggleServiceTitle(SettingsMainSwitchPreference switchPreference) {
|
||||
final AccessibilityServiceInfo info = getAccessibilityServiceInfo();
|
||||
final String switchBarText = (info == null) ? "" :
|
||||
getString(R.string.accessibility_service_primary_switch_title,
|
||||
info.getResolveInfo().loadLabel(getPackageManager()));
|
||||
switchPreference.setTitle(switchBarText);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void updateSwitchBarToggleSwitch() {
|
||||
final boolean checked = isAccessibilityServiceEnabled();
|
||||
|
||||
@@ -72,6 +72,11 @@ public class ToggleColorInversionPreferenceFragment extends
|
||||
switchPreference.setTitle(R.string.accessibility_display_inversion_switch_title);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void updateShortcutTitle(ShortcutPreference shortcutPreference) {
|
||||
shortcutPreference.setTitle(R.string.accessibility_display_inversion_shortcut_title);
|
||||
}
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||
Bundle savedInstanceState) {
|
||||
|
||||
@@ -167,6 +167,11 @@ public final class ToggleDaltonizerPreferenceFragment extends ToggleFeaturePrefe
|
||||
switchPreference.setTitle(R.string.accessibility_daltonizer_primary_switch_title);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void updateShortcutTitle(ShortcutPreference shortcutPreference) {
|
||||
shortcutPreference.setTitle(R.string.accessibility_daltonizer_shortcut_title);
|
||||
}
|
||||
|
||||
@Override
|
||||
int getUserShortcutTypes() {
|
||||
return AccessibilityUtil.getUserShortcutTypesFromSettings(getPrefContext(),
|
||||
|
||||
@@ -284,7 +284,14 @@ public abstract class ToggleFeaturePreferenceFragment extends SettingsPreference
|
||||
abstract int getUserShortcutTypes();
|
||||
|
||||
protected void updateToggleServiceTitle(SettingsMainSwitchPreference switchPreference) {
|
||||
switchPreference.setTitle(R.string.accessibility_service_primary_switch_title);
|
||||
final CharSequence title =
|
||||
getString(R.string.accessibility_service_primary_switch_title, mPackageName);
|
||||
switchPreference.setTitle(title);
|
||||
}
|
||||
|
||||
protected void updateShortcutTitle(ShortcutPreference shortcutPreference) {
|
||||
final CharSequence title = getString(R.string.accessibility_shortcut_title, mPackageName);
|
||||
shortcutPreference.setTitle(title);
|
||||
}
|
||||
|
||||
protected abstract void onPreferenceToggled(String preferenceKey, boolean enabled);
|
||||
@@ -434,8 +441,7 @@ public abstract class ToggleFeaturePreferenceFragment extends SettingsPreference
|
||||
mShortcutPreference.setKey(getShortcutPreferenceKey());
|
||||
mShortcutPreference.setOnClickCallback(this);
|
||||
|
||||
final CharSequence title = getString(R.string.accessibility_shortcut_title, mPackageName);
|
||||
mShortcutPreference.setTitle(title);
|
||||
updateShortcutTitle(mShortcutPreference);
|
||||
|
||||
final PreferenceCategory generalCategory = findPreference(KEY_GENERAL_CATEGORY);
|
||||
generalCategory.addPreference(mShortcutPreference);
|
||||
|
||||
@@ -154,6 +154,11 @@ public class ToggleReduceBrightColorsPreferenceFragment extends ToggleFeaturePre
|
||||
switchPreference.setTitle(R.string.reduce_bright_colors_preference_title);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void updateShortcutTitle(ShortcutPreference shortcutPreference) {
|
||||
shortcutPreference.setTitle(R.string.reduce_bright_colors_shortcut_title);
|
||||
}
|
||||
|
||||
@Override
|
||||
int getUserShortcutTypes() {
|
||||
return AccessibilityUtil.getUserShortcutTypesFromSettings(getPrefContext(),
|
||||
|
||||
@@ -396,6 +396,11 @@ public class ToggleScreenMagnificationPreferenceFragment extends
|
||||
generalCategory.addPreference(mShortcutPreference);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void updateShortcutTitle(ShortcutPreference shortcutPreference) {
|
||||
shortcutPreference.setTitle(R.string.accessibility_screen_magnification_shortcut_title);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void updateShortcutPreference() {
|
||||
final int shortcutTypes = PreferredShortcuts.retrieveUserShortcutType(getPrefContext(),
|
||||
|
||||
@@ -19,8 +19,11 @@ import android.app.settings.SettingsEnums;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
import android.database.ContentObserver;
|
||||
import android.net.Uri;
|
||||
import android.os.BatteryManager;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.provider.SearchIndexableResource;
|
||||
import android.util.Log;
|
||||
|
||||
@@ -31,6 +34,7 @@ import androidx.loader.content.Loader;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.SettingsActivity;
|
||||
import com.android.settings.fuelgauge.BatteryBroadcastReceiver;
|
||||
import com.android.settings.overlay.FeatureFactory;
|
||||
import com.android.settings.search.BaseSearchIndexProvider;
|
||||
import com.android.settingslib.core.AbstractPreferenceController;
|
||||
@@ -63,6 +67,17 @@ public class PowerUsageAdvanced extends PowerUsageBase {
|
||||
private BatteryChartPreferenceController mBatteryChartPreferenceController;
|
||||
private BatteryAppListPreferenceController mBatteryAppListPreferenceController;
|
||||
|
||||
private final ContentObserver mBatteryObserver =
|
||||
new ContentObserver(new Handler()) {
|
||||
@Override
|
||||
public void onChange(boolean selfChange) {
|
||||
Log.d(TAG, "onBatteryContentChange: " + selfChange);
|
||||
mIsChartDataLoaded = false;
|
||||
restartBatteryStatsLoader(
|
||||
BatteryBroadcastReceiver.BatteryUpdateType.MANUAL);
|
||||
}
|
||||
};
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle icicle) {
|
||||
super.onCreate(icicle);
|
||||
@@ -104,6 +119,20 @@ public class PowerUsageAdvanced extends PowerUsageBase {
|
||||
super.onPause();
|
||||
// Resets the flag to reload usage data in onResume() callback.
|
||||
mIsChartDataLoaded = false;
|
||||
final Uri uri = mPowerUsageFeatureProvider.getBatteryHistoryUri();
|
||||
if (uri != null) {
|
||||
getContext().getContentResolver().unregisterContentObserver(mBatteryObserver);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
final Uri uri = mPowerUsageFeatureProvider.getBatteryHistoryUri();
|
||||
if (uri != null) {
|
||||
getContext().getContentResolver().registerContentObserver(
|
||||
uri, /*notifyForDescendants*/ true, mBatteryObserver);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -18,6 +18,7 @@ package com.android.settings.fuelgauge;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.net.Uri;
|
||||
import android.util.SparseIntArray;
|
||||
|
||||
import com.android.internal.os.BatterySipper;
|
||||
@@ -141,4 +142,9 @@ public interface PowerUsageFeatureProvider {
|
||||
* Returns battery history data with corresponding timestamp key.
|
||||
*/
|
||||
Map<Long, Map<String, BatteryHistEntry>> getBatteryHistory(Context context);
|
||||
|
||||
/**
|
||||
* Returns {@link Uri} to monitor battery history data is update.
|
||||
*/
|
||||
Uri getBatteryHistoryUri();
|
||||
}
|
||||
|
||||
@@ -19,6 +19,7 @@ package com.android.settings.fuelgauge;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.net.Uri;
|
||||
import android.os.Process;
|
||||
import android.util.SparseIntArray;
|
||||
|
||||
@@ -167,4 +168,9 @@ public class PowerUsageFeatureProviderImpl implements PowerUsageFeatureProvider
|
||||
public Map<Long, Map<String, BatteryHistEntry>> getBatteryHistory(Context context) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Uri getBatteryHistoryUri() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -207,8 +207,6 @@ public class NetworkProviderSettings extends RestrictedSettingsFragment
|
||||
|
||||
private WifiDialog2 mDialog;
|
||||
|
||||
private View mProgressHeader;
|
||||
|
||||
@VisibleForTesting
|
||||
PreferenceCategory mConnectedWifiEntryPreferenceCategory;
|
||||
@VisibleForTesting
|
||||
@@ -255,8 +253,7 @@ public class NetworkProviderSettings extends RestrictedSettingsFragment
|
||||
return;
|
||||
}
|
||||
|
||||
mProgressHeader = setPinnedHeaderView(R.layout.progress_header)
|
||||
.findViewById(R.id.progress_bar_animation);
|
||||
setPinnedHeaderView(R.layout.progress_header);
|
||||
setProgressBarVisible(false);
|
||||
|
||||
mWifiManager = activity.getSystemService(WifiManager.class);
|
||||
@@ -1006,9 +1003,7 @@ public class NetworkProviderSettings extends RestrictedSettingsFragment
|
||||
}
|
||||
|
||||
protected void setProgressBarVisible(boolean visible) {
|
||||
if (mProgressHeader != null) {
|
||||
mProgressHeader.setVisibility(visible ? View.VISIBLE : View.GONE);
|
||||
}
|
||||
showPinnedHeader(visible);
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
|
||||
@@ -21,11 +21,14 @@ import android.telephony.AccessNetworkConstants.AccessNetworkType;
|
||||
import android.telephony.CellInfo;
|
||||
import android.telephony.NetworkScan;
|
||||
import android.telephony.NetworkScanRequest;
|
||||
import android.telephony.PhoneCapability;
|
||||
import android.telephony.RadioAccessSpecifier;
|
||||
import android.telephony.TelephonyManager;
|
||||
import android.telephony.TelephonyScanManager;
|
||||
import android.util.Log;
|
||||
|
||||
import androidx.annotation.VisibleForTesting;
|
||||
|
||||
import com.android.internal.telephony.CellNetworkScanResult;
|
||||
|
||||
import com.google.common.util.concurrent.FutureCallback;
|
||||
@@ -37,6 +40,7 @@ import com.google.common.util.concurrent.SettableFuture;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.CancellationException;
|
||||
import java.util.concurrent.Executor;
|
||||
@@ -111,10 +115,14 @@ public class NetworkScanHelper {
|
||||
public static final int NETWORK_SCAN_TYPE_INCREMENTAL_RESULTS = 2;
|
||||
|
||||
/** The constants below are used in the async network scan. */
|
||||
private static final boolean INCREMENTAL_RESULTS = true;
|
||||
private static final int SEARCH_PERIODICITY_SEC = 5;
|
||||
private static final int MAX_SEARCH_TIME_SEC = 300;
|
||||
private static final int INCREMENTAL_RESULTS_PERIODICITY_SEC = 3;
|
||||
@VisibleForTesting
|
||||
static final boolean INCREMENTAL_RESULTS = true;
|
||||
@VisibleForTesting
|
||||
static final int SEARCH_PERIODICITY_SEC = 5;
|
||||
@VisibleForTesting
|
||||
static final int MAX_SEARCH_TIME_SEC = 300;
|
||||
@VisibleForTesting
|
||||
static final int INCREMENTAL_RESULTS_PERIODICITY_SEC = 3;
|
||||
|
||||
private final NetworkScanCallback mNetworkScanCallback;
|
||||
private final TelephonyManager mTelephonyManager;
|
||||
@@ -133,7 +141,8 @@ public class NetworkScanHelper {
|
||||
mExecutor = executor;
|
||||
}
|
||||
|
||||
private NetworkScanRequest createNetworkScanForPreferredAccessNetworks() {
|
||||
@VisibleForTesting
|
||||
NetworkScanRequest createNetworkScanForPreferredAccessNetworks() {
|
||||
long networkTypeBitmap3gpp = mTelephonyManager.getPreferredNetworkTypeBitmask()
|
||||
& TelephonyManager.NETWORK_STANDARDS_FAMILY_BITMASK_3GPP;
|
||||
|
||||
@@ -161,14 +170,13 @@ public class NetworkScanHelper {
|
||||
// a 5G network, which means that it shouldn't scan for 5G at the expense of battery as
|
||||
// part of the manual network selection process.
|
||||
//
|
||||
// FIXME(b/151119451): re-enable this code once there is a way to distinguish SA from NSA
|
||||
// support in the modem.
|
||||
//
|
||||
// if (networkTypeBitmap3gpp == 0
|
||||
// || (networkTypeBitmap3gpp & TelephonyManager.NETWORK_CLASS_BITMASK_5G) != 0) {
|
||||
// radioAccessSpecifiers.add(
|
||||
// new RadioAccessSpecifier(AccessNetworkType.NGRAN, null, null));
|
||||
// }
|
||||
if (networkTypeBitmap3gpp == 0
|
||||
|| (hasNrSaCapability()
|
||||
&& (networkTypeBitmap3gpp & TelephonyManager.NETWORK_CLASS_BITMASK_5G) != 0)) {
|
||||
radioAccessSpecifiers.add(
|
||||
new RadioAccessSpecifier(AccessNetworkType.NGRAN, null, null));
|
||||
Log.d(TAG, "radioAccessSpecifiers add NGRAN.");
|
||||
}
|
||||
|
||||
return new NetworkScanRequest(
|
||||
NetworkScanRequest.SCAN_TYPE_ONE_SHOT,
|
||||
@@ -253,6 +261,12 @@ public class NetworkScanHelper {
|
||||
mNetworkScanCallback.onError(errCode);
|
||||
}
|
||||
|
||||
private boolean hasNrSaCapability() {
|
||||
return Arrays.stream(
|
||||
mTelephonyManager.getPhoneCapability().getDeviceNrCapabilities())
|
||||
.anyMatch(i -> i == PhoneCapability.DEVICE_NR_CAPABILITY_SA);
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts the status code of {@link CellNetworkScanResult} to one of the
|
||||
* {@link NetworkScan.ScanErrorCode}.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2019 The Android Open Source Project
|
||||
* Copyright (C) 2021 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.
|
||||
@@ -18,6 +18,7 @@ package com.android.settings.network.telephony;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.ArgumentMatchers.anyInt;
|
||||
import static org.mockito.Mockito.doAnswer;
|
||||
@@ -27,12 +28,18 @@ import static org.mockito.Mockito.times;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import android.telephony.AccessNetworkConstants;
|
||||
import android.telephony.CellInfo;
|
||||
import android.telephony.ModemInfo;
|
||||
import android.telephony.NetworkScan;
|
||||
import android.telephony.NetworkScanRequest;
|
||||
import android.telephony.PhoneCapability;
|
||||
import android.telephony.RadioAccessSpecifier;
|
||||
import android.telephony.TelephonyManager;
|
||||
import android.telephony.TelephonyScanManager;
|
||||
|
||||
import androidx.test.ext.junit.runners.AndroidJUnit4;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
@@ -41,22 +48,20 @@ import org.mockito.Mock;
|
||||
import org.mockito.MockitoAnnotations;
|
||||
import org.mockito.invocation.InvocationOnMock;
|
||||
import org.mockito.stubbing.Answer;
|
||||
import org.robolectric.RobolectricTestRunner;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.Executor;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
|
||||
@RunWith(RobolectricTestRunner.class)
|
||||
@RunWith(AndroidJUnit4.class)
|
||||
public class NetworkScanHelperTest {
|
||||
|
||||
@Mock
|
||||
private TelephonyManager mTelephonyManager;
|
||||
|
||||
@Mock
|
||||
private List<CellInfo> mCellInfos;
|
||||
|
||||
@Mock
|
||||
private NetworkScanHelper.NetworkScanCallback mNetworkScanCallback;
|
||||
|
||||
@@ -70,7 +75,7 @@ public class NetworkScanHelperTest {
|
||||
|
||||
private NetworkScan mNetworkScan;
|
||||
|
||||
private class NetworkScanMock extends NetworkScan {
|
||||
public class NetworkScanMock extends NetworkScan {
|
||||
NetworkScanMock(int scanId, int subId) {
|
||||
super(scanId, subId);
|
||||
}
|
||||
@@ -163,6 +168,87 @@ public class NetworkScanHelperTest {
|
||||
verify(mNetworkScan, times(1)).stopScan();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void createNetworkScanForPreferredAccessNetworks_deviceNoNrSa_noNgran() {
|
||||
int[] deviceNrCapabilities = new int[]{PhoneCapability.DEVICE_NR_CAPABILITY_NSA};
|
||||
PhoneCapability phoneCapability = createPhoneCapability(deviceNrCapabilities);
|
||||
doReturn(TelephonyManager.NETWORK_CLASS_BITMASK_2G
|
||||
| TelephonyManager.NETWORK_CLASS_BITMASK_3G
|
||||
| TelephonyManager.NETWORK_CLASS_BITMASK_4G
|
||||
| TelephonyManager.NETWORK_CLASS_BITMASK_5G).when(
|
||||
mTelephonyManager).getPreferredNetworkTypeBitmask();
|
||||
doReturn(phoneCapability).when(mTelephonyManager).getPhoneCapability();
|
||||
List<RadioAccessSpecifier> radioAccessSpecifiers = new ArrayList<>();
|
||||
radioAccessSpecifiers.add(
|
||||
new RadioAccessSpecifier(AccessNetworkConstants.AccessNetworkType.GERAN, null,
|
||||
null));
|
||||
radioAccessSpecifiers.add(
|
||||
new RadioAccessSpecifier(AccessNetworkConstants.AccessNetworkType.UTRAN, null,
|
||||
null));
|
||||
radioAccessSpecifiers.add(
|
||||
new RadioAccessSpecifier(AccessNetworkConstants.AccessNetworkType.EUTRAN, null,
|
||||
null));
|
||||
NetworkScanRequest expectedNetworkScanRequest = createNetworkScanRequest(
|
||||
radioAccessSpecifiers);
|
||||
|
||||
assertEquals(expectedNetworkScanRequest,
|
||||
mNetworkScanHelper.createNetworkScanForPreferredAccessNetworks());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void createNetworkScanForPreferredAccessNetworks_deviceHasNrSa_hasNgran() {
|
||||
int[] deviceNrCapabilities = new int[]{PhoneCapability.DEVICE_NR_CAPABILITY_NSA,
|
||||
PhoneCapability.DEVICE_NR_CAPABILITY_SA};
|
||||
PhoneCapability phoneCapability = createPhoneCapability(deviceNrCapabilities);
|
||||
doReturn(TelephonyManager.NETWORK_CLASS_BITMASK_2G
|
||||
| TelephonyManager.NETWORK_CLASS_BITMASK_3G
|
||||
| TelephonyManager.NETWORK_CLASS_BITMASK_4G
|
||||
| TelephonyManager.NETWORK_CLASS_BITMASK_5G).when(
|
||||
mTelephonyManager).getPreferredNetworkTypeBitmask();
|
||||
doReturn(phoneCapability).when(mTelephonyManager).getPhoneCapability();
|
||||
List<RadioAccessSpecifier> radioAccessSpecifiers = new ArrayList<>();
|
||||
radioAccessSpecifiers.add(
|
||||
new RadioAccessSpecifier(AccessNetworkConstants.AccessNetworkType.GERAN, null,
|
||||
null));
|
||||
radioAccessSpecifiers.add(
|
||||
new RadioAccessSpecifier(AccessNetworkConstants.AccessNetworkType.UTRAN, null,
|
||||
null));
|
||||
radioAccessSpecifiers.add(
|
||||
new RadioAccessSpecifier(AccessNetworkConstants.AccessNetworkType.EUTRAN, null,
|
||||
null));
|
||||
radioAccessSpecifiers.add(
|
||||
new RadioAccessSpecifier(AccessNetworkConstants.AccessNetworkType.NGRAN, null,
|
||||
null));
|
||||
NetworkScanRequest expectedNetworkScanRequest = createNetworkScanRequest(
|
||||
radioAccessSpecifiers);
|
||||
|
||||
assertEquals(expectedNetworkScanRequest,
|
||||
mNetworkScanHelper.createNetworkScanForPreferredAccessNetworks());
|
||||
}
|
||||
|
||||
private PhoneCapability createPhoneCapability(int[] deviceNrCapabilities) {
|
||||
int maxActiveVoiceCalls = 1;
|
||||
int maxActiveData = 2;
|
||||
ModemInfo modemInfo = new ModemInfo(1, 2, true, false);
|
||||
List<ModemInfo> logicalModemList = new ArrayList<>();
|
||||
logicalModemList.add(modemInfo);
|
||||
return new PhoneCapability(maxActiveVoiceCalls, maxActiveData,
|
||||
logicalModemList, false, deviceNrCapabilities);
|
||||
}
|
||||
|
||||
private NetworkScanRequest createNetworkScanRequest(
|
||||
List<RadioAccessSpecifier> radioAccessSpecifiers) {
|
||||
return new NetworkScanRequest(
|
||||
NetworkScanRequest.SCAN_TYPE_ONE_SHOT,
|
||||
radioAccessSpecifiers.toArray(
|
||||
new RadioAccessSpecifier[radioAccessSpecifiers.size()]),
|
||||
mNetworkScanHelper.SEARCH_PERIODICITY_SEC,
|
||||
mNetworkScanHelper.MAX_SEARCH_TIME_SEC,
|
||||
mNetworkScanHelper.INCREMENTAL_RESULTS,
|
||||
mNetworkScanHelper.INCREMENTAL_RESULTS_PERIODICITY_SEC,
|
||||
null /* List of PLMN ids (MCC-MNC) */);
|
||||
}
|
||||
|
||||
private void startNetworkScan_incremental(boolean waitForCompletion) {
|
||||
mNetworkScanHelper.startNetworkScan(
|
||||
NetworkScanHelper.NETWORK_SCAN_TYPE_INCREMENTAL_RESULTS);
|
||||
Reference in New Issue
Block a user