Merge "Remove isServiceConnected() from TelecomManager"
This commit is contained in:
@@ -997,13 +997,14 @@ public class TelecomManager {
|
||||
*/
|
||||
@RequiresPermission(android.Manifest.permission.READ_PHONE_STATE)
|
||||
public PhoneAccountHandle getDefaultOutgoingPhoneAccount(String uriScheme) {
|
||||
try {
|
||||
if (isServiceConnected()) {
|
||||
return getTelecomService().getDefaultOutgoingPhoneAccount(uriScheme,
|
||||
ITelecomService service = getTelecomService();
|
||||
if (service != null) {
|
||||
try {
|
||||
return service.getDefaultOutgoingPhoneAccount(uriScheme,
|
||||
mContext.getOpPackageName(), mContext.getAttributionTag());
|
||||
} catch (RemoteException e) {
|
||||
Log.e(TAG, "Error calling ITelecomService#getDefaultOutgoingPhoneAccount", e);
|
||||
}
|
||||
} catch (RemoteException e) {
|
||||
Log.e(TAG, "Error calling ITelecomService#getDefaultOutgoingPhoneAccount", e);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@@ -1023,13 +1024,14 @@ public class TelecomManager {
|
||||
*/
|
||||
@RequiresPermission(android.Manifest.permission.READ_PHONE_STATE)
|
||||
public @Nullable PhoneAccountHandle getUserSelectedOutgoingPhoneAccount() {
|
||||
try {
|
||||
if (isServiceConnected()) {
|
||||
return getTelecomService().getUserSelectedOutgoingPhoneAccount(
|
||||
ITelecomService service = getTelecomService();
|
||||
if (service != null) {
|
||||
try {
|
||||
return service.getUserSelectedOutgoingPhoneAccount(
|
||||
mContext.getOpPackageName());
|
||||
} catch (RemoteException e) {
|
||||
Log.e(TAG, "Error calling ITelecomService#getUserSelectedOutgoingPhoneAccount", e);
|
||||
}
|
||||
} catch (RemoteException e) {
|
||||
Log.e(TAG, "Error calling ITelecomService#getUserSelectedOutgoingPhoneAccount", e);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@@ -1045,12 +1047,13 @@ public class TelecomManager {
|
||||
@RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE)
|
||||
@SystemApi
|
||||
public void setUserSelectedOutgoingPhoneAccount(@Nullable PhoneAccountHandle accountHandle) {
|
||||
try {
|
||||
if (isServiceConnected()) {
|
||||
getTelecomService().setUserSelectedOutgoingPhoneAccount(accountHandle);
|
||||
ITelecomService service = getTelecomService();
|
||||
if (service != null) {
|
||||
try {
|
||||
service.setUserSelectedOutgoingPhoneAccount(accountHandle);
|
||||
} catch (RemoteException e) {
|
||||
Log.e(TAG, "Error calling ITelecomService#setUserSelectedOutgoingPhoneAccount");
|
||||
}
|
||||
} catch (RemoteException e) {
|
||||
Log.e(TAG, "Error calling ITelecomService#setUserSelectedOutgoingPhoneAccount");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1064,13 +1067,14 @@ public class TelecomManager {
|
||||
* @see SubscriptionManager#getDefaultVoiceSubscriptionId()
|
||||
*/
|
||||
public PhoneAccountHandle getSimCallManager() {
|
||||
try {
|
||||
if (isServiceConnected()) {
|
||||
return getTelecomService().getSimCallManager(
|
||||
ITelecomService service = getTelecomService();
|
||||
if (service != null) {
|
||||
try {
|
||||
return service.getSimCallManager(
|
||||
SubscriptionManager.getDefaultSubscriptionId());
|
||||
} catch (RemoteException e) {
|
||||
Log.e(TAG, "Error calling ITelecomService#getSimCallManager");
|
||||
}
|
||||
} catch (RemoteException e) {
|
||||
Log.e(TAG, "Error calling ITelecomService#getSimCallManager");
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@@ -1086,12 +1090,13 @@ public class TelecomManager {
|
||||
* @see SubscriptionManager#getActiveSubscriptionInfoList()
|
||||
*/
|
||||
public @Nullable PhoneAccountHandle getSimCallManagerForSubscription(int subscriptionId) {
|
||||
try {
|
||||
if (isServiceConnected()) {
|
||||
return getTelecomService().getSimCallManager(subscriptionId);
|
||||
ITelecomService service = getTelecomService();
|
||||
if (service != null) {
|
||||
try {
|
||||
return service.getSimCallManager(subscriptionId);
|
||||
} catch (RemoteException e) {
|
||||
Log.e(TAG, "Error calling ITelecomService#getSimCallManager");
|
||||
}
|
||||
} catch (RemoteException e) {
|
||||
Log.e(TAG, "Error calling ITelecomService#getSimCallManager");
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@@ -1109,12 +1114,13 @@ public class TelecomManager {
|
||||
*/
|
||||
@UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P, trackingBug = 119305590)
|
||||
public PhoneAccountHandle getSimCallManager(int userId) {
|
||||
try {
|
||||
if (isServiceConnected()) {
|
||||
return getTelecomService().getSimCallManagerForUser(userId);
|
||||
ITelecomService service = getTelecomService();
|
||||
if (service != null) {
|
||||
try {
|
||||
return service.getSimCallManagerForUser(userId);
|
||||
} catch (RemoteException e) {
|
||||
Log.e(TAG, "Error calling ITelecomService#getSimCallManagerForUser");
|
||||
}
|
||||
} catch (RemoteException e) {
|
||||
Log.e(TAG, "Error calling ITelecomService#getSimCallManagerForUser");
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@@ -1151,13 +1157,14 @@ public class TelecomManager {
|
||||
android.Manifest.permission.READ_PHONE_STATE
|
||||
})
|
||||
public List<PhoneAccountHandle> getPhoneAccountsSupportingScheme(String uriScheme) {
|
||||
try {
|
||||
if (isServiceConnected()) {
|
||||
return getTelecomService().getPhoneAccountsSupportingScheme(uriScheme,
|
||||
ITelecomService service = getTelecomService();
|
||||
if (service != null) {
|
||||
try {
|
||||
return service.getPhoneAccountsSupportingScheme(uriScheme,
|
||||
mContext.getOpPackageName());
|
||||
} catch (RemoteException e) {
|
||||
Log.e(TAG, "Error calling ITelecomService#getPhoneAccountsSupportingScheme", e);
|
||||
}
|
||||
} catch (RemoteException e) {
|
||||
Log.e(TAG, "Error calling ITelecomService#getPhoneAccountsSupportingScheme", e);
|
||||
}
|
||||
return new ArrayList<>();
|
||||
}
|
||||
@@ -1192,13 +1199,14 @@ public class TelecomManager {
|
||||
*/
|
||||
@RequiresPermission(android.Manifest.permission.READ_PHONE_STATE)
|
||||
public List<PhoneAccountHandle> getSelfManagedPhoneAccounts() {
|
||||
try {
|
||||
if (isServiceConnected()) {
|
||||
return getTelecomService().getSelfManagedPhoneAccounts(mContext.getOpPackageName(),
|
||||
ITelecomService service = getTelecomService();
|
||||
if (service != null) {
|
||||
try {
|
||||
return service.getSelfManagedPhoneAccounts(mContext.getOpPackageName(),
|
||||
mContext.getAttributionTag());
|
||||
} catch (RemoteException e) {
|
||||
Log.e(TAG, "Error calling ITelecomService#getSelfManagedPhoneAccounts()", e);
|
||||
}
|
||||
} catch (RemoteException e) {
|
||||
Log.e(TAG, "Error calling ITelecomService#getSelfManagedPhoneAccounts()", e);
|
||||
}
|
||||
return new ArrayList<>();
|
||||
}
|
||||
@@ -1217,14 +1225,15 @@ public class TelecomManager {
|
||||
@RequiresPermission(READ_PRIVILEGED_PHONE_STATE)
|
||||
public @NonNull List<PhoneAccountHandle> getCallCapablePhoneAccounts(
|
||||
boolean includeDisabledAccounts) {
|
||||
try {
|
||||
if (isServiceConnected()) {
|
||||
return getTelecomService().getCallCapablePhoneAccounts(includeDisabledAccounts,
|
||||
ITelecomService service = getTelecomService();
|
||||
if (service != null) {
|
||||
try {
|
||||
return service.getCallCapablePhoneAccounts(includeDisabledAccounts,
|
||||
mContext.getOpPackageName(), mContext.getAttributionTag());
|
||||
} catch (RemoteException e) {
|
||||
Log.e(TAG, "Error calling ITelecomService#getCallCapablePhoneAccounts("
|
||||
+ includeDisabledAccounts + ")", e);
|
||||
}
|
||||
} catch (RemoteException e) {
|
||||
Log.e(TAG, "Error calling ITelecomService#getCallCapablePhoneAccounts(" +
|
||||
includeDisabledAccounts + ")", e);
|
||||
}
|
||||
return new ArrayList<>();
|
||||
}
|
||||
@@ -1241,12 +1250,13 @@ public class TelecomManager {
|
||||
@SuppressLint("RequiresPermission")
|
||||
@Deprecated
|
||||
public List<PhoneAccountHandle> getPhoneAccountsForPackage() {
|
||||
try {
|
||||
if (isServiceConnected()) {
|
||||
return getTelecomService().getPhoneAccountsForPackage(mContext.getPackageName());
|
||||
ITelecomService service = getTelecomService();
|
||||
if (service != null) {
|
||||
try {
|
||||
return service.getPhoneAccountsForPackage(mContext.getPackageName());
|
||||
} catch (RemoteException e) {
|
||||
Log.e(TAG, "Error calling ITelecomService#getPhoneAccountsForPackage", e);
|
||||
}
|
||||
} catch (RemoteException e) {
|
||||
Log.e(TAG, "Error calling ITelecomService#getPhoneAccountsForPackage", e);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@@ -1259,12 +1269,13 @@ public class TelecomManager {
|
||||
* @return The {@link PhoneAccount} object.
|
||||
*/
|
||||
public PhoneAccount getPhoneAccount(PhoneAccountHandle account) {
|
||||
try {
|
||||
if (isServiceConnected()) {
|
||||
return getTelecomService().getPhoneAccount(account);
|
||||
ITelecomService service = getTelecomService();
|
||||
if (service != null) {
|
||||
try {
|
||||
return service.getPhoneAccount(account);
|
||||
} catch (RemoteException e) {
|
||||
Log.e(TAG, "Error calling ITelecomService#getPhoneAccount", e);
|
||||
}
|
||||
} catch (RemoteException e) {
|
||||
Log.e(TAG, "Error calling ITelecomService#getPhoneAccount", e);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@@ -1277,12 +1288,13 @@ public class TelecomManager {
|
||||
*/
|
||||
@SystemApi
|
||||
public int getAllPhoneAccountsCount() {
|
||||
try {
|
||||
if (isServiceConnected()) {
|
||||
return getTelecomService().getAllPhoneAccountsCount();
|
||||
ITelecomService service = getTelecomService();
|
||||
if (service != null) {
|
||||
try {
|
||||
return service.getAllPhoneAccountsCount();
|
||||
} catch (RemoteException e) {
|
||||
Log.e(TAG, "Error calling ITelecomService#getAllPhoneAccountsCount", e);
|
||||
}
|
||||
} catch (RemoteException e) {
|
||||
Log.e(TAG, "Error calling ITelecomService#getAllPhoneAccountsCount", e);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@@ -1295,12 +1307,13 @@ public class TelecomManager {
|
||||
*/
|
||||
@SystemApi
|
||||
public List<PhoneAccount> getAllPhoneAccounts() {
|
||||
try {
|
||||
if (isServiceConnected()) {
|
||||
return getTelecomService().getAllPhoneAccounts();
|
||||
ITelecomService service = getTelecomService();
|
||||
if (service != null) {
|
||||
try {
|
||||
return service.getAllPhoneAccounts();
|
||||
} catch (RemoteException e) {
|
||||
Log.e(TAG, "Error calling ITelecomService#getAllPhoneAccounts", e);
|
||||
}
|
||||
} catch (RemoteException e) {
|
||||
Log.e(TAG, "Error calling ITelecomService#getAllPhoneAccounts", e);
|
||||
}
|
||||
return Collections.EMPTY_LIST;
|
||||
}
|
||||
@@ -1313,12 +1326,13 @@ public class TelecomManager {
|
||||
*/
|
||||
@SystemApi
|
||||
public List<PhoneAccountHandle> getAllPhoneAccountHandles() {
|
||||
try {
|
||||
if (isServiceConnected()) {
|
||||
return getTelecomService().getAllPhoneAccountHandles();
|
||||
ITelecomService service = getTelecomService();
|
||||
if (service != null) {
|
||||
try {
|
||||
return service.getAllPhoneAccountHandles();
|
||||
} catch (RemoteException e) {
|
||||
Log.e(TAG, "Error calling ITelecomService#getAllPhoneAccountHandles", e);
|
||||
}
|
||||
} catch (RemoteException e) {
|
||||
Log.e(TAG, "Error calling ITelecomService#getAllPhoneAccountHandles", e);
|
||||
}
|
||||
return Collections.EMPTY_LIST;
|
||||
}
|
||||
@@ -1338,12 +1352,13 @@ public class TelecomManager {
|
||||
* @param account The complete {@link PhoneAccount}.
|
||||
*/
|
||||
public void registerPhoneAccount(PhoneAccount account) {
|
||||
try {
|
||||
if (isServiceConnected()) {
|
||||
getTelecomService().registerPhoneAccount(account);
|
||||
ITelecomService service = getTelecomService();
|
||||
if (service != null) {
|
||||
try {
|
||||
service.registerPhoneAccount(account);
|
||||
} catch (RemoteException e) {
|
||||
Log.e(TAG, "Error calling ITelecomService#registerPhoneAccount", e);
|
||||
}
|
||||
} catch (RemoteException e) {
|
||||
Log.e(TAG, "Error calling ITelecomService#registerPhoneAccount", e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1353,12 +1368,13 @@ public class TelecomManager {
|
||||
* @param accountHandle A {@link PhoneAccountHandle} for the {@link PhoneAccount} to unregister.
|
||||
*/
|
||||
public void unregisterPhoneAccount(PhoneAccountHandle accountHandle) {
|
||||
try {
|
||||
if (isServiceConnected()) {
|
||||
getTelecomService().unregisterPhoneAccount(accountHandle);
|
||||
ITelecomService service = getTelecomService();
|
||||
if (service != null) {
|
||||
try {
|
||||
service.unregisterPhoneAccount(accountHandle);
|
||||
} catch (RemoteException e) {
|
||||
Log.e(TAG, "Error calling ITelecomService#unregisterPhoneAccount", e);
|
||||
}
|
||||
} catch (RemoteException e) {
|
||||
Log.e(TAG, "Error calling ITelecomService#unregisterPhoneAccount", e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1379,12 +1395,13 @@ public class TelecomManager {
|
||||
@SystemApi
|
||||
@SuppressLint("RequiresPermission")
|
||||
public void clearAccounts() {
|
||||
try {
|
||||
if (isServiceConnected()) {
|
||||
getTelecomService().clearAccounts(mContext.getPackageName());
|
||||
ITelecomService service = getTelecomService();
|
||||
if (service != null) {
|
||||
try {
|
||||
service.clearAccounts(mContext.getPackageName());
|
||||
} catch (RemoteException e) {
|
||||
Log.e(TAG, "Error calling ITelecomService#clearAccounts", e);
|
||||
}
|
||||
} catch (RemoteException e) {
|
||||
Log.e(TAG, "Error calling ITelecomService#clearAccounts", e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1393,12 +1410,15 @@ public class TelecomManager {
|
||||
* @hide
|
||||
*/
|
||||
public void clearAccountsForPackage(String packageName) {
|
||||
try {
|
||||
if (isServiceConnected() && !TextUtils.isEmpty(packageName)) {
|
||||
getTelecomService().clearAccounts(packageName);
|
||||
ITelecomService service = getTelecomService();
|
||||
if (service != null) {
|
||||
try {
|
||||
if (!TextUtils.isEmpty(packageName)) {
|
||||
service.clearAccounts(packageName);
|
||||
}
|
||||
} catch (RemoteException e) {
|
||||
Log.e(TAG, "Error calling ITelecomService#clearAccountsForPackage", e);
|
||||
}
|
||||
} catch (RemoteException e) {
|
||||
Log.e(TAG, "Error calling ITelecomService#clearAccountsForPackage", e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1411,12 +1431,13 @@ public class TelecomManager {
|
||||
@SystemApi
|
||||
@SuppressLint("RequiresPermission")
|
||||
public ComponentName getDefaultPhoneApp() {
|
||||
try {
|
||||
if (isServiceConnected()) {
|
||||
return getTelecomService().getDefaultPhoneApp();
|
||||
ITelecomService service = getTelecomService();
|
||||
if (service != null) {
|
||||
try {
|
||||
return service.getDefaultPhoneApp();
|
||||
} catch (RemoteException e) {
|
||||
Log.e(TAG, "RemoteException attempting to get the default phone app.", e);
|
||||
}
|
||||
} catch (RemoteException e) {
|
||||
Log.e(TAG, "RemoteException attempting to get the default phone app.", e);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@@ -1428,12 +1449,13 @@ public class TelecomManager {
|
||||
* selected as the default dialer.
|
||||
*/
|
||||
public String getDefaultDialerPackage() {
|
||||
try {
|
||||
if (isServiceConnected()) {
|
||||
return getTelecomService().getDefaultDialerPackage();
|
||||
ITelecomService service = getTelecomService();
|
||||
if (service != null) {
|
||||
try {
|
||||
return service.getDefaultDialerPackage();
|
||||
} catch (RemoteException e) {
|
||||
Log.e(TAG, "RemoteException attempting to get the default dialer package name.", e);
|
||||
}
|
||||
} catch (RemoteException e) {
|
||||
Log.e(TAG, "RemoteException attempting to get the default dialer package name.", e);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@@ -1449,13 +1471,14 @@ public class TelecomManager {
|
||||
@SystemApi
|
||||
@RequiresPermission(READ_PRIVILEGED_PHONE_STATE)
|
||||
public @Nullable String getDefaultDialerPackage(@NonNull UserHandle userHandle) {
|
||||
try {
|
||||
if (isServiceConnected()) {
|
||||
return getTelecomService().getDefaultDialerPackageForUser(
|
||||
ITelecomService service = getTelecomService();
|
||||
if (service != null) {
|
||||
try {
|
||||
return service.getDefaultDialerPackageForUser(
|
||||
userHandle.getIdentifier());
|
||||
} catch (RemoteException e) {
|
||||
Log.e(TAG, "RemoteException attempting to get the default dialer package name.", e);
|
||||
}
|
||||
} catch (RemoteException e) {
|
||||
Log.e(TAG, "RemoteException attempting to get the default dialer package name.", e);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@@ -1482,12 +1505,13 @@ public class TelecomManager {
|
||||
android.Manifest.permission.MODIFY_PHONE_STATE,
|
||||
android.Manifest.permission.WRITE_SECURE_SETTINGS})
|
||||
public boolean setDefaultDialer(@Nullable String packageName) {
|
||||
try {
|
||||
if (isServiceConnected()) {
|
||||
return getTelecomService().setDefaultDialer(packageName);
|
||||
ITelecomService service = getTelecomService();
|
||||
if (service != null) {
|
||||
try {
|
||||
return service.setDefaultDialer(packageName);
|
||||
} catch (RemoteException e) {
|
||||
Log.e(TAG, "RemoteException attempting to set the default dialer.", e);
|
||||
}
|
||||
} catch (RemoteException e) {
|
||||
Log.e(TAG, "RemoteException attempting to set the default dialer.", e);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -1499,12 +1523,13 @@ public class TelecomManager {
|
||||
* preloaded.
|
||||
*/
|
||||
public @Nullable String getSystemDialerPackage() {
|
||||
try {
|
||||
if (isServiceConnected()) {
|
||||
return getTelecomService().getSystemDialerPackage();
|
||||
ITelecomService service = getTelecomService();
|
||||
if (service != null) {
|
||||
try {
|
||||
return service.getSystemDialerPackage();
|
||||
} catch (RemoteException e) {
|
||||
Log.e(TAG, "RemoteException attempting to get the system dialer package name.", e);
|
||||
}
|
||||
} catch (RemoteException e) {
|
||||
Log.e(TAG, "RemoteException attempting to get the system dialer package name.", e);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@@ -1518,13 +1543,14 @@ public class TelecomManager {
|
||||
*/
|
||||
@RequiresPermission(android.Manifest.permission.READ_PHONE_STATE)
|
||||
public boolean isVoiceMailNumber(PhoneAccountHandle accountHandle, String number) {
|
||||
try {
|
||||
if (isServiceConnected()) {
|
||||
return getTelecomService().isVoiceMailNumber(accountHandle, number,
|
||||
ITelecomService service = getTelecomService();
|
||||
if (service != null) {
|
||||
try {
|
||||
return service.isVoiceMailNumber(accountHandle, number,
|
||||
mContext.getOpPackageName(), mContext.getAttributionTag());
|
||||
} catch (RemoteException e) {
|
||||
Log.e(TAG, "RemoteException calling ITelecomService#isVoiceMailNumber.", e);
|
||||
}
|
||||
} catch (RemoteException e) {
|
||||
Log.e(TAG, "RemoteException calling ITelecomService#isVoiceMailNumber.", e);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -1538,13 +1564,14 @@ public class TelecomManager {
|
||||
*/
|
||||
@RequiresPermission(android.Manifest.permission.READ_PHONE_STATE)
|
||||
public String getVoiceMailNumber(PhoneAccountHandle accountHandle) {
|
||||
try {
|
||||
if (isServiceConnected()) {
|
||||
return getTelecomService().getVoiceMailNumber(accountHandle,
|
||||
ITelecomService service = getTelecomService();
|
||||
if (service != null) {
|
||||
try {
|
||||
return service.getVoiceMailNumber(accountHandle,
|
||||
mContext.getOpPackageName(), mContext.getAttributionTag());
|
||||
} catch (RemoteException e) {
|
||||
Log.e(TAG, "RemoteException calling ITelecomService#hasVoiceMailNumber.", e);
|
||||
}
|
||||
} catch (RemoteException e) {
|
||||
Log.e(TAG, "RemoteException calling ITelecomService#hasVoiceMailNumber.", e);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@@ -1569,13 +1596,14 @@ public class TelecomManager {
|
||||
android.Manifest.permission.READ_PHONE_NUMBERS
|
||||
}, conditional = true)
|
||||
public String getLine1Number(PhoneAccountHandle accountHandle) {
|
||||
try {
|
||||
if (isServiceConnected()) {
|
||||
return getTelecomService().getLine1Number(accountHandle,
|
||||
ITelecomService service = getTelecomService();
|
||||
if (service != null) {
|
||||
try {
|
||||
return service.getLine1Number(accountHandle,
|
||||
mContext.getOpPackageName(), mContext.getAttributionTag());
|
||||
} catch (RemoteException e) {
|
||||
Log.e(TAG, "RemoteException calling ITelecomService#getLine1Number.", e);
|
||||
}
|
||||
} catch (RemoteException e) {
|
||||
Log.e(TAG, "RemoteException calling ITelecomService#getLine1Number.", e);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@@ -1589,13 +1617,14 @@ public class TelecomManager {
|
||||
*/
|
||||
@RequiresPermission(android.Manifest.permission.READ_PHONE_STATE)
|
||||
public boolean isInCall() {
|
||||
try {
|
||||
if (isServiceConnected()) {
|
||||
return getTelecomService().isInCall(mContext.getOpPackageName(),
|
||||
ITelecomService service = getTelecomService();
|
||||
if (service != null) {
|
||||
try {
|
||||
return service.isInCall(mContext.getOpPackageName(),
|
||||
mContext.getAttributionTag());
|
||||
} catch (RemoteException e) {
|
||||
Log.e(TAG, "RemoteException calling isInCall().", e);
|
||||
}
|
||||
} catch (RemoteException e) {
|
||||
Log.e(TAG, "RemoteException calling isInCall().", e);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -1610,15 +1639,16 @@ public class TelecomManager {
|
||||
* companion app; {@code false} otherwise.
|
||||
*/
|
||||
public boolean hasCompanionInCallServiceAccess() {
|
||||
try {
|
||||
if (isServiceConnected()) {
|
||||
return getTelecomService().hasCompanionInCallServiceAccess(
|
||||
ITelecomService service = getTelecomService();
|
||||
if (service != null) {
|
||||
try {
|
||||
return service.hasCompanionInCallServiceAccess(
|
||||
mContext.getOpPackageName());
|
||||
}
|
||||
} catch (RemoteException e) {
|
||||
Log.e(TAG, "RemoteException calling hasCompanionInCallServiceAccess().", e);
|
||||
if (!isSystemProcess()) {
|
||||
e.rethrowAsRuntimeException();
|
||||
} catch (RemoteException e) {
|
||||
Log.e(TAG, "RemoteException calling hasCompanionInCallServiceAccess().", e);
|
||||
if (!isSystemProcess()) {
|
||||
e.rethrowAsRuntimeException();
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
@@ -1637,13 +1667,14 @@ public class TelecomManager {
|
||||
*/
|
||||
@RequiresPermission(android.Manifest.permission.READ_PHONE_STATE)
|
||||
public boolean isInManagedCall() {
|
||||
try {
|
||||
if (isServiceConnected()) {
|
||||
return getTelecomService().isInManagedCall(mContext.getOpPackageName(),
|
||||
ITelecomService service = getTelecomService();
|
||||
if (service != null) {
|
||||
try {
|
||||
return service.isInManagedCall(mContext.getOpPackageName(),
|
||||
mContext.getAttributionTag());
|
||||
} catch (RemoteException e) {
|
||||
Log.e(TAG, "RemoteException calling isInManagedCall().", e);
|
||||
}
|
||||
} catch (RemoteException e) {
|
||||
Log.e(TAG, "RemoteException calling isInManagedCall().", e);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -1666,12 +1697,13 @@ public class TelecomManager {
|
||||
*/
|
||||
@SystemApi
|
||||
public @CallState int getCallState() {
|
||||
try {
|
||||
if (isServiceConnected()) {
|
||||
return getTelecomService().getCallState();
|
||||
ITelecomService service = getTelecomService();
|
||||
if (service != null) {
|
||||
try {
|
||||
return service.getCallState();
|
||||
} catch (RemoteException e) {
|
||||
Log.d(TAG, "RemoteException calling getCallState().", e);
|
||||
}
|
||||
} catch (RemoteException e) {
|
||||
Log.d(TAG, "RemoteException calling getCallState().", e);
|
||||
}
|
||||
return TelephonyManager.CALL_STATE_IDLE;
|
||||
}
|
||||
@@ -1688,12 +1720,13 @@ public class TelecomManager {
|
||||
android.Manifest.permission.READ_PHONE_STATE
|
||||
})
|
||||
public boolean isRinging() {
|
||||
try {
|
||||
if (isServiceConnected()) {
|
||||
return getTelecomService().isRinging(mContext.getOpPackageName());
|
||||
ITelecomService service = getTelecomService();
|
||||
if (service != null) {
|
||||
try {
|
||||
return service.isRinging(mContext.getOpPackageName());
|
||||
} catch (RemoteException e) {
|
||||
Log.e(TAG, "RemoteException attempting to get ringing state of phone app.", e);
|
||||
}
|
||||
} catch (RemoteException e) {
|
||||
Log.e(TAG, "RemoteException attempting to get ringing state of phone app.", e);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -1716,12 +1749,13 @@ public class TelecomManager {
|
||||
@RequiresPermission(Manifest.permission.ANSWER_PHONE_CALLS)
|
||||
@Deprecated
|
||||
public boolean endCall() {
|
||||
try {
|
||||
if (isServiceConnected()) {
|
||||
return getTelecomService().endCall(mContext.getPackageName());
|
||||
ITelecomService service = getTelecomService();
|
||||
if (service != null) {
|
||||
try {
|
||||
return service.endCall(mContext.getPackageName());
|
||||
} catch (RemoteException e) {
|
||||
Log.e(TAG, "Error calling ITelecomService#endCall", e);
|
||||
}
|
||||
} catch (RemoteException e) {
|
||||
Log.e(TAG, "Error calling ITelecomService#endCall", e);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -1742,12 +1776,13 @@ public class TelecomManager {
|
||||
{Manifest.permission.ANSWER_PHONE_CALLS, Manifest.permission.MODIFY_PHONE_STATE})
|
||||
@Deprecated
|
||||
public void acceptRingingCall() {
|
||||
try {
|
||||
if (isServiceConnected()) {
|
||||
getTelecomService().acceptRingingCall(mContext.getPackageName());
|
||||
ITelecomService service = getTelecomService();
|
||||
if (service != null) {
|
||||
try {
|
||||
service.acceptRingingCall(mContext.getPackageName());
|
||||
} catch (RemoteException e) {
|
||||
Log.e(TAG, "Error calling ITelecomService#acceptRingingCall", e);
|
||||
}
|
||||
} catch (RemoteException e) {
|
||||
Log.e(TAG, "Error calling ITelecomService#acceptRingingCall", e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1763,13 +1798,14 @@ public class TelecomManager {
|
||||
{Manifest.permission.ANSWER_PHONE_CALLS, Manifest.permission.MODIFY_PHONE_STATE})
|
||||
@Deprecated
|
||||
public void acceptRingingCall(int videoState) {
|
||||
try {
|
||||
if (isServiceConnected()) {
|
||||
getTelecomService().acceptRingingCallWithVideoState(
|
||||
ITelecomService service = getTelecomService();
|
||||
if (service != null) {
|
||||
try {
|
||||
service.acceptRingingCallWithVideoState(
|
||||
mContext.getPackageName(), videoState);
|
||||
} catch (RemoteException e) {
|
||||
Log.e(TAG, "Error calling ITelecomService#acceptRingingCallWithVideoState", e);
|
||||
}
|
||||
} catch (RemoteException e) {
|
||||
Log.e(TAG, "Error calling ITelecomService#acceptRingingCallWithVideoState", e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1793,12 +1829,13 @@ public class TelecomManager {
|
||||
*/
|
||||
@RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE)
|
||||
public void silenceRinger() {
|
||||
try {
|
||||
if (isServiceConnected()) {
|
||||
getTelecomService().silenceRinger(mContext.getOpPackageName());
|
||||
ITelecomService service = getTelecomService();
|
||||
if (service != null) {
|
||||
try {
|
||||
service.silenceRinger(mContext.getOpPackageName());
|
||||
} catch (RemoteException e) {
|
||||
Log.e(TAG, "Error calling ITelecomService#silenceRinger", e);
|
||||
}
|
||||
} catch (RemoteException e) {
|
||||
Log.e(TAG, "Error calling ITelecomService#silenceRinger", e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1810,13 +1847,14 @@ public class TelecomManager {
|
||||
android.Manifest.permission.READ_PHONE_STATE
|
||||
})
|
||||
public boolean isTtySupported() {
|
||||
try {
|
||||
if (isServiceConnected()) {
|
||||
return getTelecomService().isTtySupported(mContext.getOpPackageName(),
|
||||
ITelecomService service = getTelecomService();
|
||||
if (service != null) {
|
||||
try {
|
||||
return service.isTtySupported(mContext.getOpPackageName(),
|
||||
mContext.getAttributionTag());
|
||||
} catch (RemoteException e) {
|
||||
Log.e(TAG, "RemoteException attempting to get TTY supported state.", e);
|
||||
}
|
||||
} catch (RemoteException e) {
|
||||
Log.e(TAG, "RemoteException attempting to get TTY supported state.", e);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -1834,13 +1872,14 @@ public class TelecomManager {
|
||||
@SystemApi
|
||||
@RequiresPermission(READ_PRIVILEGED_PHONE_STATE)
|
||||
public @TtyMode int getCurrentTtyMode() {
|
||||
try {
|
||||
if (isServiceConnected()) {
|
||||
return getTelecomService().getCurrentTtyMode(mContext.getOpPackageName(),
|
||||
ITelecomService service = getTelecomService();
|
||||
if (service != null) {
|
||||
try {
|
||||
return service.getCurrentTtyMode(mContext.getOpPackageName(),
|
||||
mContext.getAttributionTag());
|
||||
} catch (RemoteException e) {
|
||||
Log.e(TAG, "RemoteException attempting to get the current TTY mode.", e);
|
||||
}
|
||||
} catch (RemoteException e) {
|
||||
Log.e(TAG, "RemoteException attempting to get the current TTY mode.", e);
|
||||
}
|
||||
return TTY_MODE_OFF;
|
||||
}
|
||||
@@ -1876,8 +1915,9 @@ public class TelecomManager {
|
||||
* {@link ConnectionService#onCreateIncomingConnection}.
|
||||
*/
|
||||
public void addNewIncomingCall(PhoneAccountHandle phoneAccount, Bundle extras) {
|
||||
try {
|
||||
if (isServiceConnected()) {
|
||||
ITelecomService service = getTelecomService();
|
||||
if (service != null) {
|
||||
try {
|
||||
if (extras != null && extras.getBoolean(EXTRA_IS_HANDOVER) &&
|
||||
mContext.getApplicationContext().getApplicationInfo().targetSdkVersion >
|
||||
Build.VERSION_CODES.O_MR1) {
|
||||
@@ -1885,11 +1925,10 @@ public class TelecomManager {
|
||||
"acceptHandover for API > O-MR1");
|
||||
return;
|
||||
}
|
||||
getTelecomService().addNewIncomingCall(
|
||||
phoneAccount, extras == null ? new Bundle() : extras);
|
||||
service.addNewIncomingCall(phoneAccount, extras == null ? new Bundle() : extras);
|
||||
} catch (RemoteException e) {
|
||||
Log.e(TAG, "RemoteException adding a new incoming call: " + phoneAccount, e);
|
||||
}
|
||||
} catch (RemoteException e) {
|
||||
Log.e(TAG, "RemoteException adding a new incoming call: " + phoneAccount, e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1924,13 +1963,14 @@ public class TelecomManager {
|
||||
*/
|
||||
public void addNewIncomingConference(@NonNull PhoneAccountHandle phoneAccount,
|
||||
@NonNull Bundle extras) {
|
||||
try {
|
||||
if (isServiceConnected()) {
|
||||
getTelecomService().addNewIncomingConference(
|
||||
ITelecomService service = getTelecomService();
|
||||
if (service != null) {
|
||||
try {
|
||||
service.addNewIncomingConference(
|
||||
phoneAccount, extras == null ? new Bundle() : extras);
|
||||
} catch (RemoteException e) {
|
||||
Log.e(TAG, "RemoteException adding a new incoming conference: " + phoneAccount, e);
|
||||
}
|
||||
} catch (RemoteException e) {
|
||||
Log.e(TAG, "RemoteException adding a new incoming conference: " + phoneAccount, e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1947,13 +1987,14 @@ public class TelecomManager {
|
||||
*/
|
||||
@SystemApi
|
||||
public void addNewUnknownCall(PhoneAccountHandle phoneAccount, Bundle extras) {
|
||||
try {
|
||||
if (isServiceConnected()) {
|
||||
getTelecomService().addNewUnknownCall(
|
||||
ITelecomService service = getTelecomService();
|
||||
if (service != null) {
|
||||
try {
|
||||
service.addNewUnknownCall(
|
||||
phoneAccount, extras == null ? new Bundle() : extras);
|
||||
} catch (RemoteException e) {
|
||||
Log.e(TAG, "RemoteException adding a new unknown call: " + phoneAccount, e);
|
||||
}
|
||||
} catch (RemoteException e) {
|
||||
Log.e(TAG, "RemoteException adding a new unknown call: " + phoneAccount, e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2374,12 +2415,13 @@ public class TelecomManager {
|
||||
*/
|
||||
public void acceptHandover(Uri srcAddr, @VideoProfile.VideoState int videoState,
|
||||
PhoneAccountHandle destAcct) {
|
||||
try {
|
||||
if (isServiceConnected()) {
|
||||
getTelecomService().acceptHandover(srcAddr, videoState, destAcct);
|
||||
ITelecomService service = getTelecomService();
|
||||
if (service != null) {
|
||||
try {
|
||||
service.acceptHandover(srcAddr, videoState, destAcct);
|
||||
} catch (RemoteException e) {
|
||||
Log.e(TAG, "RemoteException acceptHandover: " + e);
|
||||
}
|
||||
} catch (RemoteException e) {
|
||||
Log.e(TAG, "RemoteException acceptHandover: " + e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2393,13 +2435,14 @@ public class TelecomManager {
|
||||
@SystemApi
|
||||
@RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE)
|
||||
public boolean isInEmergencyCall() {
|
||||
try {
|
||||
if (isServiceConnected()) {
|
||||
return getTelecomService().isInEmergencyCall();
|
||||
ITelecomService service = getTelecomService();
|
||||
if (service != null) {
|
||||
try {
|
||||
return service.isInEmergencyCall();
|
||||
} catch (RemoteException e) {
|
||||
Log.e(TAG, "RemoteException isInEmergencyCall: " + e);
|
||||
return false;
|
||||
}
|
||||
} catch (RemoteException e) {
|
||||
Log.e(TAG, "RemoteException isInEmergencyCall: " + e);
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -2411,12 +2454,13 @@ public class TelecomManager {
|
||||
* @hide
|
||||
*/
|
||||
public void handleCallIntent(Intent intent, String callingPackageProxy) {
|
||||
try {
|
||||
if (isServiceConnected()) {
|
||||
getTelecomService().handleCallIntent(intent, callingPackageProxy);
|
||||
ITelecomService service = getTelecomService();
|
||||
if (service != null) {
|
||||
try {
|
||||
service.handleCallIntent(intent, callingPackageProxy);
|
||||
} catch (RemoteException e) {
|
||||
Log.e(TAG, "RemoteException handleCallIntent: " + e);
|
||||
}
|
||||
} catch (RemoteException e) {
|
||||
Log.e(TAG, "RemoteException handleCallIntent: " + e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2428,14 +2472,11 @@ public class TelecomManager {
|
||||
if (mTelecomServiceOverride != null) {
|
||||
return mTelecomServiceOverride;
|
||||
}
|
||||
return ITelecomService.Stub.asInterface(ServiceManager.getService(Context.TELECOM_SERVICE));
|
||||
}
|
||||
|
||||
private boolean isServiceConnected() {
|
||||
boolean isConnected = getTelecomService() != null;
|
||||
if (!isConnected) {
|
||||
ITelecomService service = ITelecomService.Stub.asInterface(
|
||||
ServiceManager.getService(Context.TELECOM_SERVICE));
|
||||
if (service == null) {
|
||||
Log.w(TAG, "Telecom Service not found.");
|
||||
}
|
||||
return isConnected;
|
||||
return service;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user