android - 如何编写导航到该功能并禁用它的脚本?
问题描述
我想禁用我们 android 设备的蜂窝网络设置中列出的功能。
我通过 ADB start 活动 com.android.phone/.MobileNetworkSettings adb shell input keyevent 20 & ADB shell input keyevent 23 尝试了以下操作
该代码运行良好,并且禁用了该功能,但是,我需要通过 MDM 将其应用于批量设备,并且它仅支持 JAVA 脚本。有没有办法编写一个导航到该功能并禁用它的脚本?
我们的设备操作系统是 android 6.01
解决方案
不是 MDM 解决方案,而是使用AndroidViewClient/culebra的普通 ADB 的更好替代方案
#! /usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Copyright (C) 2013-2019 Diego Torres Milano
Culebra v20.2.0
__ __ __ __
/ \ / \ / \ / \
____________________/ __\/ __\/ __\/ __\_____________________________
___________________/ /__/ /__/ /__/ /________________________________
| / \ / \ / \ / \ \___
|/ \_/ \_/ \_/ \ o \
\_____/--<
@author: Diego Torres Milano
@author: Jennifer E. Swofford (ascii art snake)
"""
import sys
from com.dtmilano.android.viewclient import ViewClient
_s = 5
device, serialno = ViewClient.connectToDeviceOrExit()
device.startActivity(component='com.android.phone/.MobileNetworkSettings')
vc = ViewClient(device, serialno)
vc.dump(window=-1)
mobile_data = vc.findViewWithTextOrRaise('Mobile data')
vc.findViewByIdOrRaise('android:id/switch_widget', mobile_data.parent).touch()
vc.sleep(_s)
vc.dump(window=-1)
vc.findViewWithTextOrRaise('OK').touch()
请注意,您可以使用Culebra GUI指向并单击设备表示来记录这样的脚本。此外,这可以同时在多个设备上运行。
推荐阅读
- r - 导入栅格堆栈会返回较大的 NA 值
- php - Search for an item using a dropdown list in Laravel that returns the results onto a view
- html - 可使用占位符编辑的 div 内容
- pandas-profiling - Pandas 分析 KeyError
- python - Python 与 Podio 的集成
- angular - Transloco - 如何在运行时添加语言
- excel - 在下拉更改时获取单元格内容
- regex - 使用正则表达式捕获 Linux 用户字符串
- xaml - 如何在 Xamarin Forms 中包含来自上方的弹出窗口
- ios - 在 AppCenter 上构建 iOS 应用和 watchOS 应用失败