OSDN Git Service

Fix null pointer error && add settings side guard
authorSalvador Martinez <dehboxturtle@google.com>
Fri, 5 May 2017 18:04:49 +0000 (11:04 -0700)
committerSalvador Martinez <dehboxturtle@google.com>
Mon, 8 May 2017 23:39:38 +0000 (16:39 -0700)
commit52aa68f7045aec88a35a506c94038122d2175237
tree1e9e35ec76b95cfc40a6545d05bc7f7c5c0b8e00
parent3dea2a9654442ff73514d5d211a4f00c14d693ec
Fix null pointer error && add settings side guard

The null check for the cursor happens in the try block
which causes a null pointer error in the finally block
even though we avoid executing the other code because
we still try to close the cursor. This change moves
that outside of the try block to avoid that. Also added
a test to verify that a no-op occurs in the method that
uses the enhanced prediction that would have caught this.

Additionally, the method for checking if the enhanced
prediction was available was not being called in Settings.
This CL adds that check and a relevant tests to ensure it
is respected.

Test: Robotests
Bug: 38031439
Change-Id: I6924acb5552baf09a9ff0cdef8e30881115aa1ca
src/com/android/settings/fuelgauge/PowerUsageSummary.java
tests/robotests/src/com/android/settings/fuelgauge/PowerUsageSummaryTest.java