Skip to content
Snippets Groups Projects
Commit b27fecd0 authored by Peiyong Lin's avatar Peiyong Lin
Browse files

Avoid setup ANGLE again when determine whether to show toast.

Previously after the application is launched, the GraphicsEnvironment
will call into setup ANGLE again to check whether the in use toast
message dialog should be shown. However, this step is unnecessary and
creates some overhead. This patch eliminates the call into ANGLE setup
and only check whether ANGLE is used.

Bug: b/283858001
Test: check toast message when opt-in and opt-out
Change-Id: I91f59c17100ac43ee8eea4f3fa8c86602c26a416
parent e0da8106
No related branches found
No related tags found
No related merge requests found
......@@ -635,45 +635,34 @@ public class GraphicsEnvironment {
return false;
}
/**
* Determine if ANGLE will be used and setup the environment
*/
private boolean setupAndUseAngle(Context context, String packageName) {
// Need to make sure we are evaluating ANGLE usage for the correct circumstances
if (!setupAngle(context, null, context.getPackageManager(), packageName)) {
Log.v(TAG, "Package '" + packageName + "' should not use ANGLE");
return false;
}
final boolean useAngle = getShouldUseAngle(packageName);
Log.v(TAG, "Package '" + packageName + "' should use ANGLE = '" + useAngle + "'");
return useAngle;
}
/**
* Show the ANGLE in Use Dialog Box
* @param context
*/
public void showAngleInUseDialogBox(Context context) {
if (!shouldShowAngleInUseDialogBox(context)) {
return;
}
final String packageName = context.getPackageName();
if (!getShouldUseAngle(packageName)) {
return;
}
if (shouldShowAngleInUseDialogBox(context) && setupAndUseAngle(context, packageName)) {
final Intent intent = new Intent(ACTION_ANGLE_FOR_ANDROID_TOAST_MESSAGE);
String anglePkg = getAnglePackageName(context.getPackageManager());
intent.setPackage(anglePkg);
final Intent intent = new Intent(ACTION_ANGLE_FOR_ANDROID_TOAST_MESSAGE);
final String anglePkg = getAnglePackageName(context.getPackageManager());
intent.setPackage(anglePkg);
context.sendOrderedBroadcast(intent, null, new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
Bundle results = getResultExtras(true);
context.sendOrderedBroadcast(intent, null, new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
final Bundle results = getResultExtras(true);
String toastMsg = results.getString(INTENT_KEY_A4A_TOAST_MESSAGE);
final Toast toast = Toast.makeText(context, toastMsg, Toast.LENGTH_LONG);
toast.show();
}
}, null, Activity.RESULT_OK, null, null);
}
final String toastMsg = results.getString(INTENT_KEY_A4A_TOAST_MESSAGE);
final Toast toast = Toast.makeText(context, toastMsg, Toast.LENGTH_LONG);
toast.show();
}
}, null, Activity.RESULT_OK, null, null);
}
private String[] getAngleEglFeatures(Context context, Bundle coreSettings) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment