Snap for 10255078 from 4834abe241
to udc-qpr1-release
Change-Id: Ia4f2539b0b2f958d592945de991052f0b3ef487f
This commit is contained in:
@@ -23,59 +23,46 @@
|
||||
android:icon="@drawable/ic_scan_32dp"
|
||||
app:sudDescriptionText="@string/wifi_dpp_scan_qr_code_join_unknown_network">
|
||||
|
||||
<LinearLayout
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
style="@style/SudContentFrame"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical"
|
||||
android:gravity="center_horizontal">
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:gravity="center"
|
||||
android:orientation="vertical">
|
||||
<FrameLayout
|
||||
android:id="@+id/frame_layout"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="0dp"
|
||||
app:layout_constraintBottom_toTopOf="@id/error_message"
|
||||
app:layout_constraintDimensionRatio="1:1"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintHeight_max="@dimen/qrcode_preview_size"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintWidth_max="@dimen/qrcode_preview_size">
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
<TextureView
|
||||
android:id="@+id/preview_view"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:maxWidth="@dimen/qrcode_preview_size"
|
||||
android:maxHeight="@dimen/qrcode_preview_size">
|
||||
android:layout_height="match_parent" />
|
||||
|
||||
<FrameLayout
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="0dp"
|
||||
app:layout_constraintDimensionRatio="1:1"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
android:clipChildren="true">
|
||||
<TextureView
|
||||
android:id="@+id/preview_view"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"/>
|
||||
<com.android.settingslib.qrcode.QrDecorateView
|
||||
android:id="@+id/decorate_view"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"/>
|
||||
</FrameLayout>
|
||||
<com.android.settingslib.qrcode.QrDecorateView
|
||||
android:id="@+id/decorate_view"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent" />
|
||||
</FrameLayout>
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/error_message"
|
||||
style="@style/TextAppearance.ErrorText"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="16dp"
|
||||
android:layout_marginStart="?attr/sudMarginStart"
|
||||
android:layout_marginEnd="?attr/sudMarginEnd"
|
||||
android:textAlignment="center"
|
||||
android:visibility="invisible"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
<TextView
|
||||
android:id="@+id/error_message"
|
||||
style="@style/TextAppearance.ErrorText"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginVertical="16dp"
|
||||
android:visibility="invisible"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/frame_layout" />
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
</com.google.android.setupdesign.GlifLayout>
|
||||
|
||||
|
@@ -3020,8 +3020,6 @@
|
||||
<string name="reset_bluetooth_wifi_complete_toast">Bluetooth & Wi\u2011Fi have been reset</string>
|
||||
|
||||
<!-- Erase Euicc -->
|
||||
<!-- Confirmation button of dialog to confirm resetting user's app preferences [CHAR LIMIT=NONE] -->
|
||||
<string name="erase_euicc_data_button">Erase</string>
|
||||
<!-- Erase Euicc dialog and SD card & phone storage settings screen, title for the menu option and checkbox to let user decide whether erase eSIM data together [CHAR LIMIT=50] -->
|
||||
<string name="reset_esim_title">Erase eSIMs</string>
|
||||
<!-- Erase Euicc dialog and SD card & phone storage settings screen, message for the checkbox to let user decide whether erase eSIM data together [CHAR LIMIT=NONE] -->
|
||||
@@ -10189,8 +10187,7 @@
|
||||
<!-- Label explaining that the app installed by credit provider can be uninstalled. [CHAR LIMIT=60]-->
|
||||
<string name="financed_privacy_uninstall_creditor_app">You can uninstall the creditor app</string>
|
||||
<!-- Title of setting on security settings screen on a device provisioned by Device Lock. This will take the user to a screen in Device Lock with information about what a device provider can control and their impact on the user's privacy. Shown on Device Lock provisioned devices only. [CHAR LIMIT=NONE] -->
|
||||
<!-- TODO(b/282040794): Update the title -->
|
||||
<string name="device_lock_info">Device Lock</string>
|
||||
<string name="financed_device_info">Financed device info</string>
|
||||
<!-- Strings for displaying which applications were set as default for specific actions. -->
|
||||
<!-- Title for the apps that have been set as default handlers of camera-related intents. [CHAR LIMIT=30] -->
|
||||
<string name="default_camera_app_title">{count, plural,
|
||||
|
@@ -132,6 +132,8 @@
|
||||
<item name="android:windowSoftInputMode">adjustResize</item>
|
||||
<item name="android:clipToPadding">true</item>
|
||||
<item name="android:clipChildren">true</item>
|
||||
<item name="android:textDirection">locale</item>
|
||||
<item name="android:layoutDirection">locale</item>
|
||||
|
||||
<!-- Redefine the ActionBar style for contentInsetStart -->
|
||||
<item name="android:actionBarStyle">@style/Widget.ActionBar</item>
|
||||
|
@@ -147,8 +147,8 @@
|
||||
settings:controller="com.android.settings.enterprise.FinancedPrivacyPreferenceController"/>
|
||||
|
||||
<Preference
|
||||
android:key="device_lock_info"
|
||||
android:title="@string/device_lock_info"
|
||||
android:key="financed_device_info"
|
||||
android:title="@string/financed_device_info"
|
||||
android:summary="@string/summary_placeholder"
|
||||
settings:controller="com.android.settings.devicelock.DeviceLockPreferenceController">
|
||||
<intent android:action="com.android.devicelockcontroller.action.DEVICE_INFO_SETTINGS"/>
|
||||
|
@@ -59,8 +59,8 @@
|
||||
settings:controller="com.android.settings.enterprise.FinancedPrivacyPreferenceController"/>
|
||||
|
||||
<Preference
|
||||
android:key="device_lock_info"
|
||||
android:title="@string/device_lock_info"
|
||||
android:key="financed_device_info"
|
||||
android:title="@string/financed_device_info"
|
||||
android:summary="@string/summary_placeholder"
|
||||
settings:controller="com.android.settings.devicelock.DeviceLockPreferenceController">
|
||||
<intent android:action="com.android.devicelockcontroller.action.DEVICE_INFO_SETTINGS"/>
|
||||
|
@@ -99,7 +99,7 @@ public class BluetoothDetailsProfilesController extends BluetoothDetailsControll
|
||||
mIsLeContactSharingEnabled = DeviceConfig.getBoolean(DeviceConfig.NAMESPACE_SETTINGS_UI,
|
||||
SettingsUIDeviceConfig.BT_LE_AUDIO_CONTACT_SHARING_ENABLED, true);
|
||||
mIsLeAudioToggleEnabled = DeviceConfig.getBoolean(DeviceConfig.NAMESPACE_SETTINGS_UI,
|
||||
SettingsUIDeviceConfig.BT_LE_AUDIO_DEVICE_DETAIL_ENABLED, false)
|
||||
SettingsUIDeviceConfig.BT_LE_AUDIO_DEVICE_DETAIL_ENABLED, true)
|
||||
|| DeviceConfig.getBoolean(DeviceConfig.NAMESPACE_BLUETOOTH,
|
||||
CONFIG_LE_AUDIO_ENABLED_BY_DEFAULT, false);
|
||||
// Call refresh here even though it will get called later in onResume, to avoid the
|
||||
|
@@ -34,6 +34,8 @@ import com.android.settingslib.drawer.ProviderTile;
|
||||
import com.android.settingslib.drawer.Tile;
|
||||
import com.android.settingslib.drawer.TileUtils;
|
||||
|
||||
import com.google.android.setupcompat.util.WizardManagerHelper;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
@@ -79,6 +81,9 @@ public class CategoryManager {
|
||||
}
|
||||
|
||||
public synchronized List<DashboardCategory> getCategories(Context context) {
|
||||
if (!WizardManagerHelper.isUserSetupComplete(context)) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
tryInitCategories(context);
|
||||
return mCategories;
|
||||
}
|
||||
@@ -142,6 +147,10 @@ public class CategoryManager {
|
||||
}
|
||||
|
||||
private synchronized void tryInitCategories(Context context, boolean forceClearCache) {
|
||||
if (!WizardManagerHelper.isUserSetupComplete(context)) {
|
||||
// Don't init while setup wizard is still running.
|
||||
return;
|
||||
}
|
||||
if (mCategories == null) {
|
||||
final boolean firstLoading = mCategoryByKeyMap.isEmpty();
|
||||
if (forceClearCache) {
|
||||
|
@@ -40,6 +40,7 @@ public class BluetoothLeAudioDeviceDetailsPreferenceController
|
||||
|
||||
private static final String PREFERENCE_KEY = "bluetooth_show_leaudio_device_details";
|
||||
private static final String CONFIG_LE_AUDIO_ENABLED_BY_DEFAULT = "le_audio_enabled_by_default";
|
||||
private static final boolean LE_AUDIO_DEVICE_DETAIL_DEFAULT_VALUE = true;
|
||||
static int sLeAudioSupportedStateCache = BluetoothStatusCodes.ERROR_UNKNOWN;
|
||||
|
||||
@VisibleForTesting
|
||||
@@ -75,7 +76,7 @@ public class BluetoothLeAudioDeviceDetailsPreferenceController
|
||||
DeviceConfig.setProperty(
|
||||
DeviceConfig.NAMESPACE_SETTINGS_UI,
|
||||
SettingsUIDeviceConfig.BT_LE_AUDIO_DEVICE_DETAIL_ENABLED,
|
||||
isEnabled ? "true" : "false", false);
|
||||
isEnabled ? "true" : "false", LE_AUDIO_DEVICE_DETAIL_DEFAULT_VALUE);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -87,7 +88,8 @@ public class BluetoothLeAudioDeviceDetailsPreferenceController
|
||||
|
||||
final boolean leAudioDeviceDetailEnabled = DeviceConfig.getBoolean(
|
||||
DeviceConfig.NAMESPACE_SETTINGS_UI,
|
||||
SettingsUIDeviceConfig.BT_LE_AUDIO_DEVICE_DETAIL_ENABLED, false);
|
||||
SettingsUIDeviceConfig.BT_LE_AUDIO_DEVICE_DETAIL_ENABLED,
|
||||
LE_AUDIO_DEVICE_DETAIL_DEFAULT_VALUE);
|
||||
final boolean leAudioEnabledByDefault = DeviceConfig.getBoolean(
|
||||
DeviceConfig.NAMESPACE_BLUETOOTH, CONFIG_LE_AUDIO_ENABLED_BY_DEFAULT, false);
|
||||
|
||||
@@ -102,6 +104,7 @@ public class BluetoothLeAudioDeviceDetailsPreferenceController
|
||||
// Reset the toggle to null when the developer option is disabled
|
||||
DeviceConfig.setProperty(
|
||||
DeviceConfig.NAMESPACE_SETTINGS_UI,
|
||||
SettingsUIDeviceConfig.BT_LE_AUDIO_DEVICE_DETAIL_ENABLED, "null", false);
|
||||
SettingsUIDeviceConfig.BT_LE_AUDIO_DEVICE_DETAIL_ENABLED, "null",
|
||||
LE_AUDIO_DEVICE_DETAIL_DEFAULT_VALUE);
|
||||
}
|
||||
}
|
||||
|
@@ -23,7 +23,6 @@ import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.os.AsyncTask;
|
||||
import android.os.Bundle;
|
||||
import android.os.RecoverySystem;
|
||||
import android.util.Log;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
@@ -62,7 +61,7 @@ public class EraseEuiccDataDialogFragment extends InstrumentedDialogFragment imp
|
||||
return new AlertDialog.Builder(getActivity())
|
||||
.setTitle(R.string.reset_esim_title)
|
||||
.setMessage(R.string.reset_esim_desc)
|
||||
.setPositiveButton(R.string.erase_euicc_data_button, this)
|
||||
.setPositiveButton(R.string.erase_sim_confirm_button, this)
|
||||
.setNegativeButton(R.string.cancel, null)
|
||||
.setOnDismissListener(this)
|
||||
.create();
|
||||
|
@@ -46,10 +46,12 @@ import androidx.preference.PreferenceGroup;
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.Settings;
|
||||
import com.android.settings.Settings.TetherSettingsActivity;
|
||||
import com.android.settings.Settings.WifiTetherSettingsActivity;
|
||||
import com.android.settings.activityembedding.ActivityEmbeddingUtils;
|
||||
import com.android.settings.core.BasePreferenceController;
|
||||
import com.android.settings.gestures.OneHandedSettingsUtils;
|
||||
import com.android.settings.overlay.FeatureFactory;
|
||||
import com.android.settings.wifi.WifiUtils;
|
||||
import com.android.settingslib.core.instrumentation.MetricsFeatureProvider;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -192,6 +194,12 @@ public class CreateShortcutPreferenceController extends BasePreferenceController
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if (info.activityInfo.name.endsWith(WifiTetherSettingsActivity.class.getSimpleName())) {
|
||||
if (!canShowWifiHotspot()) {
|
||||
Log.d(TAG, "Skipping Wi-Fi hotspot settings:" + info.activityInfo);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if (!info.activityInfo.applicationInfo.isSystemApp()) {
|
||||
Log.d(TAG, "Skipping non-system app: " + info.activityInfo);
|
||||
continue;
|
||||
@@ -202,6 +210,11 @@ public class CreateShortcutPreferenceController extends BasePreferenceController
|
||||
return shortcuts;
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
boolean canShowWifiHotspot() {
|
||||
return WifiUtils.canShowWifiHotspot(mContext);
|
||||
}
|
||||
|
||||
private void logCreateShortcut(ResolveInfo info) {
|
||||
if (info == null || info.activityInfo == null) {
|
||||
return;
|
||||
|
@@ -39,10 +39,12 @@ import androidx.fragment.app.Fragment;
|
||||
import androidx.fragment.app.FragmentActivity;
|
||||
import androidx.fragment.app.FragmentManager;
|
||||
|
||||
import com.android.internal.annotations.VisibleForTesting;
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.network.CarrierConfigCache;
|
||||
import com.android.settings.network.SubscriptionUtil;
|
||||
import com.android.settings.network.ims.WifiCallingQueryImsState;
|
||||
import com.android.settings.network.telephony.MobileNetworkUtils;
|
||||
import com.android.settings.network.telephony.SubscriptionActionDialogActivity;
|
||||
import com.android.settings.overlay.FeatureFactory;
|
||||
import com.android.settingslib.core.instrumentation.MetricsFeatureProvider;
|
||||
@@ -77,7 +79,10 @@ public class SimDialogActivity extends FragmentActivity {
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
if (isUiRestricted()) {
|
||||
finish();
|
||||
return;
|
||||
}
|
||||
if (!SubscriptionUtil.isSimHardwareVisible(this)) {
|
||||
Log.d(TAG, "Not support on device without SIM.");
|
||||
finish();
|
||||
@@ -91,6 +96,15 @@ public class SimDialogActivity extends FragmentActivity {
|
||||
showOrUpdateDialog();
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
boolean isUiRestricted() {
|
||||
if (MobileNetworkUtils.isMobileNetworkUserRestricted(getApplicationContext())) {
|
||||
Log.e(TAG, "This setting isn't available due to user restriction.");
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onNewIntent(Intent intent) {
|
||||
super.onNewIntent(intent);
|
||||
|
@@ -41,6 +41,7 @@ object AppLanguagesPageProvider : SettingsPageProvider {
|
||||
AppListPage(
|
||||
title = stringResource(R.string.app_locales_picker_menu_title),
|
||||
listModel = rememberContext(::AppLanguagesListModel),
|
||||
noMoreOptions = true,
|
||||
header = {
|
||||
Box(Modifier.padding(SettingsDimension.itemPadding)) {
|
||||
SettingsBody(stringResource(R.string.desc_app_locale_selection_supported))
|
||||
|
@@ -84,7 +84,7 @@ public class CreateShortcutPreferenceControllerTest {
|
||||
mShadowConnectivityManager = ShadowConnectivityManager.getShadow();
|
||||
mShadowConnectivityManager.setTetheringSupported(true);
|
||||
|
||||
mController = new CreateShortcutPreferenceController(mContext, "key");
|
||||
mController = spy(new CreateShortcutPreferenceController(mContext, "key"));
|
||||
mController.setActivity(mHost);
|
||||
}
|
||||
|
||||
@@ -159,27 +159,39 @@ public class CreateShortcutPreferenceControllerTest {
|
||||
@Test
|
||||
public void queryShortcuts_setSupportOneHandedMode_ShouldEnableShortcuts() {
|
||||
SystemProperties.set(SUPPORT_ONE_HANDED_MODE, "true");
|
||||
setupActivityInfo(Settings.OneHandedSettingsActivity.class.getSimpleName());
|
||||
|
||||
setupOneHandedModeActivityInfo();
|
||||
final List<ResolveInfo> info = mController.queryShortcuts();
|
||||
|
||||
assertThat(info).hasSize(1);
|
||||
assertThat(mController.queryShortcuts()).hasSize(1);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void queryShortcuts_setUnsupportOneHandedMode_ShouldDisableShortcuts() {
|
||||
SystemProperties.set(SUPPORT_ONE_HANDED_MODE, "false");
|
||||
setupActivityInfo(Settings.OneHandedSettingsActivity.class.getSimpleName());
|
||||
|
||||
setupOneHandedModeActivityInfo();
|
||||
final List<ResolveInfo> info = mController.queryShortcuts();
|
||||
|
||||
assertThat(info).hasSize(0);
|
||||
assertThat(mController.queryShortcuts()).hasSize(0);
|
||||
}
|
||||
|
||||
private void setupOneHandedModeActivityInfo() {
|
||||
final ResolveInfo ri = new ResolveInfo();
|
||||
@Test
|
||||
public void queryShortcuts_configShowWifiHotspot_ShouldEnableShortcuts() {
|
||||
when(mController.canShowWifiHotspot()).thenReturn(true);
|
||||
setupActivityInfo(Settings.WifiTetherSettingsActivity.class.getSimpleName());
|
||||
|
||||
assertThat(mController.queryShortcuts()).hasSize(1);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void queryShortcuts_configNotShowWifiHotspot_ShouldDisableShortcuts() {
|
||||
when(mController.canShowWifiHotspot()).thenReturn(false);
|
||||
setupActivityInfo(Settings.WifiTetherSettingsActivity.class.getSimpleName());
|
||||
|
||||
assertThat(mController.queryShortcuts()).hasSize(0);
|
||||
}
|
||||
|
||||
private void setupActivityInfo(String name) {
|
||||
ResolveInfo ri = new ResolveInfo();
|
||||
ri.activityInfo = new ActivityInfo();
|
||||
ri.activityInfo.name = Settings.OneHandedSettingsActivity.class.getSimpleName();
|
||||
ri.activityInfo.name = name;
|
||||
ri.activityInfo.applicationInfo = new ApplicationInfo();
|
||||
ri.activityInfo.applicationInfo.flags = ApplicationInfo.FLAG_SYSTEM;
|
||||
|
||||
|
@@ -190,6 +190,7 @@ public class BatteryTestUtils {
|
||||
when(mockUsbPort.getStatus()).thenReturn(mockUsbPortStatus);
|
||||
when(mockUsbPort.supportsComplianceWarnings()).thenReturn(true);
|
||||
when(mockUsbPortStatus.isConnected()).thenReturn(true);
|
||||
when(mockUsbPortStatus.getComplianceWarnings()).thenReturn(new int[]{1});
|
||||
when(mockUsbPortStatus.getComplianceWarnings())
|
||||
.thenReturn(new int[]{UsbPortStatus.COMPLIANCE_WARNING_OTHER});
|
||||
}
|
||||
}
|
||||
|
@@ -0,0 +1,87 @@
|
||||
/*
|
||||
* Copyright (C) 2023 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.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.android.settings.sim;
|
||||
|
||||
import static android.os.UserManager.DISALLOW_CONFIG_MOBILE_NETWORKS;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.UserManager;
|
||||
|
||||
import androidx.test.annotation.UiThreadTest;
|
||||
import androidx.test.core.app.ApplicationProvider;
|
||||
import androidx.test.ext.junit.runners.AndroidJUnit4;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.Spy;
|
||||
import org.mockito.junit.MockitoJUnit;
|
||||
import org.mockito.junit.MockitoRule;
|
||||
|
||||
@RunWith(AndroidJUnit4.class)
|
||||
@UiThreadTest
|
||||
public class SimDialogActivityTest {
|
||||
@Rule
|
||||
public final MockitoRule mMockitoRule = MockitoJUnit.rule();
|
||||
@Spy
|
||||
private final Context mContext = ApplicationProvider.getApplicationContext();
|
||||
@Mock
|
||||
private UserManager mUserManager;
|
||||
|
||||
private MockSimDialogActivity mActivity;
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
when(mContext.getSystemService(UserManager.class)).thenReturn(mUserManager);
|
||||
when(mUserManager.isGuestUser()).thenReturn(false);
|
||||
when(mUserManager.hasUserRestriction(DISALLOW_CONFIG_MOBILE_NETWORKS)).thenReturn(false);
|
||||
|
||||
mActivity = new MockSimDialogActivity();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void isUiRestricted_normally_returnFalse() {
|
||||
assertThat(mActivity.isUiRestricted()).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void isUiRestricted_isGuestUser_returnTrue() {
|
||||
when(mUserManager.isGuestUser()).thenReturn(true);
|
||||
|
||||
assertThat(mActivity.isUiRestricted()).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void isUiRestricted_hasUserRestriction_returnTrue() {
|
||||
when(mUserManager.hasUserRestriction(DISALLOW_CONFIG_MOBILE_NETWORKS)).thenReturn(true);
|
||||
|
||||
assertThat(mActivity.isUiRestricted()).isTrue();
|
||||
}
|
||||
|
||||
public class MockSimDialogActivity extends SimDialogActivity {
|
||||
@Override
|
||||
public Context getApplicationContext() {
|
||||
return mContext;
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user