diff options
author | Yorke Lee <yorkelee@google.com> | 2015-06-03 09:33:56 -0700 |
---|---|---|
committer | Yorke Lee <yorkelee@google.com> | 2015-06-03 09:33:56 -0700 |
commit | b9381c790eef869ebd904c92bd019886600fc814 (patch) | |
tree | 3512729a6a7dfe5b4948af3e209585b168059c94 | |
parent | db6da486217daa3418944cf93086a3bae549dad2 (diff) | |
download | frameworks_base-b9381c790eef869ebd904c92bd019886600fc814.zip frameworks_base-b9381c790eef869ebd904c92bd019886600fc814.tar.gz frameworks_base-b9381c790eef869ebd904c92bd019886600fc814.tar.bz2 |
Add adb shell command to register/unregister phone accounts
Bug: 21583012
Change-Id: I3fd525259860fd9e0f9fda5b77cbb9ee7bfab6ca
-rw-r--r-- | cmds/telecom/src/com/android/commands/telecom/Telecom.java | 44 |
1 files changed, 37 insertions, 7 deletions
diff --git a/cmds/telecom/src/com/android/commands/telecom/Telecom.java b/cmds/telecom/src/com/android/commands/telecom/Telecom.java index 250b002..f62c71b 100644 --- a/cmds/telecom/src/com/android/commands/telecom/Telecom.java +++ b/cmds/telecom/src/com/android/commands/telecom/Telecom.java @@ -20,6 +20,7 @@ import android.content.ComponentName; import android.content.Context; import android.os.RemoteException; import android.os.ServiceManager; +import android.telecom.PhoneAccount; import android.telecom.PhoneAccountHandle; import android.text.TextUtils; @@ -39,8 +40,10 @@ public final class Telecom extends BaseCommand { (new Telecom()).run(args); } - private static final String COMMAND_SET_PHONE_ACOUNT_ENABLED = "set-phone-account-enabled"; - private static final String COMMAND_SET_PHONE_ACOUNT_DISABLED = "set-phone-account-disabled"; + private static final String COMMAND_SET_PHONE_ACCOUNT_ENABLED = "set-phone-account-enabled"; + private static final String COMMAND_SET_PHONE_ACCOUNT_DISABLED = "set-phone-account-disabled"; + private static final String COMMAND_REGISTER_PHONE_ACCOUNT = "register-phone-account"; + private static final String COMMAND_UNREGISTER_PHONE_ACCOUNT = "unregister-phone-account"; private static final String COMMAND_SET_DEFAULT_DIALER = "set-default-dialer"; private static final String COMMAND_GET_DEFAULT_DIALER = "get-default-dialer"; @@ -54,6 +57,8 @@ public final class Telecom extends BaseCommand { "usage: telecom [subcommand] [options]\n" + "usage: telecom set-phone-account-enabled <COMPONENT> <ID>\n" + "usage: telecom set-phone-account-disabled <COMPONENT> <ID>\n" + + "usage: telecom register-phone-account <COMPONENT> <ID> <LABEL>\n" + + "usage: telecom unregister-phone-account <COMPONENT> <ID>\n" + "usage: telecom set-default-dialer <PACKAGE>\n" + "usage: telecom get-default-dialer <PACKAGE>\n" + "\n" + @@ -80,12 +85,18 @@ public final class Telecom extends BaseCommand { String command = nextArgRequired(); switch (command) { - case COMMAND_SET_PHONE_ACOUNT_ENABLED: + case COMMAND_SET_PHONE_ACCOUNT_ENABLED: runSetPhoneAccountEnabled(true); break; - case COMMAND_SET_PHONE_ACOUNT_DISABLED: + case COMMAND_SET_PHONE_ACCOUNT_DISABLED: runSetPhoneAccountEnabled(false); break; + case COMMAND_REGISTER_PHONE_ACCOUNT: + runRegisterPhoneAccount(); + break; + case COMMAND_UNREGISTER_PHONE_ACCOUNT: + runUnregisterPhoneAccount(); + break; case COMMAND_SET_DEFAULT_DIALER: runSetDefaultDialer(); break; @@ -98,9 +109,7 @@ public final class Telecom extends BaseCommand { } private void runSetPhoneAccountEnabled(boolean enabled) throws RemoteException { - final ComponentName component = parseComponentName(nextArgRequired()); - final String accountId = nextArgRequired(); - final PhoneAccountHandle handle = new PhoneAccountHandle(component, accountId); + final PhoneAccountHandle handle = getPhoneAccountHandleFromArgs(); final boolean success = mTelecomService.enablePhoneAccount(handle, enabled); if (success) { System.out.println("Success - " + handle + (enabled ? " enabled." : " disabled.")); @@ -109,6 +118,21 @@ public final class Telecom extends BaseCommand { } } + private void runRegisterPhoneAccount() throws RemoteException { + final PhoneAccountHandle handle = getPhoneAccountHandleFromArgs(); + final String label = nextArgRequired(); + PhoneAccount account = PhoneAccount.builder(handle, label) + .setCapabilities(PhoneAccount.CAPABILITY_CALL_PROVIDER).build(); + mTelecomService.registerPhoneAccount(account); + System.out.println("Success - " + handle + " registered."); + } + + private void runUnregisterPhoneAccount() throws RemoteException { + final PhoneAccountHandle handle = getPhoneAccountHandleFromArgs(); + mTelecomService.unregisterPhoneAccount(handle); + System.out.println("Success - " + handle + " unregistered."); + } + private void runSetDefaultDialer() throws RemoteException { final String packageName = nextArgRequired(); final boolean success = mTelecomService.setDefaultDialer(packageName); @@ -124,6 +148,12 @@ public final class Telecom extends BaseCommand { System.out.println(mTelecomService.getDefaultDialerPackage()); } + private PhoneAccountHandle getPhoneAccountHandleFromArgs() { + final ComponentName component = parseComponentName(nextArgRequired()); + final String accountId = nextArgRequired(); + return new PhoneAccountHandle(component, accountId); + } + private ComponentName parseComponentName(String component) { ComponentName cn = ComponentName.unflattenFromString(component); if (cn == null) { |