Snap for 4473011 from a82c5091e1 to pi-release

Change-Id: I6d32e1f9aa625d90099eb111f23d6b3daeacb488
This commit is contained in:
android-build-team Robot
2017-11-29 08:34:47 +00:00
191 changed files with 927 additions and 516 deletions

View File

@@ -63,7 +63,7 @@
android:layout_height="wrap_content"
android:layout_below="@android:id/summary"
android:text="@string/storage_menu_free"
style="@android:style/@Widget.Material.Button.Colored" />
style="@style/ActionPrimaryButton" />
</LinearLayout>
<com.android.settings.widget.DonutView

View File

@@ -61,7 +61,7 @@
<Button
android:id="@android:id/primary"
style="@style/SuwGlifButton.Primary"
style="@style/ActionPrimaryButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"

View File

@@ -338,10 +338,10 @@
<style name="TextAppearance.SupportSummary" parent="TextAppearance.CategoryTitle"/>
<style name="SupportPrimaryButton" parent="android:Widget.Material.Button.Colored"/>
<style name="SupportPrimaryButton" parent="android:Widget.DeviceDefault.Button.Colored"/>
<style name="SupportSecondaryButton"
parent="android:Widget.Material.Button.Borderless.Colored">
parent="android:Widget.DeviceDefault.Button.Borderless.Colored">
<item name="android:textSize">12sp</item>
</style>
@@ -425,11 +425,11 @@
<item name="android:textSize">16sp</item>
</style>
<style name="ActionPrimaryButton" parent="android:Widget.Material.Button.Colored"/>
<style name="ActionPrimaryButton" parent="android:Widget.DeviceDefault.Button.Colored"/>
<style name="ActionSecondaryButton" parent="android:Widget.Material.Button"/>
<style name="ActionSecondaryButton" parent="android:Widget.DeviceDefault.Button"/>
<style name="DreamStartButton" parent="android:Widget.Material.Button" />
<style name="DreamStartButton" parent="android:Widget.DeviceDefault.Button" />
<style name="LockPatternContainerStyle">
<item name="android:maxHeight">400dp</item>

View File

@@ -0,0 +1,159 @@
/*
* Copyright (C) 2017 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.core;
import android.annotation.IntDef;
import android.app.slice.Slice;
import android.content.Context;
import android.support.v7.preference.Preference;
import android.text.TextUtils;
import android.util.Log;
import com.android.settings.core.PreferenceControllerMixin;
import com.android.settings.search.ResultPayload;
import com.android.settings.search.SearchIndexableRaw;
import com.android.settingslib.core.AbstractPreferenceController;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.util.List;
/**
* Abstract class to consolidate utility between preference controllers and act as an interface
* for Slices. The abstract classes that inherit from this class will act as the direct interfaces
* for each type when plugging into Slices.
*/
public abstract class BasePreferenceController extends AbstractPreferenceController {
private static final String TAG = "SettingsPrefController";
@Retention(RetentionPolicy.SOURCE)
@IntDef({AVAILABLE, DISABLED_UNSUPPORTED, DISABLED_FOR_USER, DISABLED_DEPENDENT_SETTING,
UNAVAILABLE_UNKNOWN})
public @interface AvailabilityStatus {
}
/**
* The setting is available.
*/
public static final int AVAILABLE = 0;
/**
* The setting is not supported by the device.
*/
public static final int DISABLED_UNSUPPORTED = 1;
/**
* The setting cannot be changed by the current user.
*/
public static final int DISABLED_FOR_USER = 2;
/**
* The setting has a dependency in the Settings App which is currently blocking access.
*/
public static final int DISABLED_DEPENDENT_SETTING = 3;
/**
* A catch-all case for internal errors and inexplicable unavailability.
*/
public static final int UNAVAILABLE_UNKNOWN = 4;
private final String mPreferenceKey;
public BasePreferenceController(Context context, String preferenceKey) {
super(context);
mPreferenceKey = preferenceKey;
}
/**
* @return {@AvailabilityStatus} for the Setting. This status is used to determine if the
* Setting should be shown or disabled in Settings. Further, it can be used to produce
* appropriate error / warning Slice in the case of unavailability.
* </p>
* The status is used for the convenience methods: {@link #isAvailable()},
* {@link #isSupported()}
*/
@AvailabilityStatus
public abstract int getAvailabilityStatus();
/**
* @return A slice for the corresponding setting.
*/
public abstract Slice getSettingSlice();
@Override
public String getPreferenceKey() {
return mPreferenceKey;
}
@Override
public final boolean isAvailable() {
return getAvailabilityStatus() == AVAILABLE;
}
/**
* @return {@code false} if the setting is not applicable to the device. This covers both
* settings which were only introduced in future versions of android, or settings that have
* hardware dependencies.
* </p>
* Note that a return value of {@code true} does not mean that the setting is available.
*/
public final boolean isSupported() {
return getAvailabilityStatus() != DISABLED_UNSUPPORTED;
}
/**
* Updates non-indexable keys for search provider.
*
* Called by SearchIndexProvider#getNonIndexableKeys
*/
public void updateNonIndexableKeys(List<String> keys) {
if (this instanceof AbstractPreferenceController) {
if (!isAvailable()) {
final String key = getPreferenceKey();
if (TextUtils.isEmpty(key)) {
Log.w(TAG,
"Skipping updateNonIndexableKeys due to empty key " + this.toString());
return;
}
keys.add(key);
}
}
}
/**
* Updates raw data for search provider.
*
* Called by SearchIndexProvider#getRawDataToIndex
*/
public void updateRawDataToIndex(List<SearchIndexableRaw> rawData) {
}
/**
* @return the {@link ResultPayload} corresponding to the search result type for the preference.
* TODO (b/69808376) Remove this method.
* Do not extend this method. It will not launch with P.
*/
@Deprecated
public ResultPayload getResultPayload() {
return null;
}
// TODO (b/69380366) Add Method to get preference UI
// TODO (b/69380464) Add method to get intent
// TODO (b/69380560) Add method to get broadcast intent
}

View File

