Merge "Prevent crash when switching displays with screen off" into sc-v2-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
0e79969bd4
@@ -1585,6 +1585,13 @@ public class NavigationBar implements View.OnAttachStateChangeListener,
|
|||||||
private final BroadcastReceiver mBroadcastReceiver = new BroadcastReceiver() {
|
private final BroadcastReceiver mBroadcastReceiver = new BroadcastReceiver() {
|
||||||
@Override
|
@Override
|
||||||
public void onReceive(Context context, Intent intent) {
|
public void onReceive(Context context, Intent intent) {
|
||||||
|
// This receiver is unregistered when the view is detached, but on devices with multiple
|
||||||
|
// displays, it can sometimes still receive an ACTION_SCREEN_ON/ACTION_SCREEN_OFF on
|
||||||
|
// display switch, after it was detached, so this null check ensures no crash in that
|
||||||
|
// scenario.
|
||||||
|
if (mNavigationBarView == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
String action = intent.getAction();
|
String action = intent.getAction();
|
||||||
if (Intent.ACTION_SCREEN_OFF.equals(action)
|
if (Intent.ACTION_SCREEN_OFF.equals(action)
|
||||||
|| Intent.ACTION_SCREEN_ON.equals(action)) {
|
|| Intent.ACTION_SCREEN_ON.equals(action)) {
|
||||||
|
|||||||
Reference in New Issue
Block a user