Android adb shell svc knowledge detailed explanation

adb shell svc detailed explanation

This command can be used to control power management, wifi switch, and data switch (that is, Internet traffic). Note that root privileges are required.

Those who are interested can learn together.

1. Commonly used commands of svc:


1、屏幕相关
          adb shell svc power stayon [true|false|usb|ac]
          设置屏幕的常亮,true保持常亮,false不保持,usb当插入usb时常亮,ac当插入电源时常亮

2、移动数据(sim卡网络)
          adb shell svc data enable/打开移动数据
          adb shell svc data disable/关闭移动数据
          adb shell svc data prefer/设置移动数据优先

3、wifi相关
         adb shell svc wifi enable/打开wifi
         adb shell svc wifi disable/关闭wifi
         adb shell svc wifi prefer/设置wifi优先

4、蓝牙相关
         adb shell svc bluetooth enable/打开wifi
         adb shell svc bluetooth disable/关闭wifi
此命令可以用作4G/wifi稳定性测试

In fact, there are other svc commands. If you want to know more about them, you can take a look later.

2. svc command and usage examples:

Check whether svc is installed on the system

path/system/bin/svc



1|console:/ # ls -l /system/bin/svc
-rwxr-xr-x 1 root shell 1697 2023-09-08 09:06 /system/bin/svc
console:/ # 

If this svc file exists, you can execute the svc command.

In fact, you can use cat to see the code of the svc file. Specifically, where it is generated and how to edit and modify it, I will not do a detailed analysis here.

1、svc

In the serial port or adb shell command line, enter svc to see the relevant functions. You
may not be able to see them all, which may be related to the system or the svc file.

console:/ # svc
Available commands:
    help             Show information about the subcommands
    power            Control the power manager
    usb              Control Usb state
    nfc              Control NFC functions
    system-server    System server process related command
console:/ # 
console:/ # 

Enter svc on the serial port to see the relevant command functions. But it may not be fully displayed.

2、svc help

console:/ # svc help
Available commands:
    help             Show information about the subcommands
    power            Control the power manager
    usb              Control Usb state
    nfc              Control NFC functions
    system-server    System server process related command
console:/ # 

Enter svc help to view the function list that is actually useless and displays the same function as svc.

3、svc power

console:/ # svc power
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 forcesuspend [t]
         Force the system into suspend, ignoring all wakelocks.
         t - Number of milliseconds to wait before issuing force-suspend.
             Helps with devices that can't suspend while plugged in.
             Defaults to 0.
             When using a delay, you must use the nohup shell modifier:
             'adb shell nohup svc power forcesuspend [time]'
         Use caution; this is dangerous. It puts the device to sleep
         immediately without giving apps or the system an opportunity to
         save their state.

console:/ # 

Here you can see that avc power includes the following functions:

svc power stayon [true|false|usb|ac|wireless] //对应的意义:[长亮|长暗|usb接入长亮|充电长亮|连接wifi长亮]
svc power reboot [reason] //[reason] 可以随便写或者不写,底层估计是会记录
svc power shutdown //关机
svc power forcesuspend [time]// 定时关机,其实也是关机,time 是多久后关机,单位是毫秒。未设置time,就是马上关机。

3、svc usb


console:/ # 
console:/ # svc usb
Control Usb state

usage: svc usb setFunctions [function]
         Set the current usb function. If function is blank, sets to charging.
       svc usb setScreenUnlockedFunctions [function]
         Sets the functions which, if the device was charging,
         become current on screen unlock.
         If function is blank, turn off this feature.
       svc usb getFunctions
         Gets the list of currently enabled functions
         possible values of [function] are any of 'mtp', 'ptp', 'rndis',
         'midi', 'ncm (if supporting gadget hal v1.2)'
       svc usb resetUsbGadget
         Reset usb gadget
       svc usb getUsbSpeed
         Gets current USB speed
         possible values of USB speed are any of 'low speed', 'full speed',
         'high speed', 'super speed', 'super speed (10G)',
         'super speed (20G)', or higher (future extension)
       svc usb getGadgetHalVersion
         Gets current Gadget Hal Version
         possible values of Hal version are any of 'unknown', 'V1_0', 'V1_1',
         'V1_2'
       svc usb getUsbHalVersion
         Gets current USB Hal Version
         possible values of Hal version are any of 'unknown', 'V1_0', 'V1_1',
         'V1_2', 'V1_3'
       svc usb resetUsbPort [port number]
         Reset the specified connected usb port
         default: the first connected usb port

