Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit 18af9a5

Browse files
timvpGoogleCommit Bot
authored andcommitted
ANGLE In Use Dialog Box
When ANGLE is enabled for an app, show a dialog box to the user to indicate that ANGLE is in use. This is useful because there are not (or at least shouldn't be) any visual indication that a different OpenGL driver is in use. Clean up some missed renaming/logging related to the "Enable ANGLE for all" setting. Bug: angleproject:3006 Test: Load an app with ANGLE enabled and verify dialog box is shown. Test: Load an app without ANGLE and verify dialog box is not shown. Change-Id: I46ec89567c93efaf156a4801948cd48aabd5f4fb Reviewed-on: https://chromium-review.googlesource.com/c/1383374 Reviewed-by: Tobin Ehlis <[email protected]> Reviewed-by: Courtney Goeltzenleuchter <[email protected]> Commit-Queue: Tim Van Patten <[email protected]>
1 parent e4a52cb commit 18af9a5

File tree

7 files changed

+68
-3
lines changed

7 files changed

+68
-3
lines changed

android/res/values/global_settings.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
<resources>
99
<string name="global_settings_driver_all_angle">angle_gl_driver_all_angle</string>
10+
<string name="global_settings_angle_in_use_dialog_box">angle_in_use_dialog_box</string>
1011
<string name="global_settings_driver_selection_pkgs">angle_gl_driver_selection_pkgs</string>
1112
<string name="global_settings_driver_selection_values">angle_gl_driver_selection_values</string>
1213
</resources>

android/res/values/preference_keys.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
<resources>
99
<string name="pref_key_angle_flags_category">angle_flags_category</string>
1010
<string name="pref_key_all_angle">all_pkgs_use_angle</string>
11+
<string name="pref_key_angle_in_use_dialog">angle_in_use_dialog_box</string>
1112
<string name="pref_key_select_opengl_driver_category">select_opengl_driver_category</string>
1213
<string name="pref_key_installed_pkgs">installed_pkgs</string>
1314
</resources>

android/res/values/strings.xml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,12 @@
1919
<!-- This is the label for a toggle button.
2020
When the toggle is enabled, we will use ANGLE for all PKGs, regardless of any other settings.
2121
This is also used as a Quick Settings tile label. -->
22-
<string name="rules_file">Use ANGLE for all apps</string>
22+
<string name="use_angle_for_all_apps">Use ANGLE for all apps</string>
23+
24+
<!-- This is the label for a toggle button.
25+
When the toggle is enabled, we will show a dialog box indicating that ANGLE is in use.
26+
This is also used as a Quick Settings tile label. -->
27+
<string name="show_angle_in_use_dialog_box">Show dialog box when ANGLE is loaded</string>
2328

2429
<!-- ListPreference title listing installed packages [CHAR_LIMIT=50]-->
2530
<string name="select_opengl_driver_title">Select OpenGL Driver</string>

android/res/xml/main.xml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,17 @@
1616
Enable the switch once Android can boot with ANGLE enabled for everything-->
1717
<android.support.v14.preference.SwitchPreference
1818
android:key="@string/pref_key_all_angle"
19-
android:title="@string/rules_file"
19+
android:title="@string/use_angle_for_all_apps"
2020
android:summary="@string/global_settings_driver_all_angle"
2121
android:defaultValue="false"
2222
android:enabled="false"/>
2323

24+
<android.support.v14.preference.SwitchPreference
25+
android:key="@string/pref_key_angle_in_use_dialog"
26+
android:title="@string/show_angle_in_use_dialog_box"
27+
android:summary="@string/global_settings_angle_in_use_dialog_box"
28+
android:defaultValue="false"
29+
android:enabled="true"/>
2430
</PreferenceCategory>
2531

2632
<PreferenceCategory

android/src/com/android/angle/common/GlobalSettings.java

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,13 +48,36 @@ Boolean getAllUseAngle()
4848
}
4949
}
5050

