Skip to content
Commit 2744b19f authored by Peter Collingbourne's avatar Peter Collingbourne
Browse files

Add missing null check for mBatteryPercentView.

On an emulated device without a battery we've observed a
NullPointerException coming from a call to setText() on a null
mBatteryPercentView:

FATAL EXCEPTION: main
Process: com.android.systemui, PID: 4234
java.lang.NullPointerException: Attempt to invoke virtual method 'void android.widget.TextView.setText(java.lang.CharSequence)' on a null object reference
        at com.android.systemui.BatteryMeterView.setPercentTextAtCurrentLevel(BatteryMeterView.java:380)
        at com.android.systemui.BatteryMeterView.lambda$updatePercentText$0(BatteryMeterView.java:366)
        at com.android.systemui.BatteryMeterView.lambda$updatePercentText$0$BatteryMeterView(Unknown Source:0)
        at com.android.systemui.-$$Lambda$BatteryMeterView$tE-TUFngFnD6fsDmUpqJf1miV_U.onBatteryRemainingEstimateRetrieved(Unknown Source:2)
        at com.android.systemui.statusbar.policy.BatteryControllerImpl.notifyEstimateFetchCallbacks(BatteryControllerImpl.java:308)
        at com.android.systemui.statusbar.policy.BatteryControllerImpl.lambda$0VzGTjPGwGKStizyJuiiH2rMVVk(Unknown Source:0)
        at com.android.systemui.statusbar.policy.-$$Lambda$BatteryControllerImpl$0VzGTjPGwGKStizyJuiiH2rMVVk.run(Unknown Source:2)

It seems that it's possible for the battery meter to enter the
hidden percentage state in between the check in updatePercentText()
and the lambda callback. Guard against that possibility with
a null check in the lambda.

Bug: 178231152
Change-Id: Ia805a1a8497d4ad4f99c2864e17a88d46690d471
parent 04d9bf62
Loading
Loading
Loading
Loading
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