console:/ # 
console:/ # 


Looking at svc usb above, it seems too complicated!

To summarize, it mainly includes the following functions:

svc usb setFunctions [function] //设置充电,还是文件等模式
svc usb setScreenUnlockedFunctions [function]
svc usb resetUsbGadget
svc usb getUsbSpeed
svc usb getGadgetHalVersion
svc usb getUsbHalVersion
svc usb resetUsbPort [port number]

In fact, after the above svc usb is executed, it is received in UsbCommand, and some method calls are executed in UsbDeviceManager.


framework\base\cmds\svc\src\com\android\commands\svc\UsbCommand.java
framework\base\services\usb\java\com\android\server\usb\UsbDeviceManager.java

If you want to study it carefully, you can take a look for yourself.

4、svc nfc

console:/ # svc nfc                                                            
Got a null NfcAdapter, is the system running?
console:/ # 

It can be seen here that ngc is not installed on the device, so no information is found.

5、svc wifi

127|console:/ # svc wifi
Control the Wi-Fi manager

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

1|console:/ # 

As seen here, avc wifi can control the wifi switch through enable/disable.

I don’t see svc wifi prefer/set wifi priority here!
This is a TV platform and I cannot insert a SIM card. The relevant settings may have been removed. If you need detailed research, you can see the svc file and wifi command related files.

packages\modules\Wifi\service\java\com\android\server\wifi\WifiShellCommand.java

6、svc bluetooth


1|console:/ # svc bluetooth
Control the Bluetooth manager

usage: svc bluetooth [enable|disable]
         Turn Bluetooth on or off.

1|console:/ # 

As seen here, avc bluetooth can control the Bluetooth switch through enable/disable.

7、svc system-server

console:/ # svc system-server 
System server process related command

usage: system-server wait-for-crash
         Wait until the system server process crashes.


console:/ # 

It is shown here that the log will be printed after the system crashes. It is estimated that the system will crash.

8、svc data

1|console:/ # svc data                                                         
Enable/Disable Mobile Data Connectivity

usage: svc data [enable|disable]

1|console:/ # 

Mobile data connections can be turned on or off via svc data enable or svc data disable. This command can be used to control the data connection status of the phone.

There is no query command here, we can only check whether it takes effect through actual testing.

9、svc volume

Viewing svc online can also control variables:

adb shell svc volume music +10 // 将音乐音量增加10个单位

However, the actual test did not recognize the volume command, which is probably related to the Android system code.

console:/ # svc volume music +10
Available commands:
    help             Show information about the subcommands
    power            Control the power manager
    usb              Control Usb state
    nfc              Control NFC functions
    system-server    System server process related command
console:/ # svc volume music                                                   
Available commands:
    help             Show information about the subcommands
    power            Control the power manager
    usb              Control Usb state
    nfc              Control NFC functions
    system-server    System server process related command
console:/ # svc volume                                                         
Available commands:
    help             Show information about the subcommands
    power            Control the power manager
    usb              Control Usb state
    nfc              Control NFC functions
    system-server    System server process related command
console:/ # 
console:/ # 

It can be seen here that the svc volume command is not recognized. In fact, the system code is not configured. If you want to know more, you can continue to read below.

2. Source code analysis related to svc command

1. cat svc file

console:/ # 
console:/ # cat /system/bin/svc
#!/system/bin/sh

# `svc wifi` has been migrated to WifiShellCommand,
# simply perform translation to `cmd wifi set-wifi-enabled` here.
if [ "x$1" == "xwifi" ]; then
    # `cmd wifi` by convention uses enabled/disabled
    # instead of enable/disable
    if [ "x$2" == "xenable" ]; then
        exec cmd wifi set-wifi-enabled enabled
    elif [ "x$2" == "xdisable" ]; then
        exec cmd wifi set-wifi-enabled disabled
    else
        echo "Control the Wi-Fi manager"
        echo ""
        echo "usage: svc wifi [enable|disable]"
        echo "         Turn Wi-Fi on or off."
        echo ""
    fi
    exit 1
fi

if [ "x$1" == "xdata" ]; then
    if [ "x$2" == "xenable" ]; then
        exec cmd phone data enable
    elif [ "x$2" == "xdisable" ]; then
        exec cmd phone data disable
    else
        echo "Enable/Disable Mobile Data Connectivity"
        echo ""
        echo "usage: svc data [enable|disable]"
        echo ""
    fi
    exit 1
