Snap for 4745538 from a6b773a3e1
to pi-release
Change-Id: Ic0b835494f325dc78286b9361ad558b4b992ef61
This commit is contained in:
Binary file not shown.
Before Width: | Height: | Size: 25 KiB After Width: | Height: | Size: 20 KiB |
@@ -27,7 +27,7 @@
|
|||||||
android:id="@+id/search_bar_container"
|
android:id="@+id/search_bar_container"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:background="@color/suggestion_condition_background">
|
android:background="?android:attr/colorPrimary">
|
||||||
<android.support.v7.widget.CardView
|
<android.support.v7.widget.CardView
|
||||||
android:id="@+id/search_bar"
|
android:id="@+id/search_bar"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
|
Binary file not shown.
@@ -95,7 +95,7 @@
|
|||||||
<color name="usage_graph_dots">#B0BEC5</color>
|
<color name="usage_graph_dots">#B0BEC5</color>
|
||||||
|
|
||||||
<!-- Gestures settings -->
|
<!-- Gestures settings -->
|
||||||
<color name="gestures_setting_background_color">#f4f4f4</color>
|
<color name="gestures_setting_background_color">#ffffff</color>
|
||||||
|
|
||||||
<color name="status_bar_color">#3c3c3c</color>
|
<color name="status_bar_color">#3c3c3c</color>
|
||||||
|
|
||||||
|
@@ -474,7 +474,7 @@
|
|||||||
</style>
|
</style>
|
||||||
|
|
||||||
<style name="SuggestionConditionStyle">
|
<style name="SuggestionConditionStyle">
|
||||||
<item name="android:background">@color/suggestion_condition_background</item>
|
<item name="android:background">?android:attr/colorPrimary</item>
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
<style name="TextAppearance.SearchBar" parent="@android:style/TextAppearance.Material.Widget.Toolbar.Subtitle">
|
<style name="TextAppearance.SearchBar" parent="@android:style/TextAppearance.Material.Widget.Toolbar.Subtitle">
|
||||||
|
@@ -30,6 +30,7 @@
|
|||||||
android:key="gesture_assist"
|
android:key="gesture_assist"
|
||||||
android:title="@string/assist_gesture_title"
|
android:title="@string/assist_gesture_title"
|
||||||
app:keywords="@string/keywords_assist_gesture_launch"
|
app:keywords="@string/keywords_assist_gesture_launch"
|
||||||
app:controller="com.android.settings.gestures.AssistGestureSettingsPreferenceController" />
|
app:controller="com.android.settings.gestures.AssistGestureSettingsPreferenceController"
|
||||||
|
app:allowDividerAbove="true" />
|
||||||
|
|
||||||
</PreferenceScreen>
|
</PreferenceScreen>
|
||||||
|
@@ -33,6 +33,7 @@
|
|||||||
settings:keywords="@string/keywords_display_auto_brightness"
|
settings:keywords="@string/keywords_display_auto_brightness"
|
||||||
settings:controller="com.android.settings.display.AutoBrightnessPreferenceController"
|
settings:controller="com.android.settings.display.AutoBrightnessPreferenceController"
|
||||||
settings:useAdminDisabledSummary="true"
|
settings:useAdminDisabledSummary="true"
|
||||||
settings:userRestriction="no_config_brightness" />
|
settings:userRestriction="no_config_brightness"
|
||||||
|
settings:allowDividerAbove="true" />
|
||||||
|
|
||||||
</PreferenceScreen>
|
</PreferenceScreen>
|
@@ -31,6 +31,7 @@
|
|||||||
android:title="@string/double_tap_power_for_camera_title"
|
android:title="@string/double_tap_power_for_camera_title"
|
||||||
android:summary="@string/double_tap_power_for_camera_summary"
|
android:summary="@string/double_tap_power_for_camera_summary"
|
||||||
app:keywords="@string/keywords_gesture"
|
app:keywords="@string/keywords_gesture"
|
||||||
app:controller="com.android.settings.gestures.DoubleTapPowerPreferenceController" />
|
app:controller="com.android.settings.gestures.DoubleTapPowerPreferenceController"
|
||||||
|
app:allowDividerAbove="true" />
|
||||||
|
|
||||||
</PreferenceScreen>
|
</PreferenceScreen>
|
@@ -31,6 +31,7 @@
|
|||||||
android:title="@string/ambient_display_title"
|
android:title="@string/ambient_display_title"
|
||||||
android:summary="@string/ambient_display_summary"
|
android:summary="@string/ambient_display_summary"
|
||||||
app:keywords="@string/keywords_gesture"
|
app:keywords="@string/keywords_gesture"
|
||||||
app:controller="com.android.settings.gestures.DoubleTapScreenPreferenceController" />
|
app:controller="com.android.settings.gestures.DoubleTapScreenPreferenceController"
|
||||||
|
app:allowDividerAbove="true" />
|
||||||
|
|
||||||
</PreferenceScreen>
|
</PreferenceScreen>
|
@@ -31,6 +31,7 @@
|
|||||||
android:title="@string/double_twist_for_camera_mode_title"
|
android:title="@string/double_twist_for_camera_mode_title"
|
||||||
android:summary="@string/double_twist_for_camera_mode_summary"
|
android:summary="@string/double_twist_for_camera_mode_summary"
|
||||||
app:keywords="@string/keywords_gesture"
|
app:keywords="@string/keywords_gesture"
|
||||||
app:controller="com.android.settings.gestures.DoubleTwistPreferenceController" />
|
app:controller="com.android.settings.gestures.DoubleTwistPreferenceController"
|
||||||
|
app:allowDividerAbove="true" />
|
||||||
|
|
||||||
</PreferenceScreen>
|
</PreferenceScreen>
|
@@ -20,13 +20,13 @@
|
|||||||
xmlns:settings="http://schemas.android.com/apk/res-auto"
|
xmlns:settings="http://schemas.android.com/apk/res-auto"
|
||||||
android:key="language_and_input_settings_screen"
|
android:key="language_and_input_settings_screen"
|
||||||
android:title="@string/language_settings"
|
android:title="@string/language_settings"
|
||||||
settings:initialExpandedChildrenCount="3" >
|
settings:initialExpandedChildrenCount="3">
|
||||||
|
|
||||||
<Preference
|
<Preference
|
||||||
android:key="phone_language"
|
android:key="phone_language"
|
||||||
android:title="@string/phone_language"
|
android:title="@string/phone_language"
|
||||||
android:icon="@drawable/ic_translate_24dp"
|
android:icon="@drawable/ic_translate_24dp"
|
||||||
android:fragment="com.android.settings.localepicker.LocaleListEditor"/>
|
android:fragment="com.android.settings.localepicker.LocaleListEditor" />
|
||||||
|
|
||||||
<PreferenceCategory
|
<PreferenceCategory
|
||||||
android:key="keyboards_category"
|
android:key="keyboards_category"
|
||||||
@@ -34,12 +34,12 @@
|
|||||||
<Preference
|
<Preference
|
||||||
android:key="virtual_keyboard_pref"
|
android:key="virtual_keyboard_pref"
|
||||||
android:title="@string/virtual_keyboard_category"
|
android:title="@string/virtual_keyboard_category"
|
||||||
android:fragment="com.android.settings.inputmethod.VirtualKeyboardFragment"/>
|
android:fragment="com.android.settings.inputmethod.VirtualKeyboardFragment" />
|
||||||
<Preference
|
<Preference
|
||||||
android:key="physical_keyboard_pref"
|
android:key="physical_keyboard_pref"
|
||||||
android:title="@string/physical_keyboard_title"
|
android:title="@string/physical_keyboard_title"
|
||||||
android:summary="@string/summary_placeholder"
|
android:summary="@string/summary_placeholder"
|
||||||
android:fragment="com.android.settings.inputmethod.PhysicalKeyboardFragment"/>
|
android:fragment="com.android.settings.inputmethod.PhysicalKeyboardFragment" />
|
||||||
</PreferenceCategory>
|
</PreferenceCategory>
|
||||||
|
|
||||||
<PreferenceCategory
|
<PreferenceCategory
|
||||||
@@ -52,7 +52,7 @@
|
|||||||
android:key="spellcheckers_settings"
|
android:key="spellcheckers_settings"
|
||||||
android:title="@string/spellcheckers_settings_title"
|
android:title="@string/spellcheckers_settings_title"
|
||||||
android:persistent="false"
|
android:persistent="false"
|
||||||
android:fragment="com.android.settings.inputmethod.SpellCheckersSettings"/>
|
android:fragment="com.android.settings.inputmethod.SpellCheckersSettings" />
|
||||||
|
|
||||||
<com.android.settings.widget.GearPreference
|
<com.android.settings.widget.GearPreference
|
||||||
android:key="default_autofill"
|
android:key="default_autofill"
|
||||||
@@ -63,7 +63,7 @@
|
|||||||
<!-- User dictionary preference title and fragment will be set programmatically. -->
|
<!-- User dictionary preference title and fragment will be set programmatically. -->
|
||||||
<Preference
|
<Preference
|
||||||
android:key="key_user_dictionary_settings"
|
android:key="key_user_dictionary_settings"
|
||||||
android:title="@string/user_dict_settings_title"/>
|
android:title="@string/user_dict_settings_title" />
|
||||||
</PreferenceCategory>
|
</PreferenceCategory>
|
||||||
|
|
||||||
<PreferenceCategory
|
<PreferenceCategory
|
||||||
@@ -73,24 +73,19 @@
|
|||||||
<com.android.settings.PointerSpeedPreference
|
<com.android.settings.PointerSpeedPreference
|
||||||
android:key="pointer_speed"
|
android:key="pointer_speed"
|
||||||
android:title="@string/pointer_speed"
|
android:title="@string/pointer_speed"
|
||||||
android:dialogTitle="@string/pointer_speed"/>
|
android:dialogTitle="@string/pointer_speed" />
|
||||||
|
|
||||||
<Preference
|
<Preference
|
||||||
android:key="tts_settings_summary"
|
android:key="tts_settings_summary"
|
||||||
android:title="@string/tts_settings_title"
|
android:title="@string/tts_settings_title"
|
||||||
android:fragment="com.android.settings.tts.TextToSpeechSettings"/>
|
android:fragment="com.android.settings.tts.TextToSpeechSettings" />
|
||||||
|
|
||||||
</PreferenceCategory>
|
</PreferenceCategory>
|
||||||
|
|
||||||
<PreferenceCategory
|
|
||||||
android:key="game_controller_settings_category"
|
|
||||||
android:title="@string/game_controller_settings_category">
|
|
||||||
|
|
||||||
<SwitchPreference
|
<SwitchPreference
|
||||||
android:key="vibrate_input_devices"
|
android:key="vibrate_input_devices"
|
||||||
android:title="@string/vibrate_input_devices"
|
android:title="@string/vibrate_input_devices"
|
||||||
android:summary="@string/vibrate_input_devices_summary" />
|
android:summary="@string/vibrate_input_devices_summary"
|
||||||
|
settings:controller="com.android.settings.inputmethod.GameControllerPreferenceController" />
|
||||||
</PreferenceCategory>
|
|
||||||
|
|
||||||
</PreferenceScreen>
|
</PreferenceScreen>
|
||||||
|
@@ -31,6 +31,7 @@
|
|||||||
android:title="@string/ambient_display_pickup_title"
|
android:title="@string/ambient_display_pickup_title"
|
||||||
android:summary="@string/ambient_display_pickup_summary"
|
android:summary="@string/ambient_display_pickup_summary"
|
||||||
app:keywords="@string/keywords_gesture"
|
app:keywords="@string/keywords_gesture"
|
||||||
app:controller="com.android.settings.gestures.PickupGesturePreferenceController" />
|
app:controller="com.android.settings.gestures.PickupGesturePreferenceController"
|
||||||
|
app:allowDividerAbove="true" />
|
||||||
|
|
||||||
</PreferenceScreen>
|
</PreferenceScreen>
|
@@ -32,6 +32,7 @@
|
|||||||
android:entries="@array/gesture_prevent_ringing_entries"
|
android:entries="@array/gesture_prevent_ringing_entries"
|
||||||
android:entryValues="@array/gesture_prevent_ringing_values"
|
android:entryValues="@array/gesture_prevent_ringing_values"
|
||||||
app:controller="com.android.settings.gestures.PreventRingingPreferenceController"
|
app:controller="com.android.settings.gestures.PreventRingingPreferenceController"
|
||||||
app:keywords="@string/keywords_gesture" />
|
app:keywords="@string/keywords_gesture"
|
||||||
|
app:allowDividerAbove="true" />
|
||||||
|
|
||||||
</PreferenceScreen>
|
</PreferenceScreen>
|
@@ -30,6 +30,7 @@
|
|||||||
android:title="@string/fingerprint_swipe_for_notifications_title"
|
android:title="@string/fingerprint_swipe_for_notifications_title"
|
||||||
android:summary="@string/fingerprint_swipe_for_notifications_summary"
|
android:summary="@string/fingerprint_swipe_for_notifications_summary"
|
||||||
app:keywords="@string/keywords_gesture"
|
app:keywords="@string/keywords_gesture"
|
||||||
app:controller="com.android.settings.gestures.SwipeToNotificationPreferenceController" />
|
app:controller="com.android.settings.gestures.SwipeToNotificationPreferenceController"
|
||||||
|
app:allowDividerAbove="true" />
|
||||||
|
|
||||||
</PreferenceScreen>
|
</PreferenceScreen>
|
@@ -31,6 +31,7 @@
|
|||||||
android:title="@string/swipe_up_to_switch_apps_title"
|
android:title="@string/swipe_up_to_switch_apps_title"
|
||||||
android:summary="@string/swipe_up_to_switch_apps_summary"
|
android:summary="@string/swipe_up_to_switch_apps_summary"
|
||||||
app:keywords="@string/keywords_gesture"
|
app:keywords="@string/keywords_gesture"
|
||||||
app:controller="com.android.settings.gestures.SwipeUpPreferenceController" />
|
app:controller="com.android.settings.gestures.SwipeUpPreferenceController"
|
||||||
|
app:allowDividerAbove="true" />
|
||||||
|
|
||||||
</PreferenceScreen>
|
</PreferenceScreen>
|
@@ -0,0 +1,43 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2018 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.connecteddevice.dock;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update the dock devices. It notifies the upper level whether to add/remove the preference
|
||||||
|
* through {@link DevicePreferenceCallback}
|
||||||
|
*/
|
||||||
|
public interface DockUpdater {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Register the dock event callback and update the list
|
||||||
|
*/
|
||||||
|
default void registerCallback() {
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Unregister the dock event callback
|
||||||
|
*/
|
||||||
|
default void unregisterCallback() {
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Force to update the list of dock devices
|
||||||
|
*/
|
||||||
|
default void forceUpdate() {
|
||||||
|
}
|
||||||
|
}
|
@@ -0,0 +1,29 @@
|
|||||||
|
package com.android.settings.connecteddevice.dock;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
|
||||||
|
import com.android.settings.connecteddevice.DevicePreferenceCallback;
|
||||||
|
import com.android.settings.connecteddevice.dock.DockUpdater;
|
||||||
|
import com.android.settings.overlay.DockUpdaterFeatureProvider;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Impl for {@link DockUpdaterFeatureProvider}
|
||||||
|
*/
|
||||||
|
public class DockUpdaterFeatureProviderImpl implements DockUpdaterFeatureProvider {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public DockUpdater getConnectedDockUpdater(Context context,
|
||||||
|
DevicePreferenceCallback devicePreferenceCallback) {
|
||||||
|
final DockUpdater updater = new DockUpdater() {
|
||||||
|
};
|
||||||
|
return updater;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public DockUpdater getSavedDockUpdater(Context context,
|
||||||
|
DevicePreferenceCallback devicePreferenceCallback) {
|
||||||
|
final DockUpdater updater = new DockUpdater() {
|
||||||
|
};
|
||||||
|
return updater;
|
||||||
|
}
|
||||||
|
}
|
@@ -258,10 +258,9 @@ public class DashboardFeatureProviderImpl implements DashboardFeatureProvider {
|
|||||||
Log.w(TAG, "Failed to get icon from uri " + uri);
|
Log.w(TAG, "Failed to get icon from uri " + uri);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
tile.icon = Icon.createWithResource(iconInfo.first, iconInfo.second);
|
final Icon icon = Icon.createWithResource(iconInfo.first, iconInfo.second);
|
||||||
ThreadUtils.postOnMainThread(() -> {
|
ThreadUtils.postOnMainThread(() -> {
|
||||||
preference.setIcon(tile.icon.loadDrawable(preference.getContext()));
|
preference.setIcon(icon.loadDrawable(preference.getContext()));
|
||||||
tile.icon = null;
|
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
@@ -13,6 +13,9 @@
|
|||||||
*/
|
*/
|
||||||
package com.android.settings.display;
|
package com.android.settings.display;
|
||||||
|
|
||||||
|
import static com.android.settingslib.display.BrightnessUtils.GAMMA_SPACE_MAX;
|
||||||
|
import static com.android.settingslib.display.BrightnessUtils.convertLinearToGamma;
|
||||||
|
|
||||||
import android.content.ContentResolver;
|
import android.content.ContentResolver;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.database.ContentObserver;
|
import android.database.ContentObserver;
|
||||||
@@ -103,6 +106,7 @@ public class BrightnessLevelPreferenceController extends AbstractPreferenceContr
|
|||||||
public void updateState(Preference preference) {
|
public void updateState(Preference preference) {
|
||||||
updatedSummary(preference);
|
updatedSummary(preference);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onStart() {
|
public void onStart() {
|
||||||
mContentResolver.registerContentObserver(BRIGHTNESS_URI, false, mBrightnessObserver);
|
mContentResolver.registerContentObserver(BRIGHTNESS_URI, false, mBrightnessObserver);
|
||||||
@@ -122,15 +126,18 @@ public class BrightnessLevelPreferenceController extends AbstractPreferenceContr
|
|||||||
}
|
}
|
||||||
|
|
||||||
private double getCurrentBrightness() {
|
private double getCurrentBrightness() {
|
||||||
|
final int value;
|
||||||
if (isInVrMode()) {
|
if (isInVrMode()) {
|
||||||
final double value = System.getInt(mContentResolver, System.SCREEN_BRIGHTNESS_FOR_VR,
|
value = convertLinearToGamma(System.getInt(mContentResolver,
|
||||||
mMaxBrightness);
|
System.SCREEN_BRIGHTNESS_FOR_VR, mMaxBrightness),
|
||||||
return getPercentage(value, mMinVrBrightness, mMaxVrBrightness);
|
mMinVrBrightness, mMaxVrBrightness);
|
||||||
} else {
|
} else {
|
||||||
final double value = Settings.System.getInt(mContentResolver, System.SCREEN_BRIGHTNESS,
|
value = convertLinearToGamma(Settings.System.getInt(mContentResolver,
|
||||||
mMinBrightness);
|
System.SCREEN_BRIGHTNESS, mMinBrightness),
|
||||||
return getPercentage(value, mMinBrightness, mMaxBrightness);
|
mMinBrightness, mMaxBrightness);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
return getPercentage(value, 0, GAMMA_SPACE_MAX);
|
||||||
}
|
}
|
||||||
|
|
||||||
private double getPercentage(double value, int min, int max) {
|
private double getPercentage(double value, int min, int max) {
|
||||||
|
@@ -19,38 +19,27 @@ package com.android.settings.inputmethod;
|
|||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.hardware.input.InputManager;
|
import android.hardware.input.InputManager;
|
||||||
import android.provider.Settings;
|
import android.provider.Settings;
|
||||||
import android.support.annotation.VisibleForTesting;
|
|
||||||
import android.support.v14.preference.SwitchPreference;
|
|
||||||
import android.support.v7.preference.Preference;
|
import android.support.v7.preference.Preference;
|
||||||
import android.support.v7.preference.PreferenceScreen;
|
import android.support.v7.preference.PreferenceScreen;
|
||||||
import android.text.TextUtils;
|
|
||||||
import android.view.InputDevice;
|
import android.view.InputDevice;
|
||||||
|
|
||||||
import com.android.settings.core.PreferenceControllerMixin;
|
|
||||||
import com.android.settings.R;
|
import com.android.settings.R;
|
||||||
import com.android.settingslib.core.AbstractPreferenceController;
|
import com.android.settings.core.PreferenceControllerMixin;
|
||||||
|
import com.android.settings.core.TogglePreferenceController;
|
||||||
import com.android.settingslib.core.lifecycle.LifecycleObserver;
|
import com.android.settingslib.core.lifecycle.LifecycleObserver;
|
||||||
import com.android.settingslib.core.lifecycle.events.OnPause;
|
import com.android.settingslib.core.lifecycle.events.OnPause;
|
||||||
import com.android.settingslib.core.lifecycle.events.OnResume;
|
import com.android.settingslib.core.lifecycle.events.OnResume;
|
||||||
|
|
||||||
import java.util.List;
|
public class GameControllerPreferenceController extends TogglePreferenceController
|
||||||
|
|
||||||
public class GameControllerPreferenceController extends AbstractPreferenceController
|
|
||||||
implements PreferenceControllerMixin, InputManager.InputDeviceListener, LifecycleObserver,
|
implements PreferenceControllerMixin, InputManager.InputDeviceListener, LifecycleObserver,
|
||||||
OnResume, OnPause {
|
OnResume, OnPause {
|
||||||
|
|
||||||
@VisibleForTesting
|
|
||||||
static final String PREF_KEY = "vibrate_input_devices";
|
|
||||||
private static final String CATEGORY_KEY = "game_controller_settings_category";
|
|
||||||
|
|
||||||
private final InputManager mIm;
|
private final InputManager mIm;
|
||||||
|
|
||||||
private PreferenceScreen mScreen;
|
|
||||||
private Preference mCategory;
|
|
||||||
private Preference mPreference;
|
private Preference mPreference;
|
||||||
|
|
||||||
public GameControllerPreferenceController(Context context) {
|
public GameControllerPreferenceController(Context context, String key) {
|
||||||
super(context);
|
super(context, key);
|
||||||
mIm = (InputManager) context.getSystemService(Context.INPUT_SERVICE);
|
mIm = (InputManager) context.getSystemService(Context.INPUT_SERVICE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -67,85 +56,61 @@ public class GameControllerPreferenceController extends AbstractPreferenceContro
|
|||||||
@Override
|
@Override
|
||||||
public void displayPreference(PreferenceScreen screen) {
|
public void displayPreference(PreferenceScreen screen) {
|
||||||
super.displayPreference(screen);
|
super.displayPreference(screen);
|
||||||
mScreen = screen;
|
mPreference = screen.findPreference(getPreferenceKey());
|
||||||
mCategory = screen.findPreference(CATEGORY_KEY);
|
|
||||||
mPreference = screen.findPreference(PREF_KEY);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isAvailable() {
|
@AvailabilityStatus
|
||||||
|
public int getAvailabilityStatus() {
|
||||||
// If device explicitly wants to hide this, return early.
|
// If device explicitly wants to hide this, return early.
|
||||||
if (!mContext.getResources().getBoolean(R.bool.config_show_vibrate_input_devices)) {
|
if (!mContext.getResources().getBoolean(R.bool.config_show_vibrate_input_devices)) {
|
||||||
return false;
|
return DISABLED_UNSUPPORTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
final int[] devices = mIm.getInputDeviceIds();
|
final int[] devices = mIm.getInputDeviceIds();
|
||||||
for (int deviceId : devices) {
|
for (int deviceId : devices) {
|
||||||
InputDevice device = mIm.getInputDevice(deviceId);
|
InputDevice device = mIm.getInputDevice(deviceId);
|
||||||
if (device != null && !device.isVirtual() && device.getVibrator().hasVibrator()) {
|
if (device != null && !device.isVirtual() && device.getVibrator().hasVibrator()) {
|
||||||
return true;
|
return AVAILABLE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return DISABLED_UNSUPPORTED;
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean handlePreferenceTreeClick(Preference preference) {
|
|
||||||
if (TextUtils.equals(PREF_KEY, preference.getKey())) {
|
|
||||||
Settings.System.putInt(mContext.getContentResolver(),
|
|
||||||
Settings.System.VIBRATE_INPUT_DEVICES,
|
|
||||||
((SwitchPreference) preference).isChecked() ? 1 : 0);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getPreferenceKey() {
|
|
||||||
return CATEGORY_KEY;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updateState(Preference preference) {
|
public void updateState(Preference preference) {
|
||||||
|
super.updateState(preference);
|
||||||
if (preference == null) {
|
if (preference == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
((SwitchPreference) preference).setChecked(Settings.System.getInt(
|
mPreference.setVisible(isAvailable());
|
||||||
mContext.getContentResolver(),
|
|
||||||
Settings.System.VIBRATE_INPUT_DEVICES, 1) > 0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updateNonIndexableKeys(List<String> keys) {
|
public boolean isChecked() {
|
||||||
if (!isAvailable()) {
|
return Settings.System.getInt(
|
||||||
keys.add(CATEGORY_KEY);
|
mContext.getContentResolver(),
|
||||||
keys.add(PREF_KEY);
|
Settings.System.VIBRATE_INPUT_DEVICES, 1) > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean setChecked(boolean isChecked) {
|
||||||
|
return Settings.System.putInt(mContext.getContentResolver(),
|
||||||
|
Settings.System.VIBRATE_INPUT_DEVICES, isChecked ? 1 : 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onInputDeviceAdded(int deviceId) {
|
public void onInputDeviceAdded(int deviceId) {
|
||||||
updateGameControllers();
|
updateState(mPreference);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onInputDeviceRemoved(int deviceId) {
|
public void onInputDeviceRemoved(int deviceId) {
|
||||||
updateGameControllers();
|
updateState(mPreference);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onInputDeviceChanged(int deviceId) {
|
public void onInputDeviceChanged(int deviceId) {
|
||||||
updateGameControllers();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void updateGameControllers() {
|
|
||||||
if (isAvailable()) {
|
|
||||||
mScreen.addPreference(mCategory);
|
|
||||||
updateState(mPreference);
|
updateState(mPreference);
|
||||||
} else {
|
|
||||||
if (mCategory != null) {
|
|
||||||
mScreen.removePreference(mCategory);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -35,7 +35,6 @@ import com.android.settings.R;
|
|||||||
import com.android.settings.applications.defaultapps.DefaultAutofillPreferenceController;
|
import com.android.settings.applications.defaultapps.DefaultAutofillPreferenceController;
|
||||||
import com.android.settings.dashboard.DashboardFragment;
|
import com.android.settings.dashboard.DashboardFragment;
|
||||||
import com.android.settings.dashboard.SummaryLoader;
|
import com.android.settings.dashboard.SummaryLoader;
|
||||||
import com.android.settings.inputmethod.GameControllerPreferenceController;
|
|
||||||
import com.android.settings.inputmethod.PhysicalKeyboardPreferenceController;
|
import com.android.settings.inputmethod.PhysicalKeyboardPreferenceController;
|
||||||
import com.android.settings.inputmethod.SpellCheckerPreferenceController;
|
import com.android.settings.inputmethod.SpellCheckerPreferenceController;
|
||||||
import com.android.settings.inputmethod.VirtualKeyboardPreferenceController;
|
import com.android.settings.inputmethod.VirtualKeyboardPreferenceController;
|
||||||
@@ -124,17 +123,6 @@ public class LanguageAndInputSettings extends DashboardFragment {
|
|||||||
controllers.add(new DefaultAutofillPreferenceController(context));
|
controllers.add(new DefaultAutofillPreferenceController(context));
|
||||||
controllers.add(new UserDictionaryPreferenceController(context));
|
controllers.add(new UserDictionaryPreferenceController(context));
|
||||||
|
|
||||||
// Game Controller
|
|
||||||
final GameControllerPreferenceController gameControllerPreferenceController
|
|
||||||
= new GameControllerPreferenceController(context);
|
|
||||||
if (lifecycle != null) {
|
|
||||||
lifecycle.addObserver(gameControllerPreferenceController);
|
|
||||||
}
|
|
||||||
controllers.add(gameControllerPreferenceController);
|
|
||||||
controllers.add(new PreferenceCategoryController(context,
|
|
||||||
KEY_GAME_CONTROLLER_CATEGORY).setChildren(
|
|
||||||
Arrays.asList(gameControllerPreferenceController)));
|
|
||||||
|
|
||||||
return controllers;
|
return controllers;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -67,7 +67,7 @@ public abstract class BaseNfcPreferenceController extends AbstractPreferenceCont
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updateNonIndexableKeys(List<String> keys) {
|
public void updateNonIndexableKeys(List<String> keys) {
|
||||||
if (isAvailable()) {
|
if (!isAvailable()) {
|
||||||
keys.add(getPreferenceKey());
|
keys.add(getPreferenceKey());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -0,0 +1,35 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2018 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.overlay;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
|
||||||
|
import com.android.settings.connecteddevice.DevicePreferenceCallback;
|
||||||
|
import com.android.settings.connecteddevice.dock.DockUpdater;
|
||||||
|
|
||||||
|
/** Feature provider for the dock updater. */
|
||||||
|
public interface DockUpdaterFeatureProvider {
|
||||||
|
|
||||||
|
/** Returns the DockUpdater of the connected dock device */
|
||||||
|
DockUpdater getConnectedDockUpdater(Context context,
|
||||||
|
DevicePreferenceCallback devicePreferenceCallback);
|
||||||
|
|
||||||
|
/** Returns the DockUpdater of the saved dock devices */
|
||||||
|
DockUpdater getSavedDockUpdater(Context context,
|
||||||
|
DevicePreferenceCallback devicePreferenceCallback);
|
||||||
|
|
||||||
|
}
|
@@ -86,6 +86,8 @@ public abstract class FeatureFactory {
|
|||||||
|
|
||||||
public abstract DashboardFeatureProvider getDashboardFeatureProvider(Context context);
|
public abstract DashboardFeatureProvider getDashboardFeatureProvider(Context context);
|
||||||
|
|
||||||
|
public abstract DockUpdaterFeatureProvider getDockUpdaterFeatureProvider();
|
||||||
|
|
||||||
public abstract ApplicationFeatureProvider getApplicationFeatureProvider(Context context);
|
public abstract ApplicationFeatureProvider getApplicationFeatureProvider(Context context);
|
||||||
|
|
||||||
public abstract LocaleFeatureProvider getLocaleFeatureProvider();
|
public abstract LocaleFeatureProvider getLocaleFeatureProvider();
|
||||||
|
@@ -29,6 +29,7 @@ import com.android.settings.applications.ApplicationFeatureProvider;
|
|||||||
import com.android.settings.applications.ApplicationFeatureProviderImpl;
|
import com.android.settings.applications.ApplicationFeatureProviderImpl;
|
||||||
import com.android.settings.bluetooth.BluetoothFeatureProvider;
|
import com.android.settings.bluetooth.BluetoothFeatureProvider;
|
||||||
import com.android.settings.bluetooth.BluetoothFeatureProviderImpl;
|
import com.android.settings.bluetooth.BluetoothFeatureProviderImpl;
|
||||||
|
import com.android.settings.connecteddevice.dock.DockUpdaterFeatureProviderImpl;
|
||||||
import com.android.settings.dashboard.DashboardFeatureProvider;
|
import com.android.settings.dashboard.DashboardFeatureProvider;
|
||||||
import com.android.settings.dashboard.DashboardFeatureProviderImpl;
|
import com.android.settings.dashboard.DashboardFeatureProviderImpl;
|
||||||
import com.android.settings.dashboard.suggestions.SuggestionFeatureProvider;
|
import com.android.settings.dashboard.suggestions.SuggestionFeatureProvider;
|
||||||
@@ -63,6 +64,7 @@ public class FeatureFactoryImpl extends FeatureFactory {
|
|||||||
private ApplicationFeatureProvider mApplicationFeatureProvider;
|
private ApplicationFeatureProvider mApplicationFeatureProvider;
|
||||||
private MetricsFeatureProvider mMetricsFeatureProvider;
|
private MetricsFeatureProvider mMetricsFeatureProvider;
|
||||||
private DashboardFeatureProviderImpl mDashboardFeatureProvider;
|
private DashboardFeatureProviderImpl mDashboardFeatureProvider;
|
||||||
|
private DockUpdaterFeatureProvider mDockUpdaterFeatureProvider;
|
||||||
private LocaleFeatureProvider mLocaleFeatureProvider;
|
private LocaleFeatureProvider mLocaleFeatureProvider;
|
||||||
private EnterprisePrivacyFeatureProvider mEnterprisePrivacyFeatureProvider;
|
private EnterprisePrivacyFeatureProvider mEnterprisePrivacyFeatureProvider;
|
||||||
private SearchFeatureProvider mSearchFeatureProvider;
|
private SearchFeatureProvider mSearchFeatureProvider;
|
||||||
@@ -105,6 +107,14 @@ public class FeatureFactoryImpl extends FeatureFactory {
|
|||||||
return mDashboardFeatureProvider;
|
return mDashboardFeatureProvider;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public DockUpdaterFeatureProvider getDockUpdaterFeatureProvider() {
|
||||||
|
if (mDockUpdaterFeatureProvider == null) {
|
||||||
|
mDockUpdaterFeatureProvider = new DockUpdaterFeatureProviderImpl();
|
||||||
|
}
|
||||||
|
return mDockUpdaterFeatureProvider;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ApplicationFeatureProvider getApplicationFeatureProvider(Context context) {
|
public ApplicationFeatureProvider getApplicationFeatureProvider(Context context) {
|
||||||
if (mApplicationFeatureProvider == null) {
|
if (mApplicationFeatureProvider == null) {
|
||||||
|
@@ -78,7 +78,6 @@ public class ConnectedDeviceDashboardFragmentTest {
|
|||||||
final List<String> niks = ConnectedDeviceDashboardFragment.SEARCH_INDEX_DATA_PROVIDER
|
final List<String> niks = ConnectedDeviceDashboardFragment.SEARCH_INDEX_DATA_PROVIDER
|
||||||
.getNonIndexableKeys(mContext);
|
.getNonIndexableKeys(mContext);
|
||||||
|
|
||||||
assertThat(niks).containsExactly(KEY_CONNECTED_DEVICES, KEY_AVAILABLE_DEVICES,
|
assertThat(niks).containsExactly(KEY_CONNECTED_DEVICES, KEY_AVAILABLE_DEVICES);
|
||||||
NfcPreferenceController.KEY_TOGGLE_NFC);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -122,7 +122,7 @@ public class BrightnessLevelPreferenceControllerTest {
|
|||||||
|
|
||||||
mController.updateState(mPreference);
|
mController.updateState(mPreference);
|
||||||
|
|
||||||
verify(mPreference).setSummary("85%");
|
verify(mPreference).setSummary("97%");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -135,7 +135,7 @@ public class BrightnessLevelPreferenceControllerTest {
|
|||||||
|
|
||||||
mController.updateState(mPreference);
|
mController.updateState(mPreference);
|
||||||
|
|
||||||
verify(mPreference).setSummary("31%");
|
verify(mPreference).setSummary("78%");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -148,7 +148,7 @@ public class BrightnessLevelPreferenceControllerTest {
|
|||||||
|
|
||||||
mController.updateState(mPreference);
|
mController.updateState(mPreference);
|
||||||
|
|
||||||
verify(mPreference).setSummary("45%");
|
verify(mPreference).setSummary("85%");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@@ -16,6 +16,8 @@
|
|||||||
|
|
||||||
package com.android.settings.inputmethod;
|
package com.android.settings.inputmethod;
|
||||||
|
|
||||||
|
import static com.android.settings.core.BasePreferenceController.AVAILABLE;
|
||||||
|
import static com.android.settings.core.BasePreferenceController.DISABLED_UNSUPPORTED;
|
||||||
import static com.google.common.truth.Truth.assertThat;
|
import static com.google.common.truth.Truth.assertThat;
|
||||||
import static org.mockito.Mockito.never;
|
import static org.mockito.Mockito.never;
|
||||||
import static org.mockito.Mockito.spy;
|
import static org.mockito.Mockito.spy;
|
||||||
@@ -37,10 +39,6 @@ import org.mockito.MockitoAnnotations;
|
|||||||
import org.robolectric.RuntimeEnvironment;
|
import org.robolectric.RuntimeEnvironment;
|
||||||
import org.robolectric.annotation.Config;
|
import org.robolectric.annotation.Config;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
@RunWith(SettingsRobolectricTestRunner.class)
|
@RunWith(SettingsRobolectricTestRunner.class)
|
||||||
public class GameControllerPreferenceControllerTest {
|
public class GameControllerPreferenceControllerTest {
|
||||||
|
|
||||||
@@ -57,7 +55,7 @@ public class GameControllerPreferenceControllerTest {
|
|||||||
MockitoAnnotations.initMocks(this);
|
MockitoAnnotations.initMocks(this);
|
||||||
mContext = spy(RuntimeEnvironment.application);
|
mContext = spy(RuntimeEnvironment.application);
|
||||||
when(mContext.getSystemService(Context.INPUT_SERVICE)).thenReturn(mInputManager);
|
when(mContext.getSystemService(Context.INPUT_SERVICE)).thenReturn(mInputManager);
|
||||||
mController = new GameControllerPreferenceController(mContext);
|
mController = new GameControllerPreferenceController(mContext, "test_key");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -75,59 +73,59 @@ public class GameControllerPreferenceControllerTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testIsAvailable_hasDeviceWithVibrator_shouldReturnTrue() {
|
public void getAvailabilityStatus_hasDeviceWithVibrator_shouldReturnAvailable() {
|
||||||
when(mInputManager.getInputDeviceIds()).thenReturn(new int[]{1});
|
when(mInputManager.getInputDeviceIds()).thenReturn(new int[] {1});
|
||||||
when(mInputManager.getInputDevice(1)).thenReturn(mInputDevice);
|
when(mInputManager.getInputDevice(1)).thenReturn(mInputDevice);
|
||||||
when(mInputDevice.isVirtual()).thenReturn(false);
|
when(mInputDevice.isVirtual()).thenReturn(false);
|
||||||
when(mInputDevice.getVibrator().hasVibrator()).thenReturn(true);
|
when(mInputDevice.getVibrator().hasVibrator()).thenReturn(true);
|
||||||
|
|
||||||
assertThat(mController.isAvailable()).isTrue();
|
assertThat(mController.getAvailabilityStatus()).isEqualTo(AVAILABLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testIsAvailable_hasNoVibratingDevice_shouldReturnFalse() {
|
public void getAvailabilityStatus_hasNoVibratingDevice_shouldReturnDisabled() {
|
||||||
when(mInputManager.getInputDeviceIds()).thenReturn(new int[]{1});
|
when(mInputManager.getInputDeviceIds()).thenReturn(new int[] {1});
|
||||||
when(mInputManager.getInputDevice(1)).thenReturn(mInputDevice);
|
when(mInputManager.getInputDevice(1)).thenReturn(mInputDevice);
|
||||||
when(mInputDevice.isVirtual()).thenReturn(false);
|
when(mInputDevice.isVirtual()).thenReturn(false);
|
||||||
when(mInputDevice.getVibrator().hasVibrator()).thenReturn(false);
|
when(mInputDevice.getVibrator().hasVibrator()).thenReturn(false);
|
||||||
|
|
||||||
assertThat(mController.isAvailable()).isFalse();
|
assertThat(mController.getAvailabilityStatus()).isEqualTo(DISABLED_UNSUPPORTED);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testIsAvailable_hasNoPhysicalDevice_shouldReturnFalse() {
|
public void getAvailabilityStatus_hasNoPhysicalDevice_shouldReturnDisabled() {
|
||||||
when(mInputManager.getInputDeviceIds()).thenReturn(new int[]{1});
|
when(mInputManager.getInputDeviceIds()).thenReturn(new int[] {1});
|
||||||
when(mInputManager.getInputDevice(1)).thenReturn(mInputDevice);
|
when(mInputManager.getInputDevice(1)).thenReturn(mInputDevice);
|
||||||
when(mInputDevice.isVirtual()).thenReturn(true);
|
when(mInputDevice.isVirtual()).thenReturn(true);
|
||||||
|
|
||||||
assertThat(mController.isAvailable()).isFalse();
|
assertThat(mController.getAvailabilityStatus()).isEqualTo(DISABLED_UNSUPPORTED);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testIsAvailable_hasNoDevice_shouldReturnFalse() {
|
public void getAvailabilityStatus_hasNoDevice_shouldReturnDisabled() {
|
||||||
when(mInputManager.getInputDeviceIds()).thenReturn(new int[]{});
|
when(mInputManager.getInputDeviceIds()).thenReturn(new int[] {});
|
||||||
|
|
||||||
assertThat(mController.isAvailable()).isFalse();
|
assertThat(mController.getAvailabilityStatus()).isEqualTo(DISABLED_UNSUPPORTED);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@Config(qualifiers = "mcc999")
|
@Config(qualifiers = "mcc999")
|
||||||
public void testIsAvailable_ifDisabled_shouldReturnFalse() {
|
public void getAvailabilityStatus_ifDisabled_shouldReturnDisabled() {
|
||||||
mController = new GameControllerPreferenceController(mContext);
|
mController = new GameControllerPreferenceController(mContext, "testkey");
|
||||||
|
|
||||||
assertThat(mController.isAvailable()).isFalse();
|
assertThat(mController.getAvailabilityStatus()).isEqualTo(DISABLED_UNSUPPORTED);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void updateNonIndexableKeys_shouldIncludeCategoryAndPrefKeys() {
|
public void setChecked_toEnabled_shouldSetToSettingsProvider() {
|
||||||
when(mInputManager.getInputDeviceIds()).thenReturn(new int[]{});
|
mController.setChecked(true);
|
||||||
|
assertThat(mController.isChecked()).isTrue();
|
||||||
|
}
|
||||||
|
|
||||||
final List<String> nonIndexables = new ArrayList<>();
|
@Test
|
||||||
mController.updateNonIndexableKeys(nonIndexables);
|
public void setChecked_toDisabled_shouldSetToSettingsProvider() {
|
||||||
|
mController.setChecked(true);
|
||||||
assertThat(mController.isAvailable()).isFalse();
|
mController.setChecked(false);
|
||||||
assertThat(nonIndexables).containsExactlyElementsIn(Arrays.asList(
|
assertThat(mController.isChecked()).isFalse();
|
||||||
GameControllerPreferenceController.PREF_KEY,
|
|
||||||
mController.getPreferenceKey()));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -41,6 +41,9 @@ import org.mockito.MockitoAnnotations;
|
|||||||
import org.robolectric.RuntimeEnvironment;
|
import org.robolectric.RuntimeEnvironment;
|
||||||
import org.robolectric.util.ReflectionHelpers;
|
import org.robolectric.util.ReflectionHelpers;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
@RunWith(SettingsRobolectricTestRunner.class)
|
@RunWith(SettingsRobolectricTestRunner.class)
|
||||||
public class AndroidBeamPreferenceControllerTest {
|
public class AndroidBeamPreferenceControllerTest {
|
||||||
|
|
||||||
@@ -132,4 +135,24 @@ public class AndroidBeamPreferenceControllerTest {
|
|||||||
mAndroidBeamController.onResume();
|
mAndroidBeamController.onResume();
|
||||||
assertThat(mAndroidBeamPreference.isEnabled()).isFalse();
|
assertThat(mAndroidBeamPreference.isEnabled()).isFalse();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void updateNonIndexableKeys_available_shouldNotUpdate() {
|
||||||
|
when(mNfcAdapter.isEnabled()).thenReturn(true);
|
||||||
|
final List<String> keys = new ArrayList<>();
|
||||||
|
|
||||||
|
mAndroidBeamController.updateNonIndexableKeys(keys);
|
||||||
|
|
||||||
|
assertThat(keys).isEmpty();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void updateNonIndexableKeys_notAvailable_shouldUpdate() {
|
||||||
|
ReflectionHelpers.setField(mAndroidBeamController, "mNfcAdapter", null);
|
||||||
|
final List<String> keys = new ArrayList<>();
|
||||||
|
|
||||||
|
mAndroidBeamController.updateNonIndexableKeys(keys);
|
||||||
|
|
||||||
|
assertThat(keys).hasSize(1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -39,6 +39,9 @@ import org.mockito.MockitoAnnotations;
|
|||||||
import org.robolectric.RuntimeEnvironment;
|
import org.robolectric.RuntimeEnvironment;
|
||||||
import org.robolectric.util.ReflectionHelpers;
|
import org.robolectric.util.ReflectionHelpers;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
@RunWith(SettingsRobolectricTestRunner.class)
|
@RunWith(SettingsRobolectricTestRunner.class)
|
||||||
public class NfcPreferenceControllerTest {
|
public class NfcPreferenceControllerTest {
|
||||||
|
|
||||||
@@ -134,4 +137,24 @@ public class NfcPreferenceControllerTest {
|
|||||||
mNfcController.onResume();
|
mNfcController.onResume();
|
||||||
assertThat(mNfcPreference.isChecked()).isFalse();
|
assertThat(mNfcPreference.isChecked()).isFalse();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void updateNonIndexableKeys_available_shouldNotUpdate() {
|
||||||
|
when(mNfcAdapter.isEnabled()).thenReturn(true);
|
||||||
|
final List<String> keys = new ArrayList<>();
|
||||||
|
|
||||||
|
mNfcController.updateNonIndexableKeys(keys);
|
||||||
|
|
||||||
|
assertThat(keys).isEmpty();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void updateNonIndexableKeys_notAvailable_shouldUpdate() {
|
||||||
|
ReflectionHelpers.setField(mNfcController, "mNfcAdapter", null);
|
||||||
|
final List<String> keys = new ArrayList<>();
|
||||||
|
|
||||||
|
mNfcController.updateNonIndexableKeys(keys);
|
||||||
|
|
||||||
|
assertThat(keys).hasSize(1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -30,6 +30,7 @@ import com.android.settings.enterprise.EnterprisePrivacyFeatureProvider;
|
|||||||
import com.android.settings.fuelgauge.PowerUsageFeatureProvider;
|
import com.android.settings.fuelgauge.PowerUsageFeatureProvider;
|
||||||
import com.android.settings.gestures.AssistGestureFeatureProvider;
|
import com.android.settings.gestures.AssistGestureFeatureProvider;
|
||||||
import com.android.settings.localepicker.LocaleFeatureProvider;
|
import com.android.settings.localepicker.LocaleFeatureProvider;
|
||||||
|
import com.android.settings.overlay.DockUpdaterFeatureProvider;
|
||||||
import com.android.settings.overlay.FeatureFactory;
|
import com.android.settings.overlay.FeatureFactory;
|
||||||
import com.android.settings.overlay.SupportFeatureProvider;
|
import com.android.settings.overlay.SupportFeatureProvider;
|
||||||
import com.android.settings.overlay.SurveyFeatureProvider;
|
import com.android.settings.overlay.SurveyFeatureProvider;
|
||||||
@@ -52,6 +53,7 @@ public class FakeFeatureFactory extends FeatureFactory {
|
|||||||
public final MetricsFeatureProvider metricsFeatureProvider;
|
public final MetricsFeatureProvider metricsFeatureProvider;
|
||||||
public final PowerUsageFeatureProvider powerUsageFeatureProvider;
|
public final PowerUsageFeatureProvider powerUsageFeatureProvider;
|
||||||
public final DashboardFeatureProvider dashboardFeatureProvider;
|
public final DashboardFeatureProvider dashboardFeatureProvider;
|
||||||
|
public final DockUpdaterFeatureProvider dockUpdaterFeatureProvider;
|
||||||
public final LocaleFeatureProvider localeFeatureProvider;
|
public final LocaleFeatureProvider localeFeatureProvider;
|
||||||
public final ApplicationFeatureProvider applicationFeatureProvider;
|
public final ApplicationFeatureProvider applicationFeatureProvider;
|
||||||
public final EnterprisePrivacyFeatureProvider enterprisePrivacyFeatureProvider;
|
public final EnterprisePrivacyFeatureProvider enterprisePrivacyFeatureProvider;
|
||||||
@@ -91,6 +93,7 @@ public class FakeFeatureFactory extends FeatureFactory {
|
|||||||
metricsFeatureProvider = mock(MetricsFeatureProvider.class);
|
metricsFeatureProvider = mock(MetricsFeatureProvider.class);
|
||||||
powerUsageFeatureProvider = mock(PowerUsageFeatureProvider.class);
|
powerUsageFeatureProvider = mock(PowerUsageFeatureProvider.class);
|
||||||
dashboardFeatureProvider = mock(DashboardFeatureProvider.class);
|
dashboardFeatureProvider = mock(DashboardFeatureProvider.class);
|
||||||
|
dockUpdaterFeatureProvider = mock(DockUpdaterFeatureProvider.class);
|
||||||
localeFeatureProvider = mock(LocaleFeatureProvider.class);
|
localeFeatureProvider = mock(LocaleFeatureProvider.class);
|
||||||
applicationFeatureProvider = mock(ApplicationFeatureProvider.class);
|
applicationFeatureProvider = mock(ApplicationFeatureProvider.class);
|
||||||
enterprisePrivacyFeatureProvider = mock(EnterprisePrivacyFeatureProvider.class);
|
enterprisePrivacyFeatureProvider = mock(EnterprisePrivacyFeatureProvider.class);
|
||||||
@@ -131,6 +134,11 @@ public class FakeFeatureFactory extends FeatureFactory {
|
|||||||
return dashboardFeatureProvider;
|
return dashboardFeatureProvider;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public DockUpdaterFeatureProvider getDockUpdaterFeatureProvider() {
|
||||||
|
return dockUpdaterFeatureProvider;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ApplicationFeatureProvider getApplicationFeatureProvider(Context context) {
|
public ApplicationFeatureProvider getApplicationFeatureProvider(Context context) {
|
||||||
return applicationFeatureProvider;
|
return applicationFeatureProvider;
|
||||||
|
Reference in New Issue
Block a user