svc命令

什么是svc命令

svc是Android的一个脚本命令,在/system/bin目录下,我们通过cat命令可查看其详细信息:

1
2
3
4
5
6
7
caigandeMacBook-Pro:~ lcg$ adb shell cat /system/bin/svc
# Script to start "am" on the device, which has a very rudimentary
# shell.
#
base=/system
export CLASSPATH=$base/framework/svc.jar
exec app_process $base/bin com.android.commands.svc.Svc $*

通过-h参数可查看所有命令:

1
2
3
4
5
6
7
caigandeMacBook-Pro:~ lcg$ adb shell svc -h
Available commands:
help Show information about the subcommands
power Control the power manager
data Control mobile data connectivity
wifi Control the Wi-Fi manager
usb Control Usb state

svc power:控制电源管理

1
2
3
4
5
6
7
8
9
shell@mx2:/ $ svc power -h
Control the power manager

usage: svc power stayon [true|false|usb|ac|wireless]
Set the 'keep awake while plugged in' setting.
svc power reboot [reason]
Perform a runtime shutdown and reboot device with specified reason.
svc power shutdown
Perform a runtime shutdown and power off the device.

svc power stayon [true|false|usb|ac|wireless]: 设置保持唤醒状态
1.true:常亮,相当于设置了所有标记(usb, ac, wireless)
2.false:清除所有标记
3.usb:插入usb时常亮
4.ac:充电时常亮
5.wireless:无线充电时常亮
当设置usb/ac/wireless其中一个标记时,会清除其余标记

svc power reboot [reason]: 设置设备在特定条件下关机并重启

svc power shutdown: 设置设备关机

svc data:控制设备数据连接

1
2
3
4
5
shell@mx2:/ $ svc data -h
Control mobile data connectivity

usage: svc data [enable|disable]
Turn mobile data on or off.

svc data [enable|disable]:控制设备数据连接开与关

svc wifi:控制wifi管理

1
2
3
4
5
shell@mx2:/ $ svc wifi -h
Control the Wi-Fi manager

usage: svc wifi [enable|disable]
Turn Wi-Fi on or off.

svc wifi [enable|disable]:控制wifi开与关

svc usb:控制usb状态

1
2
3
4
5
6
7
8
shell@mx2:/ $ svc usb -h
Control Usb state

usage: svc usb setFunction [function]
Set the current usb function.

svc usb getFunction
Gets the list of currently enabled functions

svc usb setFunction [function]:设置当前USB功能
其中[function]包括:mtp,adb等

svc usb getFunction:获取当前可用功能列表

热评文章