Game Driver: rename GUP to Game Driver

Bug: 119221883
Test: make RunSettingsRoboTests
Change-Id: Ia7b9e3978ad96436a66843e6b5d1bd1e15f367c9
This commit is contained in:
Yiwei Zhang
2019-01-24 14:04:58 -08:00
parent 8aa568f1f5
commit bf854fc41b
15 changed files with 249 additions and 210 deletions

View File

@@ -10121,27 +10121,27 @@
<!-- UI debug setting: ANGLE enabled app has been set [CHAR LIMIT=NONE] --> <!-- 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> <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] --> <!-- Title for Game Driver dashboard where developers can configure apps to use game driver or not [CHAR LIMIT=50] -->
<string name="gup_dashboard_title">Game Update Package Preferences</string> <string name="game_driver_dashboard_title">Game Driver Preferences</string>
<!-- Summary for Game Update Package dashboard [CHAR LIMIT=50] --> <!-- Summary for Game Driver dashboard [CHAR LIMIT=50] -->
<string name="gup_dashboard_summary">Modify Game Update Package settings</string> <string name="game_driver_dashboard_summary">Modify Game Driver settings</string>
<!-- Footer text for Game Update Package dashboard [CHAR LIMIT=NONE] --> <!-- 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> <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] --> <!-- Title for Game Driver all apps preference [CHAR LIMIT=50] -->
<string name="gup_all_apps_switch_title">Enable for all apps</string> <string name="game_driver_all_apps_preference_title">Enable for all apps</string>
<!-- Title for Game Update Package preference [CHAR LIMIT=50] --> <!-- Title for Game Driver app preference [CHAR LIMIT=50] -->
<string name="gup_app_preference_title">Select Graphics Driver</string> <string name="game_driver_app_preference_title">Select Graphics Driver</string>
<!-- The default value for Game Update Package preference [CHAR LIMIT=50] --> <!-- The default value for Game Driver app preference [CHAR LIMIT=50] -->
<string name="gup_app_preference_default">Default</string> <string name="game_driver_app_preference_default">Default</string>
<!-- The gup value for Game Update Package preference [CHAR LIMIT=50] --> <!-- The game driver value for Game Driver app preference [CHAR LIMIT=50] -->
<string name="gup_app_preference_gup">Game Update Package</string> <string name="game_driver_app_preference_game_driver">Game Driver</string>
<!-- The system value for Game Update Package preference [CHAR LIMIT=50] --> <!-- The system value for Game Driver app preference [CHAR LIMIT=50] -->
<string name="gup_app_preference_system">System Graphics Driver</string> <string name="game_driver_app_preference_system">System Graphics Driver</string>
<!-- All the values for Game Update Package preference [CHAR LIMIT=50] --> <!-- All the values for Game Driver app preference [CHAR LIMIT=50] -->
<string-array name="gup_app_preference_values"> <string-array name="game_driver_app_preference_values">
<item>@string/gup_app_preference_default</item> <item>@string/game_driver_app_preference_default</item>
<item>@string/gup_app_preference_gup</item> <item>@string/game_driver_app_preference_game_driver</item>
<item>@string/gup_app_preference_system</item> <item>@string/game_driver_app_preference_system</item>
</string-array> </string-array>
<!-- Slices Strings --> <!-- Slices Strings -->

View File

@@ -194,10 +194,10 @@
android:summary="@string/enable_gpu_debug_layers_summary" /> android:summary="@string/enable_gpu_debug_layers_summary" />
<Preference <Preference
android:key="gup_dashboard" android:key="game_driver_dashboard"
android:title="@string/gup_dashboard_title" android:title="@string/game_driver_dashboard_title"
android:summary="@string/gup_dashboard_summary" android:summary="@string/game_driver_dashboard_summary"
android:fragment="com.android.settings.development.gup.GupDashboard" android:fragment="com.android.settings.development.gamedriver.GameDriverDashboard"
settings:searchable="false" /> settings:searchable="false" />
</PreferenceCategory> </PreferenceCategory>

View File

@@ -18,26 +18,26 @@
<PreferenceScreen <PreferenceScreen
xmlns:android="http://schemas.android.com/apk/res/android" xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:settings="http://schemas.android.com/apk/res-auto" xmlns:settings="http://schemas.android.com/apk/res-auto"
android:key="gup_settings" android:key="game_driver_settings"
android:title="@string/gup_dashboard_title"> android:title="@string/game_driver_dashboard_title">
<SwitchPreference <SwitchPreference
android:key="gup_all_apps_preference" android:key="game_driver_all_apps_preference"
android:title="@string/gup_all_apps_switch_title" android:title="@string/game_driver_all_apps_preference_title"
settings:controller="com.android.settings.development.gup.GupEnableForAllAppsPreferenceController"> settings:controller="com.android.settings.development.gamedriver.GameDriverEnableForAllAppsPreferenceController">
</SwitchPreference> </SwitchPreference>
<PreferenceCategory <PreferenceCategory
android:key="gup_category" android:key="game_driver_category"
android:title="@string/gup_app_preference_title" android:title="@string/game_driver_app_preference_title"
settings:controller="com.android.settings.development.gup.GupPreferenceController"> settings:controller="com.android.settings.development.gamedriver.GameDriverAppPreferenceController">
</PreferenceCategory> </PreferenceCategory>
<com.android.settingslib.widget.FooterPreference <com.android.settingslib.widget.FooterPreference
android:key="footer_preference" android:key="footer_preference"
android:title="@string/game_driver_footer_text" android:title="@string/game_driver_footer_text"
android:selectable="false" android:selectable="false"
settings:controller="com.android.settings.development.gup.GameDriverFooterPreferenceController"> settings:controller="com.android.settings.development.gamedriver.GameDriverFooterPreferenceController">
</com.android.settingslib.widget.FooterPreference> </com.android.settingslib.widget.FooterPreference>
</PreferenceScreen> </PreferenceScreen>

View File

