[automerger skipped] Merge "Import translations. DO NOT MERGE ANYWHERE" into tm-d1-dev am: 04609d5747 -s ours am: 16d2b3291a -s ours
am skip reason: subject contains skip directive
Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/services/Telecomm/+/20082857
Change-Id: I73291f62522118bfed24f6c112830838543753b3
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
diff --git a/res/values-night/styles.xml b/res/values-night/styles.xml
new file mode 100644
index 0000000..5b81fac
--- /dev/null
+++ b/res/values-night/styles.xml
@@ -0,0 +1,36 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ ~ Copyright (C) 2022 The Android Open Source Project
+ ~
+ ~ Licensed under the Apache License, Version 2.0 (the "License");
+ ~ you may not use this file except in compliance with the License.
+ ~ You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing, software
+ ~ distributed under the License is distributed on an "AS IS" BASIS,
+ ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ ~ See the License for the specific language governing permissions and
+ ~ limitations under the License.
+ -->
+
+<resources>
+
+ <style name="Theme.Telecom.DialerSettings" parent="@android:style/Theme.DeviceDefault.Light">
+ <item name="android:forceDarkAllowed">true</item>
+ <item name="android:actionBarStyle">@style/TelecomDialerSettingsActionBarStyle</item>
+ <item name="android:actionOverflowButtonStyle">@style/TelecomDialerSettingsActionOverflowButtonStyle</item>
+ <item name="android:windowLightNavigationBar">true</item>
+ <item name="android:windowContentOverlay">@null</item>
+ </style>
+
+ <style name="Theme.Telecom.BlockedNumbers" parent="@android:style/Theme.DeviceDefault.Light">
+ <item name="android:forceDarkAllowed">true</item>
+ <item name="android:actionBarStyle">@style/TelecomDialerSettingsActionBarStyle</item>
+ <item name="android:windowLightNavigationBar">true</item>
+ <item name="android:windowContentOverlay">@null</item>
+ <item name="android:listDivider">@null</item>
+ </style>
+
+</resources>
\ No newline at end of file
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 6b8c0b2..bf5abca 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -73,8 +73,8 @@
that a call be put into the background so that the app can access the audio from the call.
[CHAR LIMIT=NONE] -->
<string name="notification_audioProcessing_body">
- <xliff:g id="audio_processing_app_name">%s</xliff:g> has placed a call into the
- background. This app may be accessing and playing audio over the call.
+ <xliff:g id="audio_processing_app_name">%s</xliff:g> is processing a call in the background.
+ This app may be accessing and playing audio over the call.
</string>
<!-- Crashed in call service notification label, used when the in call service has crashed and
diff --git a/src/com/android/server/telecom/CallScreeningServiceHelper.java b/src/com/android/server/telecom/CallScreeningServiceHelper.java
index 167bd1b..c1aff3d 100644
--- a/src/com/android/server/telecom/CallScreeningServiceHelper.java
+++ b/src/com/android/server/telecom/CallScreeningServiceHelper.java
@@ -210,7 +210,8 @@
if (context.bindServiceAsUser(
intent,
serviceConnection,
- Context.BIND_AUTO_CREATE | Context.BIND_FOREGROUND_SERVICE,
+ Context.BIND_AUTO_CREATE | Context.BIND_FOREGROUND_SERVICE
+ | Context.BIND_SCHEDULE_LIKE_TOP_APP,
UserHandle.CURRENT)) {
Log.d(TAG, "bindService, found service, waiting for it to connect");
return true;
diff --git a/src/com/android/server/telecom/CallsManager.java b/src/com/android/server/telecom/CallsManager.java
index 4d829bb..5c749fc 100755
--- a/src/com/android/server/telecom/CallsManager.java
+++ b/src/com/android/server/telecom/CallsManager.java
@@ -2287,17 +2287,37 @@
mPendingRedirectedOutgoingCallInfo.remove(pendingCallId);
mPendingUnredirectedOutgoingCallInfo.remove(pendingCallId);
}
+ switch (action) {
+ case TelecomBroadcastIntentProcessor.ACTION_PLACE_REDIRECTED_CALL: {
+ Runnable r = mPendingRedirectedOutgoingCallInfo.get(callId);
+ if (r != null) {
+ mHandler.post(r.prepare());
+ } else {
+ Log.w(this, "Processing %s for canceled Call ID %s",
+ action, callId);
+ }
+ break;
+ }
+ case TelecomBroadcastIntentProcessor.ACTION_PLACE_UNREDIRECTED_CALL: {
+ Runnable r = mPendingUnredirectedOutgoingCallInfo.get(callId);
+ if (r != null) {
+ mHandler.post(r.prepare());
+ } else {
+ Log.w(this, "Processing %s for canceled Call ID %s",
+ action, callId);
+ }
+ break;
+ }
+ case TelecomBroadcastIntentProcessor.ACTION_CANCEL_REDIRECTED_CALL: {
+ Log.addEvent(mPendingRedirectedOutgoingCall,
+ LogUtils.Events.REDIRECTION_USER_CANCELLED);
+ mPendingRedirectedOutgoingCall.disconnect("User canceled the redirected call.");
+ break;
+ }
+ default: {
+ // Unexpected, ignore
+ }
- if (action.equals(TelecomBroadcastIntentProcessor.ACTION_PLACE_REDIRECTED_CALL)) {
- mHandler.post(mPendingRedirectedOutgoingCallInfo.get(callId).prepare());
- } else if (action.equals(
- TelecomBroadcastIntentProcessor.ACTION_PLACE_UNREDIRECTED_CALL)) {
- mHandler.post(mPendingUnredirectedOutgoingCallInfo.get(callId).prepare());
- } else if (action.equals(
- TelecomBroadcastIntentProcessor.ACTION_CANCEL_REDIRECTED_CALL)) {
- Log.addEvent(mPendingRedirectedOutgoingCall,
- LogUtils.Events.REDIRECTION_USER_CANCELLED);
- mPendingRedirectedOutgoingCall.disconnect("User canceled the redirected call.");
}
mPendingRedirectedOutgoingCall = null;
mPendingRedirectedOutgoingCallInfo.remove(callId);
diff --git a/src/com/android/server/telecom/InCallController.java b/src/com/android/server/telecom/InCallController.java
index ec87555..9a53575 100644
--- a/src/com/android/server/telecom/InCallController.java
+++ b/src/com/android/server/telecom/InCallController.java
@@ -322,7 +322,8 @@
mInCallServiceInfo.setBindingStartTime(mClockProxy.elapsedRealtime());
if (!mContext.bindServiceAsUser(intent, mServiceConnection,
Context.BIND_AUTO_CREATE | Context.BIND_FOREGROUND_SERVICE
- | Context.BIND_ALLOW_BACKGROUND_ACTIVITY_STARTS,
+ | Context.BIND_ALLOW_BACKGROUND_ACTIVITY_STARTS
+ | Context.BIND_SCHEDULE_LIKE_TOP_APP,
UserHandle.CURRENT)) {
Log.w(this, "Failed to connect.");
mIsConnected = false;
diff --git a/src/com/android/server/telecom/Ringer.java b/src/com/android/server/telecom/Ringer.java
index b29b500..bf678d2 100644
--- a/src/com/android/server/telecom/Ringer.java
+++ b/src/com/android/server/telecom/Ringer.java
@@ -275,7 +275,7 @@
VibrationEffect effect;
CompletableFuture<Boolean> hapticsFuture = null;
// Determine if the settings and DND mode indicate that the vibrator can be used right now.
- boolean isVibratorEnabled = isVibratorEnabled(mContext);
+ boolean isVibratorEnabled = isVibratorEnabled(mContext, attributes.shouldRingForContact());
boolean shouldApplyRampingRinger =
isVibratorEnabled && mSystemSettingsUtil.isRampingRingerEnabled(mContext);
if (attributes.isRingerAudible()) {
@@ -367,7 +367,7 @@
"hasVibrator=%b, userRequestsVibrate=%b, ringerMode=%d, isVibrating=%b",
mVibrator.hasVibrator(),
mSystemSettingsUtil.isRingVibrationEnabled(mContext),
- mAudioManager.getRingerModeInternal(), mIsVibrating);
+ mAudioManager.getRingerMode(), mIsVibrating);
if (mSystemSettingsUtil.isRampingRingerEnabled(mContext) && isRingerAudible) {
Log.i(this, "start vibration for ramping ringer.");
} else {
@@ -381,7 +381,7 @@
"hasVibrator=%b, userRequestsVibrate=%b, ringerMode=%d, isVibrating=%b",
mVibrator.hasVibrator(),
mSystemSettingsUtil.isRingVibrationEnabled(mContext),
- mAudioManager.getRingerModeInternal(), mIsVibrating);
+ mAudioManager.getRingerMode(), mIsVibrating);
}
}
}
@@ -503,11 +503,14 @@
}
}
- private boolean isVibratorEnabled(Context context) {
+ private boolean isVibratorEnabled(Context context, boolean shouldRingForContact) {
AudioManager audioManager = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE);
+ // Use AudioManager#getRingerMode for more accurate result, instead of
+ // AudioManager#getRingerModeInternal which only useful for volume controllers
return mVibrator.hasVibrator()
&& mSystemSettingsUtil.isRingVibrationEnabled(context)
- && audioManager.getRingerModeInternal() != AudioManager.RINGER_MODE_SILENT;
+ && (audioManager.getRingerMode() != AudioManager.RINGER_MODE_SILENT
+ || shouldRingForContact);
}
private RingerAttributes getRingerAttributes(Call call, boolean isHfpDeviceAttached) {
diff --git a/src/com/android/server/telecom/RingtoneFactory.java b/src/com/android/server/telecom/RingtoneFactory.java
index b1846fe..5c46998 100644
--- a/src/com/android/server/telecom/RingtoneFactory.java
+++ b/src/com/android/server/telecom/RingtoneFactory.java
@@ -73,11 +73,13 @@
Uri ringtoneUri = incomingCall.getRingtone();
Ringtone ringtone = null;
+ AudioAttributes audioAttrs = getRingtoneAudioAttributes();
+
if(ringtoneUri != null && userContext != null) {
// Ringtone URI is explicitly specified. First, try to create a Ringtone with that.
try {
- ringtone = RingtoneManager.getRingtone(userContext, ringtoneUri,
- volumeShaperConfig);
+ ringtone = RingtoneManager.getRingtone(
+ userContext, ringtoneUri, volumeShaperConfig, audioAttrs);
} catch (NullPointerException npe) {
Log.e(this, npe, "getRingtone: NPE while getting ringtone.");
}
@@ -104,12 +106,19 @@
}
try {
ringtone = RingtoneManager.getRingtone(
- contextToUse, defaultRingtoneUri, volumeShaperConfig);
+ contextToUse, defaultRingtoneUri, volumeShaperConfig, audioAttrs);
} catch (NullPointerException npe) {
Log.e(this, npe, "getRingtone: NPE while getting ringtone.");
}
}
- return setRingtoneAudioAttributes(ringtone);
+ return ringtone;
+ }
+
+ public AudioAttributes getRingtoneAudioAttributes() {
+ return new AudioAttributes.Builder()
+ .setUsage(AudioAttributes.USAGE_NOTIFICATION_RINGTONE)
+ .setContentType(AudioAttributes.CONTENT_TYPE_SONIFICATION)
+ .build();
}
public Ringtone getRingtone(Call incomingCall) {
@@ -121,21 +130,12 @@
public Ringtone getHapticOnlyRingtone() {
Uri ringtoneUri = Uri.parse("file://" + mContext.getString(
com.android.internal.R.string.config_defaultRingtoneVibrationSound));
- Ringtone ringtone = RingtoneManager.getRingtone(mContext, ringtoneUri, null);
+ AudioAttributes audioAttrs = getRingtoneAudioAttributes();
+ Ringtone ringtone = RingtoneManager.getRingtone(mContext, ringtoneUri, null, audioAttrs);
if (ringtone != null) {
// Make sure the sound is muted.
ringtone.setVolume(0);
}
- return setRingtoneAudioAttributes(ringtone);
- }
-
- private Ringtone setRingtoneAudioAttributes(Ringtone ringtone) {
- if (ringtone != null) {
- ringtone.setAudioAttributes(new AudioAttributes.Builder()
- .setUsage(AudioAttributes.USAGE_NOTIFICATION_RINGTONE)
- .setContentType(AudioAttributes.CONTENT_TYPE_SONIFICATION)
- .build());
- }
return ringtone;
}
diff --git a/src/com/android/server/telecom/TelecomServiceImpl.java b/src/com/android/server/telecom/TelecomServiceImpl.java
index ee7aba6..5015099 100644
--- a/src/com/android/server/telecom/TelecomServiceImpl.java
+++ b/src/com/android/server/telecom/TelecomServiceImpl.java
@@ -1520,7 +1520,6 @@
enforceCallingPackage(callingPackage, "placeCall");
PhoneAccountHandle phoneAccountHandle = null;
- boolean clearPhoneAccountHandleExtra = false;
if (extras != null) {
phoneAccountHandle = extras.getParcelable(
TelecomManager.EXTRA_PHONE_ACCOUNT_HANDLE);
@@ -1529,32 +1528,28 @@
extras.remove(TelecomManager.EXTRA_IS_HANDOVER);
}
}
- boolean isSelfManaged = phoneAccountHandle != null &&
- isSelfManagedConnectionService(phoneAccountHandle);
- if (isSelfManaged) {
- try {
- mContext.enforceCallingOrSelfPermission(
- Manifest.permission.MANAGE_OWN_CALLS,
- "Self-managed ConnectionServices require "
- + "MANAGE_OWN_CALLS permission.");
- } catch (SecurityException e) {
- // Fallback to use mobile network to avoid disclosing phone account handle
- // package information
- clearPhoneAccountHandleExtra = true;
- }
+ ComponentName componentName = phoneAccountHandle != null
+ ? phoneAccountHandle.getComponentName() : null;
+ String packageName = componentName != null
+ ? componentName.getPackageName() : null;
- if (!clearPhoneAccountHandleExtra && !callingPackage.equals(
- phoneAccountHandle.getComponentName().getPackageName())
- && !canCallPhone(callingPackage, callingFeatureId,
- "CALL_PHONE permission required to place calls.")) {
- // The caller is not allowed to place calls, so fallback to use mobile
- // network.
- clearPhoneAccountHandleExtra = true;
- }
- } else if (!canCallPhone(callingPackage, callingFeatureId, "placeCall")) {
- throw new SecurityException("Package " + callingPackage
- + " is not allowed to place phone calls");
+ // Two cases here: the app calling this API is trying to place a call on another
+ // ConnectionService or the app calling this API implements a self-managed
+ // ConnectionService and is trying to place a call on their own ConnectionService.
+ // Case 1: If the app does not implement the ConnectionService they are requesting
+ // the call be placed on, ensure they have the correct CALL_PHONE permissions.
+ if (!callingPackage.equals(packageName) && !canCallPhone(callingPackage,
+ callingFeatureId, "CALL_PHONE permission required to place calls.")) {
+ throw new SecurityException("CALL_PHONE permission required to place calls.");
}
+ // Case 2: The package name of the caller matches the package name of the
+ // PhoneAccountHandle, so ensure the app has MANAGE_OWN_CALLS permission.
+ if (callingPackage.equals(packageName)) {
+ mContext.enforceCallingOrSelfPermission(Manifest.permission.MANAGE_OWN_CALLS,
+ "Self-managed ConnectionServices require MANAGE_OWN_CALLS permission.");
+ }
+
+ boolean isSelfManaged = isSelfManagedConnectionService(phoneAccountHandle);
// Note: we can still get here for the default/system dialer, even if the Phone
// permission is turned off. This is because the default/system dialer is always
@@ -1584,9 +1579,6 @@
final Intent intent = new Intent(hasCallPrivilegedPermission ?
Intent.ACTION_CALL_PRIVILEGED : Intent.ACTION_CALL, handle);
if (extras != null) {
- if (clearPhoneAccountHandleExtra) {
- extras.remove(TelecomManager.EXTRA_PHONE_ACCOUNT_HANDLE);
- }
extras.setDefusable(true);
intent.putExtras(extras);
}
diff --git a/src/com/android/server/telecom/bluetooth/BluetoothDeviceManager.java b/src/com/android/server/telecom/bluetooth/BluetoothDeviceManager.java
index fb637a9..7968dca 100644
--- a/src/com/android/server/telecom/bluetooth/BluetoothDeviceManager.java
+++ b/src/com/android/server/telecom/bluetooth/BluetoothDeviceManager.java
@@ -27,6 +27,7 @@
import android.content.Context;
import android.media.AudioManager;
import android.media.AudioDeviceInfo;
+import android.media.audio.common.AudioDevice;
import android.telecom.Log;
import android.util.LocalLog;
@@ -433,9 +434,11 @@
Log.i(this, "clearLeAudioCommunicationDevice: mAudioManager is null");
return;
}
- if (mAudioManager.getCommunicationDevice() != null
- && mAudioManager.getCommunicationDevice().getType()
+
+ AudioDeviceInfo audioDeviceInfo = mAudioManager.getCommunicationDevice();
+ if (audioDeviceInfo != null && audioDeviceInfo.getType()
== AudioDeviceInfo.TYPE_BLE_HEADSET) {
+ mBluetoothRouteManager.onAudioLost(audioDeviceInfo.getAddress());
mAudioManager.clearCommunicationDevice();
}
}
@@ -449,8 +452,9 @@
Log.i(this, "clearHearingAidCommunicationDevice: mAudioManager is null");
return;
}
- if (mAudioManager.getCommunicationDevice() != null
- && mAudioManager.getCommunicationDevice().getType()
+
+ AudioDeviceInfo audioDeviceInfo = mAudioManager.getCommunicationDevice();
+ if (audioDeviceInfo != null && audioDeviceInfo.getType()
== AudioDeviceInfo.TYPE_HEARING_AID) {
mAudioManager.clearCommunicationDevice();
}
diff --git a/tests/src/com/android/server/telecom/tests/CallScreeningServiceFilterTest.java b/tests/src/com/android/server/telecom/tests/CallScreeningServiceFilterTest.java
index 9ff9986..09ba47e 100644
--- a/tests/src/com/android/server/telecom/tests/CallScreeningServiceFilterTest.java
+++ b/tests/src/com/android/server/telecom/tests/CallScreeningServiceFilterTest.java
@@ -395,7 +395,8 @@
.forClass(ServiceConnection.class);
verify(mContext, timeout(CallScreeningServiceFilter.CALL_SCREENING_FILTER_TIMEOUT))
.bindServiceAsUser(intentCaptor.capture(), serviceCaptor.capture(),
- eq(Context.BIND_AUTO_CREATE | Context.BIND_FOREGROUND_SERVICE),
+ eq(Context.BIND_AUTO_CREATE | Context.BIND_FOREGROUND_SERVICE
+ | Context.BIND_SCHEDULE_LIKE_TOP_APP),
eq(UserHandle.CURRENT));
Intent capturedIntent = intentCaptor.getValue();
diff --git a/tests/src/com/android/server/telecom/tests/InCallControllerTests.java b/tests/src/com/android/server/telecom/tests/InCallControllerTests.java
index ddacf43..3d387a8 100644
--- a/tests/src/com/android/server/telecom/tests/InCallControllerTests.java
+++ b/tests/src/com/android/server/telecom/tests/InCallControllerTests.java
@@ -181,6 +181,10 @@
private SystemStateHelper.SystemStateListener mSystemStateListener;
private CarModeTracker mCarModeTracker = spy(new CarModeTracker());
+ private final int serviceBindingFlags = Context.BIND_AUTO_CREATE
+ | Context.BIND_FOREGROUND_SERVICE | Context.BIND_ALLOW_BACKGROUND_ACTIVITY_STARTS
+ | Context.BIND_SCHEDULE_LIKE_TOP_APP;
+
@Override
@Before
public void setUp() throws Exception {
@@ -354,8 +358,7 @@
verify(mMockContext).bindServiceAsUser(
bindIntentCaptor.capture(),
any(ServiceConnection.class),
- eq(Context.BIND_AUTO_CREATE | Context.BIND_FOREGROUND_SERVICE
- | Context.BIND_ALLOW_BACKGROUND_ACTIVITY_STARTS),
+ eq(serviceBindingFlags),
eq(UserHandle.CURRENT));
Intent bindIntent = bindIntentCaptor.getValue();
@@ -389,8 +392,7 @@
verify(mMockContext).bindServiceAsUser(
bindIntentCaptor.capture(),
any(ServiceConnection.class),
- eq(Context.BIND_AUTO_CREATE | Context.BIND_FOREGROUND_SERVICE
- | Context.BIND_ALLOW_BACKGROUND_ACTIVITY_STARTS),
+ eq(serviceBindingFlags),
eq(UserHandle.CURRENT));
Intent bindIntent = bindIntentCaptor.getValue();
@@ -442,8 +444,7 @@
verify(mMockContext, times(1)).bindServiceAsUser(
bindIntentCaptor.capture(),
any(ServiceConnection.class),
- eq(Context.BIND_AUTO_CREATE | Context.BIND_FOREGROUND_SERVICE
- | Context.BIND_ALLOW_BACKGROUND_ACTIVITY_STARTS),
+ eq(serviceBindingFlags),
eq(UserHandle.CURRENT));
Intent bindIntent = bindIntentCaptor.getValue();
@@ -473,8 +474,7 @@
when(mDefaultDialerCache.getDefaultDialerApplication(CURRENT_USER_ID))
.thenReturn(DEF_PKG);
when(mMockContext.bindServiceAsUser(any(Intent.class), any(ServiceConnection.class),
- eq(Context.BIND_AUTO_CREATE | Context.BIND_FOREGROUND_SERVICE
- | Context.BIND_ALLOW_BACKGROUND_ACTIVITY_STARTS),
+ eq(serviceBindingFlags),
eq(UserHandle.CURRENT))).thenReturn(true);
when(mTimeoutsAdapter.getEmergencyCallbackWindowMillis(any(ContentResolver.class)))
.thenReturn(300_000L);
@@ -502,8 +502,7 @@
verify(mMockContext, times(1)).bindServiceAsUser(
bindIntentCaptor.capture(),
any(ServiceConnection.class),
- eq(Context.BIND_AUTO_CREATE | Context.BIND_FOREGROUND_SERVICE
- | Context.BIND_ALLOW_BACKGROUND_ACTIVITY_STARTS),
+ eq(serviceBindingFlags),
eq(UserHandle.CURRENT));
Intent bindIntent = bindIntentCaptor.getValue();
@@ -552,8 +551,7 @@
ArgumentCaptor<ServiceConnection> serviceConnectionCaptor =
ArgumentCaptor.forClass(ServiceConnection.class);
when(mMockContext.bindServiceAsUser(any(Intent.class), serviceConnectionCaptor.capture(),
- eq(Context.BIND_AUTO_CREATE | Context.BIND_FOREGROUND_SERVICE
- | Context.BIND_ALLOW_BACKGROUND_ACTIVITY_STARTS),
+ eq(serviceBindingFlags),
eq(UserHandle.CURRENT))).thenReturn(true);
when(mTimeoutsAdapter.getEmergencyCallbackWindowMillis(any(ContentResolver.class)))
.thenReturn(300_000L);
@@ -581,8 +579,7 @@
verify(mMockContext, times(1)).bindServiceAsUser(
bindIntentCaptor.capture(),
any(ServiceConnection.class),
- eq(Context.BIND_AUTO_CREATE | Context.BIND_FOREGROUND_SERVICE
- | Context.BIND_ALLOW_BACKGROUND_ACTIVITY_STARTS),
+ eq(serviceBindingFlags),
eq(UserHandle.CURRENT));
Intent bindIntent = bindIntentCaptor.getValue();
@@ -611,8 +608,7 @@
verify(mMockContext, times(2)).bindServiceAsUser(
bindIntentCaptor.capture(),
any(ServiceConnection.class),
- eq(Context.BIND_AUTO_CREATE | Context.BIND_FOREGROUND_SERVICE
- | Context.BIND_ALLOW_BACKGROUND_ACTIVITY_STARTS),
+ eq(serviceBindingFlags),
eq(UserHandle.CURRENT));
// Verify we were re-granted the runtime permission.
@@ -666,8 +662,7 @@
verify(mMockContext, times(1)).bindServiceAsUser(
bindIntentCaptor.capture(),
serviceConnectionCaptor.capture(),
- eq(Context.BIND_AUTO_CREATE | Context.BIND_FOREGROUND_SERVICE
- | Context.BIND_ALLOW_BACKGROUND_ACTIVITY_STARTS),
+ eq(serviceBindingFlags),
eq(UserHandle.CURRENT));
Intent bindIntent = bindIntentCaptor.getValue();
@@ -699,8 +694,7 @@
verify(mMockContext, times(2)).bindServiceAsUser(
bindIntentCaptor2.capture(),
any(ServiceConnection.class),
- eq(Context.BIND_AUTO_CREATE | Context.BIND_FOREGROUND_SERVICE
- | Context.BIND_ALLOW_BACKGROUND_ACTIVITY_STARTS),
+ eq(serviceBindingFlags),
eq(UserHandle.CURRENT));
bindIntent = bindIntentCaptor2.getValue();
@@ -756,8 +750,7 @@
verify(mMockContext, times(2)).bindServiceAsUser(
bindIntentCaptor2.capture(),
any(ServiceConnection.class),
- eq(Context.BIND_AUTO_CREATE | Context.BIND_FOREGROUND_SERVICE
- | Context.BIND_ALLOW_BACKGROUND_ACTIVITY_STARTS),
+ eq(serviceBindingFlags),
eq(UserHandle.CURRENT));
assertEquals(sysDialerComponentName, bindIntentCaptor2.getValue().getComponent());
}
@@ -791,8 +784,7 @@
verify(mMockContext, times(1)).bindServiceAsUser(
bindIntentCaptor.capture(),
any(ServiceConnection.class),
- eq(Context.BIND_AUTO_CREATE | Context.BIND_FOREGROUND_SERVICE
- | Context.BIND_ALLOW_BACKGROUND_ACTIVITY_STARTS),
+ eq(serviceBindingFlags),
eq(UserHandle.CURRENT));
Intent bindIntent = bindIntentCaptor.getValue();
@@ -830,8 +822,7 @@
verify(mMockContext, times(1)).bindServiceAsUser(
bindIntentCaptor.capture(),
serviceConnectionCaptor.capture(),
- eq(Context.BIND_AUTO_CREATE | Context.BIND_FOREGROUND_SERVICE
- | Context.BIND_ALLOW_BACKGROUND_ACTIVITY_STARTS),
+ eq(serviceBindingFlags),
eq(UserHandle.CURRENT));
// Pretend that the call has gone away.
@@ -879,8 +870,7 @@
verify(mMockContext, times(1)).bindServiceAsUser(
bindIntentCaptor.capture(),
any(ServiceConnection.class),
- eq(Context.BIND_AUTO_CREATE | Context.BIND_FOREGROUND_SERVICE
- | Context.BIND_ALLOW_BACKGROUND_ACTIVITY_STARTS),
+ eq(serviceBindingFlags),
eq(UserHandle.CURRENT));
// Verify bind car mode ui
assertEquals(1, bindIntentCaptor.getAllValues().size());
@@ -908,8 +898,7 @@
verify(mMockContext, times(1)).bindServiceAsUser(
bindIntentCaptor.capture(),
any(ServiceConnection.class),
- eq(Context.BIND_AUTO_CREATE | Context.BIND_FOREGROUND_SERVICE
- | Context.BIND_ALLOW_BACKGROUND_ACTIVITY_STARTS),
+ eq(serviceBindingFlags),
eq(UserHandle.CURRENT));
// Verify bind to default package, instead of the invalid car mode ui.
assertEquals(1, bindIntentCaptor.getAllValues().size());
@@ -952,8 +941,7 @@
verify(mMockContext, times(2)).bindServiceAsUser(
bindIntentCaptor.capture(),
any(ServiceConnection.class),
- eq(Context.BIND_AUTO_CREATE | Context.BIND_FOREGROUND_SERVICE
- | Context.BIND_ALLOW_BACKGROUND_ACTIVITY_STARTS),
+ eq(serviceBindingFlags),
eq(UserHandle.CURRENT));
// Verify bind
@@ -997,8 +985,7 @@
verify(mMockContext, times(1)).bindServiceAsUser(
bindIntentCaptor.capture(),
any(ServiceConnection.class),
- eq(Context.BIND_AUTO_CREATE | Context.BIND_FOREGROUND_SERVICE
- | Context.BIND_ALLOW_BACKGROUND_ACTIVITY_STARTS),
+ eq(serviceBindingFlags),
eq(UserHandle.CURRENT));
// Verify bind
@@ -1031,8 +1018,7 @@
verify(mMockContext, times(1)).bindServiceAsUser(
bindIntentCaptor.capture(),
serviceConnectionCaptor.capture(),
- eq(Context.BIND_AUTO_CREATE | Context.BIND_FOREGROUND_SERVICE
- | Context.BIND_ALLOW_BACKGROUND_ACTIVITY_STARTS),
+ eq(serviceBindingFlags),
eq(UserHandle.CURRENT));
assertEquals(1, bindIntentCaptor.getAllValues().size());
verifyBinding(bindIntentCaptor, 0, DEF_PKG, DEF_CLASS);
@@ -1070,8 +1056,7 @@
verify(mMockContext).bindServiceAsUser(
bindIntentCaptor.capture(),
any(ServiceConnection.class),
- eq(Context.BIND_AUTO_CREATE | Context.BIND_FOREGROUND_SERVICE
- | Context.BIND_ALLOW_BACKGROUND_ACTIVITY_STARTS),
+ eq(serviceBindingFlags),
eq(UserHandle.CURRENT));
}
@@ -1102,8 +1087,7 @@
verify(mMockContext, times(4)).bindServiceAsUser(
bindIntentCaptor.capture(),
any(ServiceConnection.class),
- eq(Context.BIND_AUTO_CREATE | Context.BIND_FOREGROUND_SERVICE
- | Context.BIND_ALLOW_BACKGROUND_ACTIVITY_STARTS),
+ eq(serviceBindingFlags),
eq(UserHandle.CURRENT));
// Verify bind car mode ui
assertEquals(4, bindIntentCaptor.getAllValues().size());
@@ -1160,8 +1144,7 @@
verify(mMockContext, times(2)).bindServiceAsUser(
bindIntentCaptor.capture(),
serviceConnectionCaptor.capture(),
- eq(Context.BIND_AUTO_CREATE | Context.BIND_FOREGROUND_SERVICE
- | Context.BIND_ALLOW_BACKGROUND_ACTIVITY_STARTS),
+ eq(serviceBindingFlags),
eq(UserHandle.CURRENT));
CompletableFuture<Boolean> bindTimeout = mInCallController.getBindingFuture();
@@ -1229,8 +1212,7 @@
verify(mMockContext, never()).bindServiceAsUser(
any(Intent.class),
any(ServiceConnection.class),
- eq(Context.BIND_AUTO_CREATE | Context.BIND_FOREGROUND_SERVICE
- | Context.BIND_ALLOW_BACKGROUND_ACTIVITY_STARTS),
+ eq(serviceBindingFlags),
eq(UserHandle.CURRENT));
// Now switch to car mode.
@@ -1242,8 +1224,7 @@
verify(mMockContext, times(1)).bindServiceAsUser(
bindIntentCaptor.capture(),
any(ServiceConnection.class),
- eq(Context.BIND_AUTO_CREATE | Context.BIND_FOREGROUND_SERVICE
- | Context.BIND_ALLOW_BACKGROUND_ACTIVITY_STARTS),
+ eq(serviceBindingFlags),
eq(UserHandle.CURRENT));
// Verify bind car mode ui
assertEquals(1, bindIntentCaptor.getAllValues().size());
@@ -1269,8 +1250,7 @@
verify(mMockContext, never()).bindServiceAsUser(
any(Intent.class),
any(ServiceConnection.class),
- eq(Context.BIND_AUTO_CREATE | Context.BIND_FOREGROUND_SERVICE
- | Context.BIND_ALLOW_BACKGROUND_ACTIVITY_STARTS),
+ eq(serviceBindingFlags),
eq(UserHandle.CURRENT));
// Now switch to car mode.
@@ -1287,8 +1267,7 @@
verify(mMockContext, times(1)).bindServiceAsUser(
any(Intent.class),
serviceConnectionCaptor.capture(),
- eq(Context.BIND_AUTO_CREATE | Context.BIND_FOREGROUND_SERVICE
- | Context.BIND_ALLOW_BACKGROUND_ACTIVITY_STARTS),
+ eq(serviceBindingFlags),
eq(UserHandle.CURRENT));
ServiceConnection serviceConnection = serviceConnectionCaptor.getValue();
diff --git a/tests/src/com/android/server/telecom/tests/RingerTest.java b/tests/src/com/android/server/telecom/tests/RingerTest.java
index 59a5f02..fbc08ba 100644
--- a/tests/src/com/android/server/telecom/tests/RingerTest.java
+++ b/tests/src/com/android/server/telecom/tests/RingerTest.java
@@ -139,7 +139,7 @@
when(mockPlayerFactory.createPlayer(anyInt())).thenReturn(mockTonePlayer);
mockAudioManager =
(AudioManager) mContext.getSystemService(Context.AUDIO_SERVICE);
- when(mockAudioManager.getRingerModeInternal()).thenReturn(AudioManager.RINGER_MODE_NORMAL);
+ when(mockAudioManager.getRingerMode()).thenReturn(AudioManager.RINGER_MODE_NORMAL);
when(mockSystemSettingsUtil.isHapticPlaybackSupported(any(Context.class))).thenReturn(true);
NotificationManager notificationManager =
(NotificationManager) mContext.getSystemService(Context.NOTIFICATION_SERVICE);
@@ -286,7 +286,7 @@
public void testVibrateButNoRingForNullRingtone() throws Exception {
mRingerUnderTest.startCallWaiting(mockCall1);
when(mockRingtoneFactory.getRingtone(any(Call.class))).thenReturn(null);
- when(mockAudioManager.getRingerModeInternal()).thenReturn(AudioManager.RINGER_MODE_NORMAL);
+ when(mockAudioManager.getRingerMode()).thenReturn(AudioManager.RINGER_MODE_NORMAL);
mFuture.complete(false); // not using audio coupled haptics
enableVibrationWhenRinging();
assertFalse(mRingerUnderTest.startRinging(mockCall2, false));
@@ -306,7 +306,7 @@
mRingerUnderTest.startCallWaiting(mockCall1);
Ringtone mockRingtone = mock(Ringtone.class);
when(mockRingtoneFactory.getRingtone(any(Call.class))).thenReturn(mockRingtone);
- when(mockAudioManager.getRingerModeInternal()).thenReturn(AudioManager.RINGER_MODE_VIBRATE);
+ when(mockAudioManager.getRingerMode()).thenReturn(AudioManager.RINGER_MODE_VIBRATE);
when(mockAudioManager.getStreamVolume(AudioManager.STREAM_RING)).thenReturn(0);
mFuture.complete(false); // not using audio coupled haptics
enableVibrationWhenRinging();
@@ -327,7 +327,7 @@
mRingerUnderTest.startCallWaiting(mockCall1);
Ringtone mockRingtone = mock(Ringtone.class);
when(mockRingtoneFactory.getRingtone(any(Call.class))).thenReturn(mockRingtone);
- when(mockAudioManager.getRingerModeInternal()).thenReturn(AudioManager.RINGER_MODE_VIBRATE);
+ when(mockAudioManager.getRingerMode()).thenReturn(AudioManager.RINGER_MODE_VIBRATE);
when(mockAudioManager.getStreamVolume(AudioManager.STREAM_RING)).thenReturn(0);
mFuture.complete(true); // using audio coupled haptics
enableVibrationWhenRinging();
@@ -348,7 +348,7 @@
enableVibrationWhenRinging();
Ringtone mockRingtone = mock(Ringtone.class);
when(mockRingtoneFactory.getRingtone(nullable(Call.class))).thenReturn(mockRingtone);
- when(mockAudioManager.getRingerModeInternal()).thenReturn(AudioManager.RINGER_MODE_NORMAL);
+ when(mockAudioManager.getRingerMode()).thenReturn(AudioManager.RINGER_MODE_NORMAL);
mRingerUnderTest.startRinging(mockCall1, false);
// Make sure we haven't started the vibrator yet, but have started ringing.
@@ -372,7 +372,7 @@
public void testCustomVibrationForRingtone() throws Exception {
mRingerUnderTest.startCallWaiting(mockCall1);
Ringtone mockRingtone = mock(Ringtone.class);
- when(mockAudioManager.getRingerModeInternal()).thenReturn(AudioManager.RINGER_MODE_NORMAL);
+ when(mockAudioManager.getRingerMode()).thenReturn(AudioManager.RINGER_MODE_NORMAL);
when(mockRingtoneFactory.getRingtone(any(Call.class))).thenReturn(mockRingtone);
when(mockRingtone.getUri()).thenReturn(FAKE_RINGTONE_URI);
mFuture.complete(false); // not using audio coupled haptics
@@ -424,7 +424,7 @@
mRingerUnderTest.startCallWaiting(mockCall1);
Ringtone mockRingtone = mock(Ringtone.class);
when(mockRingtoneFactory.getRingtone(any(Call.class))).thenReturn(mockRingtone);
- when(mockAudioManager.getRingerModeInternal()).thenReturn(AudioManager.RINGER_MODE_NORMAL);
+ when(mockAudioManager.getRingerMode()).thenReturn(AudioManager.RINGER_MODE_NORMAL);
when(mockAudioManager.getStreamVolume(AudioManager.STREAM_RING)).thenReturn(0);
mFuture.complete(false); // not using audio coupled haptics
enableVibrationOnlyWhenNotRinging();
@@ -442,7 +442,7 @@
public void testSilentRingWithHfpStillAcquiresFocus2() throws Exception {
mRingerUnderTest.startCallWaiting(mockCall1);
when(mockRingtoneFactory.getRingtone(any(Call.class))).thenReturn(null);
- when(mockAudioManager.getRingerModeInternal()).thenReturn(AudioManager.RINGER_MODE_NORMAL);
+ when(mockAudioManager.getRingerMode()).thenReturn(AudioManager.RINGER_MODE_NORMAL);
when(mockAudioManager.getStreamVolume(AudioManager.STREAM_RING)).thenReturn(0);
mFuture.complete(false); // not using audio coupled haptics
enableVibrationOnlyWhenNotRinging();
@@ -455,10 +455,27 @@
.vibrate(any(VibrationEffect.class), any(VibrationAttributes.class));
}
+ @SmallTest
+ @Test
+ public void testRingAndVibrateForAllowedCallInDndMode() throws Exception {
+ mRingerUnderTest.startCallWaiting(mockCall1);
+ Ringtone mockRingtone = mock(Ringtone.class);
+ when(mockRingtoneFactory.getRingtone(any(Call.class))).thenReturn(mockRingtone);
+ when(mockAudioManager.getRingerMode()).thenReturn(AudioManager.RINGER_MODE_SILENT);
+ when(mockAudioManager.getStreamVolume(AudioManager.STREAM_RING)).thenReturn(100);
+ mFuture.complete(true); // using audio coupled haptics
+ enableVibrationWhenRinging();
+ assertTrue(mRingerUnderTest.startRinging(mockCall2, true));
+ mRingCompletionFuture.get();
+ verify(mockTonePlayer).stopTone();
+ verify(mockRingtonePlayer).play(any(RingtoneFactory.class), any(Call.class), eq(null),
+ eq(true) /* isRingerAudible */, eq(true) /* isVibrationEnabled */);
+ }
+
private void ensureRingerIsAudible() {
Ringtone mockRingtone = mock(Ringtone.class);
when(mockRingtoneFactory.getRingtone(any(Call.class))).thenReturn(mockRingtone);
- when(mockAudioManager.getRingerModeInternal()).thenReturn(AudioManager.RINGER_MODE_NORMAL);
+ when(mockAudioManager.getRingerMode()).thenReturn(AudioManager.RINGER_MODE_NORMAL);
when(mockAudioManager.getStreamVolume(AudioManager.STREAM_RING)).thenReturn(100);
}
diff --git a/tests/src/com/android/server/telecom/tests/TelecomServiceImplTest.java b/tests/src/com/android/server/telecom/tests/TelecomServiceImplTest.java
index 90bdc80..c3d085c 100644
--- a/tests/src/com/android/server/telecom/tests/TelecomServiceImplTest.java
+++ b/tests/src/com/android/server/telecom/tests/TelecomServiceImplTest.java
@@ -23,6 +23,7 @@
import static android.Manifest.permission.READ_PHONE_STATE;
import static android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE;
+import android.Manifest;
import android.app.ActivityManager;
import android.app.AppOpsManager;
import android.content.ComponentName;
@@ -760,12 +761,139 @@
}
}
+
+ @SmallTest
+ @Test
+ public void testPlaceCallNoPermission_SelfManaged() throws Exception {
+ doReturn(false).when(mDefaultDialerCache).isDefaultOrSystemDialer(
+ eq(DEFAULT_DIALER_PACKAGE), anyInt());
+ when(mFakePhoneAccountRegistrar.getPhoneAccountUnchecked(TEL_PA_HANDLE_CURRENT)).thenReturn(
+ makeSelfManagedPhoneAccount(TEL_PA_HANDLE_CURRENT).build());
+ Uri handle = Uri.parse("tel:6505551234");
+ Bundle extras = createSampleExtras();
+ // callingPackage matches the PhoneAccountHandle, so this is an app with a self-managed
+ // ConnectionService.
+ extras.putParcelable(TelecomManager.EXTRA_PHONE_ACCOUNT_HANDLE, TEL_PA_HANDLE_CURRENT);
+
+ doThrow(new SecurityException()).when(mContext).enforceCallingOrSelfPermission(
+ eq(Manifest.permission.MANAGE_OWN_CALLS), anyString());
+
+ try {
+ mTSIBinder.placeCall(handle, extras, PACKAGE_NAME, null);
+ fail("Expected SecurityException because MANAGE_OWN_CALLS is not set");
+ } catch(SecurityException e) {
+ // expected
+ }
+ }
+
+ @SmallTest
+ @Test
+ public void testPlaceCallNoCallPhonePermission_Managed() throws Exception {
+ doReturn(false).when(mDefaultDialerCache).isDefaultOrSystemDialer(
+ eq(DEFAULT_DIALER_PACKAGE), anyInt());
+ when(mFakePhoneAccountRegistrar.getPhoneAccountUnchecked(TEL_PA_HANDLE_CURRENT)).thenReturn(
+ makeSelfManagedPhoneAccount(TEL_PA_HANDLE_CURRENT).build());
+ Uri handle = Uri.parse("tel:6505551234");
+ Bundle extras = createSampleExtras();
+ // callingPackage doesn't match the PhoneAccountHandle, so this app is not managing the
+ //ConnectionService
+ extras.putParcelable(TelecomManager.EXTRA_PHONE_ACCOUNT_HANDLE, TEL_PA_HANDLE_CURRENT);
+
+ // Since the packages do not match, the caller needs CALL_PHONE permission
+ doThrow(new SecurityException()).when(mContext).enforceCallingOrSelfPermission(
+ eq(CALL_PHONE), anyString());
+
+ try {
+ mTSIBinder.placeCall(handle, extras, DEFAULT_DIALER_PACKAGE, null);
+ fail("Expected SecurityException because CALL_PHONE is not set");
+ } catch(SecurityException e) {
+ // expected
+ }
+ }
+
+ @SmallTest
+ @Test
+ public void testPlaceCallNoCallPhoneAppOp_Managed() throws Exception {
+ doReturn(false).when(mDefaultDialerCache).isDefaultOrSystemDialer(
+ eq(DEFAULT_DIALER_PACKAGE), anyInt());
+ when(mFakePhoneAccountRegistrar.getPhoneAccountUnchecked(TEL_PA_HANDLE_CURRENT)).thenReturn(
+ makeSelfManagedPhoneAccount(TEL_PA_HANDLE_CURRENT).build());
+ Uri handle = Uri.parse("tel:6505551234");
+ Bundle extras = createSampleExtras();
+ // callingPackage doesn't match the PhoneAccountHandle, so this app is not managing the
+ //ConnectionService
+ extras.putParcelable(TelecomManager.EXTRA_PHONE_ACCOUNT_HANDLE, TEL_PA_HANDLE_CURRENT);
+
+ // Since the packages do not match, the caller needs CALL_PHONE app op
+ when(mAppOpsManager.noteOp(eq(AppOpsManager.OP_CALL_PHONE), anyInt(), anyString(),
+ nullable(String.class), nullable(String.class)))
+ .thenReturn(AppOpsManager.MODE_IGNORED);
+
+ try {
+ mTSIBinder.placeCall(handle, extras, DEFAULT_DIALER_PACKAGE, null);
+ fail("Expected SecurityException because CALL_PHONE is not set");
+ } catch(SecurityException e) {
+ // expected
+ }
+ }
+
+ @SmallTest
+ @Test
+ public void testPlaceCallWithNonEmergencyPermission_SelfManaged() throws Exception {
+ doReturn(false).when(mDefaultDialerCache).isDefaultOrSystemDialer(
+ eq(DEFAULT_DIALER_PACKAGE), anyInt());
+ when(mFakePhoneAccountRegistrar.getPhoneAccountUnchecked(TEL_PA_HANDLE_CURRENT)).thenReturn(
+ makeSelfManagedPhoneAccount(TEL_PA_HANDLE_CURRENT).build());
+ Uri handle = Uri.parse("tel:6505551234");
+ Bundle extras = createSampleExtras();
+ // callingPackage matches the PhoneAccountHandle, so this is an app with a self-managed
+ // ConnectionService.
+ extras.putParcelable(TelecomManager.EXTRA_PHONE_ACCOUNT_HANDLE, TEL_PA_HANDLE_CURRENT);
+
+ // enforceCallingOrSelfPermission is implicitly granted for MANAGE_OWN_CALLS here and
+ // CALL_PHONE is not required.
+ when(mAppOpsManager.noteOp(eq(AppOpsManager.OP_CALL_PHONE), anyInt(), anyString(),
+ nullable(String.class), nullable(String.class)))
+ .thenReturn(AppOpsManager.MODE_IGNORED);
+ doReturn(PackageManager.PERMISSION_DENIED)
+ .when(mContext).checkCallingPermission(CALL_PHONE);
+ doReturn(PackageManager.PERMISSION_DENIED)
+ .when(mContext).checkCallingPermission(CALL_PRIVILEGED);
+
+ mTSIBinder.placeCall(handle, extras, PACKAGE_NAME, null);
+ placeCallTestHelper(handle, extras, true);
+ }
+
+ @SmallTest
+ @Test
+ public void testPlaceCallWithNonEmergencyPermission_Managed() throws Exception {
+ doReturn(false).when(mDefaultDialerCache).isDefaultOrSystemDialer(
+ eq(DEFAULT_DIALER_PACKAGE), anyInt());
+ Uri handle = Uri.parse("tel:6505551234");
+ Bundle extras = createSampleExtras();
+ // callingPackage doesn't match the PhoneAccountHandle, so this app does not have a
+ // self-managed ConnectionService
+ extras.putParcelable(TelecomManager.EXTRA_PHONE_ACCOUNT_HANDLE, TEL_PA_HANDLE_CURRENT);
+
+ when(mAppOpsManager.noteOp(eq(AppOpsManager.OP_CALL_PHONE), anyInt(), anyString(),
+ nullable(String.class), nullable(String.class)))
+ .thenReturn(AppOpsManager.MODE_ALLOWED);
+ doReturn(PackageManager.PERMISSION_GRANTED)
+ .when(mContext).checkCallingPermission(CALL_PHONE);
+ doReturn(PackageManager.PERMISSION_DENIED)
+ .when(mContext).checkCallingPermission(CALL_PRIVILEGED);
+
+ mTSIBinder.placeCall(handle, extras, DEFAULT_DIALER_PACKAGE, null);
+ placeCallTestHelper(handle, extras, true);
+ }
+
@SmallTest
@Test
public void testPlaceCallWithNonEmergencyPermission() throws Exception {
Uri handle = Uri.parse("tel:6505551234");
Bundle extras = createSampleExtras();
+ // We are assumed to be default dialer in this test, so canCallPhone is always true.
when(mAppOpsManager.noteOp(eq(AppOpsManager.OP_CALL_PHONE), anyInt(), anyString(),
nullable(String.class), nullable(String.class)))
.thenReturn(AppOpsManager.MODE_ALLOWED);
@@ -784,6 +912,7 @@
Uri handle = Uri.parse("tel:6505551234");
Bundle extras = createSampleExtras();
+ // We are assumed to be default dialer in this test, so canCallPhone is always true.
when(mAppOpsManager.noteOp(eq(AppOpsManager.OP_CALL_PHONE), anyInt(), anyString(),
nullable(String.class), nullable(String.class)))
.thenReturn(AppOpsManager.MODE_IGNORED);
@@ -802,6 +931,7 @@
Uri handle = Uri.parse("tel:6505551234");
Bundle extras = createSampleExtras();
+ // We are assumed to be default dialer in this test, so canCallPhone is always true.
when(mAppOpsManager.noteOp(eq(AppOpsManager.OP_CALL_PHONE), anyInt(), anyString(),
nullable(String.class), nullable(String.class)))
.thenReturn(AppOpsManager.MODE_ALLOWED);
@@ -1288,6 +1418,12 @@
return paBuilder;
}
+ private PhoneAccount.Builder makeSelfManagedPhoneAccount(PhoneAccountHandle paHandle) {
+ PhoneAccount.Builder paBuilder = makePhoneAccount(paHandle);
+ paBuilder.setCapabilities(PhoneAccount.CAPABILITY_SELF_MANAGED);
+ return paBuilder;
+ }
+
private PhoneAccount.Builder makePhoneAccount(PhoneAccountHandle paHandle) {
return new PhoneAccount.Builder(paHandle, "testLabel");
}