@@ -26,6 +26,7 @@ import java.util.List;
/**
* A controller mixin that adds mobile settings specific functionality
* TODO (b/69808530) Replace with BasePreferenceController.
*/
public interface PreferenceControllerMixin {
@@ -60,7 +61,11 @@ public interface PreferenceControllerMixin {
/**
* @return the {@link ResultPayload} corresponding to the search result type for the preference.
*
* Do not rely on this method for intent-based or inline results. It will be removed in the
* unbundling effort.
*/
@Deprecated
default ResultPayload getResultPayload() {
return null;
}

View File

@@ -0,0 +1,64 @@
/*
* Copyright (C) 2017 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.core;
import android.app.slice.Slice;
import android.content.Context;
import android.support.v14.preference.SwitchPreference;
import android.support.v7.preference.Preference;
/**
* Abstract class that consolidates logic for updating toggle controllers.
* It automatically handles the getting and setting of the switch UI element.
* Children of this class implement methods to get and set the underlying value of the setting.
*/
public abstract class TogglePreferenceController extends BasePreferenceController implements
Preference.OnPreferenceChangeListener {
private static final String TAG = "TogglePrefController";
public TogglePreferenceController(Context context, String preferenceKey) {
super(context, preferenceKey);
}
/**
* @return {@code true} if the Setting is enabled.
*/
public abstract boolean isChecked();
/**
* Set the Setting to {@param isChecked}
*
* @param isChecked Is {@true} when the setting should be enabled.
*/
public abstract void setChecked(boolean isChecked);
@Override
public final void updateState(Preference preference) {
((SwitchPreference) preference).setChecked(isChecked());
}
@Override
public final boolean onPreferenceChange(Preference preference, Object newValue) {
boolean auto = (Boolean) newValue;
setChecked(auto);
return true;
}
@Override
public Slice getSettingSlice() {
// TODO
return null;
}
}

View File

@@ -16,23 +16,26 @@
package com.android.settings.dashboard;
import static android.provider.SearchIndexablesContract.SITE_MAP_COLUMNS;
import static com.android.settings.dashboard.DashboardFragmentRegistry.CATEGORY_KEY_TO_PARENT_MAP;
import android.content.Context;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.provider.SearchIndexablesContract.SiteMapColumns;
import android.support.annotation.VisibleForTesting;
import android.support.annotation.WorkerThread;
import android.support.v4.util.ArrayMap;
import android.text.TextUtils;
import android.util.Log;
import com.android.settings.SettingsActivity;
import com.android.settings.overlay.FeatureFactory;
import com.android.settings.search.IndexDatabaseHelper;
import com.android.settings.search.IndexDatabaseHelper.IndexColumns;
import com.android.settings.search.IndexDatabaseHelper.SiteMapColumns;
import com.android.settingslib.drawer.DashboardCategory;
import com.android.settingslib.drawer.Tile;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
@@ -47,14 +50,6 @@ public class SiteMapManager {
private static final String TAG = "SiteMapManager";
private static final boolean DEBUG_TIMING = false;
@VisibleForTesting(otherwise = VisibleForTesting.PRIVATE)
public static final String[] SITE_MAP_COLUMNS = {
SiteMapColumns.PARENT_CLASS,
SiteMapColumns.PARENT_TITLE,
SiteMapColumns.CHILD_CLASS,
SiteMapColumns.CHILD_TITLE
};
private static final String[] CLASS_TO_SCREEN_TITLE_COLUMNS = {
IndexColumns.CLASS_NAME,
IndexColumns.SCREEN_TITLE,
@@ -108,7 +103,7 @@ public class SiteMapManager {
* 2. IA: We know from {@link DashboardFeatureProvider} which page can be dynamically
* injected to where.
*/
@VisibleForTesting(otherwise = VisibleForTesting.PRIVATE)
@VisibleForTesting
@WorkerThread
synchronized void init(Context context) {
if (mInitialized) {

View File

@@ -98,7 +98,7 @@ public class OemUnlockPreferenceController extends DeveloperOptionsPreferenceCon
@Override
public void updateState(Preference preference) {
super.updateState(preference);
mPreference.setChecked(mOemLockManager.isOemUnlockAllowed());
mPreference.setChecked(isOemUnlockedAllowed());
updateOemUnlockSettingDescription();
// Showing mEnableOemUnlock preference as device has persistent data block.
mPreference.setDisabledByAdmin(null);
@@ -183,7 +183,8 @@ public class OemUnlockPreferenceController extends DeveloperOptionsPreferenceCon
/**
* Returns {@code true} if the bootloader has been unlocked. Otherwise, returns {code false}.
*/
private boolean isBootloaderUnlocked() {
@VisibleForTesting
boolean isBootloaderUnlocked() {
return mOemLockManager.isDeviceOemUnlocked();
}
@@ -216,4 +217,9 @@ public class OemUnlockPreferenceController extends DeveloperOptionsPreferenceCon
userHandle);
}
@VisibleForTesting
boolean isOemUnlockedAllowed() {
return mOemLockManager.isOemUnlockAllowed();
}
}

View File

@@ -21,6 +21,7 @@ import android.os.UserHandle;
import android.provider.Settings;
import android.support.v14.preference.SwitchPreference;
import android.support.v7.preference.Preference;
import android.support.annotation.VisibleForTesting;
import com.android.internal.hardware.AmbientDisplayConfiguration;
import com.android.settings.R;
@@ -81,7 +82,7 @@ public class AmbientDisplayAlwaysOnPreferenceController extends
@Override
public boolean isAvailable() {
return isAvailable(mConfig);
return alwaysOnAvailableForUser(mConfig);
}
public static boolean isAvailable(AmbientDisplayConfiguration config) {
@@ -102,4 +103,9 @@ public class AmbientDisplayAlwaysOnPreferenceController extends
ResultPayload.SettingsSource.SECURE, ON /* onValue */, intent, isAvailable(),
ON /* defaultValue */);
}
@VisibleForTesting
boolean alwaysOnAvailableForUser(AmbientDisplayConfiguration config) {
return isAvailable(config);
}
}

View File

@@ -16,65 +16,54 @@ package com.android.settings.display;
import android.content.Context;
import android.content.Intent;
import android.provider.Settings;
import android.support.v14.preference.SwitchPreference;
import android.support.v7.preference.Preference;
import com.android.settings.DisplaySettings;
import com.android.settings.core.PreferenceControllerMixin;
import com.android.settings.core.TogglePreferenceController;
import com.android.settings.search.DatabaseIndexingUtils;
import com.android.settings.search.InlineSwitchPayload;
import com.android.settings.search.ResultPayload;
import com.android.settings.R;
import com.android.settingslib.core.AbstractPreferenceController;
import static android.provider.Settings.System.SCREEN_BRIGHTNESS_MODE;
import static android.provider.Settings.System.SCREEN_BRIGHTNESS_MODE_AUTOMATIC;
import static android.provider.Settings.System.SCREEN_BRIGHTNESS_MODE_MANUAL;
public class AutoBrightnessPreferenceController extends AbstractPreferenceController implements
PreferenceControllerMixin, Preference.OnPreferenceChangeListener {
private final String mAutoBrightnessKey;
public class AutoBrightnessPreferenceController extends TogglePreferenceController {
private final String SYSTEM_KEY = SCREEN_BRIGHTNESS_MODE;
private final int DEFAULT_VALUE = SCREEN_BRIGHTNESS_MODE_MANUAL;
public AutoBrightnessPreferenceController(Context context, String key) {
super(context);
mAutoBrightnessKey = key;
super(context, key);
}
@Override
public boolean isAvailable() {
return mContext.getResources().getBoolean(
com.android.internal.R.bool.config_automatic_brightness_available);
public boolean isChecked() {
return Settings.System.getInt(mContext.getContentResolver(),
SYSTEM_KEY, DEFAULT_VALUE) != DEFAULT_VALUE;
}
@Override
public String getPreferenceKey() {
return mAutoBrightnessKey;
}
@Override
public void updateState(Preference preference) {
int brightnessMode = Settings.System.getInt(mContext.getContentResolver(),
SYSTEM_KEY, DEFAULT_VALUE);
((SwitchPreference) preference).setChecked(brightnessMode != DEFAULT_VALUE);
}
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
boolean auto = (Boolean) newValue;
public void setChecked(boolean isChecked) {
Settings.System.putInt(mContext.getContentResolver(), SYSTEM_KEY,
auto ? SCREEN_BRIGHTNESS_MODE_AUTOMATIC : DEFAULT_VALUE);
return true;
isChecked ? SCREEN_BRIGHTNESS_MODE_AUTOMATIC : DEFAULT_VALUE);
}
@Override
@AvailabilityStatus
public int getAvailabilityStatus() {
return mContext.getResources().getBoolean(
com.android.internal.R.bool.config_automatic_brightness_available)
? AVAILABLE
: DISABLED_UNSUPPORTED;
}
@Override
public ResultPayload getResultPayload() {
// TODO remove result payload
final Intent intent = DatabaseIndexingUtils.buildSearchResultPageIntent(mContext,
DisplaySettings.class.getName(), mAutoBrightnessKey,
DisplaySettings.class.getName(), getPreferenceKey(),
mContext.getString(R.string.display_settings));
return new InlineSwitchPayload(SYSTEM_KEY,

View File

@@ -50,6 +50,11 @@ public class FakeUid extends Uid {
return null;
}
@Override
public Timer getMulticastWakelockStats() {
return null;
}
@Override
public ArrayMap<String, ? extends Timer> getSyncStats() {
return null;

View File

@@ -27,6 +27,7 @@ import android.util.AttributeSet;
import android.util.Log;
import android.util.Xml;
import com.android.settings.core.BasePreferenceController;
import com.android.settings.core.PreferenceControllerMixin;
import com.android.settingslib.core.AbstractPreferenceController;
@@ -71,6 +72,9 @@ public class BaseSearchIndexProvider implements Indexable.SearchIndexProvider {
if (controller instanceof PreferenceControllerMixin) {
((PreferenceControllerMixin) controller)
.updateNonIndexableKeys(nonIndexableKeys);
} else if (controller instanceof BasePreferenceController) {
((BasePreferenceController) controller).updateNonIndexableKeys(
nonIndexableKeys);
} else {
throw new IllegalStateException(controller.getClass().getName()
+ " must implement " + PreferenceControllerMixin.class.getName());

View File

@@ -19,20 +19,18 @@ package com.android.settings.search;
import static com.android.settings.search.CursorToSearchResultConverter.COLUMN_INDEX_ID;
import static com.android.settings.search.CursorToSearchResultConverter
.COLUMN_INDEX_INTENT_ACTION_TARGET_PACKAGE;
import static com.android.settings.search.CursorToSearchResultConverter.COLUMN_INDEX_INTENT_ACTION_TARGET_PACKAGE;
import static com.android.settings.search.CursorToSearchResultConverter.COLUMN_INDEX_KEY;
import static com.android.settings.search.DatabaseResultLoader.SELECT_COLUMNS;
import static com.android.settings.search.IndexDatabaseHelper.IndexColumns.DOCID;
import static com.android.settings.search.IndexDatabaseHelper.IndexColumns.CLASS_NAME;
import static com.android.settings.search.IndexDatabaseHelper.IndexColumns.DATA_ENTRIES;
import static com.android.settings.search.IndexDatabaseHelper.IndexColumns.DATA_KEYWORDS;
import static com.android.settings.search.IndexDatabaseHelper.IndexColumns.DATA_KEY_REF;
import static com.android.settings.search.IndexDatabaseHelper.IndexColumns.DATA_SUMMARY_ON;
import static com.android.settings.search.IndexDatabaseHelper.IndexColumns
.DATA_SUMMARY_ON_NORMALIZED;
import static com.android.settings.search.IndexDatabaseHelper.IndexColumns.DATA_SUMMARY_ON_NORMALIZED;
import static com.android.settings.search.IndexDatabaseHelper.IndexColumns.DATA_TITLE;
import static com.android.settings.search.IndexDatabaseHelper.IndexColumns.DATA_TITLE_NORMALIZED;
import static com.android.settings.search.IndexDatabaseHelper.IndexColumns.DOCID;
import static com.android.settings.search.IndexDatabaseHelper.IndexColumns.ENABLED;
import static com.android.settings.search.IndexDatabaseHelper.IndexColumns.ICON;
import static com.android.settings.search.IndexDatabaseHelper.IndexColumns.INTENT_ACTION;
@@ -55,6 +53,7 @@ import android.database.sqlite.SQLiteException;
import android.os.AsyncTask;
import android.os.Build;
import android.provider.SearchIndexablesContract;
import android.provider.SearchIndexablesContract.SiteMapColumns;
import android.support.annotation.VisibleForTesting;
import android.text.TextUtils;
import android.util.Log;
@@ -68,7 +67,6 @@ import com.android.settings.search.indexing.PreIndexDataCollector;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
import java.util.concurrent.atomic.AtomicBoolean;
@@ -276,17 +274,11 @@ public class DatabaseIndexingManager {
if (!TextUtils.isEmpty(dataRow.className)
&& !TextUtils.isEmpty(dataRow.childClassName)) {
ContentValues siteMapPair = new ContentValues();
final int pairDocId = Objects.hash(dataRow.className, dataRow.childClassName);
siteMapPair.put(IndexDatabaseHelper.SiteMapColumns.DOCID, pairDocId);
siteMapPair.put(IndexDatabaseHelper.SiteMapColumns.PARENT_CLASS,
dataRow.className);
siteMapPair.put(IndexDatabaseHelper.SiteMapColumns.PARENT_TITLE,
dataRow.screenTitle);
siteMapPair.put(IndexDatabaseHelper.SiteMapColumns.CHILD_CLASS,
dataRow.childClassName);
siteMapPair.put(IndexDatabaseHelper.SiteMapColumns.CHILD_TITLE,
dataRow.updatedTitle);
final ContentValues siteMapPair = new ContentValues();
siteMapPair.put(SiteMapColumns.PARENT_CLASS, dataRow.className);
siteMapPair.put(SiteMapColumns.PARENT_TITLE, dataRow.screenTitle);
siteMapPair.put(SiteMapColumns.CHILD_CLASS, dataRow.childClassName);
siteMapPair.put(SiteMapColumns.CHILD_TITLE, dataRow.updatedTitle);
database.replaceOrThrow(IndexDatabaseHelper.Tables.TABLE_SITE_MAP,
null /* nullColumnHack */, siteMapPair);

View File

@@ -27,6 +27,7 @@ import android.util.Log;
import com.android.internal.logging.nano.MetricsProto;
import com.android.settings.SettingsActivity;
import com.android.settings.Utils;
import com.android.settings.core.BasePreferenceController;
import com.android.settings.core.PreferenceControllerMixin;
import com.android.settingslib.core.AbstractPreferenceController;
@@ -72,10 +73,11 @@ public class DatabaseIndexingUtils {
* @return A map between {@link Uri}s and {@link PreferenceControllerMixin}s to get the payload
* types for Settings.
*/
public static Map<String, PreferenceControllerMixin> getPreferenceControllerUriMap(
public static Map<String, ResultPayload> getPayloadKeyMap(
String className, Context context) {
ArrayMap<String, ResultPayload> map = new ArrayMap<>();
if (context == null) {
return null;
return map;
}
final Class<?> clazz = getIndexableClass(className);
@@ -83,7 +85,7 @@ public class DatabaseIndexingUtils {
if (clazz == null) {
Log.d(TAG, "SearchIndexableResource '" + className +
"' should implement the " + Indexable.class.getName() + " interface!");
return null;
return map;
}
// Will be non null only for a Local provider implementing a
@@ -94,44 +96,28 @@ public class DatabaseIndexingUtils {
provider.getPreferenceControllers(context);
if (controllers == null) {
return null;
return map;
}
ArrayMap<String, PreferenceControllerMixin> map = new ArrayMap<>();
for (AbstractPreferenceController controller : controllers) {
ResultPayload payload;
if (controller instanceof PreferenceControllerMixin) {
map.put(controller.getPreferenceKey(), (PreferenceControllerMixin) controller);
payload = ((PreferenceControllerMixin) controller).getResultPayload();
} else if (controller instanceof BasePreferenceController) {
payload = ((BasePreferenceController) controller).getResultPayload();
} else {
throw new IllegalStateException(controller.getClass().getName()
+ " must implement " + PreferenceControllerMixin.class.getName());
}
if (payload != null) {
map.put(controller.getPreferenceKey(), payload);
}
}
return map;
}
/**
* @param uriMap Map between the {@link PreferenceControllerMixin} keys
* and the controllers themselves.
* @param key The look-up key
* @return The Payload from the {@link PreferenceControllerMixin} specified by the key,
* if it exists. Otherwise null.
*/
public static ResultPayload getPayloadFromUriMap(Map<String, PreferenceControllerMixin> uriMap,
String key) {
if (uriMap == null) {
return null;
}
PreferenceControllerMixin controller = uriMap.get(key);
if (controller == null) {
return null;
}
return controller.getResultPayload();
}
public static Class<?> getIndexableClass(String className) {
final Class<?> clazz;
try {
@@ -164,4 +150,4 @@ public class DatabaseIndexingUtils {
}
return null;
}
}
}

View File

@@ -22,6 +22,7 @@ import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import android.os.Build;
import android.provider.SearchIndexablesContract.SiteMapColumns;
import android.support.annotation.VisibleForTesting;
import android.text.TextUtils;
import android.util.Log;
@@ -33,7 +34,7 @@ public class IndexDatabaseHelper extends SQLiteOpenHelper {
private static final String TAG = "IndexDatabaseHelper";
private static final String DATABASE_NAME = "search_index.db";
private static final int DATABASE_VERSION = 117;
private static final int DATABASE_VERSION = 118;
private static final String SHARED_PREFS_TAG = "indexing_manager";
@@ -80,14 +81,6 @@ public class IndexDatabaseHelper extends SQLiteOpenHelper {
String TIME_STAMP = "timestamp";
}
public interface SiteMapColumns {
String DOCID = "docid";
String PARENT_CLASS = "parent_class";
String CHILD_CLASS = "child_class";
String PARENT_TITLE = "parent_title";
String CHILD_TITLE = "child_title";
}
private static final String CREATE_INDEX_TABLE =
"CREATE VIRTUAL TABLE " + Tables.TABLE_PREFS_INDEX + " USING fts4" +
"(" +

View File

@@ -40,16 +40,24 @@ import static android.provider.SearchIndexablesContract.COLUMN_INDEX_XML_RES_RES
import static android.provider.SearchIndexablesContract.INDEXABLES_RAW_COLUMNS;
import static android.provider.SearchIndexablesContract.INDEXABLES_XML_RES_COLUMNS;
import static android.provider.SearchIndexablesContract.NON_INDEXABLES_KEYS_COLUMNS;
import static android.provider.SearchIndexablesContract.SITE_MAP_COLUMNS;
import static com.android.settings.dashboard.DashboardFragmentRegistry.CATEGORY_KEY_TO_PARENT_MAP;
import android.content.Context;
import android.database.Cursor;
import android.database.MatrixCursor;
import android.provider.SearchIndexableResource;
import android.provider.SearchIndexablesContract;
import android.provider.SearchIndexablesProvider;
import android.text.TextUtils;
import android.util.ArraySet;
import android.util.Log;
import com.android.settings.SettingsActivity;
import com.android.settings.overlay.FeatureFactory;
import com.android.settingslib.drawer.DashboardCategory;
import com.android.settingslib.drawer.Tile;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
@@ -134,6 +142,38 @@ public class SettingsSearchIndexablesProvider extends SearchIndexablesProvider {
return cursor;
}
@Override
public Cursor querySiteMapPairs() {
final MatrixCursor cursor = new MatrixCursor(SITE_MAP_COLUMNS);
final Context context = getContext();
// Loop through all IA categories and pages and build additional SiteMapPairs
final List<DashboardCategory> categories = FeatureFactory.getFactory(context)
.getDashboardFeatureProvider(context).getAllCategories();
for (DashboardCategory category : categories) {
// Use the category key to look up parent (which page hosts this key)
final String parentClass = CATEGORY_KEY_TO_PARENT_MAP.get(category.key);
if (parentClass == null) {
continue;
}
// Build parent-child class pairs for all children listed under this key.
for (Tile tile : category.tiles) {
String childClass = null;
if (tile.metaData != null) {
childClass = tile.metaData.getString(
SettingsActivity.META_DATA_KEY_FRAGMENT_CLASS);
}
if (childClass == null) {
continue;
}
cursor.newRow()
.add(SearchIndexablesContract.SiteMapColumns.PARENT_CLASS, parentClass)
.add(SearchIndexablesContract.SiteMapColumns.CHILD_CLASS, childClass);
}
}
// Done.
return cursor;
}
private List<String> getNonIndexableKeysFromProvider(Context context) {
final Collection<Class> values = SearchIndexableResources.providerValues();
final List<String> nonIndexableKeys = new ArrayList<>();

View File

@@ -40,6 +40,7 @@ import org.xmlpull.v1.XmlPullParserException;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
@@ -178,11 +179,11 @@ public class IndexDataConverter {
final String intentTargetPackage = sir.intentTargetPackage;
final String intentTargetClass = sir.intentTargetClass;
Map<String, PreferenceControllerMixin> controllerUriMap = null;
Map<String, ResultPayload> controllerUriMap = new HashMap<>();
if (fragmentName != null) {
controllerUriMap = DatabaseIndexingUtils
.getPreferenceControllerUriMap(fragmentName, context);
.getPayloadKeyMap(fragmentName, context);
}
headerTitle = XmlParserUtils.getDataTitle(context, attrs);
@@ -249,7 +250,7 @@ public class IndexDataConverter {
}
// TODO (b/62254931) index primitives instead of payload
payload = DatabaseIndexingUtils.getPayloadFromUriMap(controllerUriMap, key);
payload = controllerUriMap.get(key);
childFragment = XmlParserUtils.getDataChildFragment(context, attrs);
builder.setSummaryOn(summary)

View File

@@ -15,6 +15,7 @@
-->
<resources>
<bool name="config_tintSettingIcon">false</bool>
<bool name="config_enableColorTemperature">false</bool>
<bool name="config_show_camera_laser_sensor">false</bool>
<bool name="config_show_connectivity_monitor">false</bool>

View File

@@ -50,7 +50,7 @@ import static org.mockito.Mockito.verifyZeroInteractions;
import static org.mockito.Mockito.when;
@RunWith(SettingsRobolectricTestRunner.class)
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class ConnectedDeviceDashboardFragment2Test {
@Mock(answer = Answers.RETURNS_DEEP_STUBS)

View File

@@ -26,7 +26,7 @@ import static org.mockito.Matchers.any;
import static org.mockito.Mockito.when;
@RunWith(SettingsRobolectricTestRunner.class)
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class UsbModePreferenceControllerTest {
@Mock(answer = RETURNS_DEEP_STUBS)

View File

@@ -0,0 +1,120 @@
/*
* Copyright (C) 2017 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.core;
import static com.android.settings.core.BasePreferenceController.AVAILABLE;
import static com.android.settings.core.BasePreferenceController
.DISABLED_DEPENDENT_SETTING;
import static com.android.settings.core.BasePreferenceController.DISABLED_FOR_USER;
import static com.android.settings.core.BasePreferenceController.DISABLED_UNSUPPORTED;
import static com.android.settings.core.BasePreferenceController.UNAVAILABLE_UNKNOWN;
import static com.google.common.truth.Truth.assertThat;
import static org.mockito.Mockito.when;
import com.android.settings.TestConfig;
import com.android.settings.testutils.SettingsRobolectricTestRunner;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import org.robolectric.annotation.Config;
@RunWith(SettingsRobolectricTestRunner.class)
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class BasePreferenceControllerTest {
@Mock
BasePreferenceController mPreferenceController;
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
}
@Test
public void isAvailable_availableStatusAvailable_returnsTrue() {
when(mPreferenceController.getAvailabilityStatus()).thenReturn(AVAILABLE);
assertThat(mPreferenceController.isAvailable()).isTrue();
}
@Test
public void isAvailable_availableStatusUnsupported_returnsFalse() {
when(mPreferenceController.getAvailabilityStatus()).thenReturn(DISABLED_UNSUPPORTED);
assertThat(mPreferenceController.isAvailable()).isFalse();
}
@Test
public void isAvailable_availableStatusDisabled_returnsFalse() {
when(mPreferenceController.getAvailabilityStatus()).thenReturn(DISABLED_FOR_USER);
assertThat(mPreferenceController.isAvailable()).isFalse();
}
@Test
public void isAvailable_availableStatusBlockedDependent_returnsFalse() {
when(mPreferenceController.getAvailabilityStatus()).thenReturn(DISABLED_DEPENDENT_SETTING);
assertThat(mPreferenceController.isAvailable()).isFalse();
}
@Test
public void isAvailable_availableStatusUnavailable_returnsFalse() {
when(mPreferenceController.getAvailabilityStatus()).thenReturn(UNAVAILABLE_UNKNOWN);
assertThat(mPreferenceController.isAvailable()).isFalse();
}
@Test
public void isSupported_availableStatusAvailable_returnsTrue() {
when(mPreferenceController.getAvailabilityStatus()).thenReturn(AVAILABLE);
assertThat(mPreferenceController.isSupported()).isTrue();
}
@Test
public void isSupported_availableStatusUnsupported_returnsFalse() {
when(mPreferenceController.getAvailabilityStatus()).thenReturn(DISABLED_UNSUPPORTED);
assertThat(mPreferenceController.isSupported()).isFalse();
}
@Test
public void isSupported_availableStatusDisabled_returnsTrue() {
when(mPreferenceController.getAvailabilityStatus()).thenReturn(DISABLED_FOR_USER);
assertThat(mPreferenceController.isSupported()).isTrue();
}
@Test
public void isSupported_availableStatusDependentSetting_returnsTrue() {
when(mPreferenceController.getAvailabilityStatus()).thenReturn(DISABLED_DEPENDENT_SETTING);
assertThat(mPreferenceController.isSupported()).isTrue();
}
@Test
public void isSupported_availableStatusUnavailable_returnsTrue() {
when(mPreferenceController.getAvailabilityStatus()).thenReturn(UNAVAILABLE_UNKNOWN);
assertThat(mPreferenceController.isSupported()).isTrue();
}
}

View File

@@ -0,0 +1,92 @@
/*
* Copyright (C) 2017 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.core;
import static com.google.common.truth.Truth.assertThat;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import android.content.Context;
import android.support.v14.preference.SwitchPreference;
import com.android.settings.TestConfig;
import com.android.settings.core.TogglePreferenceController;
import com.android.settings.testutils.SettingsRobolectricTestRunner;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import org.robolectric.RuntimeEnvironment;
import org.robolectric.annotation.Config;
@RunWith(SettingsRobolectricTestRunner.class)
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class TogglePreferenceControllerTest {
@Mock
TogglePreferenceController mTogglePreferenceController;
Context mContext;
SwitchPreference mPreference;
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
mContext = RuntimeEnvironment.application;
mPreference = new SwitchPreference(mContext);
}
@Test
public void testSetsPreferenceValue_setsChecked() {
when(mTogglePreferenceController.isChecked()).thenReturn(true);
mPreference.setChecked(false);
mTogglePreferenceController.updateState(mPreference);
assertThat(mPreference.isChecked()).isTrue();
}
@Test
public void testSetsPreferenceValue_setsNotChecked() {
when(mTogglePreferenceController.isChecked()).thenReturn(false);
mPreference.setChecked(true);
mTogglePreferenceController.updateState(mPreference);
assertThat(mPreference.isChecked()).isFalse();
}
@Test
public void testUpdatesPreferenceOnChange_turnsOn() {
boolean newValue = true;
mTogglePreferenceController.onPreferenceChange(mPreference, newValue);
verify(mTogglePreferenceController).setChecked(newValue);
}
@Test
public void testUpdatesPreferenceOnChange_turnsOff() {
boolean newValue = false;
mTogglePreferenceController.onPreferenceChange(mPreference, newValue);
verify(mTogglePreferenceController).setChecked(newValue);
}
}

View File

@@ -68,7 +68,7 @@ import java.util.List;
@RunWith(SettingsRobolectricTestRunner.class)
@Config(manifest = TestConfig.MANIFEST_PATH,
sdk = TestConfig.SDK_VERSION,
sdk = TestConfig.SDK_VERSION_O,
shadows = {
SettingsShadowResources.class,
SettingsShadowResources.SettingsShadowTheme.class,

View File

@@ -49,7 +49,7 @@ import java.util.List;
import java.util.Objects;
@RunWith(RobolectricTestRunner.class)
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class DashboardDataTest {
private static final String TEST_SUGGESTION_TITLE = "Use fingerprint";
private static final String TEST_CATEGORY_TILE_TITLE = "Display";

View File

@@ -17,10 +17,13 @@
package com.android.settings.dashboard;
import static com.google.common.truth.Truth.assertThat;
import static org.mockito.Matchers.any;
import static org.mockito.Matchers.anyInt;
import static org.mockito.Matchers.eq;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import static org.robolectric.RuntimeEnvironment.application;
@@ -30,7 +33,8 @@ import android.app.Activity;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.res.Resources;
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
import android.graphics.Bitmap;
import android.graphics.drawable.Icon;
import android.os.Bundle;
@@ -60,6 +64,7 @@ import org.mockito.Answers;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import org.robolectric.Robolectric;
import org.robolectric.RuntimeEnvironment;
import org.robolectric.annotation.Config;
import org.robolectric.shadows.ShadowActivity;
import org.robolectric.shadows.ShadowApplication;
@@ -69,7 +74,7 @@ import java.util.ArrayList;
@RunWith(SettingsRobolectricTestRunner.class)
@Config(manifest = TestConfig.MANIFEST_PATH,
sdk = TestConfig.SDK_VERSION,
sdk = TestConfig.SDK_VERSION_O,
shadows = ShadowUserManager.class)
public class DashboardFeatureProviderImplTest {
@@ -79,21 +84,28 @@ public class DashboardFeatureProviderImplTest {
private UserManager mUserManager;
@Mock
private CategoryManager mCategoryManager;
@Mock
private PackageManager mPackageManager;
private FakeFeatureFactory mFeatureFactory;
private Context mContext;
private DashboardFeatureProviderImpl mImpl;
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
mContext = spy(RuntimeEnvironment.application);
doReturn(mPackageManager).when(mContext).getPackageManager();
when(mPackageManager.resolveActivity(any(Intent.class), anyInt())).thenReturn(
new ResolveInfo());
FakeFeatureFactory.setupForTest(mActivity);
mFeatureFactory = (FakeFeatureFactory) FakeFeatureFactory.getFactory(mActivity);
mImpl = new DashboardFeatureProviderImpl(mActivity);
mImpl = new DashboardFeatureProviderImpl(mContext);
}
@Test
public void shouldHoldAppContext() {
assertThat(mImpl.mContext).isEqualTo(mActivity.getApplicationContext());
assertThat(mImpl.mContext).isEqualTo(mContext.getApplicationContext());
}
@Test
@@ -342,7 +354,7 @@ public class DashboardFeatureProviderImplTest {
}
@Test
public void bindPreference_withIntentActionMetatdata_shouldSetLaunchAction() {
public void bindPreference_withIntentActionMetadata_shouldSetLaunchAction() {
Activity activity = Robolectric.buildActivity(Activity.class).get();
final ShadowApplication application = ShadowApplication.getInstance();
final Preference preference = new Preference(application.getApplicationContext());
@@ -437,14 +449,13 @@ public class DashboardFeatureProviderImplTest {
}
@Test
public void testShouldTintIcon_shouldReturnValueFromResource() {
final Resources res = mActivity.getApplicationContext().getResources();
when(res.getBoolean(R.bool.config_tintSettingIcon))
.thenReturn(false);
assertThat(mImpl.shouldTintIcon()).isFalse();
when(res.getBoolean(R.bool.config_tintSettingIcon))
.thenReturn(true);
public void testShouldTintIcon_enabledInResources_shouldBeTrue() {
assertThat(mImpl.shouldTintIcon()).isTrue();
}
@Test
@Config(qualifiers = "mcc999")
public void testShouldTintIcon_disabledInResources_shouldBeFalse() {
assertThat(mImpl.shouldTintIcon()).isFalse();
}
}

View File

@@ -58,7 +58,7 @@ import java.util.ArrayList;
import java.util.List;
@RunWith(SettingsRobolectricTestRunner.class)
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class DashboardFragmentTest {
@Mock(answer = Answers.RETURNS_DEEP_STUBS)

View File

@@ -31,7 +31,7 @@ import org.robolectric.shadows.ShadowApplication;
import static com.google.common.truth.Truth.assertThat;
@RunWith(SettingsRobolectricTestRunner.class)
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class DashboardItemAnimatorTest {
private DashboardItemAnimator mDashboardItemAnimator;

View File

@@ -47,7 +47,7 @@ import static org.mockito.Mockito.when;
@RunWith(SettingsRobolectricTestRunner.class)
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class DashboardSummaryTest {
@Mock

View File

@@ -37,7 +37,7 @@ import static org.mockito.Matchers.anyString;
import static org.mockito.Mockito.when;
@RunWith(SettingsRobolectricTestRunner.class)
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class DashboardTilePlaceholderPreferenceControllerTest {

View File

@@ -41,7 +41,7 @@ import org.robolectric.Robolectric;
import org.robolectric.annotation.Config;
@RunWith(SettingsRobolectricTestRunner.class)
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class SummaryLoaderTest {
private static final String SUMMARY_1 = "summary1";

View File

@@ -49,7 +49,7 @@ import static org.mockito.Mockito.when;
import static org.robolectric.Shadows.shadowOf;
@RunWith(SettingsRobolectricTestRunner.class)
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class SupportItemAdapterTest {
private static final String ACCOUNT_TYPE = "com.google";
private final Account USER_1 = new Account("user1", ACCOUNT_TYPE);

View File

@@ -43,7 +43,7 @@ import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
@RunWith(SettingsRobolectricTestRunner.class)
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class ConditionAdapterTest {
@Mock
private Condition mCondition1;

View File

@@ -41,7 +41,7 @@ import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
@RunWith(SettingsRobolectricTestRunner.class)
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class ConditionTest {
@Mock

View File

@@ -35,7 +35,7 @@ import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
@RunWith(SettingsRobolectricTestRunner.class)
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class DndConditionTest {
@Mock

View File

@@ -29,7 +29,7 @@ import static com.google.common.truth.Truth.assertThat;
import org.robolectric.RuntimeEnvironment;
@RunWith(SettingsRobolectricTestRunner.class)
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class EventStoreTest {
private EventStore mEventStore;

View File

@@ -62,7 +62,7 @@ import java.util.ArrayList;
import java.util.List;
@RunWith(SettingsRobolectricTestRunner.class)
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class SuggestionAdapterTest {
@Mock(answer = Answers.RETURNS_DEEP_STUBS)

View File

@@ -43,7 +43,7 @@ import org.mockito.MockitoAnnotations;
import org.robolectric.annotation.Config;
@RunWith(SettingsRobolectricTestRunner.class)
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION,
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O,
shadows = {
ShadowSuggestionController.class
})

View File

@@ -46,7 +46,7 @@ import org.mockito.MockitoAnnotations;
import org.robolectric.annotation.Config;
@RunWith(SettingsRobolectricTestRunner.class)
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class SuggestionDismissControllerTest {
@Mock(answer = Answers.RETURNS_DEEP_STUBS)

View File

@@ -32,7 +32,7 @@ import static com.google.common.truth.Truth.assertThat;
import org.robolectric.RuntimeEnvironment;
@RunWith(SettingsRobolectricTestRunner.class)
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class SuggestionFeaturizerTest {
private EventStore mEventStore;

View File

@@ -41,7 +41,7 @@ import static org.mockito.Mockito.same;
import static org.mockito.Mockito.spy;
@RunWith(SettingsRobolectricTestRunner.class)
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class SuggestionRankerTest {
@Mock

View File

@@ -38,7 +38,7 @@ import org.robolectric.Robolectric;
import org.robolectric.annotation.Config;
@RunWith(SettingsRobolectricTestRunner.class)
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class SuggestionStateProviderTest {
@Mock(answer = Answers.RETURNS_DEEP_STUBS)

View File

@@ -23,7 +23,7 @@ import org.robolectric.RuntimeEnvironment;
import org.robolectric.annotation.Config;
@RunWith(SettingsRobolectricTestRunner.class)
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class AutomaticStorageManagerDescriptionPreferenceControllerTest {
@Mock private PreferenceScreen mScreen;
@Mock private Preference mPreference;

View File

@@ -51,7 +51,7 @@ import org.robolectric.RuntimeEnvironment;
import org.robolectric.annotation.Config;
@RunWith(SettingsRobolectricTestRunner.class)
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class AutomaticStorageManagerSwitchBarControllerTest {
private Context mContext;
private SwitchBar mSwitchBar;

View File

@@ -46,7 +46,7 @@ import org.robolectric.RuntimeEnvironment;
import org.robolectric.annotation.Config;
@RunWith(SettingsRobolectricTestRunner.class)
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class AbstractBluetoothA2dpPreferenceControllerTest {
@Mock

View File

@@ -41,7 +41,7 @@ import org.robolectric.RuntimeEnvironment;
import org.robolectric.annotation.Config;
@RunWith(SettingsRobolectricTestRunner.class)
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class AdbPreferenceControllerTest {
@Mock

View File

@@ -44,7 +44,7 @@ import org.robolectric.RuntimeEnvironment;
import org.robolectric.annotation.Config;
@RunWith(SettingsRobolectricTestRunner.class)
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class AllowAppsOnExternalPreferenceControllerTest {
@Mock

View File

@@ -44,7 +44,7 @@ import org.robolectric.annotation.Config;
import org.robolectric.util.ReflectionHelpers;
@RunWith(SettingsRobolectricTestRunner.class)
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class AnimatorDurationScalePreferenceControllerTest {
@Mock

View File

@@ -43,7 +43,7 @@ import org.robolectric.RuntimeEnvironment;
import org.robolectric.annotation.Config;
@RunWith(SettingsRobolectricTestRunner.class)
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class AppsNotRespondingPreferenceControllerTest {
@Mock

View File

@@ -40,7 +40,7 @@ import org.robolectric.RuntimeEnvironment;
import org.robolectric.annotation.Config;
@RunWith(SettingsRobolectricTestRunner.class)
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class BackgroundProcessLimitPreferenceControllerTest {
@Mock

View File

@@ -43,7 +43,7 @@ import org.robolectric.annotation.Config;
@RunWith(SettingsRobolectricTestRunner.class)
@Config(manifest = TestConfig.MANIFEST_PATH,
sdk = TestConfig.SDK_VERSION,
sdk = TestConfig.SDK_VERSION_O,
shadows = {SettingsShadowSystemProperties.class})
public class BluetoothAbsoluteVolumePreferenceControllerTest {

View File

@@ -40,7 +40,7 @@ import org.robolectric.RuntimeEnvironment;
import org.robolectric.annotation.Config;
@RunWith(SettingsRobolectricTestRunner.class)
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class BluetoothAudioBitsPerSamplePreferenceControllerTest {
@Mock

View File

@@ -40,7 +40,7 @@ import org.robolectric.RuntimeEnvironment;
import org.robolectric.annotation.Config;
@RunWith(SettingsRobolectricTestRunner.class)
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class BluetoothAudioChannelModePreferenceControllerTest {
@Mock

View File

@@ -40,7 +40,7 @@ import org.robolectric.RuntimeEnvironment;
import org.robolectric.annotation.Config;
@RunWith(SettingsRobolectricTestRunner.class)
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class BluetoothAudioCodecPreferenceControllerTest {
@Mock

View File

@@ -40,7 +40,7 @@ import org.robolectric.RuntimeEnvironment;
import org.robolectric.annotation.Config;
@RunWith(SettingsRobolectricTestRunner.class)
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class BluetoothAudioQualityPreferenceControllerTest {
@Mock

View File

@@ -40,7 +40,7 @@ import org.robolectric.RuntimeEnvironment;
import org.robolectric.annotation.Config;
@RunWith(SettingsRobolectricTestRunner.class)
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class BluetoothAudioSampleRatePreferenceControllerTest {
@Mock

View File

@@ -45,7 +45,7 @@ import org.robolectric.annotation.Config;
@RunWith(SettingsRobolectricTestRunner.class)
@Config(manifest = TestConfig.MANIFEST_PATH,
sdk = TestConfig.SDK_VERSION,
sdk = TestConfig.SDK_VERSION_O,
shadows = {SettingsShadowSystemProperties.class})
public class BluetoothAvrcpVersionPreferenceControllerTest {

View File

@@ -42,7 +42,7 @@ import org.robolectric.annotation.Config;
@RunWith(SettingsRobolectricTestRunner.class)
@Config(manifest = TestConfig.MANIFEST_PATH,
sdk = TestConfig.SDK_VERSION,
sdk = TestConfig.SDK_VERSION_O,
shadows = {SettingsShadowSystemProperties.class})
public class BluetoothDeviceNoNamePreferenceControllerTest {

View File

@@ -45,7 +45,7 @@ import org.robolectric.annotation.Config;
@RunWith(SettingsRobolectricTestRunner.class)
@Config(manifest = TestConfig.MANIFEST_PATH,
sdk = TestConfig.SDK_VERSION,
sdk = TestConfig.SDK_VERSION_O,
shadows = {SettingsShadowSystemProperties.class})
public class BluetoothInbandRingingPreferenceControllerTest {

View File

@@ -41,7 +41,7 @@ import org.robolectric.annotation.Config;
@RunWith(SettingsRobolectricTestRunner.class)
@Config(manifest = TestConfig.MANIFEST_PATH,
sdk = TestConfig.SDK_VERSION,
sdk = TestConfig.SDK_VERSION_O,
shadows = {SettingsShadowSystemProperties.class})
public class BluetoothSnoopLogPreferenceControllerTest {

View File

@@ -51,7 +51,7 @@ import org.robolectric.util.ReflectionHelpers;
@RunWith(SettingsRobolectricTestRunner.class)
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class BugReportInPowerPreferenceControllerTest {
@Mock

View File

@@ -35,7 +35,7 @@ import org.mockito.MockitoAnnotations;
import org.robolectric.annotation.Config;
@RunWith(SettingsRobolectricTestRunner.class)
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class BugReportPreferenceControllerTest {
@Mock

View File

@@ -45,7 +45,7 @@ import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
@RunWith(SettingsRobolectricTestRunner.class)
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION,
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O,
shadows = {SettingsShadowSystemProperties.class})
public class CameraLaserSensorPreferenceControllerTest {

View File

@@ -54,7 +54,7 @@ import org.robolectric.util.ReflectionHelpers;
@RunWith(SettingsRobolectricTestRunner.class)
@Config(manifest = TestConfig.MANIFEST_PATH,
sdk = TestConfig.SDK_VERSION,
sdk = TestConfig.SDK_VERSION_O,
shadows = {SettingsShadowSystemProperties.class, ShadowUtils.class})
public class ClearAdbKeysPreferenceControllerTest {

View File

@@ -43,7 +43,7 @@ import org.robolectric.RuntimeEnvironment;
import org.robolectric.annotation.Config;
@RunWith(SettingsRobolectricTestRunner.class)
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION, shadows =
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O, shadows =
SettingsShadowSystemProperties.class)
public class ConnectivityMonitorPreferenceControllerTest {

View File

@@ -45,7 +45,7 @@ import org.robolectric.annotation.Config;
@RunWith(SettingsRobolectricTestRunner.class)
@Config(manifest = TestConfig.MANIFEST_PATH,
sdk = TestConfig.SDK_VERSION,
sdk = TestConfig.SDK_VERSION_O,
shadows = {SettingsShadowSystemProperties.class})
public class CoolColorTemperaturePreferenceControllerTest {

View File

@@ -43,7 +43,7 @@ import org.robolectric.annotation.Config;
@RunWith(SettingsRobolectricTestRunner.class)
@Config(manifest = TestConfig.MANIFEST_PATH,
sdk = TestConfig.SDK_VERSION,
sdk = TestConfig.SDK_VERSION_O,
shadows = {SettingsShadowSystemProperties.class})
public class DebugGpuOverdrawPreferenceControllerTest {

View File

@@ -43,7 +43,7 @@ import org.robolectric.annotation.Config;
@RunWith(SettingsRobolectricTestRunner.class)
@Config(manifest = TestConfig.MANIFEST_PATH,
sdk = TestConfig.SDK_VERSION,
sdk = TestConfig.SDK_VERSION_O,
shadows = {SettingsShadowSystemProperties.class})
public class DebugNonRectClipOperationsPreferenceControllerTest {

View File

@@ -38,7 +38,7 @@ import org.robolectric.RuntimeEnvironment;
import org.robolectric.annotation.Config;
@RunWith(SettingsRobolectricTestRunner.class)
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class DebugViewAttributesPreferenceControllerTest {
@Mock

View File

@@ -52,7 +52,7 @@ import org.robolectric.util.ReflectionHelpers;
import java.util.List;
@RunWith(SettingsRobolectricTestRunner.class)
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class DevelopmentSettingsDashboardFragmentTest {
private SwitchBar mSwitchBar;

View File

@@ -31,7 +31,7 @@ import org.robolectric.shadows.ShadowToast;
import static com.google.common.truth.Truth.assertThat;
@RunWith(SettingsRobolectricTestRunner.class)
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class DevelopmentSettingsDisabledActivityTest {
@Test

View File

@@ -44,7 +44,7 @@ import org.robolectric.util.ReflectionHelpers;
import java.util.ArrayList;
@RunWith(SettingsRobolectricTestRunner.class)
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION,
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O,
shadows = {
ShadowUtils.class
})

View File

@@ -38,7 +38,7 @@ import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
@RunWith(SettingsRobolectricTestRunner.class)
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class DisableAutomaticUpdatesPreferenceControllerTest {
@Mock

View File

@@ -51,7 +51,7 @@ import org.robolectric.util.ReflectionHelpers;
@RunWith(SettingsRobolectricTestRunner.class)
@Config(manifest = TestConfig.MANIFEST_PATH,
sdk = TestConfig.SDK_VERSION,
sdk = TestConfig.SDK_VERSION_O,
shadows = {SettingsShadowSystemProperties.class})
public class FileEncryptionPreferenceControllerTest {

View File

@@ -43,7 +43,7 @@ import org.robolectric.annotation.Config;
@RunWith(SettingsRobolectricTestRunner.class)
@Config(manifest = TestConfig.MANIFEST_PATH,
sdk = TestConfig.SDK_VERSION,
sdk = TestConfig.SDK_VERSION_O,
shadows = {SettingsShadowSystemProperties.class})
public class ForceGpuRenderingPreferenceControllerTest {

View File

@@ -40,7 +40,7 @@ import org.robolectric.annotation.Config;
@RunWith(SettingsRobolectricTestRunner.class)
@Config(manifest = TestConfig.MANIFEST_PATH,
sdk = TestConfig.SDK_VERSION,
sdk = TestConfig.SDK_VERSION_O,
shadows = {SettingsShadowSystemProperties.class})
public class ForceMSAAPreferenceControllerTest {

View File

@@ -45,7 +45,7 @@ import org.robolectric.RuntimeEnvironment;
import org.robolectric.annotation.Config;
@RunWith(SettingsRobolectricTestRunner.class)
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class FreeformWindowsPreferenceControllerTest {
private static final String ENG_BUILD_TYPE = "eng";

View File

@@ -41,7 +41,7 @@ import org.robolectric.annotation.Config;
@RunWith(SettingsRobolectricTestRunner.class)
@Config(manifest = TestConfig.MANIFEST_PATH,
sdk = TestConfig.SDK_VERSION,
sdk = TestConfig.SDK_VERSION_O,
shadows = {SettingsShadowSystemProperties.class})
public class GpuViewUpdatesPreferenceControllerTest {

View File

@@ -41,7 +41,7 @@ import org.robolectric.annotation.Config;
@RunWith(SettingsRobolectricTestRunner.class)
@Config(manifest = TestConfig.MANIFEST_PATH,
sdk = TestConfig.SDK_VERSION,
sdk = TestConfig.SDK_VERSION_O,
shadows = {SettingsShadowSystemProperties.class})
public class HardwareLayersUpdatesPreferenceControllerTest {

View File

@@ -47,7 +47,7 @@ import org.robolectric.annotation.Config;
import org.robolectric.util.ReflectionHelpers;
@RunWith(SettingsRobolectricTestRunner.class)
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class HardwareOverlaysPreferenceControllerTest {
@Mock

View File

@@ -47,7 +47,7 @@ import org.robolectric.annotation.Config;
@RunWith(SettingsRobolectricTestRunner.class)
@Config(manifest = TestConfig.MANIFEST_PATH,
sdk = TestConfig.SDK_VERSION,
sdk = TestConfig.SDK_VERSION_O,
shadows = {SettingsShadowSystemProperties.class})
public class HdcpCheckingPreferenceControllerTest {

View File

@@ -42,7 +42,7 @@ import org.robolectric.RuntimeEnvironment;
import org.robolectric.annotation.Config;
@RunWith(SettingsRobolectricTestRunner.class)
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class KeepActivitiesPreferenceControllerTest {
private static final int SETTING_VALUE_ON = 1;

View File

@@ -28,7 +28,7 @@ import org.robolectric.annotation.Config;
import org.robolectric.util.ReflectionHelpers;
@RunWith(SettingsRobolectricTestRunner.class)
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class LocalBackupPasswordPreferenceControllerTest {
@Mock

View File

@@ -43,7 +43,7 @@ import org.mockito.MockitoAnnotations;
import org.robolectric.annotation.Config;
@RunWith(SettingsRobolectricTestRunner.class)
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class LocalTerminalPreferenceControllerTest {
@Mock

View File

@@ -40,7 +40,7 @@ import org.robolectric.annotation.Config;
@RunWith(SettingsRobolectricTestRunner.class)
@Config(manifest = TestConfig.MANIFEST_PATH,
sdk = TestConfig.SDK_VERSION,
sdk = TestConfig.SDK_VERSION_O,
shadows = {SettingsShadowSystemProperties.class})
public class LogPersistPreferenceControllerTest {

View File

@@ -39,7 +39,7 @@ import org.robolectric.annotation.Config;
@RunWith(SettingsRobolectricTestRunner.class)
@Config(manifest = TestConfig.MANIFEST_PATH,
sdk = TestConfig.SDK_VERSION,
sdk = TestConfig.SDK_VERSION_O,
shadows = {SettingsShadowSystemProperties.class})
public class LogdSizePreferenceControllerTest {

View File

@@ -41,7 +41,7 @@ import org.robolectric.RuntimeEnvironment;
import org.robolectric.annotation.Config;
@RunWith(SettingsRobolectricTestRunner.class)
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class MemoryUsagePreferenceControllerTest {
@Mock

View File

@@ -38,7 +38,7 @@ import org.robolectric.RuntimeEnvironment;
import org.robolectric.annotation.Config;
@RunWith(SettingsRobolectricTestRunner.class)
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class MobileDataAlwaysOnPreferenceControllerTest {
@Mock

View File

@@ -39,7 +39,7 @@ import org.robolectric.util.ReflectionHelpers;
import java.util.Collections;
@RunWith(SettingsRobolectricTestRunner.class)
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class MockLocationAppPreferenceControllerTest {
@Mock

View File

@@ -41,7 +41,7 @@ import org.robolectric.annotation.Config;
@RunWith(SettingsRobolectricTestRunner.class)
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class NotificationChannelWarningsPreferenceControllerTest {
@Mock

View File

@@ -48,7 +48,7 @@ import org.mockito.MockitoAnnotations;
import org.robolectric.annotation.Config;
@RunWith(SettingsRobolectricTestRunner.class)
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class OemUnlockPreferenceControllerTest {
@Mock
@@ -108,6 +108,7 @@ public class OemUnlockPreferenceControllerTest {
doReturn(false).when(mController).showKeyguardConfirmation(mResources,
REQUEST_CODE_ENABLE_OEM_UNLOCK);
doNothing().when(mController).confirmEnableOemUnlock();
mController.onPreferenceChange(null, true);
verify(mController).confirmEnableOemUnlock();
@@ -115,17 +116,20 @@ public class OemUnlockPreferenceControllerTest {
@Test
public void onPreferenceChanged_turnOffUnlock() {
mController = spy(mController);
mController.onPreferenceChange(null, false);
verify(mOemLockManager).setOemUnlockAllowedByUser(false);
doReturn(false).when(mController).isBootloaderUnlocked();
verify(mFragment).getChildFragmentManager();
}
@Test
public void updateState_preferenceShouldBeCheckedAndShouldBeDisabled() {
mController = spy(mController);
when(mOemLockManager.isOemUnlockAllowed()).thenReturn(true);
doReturn(true).when(mController).isOemUnlockedAllowed();
doReturn(true).when(mController).isOemUnlockAllowedByUserAndCarrier();
when(mOemLockManager.isDeviceOemUnlocked()).thenReturn(true);
doReturn(true).when(mController).isBootloaderUnlocked();
mController.updateState(mPreference);
verify(mPreference).setChecked(true);
@@ -135,9 +139,10 @@ public class OemUnlockPreferenceControllerTest {
@Test
public void updateState_preferenceShouldBeUncheckedAndShouldBeDisabled() {
mController = spy(mController);
when(mOemLockManager.isOemUnlockAllowed()).thenReturn(false);
doReturn(false).when(mController).isOemUnlockedAllowed();
doReturn(true).when(mController).isOemUnlockAllowedByUserAndCarrier();
when(mOemLockManager.isDeviceOemUnlocked()).thenReturn(true);
doReturn(true).when(mController).isBootloaderUnlocked();
mController.updateState(mPreference);
verify(mPreference).setChecked(false);
@@ -147,9 +152,10 @@ public class OemUnlockPreferenceControllerTest {
@Test
public void updateState_preferenceShouldBeCheckedAndShouldBeEnabled() {
mController = spy(mController);
when(mOemLockManager.isOemUnlockAllowed()).thenReturn(true);
doReturn(true).when(mController).isOemUnlockedAllowed();
doReturn(true).when(mController).isOemUnlockAllowedByUserAndCarrier();
when(mOemLockManager.isDeviceOemUnlocked()).thenReturn(false);
doReturn(false).when(mController).isBootloaderUnlocked();
mController.updateState(mPreference);
verify(mPreference).setChecked(true);
@@ -176,7 +182,9 @@ public class OemUnlockPreferenceControllerTest {
public void onDeveloperOptionsEnabled_preferenceShouldCheckRestriction() {
mController = spy(mController);
doReturn(false).when(mController).isOemUnlockAllowedByUserAndCarrier();
doReturn(false).when(mController).isBootloaderUnlocked();
when(mPreference.isEnabled()).thenReturn(true);
mController.onDeveloperOptionsEnabled();
verify(mPreference).checkRestrictionAndSetDisabled(UserManager.DISALLOW_FACTORY_RESET);
@@ -186,8 +194,11 @@ public class OemUnlockPreferenceControllerTest {
@Test
public void onDeveloperOptionsDisabled_preferenceShouldCheckRestriction() {
mController = spy(mController);
doReturn(true).when(mController).isOemUnlockedAllowed();
doReturn(false).when(mController).isOemUnlockAllowedByUserAndCarrier();
doReturn(false).when(mController).isBootloaderUnlocked();
when(mPreference.isEnabled()).thenReturn(true);
mController.onDeveloperOptionsDisabled();
verify(mPreference).checkRestrictionAndSetDisabled(UserManager.DISALLOW_FACTORY_RESET);

View File

@@ -43,7 +43,7 @@ import org.mockito.MockitoAnnotations;
import org.robolectric.annotation.Config;
@RunWith(SettingsRobolectricTestRunner.class)
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class PictureColorModePreferenceControllerTest {
@Mock

View File

@@ -40,7 +40,7 @@ import org.robolectric.RuntimeEnvironment;
import org.robolectric.annotation.Config;
@RunWith(SettingsRobolectricTestRunner.class)
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class PointerLocationPreferenceControllerTest {
@Mock

View File

@@ -43,7 +43,7 @@ import org.robolectric.annotation.Config;
@RunWith(SettingsRobolectricTestRunner.class)
@Config(manifest = TestConfig.MANIFEST_PATH,
sdk = TestConfig.SDK_VERSION,
sdk = TestConfig.SDK_VERSION_O,
shadows = {SettingsShadowSystemProperties.class})
public class ProfileGpuRenderingPreferenceControllerTest {

View File

@@ -39,7 +39,7 @@ import org.robolectric.annotation.Config;
@RunWith(SettingsRobolectricTestRunner.class)
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class ResizableActivityPreferenceControllerTest {
@Mock

View File

@@ -40,7 +40,7 @@ import org.robolectric.RuntimeEnvironment;
import org.robolectric.annotation.Config;
@RunWith(SettingsRobolectricTestRunner.class)
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class RtlLayoutPreferenceControllerTest {
@Mock

View File

@@ -39,7 +39,7 @@ import org.robolectric.RuntimeEnvironment;
import org.robolectric.annotation.Config;
@RunWith(SettingsRobolectricTestRunner.class)
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class SecondaryDisplayPreferenceControllerTest {
@Mock

View File

@@ -48,7 +48,7 @@ import org.robolectric.annotation.Config;
import org.robolectric.util.ReflectionHelpers;
@RunWith(SettingsRobolectricTestRunner.class)
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class SelectDebugAppPreferenceControllerTest {
@Mock

View File

@@ -57,7 +57,7 @@ import org.robolectric.annotation.Config;
@RunWith(SettingsRobolectricTestRunner.class)
@Config(manifest = TestConfig.MANIFEST_PATH,
sdk = TestConfig.SDK_VERSION,
sdk = TestConfig.SDK_VERSION_O,
shadows = {ShadowUtils.class})
public class SelectUsbConfigPreferenceControllerTest {

View File

@@ -43,7 +43,7 @@ import org.robolectric.annotation.Config;
@RunWith(SettingsRobolectricTestRunner.class)
@Config(manifest = TestConfig.MANIFEST_PATH,
sdk = TestConfig.SDK_VERSION,
sdk = TestConfig.SDK_VERSION_O,
shadows = {SettingsShadowSystemProperties.class})
public class SetGpuRendererPreferenceControllerTest {

View File

@@ -40,7 +40,7 @@ import org.robolectric.annotation.Config;
import org.robolectric.util.ReflectionHelpers;
@RunWith(SettingsRobolectricTestRunner.class)
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
public class ShortcutManagerThrottlingPreferenceControllerTest {
@Mock

Some files were not shown because too many files have changed in this diff Show More