Merge "Add get/set user selected outgoing phone account APIs."
This commit is contained in:
@@ -41811,6 +41811,7 @@ package android.telecom {
|
|||||||
method @RequiresPermission(android.Manifest.permission.READ_PHONE_STATE) public java.util.List<android.telecom.PhoneAccountHandle> getSelfManagedPhoneAccounts();
|
method @RequiresPermission(android.Manifest.permission.READ_PHONE_STATE) public java.util.List<android.telecom.PhoneAccountHandle> getSelfManagedPhoneAccounts();
|
||||||
method public android.telecom.PhoneAccountHandle getSimCallManager();
|
method public android.telecom.PhoneAccountHandle getSimCallManager();
|
||||||
method public String getSystemDialerPackage();
|
method public String getSystemDialerPackage();
|
||||||
|
method @RequiresPermission(android.Manifest.permission.READ_PHONE_STATE) public android.telecom.PhoneAccountHandle getUserSelectedOutgoingPhoneAccount();
|
||||||
method @RequiresPermission(android.Manifest.permission.READ_PHONE_STATE) public String getVoiceMailNumber(android.telecom.PhoneAccountHandle);
|
method @RequiresPermission(android.Manifest.permission.READ_PHONE_STATE) public String getVoiceMailNumber(android.telecom.PhoneAccountHandle);
|
||||||
method @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public boolean handleMmi(String);
|
method @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public boolean handleMmi(String);
|
||||||
method @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public boolean handleMmi(String, android.telecom.PhoneAccountHandle);
|
method @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public boolean handleMmi(String, android.telecom.PhoneAccountHandle);
|
||||||
|
|||||||
@@ -5272,6 +5272,7 @@ package android.telecom {
|
|||||||
method @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public boolean isInEmergencyCall();
|
method @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public boolean isInEmergencyCall();
|
||||||
method @RequiresPermission(anyOf={android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE, android.Manifest.permission.READ_PHONE_STATE}) public boolean isRinging();
|
method @RequiresPermission(anyOf={android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE, android.Manifest.permission.READ_PHONE_STATE}) public boolean isRinging();
|
||||||
method @Deprecated @RequiresPermission(allOf={android.Manifest.permission.MODIFY_PHONE_STATE, android.Manifest.permission.WRITE_SECURE_SETTINGS}) public boolean setDefaultDialer(String);
|
method @Deprecated @RequiresPermission(allOf={android.Manifest.permission.MODIFY_PHONE_STATE, android.Manifest.permission.WRITE_SECURE_SETTINGS}) public boolean setDefaultDialer(String);
|
||||||
|
method @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public void setUserSelectedOutgoingPhoneAccount(android.telecom.PhoneAccountHandle);
|
||||||
field public static final String EXTRA_CALL_BACK_INTENT = "android.telecom.extra.CALL_BACK_INTENT";
|
field public static final String EXTRA_CALL_BACK_INTENT = "android.telecom.extra.CALL_BACK_INTENT";
|
||||||
field public static final String EXTRA_CLEAR_MISSED_CALLS_INTENT = "android.telecom.extra.CLEAR_MISSED_CALLS_INTENT";
|
field public static final String EXTRA_CLEAR_MISSED_CALLS_INTENT = "android.telecom.extra.CLEAR_MISSED_CALLS_INTENT";
|
||||||
field public static final String EXTRA_CONNECTION_SERVICE = "android.telecom.extra.CONNECTION_SERVICE";
|
field public static final String EXTRA_CONNECTION_SERVICE = "android.telecom.extra.CONNECTION_SERVICE";
|
||||||
|
|||||||
@@ -23,8 +23,10 @@ import android.os.IUserManager;
|
|||||||
import android.os.RemoteException;
|
import android.os.RemoteException;
|
||||||
import android.os.ServiceManager;
|
import android.os.ServiceManager;
|
||||||
import android.os.UserHandle;
|
import android.os.UserHandle;
|
||||||
|
import android.telecom.Log;
|
||||||
import android.telecom.PhoneAccount;
|
import android.telecom.PhoneAccount;
|
||||||
import android.telecom.PhoneAccountHandle;
|
import android.telecom.PhoneAccountHandle;
|
||||||
|
import android.text.TextUtils;
|
||||||
|
|
||||||
import com.android.internal.os.BaseCommand;
|
import com.android.internal.os.BaseCommand;
|
||||||
import com.android.internal.telecom.ITelecomService;
|
import com.android.internal.telecom.ITelecomService;
|
||||||
@@ -45,6 +47,8 @@ public final class Telecom extends BaseCommand {
|
|||||||
private static final String COMMAND_SET_PHONE_ACCOUNT_ENABLED = "set-phone-account-enabled";
|
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_SET_PHONE_ACCOUNT_DISABLED = "set-phone-account-disabled";
|
||||||
private static final String COMMAND_REGISTER_PHONE_ACCOUNT = "register-phone-account";
|
private static final String COMMAND_REGISTER_PHONE_ACCOUNT = "register-phone-account";
|
||||||
|
private static final String COMMAND_SET_USER_SELECTED_OUTGOING_PHONE_ACCOUNT =
|
||||||
|
"set-user-selected-outgoing-phone-account";
|
||||||
private static final String COMMAND_REGISTER_SIM_PHONE_ACCOUNT = "register-sim-phone-account";
|
private static final String COMMAND_REGISTER_SIM_PHONE_ACCOUNT = "register-sim-phone-account";
|
||||||
private static final String COMMAND_SET_TEST_CALL_REDIRECTION_APP = "set-test-call-redirection-app";
|
private static final String COMMAND_SET_TEST_CALL_REDIRECTION_APP = "set-test-call-redirection-app";
|
||||||
private static final String COMMAND_SET_TEST_CALL_SCREENING_APP = "set-test-call-screening-app";
|
private static final String COMMAND_SET_TEST_CALL_SCREENING_APP = "set-test-call-screening-app";
|
||||||
@@ -70,6 +74,8 @@ public final class Telecom extends BaseCommand {
|
|||||||
+ "usage: telecom set-phone-account-enabled <COMPONENT> <ID> <USER_SN>\n"
|
+ "usage: telecom set-phone-account-enabled <COMPONENT> <ID> <USER_SN>\n"
|
||||||
+ "usage: telecom set-phone-account-disabled <COMPONENT> <ID> <USER_SN>\n"
|
+ "usage: telecom set-phone-account-disabled <COMPONENT> <ID> <USER_SN>\n"
|
||||||
+ "usage: telecom register-phone-account <COMPONENT> <ID> <USER_SN> <LABEL>\n"
|
+ "usage: telecom register-phone-account <COMPONENT> <ID> <USER_SN> <LABEL>\n"
|
||||||
|
+ "usage: telecom set-user-selected-outgoing-phone-account <COMPONENT> <ID> "
|
||||||
|
+ "<USER_SN>\n"
|
||||||
+ "usage: telecom set-test-call-redirection-app <PACKAGE>\n"
|
+ "usage: telecom set-test-call-redirection-app <PACKAGE>\n"
|
||||||
+ "usage: telecom set-test-call-screening-app <PACKAGE>\n"
|
+ "usage: telecom set-test-call-screening-app <PACKAGE>\n"
|
||||||
+ "usage: telecom set-test-auto-mode-app <PACKAGE>\n"
|
+ "usage: telecom set-test-auto-mode-app <PACKAGE>\n"
|
||||||
@@ -104,16 +110,18 @@ public final class Telecom extends BaseCommand {
|
|||||||
mTelecomService = ITelecomService.Stub.asInterface(
|
mTelecomService = ITelecomService.Stub.asInterface(
|
||||||
ServiceManager.getService(Context.TELECOM_SERVICE));
|
ServiceManager.getService(Context.TELECOM_SERVICE));
|
||||||
if (mTelecomService == null) {
|
if (mTelecomService == null) {
|
||||||
|
Log.w(this, "onRun: Can't access telecom manager.");
|
||||||
showError("Error: Could not access the Telecom Manager. Is the system running?");
|
showError("Error: Could not access the Telecom Manager. Is the system running?");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
mUserManager = IUserManager.Stub
|
mUserManager = IUserManager.Stub
|
||||||
.asInterface(ServiceManager.getService(Context.USER_SERVICE));
|
.asInterface(ServiceManager.getService(Context.USER_SERVICE));
|
||||||
if (mUserManager == null) {
|
if (mUserManager == null) {
|
||||||
|
Log.w(this, "onRun: Can't access user manager.");
|
||||||
showError("Error: Could not access the User Manager. Is the system running?");
|
showError("Error: Could not access the User Manager. Is the system running?");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
Log.i(this, "onRun: parsing command.");
|
||||||
String command = nextArgRequired();
|
String command = nextArgRequired();
|
||||||
switch (command) {
|
switch (command) {
|
||||||
case COMMAND_SET_PHONE_ACCOUNT_ENABLED:
|
case COMMAND_SET_PHONE_ACCOUNT_ENABLED:
|
||||||
@@ -143,6 +151,9 @@ public final class Telecom extends BaseCommand {
|
|||||||
case COMMAND_REGISTER_SIM_PHONE_ACCOUNT:
|
case COMMAND_REGISTER_SIM_PHONE_ACCOUNT:
|
||||||
runRegisterSimPhoneAccount();
|
runRegisterSimPhoneAccount();
|
||||||
break;
|
break;
|
||||||
|
case COMMAND_SET_USER_SELECTED_OUTGOING_PHONE_ACCOUNT:
|
||||||
|
runSetUserSelectedOutgoingPhoneAccount();
|
||||||
|
break;
|
||||||
case COMMAND_UNREGISTER_PHONE_ACCOUNT:
|
case COMMAND_UNREGISTER_PHONE_ACCOUNT:
|
||||||
runUnregisterPhoneAccount();
|
runUnregisterPhoneAccount();
|
||||||
break;
|
break;
|
||||||
@@ -159,6 +170,7 @@ public final class Telecom extends BaseCommand {
|
|||||||
runWaitOnHandler();
|
runWaitOnHandler();
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
Log.w(this, "onRun: unknown command: %s", command);
|
||||||
throw new IllegalArgumentException ("unknown command '" + command + "'");
|
throw new IllegalArgumentException ("unknown command '" + command + "'");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -227,6 +239,13 @@ public final class Telecom extends BaseCommand {
|
|||||||
mTelecomService.setTestPhoneAcctSuggestionComponent(componentName);
|
mTelecomService.setTestPhoneAcctSuggestionComponent(componentName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void runSetUserSelectedOutgoingPhoneAccount() throws RemoteException {
|
||||||
|
Log.i(this, "runSetUserSelectedOutgoingPhoneAccount");
|
||||||
|
final PhoneAccountHandle handle = getPhoneAccountHandleFromArgs();
|
||||||
|
mTelecomService.setUserSelectedOutgoingPhoneAccount(handle);
|
||||||
|
System.out.println("Success - " + handle + " set as default outgoing account.");
|
||||||
|
}
|
||||||
|
|
||||||
private void runUnregisterPhoneAccount() throws RemoteException {
|
private void runUnregisterPhoneAccount() throws RemoteException {
|
||||||
final PhoneAccountHandle handle = getPhoneAccountHandleFromArgs();
|
final PhoneAccountHandle handle = getPhoneAccountHandleFromArgs();
|
||||||
mTelecomService.unregisterPhoneAccount(handle);
|
mTelecomService.unregisterPhoneAccount(handle);
|
||||||
@@ -257,6 +276,9 @@ public final class Telecom extends BaseCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private PhoneAccountHandle getPhoneAccountHandleFromArgs() throws RemoteException {
|
private PhoneAccountHandle getPhoneAccountHandleFromArgs() throws RemoteException {
|
||||||
|
if (TextUtils.isEmpty(mArgs.peekNextArg())) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
final ComponentName component = parseComponentName(nextArgRequired());
|
final ComponentName component = parseComponentName(nextArgRequired());
|
||||||
final String accountId = nextArgRequired();
|
final String accountId = nextArgRequired();
|
||||||
final String userSnInStr = nextArgRequired();
|
final String userSnInStr = nextArgRequired();
|
||||||
@@ -265,6 +287,7 @@ public final class Telecom extends BaseCommand {
|
|||||||
final int userSn = Integer.parseInt(userSnInStr);
|
final int userSn = Integer.parseInt(userSnInStr);
|
||||||
userHandle = UserHandle.of(mUserManager.getUserHandle(userSn));
|
userHandle = UserHandle.of(mUserManager.getUserHandle(userSn));
|
||||||
} catch (NumberFormatException ex) {
|
} catch (NumberFormatException ex) {
|
||||||
|
Log.w(this, "getPhoneAccountHandleFromArgs - invalid user %s", userSnInStr);
|
||||||
throw new IllegalArgumentException ("Invalid user serial number " + userSnInStr);
|
throw new IllegalArgumentException ("Invalid user serial number " + userSnInStr);
|
||||||
}
|
}
|
||||||
return new PhoneAccountHandle(component, accountId, userHandle);
|
return new PhoneAccountHandle(component, accountId, userHandle);
|
||||||
|
|||||||
@@ -788,15 +788,17 @@ public class TelecomManager {
|
|||||||
* <p>
|
* <p>
|
||||||
* Apps must be prepared for this method to return {@code null}, indicating that there currently
|
* Apps must be prepared for this method to return {@code null}, indicating that there currently
|
||||||
* exists no user-chosen default {@code PhoneAccount}.
|
* exists no user-chosen default {@code PhoneAccount}.
|
||||||
|
* <p>
|
||||||
|
* The default dialer has access to use this method.
|
||||||
*
|
*
|
||||||
* @return The user outgoing phone account selected by the user.
|
* @return The user outgoing phone account selected by the user.
|
||||||
* @hide
|
|
||||||
*/
|
*/
|
||||||
@UnsupportedAppUsage
|
@RequiresPermission(android.Manifest.permission.READ_PHONE_STATE)
|
||||||
public PhoneAccountHandle getUserSelectedOutgoingPhoneAccount() {
|
public PhoneAccountHandle getUserSelectedOutgoingPhoneAccount() {
|
||||||
try {
|
try {
|
||||||
if (isServiceConnected()) {
|
if (isServiceConnected()) {
|
||||||
return getTelecomService().getUserSelectedOutgoingPhoneAccount();
|
return getTelecomService().getUserSelectedOutgoingPhoneAccount(
|
||||||
|
mContext.getOpPackageName());
|
||||||
}
|
}
|
||||||
} catch (RemoteException e) {
|
} catch (RemoteException e) {
|
||||||
Log.e(TAG, "Error calling ITelecomService#getUserSelectedOutgoingPhoneAccount", e);
|
Log.e(TAG, "Error calling ITelecomService#getUserSelectedOutgoingPhoneAccount", e);
|
||||||
@@ -805,10 +807,14 @@ public class TelecomManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the user-chosen default for making outgoing phone calls.
|
* Sets the user-chosen default {@link PhoneAccountHandle} for making outgoing phone calls.
|
||||||
|
*
|
||||||
|
* @param accountHandle The {@link PhoneAccountHandle} which will be used by default for making
|
||||||
|
* outgoing voice calls.
|
||||||
* @hide
|
* @hide
|
||||||
*/
|
*/
|
||||||
@UnsupportedAppUsage
|
@RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE)
|
||||||
|
@SystemApi
|
||||||
public void setUserSelectedOutgoingPhoneAccount(PhoneAccountHandle accountHandle) {
|
public void setUserSelectedOutgoingPhoneAccount(PhoneAccountHandle accountHandle) {
|
||||||
try {
|
try {
|
||||||
if (isServiceConnected()) {
|
if (isServiceConnected()) {
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ interface ITelecomService {
|
|||||||
/**
|
/**
|
||||||
* @see TelecomServiceImpl#getUserSelectedOutgoingPhoneAccount
|
* @see TelecomServiceImpl#getUserSelectedOutgoingPhoneAccount
|
||||||
*/
|
*/
|
||||||
PhoneAccountHandle getUserSelectedOutgoingPhoneAccount();
|
PhoneAccountHandle getUserSelectedOutgoingPhoneAccount(String callingPackage);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see TelecomServiceImpl#setUserSelectedOutgoingPhoneAccount
|
* @see TelecomServiceImpl#setUserSelectedOutgoingPhoneAccount
|
||||||
|
|||||||
Reference in New Issue
Block a user