Loading src/java/com/android/internal/telephony/DeviceStateMonitor.java +26 −2 Original line number Diff line number Diff line Loading @@ -25,7 +25,7 @@ import android.content.Context; import android.content.Intent; import android.content.IntentFilter; import android.hardware.display.DisplayManager; import android.hardware.radio.V1_2.IndicationFilter; import android.hardware.radio.V1_5.IndicationFilter; import android.net.ConnectivityManager; import android.net.Network; import android.net.NetworkCapabilities; Loading Loading @@ -380,7 +380,6 @@ public class DeviceStateMonitor extends Handler { // 1. The device is charging. // 2. When the screen is on. // 3. When data tethering is on. // 4. When the update mode is IGNORE_SCREEN_OFF. if (mIsCharging || mIsScreenOn || mIsTetheringOn) { return false; } Loading @@ -389,6 +388,17 @@ public class DeviceStateMonitor extends Handler { return true; } /** * @return True if BarryingInfo update should be turned off. */ private boolean shouldTurnOffBarringInfo() { // We should not turn off BarringInfo update if one of the following condition is true. // 1. The device is charging. // 2. When the screen is on. // 3. When the tethering is on. return !(mIsCharging || mIsScreenOn || mIsTetheringOn); } /** * Set if Telephony need always report signal strength. * Loading Loading @@ -435,18 +445,22 @@ public class DeviceStateMonitor extends Handler { * @param state True if enabled/on, otherwise disabled/off. */ private void onUpdateDeviceState(int eventType, boolean state) { boolean shouldPollBarringInfo = false; switch (eventType) { case EVENT_SCREEN_STATE_CHANGED: if (mIsScreenOn == state) return; shouldPollBarringInfo = shouldTurnOffBarringInfo(); mIsScreenOn = state; break; case EVENT_CHARGING_STATE_CHANGED: if (mIsCharging == state) return; shouldPollBarringInfo = shouldTurnOffBarringInfo(); mIsCharging = state; sendDeviceState(CHARGING_STATE, mIsCharging); break; case EVENT_TETHERING_STATE_CHANGED: if (mIsTetheringOn == state) return; shouldPollBarringInfo = shouldTurnOffBarringInfo(); mIsTetheringOn = state; break; case EVENT_POWER_SAVE_MODE_CHANGED: Loading Loading @@ -499,7 +513,17 @@ public class DeviceStateMonitor extends Handler { newFilter |= IndicationFilter.PHYSICAL_CHANNEL_CONFIG; } if (!shouldTurnOffBarringInfo()) { newFilter |= IndicationFilter.BARRING_INFO; } setUnsolResponseFilter(newFilter, false); if (shouldPollBarringInfo) { if (DBG) log("Manually pull barring info...", true); // use a null message since we don't care of receiving response mPhone.mCi.getBarringInfo(null); } } /** Loading src/java/com/android/internal/telephony/RIL.java +28 −4 Original line number Diff line number Diff line Loading @@ -36,7 +36,6 @@ import android.hardware.radio.V1_0.HardwareConfigModem; import android.hardware.radio.V1_0.IRadio; import android.hardware.radio.V1_0.IccIo; import android.hardware.radio.V1_0.ImsSmsMessage; import android.hardware.radio.V1_0.IndicationFilter; import android.hardware.radio.V1_0.LceDataInfo; import android.hardware.radio.V1_0.MvnoType; import android.hardware.radio.V1_0.NvWriteItem; Loading @@ -52,6 +51,7 @@ import android.hardware.radio.V1_0.UusInfo; import android.hardware.radio.V1_4.CarrierRestrictionsWithPriority; import android.hardware.radio.V1_4.SimLockMultiSimPolicy; import android.hardware.radio.V1_5.AccessNetwork; import android.hardware.radio.V1_5.IndicationFilter; import android.hardware.radio.V1_5.RadioAccessNetworks; import android.hardware.radio.deprecated.V1_0.IOemHook; import android.net.InetAddresses; Loading Loading @@ -189,6 +189,19 @@ public class RIL extends BaseCommands implements CommandsInterface { // IRadio version private HalVersion mRadioVersion = RADIO_HAL_VERSION_UNKNOWN; private static final int INDICATION_FILTERS_ALL_V1_0 = IndicationFilter.SIGNAL_STRENGTH | IndicationFilter.FULL_NETWORK_STATE | IndicationFilter.DATA_CALL_DORMANCY_CHANGED; private static final int INDICATION_FILTERS_ALL_V1_2 = INDICATION_FILTERS_ALL_V1_0 | IndicationFilter.LINK_CAPACITY_ESTIMATE | IndicationFilter.PHYSICAL_CHANNEL_CONFIG; private static final int INDICATION_FILTERS_ALL_V1_5 = INDICATION_FILTERS_ALL_V1_2 | IndicationFilter.REGISTRATION_FAILURE | IndicationFilter.BARRING_INFO; //***** Instance Variables @UnsupportedAppUsage Loading Loading @@ -4633,19 +4646,30 @@ public class RIL extends BaseCommands implements CommandsInterface { riljLog(rr.serialString() + "> " + requestToString(rr.mRequest) + " " + filter); } if (mRadioVersion.greaterOrEqual(RADIO_HAL_VERSION_1_2)) { if (mRadioVersion.greaterOrEqual(RADIO_HAL_VERSION_1_5)) { try { android.hardware.radio.V1_5.IRadio radioProxy15 = (android.hardware.radio.V1_5.IRadio) radioProxy; filter &= INDICATION_FILTERS_ALL_V1_5; radioProxy15.setIndicationFilter_1_5(rr.mSerial, filter); } catch (RemoteException | RuntimeException e) { handleRadioProxyExceptionForRR(rr, "setIndicationFilter_1_5", e); } } else if (mRadioVersion.greaterOrEqual(RADIO_HAL_VERSION_1_2)) { try { android.hardware.radio.V1_2.IRadio radioProxy12 = (android.hardware.radio.V1_2.IRadio) radioProxy; filter &= INDICATION_FILTERS_ALL_V1_2; radioProxy12.setIndicationFilter_1_2(rr.mSerial, filter); } catch (RemoteException | RuntimeException e) { handleRadioProxyExceptionForRR(rr, "setIndicationFilter_1_2", e); } } else { try { int filter10 = filter & IndicationFilter.ALL; radioProxy.setIndicationFilter(rr.mSerial, filter10); filter &= INDICATION_FILTERS_ALL_V1_0; radioProxy.setIndicationFilter(rr.mSerial, filter); } catch (RemoteException | RuntimeException e) { handleRadioProxyExceptionForRR(rr, "setIndicationFilter", e); } Loading tests/telephonytests/src/com/android/internal/telephony/DeviceStateMonitorTest.java +33 −4 Original line number Diff line number Diff line Loading @@ -20,7 +20,7 @@ import static android.hardware.radio.V1_0.DeviceStateType.LOW_DATA_EXPECTED; import static android.hardware.radio.V1_0.DeviceStateType.POWER_SAVE_MODE; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; import static org.junit.Assert.assertNotEquals; import static org.mockito.Matchers.anyBoolean; import static org.mockito.Matchers.anyInt; import static org.mockito.Matchers.eq; Loading @@ -33,7 +33,7 @@ import static java.util.Arrays.asList; import android.annotation.IntDef; import android.content.Intent; import android.hardware.radio.V1_2.IndicationFilter; import android.hardware.radio.V1_5.IndicationFilter; import android.net.ConnectivityManager; import android.os.BatteryManager; import android.os.Message; Loading Loading @@ -65,7 +65,8 @@ public class DeviceStateMonitorTest extends TelephonyTest { | IndicationFilter.FULL_NETWORK_STATE | IndicationFilter.DATA_CALL_DORMANCY_CHANGED | IndicationFilter.LINK_CAPACITY_ESTIMATE | IndicationFilter.PHYSICAL_CHANNEL_CONFIG; | IndicationFilter.PHYSICAL_CHANNEL_CONFIG | IndicationFilter.BARRING_INFO; // INDICATION_FILTERS_ALL but excludes Indication.SIGNAL_STRENGTH private static final int INDICATION_FILTERS_WHEN_TETHERING_ON = Loading Loading @@ -193,7 +194,7 @@ public class DeviceStateMonitorTest extends TelephonyTest { ArgumentCaptor<Integer> acIndicationFilter = ArgumentCaptor.forClass(Integer.class); verify(mSimulatedCommandsVerifier).setUnsolResponseFilter( acIndicationFilter.capture(), nullable(Message.class)); assertTrue((acIndicationFilter.getValue() & indicationFilter) != 0); assertNotEquals((acIndicationFilter.getValue() & indicationFilter), 0); // Turn off the state again updateState(state, STATE_OFF); Loading Loading @@ -336,4 +337,32 @@ public class DeviceStateMonitorTest extends TelephonyTest { assertEquals( DeviceStateMonitor.CELL_INFO_INTERVAL_SHORT_MS, mDSM.computeCellInfoMinInterval()); } @Test public void testGetBarringInfo() { // At beginning, all states off. Now turn screen on updateState(STATE_TYPE_SCREEN, STATE_ON); ArgumentCaptor<Integer> acBarringInfo = ArgumentCaptor.forClass(Integer.class); verify(mSimulatedCommandsVerifier).setUnsolResponseFilter(acBarringInfo.capture(), nullable(Message.class)); assertNotEquals((acBarringInfo.getValue() & IndicationFilter.BARRING_INFO), 0); verify(mSimulatedCommandsVerifier).getBarringInfo(nullable(Message.class)); reset(mSimulatedCommandsVerifier); // Turn screen off updateState(STATE_TYPE_SCREEN, STATE_OFF); verify(mSimulatedCommandsVerifier, never()).getBarringInfo(nullable(Message.class)); verify(mSimulatedCommandsVerifier).setUnsolResponseFilter(acBarringInfo.capture(), nullable(Message.class)); assertEquals((acBarringInfo.getValue() & IndicationFilter.BARRING_INFO), 0); reset(mSimulatedCommandsVerifier); // Turn tethering on, then screen on, getBarringInfo() should only be called once updateState(STATE_TYPE_TETHERING, STATE_ON); updateState(STATE_TYPE_SCREEN, STATE_ON); verify(mSimulatedCommandsVerifier).getBarringInfo(nullable(Message.class)); } } tests/telephonytests/src/com/android/internal/telephony/SimulatedCommands.java +6 −0 Original line number Diff line number Diff line Loading @@ -2366,4 +2366,10 @@ public class SimulatedCommands extends BaseCommands public Handler getHandler() { return mHandlerThread.getThreadHandler(); } @Override public void getBarringInfo(Message result) { SimulatedCommandsVerifier.getInstance().getBarringInfo(result); resultSuccess(result, null); } } tests/telephonytests/src/com/android/internal/telephony/SimulatedCommandsVerifier.java +4 −0 Original line number Diff line number Diff line Loading @@ -1454,4 +1454,8 @@ public class SimulatedCommandsVerifier implements CommandsInterface { @Override public void unregisterUiccApplicationEnablementChanged(Handler h) {} @Override public void getBarringInfo(Message result) { } } Loading
src/java/com/android/internal/telephony/DeviceStateMonitor.java +26 −2 Original line number Diff line number Diff line Loading @@ -25,7 +25,7 @@ import android.content.Context; import android.content.Intent; import android.content.IntentFilter; import android.hardware.display.DisplayManager; import android.hardware.radio.V1_2.IndicationFilter; import android.hardware.radio.V1_5.IndicationFilter; import android.net.ConnectivityManager; import android.net.Network; import android.net.NetworkCapabilities; Loading Loading @@ -380,7 +380,6 @@ public class DeviceStateMonitor extends Handler { // 1. The device is charging. // 2. When the screen is on. // 3. When data tethering is on. // 4. When the update mode is IGNORE_SCREEN_OFF. if (mIsCharging || mIsScreenOn || mIsTetheringOn) { return false; } Loading @@ -389,6 +388,17 @@ public class DeviceStateMonitor extends Handler { return true; } /** * @return True if BarryingInfo update should be turned off. */ private boolean shouldTurnOffBarringInfo() { // We should not turn off BarringInfo update if one of the following condition is true. // 1. The device is charging. // 2. When the screen is on. // 3. When the tethering is on. return !(mIsCharging || mIsScreenOn || mIsTetheringOn); } /** * Set if Telephony need always report signal strength. * Loading Loading @@ -435,18 +445,22 @@ public class DeviceStateMonitor extends Handler { * @param state True if enabled/on, otherwise disabled/off. */ private void onUpdateDeviceState(int eventType, boolean state) { boolean shouldPollBarringInfo = false; switch (eventType) { case EVENT_SCREEN_STATE_CHANGED: if (mIsScreenOn == state) return; shouldPollBarringInfo = shouldTurnOffBarringInfo(); mIsScreenOn = state; break; case EVENT_CHARGING_STATE_CHANGED: if (mIsCharging == state) return; shouldPollBarringInfo = shouldTurnOffBarringInfo(); mIsCharging = state; sendDeviceState(CHARGING_STATE, mIsCharging); break; case EVENT_TETHERING_STATE_CHANGED: if (mIsTetheringOn == state) return; shouldPollBarringInfo = shouldTurnOffBarringInfo(); mIsTetheringOn = state; break; case EVENT_POWER_SAVE_MODE_CHANGED: Loading Loading @@ -499,7 +513,17 @@ public class DeviceStateMonitor extends Handler { newFilter |= IndicationFilter.PHYSICAL_CHANNEL_CONFIG; } if (!shouldTurnOffBarringInfo()) { newFilter |= IndicationFilter.BARRING_INFO; } setUnsolResponseFilter(newFilter, false); if (shouldPollBarringInfo) { if (DBG) log("Manually pull barring info...", true); // use a null message since we don't care of receiving response mPhone.mCi.getBarringInfo(null); } } /** Loading
src/java/com/android/internal/telephony/RIL.java +28 −4 Original line number Diff line number Diff line Loading @@ -36,7 +36,6 @@ import android.hardware.radio.V1_0.HardwareConfigModem; import android.hardware.radio.V1_0.IRadio; import android.hardware.radio.V1_0.IccIo; import android.hardware.radio.V1_0.ImsSmsMessage; import android.hardware.radio.V1_0.IndicationFilter; import android.hardware.radio.V1_0.LceDataInfo; import android.hardware.radio.V1_0.MvnoType; import android.hardware.radio.V1_0.NvWriteItem; Loading @@ -52,6 +51,7 @@ import android.hardware.radio.V1_0.UusInfo; import android.hardware.radio.V1_4.CarrierRestrictionsWithPriority; import android.hardware.radio.V1_4.SimLockMultiSimPolicy; import android.hardware.radio.V1_5.AccessNetwork; import android.hardware.radio.V1_5.IndicationFilter; import android.hardware.radio.V1_5.RadioAccessNetworks; import android.hardware.radio.deprecated.V1_0.IOemHook; import android.net.InetAddresses; Loading Loading @@ -189,6 +189,19 @@ public class RIL extends BaseCommands implements CommandsInterface { // IRadio version private HalVersion mRadioVersion = RADIO_HAL_VERSION_UNKNOWN; private static final int INDICATION_FILTERS_ALL_V1_0 = IndicationFilter.SIGNAL_STRENGTH | IndicationFilter.FULL_NETWORK_STATE | IndicationFilter.DATA_CALL_DORMANCY_CHANGED; private static final int INDICATION_FILTERS_ALL_V1_2 = INDICATION_FILTERS_ALL_V1_0 | IndicationFilter.LINK_CAPACITY_ESTIMATE | IndicationFilter.PHYSICAL_CHANNEL_CONFIG; private static final int INDICATION_FILTERS_ALL_V1_5 = INDICATION_FILTERS_ALL_V1_2 | IndicationFilter.REGISTRATION_FAILURE | IndicationFilter.BARRING_INFO; //***** Instance Variables @UnsupportedAppUsage Loading Loading @@ -4633,19 +4646,30 @@ public class RIL extends BaseCommands implements CommandsInterface { riljLog(rr.serialString() + "> " + requestToString(rr.mRequest) + " " + filter); } if (mRadioVersion.greaterOrEqual(RADIO_HAL_VERSION_1_2)) { if (mRadioVersion.greaterOrEqual(RADIO_HAL_VERSION_1_5)) { try { android.hardware.radio.V1_5.IRadio radioProxy15 = (android.hardware.radio.V1_5.IRadio) radioProxy; filter &= INDICATION_FILTERS_ALL_V1_5; radioProxy15.setIndicationFilter_1_5(rr.mSerial, filter); } catch (RemoteException | RuntimeException e) { handleRadioProxyExceptionForRR(rr, "setIndicationFilter_1_5", e); } } else if (mRadioVersion.greaterOrEqual(RADIO_HAL_VERSION_1_2)) { try { android.hardware.radio.V1_2.IRadio radioProxy12 = (android.hardware.radio.V1_2.IRadio) radioProxy; filter &= INDICATION_FILTERS_ALL_V1_2; radioProxy12.setIndicationFilter_1_2(rr.mSerial, filter); } catch (RemoteException | RuntimeException e) { handleRadioProxyExceptionForRR(rr, "setIndicationFilter_1_2", e); } } else { try { int filter10 = filter & IndicationFilter.ALL; radioProxy.setIndicationFilter(rr.mSerial, filter10); filter &= INDICATION_FILTERS_ALL_V1_0; radioProxy.setIndicationFilter(rr.mSerial, filter); } catch (RemoteException | RuntimeException e) { handleRadioProxyExceptionForRR(rr, "setIndicationFilter", e); } Loading
tests/telephonytests/src/com/android/internal/telephony/DeviceStateMonitorTest.java +33 −4 Original line number Diff line number Diff line Loading @@ -20,7 +20,7 @@ import static android.hardware.radio.V1_0.DeviceStateType.LOW_DATA_EXPECTED; import static android.hardware.radio.V1_0.DeviceStateType.POWER_SAVE_MODE; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; import static org.junit.Assert.assertNotEquals; import static org.mockito.Matchers.anyBoolean; import static org.mockito.Matchers.anyInt; import static org.mockito.Matchers.eq; Loading @@ -33,7 +33,7 @@ import static java.util.Arrays.asList; import android.annotation.IntDef; import android.content.Intent; import android.hardware.radio.V1_2.IndicationFilter; import android.hardware.radio.V1_5.IndicationFilter; import android.net.ConnectivityManager; import android.os.BatteryManager; import android.os.Message; Loading Loading @@ -65,7 +65,8 @@ public class DeviceStateMonitorTest extends TelephonyTest { | IndicationFilter.FULL_NETWORK_STATE | IndicationFilter.DATA_CALL_DORMANCY_CHANGED | IndicationFilter.LINK_CAPACITY_ESTIMATE | IndicationFilter.PHYSICAL_CHANNEL_CONFIG; | IndicationFilter.PHYSICAL_CHANNEL_CONFIG | IndicationFilter.BARRING_INFO; // INDICATION_FILTERS_ALL but excludes Indication.SIGNAL_STRENGTH private static final int INDICATION_FILTERS_WHEN_TETHERING_ON = Loading Loading @@ -193,7 +194,7 @@ public class DeviceStateMonitorTest extends TelephonyTest { ArgumentCaptor<Integer> acIndicationFilter = ArgumentCaptor.forClass(Integer.class); verify(mSimulatedCommandsVerifier).setUnsolResponseFilter( acIndicationFilter.capture(), nullable(Message.class)); assertTrue((acIndicationFilter.getValue() & indicationFilter) != 0); assertNotEquals((acIndicationFilter.getValue() & indicationFilter), 0); // Turn off the state again updateState(state, STATE_OFF); Loading Loading @@ -336,4 +337,32 @@ public class DeviceStateMonitorTest extends TelephonyTest { assertEquals( DeviceStateMonitor.CELL_INFO_INTERVAL_SHORT_MS, mDSM.computeCellInfoMinInterval()); } @Test public void testGetBarringInfo() { // At beginning, all states off. Now turn screen on updateState(STATE_TYPE_SCREEN, STATE_ON); ArgumentCaptor<Integer> acBarringInfo = ArgumentCaptor.forClass(Integer.class); verify(mSimulatedCommandsVerifier).setUnsolResponseFilter(acBarringInfo.capture(), nullable(Message.class)); assertNotEquals((acBarringInfo.getValue() & IndicationFilter.BARRING_INFO), 0); verify(mSimulatedCommandsVerifier).getBarringInfo(nullable(Message.class)); reset(mSimulatedCommandsVerifier); // Turn screen off updateState(STATE_TYPE_SCREEN, STATE_OFF); verify(mSimulatedCommandsVerifier, never()).getBarringInfo(nullable(Message.class)); verify(mSimulatedCommandsVerifier).setUnsolResponseFilter(acBarringInfo.capture(), nullable(Message.class)); assertEquals((acBarringInfo.getValue() & IndicationFilter.BARRING_INFO), 0); reset(mSimulatedCommandsVerifier); // Turn tethering on, then screen on, getBarringInfo() should only be called once updateState(STATE_TYPE_TETHERING, STATE_ON); updateState(STATE_TYPE_SCREEN, STATE_ON); verify(mSimulatedCommandsVerifier).getBarringInfo(nullable(Message.class)); } }
tests/telephonytests/src/com/android/internal/telephony/SimulatedCommands.java +6 −0 Original line number Diff line number Diff line Loading @@ -2366,4 +2366,10 @@ public class SimulatedCommands extends BaseCommands public Handler getHandler() { return mHandlerThread.getThreadHandler(); } @Override public void getBarringInfo(Message result) { SimulatedCommandsVerifier.getInstance().getBarringInfo(result); resultSuccess(result, null); } }
tests/telephonytests/src/com/android/internal/telephony/SimulatedCommandsVerifier.java +4 −0 Original line number Diff line number Diff line Loading @@ -1454,4 +1454,8 @@ public class SimulatedCommandsVerifier implements CommandsInterface { @Override public void unregisterUiccApplicationEnablementChanged(Handler h) {} @Override public void getBarringInfo(Message result) { } }