fi

# `svc bluetooth` has been migrated to BluetoothShellCommand,
# simply perform translation to `cmd bluetooth set-bluetooth-enabled` here.
if [ "x$1" == "xbluetooth" ]; then
    # `cmd wifi` by convention uses enabled/disabled
    # instead of enable/disable
    if [ "x$2" == "xenable" ]; then
        exec cmd bluetooth_manager enable
    elif [ "x$2" == "xdisable" ]; then
        exec cmd bluetooth_manager disable
    else
        echo "Control the Bluetooth manager"
        echo ""
        echo "usage: svc bluetooth [enable|disable]"
        echo "         Turn Bluetooth on or off."
        echo ""
    fi
    exit 1
fi

export CLASSPATH=/system/framework/svc.jar
exec app_process /system/bin com.android.commands.svc.Svc "$@"

console:/ # 

Here we see the simple judgment of wifi and bluetooth, and the association of svc.jar

This svc file also exists in the Android system source code. The file directory is:

framework\base\cmds\svc\svc

The reception and processing of svc related functions are all in the framework\base\cmds\svc folder.

2. svc related source code files

Main relevant documents:

framework\base\cmds\svc\src\com\android\commands\svc\Svc.java
framework\base\cmds\svc\src\com\android\commands\svc\NfcCommand.java
framework\base\cmds\svc\src\com\android\commands\svc\PowerCommand.java
framework\base\cmds\svc\src\com\android\commands\svc\SystemServerCommand.java
framework\base\cmds\svc\src\com\android\commands\svc\UsbCommand.java

packages\modules\Wifi\service\java\com\android\server\wifi\WifiShellCommand.java // Android13
packages\modules\Bluetooth\service\java\com\android\server\bluetooth\BluetoothShellCommand.java //Android13

SVC related file process analyzed by others:
https://blog.csdn.net/zhangqi6627/article/details/121496414

(1) The file Svc.java that receives all svc commands

public class Svc {

    public static abstract class Command { // 所有command 子类都是会继承这个抽象接口,后面会看到
        private String mName;

        public Command(String name) { //设置Command 名称
            mName = name;
        }

        public String name() { //查询Command名称
            return mName;
        }

        public abstract String shortHelp();         // should fit on one short line, //svc help看到的各个Command 的信息
        public abstract String longHelp();          // take as much space as you need, 75 col max // svc 具体命令后,看到的具体提示信息
        public abstract void run(String[] args);    // run the command //执行接收输入的命令
    }

    // (1)执行入口
    public static void main(String[] args) {
        if (args.length >= 1) {
            Command c = lookupCommand(args[0]); //(2)根据输入的字符串,返回Command 对象
            if (c != null) {
                c.run(args);
                return;
            }
        }
        COMMAND_HELP.run(args); // (3)如果只输入 avc,显示help 提示的字符串
    }


    // (4)根据字符串查找 Command 对象,其实就是USB、Wifi那些控制对象
    private static Command lookupCommand(String name) {
        final int N = COMMANDS.length;
        for (int i=0; i<N; i++) { // (5)遍历所有Command对象进行匹配
            Command c = COMMANDS[i];
            if (c.name().equals(name)) {
                return c;
            }
        }
        return null;
    }

    // (5)定义所有的 Command 对象
    public static final Command[] COMMANDS = new Command[] {
            COMMAND_HELP,   // (6)help 是自身
            new PowerCommand(), // (7) power相关命令处理
            // `svc wifi` has been migrated to WifiShellCommand // (8)wifi 相关命令处理,svc 文件已经说明了,会在 WifiShellCommand 进行处理。
            new UsbCommand(), // (9) usb相关命令处理
            new NfcCommand(), // (10)nfc相关命令处理
            // `svc bluetooth` has been migrated to BluetoothShellCommand // (11)bluetooth相关命令处理
            new SystemServerCommand(), // (11)system-server 命令处理
    };

}

(2) Receive the file PowerCommand.java of all svc power commands

Here we only explain the reception and processing of the avc power command. The analysis of the Command command class of other commands is also similar and you can refer to it.

public class PowerCommand extends Svc.Command { //(1) svc 命令都是要继承 Command抽象类
    private static final int FORCE_SUSPEND_DELAY_DEFAULT_MILLIS = 0;