@@ -14,10 +14,10 @@
* limitations under the License. * 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.gamedriver.GameDriverEnableForAllAppsPreferenceController.GAME_DRIVER_DEFAULT;
import static com.android.settings.development.gup.GupEnableForAllAppsPreferenceController.GUP_OFF; import static com.android.settings.development.gamedriver.GameDriverEnableForAllAppsPreferenceController.GAME_DRIVER_OFF;
import android.content.ContentResolver; import android.content.ContentResolver;
import android.content.Context; import android.content.Context;
@@ -53,16 +53,17 @@ import java.util.Set;
/** /**
* Controller of all the per App based list preferences. * Controller of all the per App based list preferences.
*/ */
public class GupPreferenceController extends BasePreferenceController public class GameDriverAppPreferenceController extends BasePreferenceController
implements Preference.OnPreferenceChangeListener, implements Preference.OnPreferenceChangeListener,
GameDriverContentObserver.OnGameDriverContentChangedListener, LifecycleObserver, GameDriverContentObserver.OnGameDriverContentChangedListener, LifecycleObserver,
OnStart, OnStop { OnStart, OnStop {
private final Context mContext; private final Context mContext;
private final ContentResolver mContentResolver; private final ContentResolver mContentResolver;
private final CharSequence[] mEntryList; private final CharSequence[] mEntryList;
private final String mPreferenceTitle; private final String mPreferenceTitle;
private final String mPreferenceDefault; private final String mPreferenceDefault;
private final String mPreferenceGup; private final String mPreferenceGameDriver;
private final String mPreferenceSystem; private final String mPreferenceSystem;
@VisibleForTesting @VisibleForTesting
GameDriverContentObserver mGameDriverContentObserver; GameDriverContentObserver mGameDriverContentObserver;
@@ -73,7 +74,7 @@ public class GupPreferenceController extends BasePreferenceController
private PreferenceGroup mPreferenceGroup; private PreferenceGroup mPreferenceGroup;
public GupPreferenceController(Context context, String key) { public GameDriverAppPreferenceController(Context context, String key) {
super(context, key); super(context, key);
mContext = context; mContext = context;
@@ -82,28 +83,29 @@ public class GupPreferenceController extends BasePreferenceController
new GameDriverContentObserver(new Handler(Looper.getMainLooper()), this); new GameDriverContentObserver(new Handler(Looper.getMainLooper()), this);
final Resources resources = context.getResources(); final Resources resources = context.getResources();
mEntryList = resources.getStringArray(R.array.gup_app_preference_values); mEntryList = resources.getStringArray(R.array.game_driver_app_preference_values);
mPreferenceTitle = resources.getString(R.string.gup_app_preference_title); mPreferenceTitle = resources.getString(R.string.game_driver_app_preference_title);
mPreferenceDefault = resources.getString(R.string.gup_app_preference_default); mPreferenceDefault = resources.getString(R.string.game_driver_app_preference_default);
mPreferenceGup = resources.getString(R.string.gup_app_preference_gup); mPreferenceGameDriver =
mPreferenceSystem = resources.getString(R.string.gup_app_preference_system); 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. // TODO: Move this task to background if there's potential ANR/Jank.
// Update the UI when all the app infos are ready. // Update the UI when all the app infos are ready.
mAppInfos = getAppInfos(context); mAppInfos = getAppInfos(context);
mDevOptInApps = mDevOptInApps =
getGlobalSettingsString(mContentResolver, Settings.Global.GUP_DEV_OPT_IN_APPS); getGlobalSettingsString(mContentResolver, Settings.Global.GAME_DRIVER_OPT_IN_APPS);
mDevOptOutApps = mDevOptOutApps =
getGlobalSettingsString(mContentResolver, Settings.Global.GUP_DEV_OPT_OUT_APPS); getGlobalSettingsString(mContentResolver, Settings.Global.GAME_DRIVER_OPT_OUT_APPS);
} }
@Override @Override
public int getAvailabilityStatus() { public int getAvailabilityStatus() {
return DevelopmentSettingsEnabler.isDevelopmentSettingsEnabled(mContext) return DevelopmentSettingsEnabler.isDevelopmentSettingsEnabled(mContext)
&& (Settings.Global.getInt( && (Settings.Global.getInt(mContentResolver,
mContentResolver, Settings.Global.GUP_DEV_ALL_APPS, GUP_DEFAULT) Settings.Global.GAME_DRIVER_ALL_APPS, GAME_DRIVER_DEFAULT)
!= GUP_OFF) != GAME_DRIVER_OFF)
? AVAILABLE ? AVAILABLE
: CONDITIONALLY_UNAVAILABLE; : CONDITIONALLY_UNAVAILABLE;
} }
@@ -146,7 +148,7 @@ public class GupPreferenceController extends BasePreferenceController
if (value.equals(mPreferenceSystem)) { if (value.equals(mPreferenceSystem)) {
mDevOptInApps.remove(packageName); mDevOptInApps.remove(packageName);
mDevOptOutApps.add(packageName); mDevOptOutApps.add(packageName);
} else if (value.equals(mPreferenceGup)) { } else if (value.equals(mPreferenceGameDriver)) {
mDevOptInApps.add(packageName); mDevOptInApps.add(packageName);
mDevOptOutApps.remove(packageName); mDevOptOutApps.remove(packageName);
} else { } else {
@@ -157,10 +159,10 @@ public class GupPreferenceController extends BasePreferenceController
listPref.setSummary(value); listPref.setSummary(value);
// Push the updated Sets for opt-in and opt-out apps to // Push the updated Sets for opt-in and opt-out apps to
// corresponding Settings.Global.GUP_DEV_OPT_(IN|OUT)_APPS // corresponding Settings.Global.GAME_DRIVER_OPT_(IN|OUT)_APPS
Settings.Global.putString(mContentResolver, Settings.Global.GUP_DEV_OPT_IN_APPS, Settings.Global.putString(mContentResolver, Settings.Global.GAME_DRIVER_OPT_IN_APPS,
String.join(",", mDevOptInApps)); 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)); String.join(",", mDevOptOutApps));
return true; return true;
@@ -230,13 +232,13 @@ public class GupPreferenceController extends BasePreferenceController
listPreference.setEntryValues(mEntryList); listPreference.setEntryValues(mEntryList);
// Initialize preference default and summary with the opt in/out choices // 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)) { if (mDevOptOutApps.contains(packageName)) {
listPreference.setValue(mPreferenceSystem); listPreference.setValue(mPreferenceSystem);
listPreference.setSummary(mPreferenceSystem); listPreference.setSummary(mPreferenceSystem);
} else if (mDevOptInApps.contains(packageName)) { } else if (mDevOptInApps.contains(packageName)) {
listPreference.setValue(mPreferenceGup); listPreference.setValue(mPreferenceGameDriver);
listPreference.setSummary(mPreferenceGup); listPreference.setSummary(mPreferenceGameDriver);
} else { } else {
listPreference.setValue(mPreferenceDefault); listPreference.setValue(mPreferenceDefault);
listPreference.setSummary(mPreferenceDefault); listPreference.setSummary(mPreferenceDefault);

View File

@@ -14,7 +14,7 @@
* limitations under the License. * limitations under the License.
*/ */
package com.android.settings.development.gup; package com.android.settings.development.gamedriver;
import android.content.ContentResolver; import android.content.ContentResolver;
import android.database.ContentObserver; import android.database.ContentObserver;
@@ -27,6 +27,7 @@ import androidx.annotation.VisibleForTesting;
* Helper class to observe Game Driver settings global change. * Helper class to observe Game Driver settings global change.
*/ */
public class GameDriverContentObserver extends ContentObserver { public class GameDriverContentObserver extends ContentObserver {
interface OnGameDriverContentChangedListener { interface OnGameDriverContentChangedListener {
void onGameDriverContentChanged(); void onGameDriverContentChanged();
} }
@@ -47,7 +48,7 @@ public class GameDriverContentObserver extends ContentObserver {
public void register(ContentResolver contentResolver) { public void register(ContentResolver contentResolver) {
contentResolver.registerContentObserver( 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) { public void unregister(ContentResolver contentResolver) {

View File

@@ -14,7 +14,7 @@
* limitations under the License. * limitations under the License.
*/ */
package com.android.settings.development.gup; package com.android.settings.development.gamedriver;
import android.app.settings.SettingsEnums; import android.app.settings.SettingsEnums;
import android.content.Context; import android.content.Context;
@@ -38,12 +38,13 @@ import java.util.List;
* Dashboard for Game Driver preferences. * Dashboard for Game Driver preferences.
*/ */
@SearchIndexable @SearchIndexable
public class GupDashboard extends DashboardFragment { public class GameDriverDashboard extends DashboardFragment {
private static final String TAG = "GupDashboard";
private static final String TAG = "GameDriverDashboard";
@Override @Override
public int getMetricsCategory() { public int getMetricsCategory() {
return SettingsEnums.SETTINGS_GUP_DASHBOARD; return SettingsEnums.SETTINGS_GAME_DRIVER_DASHBOARD;
} }
@Override @Override
@@ -53,7 +54,7 @@ public class GupDashboard extends DashboardFragment {
@Override @Override
protected int getPreferenceScreenResId() { protected int getPreferenceScreenResId() {
return R.xml.gup_settings; return R.xml.game_driver_settings;
} }
@Override @Override
@@ -67,8 +68,9 @@ public class GupDashboard extends DashboardFragment {
final SettingsActivity activity = (SettingsActivity) getActivity(); final SettingsActivity activity = (SettingsActivity) getActivity();
final SwitchBar switchBar = activity.getSwitchBar(); final SwitchBar switchBar = activity.getSwitchBar();
final GupGlobalSwitchBarController switchBarController = final GameDriverGlobalSwitchBarController switchBarController =
new GupGlobalSwitchBarController(activity, new SwitchBarController(switchBar)); new GameDriverGlobalSwitchBarController(
activity, new SwitchBarController(switchBar));
getSettingsLifecycle().addObserver(switchBarController); getSettingsLifecycle().addObserver(switchBarController);
switchBar.show(); switchBar.show();
} }
@@ -80,7 +82,7 @@ public class GupDashboard extends DashboardFragment {
Context context, boolean enabled) { Context context, boolean enabled) {
final List<SearchIndexableResource> result = new ArrayList<>(); final List<SearchIndexableResource> result = new ArrayList<>();
final SearchIndexableResource sir = new SearchIndexableResource(context); final SearchIndexableResource sir = new SearchIndexableResource(context);
sir.xmlResId = R.xml.gup_settings; sir.xmlResId = R.xml.game_driver_settings;
result.add(sir); result.add(sir);
return result; return result;
} }

View File

@@ -14,7 +14,7 @@
* limitations under the License. * limitations under the License.
*/ */
package com.android.settings.development.gup; package com.android.settings.development.gamedriver;
import android.content.ContentResolver; import android.content.ContentResolver;
import android.content.Context; 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. * Controller of global switch to enable Game Driver for all Apps.
*/ */
public class GupEnableForAllAppsPreferenceController extends BasePreferenceController public class GameDriverEnableForAllAppsPreferenceController extends BasePreferenceController
implements Preference.OnPreferenceChangeListener, implements Preference.OnPreferenceChangeListener,
GameDriverContentObserver.OnGameDriverContentChangedListener, LifecycleObserver, GameDriverContentObserver.OnGameDriverContentChangedListener, LifecycleObserver,
OnStart, OnStop { OnStart, OnStop {
public static final int GUP_DEFAULT = 0;
public static final int GUP_ALL_APPS = 1; public static final int GAME_DRIVER_DEFAULT = 0;
public static final int GUP_OFF = 2; public static final int GAME_DRIVER_ALL_APPS = 1;
public static final int GAME_DRIVER_OFF = 2;
private final Context mContext; private final Context mContext;
private final ContentResolver mContentResolver; private final ContentResolver mContentResolver;
@@ -51,7 +52,7 @@ public class GupEnableForAllAppsPreferenceController extends BasePreferenceContr
private SwitchPreference mPreference; private SwitchPreference mPreference;
public GupEnableForAllAppsPreferenceController(Context context, String key) { public GameDriverEnableForAllAppsPreferenceController(Context context, String key) {
super(context, key); super(context, key);
mContext = context; mContext = context;
mContentResolver = context.getContentResolver(); mContentResolver = context.getContentResolver();
@@ -62,9 +63,9 @@ public class GupEnableForAllAppsPreferenceController extends BasePreferenceContr
@Override @Override
public int getAvailabilityStatus() { public int getAvailabilityStatus() {
return DevelopmentSettingsEnabler.isDevelopmentSettingsEnabled(mContext) return DevelopmentSettingsEnabler.isDevelopmentSettingsEnabled(mContext)
&& (Settings.Global.getInt( && (Settings.Global.getInt(mContentResolver,
mContentResolver, Settings.Global.GUP_DEV_ALL_APPS, GUP_DEFAULT) Settings.Global.GAME_DRIVER_ALL_APPS, GAME_DRIVER_DEFAULT)
!= GUP_OFF) != GAME_DRIVER_OFF)
? AVAILABLE ? AVAILABLE
: CONDITIONALLY_UNAVAILABLE; : CONDITIONALLY_UNAVAILABLE;
} }
@@ -89,15 +90,16 @@ public class GupEnableForAllAppsPreferenceController extends BasePreferenceContr
public void updateState(Preference preference) { public void updateState(Preference preference) {
final SwitchPreference switchPreference = (SwitchPreference) preference; final SwitchPreference switchPreference = (SwitchPreference) preference;
switchPreference.setVisible(isAvailable()); switchPreference.setVisible(isAvailable());
switchPreference.setChecked(Settings.Global.getInt(mContentResolver, switchPreference.setChecked(
Settings.Global.GUP_DEV_ALL_APPS, GUP_DEFAULT) Settings.Global.getInt(
== GUP_ALL_APPS); mContentResolver, Settings.Global.GAME_DRIVER_ALL_APPS, GAME_DRIVER_DEFAULT)
== GAME_DRIVER_ALL_APPS);
} }
@Override @Override
public boolean onPreferenceChange(Preference preference, Object newValue) { public boolean onPreferenceChange(Preference preference, Object newValue) {
Settings.Global.putInt(mContentResolver, Settings.Global.GUP_DEV_ALL_APPS, Settings.Global.putInt(mContentResolver, Settings.Global.GAME_DRIVER_ALL_APPS,
(boolean) newValue ? GUP_ALL_APPS : GUP_DEFAULT); (boolean) newValue ? GAME_DRIVER_ALL_APPS : GAME_DRIVER_DEFAULT);
return true; return true;
} }

View File

@@ -14,10 +14,10 @@
* limitations under the License. * 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.gamedriver.GameDriverEnableForAllAppsPreferenceController.GAME_DRIVER_DEFAULT;
import static com.android.settings.development.gup.GupEnableForAllAppsPreferenceController.GUP_OFF; import static com.android.settings.development.gamedriver.GameDriverEnableForAllAppsPreferenceController.GAME_DRIVER_OFF;
import android.content.ContentResolver; import android.content.ContentResolver;
import android.content.Context; import android.content.Context;
@@ -41,6 +41,7 @@ import com.android.settingslib.widget.FooterPreference;
public class GameDriverFooterPreferenceController extends BasePreferenceController public class GameDriverFooterPreferenceController extends BasePreferenceController
implements GameDriverContentObserver.OnGameDriverContentChangedListener, LifecycleObserver, implements GameDriverContentObserver.OnGameDriverContentChangedListener, LifecycleObserver,
OnStart, OnStop { OnStart, OnStop {
private final ContentResolver mContentResolver; private final ContentResolver mContentResolver;
@VisibleForTesting @VisibleForTesting
GameDriverContentObserver mGameDriverContentObserver; GameDriverContentObserver mGameDriverContentObserver;
@@ -57,8 +58,8 @@ public class GameDriverFooterPreferenceController extends BasePreferenceControll
@Override @Override
public int getAvailabilityStatus() { public int getAvailabilityStatus() {
return Settings.Global.getInt( return Settings.Global.getInt(
mContentResolver, Settings.Global.GUP_DEV_ALL_APPS, GUP_DEFAULT) mContentResolver, Settings.Global.GAME_DRIVER_ALL_APPS, GAME_DRIVER_DEFAULT)
== GUP_OFF == GAME_DRIVER_OFF
? AVAILABLE_UNSEARCHABLE ? AVAILABLE_UNSEARCHABLE
: CONDITIONALLY_UNAVAILABLE; : CONDITIONALLY_UNAVAILABLE;
} }

View File

@@ -14,11 +14,11 @@
* limitations under the License. * 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.gamedriver.GameDriverEnableForAllAppsPreferenceController.GAME_DRIVER_ALL_APPS;
import static com.android.settings.development.gup.GupEnableForAllAppsPreferenceController.GUP_DEFAULT; import static com.android.settings.development.gamedriver.GameDriverEnableForAllAppsPreferenceController.GAME_DRIVER_DEFAULT;
import static com.android.settings.development.gup.GupEnableForAllAppsPreferenceController.GUP_OFF; import static com.android.settings.development.gamedriver.GameDriverEnableForAllAppsPreferenceController.GAME_DRIVER_OFF;
import android.content.ContentResolver; import android.content.ContentResolver;
import android.content.Context; 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. * Controller of global switch bar used to fully turn off Game Driver.
*/ */
public class GupGlobalSwitchBarController public class GameDriverGlobalSwitchBarController
implements SwitchWidgetController.OnSwitchChangeListener, implements SwitchWidgetController.OnSwitchChangeListener,
GameDriverContentObserver.OnGameDriverContentChangedListener, LifecycleObserver, GameDriverContentObserver.OnGameDriverContentChangedListener, LifecycleObserver,
OnStart, OnStop { OnStart, OnStop {
private final Context mContext; private final Context mContext;
private final ContentResolver mContentResolver; private final ContentResolver mContentResolver;
@VisibleForTesting @VisibleForTesting
@@ -48,7 +49,8 @@ public class GupGlobalSwitchBarController
@VisibleForTesting @VisibleForTesting
GameDriverContentObserver mGameDriverContentObserver; GameDriverContentObserver mGameDriverContentObserver;
GupGlobalSwitchBarController(Context context, SwitchWidgetController switchWidgetController) { GameDriverGlobalSwitchBarController(
Context context, SwitchWidgetController switchWidgetController) {
mContext = context; mContext = context;
mContentResolver = context.getContentResolver(); mContentResolver = context.getContentResolver();
mGameDriverContentObserver = mGameDriverContentObserver =
@@ -56,9 +58,10 @@ public class GupGlobalSwitchBarController
mSwitchWidgetController = switchWidgetController; mSwitchWidgetController = switchWidgetController;
mSwitchWidgetController.setEnabled( mSwitchWidgetController.setEnabled(
DevelopmentSettingsEnabler.isDevelopmentSettingsEnabled(context)); DevelopmentSettingsEnabler.isDevelopmentSettingsEnabled(context));
mSwitchWidgetController.setChecked(Settings.Global.getInt(mContentResolver, mSwitchWidgetController.setChecked(
Settings.Global.GUP_DEV_ALL_APPS, GUP_DEFAULT) Settings.Global.getInt(
!= GUP_OFF); mContentResolver, Settings.Global.GAME_DRIVER_ALL_APPS, GAME_DRIVER_DEFAULT)
!= GAME_DRIVER_OFF);
mSwitchWidgetController.setListener(this); mSwitchWidgetController.setListener(this);
} }
@@ -77,13 +80,16 @@ public class GupGlobalSwitchBarController
@Override @Override
public boolean onSwitchToggled(boolean isChecked) { public boolean onSwitchToggled(boolean isChecked) {
if (!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; return true;
} }
if (Settings.Global.getInt(mContentResolver, Settings.Global.GUP_DEV_ALL_APPS, GUP_DEFAULT) if (Settings.Global.getInt(
!= GUP_ALL_APPS) { mContentResolver, Settings.Global.GAME_DRIVER_ALL_APPS, GAME_DRIVER_DEFAULT)
Settings.Global.putInt(mContentResolver, Settings.Global.GUP_DEV_ALL_APPS, GUP_DEFAULT); != GAME_DRIVER_ALL_APPS) {
Settings.Global.putInt(
mContentResolver, Settings.Global.GAME_DRIVER_ALL_APPS, GAME_DRIVER_DEFAULT);
} }
return true; return true;
@@ -91,8 +97,9 @@ public class GupGlobalSwitchBarController
@Override @Override
public void onGameDriverContentChanged() { public void onGameDriverContentChanged() {
mSwitchWidgetController.setChecked(Settings.Global.getInt(mContentResolver, mSwitchWidgetController.setChecked(
Settings.Global.GUP_DEV_ALL_APPS, GUP_DEFAULT) Settings.Global.getInt(
!= GUP_OFF); mContentResolver, Settings.Global.GAME_DRIVER_ALL_APPS, GAME_DRIVER_DEFAULT)
!= GAME_DRIVER_OFF);
} }
} }

View File

@@ -14,12 +14,12 @@
* limitations under the License. * 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.AVAILABLE;
import static com.android.settings.core.BasePreferenceController.CONDITIONALLY_UNAVAILABLE; 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.gamedriver.GameDriverEnableForAllAppsPreferenceController.GAME_DRIVER_DEFAULT;
import static com.android.settings.development.gup.GupEnableForAllAppsPreferenceController.GUP_OFF; import static com.android.settings.development.gamedriver.GameDriverEnableForAllAppsPreferenceController.GAME_DRIVER_OFF;
import static com.android.settings.testutils.ApplicationTestUtils.buildInfo; import static com.android.settings.testutils.ApplicationTestUtils.buildInfo;
import static com.google.common.truth.Truth.assertThat; import static com.google.common.truth.Truth.assertThat;
@@ -52,9 +52,10 @@ import org.robolectric.RobolectricTestRunner;
import org.robolectric.RuntimeEnvironment; import org.robolectric.RuntimeEnvironment;
@RunWith(RobolectricTestRunner.class) @RunWith(RobolectricTestRunner.class)
public class GupPreferenceControllerTest { public class GameDriverAppPreferenceControllerTest {
private static final int DEFAULT = 0; 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 int SYSTEM = 2;
private static final String TEST_APP_NAME = "testApp"; private static final String TEST_APP_NAME = "testApp";
private static final String TEST_PKG_NAME = "testPkg"; private static final String TEST_PKG_NAME = "testPkg";
@@ -75,7 +76,7 @@ public class GupPreferenceControllerTest {
private PreferenceGroup mGroup; private PreferenceGroup mGroup;
private PreferenceManager mPreferenceManager; private PreferenceManager mPreferenceManager;
private ContentResolver mResolver; private ContentResolver mResolver;
private GupPreferenceController mController; private GameDriverAppPreferenceController mController;
private CharSequence[] mValueList; private CharSequence[] mValueList;
private String mDialogTitle; private String mDialogTitle;
@@ -84,15 +85,17 @@ public class GupPreferenceControllerTest {
MockitoAnnotations.initMocks(this); MockitoAnnotations.initMocks(this);
mContext = spy(RuntimeEnvironment.application); mContext = spy(RuntimeEnvironment.application);
mResolver = mContext.getContentResolver(); mResolver = mContext.getContentResolver();
mValueList = mContext.getResources().getStringArray(R.array.gup_app_preference_values); mValueList =
mDialogTitle = mContext.getResources().getString(R.string.gup_app_preference_title); mContext.getResources().getStringArray(R.array.game_driver_app_preference_values);
mDialogTitle = mContext.getResources().getString(R.string.game_driver_app_preference_title);
} }
@Test @Test
public void getAvailability_developmentSettingsEnabledAndGupSettingsOn_available() { public void getAvailability_developmentSettingsEnabledAndGameDriverOn_available() {
loadDefaultConfig(); loadDefaultConfig();
Settings.Global.putInt(mResolver, Settings.Global.DEVELOPMENT_SETTINGS_ENABLED, 1); 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); assertThat(mController.getAvailabilityStatus()).isEqualTo(AVAILABLE);
} }
@@ -106,9 +109,9 @@ public class GupPreferenceControllerTest {
} }
@Test @Test
public void getAvailability_gupSettingsOff_conditionallyUnavailable() { public void getAvailability_gameDriverOff_conditionallyUnavailable() {
loadDefaultConfig(); 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); assertThat(mController.getAvailabilityStatus()).isEqualTo(CONDITIONALLY_UNAVAILABLE);
} }
@@ -145,15 +148,16 @@ public class GupPreferenceControllerTest {
@Test @Test
public void updateState_available_visible() { public void updateState_available_visible() {
Settings.Global.putInt(mResolver, Settings.Global.DEVELOPMENT_SETTINGS_ENABLED, 1); 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(); loadDefaultConfig();
assertThat(mGroup.isVisible()).isTrue(); assertThat(mGroup.isVisible()).isTrue();
} }
@Test @Test
public void updateState_gupSettingsOff_notVisible() { public void updateState_gameDriverOff_notVisible() {
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);
loadDefaultConfig(); loadDefaultConfig();
assertThat(mGroup.isVisible()).isFalse(); assertThat(mGroup.isVisible()).isFalse();
@@ -176,7 +180,7 @@ public class GupPreferenceControllerTest {
} }
@Test @Test
public void createPreference_configGup_shouldSetGupAttributes() { public void createPreference_configGAME_DRIVER_shouldSetGameDriverAttributes() {
loadConfig(TEST_PKG_NAME, ""); loadConfig(TEST_PKG_NAME, "");
final ListPreference preference = final ListPreference preference =
mController.createListPreference(mContext, TEST_PKG_NAME, TEST_APP_NAME); mController.createListPreference(mContext, TEST_PKG_NAME, TEST_APP_NAME);
@@ -186,9 +190,9 @@ public class GupPreferenceControllerTest {
assertThat(preference.getDialogTitle()).isEqualTo(mDialogTitle); assertThat(preference.getDialogTitle()).isEqualTo(mDialogTitle);
assertThat(preference.getEntries()).isEqualTo(mValueList); assertThat(preference.getEntries()).isEqualTo(mValueList);
assertThat(preference.getEntryValues()).isEqualTo(mValueList); assertThat(preference.getEntryValues()).isEqualTo(mValueList);
assertThat(preference.getEntry()).isEqualTo(mValueList[GUP]); assertThat(preference.getEntry()).isEqualTo(mValueList[GAME_DRIVER]);
assertThat(preference.getValue()).isEqualTo(mValueList[GUP]); assertThat(preference.getValue()).isEqualTo(mValueList[GAME_DRIVER]);
assertThat(preference.getSummary()).isEqualTo(mValueList[GUP]); assertThat(preference.getSummary()).isEqualTo(mValueList[GAME_DRIVER]);
} }
@Test @Test
@@ -217,25 +221,25 @@ public class GupPreferenceControllerTest {
assertThat(preference.getEntry()).isEqualTo(mValueList[DEFAULT]); assertThat(preference.getEntry()).isEqualTo(mValueList[DEFAULT]);
assertThat(preference.getValue()).isEqualTo(mValueList[DEFAULT]); assertThat(preference.getValue()).isEqualTo(mValueList[DEFAULT]);
assertThat(preference.getSummary()).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(""); .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(""); .isEqualTo("");
} }
@Test @Test
public void onPreferenceChange_selectGup_shouldUpdateAttributesAndSettingsGlobal() { public void onPreferenceChange_selectGAME_DRIVER_shouldUpdateAttributesAndSettingsGlobal() {
loadDefaultConfig(); loadDefaultConfig();
final ListPreference preference = final ListPreference preference =
mController.createListPreference(mContext, TEST_PKG_NAME, TEST_APP_NAME); 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.getEntry()).isEqualTo(mValueList[GAME_DRIVER]);
assertThat(preference.getValue()).isEqualTo(mValueList[GUP]); assertThat(preference.getValue()).isEqualTo(mValueList[GAME_DRIVER]);
assertThat(preference.getSummary()).isEqualTo(mValueList[GUP]); assertThat(preference.getSummary()).isEqualTo(mValueList[GAME_DRIVER]);
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(TEST_PKG_NAME); .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(""); .isEqualTo("");
} }
@@ -249,9 +253,9 @@ public class GupPreferenceControllerTest {
assertThat(preference.getEntry()).isEqualTo(mValueList[SYSTEM]); assertThat(preference.getEntry()).isEqualTo(mValueList[SYSTEM]);
assertThat(preference.getValue()).isEqualTo(mValueList[SYSTEM]); assertThat(preference.getValue()).isEqualTo(mValueList[SYSTEM]);
assertThat(preference.getSummary()).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(""); .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); .isEqualTo(TEST_PKG_NAME);
} }
@@ -273,10 +277,10 @@ public class GupPreferenceControllerTest {
private void loadDefaultConfig() { loadConfig("", ""); } private void loadDefaultConfig() { loadConfig("", ""); }
private void loadConfig(String optIn, String optOut) { 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.GAME_DRIVER_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_OUT_APPS, optOut);
mController = new GupPreferenceController(mContext, "testKey"); mController = new GameDriverAppPreferenceController(mContext, "testKey");
mGroup = spy(new PreferenceCategory(mContext)); mGroup = spy(new PreferenceCategory(mContext));
final PreferenceManager preferenceManager = new PreferenceManager(mContext); final PreferenceManager preferenceManager = new PreferenceManager(mContext);
when(mGroup.getContext()).thenReturn(mContext); when(mGroup.getContext()).thenReturn(mContext);

View File

@@ -14,13 +14,14 @@
* limitations under the License. * 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.spy;
import static org.mockito.Mockito.verify; import static org.mockito.Mockito.verify;
import android.content.ContentResolver; import android.content.ContentResolver;
import android.provider.Settings; import android.provider.Settings;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
@@ -31,6 +32,7 @@ import org.robolectric.RuntimeEnvironment;
@RunWith(RobolectricTestRunner.class) @RunWith(RobolectricTestRunner.class)
public class GameDriverContentObserverTest { public class GameDriverContentObserverTest {
@Mock @Mock
private ContentResolver mResolver; private ContentResolver mResolver;
@Mock @Mock
@@ -57,7 +59,7 @@ public class GameDriverContentObserverTest {
mGameDriverContentObserver.register(mResolver); mGameDriverContentObserver.register(mResolver);
verify(mResolver).registerContentObserver( verify(mResolver).registerContentObserver(
Settings.Global.getUriFor(Settings.Global.GUP_DEV_ALL_APPS), false, Settings.Global.getUriFor(Settings.Global.GAME_DRIVER_ALL_APPS), false,
mGameDriverContentObserver); mGameDriverContentObserver);
} }

View File

@@ -14,11 +14,12 @@
* limitations under the License. * 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 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 com.android.settings.R;
import org.junit.Before; import org.junit.Before;
@@ -27,12 +28,13 @@ import org.junit.runner.RunWith;
import org.robolectric.RobolectricTestRunner; import org.robolectric.RobolectricTestRunner;
@RunWith(RobolectricTestRunner.class) @RunWith(RobolectricTestRunner.class)
public class GupDashboardTest { public class GameDriverDashboardTest {
private GupDashboard mDashboard;
private GameDriverDashboard mDashboard;
@Before @Before
public void setUp() { public void setUp() {
mDashboard = new GupDashboard(); mDashboard = new GameDriverDashboard();
} }
@Test @Test
@@ -41,14 +43,13 @@ public class GupDashboardTest {
} }
@Test @Test
public void getMetricesCategory_shouldReturnGupDashboard() { public void getMetricesCategory_shouldReturnGameDriverDashboard() {
assertThat(mDashboard.getMetricsCategory()) assertThat(mDashboard.getMetricsCategory())
.isEqualTo(MetricsProto.MetricsEvent.SETTINGS_GUP_DASHBOARD); .isEqualTo(SettingsEnums.SETTINGS_GAME_DRIVER_DASHBOARD);
} }
@Test @Test
public void getPreferenceScreen_shouldReturnGupSettings() { public void getPreferenceScreen_shouldReturnGameDriverSettings() {
assertThat(mDashboard.getPreferenceScreenResId()) assertThat(mDashboard.getPreferenceScreenResId()).isEqualTo(R.xml.game_driver_settings);
.isEqualTo(R.xml.gup_settings);
} }
} }

View File

@@ -14,13 +14,13 @@
* limitations under the License. * 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.AVAILABLE;
import static com.android.settings.core.BasePreferenceController.CONDITIONALLY_UNAVAILABLE; 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.gamedriver.GameDriverEnableForAllAppsPreferenceController.GAME_DRIVER_ALL_APPS;
import static com.android.settings.development.gup.GupEnableForAllAppsPreferenceController.GUP_DEFAULT; import static com.android.settings.development.gamedriver.GameDriverEnableForAllAppsPreferenceController.GAME_DRIVER_DEFAULT;
import static com.android.settings.development.gup.GupEnableForAllAppsPreferenceController.GUP_OFF; import static com.android.settings.development.gamedriver.GameDriverEnableForAllAppsPreferenceController.GAME_DRIVER_OFF;
import static com.google.common.truth.Truth.assertThat; import static com.google.common.truth.Truth.assertThat;
import static org.mockito.Mockito.atLeastOnce; import static org.mockito.Mockito.atLeastOnce;
@@ -43,7 +43,8 @@ import org.robolectric.RobolectricTestRunner;
import org.robolectric.RuntimeEnvironment; import org.robolectric.RuntimeEnvironment;
@RunWith(RobolectricTestRunner.class) @RunWith(RobolectricTestRunner.class)
public class GupEnableForAllAppsPreferenceControllerTest { public class GameDriverEnableForAllAppsPreferenceControllerTest {
@Mock @Mock
private PreferenceScreen mScreen; private PreferenceScreen mScreen;
@Mock @Mock
@@ -53,14 +54,14 @@ public class GupEnableForAllAppsPreferenceControllerTest {
private Context mContext; private Context mContext;
private ContentResolver mResolver; private ContentResolver mResolver;
private GupEnableForAllAppsPreferenceController mController; private GameDriverEnableForAllAppsPreferenceController mController;
@Before @Before
public void setUp() { public void setUp() {
MockitoAnnotations.initMocks(this); MockitoAnnotations.initMocks(this);
mContext = RuntimeEnvironment.application; mContext = RuntimeEnvironment.application;
mResolver = mContext.getContentResolver(); mResolver = mContext.getContentResolver();
mController = new GupEnableForAllAppsPreferenceController(mContext, "testKey"); mController = new GameDriverEnableForAllAppsPreferenceController(mContext, "testKey");
when(mScreen.findPreference(mController.getPreferenceKey())).thenReturn(mPreference); when(mScreen.findPreference(mController.getPreferenceKey())).thenReturn(mPreference);
mController.displayPreference(mScreen); mController.displayPreference(mScreen);
@@ -68,8 +69,9 @@ public class GupEnableForAllAppsPreferenceControllerTest {
} }
@Test @Test
public void getAvailability_developmentSettingsEnabledAndGupSettingsOn_available() { public void getAvailability_developmentSettingsEnabledAndGameDriverSettingsOn_available() {
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); assertThat(mController.getAvailabilityStatus()).isEqualTo(AVAILABLE);
} }
@@ -82,15 +84,16 @@ public class GupEnableForAllAppsPreferenceControllerTest {
} }
@Test @Test
public void getAvailability_gupSettingsOff_conditionallyUnavailable() { public void getAvailability_gameDriverOff_conditionallyUnavailable() {
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); assertThat(mController.getAvailabilityStatus()).isEqualTo(CONDITIONALLY_UNAVAILABLE);
} }
@Test @Test
public void displayPreference_shouldAddSwitchPreference() { 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); mController.updateState(mPreference);
verify(mPreference).setChecked(false); verify(mPreference).setChecked(false);
@@ -113,8 +116,9 @@ public class GupEnableForAllAppsPreferenceControllerTest {
} }
@Test @Test
public void updateState_availableAndGupDefault_visibleAndUncheck() { public void updateState_availableAndGameDriverDefault_visibleAndUncheck() {
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); mController.updateState(mPreference);
verify(mPreference, atLeastOnce()).setVisible(true); verify(mPreference, atLeastOnce()).setVisible(true);
@@ -122,8 +126,9 @@ public class GupEnableForAllAppsPreferenceControllerTest {
} }
@Test @Test
public void updateState_availableAndGupAllApps_visibleAndCheck() { public void updateState_availableAndGameDriverAllApps_visibleAndCheck() {
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.updateState(mPreference); mController.updateState(mPreference);
verify(mPreference, atLeastOnce()).setVisible(true); verify(mPreference, atLeastOnce()).setVisible(true);
@@ -131,8 +136,8 @@ public class GupEnableForAllAppsPreferenceControllerTest {
} }
@Test @Test
public void updateState_gupSettingsOff_notVisibleAndUncheck() { public void updateState_gameDriverOff_notVisibleAndUncheck() {
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);
mController.updateState(mPreference); mController.updateState(mPreference);
verify(mPreference).setVisible(false); verify(mPreference).setVisible(false);
@@ -141,19 +146,23 @@ public class GupEnableForAllAppsPreferenceControllerTest {
@Test @Test
public void onPreferenceChange_check_shouldUpdateSettingsGlobal() { 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); mController.onPreferenceChange(mPreference, true);
assertThat(Settings.Global.getInt(mResolver, Settings.Global.GUP_DEV_ALL_APPS, GUP_DEFAULT)) assertThat(Settings.Global.getInt(
.isEqualTo(GUP_ALL_APPS); mResolver, Settings.Global.GAME_DRIVER_ALL_APPS, GAME_DRIVER_DEFAULT))
.isEqualTo(GAME_DRIVER_ALL_APPS);
} }
@Test @Test
public void onPreferenceChange_uncheck_shouldUpdateSettingsGlobal() { 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); mController.onPreferenceChange(mPreference, false);
assertThat(Settings.Global.getInt(mResolver, Settings.Global.GUP_DEV_ALL_APPS, GUP_DEFAULT)) assertThat(Settings.Global.getInt(
.isEqualTo(GUP_DEFAULT); mResolver, Settings.Global.GAME_DRIVER_ALL_APPS, GAME_DRIVER_DEFAULT))
.isEqualTo(GAME_DRIVER_DEFAULT);
} }
} }

View File

@@ -14,13 +14,13 @@
* limitations under the License. * 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.AVAILABLE_UNSEARCHABLE;
import static com.android.settings.core.BasePreferenceController.CONDITIONALLY_UNAVAILABLE; 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.gamedriver.GameDriverEnableForAllAppsPreferenceController.GAME_DRIVER_ALL_APPS;
import static com.android.settings.development.gup.GupEnableForAllAppsPreferenceController.GUP_DEFAULT; import static com.android.settings.development.gamedriver.GameDriverEnableForAllAppsPreferenceController.GAME_DRIVER_DEFAULT;
import static com.android.settings.development.gup.GupEnableForAllAppsPreferenceController.GUP_OFF; import static com.android.settings.development.gamedriver.GameDriverEnableForAllAppsPreferenceController.GAME_DRIVER_OFF;
import static com.google.common.truth.Truth.assertThat; import static com.google.common.truth.Truth.assertThat;
import static org.mockito.Mockito.spy; import static org.mockito.Mockito.spy;
@@ -45,6 +45,7 @@ import org.robolectric.RuntimeEnvironment;
@RunWith(RobolectricTestRunner.class) @RunWith(RobolectricTestRunner.class)
public class GameDriverFooterPreferenceControllerTest { public class GameDriverFooterPreferenceControllerTest {
@Mock @Mock
private PreferenceScreen mScreen; private PreferenceScreen mScreen;
@Mock @Mock
@@ -67,21 +68,23 @@ public class GameDriverFooterPreferenceControllerTest {
@Test @Test
public void getAvailabilityStatus_gameDriverOff_availableUnsearchable() { 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); assertThat(mController.getAvailabilityStatus()).isEqualTo(AVAILABLE_UNSEARCHABLE);
} }
@Test @Test
public void getAvailabilityStatus_gameDriverDefault_conditionallyUnavailable() { 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); assertThat(mController.getAvailabilityStatus()).isEqualTo(CONDITIONALLY_UNAVAILABLE);
} }
@Test @Test
public void getAvailabilityStatus_gameDriverAllApps_conditionallyUnavailable() { 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); assertThat(mController.getAvailabilityStatus()).isEqualTo(CONDITIONALLY_UNAVAILABLE);
} }

View File

@@ -14,10 +14,10 @@
* limitations under the License. * 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.gamedriver.GameDriverEnableForAllAppsPreferenceController.GAME_DRIVER_DEFAULT;
import static com.android.settings.development.gup.GupEnableForAllAppsPreferenceController.GUP_OFF; import static com.android.settings.development.gamedriver.GameDriverEnableForAllAppsPreferenceController.GAME_DRIVER_OFF;
import static com.google.common.truth.Truth.assertThat; import static com.google.common.truth.Truth.assertThat;
import static org.mockito.Mockito.verify; import static org.mockito.Mockito.verify;
@@ -39,7 +39,8 @@ import org.robolectric.RobolectricTestRunner;
import org.robolectric.RuntimeEnvironment; import org.robolectric.RuntimeEnvironment;
@RunWith(RobolectricTestRunner.class) @RunWith(RobolectricTestRunner.class)
public class GupGlobalSwitchBarControllerTest { public class GameDriverGlobalSwitchBarControllerTest {
@Mock @Mock
private SwitchBar mSwitchBar; private SwitchBar mSwitchBar;
@Mock @Mock
@@ -49,7 +50,7 @@ public class GupGlobalSwitchBarControllerTest {
private Context mContext; private Context mContext;
private ContentResolver mResolver; private ContentResolver mResolver;
private GupGlobalSwitchBarController mController; private GameDriverGlobalSwitchBarController mController;
@Before @Before
public void setUp() { public void setUp() {
@@ -59,19 +60,20 @@ public class GupGlobalSwitchBarControllerTest {
} }
@Test @Test
public void constructor_gupOn_shouldCheckSwitchBar() { public void constructor_gameDriverOn_shouldCheckSwitchBar() {
Settings.Global.putInt(mResolver, Settings.Global.GUP_DEV_ALL_APPS, GUP_DEFAULT); Settings.Global.putInt(
mController = mResolver, Settings.Global.GAME_DRIVER_ALL_APPS, GAME_DRIVER_DEFAULT);
new GupGlobalSwitchBarController(mContext, new SwitchBarController(mSwitchBar)); mController = new GameDriverGlobalSwitchBarController(
mContext, new SwitchBarController(mSwitchBar));
verify(mSwitchBar).setChecked(true); verify(mSwitchBar).setChecked(true);
} }
@Test @Test
public void constructor_gupOff_shouldUncheckSwitchBar() { public void constructor_gameDriverOff_shouldUncheckSwitchBar() {
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);
mController = mController = new GameDriverGlobalSwitchBarController(
new GupGlobalSwitchBarController(mContext, new SwitchBarController(mSwitchBar)); mContext, new SwitchBarController(mSwitchBar));
verify(mSwitchBar).setChecked(false); verify(mSwitchBar).setChecked(false);
} }
@@ -79,8 +81,8 @@ public class GupGlobalSwitchBarControllerTest {
@Test @Test
public void constructor_developmentSettingsEnabled_shouldEnableSwitchBar() { public void constructor_developmentSettingsEnabled_shouldEnableSwitchBar() {
Settings.Global.putInt(mResolver, Settings.Global.DEVELOPMENT_SETTINGS_ENABLED, 1); Settings.Global.putInt(mResolver, Settings.Global.DEVELOPMENT_SETTINGS_ENABLED, 1);
mController = mController = new GameDriverGlobalSwitchBarController(
new GupGlobalSwitchBarController(mContext, new SwitchBarController(mSwitchBar)); mContext, new SwitchBarController(mSwitchBar));
verify(mSwitchBar).setEnabled(true); verify(mSwitchBar).setEnabled(true);
} }
@@ -88,16 +90,16 @@ public class GupGlobalSwitchBarControllerTest {
@Test @Test
public void constructor_developmentSettingsDisabled_shouldDisableSwitchBar() { public void constructor_developmentSettingsDisabled_shouldDisableSwitchBar() {
Settings.Global.putInt(mResolver, Settings.Global.DEVELOPMENT_SETTINGS_ENABLED, 0); Settings.Global.putInt(mResolver, Settings.Global.DEVELOPMENT_SETTINGS_ENABLED, 0);
mController = mController = new GameDriverGlobalSwitchBarController(
new GupGlobalSwitchBarController(mContext, new SwitchBarController(mSwitchBar)); mContext, new SwitchBarController(mSwitchBar));
verify(mSwitchBar).setEnabled(false); verify(mSwitchBar).setEnabled(false);
} }
@Test @Test
public void onStart_shouldStartListeningAndRegister() { public void onStart_shouldStartListeningAndRegister() {
mController = mController = new GameDriverGlobalSwitchBarController(
new GupGlobalSwitchBarController(mContext, new SwitchBarController(mSwitchBar)); mContext, new SwitchBarController(mSwitchBar));
mController.mSwitchWidgetController = mSwitchWidgetController; mController.mSwitchWidgetController = mSwitchWidgetController;
mController.mGameDriverContentObserver = mGameDriverContentObserver; mController.mGameDriverContentObserver = mGameDriverContentObserver;
mController.onStart(); mController.onStart();
@@ -108,8 +110,8 @@ public class GupGlobalSwitchBarControllerTest {
@Test @Test
public void onStop_shouldStopListeningAndUnregister() { public void onStop_shouldStopListeningAndUnregister() {
mController = mController = new GameDriverGlobalSwitchBarController(
new GupGlobalSwitchBarController(mContext, new SwitchBarController(mSwitchBar)); mContext, new SwitchBarController(mSwitchBar));
mController.mSwitchWidgetController = mSwitchWidgetController; mController.mSwitchWidgetController = mSwitchWidgetController;
mController.mGameDriverContentObserver = mGameDriverContentObserver; mController.mGameDriverContentObserver = mGameDriverContentObserver;
mController.onStop(); mController.onStop();
@@ -119,24 +121,27 @@ public class GupGlobalSwitchBarControllerTest {
} }
@Test @Test
public void onSwitchToggled_checked_shouldTurnOnGup() { public void onSwitchToggled_checked_shouldTurnOnGameDriver() {
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);
mController = mController = new GameDriverGlobalSwitchBarController(
new GupGlobalSwitchBarController(mContext, new SwitchBarController(mSwitchBar)); mContext, new SwitchBarController(mSwitchBar));
mController.onSwitchToggled(true); mController.onSwitchToggled(true);
assertThat(Settings.Global.getInt(mResolver, Settings.Global.GUP_DEV_ALL_APPS, GUP_DEFAULT)) assertThat(Settings.Global.getInt(
.isEqualTo(GUP_DEFAULT); mResolver, Settings.Global.GAME_DRIVER_ALL_APPS, GAME_DRIVER_DEFAULT))
.isEqualTo(GAME_DRIVER_DEFAULT);
} }
@Test @Test
public void onSwitchToggled_unchecked_shouldTurnOffGup() { public void onSwitchToggled_unchecked_shouldTurnOffGameDriver() {
Settings.Global.putInt(mResolver, Settings.Global.GUP_DEV_ALL_APPS, GUP_DEFAULT); Settings.Global.putInt(
mController = mResolver, Settings.Global.GAME_DRIVER_ALL_APPS, GAME_DRIVER_DEFAULT);
new GupGlobalSwitchBarController(mContext, new SwitchBarController(mSwitchBar)); mController = new GameDriverGlobalSwitchBarController(
mContext, new SwitchBarController(mSwitchBar));
mController.onSwitchToggled(false); mController.onSwitchToggled(false);
assertThat(Settings.Global.getInt(mResolver, Settings.Global.GUP_DEV_ALL_APPS, GUP_DEFAULT)) assertThat(Settings.Global.getInt(
.isEqualTo(GUP_OFF); mResolver, Settings.Global.GAME_DRIVER_ALL_APPS, GAME_DRIVER_DEFAULT))
.isEqualTo(GAME_DRIVER_OFF);
} }
} }