Skip to content

Commit 3b91340

Browse files
authored
refactor: remove legacy gsm fallback logic (#1225)
Removed legacy command execution fallbacks in the Gsm extension for Android. The methods make_gsm_call, set_gsm_signal, and set_gsm_voice now use execute_script with the 'mobile:' prefix directly. - Removed UnknownMethodException and CanRememberExtensionPresence imports. - Updated Gsm class to no longer inherit from CanRememberExtensionPresence. - Simplified extension methods by removing try-except blocks. - Emptied _add_commands method as legacy endpoints are no longer needed.
1 parent ed9eaff commit 3b91340

1 file changed

Lines changed: 5 additions & 24 deletions

File tree

  • appium/webdriver/extensions/android

appium/webdriver/extensions/android/gsm.py

Lines changed: 5 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,12 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
from selenium.common.exceptions import UnknownMethodException
1615
from typing_extensions import Self
1716

1817
from appium.common.helper import extract_const_attributes
1918
from appium.common.logger import logger
2019
from appium.protocols.webdriver.can_execute_commands import CanExecuteCommands
2120
from appium.protocols.webdriver.can_execute_scripts import CanExecuteScripts
22-
from appium.protocols.webdriver.can_remember_extension_presence import CanRememberExtensionPresence
23-
from appium.webdriver.mobilecommand import MobileCommand as Command
2421

2522

2623
class GsmCallActions:
@@ -48,7 +45,7 @@ class GsmVoiceState:
4845
ON = 'on'
4946

5047

51-
class Gsm(CanExecuteCommands, CanExecuteScripts, CanRememberExtensionPresence):
48+
class Gsm(CanExecuteCommands, CanExecuteScripts):
5249
def make_gsm_call(self, phone_number: str, action: str) -> Self:
5350
"""Make GSM call (Emulator only)
5451
@@ -73,11 +70,7 @@ def make_gsm_call(self, phone_number: str, action: str) -> Self:
7370
f'(e.g. {GsmCallActions.__name__}.CALL)'
7471
)
7572
args = {'phoneNumber': phone_number, 'action': action}
76-
try:
77-
self.assert_extension_exists(ext_name).execute_script(ext_name, args)
78-
except UnknownMethodException:
79-
# TODO: Remove the fallback
80-
self.mark_extension_absence(ext_name).execute(Command.MAKE_GSM_CALL, args)
73+
self.execute_script(ext_name, args)
8174
return self
8275

8376
def set_gsm_signal(self, strength: int) -> Self:
@@ -102,13 +95,7 @@ def set_gsm_signal(self, strength: int) -> Self:
10295
f'{strength} is out of range. Consider using one of {list(constants.keys())} constants. '
10396
f'(e.g. {GsmSignalStrength.__name__}.GOOD)'
10497
)
105-
try:
106-
self.assert_extension_exists(ext_name).execute_script(ext_name, {'strength': strength})
107-
except UnknownMethodException:
108-
# TODO: Remove the fallback
109-
self.mark_extension_absence(ext_name).execute(
110-
Command.SET_GSM_SIGNAL, {'signalStrength': strength, 'signalStrengh': strength}
111-
)
98+
self.execute_script(ext_name, {'strength': strength})
11299
return self
113100

114101
def set_gsm_voice(self, state: str) -> Self:
@@ -134,14 +121,8 @@ def set_gsm_voice(self, state: str) -> Self:
134121
f'(e.g. {GsmVoiceState.__name__}.HOME)'
135122
)
136123
args = {'state': state}
137-
try:
138-
self.assert_extension_exists(ext_name).execute_script(ext_name, args)
139-
except UnknownMethodException:
140-
# TODO: Remove the fallback
141-
self.mark_extension_absence(ext_name).execute(Command.SET_GSM_VOICE, args)
124+
self.execute_script(ext_name, args)
142125
return self
143126

144127
def _add_commands(self) -> None:
145-
self.command_executor.add_command(Command.MAKE_GSM_CALL, 'POST', '/session/$sessionId/appium/device/gsm_call')
146-
self.command_executor.add_command(Command.SET_GSM_SIGNAL, 'POST', '/session/$sessionId/appium/device/gsm_signal')
147-
self.command_executor.add_command(Command.SET_GSM_VOICE, 'POST', '/session/$sessionId/appium/device/gsm_voice')
128+
pass

0 commit comments

Comments
 (0)