Loading src/java/com/android/internal/telephony/satellite/PointingAppController.java +14 −12 Original line number Diff line number Diff line Loading @@ -62,6 +62,8 @@ public class PointingAppController { @NonNull private final Context mContext; private boolean mStartedSatelliteTransmissionUpdates; private boolean mLastNeedFullScreenPointingUI; private boolean mLastIsDemoMode; private boolean mLastIsEmergency; private boolean mListenerForPointingUIRegistered; @NonNull private String mPointingUiPackageName = ""; @NonNull private String mPointingUiClassName = ""; Loading Loading @@ -105,6 +107,8 @@ public class PointingAppController { mContext = context; mStartedSatelliteTransmissionUpdates = false; mLastNeedFullScreenPointingUI = false; mLastIsDemoMode = false; mLastIsEmergency = false; mListenerForPointingUIRegistered = false; mActivityManager = mContext.getSystemService(ActivityManager.class); } Loading @@ -129,15 +133,6 @@ public class PointingAppController { return mStartedSatelliteTransmissionUpdates; } /** * Get the flag mStartedSatelliteTransmissionUpdates * @return returns mStartedSatelliteTransmissionUpdates */ @VisibleForTesting public boolean getLastNeedFullScreenPointingUI() { return mLastNeedFullScreenPointingUI; } /** * Listener for handling pointing UI App in the event of crash */ Loading @@ -153,7 +148,8 @@ public class PointingAppController { if (callerPackages != null) { if (Arrays.stream(callerPackages).anyMatch(pointingUiPackage::contains)) { logd("Restarting pointingUI"); startPointingUI(mLastNeedFullScreenPointingUI); startPointingUI(mLastNeedFullScreenPointingUI, mLastIsDemoMode, mLastIsEmergency); } } } Loading Loading @@ -359,7 +355,8 @@ public class PointingAppController { * Check if Pointing is needed and Launch Pointing UI * @param needFullScreenPointingUI if pointing UI has to be launchd with Full screen */ public void startPointingUI(boolean needFullScreenPointingUI) { public void startPointingUI(boolean needFullScreenPointingUI, boolean isDemoMode, boolean isEmergency) { String packageName = getPointingUiPackageName(); if (TextUtils.isEmpty(packageName)) { logd("startPointingUI: config_pointing_ui_package is not set. Ignore the request"); Loading @@ -379,8 +376,11 @@ public class PointingAppController { loge("startPointingUI: launchIntent is null"); return; } logd("startPointingUI: needFullScreenPointingUI: " + needFullScreenPointingUI); logd("startPointingUI: needFullScreenPointingUI: " + needFullScreenPointingUI + ", isDemoMode: " + isDemoMode + ", isEmergency: " + isEmergency); launchIntent.putExtra("needFullScreen", needFullScreenPointingUI); launchIntent.putExtra("isDemoMode", isDemoMode); launchIntent.putExtra("isEmergency", isEmergency); try { if (!mListenerForPointingUIRegistered) { Loading @@ -389,6 +389,8 @@ public class PointingAppController { mListenerForPointingUIRegistered = true; } mLastNeedFullScreenPointingUI = needFullScreenPointingUI; mLastIsDemoMode = isDemoMode; mLastIsEmergency = isEmergency; mContext.startActivity(launchIntent); } catch (ActivityNotFoundException ex) { loge("startPointingUI: Pointing UI app activity is not found, ex=" + ex); Loading src/java/com/android/internal/telephony/satellite/SatelliteController.java +6 −1 Original line number Diff line number Diff line Loading @@ -300,6 +300,7 @@ public class SatelliteController extends Handler { @GuardedBy("mIsSatelliteSupportedLock") private Boolean mIsSatelliteSupported = null; private boolean mIsDemoModeEnabled = false; private boolean mIsEmergency = false; private final Object mIsSatelliteEnabledLock = new Object(); @GuardedBy("mIsSatelliteEnabledLock") private Boolean mIsSatelliteEnabled = null; Loading Loading @@ -2007,7 +2008,9 @@ public class SatelliteController extends Handler { * TODO for NTN-based satellites: Check if satellite is acquired. */ if (mNeedsSatellitePointing) { mPointingAppController.startPointingUI(needFullScreenPointingUI); mPointingAppController.startPointingUI(needFullScreenPointingUI, mIsDemoModeEnabled, mIsEmergency); } final int validSubId = SatelliteServiceUtils.getValidSatelliteSubId(subId, mContext); Loading Loading @@ -3500,6 +3503,7 @@ public class SatelliteController extends Handler { && mWaitingForRadioDisabled) { logd("Sending success to callback that sent enable satellite request"); setDemoModeEnabled(mSatelliteEnabledRequest.enableDemoMode); mIsEmergency = mSatelliteEnabledRequest.isEmergency; synchronized (mIsSatelliteEnabledLock) { mIsSatelliteEnabled = mSatelliteEnabledRequest.enableSatellite; } Loading Loading @@ -3527,6 +3531,7 @@ public class SatelliteController extends Handler { synchronized (mIsSatelliteEnabledLock) { resetSatelliteEnabledRequest(); setDemoModeEnabled(false); mIsEmergency = false; mIsSatelliteEnabled = false; setSettingsKeyForSatelliteMode(SATELLITE_MODE_ENABLED_FALSE); if (callback != null) callback.accept(error); Loading tests/telephonytests/src/com/android/internal/telephony/satellite/PointingAppControllerTest.java +19 −6 Original line number Diff line number Diff line Loading @@ -76,6 +76,8 @@ public class PointingAppControllerTest extends TelephonyTest { private static final String KEY_POINTING_UI_PACKAGE_NAME = "default_pointing_ui_package"; private static final String KEY_POINTING_UI_CLASS_NAME = "default_pointing_ui_class"; private static final String KEY_NEED_FULL_SCREEN = "needFullScreen"; private static final String KEY_IS_DEMO_MODE = "isDemoMode"; private static final String KEY_IS_EMERGENCY = "isEmergency"; private PointingAppController mPointingAppController; InOrder mInOrder; Loading Loading @@ -312,7 +314,7 @@ public class PointingAppControllerTest extends TelephonyTest { @Test public void testStartPointingUI() throws Exception { ArgumentCaptor<Intent> startedIntentCaptor = ArgumentCaptor.forClass(Intent.class); mPointingAppController.startPointingUI(true); mPointingAppController.startPointingUI(true, true, true); verify(mContext).startActivity(startedIntentCaptor.capture()); Intent intent = startedIntentCaptor.getValue(); assertEquals(KEY_POINTING_UI_PACKAGE_NAME, intent.getComponent().getPackageName()); Loading @@ -320,19 +322,24 @@ public class PointingAppControllerTest extends TelephonyTest { Bundle b = intent.getExtras(); assertTrue(b.containsKey(KEY_NEED_FULL_SCREEN)); assertTrue(b.getBoolean(KEY_NEED_FULL_SCREEN)); assertTrue(b.containsKey(KEY_IS_DEMO_MODE)); assertTrue(b.getBoolean(KEY_IS_DEMO_MODE)); assertTrue(b.containsKey(KEY_IS_EMERGENCY)); assertTrue(b.getBoolean(KEY_IS_EMERGENCY)); } @Test public void testRestartPointingUi() throws Exception { mPointingAppController.startPointingUI(true); mPointingAppController.startPointingUI(true, false, true); mInOrderForPointingUi.verify(mContext).startActivity(any(Intent.class)); testRestartPointingUi(true); mPointingAppController.startPointingUI(false); testRestartPointingUi(true, false, true); mPointingAppController.startPointingUI(false, true, false); mInOrderForPointingUi.verify(mContext).startActivity(any(Intent.class)); testRestartPointingUi(false); testRestartPointingUi(false, true, false); } private void testRestartPointingUi(boolean expectedFullScreen) { private void testRestartPointingUi(boolean expectedFullScreen, boolean expectedDemoMode, boolean expectedEmergency) { when(mContext.getPackageManager()).thenReturn(mPackageManager); doReturn(new String[]{KEY_POINTING_UI_PACKAGE_NAME}).when(mPackageManager) .getPackagesForUid(anyInt()); Loading @@ -346,6 +353,12 @@ public class PointingAppControllerTest extends TelephonyTest { assertTrue(b.containsKey(KEY_NEED_FULL_SCREEN)); // Checking if last value of KEY_NEED_FULL_SCREEN is taken or not assertEquals(expectedFullScreen, b.getBoolean(KEY_NEED_FULL_SCREEN)); assertTrue(b.containsKey(KEY_IS_DEMO_MODE)); // Checking if last value of KEY_IS_DEMO_MODE is taken or not assertEquals(expectedDemoMode, b.getBoolean(KEY_IS_DEMO_MODE)); assertTrue(b.containsKey(KEY_IS_EMERGENCY)); // Checking if last value of KEY_IS_EMERGENCY is taken or not assertEquals(expectedEmergency, b.getBoolean(KEY_IS_EMERGENCY)); } @Test Loading tests/telephonytests/src/com/android/internal/telephony/satellite/SatelliteControllerTest.java +4 −2 Original line number Diff line number Diff line Loading @@ -841,7 +841,8 @@ public class SatelliteControllerTest extends TelephonyTest { assertTrue(waitForIIntegerConsumerResult(1)); assertEquals(SATELLITE_RESULT_INVALID_MODEM_STATE, (long) mIIntegerConsumerResults.get(0)); verifySatelliteEnabled(false, SATELLITE_RESULT_SUCCESS); verify(mMockPointingAppController, never()).startPointingUI(anyBoolean()); verify(mMockPointingAppController, never()).startPointingUI(anyBoolean(), anyBoolean(), anyBoolean()); assertFalse(mSatelliteControllerUT.setSettingsKeyForSatelliteModeCalled); verify(mMockControllerMetricsStats, times(1)).reportServiceEnablementFailCount(); Loading Loading @@ -1451,7 +1452,8 @@ public class SatelliteControllerTest extends TelephonyTest { verify(mMockDatagramController, times(1)).sendSatelliteDatagram(anyInt(), eq(SatelliteManager.DATAGRAM_TYPE_SOS_MESSAGE), eq(datagram), eq(true), any()); verify(mMockPointingAppController, times(1)).startPointingUI(eq(true)); verify(mMockPointingAppController, times(1)).startPointingUI(eq(true), anyBoolean(), anyBoolean()); } @Test Loading Loading
src/java/com/android/internal/telephony/satellite/PointingAppController.java +14 −12 Original line number Diff line number Diff line Loading @@ -62,6 +62,8 @@ public class PointingAppController { @NonNull private final Context mContext; private boolean mStartedSatelliteTransmissionUpdates; private boolean mLastNeedFullScreenPointingUI; private boolean mLastIsDemoMode; private boolean mLastIsEmergency; private boolean mListenerForPointingUIRegistered; @NonNull private String mPointingUiPackageName = ""; @NonNull private String mPointingUiClassName = ""; Loading Loading @@ -105,6 +107,8 @@ public class PointingAppController { mContext = context; mStartedSatelliteTransmissionUpdates = false; mLastNeedFullScreenPointingUI = false; mLastIsDemoMode = false; mLastIsEmergency = false; mListenerForPointingUIRegistered = false; mActivityManager = mContext.getSystemService(ActivityManager.class); } Loading @@ -129,15 +133,6 @@ public class PointingAppController { return mStartedSatelliteTransmissionUpdates; } /** * Get the flag mStartedSatelliteTransmissionUpdates * @return returns mStartedSatelliteTransmissionUpdates */ @VisibleForTesting public boolean getLastNeedFullScreenPointingUI() { return mLastNeedFullScreenPointingUI; } /** * Listener for handling pointing UI App in the event of crash */ Loading @@ -153,7 +148,8 @@ public class PointingAppController { if (callerPackages != null) { if (Arrays.stream(callerPackages).anyMatch(pointingUiPackage::contains)) { logd("Restarting pointingUI"); startPointingUI(mLastNeedFullScreenPointingUI); startPointingUI(mLastNeedFullScreenPointingUI, mLastIsDemoMode, mLastIsEmergency); } } } Loading Loading @@ -359,7 +355,8 @@ public class PointingAppController { * Check if Pointing is needed and Launch Pointing UI * @param needFullScreenPointingUI if pointing UI has to be launchd with Full screen */ public void startPointingUI(boolean needFullScreenPointingUI) { public void startPointingUI(boolean needFullScreenPointingUI, boolean isDemoMode, boolean isEmergency) { String packageName = getPointingUiPackageName(); if (TextUtils.isEmpty(packageName)) { logd("startPointingUI: config_pointing_ui_package is not set. Ignore the request"); Loading @@ -379,8 +376,11 @@ public class PointingAppController { loge("startPointingUI: launchIntent is null"); return; } logd("startPointingUI: needFullScreenPointingUI: " + needFullScreenPointingUI); logd("startPointingUI: needFullScreenPointingUI: " + needFullScreenPointingUI + ", isDemoMode: " + isDemoMode + ", isEmergency: " + isEmergency); launchIntent.putExtra("needFullScreen", needFullScreenPointingUI); launchIntent.putExtra("isDemoMode", isDemoMode); launchIntent.putExtra("isEmergency", isEmergency); try { if (!mListenerForPointingUIRegistered) { Loading @@ -389,6 +389,8 @@ public class PointingAppController { mListenerForPointingUIRegistered = true; } mLastNeedFullScreenPointingUI = needFullScreenPointingUI; mLastIsDemoMode = isDemoMode; mLastIsEmergency = isEmergency; mContext.startActivity(launchIntent); } catch (ActivityNotFoundException ex) { loge("startPointingUI: Pointing UI app activity is not found, ex=" + ex); Loading
src/java/com/android/internal/telephony/satellite/SatelliteController.java +6 −1 Original line number Diff line number Diff line Loading @@ -300,6 +300,7 @@ public class SatelliteController extends Handler { @GuardedBy("mIsSatelliteSupportedLock") private Boolean mIsSatelliteSupported = null; private boolean mIsDemoModeEnabled = false; private boolean mIsEmergency = false; private final Object mIsSatelliteEnabledLock = new Object(); @GuardedBy("mIsSatelliteEnabledLock") private Boolean mIsSatelliteEnabled = null; Loading Loading @@ -2007,7 +2008,9 @@ public class SatelliteController extends Handler { * TODO for NTN-based satellites: Check if satellite is acquired. */ if (mNeedsSatellitePointing) { mPointingAppController.startPointingUI(needFullScreenPointingUI); mPointingAppController.startPointingUI(needFullScreenPointingUI, mIsDemoModeEnabled, mIsEmergency); } final int validSubId = SatelliteServiceUtils.getValidSatelliteSubId(subId, mContext); Loading Loading @@ -3500,6 +3503,7 @@ public class SatelliteController extends Handler { && mWaitingForRadioDisabled) { logd("Sending success to callback that sent enable satellite request"); setDemoModeEnabled(mSatelliteEnabledRequest.enableDemoMode); mIsEmergency = mSatelliteEnabledRequest.isEmergency; synchronized (mIsSatelliteEnabledLock) { mIsSatelliteEnabled = mSatelliteEnabledRequest.enableSatellite; } Loading Loading @@ -3527,6 +3531,7 @@ public class SatelliteController extends Handler { synchronized (mIsSatelliteEnabledLock) { resetSatelliteEnabledRequest(); setDemoModeEnabled(false); mIsEmergency = false; mIsSatelliteEnabled = false; setSettingsKeyForSatelliteMode(SATELLITE_MODE_ENABLED_FALSE); if (callback != null) callback.accept(error); Loading
tests/telephonytests/src/com/android/internal/telephony/satellite/PointingAppControllerTest.java +19 −6 Original line number Diff line number Diff line Loading @@ -76,6 +76,8 @@ public class PointingAppControllerTest extends TelephonyTest { private static final String KEY_POINTING_UI_PACKAGE_NAME = "default_pointing_ui_package"; private static final String KEY_POINTING_UI_CLASS_NAME = "default_pointing_ui_class"; private static final String KEY_NEED_FULL_SCREEN = "needFullScreen"; private static final String KEY_IS_DEMO_MODE = "isDemoMode"; private static final String KEY_IS_EMERGENCY = "isEmergency"; private PointingAppController mPointingAppController; InOrder mInOrder; Loading Loading @@ -312,7 +314,7 @@ public class PointingAppControllerTest extends TelephonyTest { @Test public void testStartPointingUI() throws Exception { ArgumentCaptor<Intent> startedIntentCaptor = ArgumentCaptor.forClass(Intent.class); mPointingAppController.startPointingUI(true); mPointingAppController.startPointingUI(true, true, true); verify(mContext).startActivity(startedIntentCaptor.capture()); Intent intent = startedIntentCaptor.getValue(); assertEquals(KEY_POINTING_UI_PACKAGE_NAME, intent.getComponent().getPackageName()); Loading @@ -320,19 +322,24 @@ public class PointingAppControllerTest extends TelephonyTest { Bundle b = intent.getExtras(); assertTrue(b.containsKey(KEY_NEED_FULL_SCREEN)); assertTrue(b.getBoolean(KEY_NEED_FULL_SCREEN)); assertTrue(b.containsKey(KEY_IS_DEMO_MODE)); assertTrue(b.getBoolean(KEY_IS_DEMO_MODE)); assertTrue(b.containsKey(KEY_IS_EMERGENCY)); assertTrue(b.getBoolean(KEY_IS_EMERGENCY)); } @Test public void testRestartPointingUi() throws Exception { mPointingAppController.startPointingUI(true); mPointingAppController.startPointingUI(true, false, true); mInOrderForPointingUi.verify(mContext).startActivity(any(Intent.class)); testRestartPointingUi(true); mPointingAppController.startPointingUI(false); testRestartPointingUi(true, false, true); mPointingAppController.startPointingUI(false, true, false); mInOrderForPointingUi.verify(mContext).startActivity(any(Intent.class)); testRestartPointingUi(false); testRestartPointingUi(false, true, false); } private void testRestartPointingUi(boolean expectedFullScreen) { private void testRestartPointingUi(boolean expectedFullScreen, boolean expectedDemoMode, boolean expectedEmergency) { when(mContext.getPackageManager()).thenReturn(mPackageManager); doReturn(new String[]{KEY_POINTING_UI_PACKAGE_NAME}).when(mPackageManager) .getPackagesForUid(anyInt()); Loading @@ -346,6 +353,12 @@ public class PointingAppControllerTest extends TelephonyTest { assertTrue(b.containsKey(KEY_NEED_FULL_SCREEN)); // Checking if last value of KEY_NEED_FULL_SCREEN is taken or not assertEquals(expectedFullScreen, b.getBoolean(KEY_NEED_FULL_SCREEN)); assertTrue(b.containsKey(KEY_IS_DEMO_MODE)); // Checking if last value of KEY_IS_DEMO_MODE is taken or not assertEquals(expectedDemoMode, b.getBoolean(KEY_IS_DEMO_MODE)); assertTrue(b.containsKey(KEY_IS_EMERGENCY)); // Checking if last value of KEY_IS_EMERGENCY is taken or not assertEquals(expectedEmergency, b.getBoolean(KEY_IS_EMERGENCY)); } @Test Loading
tests/telephonytests/src/com/android/internal/telephony/satellite/SatelliteControllerTest.java +4 −2 Original line number Diff line number Diff line Loading @@ -841,7 +841,8 @@ public class SatelliteControllerTest extends TelephonyTest { assertTrue(waitForIIntegerConsumerResult(1)); assertEquals(SATELLITE_RESULT_INVALID_MODEM_STATE, (long) mIIntegerConsumerResults.get(0)); verifySatelliteEnabled(false, SATELLITE_RESULT_SUCCESS); verify(mMockPointingAppController, never()).startPointingUI(anyBoolean()); verify(mMockPointingAppController, never()).startPointingUI(anyBoolean(), anyBoolean(), anyBoolean()); assertFalse(mSatelliteControllerUT.setSettingsKeyForSatelliteModeCalled); verify(mMockControllerMetricsStats, times(1)).reportServiceEnablementFailCount(); Loading Loading @@ -1451,7 +1452,8 @@ public class SatelliteControllerTest extends TelephonyTest { verify(mMockDatagramController, times(1)).sendSatelliteDatagram(anyInt(), eq(SatelliteManager.DATAGRAM_TYPE_SOS_MESSAGE), eq(datagram), eq(true), any()); verify(mMockPointingAppController, times(1)).startPointingUI(eq(true)); verify(mMockPointingAppController, times(1)).startPointingUI(eq(true), anyBoolean(), anyBoolean()); } @Test Loading