Game Driver: rename GUP to Game Driver
Bug: 119221883 Test: make RunSettingsRoboTests Change-Id: Ia7b9e3978ad96436a66843e6b5d1bd1e15f367c9
This commit is contained in:
@@ -10121,27 +10121,27 @@
|
||||
<!-- UI debug setting: ANGLE enabled app has been set [CHAR LIMIT=NONE] -->
|
||||
<string name="angle_enabled_app_set">ANGLE enabled application: <xliff:g id="app_name" example="com.company.app">%1$s</xliff:g></string>
|
||||
|
||||
<!-- Title for Game Update Package dashboard where developers can configure apps to use GUP or not [CHAR LIMIT=50] -->
|
||||
<string name="gup_dashboard_title">Game Update Package Preferences</string>
|
||||
<!-- Summary for Game Update Package dashboard [CHAR LIMIT=50] -->
|
||||
<string name="gup_dashboard_summary">Modify Game Update Package settings</string>
|
||||
<!-- Footer text for Game Update Package dashboard [CHAR LIMIT=NONE] -->
|
||||
<!-- Title for Game Driver dashboard where developers can configure apps to use game driver or not [CHAR LIMIT=50] -->
|
||||
<string name="game_driver_dashboard_title">Game Driver Preferences</string>
|
||||
<!-- Summary for Game Driver dashboard [CHAR LIMIT=50] -->
|
||||
<string name="game_driver_dashboard_summary">Modify Game Driver settings</string>
|
||||
<!-- Footer text for Game Driver dashboard [CHAR LIMIT=NONE] -->
|
||||
<string name="game_driver_footer_text">When Game Driver is turned on, you can pick to use the updated graphics driver for Apps installed on the device.</string>
|
||||
<!-- Title for Game Update Package all apps preference [CHAR LIMIT=50] -->
|
||||
<string name="gup_all_apps_switch_title">Enable for all apps</string>
|
||||
<!-- Title for Game Update Package preference [CHAR LIMIT=50] -->
|
||||
<string name="gup_app_preference_title">Select Graphics Driver</string>
|
||||
<!-- The default value for Game Update Package preference [CHAR LIMIT=50] -->
|
||||
<string name="gup_app_preference_default">Default</string>
|
||||
<!-- The gup value for Game Update Package preference [CHAR LIMIT=50] -->
|
||||
<string name="gup_app_preference_gup">Game Update Package</string>
|
||||
<!-- The system value for Game Update Package preference [CHAR LIMIT=50] -->
|
||||
<string name="gup_app_preference_system">System Graphics Driver</string>
|
||||
<!-- All the values for Game Update Package preference [CHAR LIMIT=50] -->
|
||||
<string-array name="gup_app_preference_values">
|
||||
<item>@string/gup_app_preference_default</item>
|
||||
<item>@string/gup_app_preference_gup</item>
|
||||
<item>@string/gup_app_preference_system</item>
|
||||
<!-- Title for Game Driver all apps preference [CHAR LIMIT=50] -->
|
||||
<string name="game_driver_all_apps_preference_title">Enable for all apps</string>
|
||||
<!-- Title for Game Driver app preference [CHAR LIMIT=50] -->
|
||||
<string name="game_driver_app_preference_title">Select Graphics Driver</string>
|
||||
<!-- The default value for Game Driver app preference [CHAR LIMIT=50] -->
|
||||
<string name="game_driver_app_preference_default">Default</string>
|
||||
<!-- The game driver value for Game Driver app preference [CHAR LIMIT=50] -->
|
||||
<string name="game_driver_app_preference_game_driver">Game Driver</string>
|
||||
<!-- The system value for Game Driver app preference [CHAR LIMIT=50] -->
|
||||
<string name="game_driver_app_preference_system">System Graphics Driver</string>
|
||||
<!-- All the values for Game Driver app preference [CHAR LIMIT=50] -->
|
||||
<string-array name="game_driver_app_preference_values">
|
||||
<item>@string/game_driver_app_preference_default</item>
|
||||
<item>@string/game_driver_app_preference_game_driver</item>
|
||||
<item>@string/game_driver_app_preference_system</item>
|
||||
</string-array>
|
||||
|
||||
<!-- Slices Strings -->
|
||||
|
@@ -194,10 +194,10 @@
|
||||
android:summary="@string/enable_gpu_debug_layers_summary" />
|
||||
|
||||
<Preference
|
||||
android:key="gup_dashboard"
|
||||
android:title="@string/gup_dashboard_title"
|
||||
android:summary="@string/gup_dashboard_summary"
|
||||
android:fragment="com.android.settings.development.gup.GupDashboard"
|
||||
android:key="game_driver_dashboard"
|
||||
android:title="@string/game_driver_dashboard_title"
|
||||
android:summary="@string/game_driver_dashboard_summary"
|
||||
android:fragment="com.android.settings.development.gamedriver.GameDriverDashboard"
|
||||
settings:searchable="false" />
|
||||
|
||||
</PreferenceCategory>
|
||||
|
@@ -18,26 +18,26 @@
|
||||
<PreferenceScreen
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:settings="http://schemas.android.com/apk/res-auto"
|
||||
android:key="gup_settings"
|
||||
android:title="@string/gup_dashboard_title">
|
||||
android:key="game_driver_settings"
|
||||
android:title="@string/game_driver_dashboard_title">
|
||||
|
||||
<SwitchPreference
|
||||
android:key="gup_all_apps_preference"
|
||||
android:title="@string/gup_all_apps_switch_title"
|
||||
settings:controller="com.android.settings.development.gup.GupEnableForAllAppsPreferenceController">
|
||||
android:key="game_driver_all_apps_preference"
|
||||
android:title="@string/game_driver_all_apps_preference_title"
|
||||
settings:controller="com.android.settings.development.gamedriver.GameDriverEnableForAllAppsPreferenceController">
|
||||
</SwitchPreference>
|
||||
|
||||
<PreferenceCategory
|
||||
android:key="gup_category"
|
||||
android:title="@string/gup_app_preference_title"
|
||||
settings:controller="com.android.settings.development.gup.GupPreferenceController">
|
||||
android:key="game_driver_category"
|
||||
android:title="@string/game_driver_app_preference_title"
|
||||
settings:controller="com.android.settings.development.gamedriver.GameDriverAppPreferenceController">
|
||||
</PreferenceCategory>
|
||||
|
||||
<com.android.settingslib.widget.FooterPreference
|
||||
android:key="footer_preference"
|
||||
android:title="@string/game_driver_footer_text"
|
||||
android:selectable="false"
|
||||
settings:controller="com.android.settings.development.gup.GameDriverFooterPreferenceController">
|
||||
settings:controller="com.android.settings.development.gamedriver.GameDriverFooterPreferenceController">
|
||||
</com.android.settingslib.widget.FooterPreference>
|
||||
|
||||
</PreferenceScreen>
|
@@ -14,10 +14,10 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.android.settings.development.gup;
|
||||
package com.android.settings.development.gamedriver;
|
||||
|
||||
import static com.android.settings.development.gup.GupEnableForAllAppsPreferenceController.GUP_DEFAULT;
|
||||
import static com.android.settings.development.gup.GupEnableForAllAppsPreferenceController.GUP_OFF;
|
||||
import static com.android.settings.development.gamedriver.GameDriverEnableForAllAppsPreferenceController.GAME_DRIVER_DEFAULT;
|
||||
import static com.android.settings.development.gamedriver.GameDriverEnableForAllAppsPreferenceController.GAME_DRIVER_OFF;
|
||||
|
||||
import android.content.ContentResolver;
|
||||
import android.content.Context;
|
||||
@@ -53,16 +53,17 @@ import java.util.Set;
|
||||
/**
|
||||
* Controller of all the per App based list preferences.
|
||||
*/
|
||||
public class GupPreferenceController extends BasePreferenceController
|
||||
public class GameDriverAppPreferenceController extends BasePreferenceController
|
||||
implements Preference.OnPreferenceChangeListener,
|
||||
GameDriverContentObserver.OnGameDriverContentChangedListener, LifecycleObserver,
|
||||
OnStart, OnStop {
|
||||
|
||||
private final Context mContext;
|
||||
private final ContentResolver mContentResolver;
|
||||
private final CharSequence[] mEntryList;
|
||||
private final String mPreferenceTitle;
|
||||
private final String mPreferenceDefault;
|
||||
private final String mPreferenceGup;
|
||||
private final String mPreferenceGameDriver;
|
||||
private final String mPreferenceSystem;
|
||||
@VisibleForTesting
|
||||
GameDriverContentObserver mGameDriverContentObserver;
|
||||
@@ -73,7 +74,7 @@ public class GupPreferenceController extends BasePreferenceController
|
||||
|
||||
private PreferenceGroup mPreferenceGroup;
|
||||
|
||||
public GupPreferenceController(Context context, String key) {
|
||||
public GameDriverAppPreferenceController(Context context, String key) {
|
||||
super(context, key);
|
||||
|
||||
mContext = context;
|
||||
@@ -82,28 +83,29 @@ public class GupPreferenceController extends BasePreferenceController
|
||||
new GameDriverContentObserver(new Handler(Looper.getMainLooper()), this);
|
||||
|
||||
final Resources resources = context.getResources();
|
||||
mEntryList = resources.getStringArray(R.array.gup_app_preference_values);
|
||||
mPreferenceTitle = resources.getString(R.string.gup_app_preference_title);
|
||||
mPreferenceDefault = resources.getString(R.string.gup_app_preference_default);
|
||||
mPreferenceGup = resources.getString(R.string.gup_app_preference_gup);
|
||||
mPreferenceSystem = resources.getString(R.string.gup_app_preference_system);
|
||||
mEntryList = resources.getStringArray(R.array.game_driver_app_preference_values);
|
||||
mPreferenceTitle = resources.getString(R.string.game_driver_app_preference_title);
|
||||
mPreferenceDefault = resources.getString(R.string.game_driver_app_preference_default);
|
||||
mPreferenceGameDriver =
|
||||
resources.getString(R.string.game_driver_app_preference_game_driver);
|
||||
mPreferenceSystem = resources.getString(R.string.game_driver_app_preference_system);
|
||||
|
||||
// TODO: Move this task to background if there's potential ANR/Jank.
|
||||
// Update the UI when all the app infos are ready.
|
||||
mAppInfos = getAppInfos(context);
|
||||
|
||||
mDevOptInApps =
|
||||
getGlobalSettingsString(mContentResolver, Settings.Global.GUP_DEV_OPT_IN_APPS);
|
||||
getGlobalSettingsString(mContentResolver, Settings.Global.GAME_DRIVER_OPT_IN_APPS);
|
||||
mDevOptOutApps =
|
||||
getGlobalSettingsString(mContentResolver, Settings.Global.GUP_DEV_OPT_OUT_APPS);
|
||||
getGlobalSettingsString(mContentResolver, Settings.Global.GAME_DRIVER_OPT_OUT_APPS);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getAvailabilityStatus() {
|
||||
return DevelopmentSettingsEnabler.isDevelopmentSettingsEnabled(mContext)
|
||||
&& (Settings.Global.getInt(
|
||||
mContentResolver, Settings.Global.GUP_DEV_ALL_APPS, GUP_DEFAULT)
|
||||
!= GUP_OFF)
|
||||
&& (Settings.Global.getInt(mContentResolver,
|
||||
Settings.Global.GAME_DRIVER_ALL_APPS, GAME_DRIVER_DEFAULT)
|
||||
!= GAME_DRIVER_OFF)
|
||||
? AVAILABLE
|
||||
: CONDITIONALLY_UNAVAILABLE;
|
||||
}
|
||||
@@ -146,7 +148,7 @@ public class GupPreferenceController extends BasePreferenceController
|
||||
if (value.equals(mPreferenceSystem)) {
|
||||
mDevOptInApps.remove(packageName);
|
||||
mDevOptOutApps.add(packageName);
|
||||
} else if (value.equals(mPreferenceGup)) {
|
||||
} else if (value.equals(mPreferenceGameDriver)) {
|
||||
mDevOptInApps.add(packageName);
|
||||
mDevOptOutApps.remove(packageName);
|
||||
} else {
|
||||
@@ -157,10 +159,10 @@ public class GupPreferenceController extends BasePreferenceController
|
||||
listPref.setSummary(value);
|
||||
|
||||
// Push the updated Sets for opt-in and opt-out apps to
|
||||
// corresponding Settings.Global.GUP_DEV_OPT_(IN|OUT)_APPS
|
||||
Settings.Global.putString(mContentResolver, Settings.Global.GUP_DEV_OPT_IN_APPS,
|
||||
// corresponding Settings.Global.GAME_DRIVER_OPT_(IN|OUT)_APPS
|
||||
Settings.Global.putString(mContentResolver, Settings.Global.GAME_DRIVER_OPT_IN_APPS,
|
||||
String.join(",", mDevOptInApps));
|
||||
Settings.Global.putString(mContentResolver, Settings.Global.GUP_DEV_OPT_OUT_APPS,
|
||||
Settings.Global.putString(mContentResolver, Settings.Global.GAME_DRIVER_OPT_OUT_APPS,
|
||||
String.join(",", mDevOptOutApps));
|
||||
|
||||
return true;
|
||||
@@ -230,13 +232,13 @@ public class GupPreferenceController extends BasePreferenceController
|
||||
listPreference.setEntryValues(mEntryList);
|
||||
|
||||
// Initialize preference default and summary with the opt in/out choices
|
||||
// from Settings.Global.GUP_DEV_OPT_(IN|OUT)_APPS
|
||||
// from Settings.Global.GAME_DRIVER_OPT_(IN|OUT)_APPS
|
||||
if (mDevOptOutApps.contains(packageName)) {
|
||||
listPreference.setValue(mPreferenceSystem);
|
||||
listPreference.setSummary(mPreferenceSystem);
|
||||
} else if (mDevOptInApps.contains(packageName)) {
|
||||
listPreference.setValue(mPreferenceGup);
|
||||
listPreference.setSummary(mPreferenceGup);
|
||||
listPreference.setValue(mPreferenceGameDriver);
|
||||
listPreference.setSummary(mPreferenceGameDriver);
|
||||
} else {
|
||||
listPreference.setValue(mPreferenceDefault);
|
||||
listPreference.setSummary(mPreferenceDefault);
|
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.android.settings.development.gup;
|
||||
package com.android.settings.development.gamedriver;
|
||||
|
||||
import android.content.ContentResolver;
|
||||
import android.database.ContentObserver;
|
||||
@@ -27,6 +27,7 @@ import androidx.annotation.VisibleForTesting;
|
||||
* Helper class to observe Game Driver settings global change.
|
||||
*/
|
||||
public class GameDriverContentObserver extends ContentObserver {
|
||||
|
||||
interface OnGameDriverContentChangedListener {
|
||||
void onGameDriverContentChanged();
|
||||
}
|
||||
@@ -47,7 +48,7 @@ public class GameDriverContentObserver extends ContentObserver {
|
||||
|
||||
public void register(ContentResolver contentResolver) {
|
||||
contentResolver.registerContentObserver(
|
||||
Settings.Global.getUriFor(Settings.Global.GUP_DEV_ALL_APPS), false, this);
|
||||
Settings.Global.getUriFor(Settings.Global.GAME_DRIVER_ALL_APPS), false, this);
|
||||
}
|
||||
|
||||
public void unregister(ContentResolver contentResolver) {
|
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.android.settings.development.gup;
|
||||
package com.android.settings.development.gamedriver;
|
||||
|
||||
import android.app.settings.SettingsEnums;
|
||||
import android.content.Context;
|
||||
@@ -38,12 +38,13 @@ import java.util.List;
|
||||
* Dashboard for Game Driver preferences.
|
||||
*/
|
||||
@SearchIndexable
|
||||
public class GupDashboard extends DashboardFragment {
|
||||
private static final String TAG = "GupDashboard";
|
||||
public class GameDriverDashboard extends DashboardFragment {
|
||||
|
||||
private static final String TAG = "GameDriverDashboard";
|
||||
|
||||
@Override
|
||||
public int getMetricsCategory() {
|
||||
return SettingsEnums.SETTINGS_GUP_DASHBOARD;
|
||||
return SettingsEnums.SETTINGS_GAME_DRIVER_DASHBOARD;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -53,7 +54,7 @@ public class GupDashboard extends DashboardFragment {
|
||||
|
||||
@Override
|
||||
protected int getPreferenceScreenResId() {
|
||||
return R.xml.gup_settings;
|
||||
return R.xml.game_driver_settings;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -67,8 +68,9 @@ public class GupDashboard extends DashboardFragment {
|
||||
|
||||
final SettingsActivity activity = (SettingsActivity) getActivity();
|
||||
final SwitchBar switchBar = activity.getSwitchBar();
|
||||
final GupGlobalSwitchBarController switchBarController =
|
||||
new GupGlobalSwitchBarController(activity, new SwitchBarController(switchBar));
|
||||
final GameDriverGlobalSwitchBarController switchBarController =
|
||||
new GameDriverGlobalSwitchBarController(
|
||||
activity, new SwitchBarController(switchBar));
|
||||
getSettingsLifecycle().addObserver(switchBarController);
|
||||
switchBar.show();
|
||||
}
|
||||
@@ -80,7 +82,7 @@ public class GupDashboard extends DashboardFragment {
|
||||
Context context, boolean enabled) {
|
||||
final List<SearchIndexableResource> result = new ArrayList<>();
|
||||
final SearchIndexableResource sir = new SearchIndexableResource(context);
|
||||
sir.xmlResId = R.xml.gup_settings;
|
||||
sir.xmlResId = R.xml.game_driver_settings;
|
||||
result.add(sir);
|
||||
return result;
|
||||
}
|
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.android.settings.development.gup;
|
||||
package com.android.settings.development.gamedriver;
|
||||
|
||||
import android.content.ContentResolver;
|
||||
import android.content.Context;
|
||||
@@ -36,13 +36,14 @@ import com.android.settingslib.development.DevelopmentSettingsEnabler;
|
||||
/**
|
||||
* Controller of global switch to enable Game Driver for all Apps.
|
||||
*/
|
||||
public class GupEnableForAllAppsPreferenceController extends BasePreferenceController
|
||||
public class GameDriverEnableForAllAppsPreferenceController extends BasePreferenceController
|
||||
implements Preference.OnPreferenceChangeListener,
|
||||
GameDriverContentObserver.OnGameDriverContentChangedListener, LifecycleObserver,
|
||||
OnStart, OnStop {
|
||||
public static final int GUP_DEFAULT = 0;
|
||||
public static final int GUP_ALL_APPS = 1;
|
||||
public static final int GUP_OFF = 2;
|
||||
|
||||
public static final int GAME_DRIVER_DEFAULT = 0;
|
||||
public static final int GAME_DRIVER_ALL_APPS = 1;
|
||||
public static final int GAME_DRIVER_OFF = 2;
|
||||
|
||||
private final Context mContext;
|
||||
private final ContentResolver mContentResolver;
|
||||
@@ -51,7 +52,7 @@ public class GupEnableForAllAppsPreferenceController extends BasePreferenceContr
|
||||
|
||||
private SwitchPreference mPreference;
|
||||
|
||||
public GupEnableForAllAppsPreferenceController(Context context, String key) {
|
||||
public GameDriverEnableForAllAppsPreferenceController(Context context, String key) {
|
||||
super(context, key);
|
||||
mContext = context;
|
||||
mContentResolver = context.getContentResolver();
|
||||
@@ -62,9 +63,9 @@ public class GupEnableForAllAppsPreferenceController extends BasePreferenceContr
|
||||
@Override
|
||||
public int getAvailabilityStatus() {
|
||||
return DevelopmentSettingsEnabler.isDevelopmentSettingsEnabled(mContext)
|
||||
&& (Settings.Global.getInt(
|
||||
mContentResolver, Settings.Global.GUP_DEV_ALL_APPS, GUP_DEFAULT)
|
||||
!= GUP_OFF)
|
||||
&& (Settings.Global.getInt(mContentResolver,
|
||||
Settings.Global.GAME_DRIVER_ALL_APPS, GAME_DRIVER_DEFAULT)
|
||||
!= GAME_DRIVER_OFF)
|
||||
? AVAILABLE
|
||||
: CONDITIONALLY_UNAVAILABLE;
|
||||
}
|
||||
@@ -89,15 +90,16 @@ public class GupEnableForAllAppsPreferenceController extends BasePreferenceContr
|
||||
public void updateState(Preference preference) {
|
||||
final SwitchPreference switchPreference = (SwitchPreference) preference;
|
||||
switchPreference.setVisible(isAvailable());
|
||||
switchPreference.setChecked(Settings.Global.getInt(mContentResolver,
|
||||
Settings.Global.GUP_DEV_ALL_APPS, GUP_DEFAULT)
|
||||
== GUP_ALL_APPS);
|
||||
switchPreference.setChecked(
|
||||
Settings.Global.getInt(
|
||||
mContentResolver, Settings.Global.GAME_DRIVER_ALL_APPS, GAME_DRIVER_DEFAULT)
|
||||
== GAME_DRIVER_ALL_APPS);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onPreferenceChange(Preference preference, Object newValue) {
|
||||
Settings.Global.putInt(mContentResolver, Settings.Global.GUP_DEV_ALL_APPS,
|
||||
(boolean) newValue ? GUP_ALL_APPS : GUP_DEFAULT);
|
||||
Settings.Global.putInt(mContentResolver, Settings.Global.GAME_DRIVER_ALL_APPS,
|
||||
(boolean) newValue ? GAME_DRIVER_ALL_APPS : GAME_DRIVER_DEFAULT);
|
||||
|
||||
return true;
|
||||
}
|
@@ -14,10 +14,10 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.android.settings.development.gup;
|
||||
package com.android.settings.development.gamedriver;
|
||||
|
||||
import static com.android.settings.development.gup.GupEnableForAllAppsPreferenceController.GUP_DEFAULT;
|
||||
import static com.android.settings.development.gup.GupEnableForAllAppsPreferenceController.GUP_OFF;
|
||||
import static com.android.settings.development.gamedriver.GameDriverEnableForAllAppsPreferenceController.GAME_DRIVER_DEFAULT;
|
||||
import static com.android.settings.development.gamedriver.GameDriverEnableForAllAppsPreferenceController.GAME_DRIVER_OFF;
|
||||
|
||||
import android.content.ContentResolver;
|
||||
import android.content.Context;
|
||||
@@ -41,6 +41,7 @@ import com.android.settingslib.widget.FooterPreference;
|
||||
public class GameDriverFooterPreferenceController extends BasePreferenceController
|
||||
implements GameDriverContentObserver.OnGameDriverContentChangedListener, LifecycleObserver,
|
||||
OnStart, OnStop {
|
||||
|
||||
private final ContentResolver mContentResolver;
|
||||
@VisibleForTesting
|
||||
GameDriverContentObserver mGameDriverContentObserver;
|
||||
@@ -57,8 +58,8 @@ public class GameDriverFooterPreferenceController extends BasePreferenceControll
|
||||
@Override
|
||||
public int getAvailabilityStatus() {
|
||||
return Settings.Global.getInt(
|
||||
mContentResolver, Settings.Global.GUP_DEV_ALL_APPS, GUP_DEFAULT)
|
||||
== GUP_OFF
|
||||
mContentResolver, Settings.Global.GAME_DRIVER_ALL_APPS, GAME_DRIVER_DEFAULT)
|
||||
== GAME_DRIVER_OFF
|
||||
? AVAILABLE_UNSEARCHABLE
|
||||
: CONDITIONALLY_UNAVAILABLE;
|
||||
}
|
@@ -14,11 +14,11 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.android.settings.development.gup;
|
||||
package com.android.settings.development.gamedriver;
|
||||
|
||||
import static com.android.settings.development.gup.GupEnableForAllAppsPreferenceController.GUP_ALL_APPS;
|
||||
import static com.android.settings.development.gup.GupEnableForAllAppsPreferenceController.GUP_DEFAULT;
|
||||
import static com.android.settings.development.gup.GupEnableForAllAppsPreferenceController.GUP_OFF;
|
||||
import static com.android.settings.development.gamedriver.GameDriverEnableForAllAppsPreferenceController.GAME_DRIVER_ALL_APPS;
|
||||
import static com.android.settings.development.gamedriver.GameDriverEnableForAllAppsPreferenceController.GAME_DRIVER_DEFAULT;
|
||||
import static com.android.settings.development.gamedriver.GameDriverEnableForAllAppsPreferenceController.GAME_DRIVER_OFF;
|
||||
|
||||
import android.content.ContentResolver;
|
||||
import android.content.Context;
|
||||
@@ -37,10 +37,11 @@ import com.android.settingslib.development.DevelopmentSettingsEnabler;
|
||||
/**
|
||||
* Controller of global switch bar used to fully turn off Game Driver.
|
||||
*/
|
||||
public class GupGlobalSwitchBarController
|
||||
public class GameDriverGlobalSwitchBarController
|
||||
implements SwitchWidgetController.OnSwitchChangeListener,
|
||||
GameDriverContentObserver.OnGameDriverContentChangedListener, LifecycleObserver,
|
||||
OnStart, OnStop {
|
||||
|
||||
private final Context mContext;
|
||||
private final ContentResolver mContentResolver;
|
||||
@VisibleForTesting
|
||||
@@ -48,7 +49,8 @@ public class GupGlobalSwitchBarController
|
||||
@VisibleForTesting
|
||||
GameDriverContentObserver mGameDriverContentObserver;
|
||||
|
||||
GupGlobalSwitchBarController(Context context, SwitchWidgetController switchWidgetController) {
|
||||
GameDriverGlobalSwitchBarController(
|
||||
Context context, SwitchWidgetController switchWidgetController) {
|
||||
mContext = context;
|
||||
mContentResolver = context.getContentResolver();
|
||||
mGameDriverContentObserver =
|
||||
@@ -56,9 +58,10 @@ public class GupGlobalSwitchBarController
|
||||
mSwitchWidgetController = switchWidgetController;
|
||||
mSwitchWidgetController.setEnabled(
|
||||
DevelopmentSettingsEnabler.isDevelopmentSettingsEnabled(context));
|
||||
mSwitchWidgetController.setChecked(Settings.Global.getInt(mContentResolver,
|
||||
Settings.Global.GUP_DEV_ALL_APPS, GUP_DEFAULT)
|
||||
!= GUP_OFF);
|
||||
mSwitchWidgetController.setChecked(
|
||||
Settings.Global.getInt(
|
||||
mContentResolver, Settings.Global.GAME_DRIVER_ALL_APPS, GAME_DRIVER_DEFAULT)
|
||||
!= GAME_DRIVER_OFF);
|
||||
mSwitchWidgetController.setListener(this);
|
||||
}
|
||||
|
||||
@@ -77,13 +80,16 @@ public class GupGlobalSwitchBarController
|
||||
@Override
|
||||
public boolean onSwitchToggled(boolean isChecked) {
|
||||
if (!isChecked) {
|
||||
Settings.Global.putInt(mContentResolver, Settings.Global.GUP_DEV_ALL_APPS, GUP_OFF);
|
||||
Settings.Global.putInt(
|
||||
mContentResolver, Settings.Global.GAME_DRIVER_ALL_APPS, GAME_DRIVER_OFF);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (Settings.Global.getInt(mContentResolver, Settings.Global.GUP_DEV_ALL_APPS, GUP_DEFAULT)
|
||||
!= GUP_ALL_APPS) {
|
||||
Settings.Global.putInt(mContentResolver, Settings.Global.GUP_DEV_ALL_APPS, GUP_DEFAULT);
|
||||
if (Settings.Global.getInt(
|
||||
mContentResolver, Settings.Global.GAME_DRIVER_ALL_APPS, GAME_DRIVER_DEFAULT)
|
||||
!= GAME_DRIVER_ALL_APPS) {
|
||||
Settings.Global.putInt(
|
||||
mContentResolver, Settings.Global.GAME_DRIVER_ALL_APPS, GAME_DRIVER_DEFAULT);
|
||||
}
|
||||
|
||||
return true;
|
||||
@@ -91,8 +97,9 @@ public class GupGlobalSwitchBarController
|
||||
|
||||
@Override
|
||||
public void onGameDriverContentChanged() {
|
||||
mSwitchWidgetController.setChecked(Settings.Global.getInt(mContentResolver,
|
||||
Settings.Global.GUP_DEV_ALL_APPS, GUP_DEFAULT)
|
||||
!= GUP_OFF);
|
||||
mSwitchWidgetController.setChecked(
|
||||
Settings.Global.getInt(
|
||||
mContentResolver, Settings.Global.GAME_DRIVER_ALL_APPS, GAME_DRIVER_DEFAULT)
|
||||
!= GAME_DRIVER_OFF);
|
||||
}
|
||||
}
|
@@ -14,12 +14,12 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.android.settings.development.gup;
|
||||
package com.android.settings.development.gamedriver;
|
||||
|
||||
import static com.android.settings.core.BasePreferenceController.AVAILABLE;
|
||||
import static com.android.settings.core.BasePreferenceController.CONDITIONALLY_UNAVAILABLE;
|
||||
import static com.android.settings.development.gup.GupEnableForAllAppsPreferenceController.GUP_DEFAULT;
|
||||
import static com.android.settings.development.gup.GupEnableForAllAppsPreferenceController.GUP_OFF;
|
||||
import static com.android.settings.development.gamedriver.GameDriverEnableForAllAppsPreferenceController.GAME_DRIVER_DEFAULT;
|
||||
import static com.android.settings.development.gamedriver.GameDriverEnableForAllAppsPreferenceController.GAME_DRIVER_OFF;
|
||||
import static com.android.settings.testutils.ApplicationTestUtils.buildInfo;
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
@@ -52,9 +52,10 @@ import org.robolectric.RobolectricTestRunner;
|
||||
import org.robolectric.RuntimeEnvironment;
|
||||
|
||||
@RunWith(RobolectricTestRunner.class)
|
||||
public class GupPreferenceControllerTest {
|
||||
public class GameDriverAppPreferenceControllerTest {
|
||||
|
||||
private static final int DEFAULT = 0;
|
||||
private static final int GUP = 1;
|
||||
private static final int GAME_DRIVER = 1;
|
||||
private static final int SYSTEM = 2;
|
||||
private static final String TEST_APP_NAME = "testApp";
|
||||
private static final String TEST_PKG_NAME = "testPkg";
|
||||
@@ -75,7 +76,7 @@ public class GupPreferenceControllerTest {
|
||||
private PreferenceGroup mGroup;
|
||||
private PreferenceManager mPreferenceManager;
|
||||
private ContentResolver mResolver;
|
||||
private GupPreferenceController mController;
|
||||
private GameDriverAppPreferenceController mController;
|
||||
private CharSequence[] mValueList;
|
||||
private String mDialogTitle;
|
||||
|
||||
@@ -84,15 +85,17 @@ public class GupPreferenceControllerTest {
|
||||
MockitoAnnotations.initMocks(this);
|
||||
mContext = spy(RuntimeEnvironment.application);
|
||||
mResolver = mContext.getContentResolver();
|
||||
mValueList = mContext.getResources().getStringArray(R.array.gup_app_preference_values);
|
||||
mDialogTitle = mContext.getResources().getString(R.string.gup_app_preference_title);
|
||||
mValueList =
|
||||
mContext.getResources().getStringArray(R.array.game_driver_app_preference_values);
|
||||
mDialogTitle = mContext.getResources().getString(R.string.game_driver_app_preference_title);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getAvailability_developmentSettingsEnabledAndGupSettingsOn_available() {
|
||||
public void getAvailability_developmentSettingsEnabledAndGameDriverOn_available() {
|
||||
loadDefaultConfig();
|
||||
Settings.Global.putInt(mResolver, Settings.Global.DEVELOPMENT_SETTINGS_ENABLED, 1);
|
||||
Settings.Global.putInt(mResolver, Settings.Global.GUP_DEV_ALL_APPS, GUP_DEFAULT);
|
||||
Settings.Global.putInt(
|
||||
mResolver, Settings.Global.GAME_DRIVER_ALL_APPS, GAME_DRIVER_DEFAULT);
|
||||
|
||||
assertThat(mController.getAvailabilityStatus()).isEqualTo(AVAILABLE);
|
||||
}
|
||||
@@ -106,9 +109,9 @@ public class GupPreferenceControllerTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getAvailability_gupSettingsOff_conditionallyUnavailable() {
|
||||
public void getAvailability_gameDriverOff_conditionallyUnavailable() {
|
||||
loadDefaultConfig();
|
||||
Settings.Global.putInt(mResolver, Settings.Global.GUP_DEV_ALL_APPS, GUP_OFF);
|
||||
Settings.Global.putInt(mResolver, Settings.Global.GAME_DRIVER_ALL_APPS, GAME_DRIVER_OFF);
|
||||
|
||||
assertThat(mController.getAvailabilityStatus()).isEqualTo(CONDITIONALLY_UNAVAILABLE);
|
||||
}
|
||||
@@ -145,15 +148,16 @@ public class GupPreferenceControllerTest {
|
||||
@Test
|
||||
public void updateState_available_visible() {
|
||||
Settings.Global.putInt(mResolver, Settings.Global.DEVELOPMENT_SETTINGS_ENABLED, 1);
|
||||
Settings.Global.putInt(mResolver, Settings.Global.GUP_DEV_ALL_APPS, GUP_DEFAULT);
|
||||
Settings.Global.putInt(
|
||||
mResolver, Settings.Global.GAME_DRIVER_ALL_APPS, GAME_DRIVER_DEFAULT);
|
||||
loadDefaultConfig();
|
||||
|
||||
assertThat(mGroup.isVisible()).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void updateState_gupSettingsOff_notVisible() {
|
||||
Settings.Global.putInt(mResolver, Settings.Global.GUP_DEV_ALL_APPS, GUP_OFF);
|
||||
public void updateState_gameDriverOff_notVisible() {
|
||||
Settings.Global.putInt(mResolver, Settings.Global.GAME_DRIVER_ALL_APPS, GAME_DRIVER_OFF);
|
||||
loadDefaultConfig();
|
||||
|
||||
assertThat(mGroup.isVisible()).isFalse();
|
||||
@@ -176,7 +180,7 @@ public class GupPreferenceControllerTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void createPreference_configGup_shouldSetGupAttributes() {
|
||||
public void createPreference_configGAME_DRIVER_shouldSetGameDriverAttributes() {
|
||||
loadConfig(TEST_PKG_NAME, "");
|
||||
final ListPreference preference =
|
||||
mController.createListPreference(mContext, TEST_PKG_NAME, TEST_APP_NAME);
|
||||
@@ -186,9 +190,9 @@ public class GupPreferenceControllerTest {
|
||||
assertThat(preference.getDialogTitle()).isEqualTo(mDialogTitle);
|
||||
assertThat(preference.getEntries()).isEqualTo(mValueList);
|
||||
assertThat(preference.getEntryValues()).isEqualTo(mValueList);
|
||||
assertThat(preference.getEntry()).isEqualTo(mValueList[GUP]);
|
||||
assertThat(preference.getValue()).isEqualTo(mValueList[GUP]);
|
||||
assertThat(preference.getSummary()).isEqualTo(mValueList[GUP]);
|
||||
assertThat(preference.getEntry()).isEqualTo(mValueList[GAME_DRIVER]);
|
||||
assertThat(preference.getValue()).isEqualTo(mValueList[GAME_DRIVER]);
|
||||
assertThat(preference.getSummary()).isEqualTo(mValueList[GAME_DRIVER]);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -217,25 +221,25 @@ public class GupPreferenceControllerTest {
|
||||
assertThat(preference.getEntry()).isEqualTo(mValueList[DEFAULT]);
|
||||
assertThat(preference.getValue()).isEqualTo(mValueList[DEFAULT]);
|
||||
assertThat(preference.getSummary()).isEqualTo(mValueList[DEFAULT]);
|
||||
assertThat(Settings.Global.getString(mResolver, Settings.Global.GUP_DEV_OPT_IN_APPS))
|
||||
assertThat(Settings.Global.getString(mResolver, Settings.Global.GAME_DRIVER_OPT_IN_APPS))
|
||||
.isEqualTo("");
|
||||
assertThat(Settings.Global.getString(mResolver, Settings.Global.GUP_DEV_OPT_OUT_APPS))
|
||||
assertThat(Settings.Global.getString(mResolver, Settings.Global.GAME_DRIVER_OPT_OUT_APPS))
|
||||
.isEqualTo("");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void onPreferenceChange_selectGup_shouldUpdateAttributesAndSettingsGlobal() {
|
||||
public void onPreferenceChange_selectGAME_DRIVER_shouldUpdateAttributesAndSettingsGlobal() {
|
||||
loadDefaultConfig();
|
||||
final ListPreference preference =
|
||||
mController.createListPreference(mContext, TEST_PKG_NAME, TEST_APP_NAME);
|
||||
mController.onPreferenceChange(preference, mValueList[GUP]);
|
||||
mController.onPreferenceChange(preference, mValueList[GAME_DRIVER]);
|
||||
|
||||
assertThat(preference.getEntry()).isEqualTo(mValueList[GUP]);
|
||||
assertThat(preference.getValue()).isEqualTo(mValueList[GUP]);
|
||||
assertThat(preference.getSummary()).isEqualTo(mValueList[GUP]);
|
||||
assertThat(Settings.Global.getString(mResolver, Settings.Global.GUP_DEV_OPT_IN_APPS))
|
||||
assertThat(preference.getEntry()).isEqualTo(mValueList[GAME_DRIVER]);
|
||||
assertThat(preference.getValue()).isEqualTo(mValueList[GAME_DRIVER]);
|
||||
assertThat(preference.getSummary()).isEqualTo(mValueList[GAME_DRIVER]);
|
||||
assertThat(Settings.Global.getString(mResolver, Settings.Global.GAME_DRIVER_OPT_IN_APPS))
|
||||
.isEqualTo(TEST_PKG_NAME);
|
||||
assertThat(Settings.Global.getString(mResolver, Settings.Global.GUP_DEV_OPT_OUT_APPS))
|
||||
assertThat(Settings.Global.getString(mResolver, Settings.Global.GAME_DRIVER_OPT_OUT_APPS))
|
||||
.isEqualTo("");
|
||||
}
|
||||
|
||||
@@ -249,9 +253,9 @@ public class GupPreferenceControllerTest {
|
||||
assertThat(preference.getEntry()).isEqualTo(mValueList[SYSTEM]);
|
||||
assertThat(preference.getValue()).isEqualTo(mValueList[SYSTEM]);
|
||||
assertThat(preference.getSummary()).isEqualTo(mValueList[SYSTEM]);
|
||||
assertThat(Settings.Global.getString(mResolver, Settings.Global.GUP_DEV_OPT_IN_APPS))
|
||||
assertThat(Settings.Global.getString(mResolver, Settings.Global.GAME_DRIVER_OPT_IN_APPS))
|
||||
.isEqualTo("");
|
||||
assertThat(Settings.Global.getString(mResolver, Settings.Global.GUP_DEV_OPT_OUT_APPS))
|
||||
assertThat(Settings.Global.getString(mResolver, Settings.Global.GAME_DRIVER_OPT_OUT_APPS))
|
||||
.isEqualTo(TEST_PKG_NAME);
|
||||
}
|
||||
|
||||
@@ -273,10 +277,10 @@ public class GupPreferenceControllerTest {
|
||||
private void loadDefaultConfig() { loadConfig("", ""); }
|
||||
|
||||
private void loadConfig(String optIn, String optOut) {
|
||||
Settings.Global.putString(mResolver, Settings.Global.GUP_DEV_OPT_IN_APPS, optIn);
|
||||
Settings.Global.putString(mResolver, Settings.Global.GUP_DEV_OPT_OUT_APPS, optOut);
|
||||
Settings.Global.putString(mResolver, Settings.Global.GAME_DRIVER_OPT_IN_APPS, optIn);
|
||||
Settings.Global.putString(mResolver, Settings.Global.GAME_DRIVER_OPT_OUT_APPS, optOut);
|
||||
|
||||
mController = new GupPreferenceController(mContext, "testKey");
|
||||
mController = new GameDriverAppPreferenceController(mContext, "testKey");
|
||||
mGroup = spy(new PreferenceCategory(mContext));
|
||||
final PreferenceManager preferenceManager = new PreferenceManager(mContext);
|
||||
when(mGroup.getContext()).thenReturn(mContext);
|
@@ -14,13 +14,14 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.android.settings.development.gup;
|
||||
package com.android.settings.development.gamedriver;
|
||||
|
||||
import static org.mockito.Mockito.spy;
|
||||
import static org.mockito.Mockito.verify;
|
||||
|
||||
import android.content.ContentResolver;
|
||||
import android.provider.Settings;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
@@ -31,6 +32,7 @@ import org.robolectric.RuntimeEnvironment;
|
||||
|
||||
@RunWith(RobolectricTestRunner.class)
|
||||
public class GameDriverContentObserverTest {
|
||||
|
||||
@Mock
|
||||
private ContentResolver mResolver;
|
||||
@Mock
|
||||
@@ -57,7 +59,7 @@ public class GameDriverContentObserverTest {
|
||||
mGameDriverContentObserver.register(mResolver);
|
||||
|
||||
verify(mResolver).registerContentObserver(
|
||||
Settings.Global.getUriFor(Settings.Global.GUP_DEV_ALL_APPS), false,
|
||||
Settings.Global.getUriFor(Settings.Global.GAME_DRIVER_ALL_APPS), false,
|
||||
mGameDriverContentObserver);
|
||||
}
|
||||
|
@@ -14,11 +14,12 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.android.settings.development.gup;
|
||||
package com.android.settings.development.gamedriver;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
import com.android.internal.logging.nano.MetricsProto;
|
||||
import android.app.settings.SettingsEnums;
|
||||
|
||||
import com.android.settings.R;
|
||||
|
||||
import org.junit.Before;
|
||||
@@ -27,12 +28,13 @@ import org.junit.runner.RunWith;
|
||||
import org.robolectric.RobolectricTestRunner;
|
||||
|
||||
@RunWith(RobolectricTestRunner.class)
|
||||
public class GupDashboardTest {
|
||||
private GupDashboard mDashboard;
|
||||
public class GameDriverDashboardTest {
|
||||
|
||||
private GameDriverDashboard mDashboard;
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
mDashboard = new GupDashboard();
|
||||
mDashboard = new GameDriverDashboard();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -41,14 +43,13 @@ public class GupDashboardTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getMetricesCategory_shouldReturnGupDashboard() {
|
||||
public void getMetricesCategory_shouldReturnGameDriverDashboard() {
|
||||
assertThat(mDashboard.getMetricsCategory())
|
||||
.isEqualTo(MetricsProto.MetricsEvent.SETTINGS_GUP_DASHBOARD);
|
||||
.isEqualTo(SettingsEnums.SETTINGS_GAME_DRIVER_DASHBOARD);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getPreferenceScreen_shouldReturnGupSettings() {
|
||||
assertThat(mDashboard.getPreferenceScreenResId())
|
||||
.isEqualTo(R.xml.gup_settings);
|
||||
public void getPreferenceScreen_shouldReturnGameDriverSettings() {
|
||||
assertThat(mDashboard.getPreferenceScreenResId()).isEqualTo(R.xml.game_driver_settings);
|
||||
}
|
||||
}
|
@@ -14,13 +14,13 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.android.settings.development.gup;
|
||||
package com.android.settings.development.gamedriver;
|
||||
|
||||
import static com.android.settings.core.BasePreferenceController.AVAILABLE;
|
||||
import static com.android.settings.core.BasePreferenceController.CONDITIONALLY_UNAVAILABLE;
|
||||
import static com.android.settings.development.gup.GupEnableForAllAppsPreferenceController.GUP_ALL_APPS;
|
||||
import static com.android.settings.development.gup.GupEnableForAllAppsPreferenceController.GUP_DEFAULT;
|
||||
import static com.android.settings.development.gup.GupEnableForAllAppsPreferenceController.GUP_OFF;
|
||||
import static com.android.settings.development.gamedriver.GameDriverEnableForAllAppsPreferenceController.GAME_DRIVER_ALL_APPS;
|
||||
import static com.android.settings.development.gamedriver.GameDriverEnableForAllAppsPreferenceController.GAME_DRIVER_DEFAULT;
|
||||
import static com.android.settings.development.gamedriver.GameDriverEnableForAllAppsPreferenceController.GAME_DRIVER_OFF;
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
import static org.mockito.Mockito.atLeastOnce;
|
||||
@@ -43,7 +43,8 @@ import org.robolectric.RobolectricTestRunner;
|
||||
import org.robolectric.RuntimeEnvironment;
|
||||
|
||||
@RunWith(RobolectricTestRunner.class)
|
||||
public class GupEnableForAllAppsPreferenceControllerTest {
|
||||
public class GameDriverEnableForAllAppsPreferenceControllerTest {
|
||||
|
||||
@Mock
|
||||
private PreferenceScreen mScreen;
|
||||
@Mock
|
||||
@@ -53,14 +54,14 @@ public class GupEnableForAllAppsPreferenceControllerTest {
|
||||
|
||||
private Context mContext;
|
||||
private ContentResolver mResolver;
|
||||
private GupEnableForAllAppsPreferenceController mController;
|
||||
private GameDriverEnableForAllAppsPreferenceController mController;
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
MockitoAnnotations.initMocks(this);
|
||||
mContext = RuntimeEnvironment.application;
|
||||
mResolver = mContext.getContentResolver();
|
||||
mController = new GupEnableForAllAppsPreferenceController(mContext, "testKey");
|
||||
mController = new GameDriverEnableForAllAppsPreferenceController(mContext, "testKey");
|
||||
when(mScreen.findPreference(mController.getPreferenceKey())).thenReturn(mPreference);
|
||||
mController.displayPreference(mScreen);
|
||||
|
||||
@@ -68,8 +69,9 @@ public class GupEnableForAllAppsPreferenceControllerTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getAvailability_developmentSettingsEnabledAndGupSettingsOn_available() {
|
||||
Settings.Global.putInt(mResolver, Settings.Global.GUP_DEV_ALL_APPS, GUP_DEFAULT);
|
||||
public void getAvailability_developmentSettingsEnabledAndGameDriverSettingsOn_available() {
|
||||
Settings.Global.putInt(
|
||||
mResolver, Settings.Global.GAME_DRIVER_ALL_APPS, GAME_DRIVER_DEFAULT);
|
||||
|
||||
assertThat(mController.getAvailabilityStatus()).isEqualTo(AVAILABLE);
|
||||
}
|
||||
@@ -82,15 +84,16 @@ public class GupEnableForAllAppsPreferenceControllerTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getAvailability_gupSettingsOff_conditionallyUnavailable() {
|
||||
Settings.Global.putInt(mResolver, Settings.Global.GUP_DEV_ALL_APPS, GUP_OFF);
|
||||
public void getAvailability_gameDriverOff_conditionallyUnavailable() {
|
||||
Settings.Global.putInt(mResolver, Settings.Global.GAME_DRIVER_ALL_APPS, GAME_DRIVER_OFF);
|
||||
|
||||
assertThat(mController.getAvailabilityStatus()).isEqualTo(CONDITIONALLY_UNAVAILABLE);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void displayPreference_shouldAddSwitchPreference() {
|
||||
Settings.Global.putInt(mResolver, Settings.Global.GUP_DEV_ALL_APPS, GUP_DEFAULT);
|
||||
Settings.Global.putInt(
|
||||
mResolver, Settings.Global.GAME_DRIVER_ALL_APPS, GAME_DRIVER_DEFAULT);
|
||||
mController.updateState(mPreference);
|
||||
|
||||
verify(mPreference).setChecked(false);
|
||||
@@ -113,8 +116,9 @@ public class GupEnableForAllAppsPreferenceControllerTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void updateState_availableAndGupDefault_visibleAndUncheck() {
|
||||
Settings.Global.putInt(mResolver, Settings.Global.GUP_DEV_ALL_APPS, GUP_DEFAULT);
|
||||
public void updateState_availableAndGameDriverDefault_visibleAndUncheck() {
|
||||
Settings.Global.putInt(
|
||||
mResolver, Settings.Global.GAME_DRIVER_ALL_APPS, GAME_DRIVER_DEFAULT);
|
||||
mController.updateState(mPreference);
|
||||
|
||||
verify(mPreference, atLeastOnce()).setVisible(true);
|
||||
@@ -122,8 +126,9 @@ public class GupEnableForAllAppsPreferenceControllerTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void updateState_availableAndGupAllApps_visibleAndCheck() {
|
||||
Settings.Global.putInt(mResolver, Settings.Global.GUP_DEV_ALL_APPS, GUP_ALL_APPS);
|
||||
public void updateState_availableAndGameDriverAllApps_visibleAndCheck() {
|
||||
Settings.Global.putInt(
|
||||
mResolver, Settings.Global.GAME_DRIVER_ALL_APPS, GAME_DRIVER_ALL_APPS);
|
||||
mController.updateState(mPreference);
|
||||
|
||||
verify(mPreference, atLeastOnce()).setVisible(true);
|
||||
@@ -131,8 +136,8 @@ public class GupEnableForAllAppsPreferenceControllerTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void updateState_gupSettingsOff_notVisibleAndUncheck() {
|
||||
Settings.Global.putInt(mResolver, Settings.Global.GUP_DEV_ALL_APPS, GUP_OFF);
|
||||
public void updateState_gameDriverOff_notVisibleAndUncheck() {
|
||||
Settings.Global.putInt(mResolver, Settings.Global.GAME_DRIVER_ALL_APPS, GAME_DRIVER_OFF);
|
||||
mController.updateState(mPreference);
|
||||
|
||||
verify(mPreference).setVisible(false);
|
||||
@@ -141,19 +146,23 @@ public class GupEnableForAllAppsPreferenceControllerTest {
|
||||
|
||||
@Test
|
||||
public void onPreferenceChange_check_shouldUpdateSettingsGlobal() {
|
||||
Settings.Global.putInt(mResolver, Settings.Global.GUP_DEV_ALL_APPS, GUP_DEFAULT);
|
||||
Settings.Global.putInt(
|
||||
mResolver, Settings.Global.GAME_DRIVER_ALL_APPS, GAME_DRIVER_DEFAULT);
|
||||
mController.onPreferenceChange(mPreference, true);
|
||||
|
||||
assertThat(Settings.Global.getInt(mResolver, Settings.Global.GUP_DEV_ALL_APPS, GUP_DEFAULT))
|
||||
.isEqualTo(GUP_ALL_APPS);
|
||||
assertThat(Settings.Global.getInt(
|
||||
mResolver, Settings.Global.GAME_DRIVER_ALL_APPS, GAME_DRIVER_DEFAULT))
|
||||
.isEqualTo(GAME_DRIVER_ALL_APPS);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void onPreferenceChange_uncheck_shouldUpdateSettingsGlobal() {
|
||||
Settings.Global.putInt(mResolver, Settings.Global.GUP_DEV_ALL_APPS, GUP_ALL_APPS);
|
||||
Settings.Global.putInt(
|
||||
mResolver, Settings.Global.GAME_DRIVER_ALL_APPS, GAME_DRIVER_ALL_APPS);
|
||||
mController.onPreferenceChange(mPreference, false);
|
||||
|
||||
assertThat(Settings.Global.getInt(mResolver, Settings.Global.GUP_DEV_ALL_APPS, GUP_DEFAULT))
|
||||
.isEqualTo(GUP_DEFAULT);
|
||||
assertThat(Settings.Global.getInt(
|
||||
mResolver, Settings.Global.GAME_DRIVER_ALL_APPS, GAME_DRIVER_DEFAULT))
|
||||
.isEqualTo(GAME_DRIVER_DEFAULT);
|
||||
}
|
||||
}
|
@@ -14,13 +14,13 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.android.settings.development.gup;
|
||||
package com.android.settings.development.gamedriver;
|
||||
|
||||
import static com.android.settings.core.BasePreferenceController.AVAILABLE_UNSEARCHABLE;
|
||||
import static com.android.settings.core.BasePreferenceController.CONDITIONALLY_UNAVAILABLE;
|
||||
import static com.android.settings.development.gup.GupEnableForAllAppsPreferenceController.GUP_ALL_APPS;
|
||||
import static com.android.settings.development.gup.GupEnableForAllAppsPreferenceController.GUP_DEFAULT;
|
||||
import static com.android.settings.development.gup.GupEnableForAllAppsPreferenceController.GUP_OFF;
|
||||
import static com.android.settings.development.gamedriver.GameDriverEnableForAllAppsPreferenceController.GAME_DRIVER_ALL_APPS;
|
||||
import static com.android.settings.development.gamedriver.GameDriverEnableForAllAppsPreferenceController.GAME_DRIVER_DEFAULT;
|
||||
import static com.android.settings.development.gamedriver.GameDriverEnableForAllAppsPreferenceController.GAME_DRIVER_OFF;
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
import static org.mockito.Mockito.spy;
|
||||
@@ -45,6 +45,7 @@ import org.robolectric.RuntimeEnvironment;
|
||||
|
||||
@RunWith(RobolectricTestRunner.class)
|
||||
public class GameDriverFooterPreferenceControllerTest {
|
||||
|
||||
@Mock
|
||||
private PreferenceScreen mScreen;
|
||||
@Mock
|
||||
@@ -67,21 +68,23 @@ public class GameDriverFooterPreferenceControllerTest {
|
||||
|
||||
@Test
|
||||
public void getAvailabilityStatus_gameDriverOff_availableUnsearchable() {
|
||||
Settings.Global.putInt(mResolver, Settings.Global.GUP_DEV_ALL_APPS, GUP_OFF);
|
||||
Settings.Global.putInt(mResolver, Settings.Global.GAME_DRIVER_ALL_APPS, GAME_DRIVER_OFF);
|
||||
|
||||
assertThat(mController.getAvailabilityStatus()).isEqualTo(AVAILABLE_UNSEARCHABLE);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getAvailabilityStatus_gameDriverDefault_conditionallyUnavailable() {
|
||||
Settings.Global.putInt(mResolver, Settings.Global.GUP_DEV_ALL_APPS, GUP_DEFAULT);
|
||||
Settings.Global.putInt(
|
||||
mResolver, Settings.Global.GAME_DRIVER_ALL_APPS, GAME_DRIVER_DEFAULT);
|
||||
|
||||
assertThat(mController.getAvailabilityStatus()).isEqualTo(CONDITIONALLY_UNAVAILABLE);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getAvailabilityStatus_gameDriverAllApps_conditionallyUnavailable() {
|
||||
Settings.Global.putInt(mResolver, Settings.Global.GUP_DEV_ALL_APPS, GUP_ALL_APPS);
|
||||
Settings.Global.putInt(
|
||||
mResolver, Settings.Global.GAME_DRIVER_ALL_APPS, GAME_DRIVER_ALL_APPS);
|
||||
|
||||
assertThat(mController.getAvailabilityStatus()).isEqualTo(CONDITIONALLY_UNAVAILABLE);
|
||||
}
|
@@ -14,10 +14,10 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.android.settings.development.gup;
|
||||
package com.android.settings.development.gamedriver;
|
||||
|
||||
import static com.android.settings.development.gup.GupEnableForAllAppsPreferenceController.GUP_DEFAULT;
|
||||
import static com.android.settings.development.gup.GupEnableForAllAppsPreferenceController.GUP_OFF;
|
||||
import static com.android.settings.development.gamedriver.GameDriverEnableForAllAppsPreferenceController.GAME_DRIVER_DEFAULT;
|
||||
import static com.android.settings.development.gamedriver.GameDriverEnableForAllAppsPreferenceController.GAME_DRIVER_OFF;
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
import static org.mockito.Mockito.verify;
|
||||
@@ -39,7 +39,8 @@ import org.robolectric.RobolectricTestRunner;
|
||||
import org.robolectric.RuntimeEnvironment;
|
||||
|
||||
@RunWith(RobolectricTestRunner.class)
|
||||
public class GupGlobalSwitchBarControllerTest {
|
||||
public class GameDriverGlobalSwitchBarControllerTest {
|
||||
|
||||
@Mock
|
||||
private SwitchBar mSwitchBar;
|
||||
@Mock
|
||||
@@ -49,7 +50,7 @@ public class GupGlobalSwitchBarControllerTest {
|
||||
|
||||
private Context mContext;
|
||||
private ContentResolver mResolver;
|
||||
private GupGlobalSwitchBarController mController;
|
||||
private GameDriverGlobalSwitchBarController mController;
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
@@ -59,19 +60,20 @@ public class GupGlobalSwitchBarControllerTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void constructor_gupOn_shouldCheckSwitchBar() {
|
||||
Settings.Global.putInt(mResolver, Settings.Global.GUP_DEV_ALL_APPS, GUP_DEFAULT);
|
||||
mController =
|
||||
new GupGlobalSwitchBarController(mContext, new SwitchBarController(mSwitchBar));
|
||||
public void constructor_gameDriverOn_shouldCheckSwitchBar() {
|
||||
Settings.Global.putInt(
|
||||
mResolver, Settings.Global.GAME_DRIVER_ALL_APPS, GAME_DRIVER_DEFAULT);
|
||||
mController = new GameDriverGlobalSwitchBarController(
|
||||
mContext, new SwitchBarController(mSwitchBar));
|
||||
|
||||
verify(mSwitchBar).setChecked(true);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void constructor_gupOff_shouldUncheckSwitchBar() {
|
||||
Settings.Global.putInt(mResolver, Settings.Global.GUP_DEV_ALL_APPS, GUP_OFF);
|
||||
mController =
|
||||
new GupGlobalSwitchBarController(mContext, new SwitchBarController(mSwitchBar));
|
||||
public void constructor_gameDriverOff_shouldUncheckSwitchBar() {
|
||||
Settings.Global.putInt(mResolver, Settings.Global.GAME_DRIVER_ALL_APPS, GAME_DRIVER_OFF);
|
||||
mController = new GameDriverGlobalSwitchBarController(
|
||||
mContext, new SwitchBarController(mSwitchBar));
|
||||
|
||||
verify(mSwitchBar).setChecked(false);
|
||||
}
|
||||
@@ -79,8 +81,8 @@ public class GupGlobalSwitchBarControllerTest {
|
||||
@Test
|
||||
public void constructor_developmentSettingsEnabled_shouldEnableSwitchBar() {
|
||||
Settings.Global.putInt(mResolver, Settings.Global.DEVELOPMENT_SETTINGS_ENABLED, 1);
|
||||
mController =
|
||||
new GupGlobalSwitchBarController(mContext, new SwitchBarController(mSwitchBar));
|
||||
mController = new GameDriverGlobalSwitchBarController(
|
||||
mContext, new SwitchBarController(mSwitchBar));
|
||||
|
||||
verify(mSwitchBar).setEnabled(true);
|
||||
}
|
||||
@@ -88,16 +90,16 @@ public class GupGlobalSwitchBarControllerTest {
|
||||
@Test
|
||||
public void constructor_developmentSettingsDisabled_shouldDisableSwitchBar() {
|
||||
Settings.Global.putInt(mResolver, Settings.Global.DEVELOPMENT_SETTINGS_ENABLED, 0);
|
||||
mController =
|
||||
new GupGlobalSwitchBarController(mContext, new SwitchBarController(mSwitchBar));
|
||||
mController = new GameDriverGlobalSwitchBarController(
|
||||
mContext, new SwitchBarController(mSwitchBar));
|
||||
|
||||
verify(mSwitchBar).setEnabled(false);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void onStart_shouldStartListeningAndRegister() {
|
||||
mController =
|
||||
new GupGlobalSwitchBarController(mContext, new SwitchBarController(mSwitchBar));
|
||||
mController = new GameDriverGlobalSwitchBarController(
|
||||
mContext, new SwitchBarController(mSwitchBar));
|
||||
mController.mSwitchWidgetController = mSwitchWidgetController;
|
||||
mController.mGameDriverContentObserver = mGameDriverContentObserver;
|
||||
mController.onStart();
|
||||
@@ -108,8 +110,8 @@ public class GupGlobalSwitchBarControllerTest {
|
||||
|
||||
@Test
|
||||
public void onStop_shouldStopListeningAndUnregister() {
|
||||
mController =
|
||||
new GupGlobalSwitchBarController(mContext, new SwitchBarController(mSwitchBar));
|
||||
mController = new GameDriverGlobalSwitchBarController(
|
||||
mContext, new SwitchBarController(mSwitchBar));
|
||||
mController.mSwitchWidgetController = mSwitchWidgetController;
|
||||
mController.mGameDriverContentObserver = mGameDriverContentObserver;
|
||||
mController.onStop();
|
||||
@@ -119,24 +121,27 @@ public class GupGlobalSwitchBarControllerTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void onSwitchToggled_checked_shouldTurnOnGup() {
|
||||
Settings.Global.putInt(mResolver, Settings.Global.GUP_DEV_ALL_APPS, GUP_OFF);
|
||||
mController =
|
||||
new GupGlobalSwitchBarController(mContext, new SwitchBarController(mSwitchBar));
|
||||
public void onSwitchToggled_checked_shouldTurnOnGameDriver() {
|
||||
Settings.Global.putInt(mResolver, Settings.Global.GAME_DRIVER_ALL_APPS, GAME_DRIVER_OFF);
|
||||
mController = new GameDriverGlobalSwitchBarController(
|
||||
mContext, new SwitchBarController(mSwitchBar));
|
||||
mController.onSwitchToggled(true);
|
||||
|
||||
assertThat(Settings.Global.getInt(mResolver, Settings.Global.GUP_DEV_ALL_APPS, GUP_DEFAULT))
|
||||
.isEqualTo(GUP_DEFAULT);
|
||||
assertThat(Settings.Global.getInt(
|
||||
mResolver, Settings.Global.GAME_DRIVER_ALL_APPS, GAME_DRIVER_DEFAULT))
|
||||
.isEqualTo(GAME_DRIVER_DEFAULT);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void onSwitchToggled_unchecked_shouldTurnOffGup() {
|
||||
Settings.Global.putInt(mResolver, Settings.Global.GUP_DEV_ALL_APPS, GUP_DEFAULT);
|
||||
mController =
|
||||
new GupGlobalSwitchBarController(mContext, new SwitchBarController(mSwitchBar));
|
||||
public void onSwitchToggled_unchecked_shouldTurnOffGameDriver() {
|
||||
Settings.Global.putInt(
|
||||
mResolver, Settings.Global.GAME_DRIVER_ALL_APPS, GAME_DRIVER_DEFAULT);
|
||||
mController = new GameDriverGlobalSwitchBarController(
|
||||
mContext, new SwitchBarController(mSwitchBar));
|
||||
mController.onSwitchToggled(false);
|
||||
|
||||
assertThat(Settings.Global.getInt(mResolver, Settings.Global.GUP_DEV_ALL_APPS, GUP_DEFAULT))
|
||||
.isEqualTo(GUP_OFF);
|
||||
assertThat(Settings.Global.getInt(
|
||||
mResolver, Settings.Global.GAME_DRIVER_ALL_APPS, GAME_DRIVER_DEFAULT))
|
||||
.isEqualTo(GAME_DRIVER_OFF);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user