Loading src/com/android/server/telecom/InCallWakeLockController.java +9 −1 Original line number Diff line number Diff line Loading @@ -60,10 +60,18 @@ public class InCallWakeLockController extends CallsManagerListenerBase { handleWakeLock(); } @Override public void onExternalCallChanged(Call call, boolean isExternalCall) { // In case a call changes its external call state during ringing, we need to trigger // the wake lock update correspondingly. External call is handled by another device // and should not hold a wake lock on the local device. handleWakeLock(); } private void handleWakeLock() { // We grab a full lock as long as there exists a ringing call. Call ringingCall = mCallsManager.getRingingOrSimulatedRingingCall(); if (ringingCall != null) { if (ringingCall != null && !ringingCall.isExternalCall()) { mTelecomWakeLock.acquire(); Log.i(this, "Acquiring full wake lock"); } else { Loading tests/src/com/android/server/telecom/tests/InCallWakeLockControllerTest.java +31 −0 Original line number Diff line number Diff line Loading @@ -17,6 +17,7 @@ package com.android.server.telecom.tests; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.reset; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; import static org.mockito.Mockito.never; Loading Loading @@ -128,4 +129,34 @@ public class InCallWakeLockControllerTest extends TelecomTestCase { verify(mWakeLockAdapter, never()).acquire(); } @SmallTest @Test public void testExternalCallStateChangeDuringRinging() throws Exception { // A call is ringing on the local device directly. when(mCallsManager.getRingingOrSimulatedRingingCall()).thenReturn(mCall); when(mCall.isExternalCall()).thenReturn(false); mInCallWakeLockController.onCallAdded(mCall); verify(mWakeLockAdapter).acquire(); // The call then becomes an external call during ringing. The wake lock should be // released. reset(mWakeLockAdapter); when(mWakeLockAdapter.isHeld()).thenReturn(true); when(mCall.isExternalCall()).thenReturn(true); mInCallWakeLockController.onExternalCallChanged(mCall, /* isExternalCall= */ true); verify(mWakeLockAdapter).release(0); // The call then is pulled to the device, wake up the device and acquire the wake lock. reset(mWakeLockAdapter); when(mCall.isExternalCall()).thenReturn(false); mInCallWakeLockController.onExternalCallChanged(mCall, /* isExternalCall= */ true); verify(mWakeLockAdapter).acquire(); } } Loading
src/com/android/server/telecom/InCallWakeLockController.java +9 −1 Original line number Diff line number Diff line Loading @@ -60,10 +60,18 @@ public class InCallWakeLockController extends CallsManagerListenerBase { handleWakeLock(); } @Override public void onExternalCallChanged(Call call, boolean isExternalCall) { // In case a call changes its external call state during ringing, we need to trigger // the wake lock update correspondingly. External call is handled by another device // and should not hold a wake lock on the local device. handleWakeLock(); } private void handleWakeLock() { // We grab a full lock as long as there exists a ringing call. Call ringingCall = mCallsManager.getRingingOrSimulatedRingingCall(); if (ringingCall != null) { if (ringingCall != null && !ringingCall.isExternalCall()) { mTelecomWakeLock.acquire(); Log.i(this, "Acquiring full wake lock"); } else { Loading
tests/src/com/android/server/telecom/tests/InCallWakeLockControllerTest.java +31 −0 Original line number Diff line number Diff line Loading @@ -17,6 +17,7 @@ package com.android.server.telecom.tests; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.reset; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; import static org.mockito.Mockito.never; Loading Loading @@ -128,4 +129,34 @@ public class InCallWakeLockControllerTest extends TelecomTestCase { verify(mWakeLockAdapter, never()).acquire(); } @SmallTest @Test public void testExternalCallStateChangeDuringRinging() throws Exception { // A call is ringing on the local device directly. when(mCallsManager.getRingingOrSimulatedRingingCall()).thenReturn(mCall); when(mCall.isExternalCall()).thenReturn(false); mInCallWakeLockController.onCallAdded(mCall); verify(mWakeLockAdapter).acquire(); // The call then becomes an external call during ringing. The wake lock should be // released. reset(mWakeLockAdapter); when(mWakeLockAdapter.isHeld()).thenReturn(true); when(mCall.isExternalCall()).thenReturn(true); mInCallWakeLockController.onExternalCallChanged(mCall, /* isExternalCall= */ true); verify(mWakeLockAdapter).release(0); // The call then is pulled to the device, wake up the device and acquire the wake lock. reset(mWakeLockAdapter); when(mCall.isExternalCall()).thenReturn(false); mInCallWakeLockController.onExternalCallChanged(mCall, /* isExternalCall= */ true); verify(mWakeLockAdapter).acquire(); } }