    public PowerCommand() {
        super("power"); // (2)父类的构成方法,设置Command 对象名称,也是svc 后面对应的功能名称
    }

    public String shortHelp() { // (3)svc 显示的 power 功能简单提示
        return "Control the power manager";
    }

    public String longHelp() { // (4)svc power 显示的 power 功能具体提示,这个也说明文本提示因供参考,真正的实现还是要看代码逻辑
        return shortHelp() + "\n"
                + "\n"
                + "usage: svc power stayon [true|false|usb|ac|wireless]\n"
                + "         Set the 'keep awake while plugged in' setting.\n"
                + "       svc power reboot [reason]\n"
                + "         Perform a runtime shutdown and reboot device with specified reason.\n"
                + "       svc power shutdown\n"
                + "         Perform a runtime shutdown and power off the device.\n"
                + "       svc power forcesuspend [t]\n"
                + "         Force the system into suspend, ignoring all wakelocks.\n"
                + "         t - Number of milliseconds to wait before issuing force-suspend.\n"
                + "             Helps with devices that can't suspend while plugged in.\n"
                + "             Defaults to " + FORCE_SUSPEND_DELAY_DEFAULT_MILLIS + ".\n"
                + "             When using a delay, you must use the nohup shell modifier:\n"
                + "             'adb shell nohup svc power forcesuspend [time]'\n"
                + "         Use caution; this is dangerous. It puts the device to sleep\n"
                + "         immediately without giving apps or the system an opportunity to\n"
                + "         save their state.\n";
    }

    //(5)这个就是 svc power 功能的具体处理代码了,也是最重要的部分
    public void run(String[] args) {
        fail: {
            if (args.length >= 2) { //(6)命令字符串大于等于2 才有意义, args[0] = power, args[1] = 某个功能,比如 stayon ,args[2] = 某个功能的参数
                IPowerManager pm = IPowerManager.Stub.asInterface(
                        ServiceManager.getService(Context.POWER_SERVICE)); //(7)具体实现其实也是调用到了PowerManager对于的Service 服务里面,也就是说avc 里面的实现基本都是调用系统api的操作
                if ("stayon".equals(args[1]) && args.length == 3) { // (8)avc power stayon 功能的判断
                    int val;
                    if ("true".equals(args[2])) { //(9)avc power stayon true 的判断,长亮
                        val = BatteryManager.BATTERY_PLUGGED_AC |
                                BatteryManager.BATTERY_PLUGGED_USB |
                                BatteryManager.BATTERY_PLUGGED_WIRELESS;
                    }
                    else if ("false".equals(args[2])) {  //(10)avc power stayon false 的判断,长暗
                        val = 0;
                    } else if ("usb".equals(args[2])) { //(11)avc power stayon usb 的判断,插入usb长亮
                        val = BatteryManager.BATTERY_PLUGGED_USB;
                    } else if ("ac".equals(args[2])) { //(12)avc power stayon ac 的判断,插入ac电源长亮
                        val = BatteryManager.BATTERY_PLUGGED_AC;
                    } else if ("wireless".equals(args[2])) { //(13)avc power stayon wireless 的判断,连接wifi 长亮
                        val = BatteryManager.BATTERY_PLUGGED_WIRELESS;
                    } else { //(14)avc power 其他参数都是,错误情况,进行提示
                        break fail;
                    }
                    try {
                        if (val != 0) {
                            // if the request is not to set it to false, wake up the screen so that
                            // it can stay on as requested
                            pm.wakeUp(SystemClock.uptimeMillis(),
                                    PowerManager.WAKE_REASON_UNKNOWN, "PowerCommand", null);
                        }
                        pm.setStayOnSetting(val);  //(15)根据 avc power 设置的功能,调用相关api,设置相关参数,
                    }
                    catch (RemoteException e) {
                        System.err.println("Faild to set setting: " + e);
                    }
                    return;
                } else if ("reboot".equals(args[1])) { //(16)后面的流程就不一一分析了,参数长度和具体调用的api不同而已。
                    String mode = null;
                    if (args.length == 3) {
                        mode = args[2];
                    }
                    try {
                        // no confirm, wait till device is rebooted
                        pm.reboot(false, mode, true);
                    } catch (RemoteException e) {
                        maybeLogRemoteException("Failed to reboot.");
                    } catch (Exception e) {
                        System.err.println("Failed to reboot: " + e.getMessage());
                    }
                    return;
                } else if ("shutdown".equals(args[1])) {
                    try {
                        // no confirm, wait till device is off
                        pm.shutdown(false, null, true);
                    } catch (RemoteException e) {
                        maybeLogRemoteException("Failed to shutdown.");
                    }
                    return;
                } else if ("forcesuspend".equals(args[1])) {
                    int delayMillis = args.length > 2
                            ? Integer.parseInt(args[2]) : FORCE_SUSPEND_DELAY_DEFAULT_MILLIS;
                    try {
                        Thread.sleep(delayMillis);
                        if (!pm.forceSuspend()) {
                            System.err.println("Failed to force suspend.");
                        }
                    } catch (InterruptedException e) {
                        System.err.println("Failed to force suspend: " + e);
                    } catch (RemoteException e) {
                        maybeLogRemoteException("Failed to force-suspend with exception: " + e);
                    }
                    return;
                }
            }
        }
        System.err.println(longHelp()); // (17)如果参数错误的情况,就显示avc power 的具体命令提示。
    }

3. Add customized svc command implementation to the system source code

1. To add a new svc to the system source code, you only need to do the following two steps:

(1)创建一个自己  Command 对象,可以参考同目录下的其他Command对象,比如 PowerCommand 的代码;
(2)在 Svc.java 文件中 COMMANDS列表对象中添加自定义的 Command 对象,svc 遍历的时候就会判断是否包含你的命令

2. Modifications in Svc.java

