Merge "Deprecate Data Command in Android"
This commit is contained in:
@@ -16,12 +16,16 @@
|
|||||||
|
|
||||||
package com.android.commands.svc;
|
package com.android.commands.svc;
|
||||||
|
|
||||||
import android.os.ServiceManager;
|
/**
|
||||||
import android.os.RemoteException;
|
* @deprecated Please use adb shell cmd phone data enabled/disable instead.
|
||||||
import android.content.Context;
|
*/
|
||||||
import com.android.internal.telephony.ITelephony;
|
@Deprecated
|
||||||
|
|
||||||
public class DataCommand extends Svc.Command {
|
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.";
|
||||||
|
|
||||||
public DataCommand() {
|
public DataCommand() {
|
||||||
super("data");
|
super("data");
|
||||||
}
|
}
|
||||||
@@ -33,36 +37,10 @@ public class DataCommand extends Svc.Command {
|
|||||||
public String longHelp() {
|
public String longHelp() {
|
||||||
return shortHelp() + "\n"
|
return shortHelp() + "\n"
|
||||||
+ "\n"
|
+ "\n"
|
||||||
+ "usage: svc data [enable|disable]\n"
|
+ DECPRECATED_MESSAGE;
|
||||||
+ " Turn mobile data on or off.\n\n";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void run(String[] args) {
|
public void run(String[] args) {
|
||||||
boolean validCommand = false;
|
System.err.println(DECPRECATED_MESSAGE);
|
||||||
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());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user