Snap for 8362632 from 6f94d1f784 to tm-release
Change-Id: I8cc40445ff3a8e0f7e98becedcacdfa364203a78
This commit is contained in:
@@ -2343,7 +2343,7 @@
|
|||||||
</activity>
|
</activity>
|
||||||
|
|
||||||
<activity android:name=".password.ScreenLockSuggestionActivity"
|
<activity android:name=".password.ScreenLockSuggestionActivity"
|
||||||
android:exported="true"
|
android:exported="false"
|
||||||
android:icon="@drawable/ic_suggestion_security">
|
android:icon="@drawable/ic_suggestion_security">
|
||||||
<intent-filter android:priority="1">
|
<intent-filter android:priority="1">
|
||||||
<action android:name="android.intent.action.MAIN" />
|
<action android:name="android.intent.action.MAIN" />
|
||||||
|
|||||||
@@ -27,9 +27,14 @@
|
|||||||
android:id="@+id/reset_button"
|
android:id="@+id/reset_button"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_gravity="center"
|
android:layout_gravity="center|end"
|
||||||
android:paddingHorizontal="24dp"
|
|
||||||
android:paddingVertical="14dp"
|
android:paddingVertical="14dp"
|
||||||
android:text="@string/accessibility_text_reading_reset_button_title"
|
android:background="@null"
|
||||||
style="@style/ActionPrimaryButton"/>
|
android:drawableStart="@drawable/ic_history"
|
||||||
|
android:drawablePadding="9dp"
|
||||||
|
android:drawableTint="?android:attr/colorAccent"
|
||||||
|
android:textColor="?android:attr/colorAccent"
|
||||||
|
android:textSize="16sp"
|
||||||
|
android:textAppearance="@android:style/TextAppearance.DeviceDefault.Medium"
|
||||||
|
android:text="@string/accessibility_text_reading_reset_button_title"/>
|
||||||
</FrameLayout>
|
</FrameLayout>
|
||||||
|
|||||||
@@ -4680,8 +4680,8 @@
|
|||||||
<string name="clear_user_data_text">Clear storage</string>
|
<string name="clear_user_data_text">Clear storage</string>
|
||||||
<!-- Manage applications, restore updated system application to factory version -->
|
<!-- Manage applications, restore updated system application to factory version -->
|
||||||
<string name="app_factory_reset">Uninstall updates</string>
|
<string name="app_factory_reset">Uninstall updates</string>
|
||||||
<!-- [CHAR LIMIT=50] Manage applications, unlock restricted settings from lock screen title -->
|
<!-- [CHAR LIMIT=50] Manage applications, unlock restricted setting from lock screen title -->
|
||||||
<string name="app_restricted_settings_lockscreen_title">Unlock restricted settings</string>
|
<string name="app_restricted_settings_lockscreen_title">Allow restricted settings</string>
|
||||||
<!-- Manage applications, individual application info screen, screen, message text under Launch by default heading. This is present if the app is set as a default for some actions. -->
|
<!-- Manage applications, individual application info screen, screen, message text under Launch by default heading. This is present if the app is set as a default for some actions. -->
|
||||||
<string name="auto_launch_enable_text">Some activities you\u2019ve selected open in this app by default.</string>
|
<string name="auto_launch_enable_text">Some activities you\u2019ve selected open in this app by default.</string>
|
||||||
<!-- Manage applications, individual application info screen, screen, message text under Launch by default heading. This is present if the app was given user permission to create widgets. -->
|
<!-- Manage applications, individual application info screen, screen, message text under Launch by default heading. This is present if the app was given user permission to create widgets. -->
|
||||||
@@ -12166,7 +12166,9 @@
|
|||||||
<!-- Button label to allow the user to view additional information [CHAR LIMIT=NONE BACKUP_MESSAGE_ID=2416766240581561009] -->
|
<!-- Button label to allow the user to view additional information [CHAR LIMIT=NONE BACKUP_MESSAGE_ID=2416766240581561009] -->
|
||||||
<string name="learn_more">Learn more</string>
|
<string name="learn_more">Learn more</string>
|
||||||
<!--Title for dialog displayed to tell user that settings are blocked by setting restrictions [CHAR LIMIT=50] -->
|
<!--Title for dialog displayed to tell user that settings are blocked by setting restrictions [CHAR LIMIT=50] -->
|
||||||
<string name="blocked_by_restricted_settings_title">Restricted Settings</string>
|
<string name="blocked_by_restricted_settings_title">Restricted setting</string>
|
||||||
|
<!--Toast message shown after the user successfully allows restricted settings [CHAR LIMIT=50] -->
|
||||||
|
<string name="toast_allows_restricted_settings_successfully">Restricted settings allowed for <xliff:g id="app_name" example="Gmail">%s</xliff:g></string>
|
||||||
<!--Content for dialog displayed to tell user that settings are blocked by setting restrictions [CHAR LIMIT=100] -->
|
<!--Content for dialog displayed to tell user that settings are blocked by setting restrictions [CHAR LIMIT=100] -->
|
||||||
<string name="blocked_by_restricted_settings_content">For your security, this setting is currently unavailable.</string>
|
<string name="blocked_by_restricted_settings_content">For your security, this setting is currently unavailable.</string>
|
||||||
|
|
||||||
|
|||||||
@@ -141,7 +141,7 @@
|
|||||||
|
|
||||||
<PreferenceCategory
|
<PreferenceCategory
|
||||||
android:key="app_hibernation_info"
|
android:key="app_hibernation_info"
|
||||||
android:title="@string/unused_apps"
|
android:title="@string/unused_apps_category"
|
||||||
settings:controller=
|
settings:controller=
|
||||||
"com.android.settings.applications.appinfo.AppHibernationPreferenceCategoryController">
|
"com.android.settings.applications.appinfo.AppHibernationPreferenceCategoryController">
|
||||||
|
|
||||||
|
|||||||
@@ -118,6 +118,11 @@ public class AccessibilityDialogUtils {
|
|||||||
* launch tutorial.
|
* launch tutorial.
|
||||||
*/
|
*/
|
||||||
int LAUNCH_ACCESSIBILITY_TUTORIAL = 1008;
|
int LAUNCH_ACCESSIBILITY_TUTORIAL = 1008;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* OPEN: Settings > Accessibility > Display size and text > Click 'Reset settings' button.
|
||||||
|
*/
|
||||||
|
int DIALOG_RESET_SETTINGS = 1009;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -333,6 +333,10 @@ public abstract class AccessibilityShortcutPreferenceFragment extends DashboardF
|
|||||||
mShortcutPreference.setChecked(shortcutAssigned);
|
mShortcutPreference.setChecked(shortcutAssigned);
|
||||||
mShortcutPreference.setSummary(getShortcutTypeSummary(getPrefContext()));
|
mShortcutPreference.setSummary(getShortcutTypeSummary(getPrefContext()));
|
||||||
|
|
||||||
|
if (mHardwareTypeCheckBox.isChecked()) {
|
||||||
|
AccessibilityUtil.skipVolumeShortcutDialogTimeoutRestriction(getPrefContext());
|
||||||
|
}
|
||||||
|
|
||||||
// Show the quick setting tooltip if the shortcut assigned in the first time
|
// Show the quick setting tooltip if the shortcut assigned in the first time
|
||||||
if (shortcutAssigned) {
|
if (shortcutAssigned) {
|
||||||
showQuickSettingsTooltipIfNeeded();
|
showQuickSettingsTooltipIfNeeded();
|
||||||
|
|||||||
@@ -434,4 +434,15 @@ public final class AccessibilityUtil {
|
|||||||
public static boolean isSystemApp(@NonNull AccessibilityServiceInfo info) {
|
public static boolean isSystemApp(@NonNull AccessibilityServiceInfo info) {
|
||||||
return info.getResolveInfo().serviceInfo.applicationInfo.isSystemApp();
|
return info.getResolveInfo().serviceInfo.applicationInfo.isSystemApp();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Bypasses the timeout restriction if volume key shortcut assigned.
|
||||||
|
*
|
||||||
|
* @param context the current context.
|
||||||
|
*/
|
||||||
|
public static void skipVolumeShortcutDialogTimeoutRestriction(Context context) {
|
||||||
|
Settings.Secure.putInt(context.getContentResolver(),
|
||||||
|
Settings.Secure.SKIP_ACCESSIBILITY_SHORTCUT_DIALOG_TIMEOUT_RESTRICTION, /*
|
||||||
|
true */ 1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,10 +18,15 @@ package com.android.settings.accessibility;
|
|||||||
|
|
||||||
import static com.android.settings.accessibility.TextReadingResetController.ResetStateListener;
|
import static com.android.settings.accessibility.TextReadingResetController.ResetStateListener;
|
||||||
|
|
||||||
|
import android.app.Dialog;
|
||||||
import android.app.settings.SettingsEnums;
|
import android.app.settings.SettingsEnums;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.content.DialogInterface;
|
||||||
|
|
||||||
|
import androidx.appcompat.app.AlertDialog;
|
||||||
|
|
||||||
import com.android.settings.R;
|
import com.android.settings.R;
|
||||||
|
import com.android.settings.accessibility.AccessibilityDialogUtils.DialogEnums;
|
||||||
import com.android.settings.dashboard.DashboardFragment;
|
import com.android.settings.dashboard.DashboardFragment;
|
||||||
import com.android.settings.search.BaseSearchIndexProvider;
|
import com.android.settings.search.BaseSearchIndexProvider;
|
||||||
import com.android.settingslib.core.AbstractPreferenceController;
|
import com.android.settingslib.core.AbstractPreferenceController;
|
||||||
@@ -88,16 +93,54 @@ public class TextReadingPreferenceFragment extends DashboardFragment {
|
|||||||
new HighTextContrastPreferenceController(context, HIGHT_TEXT_CONTRAST_KEY);
|
new HighTextContrastPreferenceController(context, HIGHT_TEXT_CONTRAST_KEY);
|
||||||
controllers.add(highTextContrastController);
|
controllers.add(highTextContrastController);
|
||||||
|
|
||||||
final List<ResetStateListener> resetStateListeners =
|
|
||||||
controllers.stream().filter(c -> c instanceof ResetStateListener).map(
|
|
||||||
c -> (ResetStateListener) c).collect(Collectors.toList());
|
|
||||||
final TextReadingResetController resetController =
|
final TextReadingResetController resetController =
|
||||||
new TextReadingResetController(context, RESET_KEY, resetStateListeners);
|
new TextReadingResetController(context, RESET_KEY,
|
||||||
|
v -> showDialog(DialogEnums.DIALOG_RESET_SETTINGS));
|
||||||
controllers.add(resetController);
|
controllers.add(resetController);
|
||||||
|
|
||||||
return controllers;
|
return controllers;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Dialog onCreateDialog(int dialogId) {
|
||||||
|
if (dialogId == DialogEnums.DIALOG_RESET_SETTINGS) {
|
||||||
|
return new AlertDialog.Builder(getPrefContext())
|
||||||
|
.setTitle(R.string.accessibility_text_reading_confirm_dialog_title)
|
||||||
|
.setMessage(R.string.accessibility_text_reading_confirm_dialog_message)
|
||||||
|
.setPositiveButton(
|
||||||
|
R.string.accessibility_text_reading_confirm_dialog_reset_button,
|
||||||
|
this::onPositiveButtonClicked)
|
||||||
|
.setNegativeButton(R.string.cancel, /* listener= */ null)
|
||||||
|
.create();
|
||||||
|
}
|
||||||
|
|
||||||
|
throw new IllegalArgumentException("Unsupported dialogId " + dialogId);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getDialogMetricsCategory(int dialogId) {
|
||||||
|
if (dialogId == DialogEnums.DIALOG_RESET_SETTINGS) {
|
||||||
|
return SettingsEnums.DIALOG_RESET_SETTINGS;
|
||||||
|
}
|
||||||
|
|
||||||
|
return super.getDialogMetricsCategory(dialogId);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void onPositiveButtonClicked(DialogInterface dialog, int which) {
|
||||||
|
// To avoid showing the dialog again, probably the onDetach() of SettingsDialogFragment
|
||||||
|
// was interrupted by unexpectedly recreating the activity.
|
||||||
|
removeDialog(DialogEnums.DIALOG_RESET_SETTINGS);
|
||||||
|
|
||||||
|
getResetStateListeners().forEach(ResetStateListener::resetState);
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<ResetStateListener> getResetStateListeners() {
|
||||||
|
final List<AbstractPreferenceController> controllers = new ArrayList<>();
|
||||||
|
getPreferenceControllers().forEach(controllers::addAll);
|
||||||
|
return controllers.stream().filter(c -> c instanceof ResetStateListener).map(
|
||||||
|
c -> (ResetStateListener) c).collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
|
||||||
public static final BaseSearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
|
public static final BaseSearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
|
||||||
new BaseSearchIndexProvider(R.xml.accessibility_text_reading_options);
|
new BaseSearchIndexProvider(R.xml.accessibility_text_reading_options);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,25 +19,23 @@ package com.android.settings.accessibility;
|
|||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.Nullable;
|
||||||
import androidx.preference.PreferenceScreen;
|
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.widget.LayoutPreference;
|
import com.android.settingslib.widget.LayoutPreference;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The controller of the reset button in the text and reading options page.
|
* The controller of the reset button in the text and reading options page.
|
||||||
*/
|
*/
|
||||||
class TextReadingResetController extends BasePreferenceController {
|
class TextReadingResetController extends BasePreferenceController {
|
||||||
private final List<ResetStateListener> mListeners;
|
private final View.OnClickListener mOnResetClickListener;
|
||||||
|
|
||||||
TextReadingResetController(Context context, String preferenceKey,
|
TextReadingResetController(Context context, String preferenceKey,
|
||||||
@NonNull List<ResetStateListener> listeners) {
|
@Nullable View.OnClickListener listener) {
|
||||||
super(context, preferenceKey);
|
super(context, preferenceKey);
|
||||||
mListeners = listeners;
|
mOnResetClickListener = listener;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -51,7 +49,11 @@ class TextReadingResetController extends BasePreferenceController {
|
|||||||
|
|
||||||
final LayoutPreference layoutPreference = screen.findPreference(getPreferenceKey());
|
final LayoutPreference layoutPreference = screen.findPreference(getPreferenceKey());
|
||||||
final View view = layoutPreference.findViewById(R.id.reset_button);
|
final View view = layoutPreference.findViewById(R.id.reset_button);
|
||||||
view.setOnClickListener(v -> mListeners.forEach(ResetStateListener::resetState));
|
view.setOnClickListener(v -> {
|
||||||
|
if (mOnResetClickListener != null) {
|
||||||
|
mOnResetClickListener.onClick(v);
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -725,6 +725,10 @@ public abstract class ToggleFeaturePreferenceFragment extends SettingsPreference
|
|||||||
mShortcutPreference.setChecked(shortcutAssigned);
|
mShortcutPreference.setChecked(shortcutAssigned);
|
||||||
mShortcutPreference.setSummary(getShortcutTypeSummary(getPrefContext()));
|
mShortcutPreference.setSummary(getShortcutTypeSummary(getPrefContext()));
|
||||||
|
|
||||||
|
if (mHardwareTypeCheckBox.isChecked()) {
|
||||||
|
AccessibilityUtil.skipVolumeShortcutDialogTimeoutRestriction(getPrefContext());
|
||||||
|
}
|
||||||
|
|
||||||
// Show the quick setting tooltip if the shortcut assigned in the first time
|
// Show the quick setting tooltip if the shortcut assigned in the first time
|
||||||
if (shortcutAssigned) {
|
if (shortcutAssigned) {
|
||||||
showQuickSettingsTooltipIfNeeded();
|
showQuickSettingsTooltipIfNeeded();
|
||||||
|
|||||||
@@ -367,6 +367,10 @@ public class ToggleScreenMagnificationPreferenceFragment extends
|
|||||||
mShortcutPreference.setChecked(value != UserShortcutType.EMPTY);
|
mShortcutPreference.setChecked(value != UserShortcutType.EMPTY);
|
||||||
mShortcutPreference.setSummary(
|
mShortcutPreference.setSummary(
|
||||||
getShortcutTypeSummary(getPrefContext()));
|
getShortcutTypeSummary(getPrefContext()));
|
||||||
|
|
||||||
|
if (mHardwareTypeCheckBox.isChecked()) {
|
||||||
|
AccessibilityUtil.skipVolumeShortcutDialogTimeoutRestriction(getPrefContext());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -48,6 +48,7 @@ import android.util.Log;
|
|||||||
import android.view.Menu;
|
import android.view.Menu;
|
||||||
import android.view.MenuInflater;
|
import android.view.MenuInflater;
|
||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
|
import android.widget.Toast;
|
||||||
|
|
||||||
import androidx.annotation.VisibleForTesting;
|
import androidx.annotation.VisibleForTesting;
|
||||||
|
|
||||||
@@ -443,14 +444,14 @@ public class AppInfoDashboardFragment extends DashboardFragment
|
|||||||
};
|
};
|
||||||
|
|
||||||
final BiometricPrompt.Builder builder = new BiometricPrompt.Builder(context)
|
final BiometricPrompt.Builder builder = new BiometricPrompt.Builder(context)
|
||||||
.setTitle(context.getText(R.string.app_restricted_settings_lockscreen_title));
|
.setUseDefaultTitle(); // use default title if title is null/empty
|
||||||
|
|
||||||
if (context.getSystemService(BiometricManager.class).canAuthenticate(
|
final BiometricManager bm = context.getSystemService(BiometricManager.class);
|
||||||
BiometricManager.Authenticators.DEVICE_CREDENTIAL
|
final int authenticators = BiometricManager.Authenticators.DEVICE_CREDENTIAL
|
||||||
| BiometricManager.Authenticators.BIOMETRIC_WEAK)
|
| BiometricManager.Authenticators.BIOMETRIC_WEAK;
|
||||||
== BiometricManager.BIOMETRIC_SUCCESS) {
|
if (bm.canAuthenticate(authenticators) == BiometricManager.BIOMETRIC_SUCCESS) {
|
||||||
builder.setAllowedAuthenticators(BiometricManager.Authenticators.DEVICE_CREDENTIAL
|
builder.setAllowedAuthenticators(authenticators);
|
||||||
| BiometricManager.Authenticators.BIOMETRIC_WEAK);
|
builder.setSubtitle(bm.getStrings(authenticators).getPromptMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
final BiometricPrompt bp = builder.build();
|
final BiometricPrompt bp = builder.build();
|
||||||
@@ -481,6 +482,10 @@ public class AppInfoDashboardFragment extends DashboardFragment
|
|||||||
getPackageName(),
|
getPackageName(),
|
||||||
AppOpsManager.MODE_ALLOWED);
|
AppOpsManager.MODE_ALLOWED);
|
||||||
getActivity().invalidateOptionsMenu();
|
getActivity().invalidateOptionsMenu();
|
||||||
|
final String toastString = getContext().getString(
|
||||||
|
R.string.toast_allows_restricted_settings_successfully,
|
||||||
|
mAppEntry.label);
|
||||||
|
Toast.makeText(getContext(), toastString, Toast.LENGTH_LONG).show();
|
||||||
});
|
});
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -32,8 +32,9 @@ import android.graphics.drawable.Drawable;
|
|||||||
import android.graphics.drawable.LayerDrawable;
|
import android.graphics.drawable.LayerDrawable;
|
||||||
import android.hardware.fingerprint.FingerprintManager;
|
import android.hardware.fingerprint.FingerprintManager;
|
||||||
import android.hardware.fingerprint.FingerprintSensorPropertiesInternal;
|
import android.hardware.fingerprint.FingerprintSensorPropertiesInternal;
|
||||||
import android.media.AudioAttributes;
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.os.Process;
|
||||||
|
import android.os.VibrationAttributes;
|
||||||
import android.os.VibrationEffect;
|
import android.os.VibrationEffect;
|
||||||
import android.os.Vibrator;
|
import android.os.Vibrator;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
@@ -108,11 +109,8 @@ public class FingerprintEnrollEnrolling extends BiometricsEnrollEnrolling {
|
|||||||
|
|
||||||
private static final VibrationEffect VIBRATE_EFFECT_ERROR =
|
private static final VibrationEffect VIBRATE_EFFECT_ERROR =
|
||||||
VibrationEffect.createWaveform(new long[] {0, 5, 55, 60}, -1);
|
VibrationEffect.createWaveform(new long[] {0, 5, 55, 60}, -1);
|
||||||
private static final AudioAttributes FINGERPRINT_ENROLLING_SONFICATION_ATTRIBUTES =
|
private static final VibrationAttributes FINGERPRINT_ENROLLING_SONFICATION_ATTRIBUTES =
|
||||||
new AudioAttributes.Builder()
|
VibrationAttributes.createForUsage(VibrationAttributes.USAGE_ACCESSIBILITY);
|
||||||
.setContentType(AudioAttributes.CONTENT_TYPE_SONIFICATION)
|
|
||||||
.setUsage(AudioAttributes.USAGE_ASSISTANCE_SONIFICATION)
|
|
||||||
.build();
|
|
||||||
|
|
||||||
private FingerprintManager mFingerprintManager;
|
private FingerprintManager mFingerprintManager;
|
||||||
private boolean mCanAssumeUdfps;
|
private boolean mCanAssumeUdfps;
|
||||||
@@ -582,8 +580,10 @@ public class FingerprintEnrollEnrolling extends BiometricsEnrollEnrolling {
|
|||||||
mErrorText.setTranslationY(0f);
|
mErrorText.setTranslationY(0f);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (isResumed()) {
|
if (isResumed() && (mIsAccessibilityEnabled || !mCanAssumeUdfps)) {
|
||||||
mVibrator.vibrate(VIBRATE_EFFECT_ERROR, FINGERPRINT_ENROLLING_SONFICATION_ATTRIBUTES);
|
mVibrator.vibrate(Process.myUid(), getApplicationContext().getOpPackageName(),
|
||||||
|
VIBRATE_EFFECT_ERROR, "FingerprintEnrollEnrolling:showError",
|
||||||
|
FINGERPRINT_ENROLLING_SONFICATION_ATTRIBUTES);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -126,7 +126,7 @@ public final class BluetoothPermissionRequest extends BroadcastReceiver {
|
|||||||
// "Clear All Notifications" button
|
// "Clear All Notifications" button
|
||||||
|
|
||||||
Intent deleteIntent = new Intent(BluetoothDevice.ACTION_CONNECTION_ACCESS_REPLY);
|
Intent deleteIntent = new Intent(BluetoothDevice.ACTION_CONNECTION_ACCESS_REPLY);
|
||||||
deleteIntent.setPackage("com.android.bluetooth");
|
deleteIntent.setPackage("com.android.bluetooth.services");
|
||||||
deleteIntent.putExtra(BluetoothDevice.EXTRA_DEVICE, mDevice);
|
deleteIntent.putExtra(BluetoothDevice.EXTRA_DEVICE, mDevice);
|
||||||
deleteIntent.putExtra(BluetoothDevice.EXTRA_CONNECTION_ACCESS_RESULT,
|
deleteIntent.putExtra(BluetoothDevice.EXTRA_CONNECTION_ACCESS_RESULT,
|
||||||
BluetoothDevice.CONNECTION_ACCESS_NO);
|
BluetoothDevice.CONNECTION_ACCESS_NO);
|
||||||
|
|||||||
@@ -47,10 +47,10 @@ public class BluetoothMaxConnectedAudioDevicesPreferenceController extends
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
Resources res = context.getPackageManager().getResourcesForApplication(
|
Resources res = context.getPackageManager().getResourcesForApplication(
|
||||||
"com.android.bluetooth");
|
"com.android.bluetooth.services");
|
||||||
mDefaultMaxConnectedAudioDevices = res.getInteger(res.getIdentifier(
|
mDefaultMaxConnectedAudioDevices = res.getInteger(res.getIdentifier(
|
||||||
"config_bluetooth_max_connected_audio_devices",
|
"config_bluetooth_max_connected_audio_devices",
|
||||||
"integer", "com.android.bluetooth"));
|
"integer", "com.android.bluetooth.services"));
|
||||||
} catch (PackageManager.NameNotFoundException e) {
|
} catch (PackageManager.NameNotFoundException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -119,6 +119,7 @@ public class RemoteVolumeGroupController extends BasePreferenceController implem
|
|||||||
if (seekBarPreference.getProgress() != info.getVolume()) {
|
if (seekBarPreference.getProgress() != info.getVolume()) {
|
||||||
seekBarPreference.setProgress(info.getVolume());
|
seekBarPreference.setProgress(info.getVolume());
|
||||||
}
|
}
|
||||||
|
seekBarPreference.setEnabled(mLocalMediaManager.shouldEnableVolumeSeekBar(info));
|
||||||
} else {
|
} else {
|
||||||
// Add slider
|
// Add slider
|
||||||
seekBarPreference = new RemoteVolumeSeekBarPreference(mContext);
|
seekBarPreference = new RemoteVolumeSeekBarPreference(mContext);
|
||||||
|
|||||||
@@ -20,7 +20,6 @@ import static com.android.settings.security.EncryptionStatusPreferenceController
|
|||||||
|
|
||||||
import android.app.settings.SettingsEnums;
|
import android.app.settings.SettingsEnums;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.os.UserManager;
|
|
||||||
|
|
||||||
import com.android.settings.R;
|
import com.android.settings.R;
|
||||||
import com.android.settings.dashboard.DashboardFragment;
|
import com.android.settings.dashboard.DashboardFragment;
|
||||||
@@ -96,9 +95,7 @@ public class EncryptionAndCredential extends DashboardFragment {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected boolean isPageSearchEnabled(Context context) {
|
protected boolean isPageSearchEnabled(Context context) {
|
||||||
final UserManager um = (UserManager) context.getSystemService(
|
return true;
|
||||||
Context.USER_SERVICE);
|
|
||||||
return um.isAdminUser();
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ public class EncryptionStatusPreferenceController extends BasePreferenceControll
|
|||||||
return UNSUPPORTED_ON_DEVICE;
|
return UNSUPPORTED_ON_DEVICE;
|
||||||
}
|
}
|
||||||
|
|
||||||
return mUserManager.isAdminUser() ? AVAILABLE : DISABLED_FOR_USER;
|
return AVAILABLE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ import android.text.TextUtils;
|
|||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.ImageButton;
|
import android.widget.ImageButton;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
|
import android.widget.TextView;
|
||||||
|
|
||||||
import androidx.annotation.DrawableRes;
|
import androidx.annotation.DrawableRes;
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
@@ -35,6 +36,7 @@ import androidx.preference.PreferenceViewHolder;
|
|||||||
import com.android.settingslib.R;
|
import com.android.settingslib.R;
|
||||||
import com.android.settingslib.Utils;
|
import com.android.settingslib.Utils;
|
||||||
import com.android.settingslib.wifi.WifiUtils;
|
import com.android.settingslib.wifi.WifiUtils;
|
||||||
|
import com.android.wifitrackerlib.BaseWifiTracker;
|
||||||
import com.android.wifitrackerlib.WifiEntry;
|
import com.android.wifitrackerlib.WifiEntry;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -94,6 +96,12 @@ public class WifiEntryPreference extends Preference implements WifiEntry.WifiEnt
|
|||||||
@Override
|
@Override
|
||||||
public void onBindViewHolder(final PreferenceViewHolder view) {
|
public void onBindViewHolder(final PreferenceViewHolder view) {
|
||||||
super.onBindViewHolder(view);
|
super.onBindViewHolder(view);
|
||||||
|
if (BaseWifiTracker.isVerboseLoggingEnabled()) {
|
||||||
|
TextView summary = (TextView) view.findViewById(android.R.id.summary);
|
||||||
|
if (summary != null) {
|
||||||
|
summary.setMaxLines(100);
|
||||||
|
}
|
||||||
|
}
|
||||||
final Drawable drawable = getIcon();
|
final Drawable drawable = getIcon();
|
||||||
if (drawable != null) {
|
if (drawable != null) {
|
||||||
drawable.setLevel(mLevel);
|
drawable.setLevel(mLevel);
|
||||||
|
|||||||
@@ -26,7 +26,6 @@ import android.net.ConnectivityManager;
|
|||||||
import android.net.wifi.WifiManager;
|
import android.net.wifi.WifiManager;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.os.Looper;
|
import android.os.Looper;
|
||||||
import android.view.View;
|
|
||||||
import android.widget.Switch;
|
import android.widget.Switch;
|
||||||
|
|
||||||
import androidx.annotation.VisibleForTesting;
|
import androidx.annotation.VisibleForTesting;
|
||||||
@@ -36,12 +35,13 @@ import com.android.settings.widget.SettingsMainSwitchBar;
|
|||||||
import com.android.settingslib.core.lifecycle.LifecycleObserver;
|
import com.android.settingslib.core.lifecycle.LifecycleObserver;
|
||||||
import com.android.settingslib.core.lifecycle.events.OnStart;
|
import com.android.settingslib.core.lifecycle.events.OnStart;
|
||||||
import com.android.settingslib.core.lifecycle.events.OnStop;
|
import com.android.settingslib.core.lifecycle.events.OnStop;
|
||||||
|
import com.android.settingslib.widget.OnMainSwitchChangeListener;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Controller for logic pertaining to switch Wi-Fi tethering.
|
* Controller for logic pertaining to switch Wi-Fi tethering.
|
||||||
*/
|
*/
|
||||||
public class WifiTetherSwitchBarController implements
|
public class WifiTetherSwitchBarController implements
|
||||||
LifecycleObserver, OnStart, OnStop, DataSaverBackend.Listener, View.OnClickListener {
|
LifecycleObserver, OnStart, OnStop, DataSaverBackend.Listener, OnMainSwitchChangeListener {
|
||||||
private static final IntentFilter WIFI_INTENT_FILTER;
|
private static final IntentFilter WIFI_INTENT_FILTER;
|
||||||
|
|
||||||
private final Context mContext;
|
private final Context mContext;
|
||||||
@@ -82,7 +82,7 @@ public class WifiTetherSwitchBarController implements
|
|||||||
@Override
|
@Override
|
||||||
public void onStart() {
|
public void onStart() {
|
||||||
mDataSaverBackend.addListener(this);
|
mDataSaverBackend.addListener(this);
|
||||||
mSwitch.setOnClickListener(this);
|
mSwitchBar.addOnSwitchChangeListener(this);
|
||||||
mContext.registerReceiver(mReceiver, WIFI_INTENT_FILTER,
|
mContext.registerReceiver(mReceiver, WIFI_INTENT_FILTER,
|
||||||
Context.RECEIVER_EXPORTED_UNAUDITED);
|
Context.RECEIVER_EXPORTED_UNAUDITED);
|
||||||
}
|
}
|
||||||
@@ -94,8 +94,8 @@ public class WifiTetherSwitchBarController implements
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onSwitchChanged(Switch switchView, boolean isChecked) {
|
||||||
if (((Switch) v).isChecked()) {
|
if (isChecked) {
|
||||||
startTether();
|
startTether();
|
||||||
} else {
|
} else {
|
||||||
stopTether();
|
stopTether();
|
||||||
|
|||||||
@@ -16,10 +16,10 @@
|
|||||||
|
|
||||||
package com.android.settings.accessibility;
|
package com.android.settings.accessibility;
|
||||||
|
|
||||||
import static com.android.settings.accessibility.TextReadingResetController.ResetStateListener;
|
|
||||||
|
|
||||||
import static com.google.common.truth.Truth.assertThat;
|
import static com.google.common.truth.Truth.assertThat;
|
||||||
|
|
||||||
|
import static org.mockito.ArgumentMatchers.any;
|
||||||
|
import static org.mockito.Mockito.verify;
|
||||||
import static org.mockito.Mockito.when;
|
import static org.mockito.Mockito.when;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
@@ -29,7 +29,6 @@ import androidx.preference.PreferenceScreen;
|
|||||||
import androidx.test.core.app.ApplicationProvider;
|
import androidx.test.core.app.ApplicationProvider;
|
||||||
|
|
||||||
import com.android.settings.R;
|
import com.android.settings.R;
|
||||||
import com.android.settings.core.BasePreferenceController;
|
|
||||||
import com.android.settingslib.widget.LayoutPreference;
|
import com.android.settingslib.widget.LayoutPreference;
|
||||||
|
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
@@ -39,21 +38,18 @@ import org.mockito.Mock;
|
|||||||
import org.mockito.MockitoAnnotations;
|
import org.mockito.MockitoAnnotations;
|
||||||
import org.robolectric.RobolectricTestRunner;
|
import org.robolectric.RobolectricTestRunner;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests for {@link TextReadingResetController}.
|
* Tests for {@link TextReadingResetController}.
|
||||||
*/
|
*/
|
||||||
@RunWith(RobolectricTestRunner.class)
|
@RunWith(RobolectricTestRunner.class)
|
||||||
public class TextReadingResetControllerTest {
|
public class TextReadingResetControllerTest {
|
||||||
private static final String TEST_KEY = "test";
|
|
||||||
private static final String RESET_KEY = "reset";
|
private static final String RESET_KEY = "reset";
|
||||||
private final Context mContext = ApplicationProvider.getApplicationContext();
|
private final Context mContext = ApplicationProvider.getApplicationContext();
|
||||||
private final View mResetView = new View(mContext);
|
private final View mResetView = new View(mContext);
|
||||||
private final List<ResetStateListener> mListeners = new ArrayList<>();
|
|
||||||
private TextReadingResetController mResetController;
|
private TextReadingResetController mResetController;
|
||||||
private TestPreferenceController mPreferenceController;
|
|
||||||
|
@Mock
|
||||||
|
private View.OnClickListener mOnResetButtonClickListener;
|
||||||
|
|
||||||
@Mock
|
@Mock
|
||||||
private PreferenceScreen mPreferenceScreen;
|
private PreferenceScreen mPreferenceScreen;
|
||||||
@@ -64,10 +60,8 @@ public class TextReadingResetControllerTest {
|
|||||||
@Before
|
@Before
|
||||||
public void setUp() {
|
public void setUp() {
|
||||||
MockitoAnnotations.initMocks(this);
|
MockitoAnnotations.initMocks(this);
|
||||||
|
mResetController = new TextReadingResetController(mContext, RESET_KEY,
|
||||||
mPreferenceController = new TestPreferenceController(mContext, TEST_KEY);
|
mOnResetButtonClickListener);
|
||||||
mListeners.add(mPreferenceController);
|
|
||||||
mResetController = new TextReadingResetController(mContext, RESET_KEY, mListeners);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -80,40 +74,17 @@ public class TextReadingResetControllerTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void triggerResetState_success() {
|
public void clickResetButtonAfterDisplayPreference_verifyClickListener() {
|
||||||
setupResetButton();
|
setupResetButton();
|
||||||
|
|
||||||
mResetController.displayPreference(mPreferenceScreen);
|
mResetController.displayPreference(mPreferenceScreen);
|
||||||
mResetView.callOnClick();
|
mResetView.callOnClick();
|
||||||
|
|
||||||
assertThat(mPreferenceController.isReset()).isTrue();
|
verify(mOnResetButtonClickListener).onClick(any(View.class));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setupResetButton() {
|
private void setupResetButton() {
|
||||||
when(mPreferenceScreen.findPreference(RESET_KEY)).thenReturn(mLayoutPreference);
|
when(mPreferenceScreen.findPreference(RESET_KEY)).thenReturn(mLayoutPreference);
|
||||||
when(mLayoutPreference.findViewById(R.id.reset_button)).thenReturn(mResetView);
|
when(mLayoutPreference.findViewById(R.id.reset_button)).thenReturn(mResetView);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class TestPreferenceController extends BasePreferenceController implements
|
|
||||||
ResetStateListener {
|
|
||||||
private boolean mIsReset = false;
|
|
||||||
|
|
||||||
TestPreferenceController(Context context, String preferenceKey) {
|
|
||||||
super(context, preferenceKey);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void resetState() {
|
|
||||||
mIsReset = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getAvailabilityStatus() {
|
|
||||||
return AVAILABLE;
|
|
||||||
}
|
|
||||||
|
|
||||||
boolean isReset() {
|
|
||||||
return mIsReset;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -38,6 +38,7 @@ import android.provider.Settings;
|
|||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
|
import android.widget.CheckBox;
|
||||||
import android.widget.PopupWindow;
|
import android.widget.PopupWindow;
|
||||||
|
|
||||||
import androidx.annotation.XmlRes;
|
import androidx.annotation.XmlRes;
|
||||||
@@ -183,6 +184,28 @@ public class ToggleFeaturePreferenceFragmentTest {
|
|||||||
assertThat(expectedType).isEqualTo(UserShortcutType.HARDWARE);
|
assertThat(expectedType).isEqualTo(UserShortcutType.HARDWARE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void dialogCheckboxClicked_hardwareType_skipTimeoutRestriction() {
|
||||||
|
mContext.setTheme(R.style.Theme_AppCompat);
|
||||||
|
final ShortcutPreference shortcutPreference = new ShortcutPreference(mContext, /* attrs= */
|
||||||
|
null);
|
||||||
|
mFragment.mComponentName = PLACEHOLDER_COMPONENT_NAME;
|
||||||
|
mFragment.mShortcutPreference = shortcutPreference;
|
||||||
|
final AlertDialog dialog = AccessibilityDialogUtils.showEditShortcutDialog(
|
||||||
|
mContext, DialogType.EDIT_SHORTCUT_GENERIC, PLACEHOLDER_DIALOG_TITLE,
|
||||||
|
mFragment::callOnAlertDialogCheckboxClicked);
|
||||||
|
mFragment.setupEditShortcutDialog(dialog);
|
||||||
|
|
||||||
|
final View dialogHardwareView = dialog.findViewById(R.id.hardware_shortcut);
|
||||||
|
final CheckBox hardwareTypeCheckBox = dialogHardwareView.findViewById(R.id.checkbox);
|
||||||
|
hardwareTypeCheckBox.setChecked(true);
|
||||||
|
dialog.getButton(DialogInterface.BUTTON_POSITIVE).callOnClick();
|
||||||
|
final boolean skipTimeoutRestriction = Settings.Secure.getInt(mContext.getContentResolver(),
|
||||||
|
Settings.Secure.SKIP_ACCESSIBILITY_SHORTCUT_DIALOG_TIMEOUT_RESTRICTION, 0) != 0;
|
||||||
|
|
||||||
|
assertThat(skipTimeoutRestriction).isTrue();
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void setupEditShortcutDialog_shortcutPreferenceOff_checkboxIsEmptyValue() {
|
public void setupEditShortcutDialog_shortcutPreferenceOff_checkboxIsEmptyValue() {
|
||||||
mContext.setTheme(R.style.Theme_AppCompat);
|
mContext.setTheme(R.style.Theme_AppCompat);
|
||||||
|
|||||||
@@ -70,8 +70,8 @@ public class BluetoothMaxConnectedAudioDevicesPreferenceControllerTest {
|
|||||||
mPreference.setEntryValues(R.array.bluetooth_max_connected_audio_devices_values);
|
mPreference.setEntryValues(R.array.bluetooth_max_connected_audio_devices_values);
|
||||||
// Retrieve default max connected audio devices to a test controlled value
|
// Retrieve default max connected audio devices to a test controlled value
|
||||||
try {
|
try {
|
||||||
Resources res = mSpyContext.getPackageManager().getResourcesForApplication("com.android.bluetooth");
|
Resources res = mSpyContext.getPackageManager().getResourcesForApplication("com.android.bluetooth.services");
|
||||||
TEST_MAX_CONNECTED_AUDIO_DEVICES = res.getInteger(res.getIdentifier("config_bluetooth_max_connected_audio_devices", "integer", "com.android.bluetooth"));
|
TEST_MAX_CONNECTED_AUDIO_DEVICES = res.getInteger(res.getIdentifier("config_bluetooth_max_connected_audio_devices", "integer", "com.android.bluetooth.services"));
|
||||||
} catch (PackageManager.NameNotFoundException e) {
|
} catch (PackageManager.NameNotFoundException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,19 +16,13 @@
|
|||||||
|
|
||||||
package com.android.settings.security;
|
package com.android.settings.security;
|
||||||
|
|
||||||
import static com.android.settings.security.EncryptionAndCredential.SEARCH_INDEX_DATA_PROVIDER;
|
|
||||||
|
|
||||||
import static com.google.common.truth.Truth.assertThat;
|
import static com.google.common.truth.Truth.assertThat;
|
||||||
|
|
||||||
import static org.mockito.Mockito.when;
|
|
||||||
|
|
||||||
import android.app.admin.DevicePolicyManager;
|
import android.app.admin.DevicePolicyManager;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.os.UserManager;
|
import android.os.UserManager;
|
||||||
import android.provider.SearchIndexableResource;
|
|
||||||
|
|
||||||
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
|
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
|
||||||
import com.android.settings.search.BaseSearchIndexProvider;
|
|
||||||
|
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
@@ -39,9 +33,6 @@ import org.robolectric.RobolectricTestRunner;
|
|||||||
import org.robolectric.RuntimeEnvironment;
|
import org.robolectric.RuntimeEnvironment;
|
||||||
import org.robolectric.shadows.ShadowApplication;
|
import org.robolectric.shadows.ShadowApplication;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
@RunWith(RobolectricTestRunner.class)
|
@RunWith(RobolectricTestRunner.class)
|
||||||
public class EncryptionAndCredentialTest {
|
public class EncryptionAndCredentialTest {
|
||||||
|
|
||||||
@@ -67,19 +58,4 @@ public class EncryptionAndCredentialTest {
|
|||||||
assertThat(fragment.getMetricsCategory()).isEqualTo(MetricsEvent.ENCRYPTION_AND_CREDENTIAL);
|
assertThat(fragment.getMetricsCategory()).isEqualTo(MetricsEvent.ENCRYPTION_AND_CREDENTIAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
|
||||||
public void getNonIndexableKeys_pageIsDisabled_shouldReturnAllKeysAsNonIndexable() {
|
|
||||||
when(mUserManager.isAdminUser()).thenReturn(false);
|
|
||||||
|
|
||||||
final List<SearchIndexableResource> index =
|
|
||||||
SEARCH_INDEX_DATA_PROVIDER.getXmlResourcesToIndex(mContext, true /* enabled */);
|
|
||||||
final List<String> expectedKeys = new ArrayList<>();
|
|
||||||
for (SearchIndexableResource res : index) {
|
|
||||||
expectedKeys.addAll(((BaseSearchIndexProvider) SEARCH_INDEX_DATA_PROVIDER)
|
|
||||||
.getNonIndexableKeysFromXml(mContext, res.xmlResId, true /* suppressAll */));
|
|
||||||
}
|
|
||||||
final List<String> keys = SEARCH_INDEX_DATA_PROVIDER.getNonIndexableKeys(mContext);
|
|
||||||
|
|
||||||
assertThat(keys).containsExactlyElementsIn(expectedKeys);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -56,20 +56,6 @@ public class EncryptionStatusPreferenceControllerTest {
|
|||||||
mPreference = new Preference(mContext);
|
mPreference = new Preference(mContext);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
|
||||||
public void isAvailable_admin_true() {
|
|
||||||
mShadowUserManager.setIsAdminUser(true);
|
|
||||||
|
|
||||||
assertThat(mController.isAvailable()).isTrue();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void isAvailable_notAdmin_false() {
|
|
||||||
mShadowUserManager.setIsAdminUser(false);
|
|
||||||
|
|
||||||
assertThat(mController.isAvailable()).isFalse();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@Config(qualifiers = "mcc999")
|
@Config(qualifiers = "mcc999")
|
||||||
public void isAvailable_notVisible_false() {
|
public void isAvailable_notVisible_false() {
|
||||||
@@ -82,7 +68,6 @@ public class EncryptionStatusPreferenceControllerTest {
|
|||||||
mController = new EncryptionStatusPreferenceController(mContext,
|
mController = new EncryptionStatusPreferenceController(mContext,
|
||||||
PREF_KEY_ENCRYPTION_SECURITY_PAGE);
|
PREF_KEY_ENCRYPTION_SECURITY_PAGE);
|
||||||
|
|
||||||
mShadowUserManager.setIsAdminUser(true);
|
|
||||||
assertThat(mController.isAvailable()).isTrue();
|
assertThat(mController.isAvailable()).isTrue();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -16,15 +16,14 @@
|
|||||||
|
|
||||||
package com.android.settings.wifi.tether;
|
package com.android.settings.wifi.tether;
|
||||||
|
|
||||||
|
import static android.net.ConnectivityManager.TETHERING_WIFI;
|
||||||
|
|
||||||
import static com.google.common.truth.Truth.assertThat;
|
import static com.google.common.truth.Truth.assertThat;
|
||||||
|
|
||||||
import static org.mockito.ArgumentMatchers.any;
|
import static org.mockito.ArgumentMatchers.any;
|
||||||
import static org.mockito.ArgumentMatchers.anyBoolean;
|
import static org.mockito.ArgumentMatchers.anyBoolean;
|
||||||
import static org.mockito.ArgumentMatchers.anyInt;
|
import static org.mockito.ArgumentMatchers.eq;
|
||||||
import static org.mockito.Mockito.mock;
|
|
||||||
import static org.mockito.Mockito.never;
|
|
||||||
import static org.mockito.Mockito.spy;
|
import static org.mockito.Mockito.spy;
|
||||||
import static org.mockito.Mockito.times;
|
|
||||||
import static org.mockito.Mockito.verify;
|
import static org.mockito.Mockito.verify;
|
||||||
import static org.mockito.Mockito.when;
|
import static org.mockito.Mockito.when;
|
||||||
|
|
||||||
@@ -52,6 +51,8 @@ public class WifiTetherSwitchBarControllerTest {
|
|||||||
private ConnectivityManager mConnectivityManager;
|
private ConnectivityManager mConnectivityManager;
|
||||||
@Mock
|
@Mock
|
||||||
private NetworkPolicyManager mNetworkPolicyManager;
|
private NetworkPolicyManager mNetworkPolicyManager;
|
||||||
|
@Mock
|
||||||
|
private Switch mSwitch;
|
||||||
|
|
||||||
private Context mContext;
|
private Context mContext;
|
||||||
private SettingsMainSwitchBar mSwitchBar;
|
private SettingsMainSwitchBar mSwitchBar;
|
||||||
@@ -99,23 +100,20 @@ public class WifiTetherSwitchBarControllerTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void onSwitchToggled_switchOff_noStartTethering() {
|
public void onSwitchChanged_isChecked_startTethering() {
|
||||||
final Switch mockSwitch = mock(Switch.class);
|
when(mSwitch.isChecked()).thenReturn(true);
|
||||||
when(mockSwitch.isChecked()).thenReturn(false);
|
|
||||||
|
|
||||||
mController.onClick(mockSwitch);
|
mController.onSwitchChanged(mSwitch, mSwitch.isChecked());
|
||||||
|
|
||||||
verify(mConnectivityManager, never()).startTethering(anyInt(), anyBoolean(), any(), any());
|
verify(mConnectivityManager).startTethering(eq(TETHERING_WIFI), anyBoolean(), any(), any());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void onSwitchToggled_switchOn_startTethering() {
|
public void onSwitchChanged_isNotChecked_stopTethering() {
|
||||||
final Switch mockSwitch = mock(Switch.class);
|
when(mSwitch.isChecked()).thenReturn(false);
|
||||||
when(mockSwitch.isChecked()).thenReturn(true);
|
|
||||||
|
|
||||||
mController.onClick(mockSwitch);
|
mController.onSwitchChanged(mSwitch, mSwitch.isChecked());
|
||||||
|
|
||||||
verify(mConnectivityManager, times(1))
|
verify(mConnectivityManager).stopTethering(TETHERING_WIFI);
|
||||||
.startTethering(anyInt(), anyBoolean(), any(), any());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user