    public static final Command[] COMMANDS = new Command[] {
            COMMAND_HELP,
            new LwzCommand(), //这里添加自定定义的 Command 对象
            new PowerCommand(),
            // `svc wifi` has been migrated to WifiShellCommand
            new UsbCommand(),
            new NfcCommand(),
            // `svc bluetooth` has been migrated to BluetoothShellCommand
            new SystemServerCommand(),
    };


When the svc command is entered, the names of all Command objects will be traversed.
Whichever one matches the name will return the specific Command object. The specific processing is in a certain Command object.

3. Create a custom Command object


package com.android.commands.svc;

import android.content.Context;

public class LwzCommand extends Svc.Command { //(1)自定义Command对象,需要继承 Svc.Command
    private static final int FORCE_SUSPEND_DELAY_DEFAULT_MILLIS = 0;

    public LwzCommand() { //(2)自定义对象的命令名称,这个也是cmd 窗口中的功能命令,Java那个对象命名是无所谓的
        super("lwz");
    }

    public String shortHelp() { //(3)简短的介绍,avc 、avc help 会出现该提示
        return "lwz Control the test command";
    }

    public String longHelp() { //(4)详细的介绍,avc lwz 或者 avc lwz help ,会打印该提示
        return shortHelp() + "\n"
                + "\n"
                + "usage: svc lwz stayon [true|false|usb|ac|wireless]\n"
                + "         Set the 'keep awake while plugged in' setting.\n"
                + "       svc lwz reboot [reason]\n"
                + "         Perform a runtime shutdown and reboot device with specified reason.\n"
                + "       svc lwz shutdown\n";
    }

