diff options
Diffstat (limited to 'shadows/framework/src/main/java/org/robolectric/shadows/ShadowTelecomManager.java')
-rw-r--r-- | shadows/framework/src/main/java/org/robolectric/shadows/ShadowTelecomManager.java | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/shadows/framework/src/main/java/org/robolectric/shadows/ShadowTelecomManager.java b/shadows/framework/src/main/java/org/robolectric/shadows/ShadowTelecomManager.java index 87dbf83e1..2a8459609 100644 --- a/shadows/framework/src/main/java/org/robolectric/shadows/ShadowTelecomManager.java +++ b/shadows/framework/src/main/java/org/robolectric/shadows/ShadowTelecomManager.java @@ -1,13 +1,16 @@ package org.robolectric.shadows; +import static android.os.Build.VERSION.SDK_INT; import static android.os.Build.VERSION_CODES.LOLLIPOP; import static android.os.Build.VERSION_CODES.LOLLIPOP_MR1; import static android.os.Build.VERSION_CODES.M; import static android.os.Build.VERSION_CODES.N; import static android.os.Build.VERSION_CODES.O; import static android.os.Build.VERSION_CODES.R; +import static android.os.Build.VERSION_CODES.UPSIDE_DOWN_CAKE; import static com.google.common.base.Verify.verifyNotNull; +import android.annotation.Nullable; import android.annotation.SystemApi; import android.annotation.TargetApi; import android.bluetooth.BluetoothDevice; @@ -27,7 +30,6 @@ import android.telecom.TelecomManager; import android.telecom.VideoProfile; import android.text.TextUtils; import android.util.ArrayMap; -import androidx.annotation.Nullable; import com.google.common.collect.ImmutableList; import com.google.common.collect.Iterables; import java.util.ArrayList; @@ -245,9 +247,22 @@ public class ShadowTelecomManager { @Implementation protected void registerPhoneAccount(PhoneAccount account) { + account = adjustCapabilities(account); accounts.put(account.getAccountHandle(), account); } + private PhoneAccount adjustCapabilities(PhoneAccount account) { + // Mirror the capabilities adjustments done in com.android.server.telecom.PhoneAccountRegistrar. + if (SDK_INT >= UPSIDE_DOWN_CAKE + && account.hasCapabilities(PhoneAccount.CAPABILITY_SUPPORTS_TRANSACTIONAL_OPERATIONS) + && !account.hasCapabilities(PhoneAccount.CAPABILITY_SELF_MANAGED)) { + return account.toBuilder() + .setCapabilities(account.getCapabilities() | PhoneAccount.CAPABILITY_SELF_MANAGED) + .build(); + } + return account; + } + @Implementation protected void unregisterPhoneAccount(PhoneAccountHandle accountHandle) { accounts.remove(accountHandle); |