diff options
author | Shuo Qian <shuoq@google.com> | 2019-12-18 17:23:35 +0000 |
---|---|---|
committer | Shuo Qian <shuoq@google.com> | 2019-12-18 17:27:21 +0000 |
commit | b179a7fc2f49d62fabbdaa0b2f59dd2df7203998 (patch) | |
tree | 9931c38ff1990ef95d65bcb536ffd11472213c0e /cmds/svc | |
parent | 5c4e7b81b571d11851fd9c63a308e1a910b196b9 (diff) |
Revert "Deprecate Data Command in Android"
This reverts commit 5c4e7b81b571d11851fd9c63a308e1a910b196b9.
Reason for revert: <b/146461873>
Bug: 146461873
Change-Id: I8bd10333f2014e52e1d3122c5b9dc895a5d6c658
Diffstat (limited to 'cmds/svc')
-rw-r--r-- | cmds/svc/src/com/android/commands/svc/DataCommand.java | 44 |
1 files changed, 33 insertions, 11 deletions
diff --git a/cmds/svc/src/com/android/commands/svc/DataCommand.java b/cmds/svc/src/com/android/commands/svc/DataCommand.java index b4dbd1d41bc1..35510cfd38b1 100644 --- a/cmds/svc/src/com/android/commands/svc/DataCommand.java +++ b/cmds/svc/src/com/android/commands/svc/DataCommand.java @@ -16,16 +16,12 @@ package com.android.commands.svc; -/** - * @deprecated Please use adb shell cmd phone data enabled/disable instead. - */ -@Deprecated -public class DataCommand extends Svc.Command { - - private static final String DECPRECATED_MESSAGE = - "adb shell svc data enable/disable is deprecated;" - + "please use adb shell cmd phone data enable/disable instead."; +import android.os.ServiceManager; +import android.os.RemoteException; +import android.content.Context; +import com.android.internal.telephony.ITelephony; +public class DataCommand extends Svc.Command { public DataCommand() { super("data"); } @@ -37,10 +33,36 @@ public class DataCommand extends Svc.Command { public String longHelp() { return shortHelp() + "\n" + "\n" - + DECPRECATED_MESSAGE; + + "usage: svc data [enable|disable]\n" + + " Turn mobile data on or off.\n\n"; } public void run(String[] args) { - System.err.println(DECPRECATED_MESSAGE); + 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()); } } |