From 15c90207e2bf98a2ad7f6fe713cf2be08c992795 Mon Sep 17 00:00:00 2001 From: ELIYAZ MOMIN Date: Mon, 29 Apr 2024 11:37:35 +0000 Subject: [PATCH] Revert "Add a new warning dialog for Satellite mode" This reverts commit 680d062c77528bb018ddb6f688fa53c46650a917. Reason for revert: Change-Id: I6fbb7a0587fbb474012e1a97a75c036420500f99 --- AndroidManifest.xml | 8 -- res/values/strings.xml | 5 - .../network/SatelliteWarningDialogActivity.kt | 87 ------------ .../SatelliteWarningDialogActivityTest.kt | 126 ------------------ 4 files changed, 226 deletions(-) delete mode 100644 src/com/android/settings/network/SatelliteWarningDialogActivity.kt delete mode 100644 tests/spa_unit/src/com/android/settings/spa/network/SatelliteWarningDialogActivityTest.kt diff --git a/AndroidManifest.xml b/AndroidManifest.xml index 2282cdbda3d..a4ac2d7eedf 100644 --- a/AndroidManifest.xml +++ b/AndroidManifest.xml @@ -5142,14 +5142,6 @@ android:permission="android.permission.NETWORK_SETTINGS"> - - - diff --git a/res/values/strings.xml b/res/values/strings.xml index 609954977eb..1e76855dc09 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -11559,11 +11559,6 @@ Satellite messaging may take longer and is available only in some areas. Weather and certain structures may affect your satellite connection. Calling by satellite isn\u2019t available. Emergency calls may still connect.\n\nIt may take some time for account changes to show in Settings. Contact your carrier for details. More about satellite messaging - - Can’t turn on %1$s - - To turn on %1$s, first end the satellite connection - Access Point Names diff --git a/src/com/android/settings/network/SatelliteWarningDialogActivity.kt b/src/com/android/settings/network/SatelliteWarningDialogActivity.kt deleted file mode 100644 index a0d494cdef6..00000000000 --- a/src/com/android/settings/network/SatelliteWarningDialogActivity.kt +++ /dev/null @@ -1,87 +0,0 @@ -/* - * Copyright (C) 2024 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.settings.network - -import android.os.Bundle -import android.view.WindowManager -import androidx.compose.foundation.layout.fillMaxWidth -import androidx.compose.material3.Text -import androidx.compose.runtime.Composable -import androidx.compose.ui.Modifier -import androidx.compose.ui.text.style.TextAlign -import com.android.settings.R -import com.android.settingslib.spa.SpaDialogWindowTypeActivity -import com.android.settingslib.spa.widget.dialog.AlertDialogButton -import com.android.settingslib.spa.widget.dialog.SettingsAlertDialogContent - -/** A dialog to show the warning message when device is under satellite mode. */ -class SatelliteWarningDialogActivity : SpaDialogWindowTypeActivity() { - private var warningType = TYPE_IS_UNKNOWN - - override fun onCreate(savedInstanceState: Bundle?) { - warningType = intent.getIntExtra(EXTRA_TYPE_OF_SATELLITE_WARNING_DIALOG, TYPE_IS_UNKNOWN) - if (warningType == TYPE_IS_UNKNOWN) { - finish() - } - super.onCreate(savedInstanceState) - } - - override fun getDialogWindowType(): Int { - return WindowManager.LayoutParams.FIRST_APPLICATION_WINDOW - } - - @Composable - override fun Content() { - SettingsAlertDialogContent( - dismissButton = null, - confirmButton = AlertDialogButton( - getString(com.android.settingslib.R.string.okay) - ) { finish() }, - title = String.format( - getString(R.string.satellite_warning_dialog_title), - getTypeString(warningType) - ), - text = { - Text( - String.format( - getString(R.string.satellite_warning_dialog_content), - getTypeString(warningType) - ), - modifier = Modifier.fillMaxWidth(), - textAlign = TextAlign.Center - ) - }) - } - - private fun getTypeString(num: Int): String { - return when (num) { - TYPE_IS_WIFI -> getString(R.string.wifi) - TYPE_IS_BLUETOOTH -> getString(R.string.bluetooth) - TYPE_IS_AIRPLANE_MODE -> getString(R.string.airplane_mode) - else -> "" - } - } - - companion object { - const val EXTRA_TYPE_OF_SATELLITE_WARNING_DIALOG: String = - "extra_type_of_satellite_warning_dialog" - const val TYPE_IS_UNKNOWN = -1 - const val TYPE_IS_WIFI = 0 - const val TYPE_IS_BLUETOOTH = 1 - const val TYPE_IS_AIRPLANE_MODE = 2 - } -} \ No newline at end of file diff --git a/tests/spa_unit/src/com/android/settings/spa/network/SatelliteWarningDialogActivityTest.kt b/tests/spa_unit/src/com/android/settings/spa/network/SatelliteWarningDialogActivityTest.kt deleted file mode 100644 index 04e83f5daf8..00000000000 --- a/tests/spa_unit/src/com/android/settings/spa/network/SatelliteWarningDialogActivityTest.kt +++ /dev/null @@ -1,126 +0,0 @@ -/* - * Copyright (C) 2024 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.settings.spa.network - -import android.content.Context -import android.content.Intent -import androidx.compose.ui.test.assertIsDisplayed -import androidx.compose.ui.test.junit4.createAndroidComposeRule -import androidx.compose.ui.test.onNodeWithText -import androidx.lifecycle.Lifecycle -import androidx.test.core.app.ActivityScenario -import androidx.test.core.app.ActivityScenario.launch -import androidx.test.core.app.ApplicationProvider -import androidx.test.ext.junit.runners.AndroidJUnit4 -import com.android.settings.R -import com.android.settings.network.SatelliteWarningDialogActivity -import com.android.settings.network.SatelliteWarningDialogActivity.Companion.EXTRA_TYPE_OF_SATELLITE_WARNING_DIALOG -import com.android.settings.network.SatelliteWarningDialogActivity.Companion.TYPE_IS_AIRPLANE_MODE -import com.android.settings.network.SatelliteWarningDialogActivity.Companion.TYPE_IS_BLUETOOTH -import com.android.settings.network.SatelliteWarningDialogActivity.Companion.TYPE_IS_UNKNOWN -import com.android.settings.network.SatelliteWarningDialogActivity.Companion.TYPE_IS_WIFI -import org.junit.Assert.assertTrue -import org.junit.Rule -import org.junit.Test -import org.junit.runner.RunWith - -@RunWith(AndroidJUnit4::class) -class SatelliteWarningDialogActivityTest { - @get:Rule - val composeTestRule = createAndroidComposeRule() - val context: Context = ApplicationProvider.getApplicationContext() - - @Test - fun launchActivity_checkExtraValue_typeIsWifi() { - val scenario = launchDialogActivity(TYPE_IS_WIFI) - - scenario.onActivity { activity -> - assert( - activity.intent.getIntExtra( - EXTRA_TYPE_OF_SATELLITE_WARNING_DIALOG, - TYPE_IS_UNKNOWN - ) == TYPE_IS_WIFI - ) - } - scenario.close() - } - - @Test - fun launchActivity_checkExtraValue_typeIsBluetooth() { - val scenario = launchDialogActivity(TYPE_IS_BLUETOOTH) - - scenario.onActivity { activity -> - assert( - activity.intent.getIntExtra( - EXTRA_TYPE_OF_SATELLITE_WARNING_DIALOG, - TYPE_IS_UNKNOWN - ) == TYPE_IS_BLUETOOTH - ) - } - scenario.close() - } - - @Test - fun launchActivity_unknownType_destroyActivity() { - val scenario = launchDialogActivity(TYPE_IS_UNKNOWN) - - assertTrue(scenario.state.isAtLeast(Lifecycle.State.DESTROYED)) - scenario.close() - } - - @Test - fun testDialogIsExisted() { - val scenario = launchDialogActivity(TYPE_IS_WIFI) - - composeTestRule.onNodeWithText(context.getString(com.android.settingslib.R.string.okay)) - .assertIsDisplayed() - scenario.close() - } - - @Test - fun testDialogTitle_titleIsIncludeWifi() { - val scenario = launchDialogActivity(TYPE_IS_WIFI) - - composeTestRule.onNodeWithText( - String.format( - context.getString(R.string.satellite_warning_dialog_title), - context.getString(R.string.wifi), - ) - ).assertIsDisplayed() - scenario.close() - } - - @Test - fun testDialogTitle_titleIsIncludeAirplaneMode() { - val scenario = launchDialogActivity(TYPE_IS_AIRPLANE_MODE) - - composeTestRule.onNodeWithText( - String.format( - context.getString(R.string.satellite_warning_dialog_title), - context.getString(R.string.airplane_mode), - ) - ).assertIsDisplayed() - scenario.close() - } - - private fun launchDialogActivity(type: Int): ActivityScenario = launch( - Intent( - context, - SatelliteWarningDialogActivity::class.java - ).putExtra(EXTRA_TYPE_OF_SATELLITE_WARNING_DIALOG, type) - ) -}