FileDocCategorySizeDatePackage
DataCommand.javaAPI DocAndroid 5.1 API2310Thu Mar 12 22:22:08 GMT 2015com.android.commands.svc

DataCommand

public class DataCommand extends Svc.Command

Fields Summary
Constructors Summary
public DataCommand()

        super("data");
    
Methods Summary
public java.lang.StringlongHelp()

        return shortHelp() + "\n"
                + "\n"
                + "usage: svc data [enable|disable]\n"
                + "         Turn mobile data on or off.\n\n";
    
public voidrun(java.lang.String[] args)

        boolean validCommand = false;
        if (args.length >= 2) {
            boolean flag = false;
            if ("enable".equals(args[1])) {
                flag = true;
                validCommand = true;
            } else if ("disable".equals(args[1])) {
                flag = false;
                validCommand = true;
            }
            if (validCommand) {
                ITelephony phoneMgr
                        = ITelephony.Stub.asInterface(ServiceManager.getService(Context.TELEPHONY_SERVICE));
                try {
                    if (flag) {
                        phoneMgr.enableDataConnectivity();
                    } else
                        phoneMgr.disableDataConnectivity();
                }
                catch (RemoteException e) {
                    System.err.println("Mobile data operation failed: " + e);
                }
                return;
            }
        }
        System.err.println(longHelp());
    
public java.lang.StringshortHelp()

        return "Control mobile data connectivity";