Prevent race condition by foregroundAppPackageName

Create a local variable from the member variable so it cannot become
null part way through.

Bug: 235064663
Test: Builds
Change-Id: Id5d13ee105fc2c78327ff3ddb3839f6cbd99fbab
This commit is contained in:
Fiona Campbell
2022-08-16 09:44:34 +00:00
parent 83f3bbb832
commit dcc1f9d64e

View File

@@ -993,8 +993,9 @@ class AutomaticBrightnessController {
final String packageName = info.topActivity.getPackageName();
// If the app didn't change, there's nothing to do. Otherwise, we have to
// update the category and re-apply the brightness correction.
if (mForegroundAppPackageName != null
&& mForegroundAppPackageName.equals(packageName)) {
String currentForegroundAppPackageName = mForegroundAppPackageName;
if (currentForegroundAppPackageName != null
&& currentForegroundAppPackageName.equals(packageName)) {
return;
}
mPendingForegroundAppPackageName = packageName;