    public void run(String[] args) {  //(4)avc lwz XXX 的具体处理
        fail: {
            if (args.length >= 2) { //(5)avc lwz stayon 的具体处理,这里只是做了一些打印,未调用具体的api实现
                if ("stayon".equals(args[1]) && args.length == 3) {
                    int val;
                    if ("true".equals(args[2])) {
                        val = 100;
                    }
                    else if ("false".equals(args[2])) {
                        val = 0;
                    } else if ("usb".equals(args[2])) {
                        val = 1;
                    } else if ("ac".equals(args[2])) {
                        val = 2;
                    } else if ("wireless".equals(args[2])) {
                        val = 3;
                    } else {
                        break fail;
                    }
                    System.err.println("test avc lwz command :" + args[2] + ", val = " + val); //添加了自定义打印
                    return;
                } else if ("reboot".equals(args[1])) { //(6)avc lwz reboot 的具体处理,这里只是做了一些打印,未调用具体的api实现
                    String mode = null;
                    if (args.length == 3) {
                        mode = args[2];
                    }
                    System.err.println("test avc lwz command :" + args[1] + ", mode = " + mode);
                    return;
                }
                 //(6)avc lwz XXX 其他输入的处理,打印具体介绍字符串
                System.err.println(longHelp());
            }
        }
        System.err.println(longHelp());
    }

}


The customized Command object above does not call the specific API.
In actual applications, the system API can be called, the returned data can be printed, and the writing thread can access the network without any problem.

4. After adding a custom Command command, the display of serial port operations

The following is the print log of the serial port after adding the custom LwzCommand.java file:


console:/ # 
console:/ # svc //(1)输入svc 可以看到添加了 自定义的 lwz 功能命令
Available commands:
    help             Show information about the subcommands
    lwz              lwz Control the test command
    power            Control the power manager
    usb              Control Usb state
    nfc              Control NFC functions
    system-server    System server process related command
console:/ # 
console:/ # svc lwz //(2)自定义的功能简介,参考 svc power 的功能编写的
lwz Control the test command //(3)添加的打印
usage: svc lwz stayon [true|false|usb|ac|wireless]
         Set the 'keep awake while plugged in' setting.
       svc lwz reboot [reason]
         Perform a runtime shutdown and reboot device with specified reason.
       svc lwz shutdown
console:/ # 

console:/ # 
console:/ # svc lwz shutdown // (4)avc lwz shutdown 实际代码未实现,代码中打印了Help提示
lwz Control the test command
usage: svc lwz stayon [true|false|usb|ac|wireless]
         Set the 'keep awake while plugged in' setting.
       svc lwz reboot [reason]
         Perform a runtime shutdown and reboot device with specified reason.
       svc lwz shutdown
console:/ #
console:/ # 
console:/ # svc lwz reboot // (5)avc lwz reboot 代码中只是添加了打印,未做处理
test avc lwz command :reboot, mode = null
console:/ # 
console:/ # 
console:/ # svc lwz stayon true  // (6)avc lwz stayon true 代码中只是添加了打印,未做其他处理
test avc lwz command :true, val = 100
console:/ # 
console:/ # 
console:/ # svc lwz stayon false  // (7)avc lwz stayon false 代码中只是添加了打印,未做其他处理
test avc lwz command :false, val = 0
console:/ # 

The effect here is quite good.
That is to say, I learned the relevant content of svc and also learned the knowledge of custom extensions.

4. Summary

1. Use of svc

svc main commands:

adb shell svc power/wifi/bluetooth/usb/nfc

As you can know from the above introduction, in fact, as long as you remember svc, you will be prompted for other related commands, and then enter the function command, and the specific parameter introduction will be displayed.

2. svc design custom command

In fact, it is not difficult. One is to write a custom Command class, and the other is to add this class object to Svc.java.

Modifications involved:

framework\base\cmds\svc\src\com\android\commands\svc\Svc.java
framework\base\cmds\svc\src\com\android\commands\svc\XXXCommand.java

3. Other relevant knowledge

(1) Some serial ports display that svc is invalid.

The printing in the serial port is as follows:

1|console:/ # svc
CANNOT LINK EXECUTABLE "app_process": library "libnativeloader.so" not found: needed by main executable
1|console:/ # 
1|console:/ # 

My 311D2 13 system here prompts like this, but other systems don’t know what the prompts are.
But the svc file exists, and the cmd window of adb shell is ok; it is unclear where this is related.

(2) cmd other command extension instructions

In fact, in addition to svc, there are many serial port debugging commands in the system source code.
You can see this in the system source code directory frameworks\base\cmds:


Android13-IFP/release$ 
Android13-IFP/release$ cd frameworks/base/cmds
Android13-IFP/release/frameworks/base/cmds$ ls
abx  appops       appwidget  bmgr           bu       device_config  hid     ime       incidentd        input        locksettings  requestsync  settings  svc      uiautomator  vr
am   app_process  backup     bootanimation  content  dpm            idmap2  incident  incident_helper  interrupter  pm            screencap    sm        telecom  uinput       wm
Android13-IFP/release/frameworks/base/cmds$ 

Here you can see that there are more than 30 cmd commands in it. For example, am/pm commands to control applications, wm commands to control display, etc.
Some of these commands require root permissions, and some do not.
However, not all cmd names are defined here. For example, ifconfig is a command that I don’t know where it is implemented.

At this point, we have a thorough understanding of svc and related knowledge.

Guess you like

Origin blog.csdn.net/wenzhi20102321/article/details/132779708