Snap for 8362632 from 6f94d1f784 to tm-release
Change-Id: I8cc40445ff3a8e0f7e98becedcacdfa364203a78
This commit is contained in:
@@ -2343,7 +2343,7 @@
|
||||
</activity>
|
||||
|
||||
<activity android:name=".password.ScreenLockSuggestionActivity"
|
||||
android:exported="true"
|
||||
android:exported="false"
|
||||
android:icon="@drawable/ic_suggestion_security">
|
||||
<intent-filter android:priority="1">
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
|
||||
@@ -27,9 +27,14 @@
|
||||
android:id="@+id/reset_button"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:paddingHorizontal="24dp"
|
||||
android:layout_gravity="center|end"
|
||||
android:paddingVertical="14dp"
|
||||
android:text="@string/accessibility_text_reading_reset_button_title"
|
||||
style="@style/ActionPrimaryButton"/>
|
||||
android:background="@null"
|
||||
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>
|
||||
|
||||
@@ -4680,8 +4680,8 @@
|
||||
<string name="clear_user_data_text">Clear storage</string>
|
||||
<!-- Manage applications, restore updated system application to factory version -->
|
||||
<string name="app_factory_reset">Uninstall updates</string>
|
||||
<!-- [CHAR LIMIT=50] Manage applications, unlock restricted settings from lock screen title -->
|
||||
<string name="app_restricted_settings_lockscreen_title">Unlock restricted settings</string>
|
||||
<!-- [CHAR LIMIT=50] Manage applications, unlock restricted setting from lock screen title -->
|
||||
<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. -->
|
||||
<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. -->
|
||||
@@ -12166,7 +12166,9 @@
|
||||
<!-- Button label to allow the user to view additional information [CHAR LIMIT=NONE BACKUP_MESSAGE_ID=2416766240581561009] -->
|
||||
<string name="learn_more">Learn more</string>
|
||||
<!--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] -->
|
||||
<string name="blocked_by_restricted_settings_content">For your security, this setting is currently unavailable.</string>
|
||||
|
||||
|
||||
@@ -141,7 +141,7 @@
|
||||
|
||||
<PreferenceCategory
|
||||
android:key="app_hibernation_info"
|
||||
android:title="@string/unused_apps"
|
||||
android:title="@string/unused_apps_category"
|
||||
settings:controller=
|
||||
"com.android.settings.applications.appinfo.AppHibernationPreferenceCategoryController">
|
||||
|
||||
|
||||
@@ -118,6 +118,11 @@ public class AccessibilityDialogUtils {
|
||||
* launch tutorial.
|
||||
*/
|
||||
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.setSummary(getShortcutTypeSummary(getPrefContext()));
|
||||
|
||||
if (mHardwareTypeCheckBox.isChecked()) {
|
||||
AccessibilityUtil.skipVolumeShortcutDialogTimeoutRestriction(getPrefContext());
|
||||
}
|
||||
|
||||
// Show the quick setting tooltip if the shortcut assigned in the first time
|
||||
if (shortcutAssigned) {
|
||||
showQuickSettingsTooltipIfNeeded();
|
||||
|
||||
@@ -434,4 +434,15 @@ public final class AccessibilityUtil {
|
||||
public static boolean isSystemApp(@NonNull AccessibilityServiceInfo info) {
|
||||
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 android.app.Dialog;
|
||||
import android.app.settings.SettingsEnums;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
|
||||
import androidx.appcompat.app.AlertDialog;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.accessibility.AccessibilityDialogUtils.DialogEnums;
|
||||
import com.android.settings.dashboard.DashboardFragment;
|
||||
import com.android.settings.search.BaseSearchIndexProvider;
|
||||
import com.android.settingslib.core.AbstractPreferenceController;
|
||||
@@ -88,16 +93,54 @@ public class TextReadingPreferenceFragment extends DashboardFragment {
|
||||
new HighTextContrastPreferenceController(context, HIGHT_TEXT_CONTRAST_KEY);
|
||||
controllers.add(highTextContrastController);
|
||||
|
||||
final List<ResetStateListener> resetStateListeners =
|
||||
controllers.stream().filter(c -> c instanceof ResetStateListener).map(
|
||||
c -> (ResetStateListener) c).collect(Collectors.toList());
|
||||
final TextReadingResetController resetController =
|
||||
new TextReadingResetController(context, RESET_KEY, resetStateListeners);
|
||||
new TextReadingResetController(context, RESET_KEY,
|
||||
v -> showDialog(DialogEnums.DIALOG_RESET_SETTINGS));
|
||||
controllers.add(resetController);
|
||||
|
||||
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 =
|
||||
new BaseSearchIndexProvider(R.xml.accessibility_text_reading_options);
|
||||
}
|
||||
|
||||
@@ -19,25 +19,23 @@ package com.android.settings.accessibility;
|
||||
import android.content.Context;
|
||||
import android.view.View;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.preference.PreferenceScreen;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.core.BasePreferenceController;
|
||||
import com.android.settingslib.widget.LayoutPreference;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* The controller of the reset button in the text and reading options page.
|
||||
*/
|
||||
class TextReadingResetController extends BasePreferenceController {
|
||||
private final List<ResetStateListener> mListeners;
|
||||
private final View.OnClickListener mOnResetClickListener;
|
||||
|
||||
TextReadingResetController(Context context, String preferenceKey,
|
||||
@NonNull List<ResetStateListener> listeners) {
|
||||
@Nullable View.OnClickListener listener) {
|
||||
super(context, preferenceKey);
|
||||
mListeners = listeners;
|
||||
mOnResetClickListener = listener;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -51,7 +49,11 @@ class TextReadingResetController extends BasePreferenceController {
|
||||
|
||||
final LayoutPreference layoutPreference = screen.findPreference(getPreferenceKey());
|
||||
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.setSummary(getShortcutTypeSummary(getPrefContext()));
|
||||
|
||||
if (mHardwareTypeCheckBox.isChecked()) {
|
||||
AccessibilityUtil.skipVolumeShortcutDialogTimeoutRestriction(getPrefContext());
|
||||
}
|
||||
|
||||
// Show the quick setting tooltip if the shortcut assigned in the first time
|
||||
if (shortcutAssigned) {
|
||||
showQuickSettingsTooltipIfNeeded();
|
||||
|
||||
@@ -367,6 +367,10 @@ public class ToggleScreenMagnificationPreferenceFragment extends
|
||||
mShortcutPreference.setChecked(value != UserShortcutType.EMPTY);
|
||||
mShortcutPreference.setSummary(
|
||||
getShortcutTypeSummary(getPrefContext()));
|
||||
|
||||
if (mHardwareTypeCheckBox.isChecked()) {
|
||||
AccessibilityUtil.skipVolumeShortcutDialogTimeoutRestriction(getPrefContext());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -48,6 +48,7 @@ import android.util.Log;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuInflater;
|
||||
import android.view.MenuItem;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.annotation.VisibleForTesting;
|
||||
|
||||
@@ -443,14 +444,14 @@ public class AppInfoDashboardFragment extends DashboardFragment
|
||||
};
|
||||
|
||||
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(
|
||||
BiometricManager.Authenticators.DEVICE_CREDENTIAL
|
||||
| BiometricManager.Authenticators.BIOMETRIC_WEAK)
|
||||
== BiometricManager.BIOMETRIC_SUCCESS) {
|
||||
builder.setAllowedAuthenticators(BiometricManager.Authenticators.DEVICE_CREDENTIAL
|
||||
| BiometricManager.Authenticators.BIOMETRIC_WEAK);
|
||||
final BiometricManager bm = context.getSystemService(BiometricManager.class);
|
||||
final int authenticators = BiometricManager.Authenticators.DEVICE_CREDENTIAL
|
||||
| BiometricManager.Authenticators.BIOMETRIC_WEAK;
|
||||
if (bm.canAuthenticate(authenticators) == BiometricManager.BIOMETRIC_SUCCESS) {
|
||||
builder.setAllowedAuthenticators(authenticators);
|
||||
builder.setSubtitle(bm.getStrings(authenticators).getPromptMessage());
|
||||
}
|
||||
|
||||
final BiometricPrompt bp = builder.build();
|
||||
@@ -481,6 +482,10 @@ public class AppInfoDashboardFragment extends DashboardFragment
|
||||
getPackageName(),
|
||||
AppOpsManager.MODE_ALLOWED);
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -32,8 +32,9 @@ import android.graphics.drawable.Drawable;
|
||||
import android.graphics.drawable.LayerDrawable;
|
||||
import android.hardware.fingerprint.FingerprintManager;
|
||||
import android.hardware.fingerprint.FingerprintSensorPropertiesInternal;
|
||||
import android.media.AudioAttributes;
|
||||
import android.os.Bundle;
|
||||
import android.os.Process;
|
||||
import android.os.VibrationAttributes;
|
||||
import android.os.VibrationEffect;
|
||||
import android.os.Vibrator;
|
||||
import android.text.TextUtils;
|
||||
@@ -108,11 +109,8 @@ public class FingerprintEnrollEnrolling extends BiometricsEnrollEnrolling {
|
||||
|
||||
private static final VibrationEffect VIBRATE_EFFECT_ERROR =
|
||||
VibrationEffect.createWaveform(new long[] {0, 5, 55, 60}, -1);
|
||||
private static final AudioAttributes FINGERPRINT_ENROLLING_SONFICATION_ATTRIBUTES =
|
||||
new AudioAttributes.Builder()
|
||||
.setContentType(AudioAttributes.CONTENT_TYPE_SONIFICATION)
|
||||
.setUsage(AudioAttributes.USAGE_ASSISTANCE_SONIFICATION)
|
||||
.build();
|
||||
private static final VibrationAttributes FINGERPRINT_ENROLLING_SONFICATION_ATTRIBUTES =
|
||||
VibrationAttributes.createForUsage(VibrationAttributes.USAGE_ACCESSIBILITY);
|
||||
|
||||
private FingerprintManager mFingerprintManager;
|
||||
private boolean mCanAssumeUdfps;
|
||||
@@ -582,8 +580,10 @@ public class FingerprintEnrollEnrolling extends BiometricsEnrollEnrolling {
|
||||
mErrorText.setTranslationY(0f);
|
||||
}
|
||||
}
|
||||
if (isResumed()) {
|
||||
mVibrator.vibrate(VIBRATE_EFFECT_ERROR, FINGERPRINT_ENROLLING_SONFICATION_ATTRIBUTES);
|
||||
if (isResumed() && (mIsAccessibilityEnabled || !mCanAssumeUdfps)) {
|
||||
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
|
||||
|
||||
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_CONNECTION_ACCESS_RESULT,
|
||||
BluetoothDevice.CONNECTION_ACCESS_NO);
|
||||
|
||||
@@ -47,10 +47,10 @@ public class BluetoothMaxConnectedAudioDevicesPreferenceController extends
|
||||
|
||||
try {
|
||||
Resources res = context.getPackageManager().getResourcesForApplication(
|
||||
"com.android.bluetooth");
|
||||
"com.android.bluetooth.services");
|
||||
mDefaultMaxConnectedAudioDevices = res.getInteger(res.getIdentifier(
|
||||
"config_bluetooth_max_connected_audio_devices",
|
||||
"integer", "com.android.bluetooth"));
|
||||
"integer", "com.android.bluetooth.services"));
|
||||
} catch (PackageManager.NameNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
@@ -119,6 +119,7 @@ public class RemoteVolumeGroupController extends BasePreferenceController implem
|
||||
if (seekBarPreference.getProgress() != info.getVolume()) {
|
||||
seekBarPreference.setProgress(info.getVolume());
|
||||
}
|
||||
seekBarPreference.setEnabled(mLocalMediaManager.shouldEnableVolumeSeekBar(info));
|
||||
} else {
|
||||
// Add slider
|
||||
seekBarPreference = new RemoteVolumeSeekBarPreference(mContext);
|
||||
|
||||
@@ -20,7 +20,6 @@ import static com.android.settings.security.EncryptionStatusPreferenceController
|
||||
|
||||
import android.app.settings.SettingsEnums;
|
||||
import android.content.Context;
|
||||
import android.os.UserManager;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.dashboard.DashboardFragment;
|
||||
@@ -96,9 +95,7 @@ public class EncryptionAndCredential extends DashboardFragment {
|
||||
|
||||
@Override
|
||||
protected boolean isPageSearchEnabled(Context context) {
|
||||
final UserManager um = (UserManager) context.getSystemService(
|
||||
Context.USER_SERVICE);
|
||||
return um.isAdminUser();
|
||||
return true;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -48,7 +48,7 @@ public class EncryptionStatusPreferenceController extends BasePreferenceControll
|
||||
return UNSUPPORTED_ON_DEVICE;
|
||||
}
|
||||
|
||||
return mUserManager.isAdminUser() ? AVAILABLE : DISABLED_FOR_USER;
|
||||
return AVAILABLE;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -25,6 +25,7 @@ import android.text.TextUtils;
|
||||
import android.view.View;
|
||||
import android.widget.ImageButton;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.DrawableRes;
|
||||
import androidx.annotation.NonNull;
|
||||
@@ -35,6 +36,7 @@ import androidx.preference.PreferenceViewHolder;
|
||||
import com.android.settingslib.R;
|
||||
import com.android.settingslib.Utils;
|
||||
import com.android.settingslib.wifi.WifiUtils;
|
||||
import com.android.wifitrackerlib.BaseWifiTracker;
|
||||
import com.android.wifitrackerlib.WifiEntry;
|
||||
|
||||
/**
|
||||
@@ -94,6 +96,12 @@ public class WifiEntryPreference extends Preference implements WifiEntry.WifiEnt
|
||||
@Override
|
||||
public void onBindViewHolder(final PreferenceViewHolder 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();
|
||||
if (drawable != null) {
|
||||
drawable.setLevel(mLevel);
|
||||
|
||||
@@ -26,7 +26,6 @@ import android.net.ConnectivityManager;
|
||||
import android.net.wifi.WifiManager;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import android.view.View;
|
||||
import android.widget.Switch;
|
||||
|
||||
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.events.OnStart;
|
||||
import com.android.settingslib.core.lifecycle.events.OnStop;
|
||||
import com.android.settingslib.widget.OnMainSwitchChangeListener;
|
||||
|
||||
/**
|
||||
* Controller for logic pertaining to switch Wi-Fi tethering.
|
||||
*/
|
||||
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 final Context mContext;
|
||||
@@ -82,7 +82,7 @@ public class WifiTetherSwitchBarController implements
|
||||
@Override
|
||||
public void onStart() {
|
||||
mDataSaverBackend.addListener(this);
|
||||
mSwitch.setOnClickListener(this);
|
||||
mSwitchBar.addOnSwitchChangeListener(this);
|
||||
mContext.registerReceiver(mReceiver, WIFI_INTENT_FILTER,
|
||||
Context.RECEIVER_EXPORTED_UNAUDITED);
|
||||
}
|
||||
@@ -94,8 +94,8 @@ public class WifiTetherSwitchBarController implements
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (((Switch) v).isChecked()) {
|
||||
public void onSwitchChanged(Switch switchView, boolean isChecked) {
|
||||
if (isChecked) {
|
||||
startTether();
|
||||
} else {
|
||||
stopTether();
|
||||
|
||||
@@ -16,10 +16,10 @@
|
||||
|
||||
package com.android.settings.accessibility;
|
||||
|
||||
import static com.android.settings.accessibility.TextReadingResetController.ResetStateListener;
|
||||
|
||||
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 android.content.Context;
|
||||
@@ -29,7 +29,6 @@ import androidx.preference.PreferenceScreen;
|
||||
import androidx.test.core.app.ApplicationProvider;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.core.BasePreferenceController;
|
||||
import com.android.settingslib.widget.LayoutPreference;
|
||||
|
||||
import org.junit.Before;
|
||||
@@ -39,21 +38,18 @@ import org.mockito.Mock;
|
||||
import org.mockito.MockitoAnnotations;
|
||||
import org.robolectric.RobolectricTestRunner;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Tests for {@link TextReadingResetController}.
|
||||
*/
|
||||
@RunWith(RobolectricTestRunner.class)
|
||||
public class TextReadingResetControllerTest {
|
||||
private static final String TEST_KEY = "test";
|
||||
private static final String RESET_KEY = "reset";
|
||||
private final Context mContext = ApplicationProvider.getApplicationContext();
|
||||
private final View mResetView = new View(mContext);
|
||||
private final List<ResetStateListener> mListeners = new ArrayList<>();
|
||||
private TextReadingResetController mResetController;
|
||||
private TestPreferenceController mPreferenceController;
|
||||
|
||||
@Mock
|
||||
private View.OnClickListener mOnResetButtonClickListener;
|
||||
|
||||
@Mock
|
||||
private PreferenceScreen mPreferenceScreen;
|
||||
@@ -64,10 +60,8 @@ public class TextReadingResetControllerTest {
|
||||
@Before
|
||||
public void setUp() {
|
||||
MockitoAnnotations.initMocks(this);
|
||||
|
||||
mPreferenceController = new TestPreferenceController(mContext, TEST_KEY);
|
||||
mListeners.add(mPreferenceController);
|
||||
mResetController = new TextReadingResetController(mContext, RESET_KEY, mListeners);
|
||||
mResetController = new TextReadingResetController(mContext, RESET_KEY,
|
||||
mOnResetButtonClickListener);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -80,40 +74,17 @@ public class TextReadingResetControllerTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void triggerResetState_success() {
|
||||
public void clickResetButtonAfterDisplayPreference_verifyClickListener() {
|
||||
setupResetButton();
|
||||
|
||||
mResetController.displayPreference(mPreferenceScreen);
|
||||
mResetView.callOnClick();
|
||||
|
||||
assertThat(mPreferenceController.isReset()).isTrue();
|
||||
verify(mOnResetButtonClickListener).onClick(any(View.class));
|
||||
}
|
||||
|
||||
private void setupResetButton() {
|
||||
when(mPreferenceScreen.findPreference(RESET_KEY)).thenReturn(mLayoutPreference);
|
||||
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.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.CheckBox;
|
||||
import android.widget.PopupWindow;
|
||||
|
||||
import androidx.annotation.XmlRes;
|
||||
@@ -183,6 +184,28 @@ public class ToggleFeaturePreferenceFragmentTest {
|
||||
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
|
||||
public void setupEditShortcutDialog_shortcutPreferenceOff_checkboxIsEmptyValue() {
|
||||
mContext.setTheme(R.style.Theme_AppCompat);
|
||||
|
||||
@@ -70,8 +70,8 @@ public class BluetoothMaxConnectedAudioDevicesPreferenceControllerTest {
|
||||
mPreference.setEntryValues(R.array.bluetooth_max_connected_audio_devices_values);
|
||||
// Retrieve default max connected audio devices to a test controlled value
|
||||
try {
|
||||
Resources res = mSpyContext.getPackageManager().getResourcesForApplication("com.android.bluetooth");
|
||||
TEST_MAX_CONNECTED_AUDIO_DEVICES = res.getInteger(res.getIdentifier("config_bluetooth_max_connected_audio_devices", "integer", "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.services"));
|
||||
} catch (PackageManager.NameNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
@@ -16,19 +16,13 @@
|
||||
|
||||
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 org.mockito.Mockito.when;
|
||||
|
||||
import android.app.admin.DevicePolicyManager;
|
||||
import android.content.Context;
|
||||
import android.os.UserManager;
|
||||
import android.provider.SearchIndexableResource;
|
||||
|
||||
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
|
||||
import com.android.settings.search.BaseSearchIndexProvider;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
@@ -39,9 +33,6 @@ import org.robolectric.RobolectricTestRunner;
|
||||
import org.robolectric.RuntimeEnvironment;
|
||||
import org.robolectric.shadows.ShadowApplication;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@RunWith(RobolectricTestRunner.class)
|
||||
public class EncryptionAndCredentialTest {
|
||||
|
||||
@@ -67,19 +58,4 @@ public class EncryptionAndCredentialTest {
|
||||
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);
|
||||
}
|
||||
|
||||
@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
|
||||
@Config(qualifiers = "mcc999")
|
||||
public void isAvailable_notVisible_false() {
|
||||
@@ -82,7 +68,6 @@ public class EncryptionStatusPreferenceControllerTest {
|
||||
mController = new EncryptionStatusPreferenceController(mContext,
|
||||
PREF_KEY_ENCRYPTION_SECURITY_PAGE);
|
||||
|
||||
mShadowUserManager.setIsAdminUser(true);
|
||||
assertThat(mController.isAvailable()).isTrue();
|
||||
}
|
||||
|
||||
|
||||
@@ -16,15 +16,14 @@
|
||||
|
||||
package com.android.settings.wifi.tether;
|
||||
|
||||
import static android.net.ConnectivityManager.TETHERING_WIFI;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.ArgumentMatchers.anyBoolean;
|
||||
import static org.mockito.ArgumentMatchers.anyInt;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.never;
|
||||
import static org.mockito.ArgumentMatchers.eq;
|
||||
import static org.mockito.Mockito.spy;
|
||||
import static org.mockito.Mockito.times;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
@@ -52,6 +51,8 @@ public class WifiTetherSwitchBarControllerTest {
|
||||
private ConnectivityManager mConnectivityManager;
|
||||
@Mock
|
||||
private NetworkPolicyManager mNetworkPolicyManager;
|
||||
@Mock
|
||||
private Switch mSwitch;
|
||||
|
||||
private Context mContext;
|
||||
private SettingsMainSwitchBar mSwitchBar;
|
||||
@@ -99,23 +100,20 @@ public class WifiTetherSwitchBarControllerTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void onSwitchToggled_switchOff_noStartTethering() {
|
||||
final Switch mockSwitch = mock(Switch.class);
|
||||
when(mockSwitch.isChecked()).thenReturn(false);
|
||||
public void onSwitchChanged_isChecked_startTethering() {
|
||||
when(mSwitch.isChecked()).thenReturn(true);
|
||||
|
||||
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
|
||||
public void onSwitchToggled_switchOn_startTethering() {
|
||||
final Switch mockSwitch = mock(Switch.class);
|
||||
when(mockSwitch.isChecked()).thenReturn(true);
|
||||
public void onSwitchChanged_isNotChecked_stopTethering() {
|
||||
when(mSwitch.isChecked()).thenReturn(false);
|
||||
|
||||
mController.onClick(mockSwitch);
|
||||
mController.onSwitchChanged(mSwitch, mSwitch.isChecked());
|
||||
|
||||
verify(mConnectivityManager, times(1))
|
||||
.startTethering(anyInt(), anyBoolean(), any(), any());
|
||||
verify(mConnectivityManager).stopTethering(TETHERING_WIFI);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user