51+
Boolean getShowAngleInUseDialogBox()
52+
{
53+
ContentResolver contentResolver = mContext.getContentResolver();
54+
try
55+
{
56+
int showAngleInUseDialogBox = Settings.Global.getInt(contentResolver,
57+
mContext.getString(R.string.global_settings_angle_in_use_dialog_box));
58+
return (showAngleInUseDialogBox == 1);
59+
}
60+
catch (Settings.SettingNotFoundException e)
61+
{
62+
return false;
63+
}
64+
}
65+
5166
static void updateAllUseAngle(Context context, Boolean allUseAngle)
5267
{
5368
ContentResolver contentResolver = context.getContentResolver();
5469
Settings.Global.putInt(contentResolver,
5570
context.getString(R.string.global_settings_driver_all_angle), allUseAngle ? 1 : 0);
5671
}
5772

73+
static void updateShowAngleInUseDialog(Context context, Boolean showAngleInUseDialog)
74+
{
75+
ContentResolver contentResolver = context.getContentResolver();
76+
Settings.Global.putInt(contentResolver,
77+
context.getString(R.string.global_settings_angle_in_use_dialog_box),
78+
showAngleInUseDialog ? 1 : 0);
79+
}
80+
5881
void updatePkg(String pkgName, String driver)
5982
{
6083
int pkgIndex = getGlobalSettingsPkgIndex(pkgName);

android/src/com/android/angle/common/MainFragment.java

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ public class MainFragment extends PreferenceFragment implements OnSharedPreferen
4040
private GlobalSettings mGlobalSettings;
4141
private Receiver mRefreshReceiver;
4242
private SwitchPreference mAllAngleSwitchPref;
43+
private SwitchPreference mShowAngleInUseDialogSwitchPref;
4344
private List<PackageInfo> mInstalledPkgs = new ArrayList<>();
4445
private List<ListPreference> mDriverListPrefs = new ArrayList<>();
4546

@@ -87,6 +88,22 @@ public boolean onPreferenceClick(Preference preference)
8788
}
8889
});
8990

91+
String showAngleInUseDialogKey =
92+
getContext().getString(R.string.pref_key_angle_in_use_dialog);
93+
Boolean showAngleInUseDialogBox = mPrefs.getBoolean(showAngleInUseDialogKey, false);
94+
mShowAngleInUseDialogSwitchPref =
95+
(SwitchPreference) findPreference(showAngleInUseDialogKey);
96+
mShowAngleInUseDialogSwitchPref.setChecked(mGlobalSettings.getShowAngleInUseDialogBox());
97+
mShowAngleInUseDialogSwitchPref.setOnPreferenceClickListener(
98+
new Preference.OnPreferenceClickListener() {
99+
@Override
100+
public boolean onPreferenceClick(Preference preference)
101+
{
102+
Receiver.updateShowAngleInUseDialogBox(getContext());
103+
return true;
104+
}
105+
});
106+
90107
String selectDriverCatKey =
91108
getContext().getString(R.string.pref_key_select_opengl_driver_category);
92109
PreferenceCategory installedPkgsCat =

android/src/com/android/angle/common/Receiver.java

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,18 @@ static void updateAllUseAngle(Context context)
3232

3333
GlobalSettings.updateAllUseAngle(context, allUseAngle);
3434

35-
Log.v(TAG, "Use Rules File set to: " + allUseAngle);
35+
Log.v(TAG, "All PKGs use ANGLE set to: " + allUseAngle);
36+
}
37+
38+
static void updateShowAngleInUseDialogBox(Context context)
39+
{
40+
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
41+
String showAngleInUseDialogBoxKey =
42+
context.getString(R.string.pref_key_angle_in_use_dialog);
43+
boolean showAngleInUseDialogBox = prefs.getBoolean(showAngleInUseDialogBoxKey, false);
44+
45+
GlobalSettings.updateShowAngleInUseDialog(context, showAngleInUseDialogBox);
46+
47+
Log.v(TAG, "Show 'ANGLE In Use' dialog box set to: " + showAngleInUseDialogBox);
3648
}
3749
}

0 commit comments

Comments
 (0)