Merge "ThermalManagerService: only update thermal status for SKIN type thermistor"
This commit is contained in:
committed by
Android (Google) Code Review
commit
6f608f1770
@@ -200,7 +200,7 @@ public class ThermalManagerService extends SystemService {
|
||||
final int count = mTemperatureMap.size();
|
||||
for (int i = 0; i < count; i++) {
|
||||
Temperature t = mTemperatureMap.valueAt(i);
|
||||
if (t.getStatus() >= newStatus) {
|
||||
if (t.getType() == Temperature.TYPE_SKIN && t.getStatus() >= newStatus) {
|
||||
newStatus = t.getStatus();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -284,28 +284,29 @@ public class ThermalManagerServiceTest {
|
||||
@Test
|
||||
public void testNotify() throws RemoteException {
|
||||
int status = Temperature.THROTTLING_SEVERE;
|
||||
// Should only notify event not status
|
||||
Temperature newBattery = new Temperature(50, Temperature.TYPE_BATTERY, "batt", status);
|
||||
mFakeHal.mCallback.onValues(newBattery);
|
||||
verify(mEventListener1, timeout(CALLBACK_TIMEOUT_MILLI_SEC)
|
||||
.times(1)).notifyThrottling(newBattery);
|
||||
verify(mStatusListener1, timeout(CALLBACK_TIMEOUT_MILLI_SEC)
|
||||
.times(1)).onStatusChange(status);
|
||||
.times(0)).onStatusChange(anyInt());
|
||||
verify(mEventListener2, timeout(CALLBACK_TIMEOUT_MILLI_SEC)
|
||||
.times(0)).notifyThrottling(newBattery);
|
||||
verify(mStatusListener2, timeout(CALLBACK_TIMEOUT_MILLI_SEC)
|
||||
.times(1)).onStatusChange(status);
|
||||
.times(0)).onStatusChange(anyInt());
|
||||
resetListenerMock();
|
||||
// Should only notify event not status
|
||||
// Notify both event and status
|
||||
Temperature newSkin = new Temperature(50, Temperature.TYPE_SKIN, "skin1", status);
|
||||
mFakeHal.mCallback.onValues(newSkin);
|
||||
verify(mEventListener1, timeout(CALLBACK_TIMEOUT_MILLI_SEC)
|
||||
.times(1)).notifyThrottling(newSkin);
|
||||
verify(mStatusListener1, timeout(CALLBACK_TIMEOUT_MILLI_SEC)
|
||||
.times(0)).onStatusChange(anyInt());
|
||||
.times(1)).onStatusChange(status);
|
||||
verify(mEventListener2, timeout(CALLBACK_TIMEOUT_MILLI_SEC)
|
||||
.times(1)).notifyThrottling(newSkin);
|
||||
verify(mStatusListener2, timeout(CALLBACK_TIMEOUT_MILLI_SEC)
|
||||
.times(0)).onStatusChange(anyInt());
|
||||
.times(1)).onStatusChange(status);
|
||||
resetListenerMock();
|
||||
// Back to None, should only notify event not status
|
||||
status = Temperature.THROTTLING_NONE;
|
||||
@@ -345,10 +346,13 @@ public class ThermalManagerServiceTest {
|
||||
|
||||
@Test
|
||||
public void testGetCurrentStatus() throws RemoteException {
|
||||
int status = Temperature.THROTTLING_EMERGENCY;
|
||||
int status = Temperature.THROTTLING_SEVERE;
|
||||
Temperature newSkin = new Temperature(100, Temperature.TYPE_SKIN, "skin1", status);
|
||||
mFakeHal.mCallback.onValues(newSkin);
|
||||
assertEquals(status, mService.mService.getCurrentThermalStatus());
|
||||
int battStatus = Temperature.THROTTLING_EMERGENCY;
|
||||
Temperature newBattery = new Temperature(60, Temperature.TYPE_BATTERY, "batt", battStatus);
|
||||
assertEquals(status, mService.mService.getCurrentThermalStatus());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
Reference in New Issue
Block a user