Merge changes from topics "call-screening-refactor", "composer-call-screening" into sc-dev
* changes:
Delete call composer attachments when specified
Refactor CallScreeningService
diff --git a/src/com/android/server/telecom/CallsManager.java b/src/com/android/server/telecom/CallsManager.java
index 81dddbe..53e6084 100755
--- a/src/com/android/server/telecom/CallsManager.java
+++ b/src/com/android/server/telecom/CallsManager.java
@@ -1274,7 +1274,7 @@
call.setIsVoipAudioMode(true);
call.setVisibleToInCallService(phoneAccountExtras != null
&& phoneAccountExtras.getBoolean(
- PhoneAccount.EXTRA_ADD_SELF_MANAGED_CALLS_TO_INCALLSERVICE, false));
+ PhoneAccount.EXTRA_ADD_SELF_MANAGED_CALLS_TO_INCALLSERVICE, true));
} else {
// Incoming call is managed, the active call is self-managed and can't be held.
// We need to set extras on it to indicate whether answering will cause a
@@ -1540,7 +1540,7 @@
call.setIsVoipAudioMode(true);
call.setVisibleToInCallService(phoneAccountExtra != null
&& phoneAccountExtra.getBoolean(
- PhoneAccount.EXTRA_ADD_SELF_MANAGED_CALLS_TO_INCALLSERVICE, false));
+ PhoneAccount.EXTRA_ADD_SELF_MANAGED_CALLS_TO_INCALLSERVICE, true));
}
call.setInitiatingUser(initiatingUser);
isReusedCall = false;
diff --git a/src/com/android/server/telecom/InCallController.java b/src/com/android/server/telecom/InCallController.java
index 40fad9b..dbf7f83 100644
--- a/src/com/android/server/telecom/InCallController.java
+++ b/src/com/android/server/telecom/InCallController.java
@@ -982,6 +982,11 @@
*/
private boolean mIsCallUsingMicrophone = false;
+ /**
+ * A list of call IDs which are currently using the camera.
+ */
+ private ArrayList<String> mCallsUsingCamera = new ArrayList<>();
+
public InCallController(Context context, TelecomSystem.SyncRoot lock, CallsManager callsManager,
SystemStateHelper systemStateHelper, DefaultDialerCache defaultDialerCache,
Timeouts.Adapter timeoutsAdapter, EmergencyCallHelper emergencyCallHelper,
@@ -1080,6 +1085,7 @@
call.removeListener(mCallListener);
mCallIdMapper.removeCall(call);
maybeTrackMicrophoneUse(isMuted());
+ onSetCamera(call, null);
}
@Override
@@ -1252,13 +1258,28 @@
*/
@Override
public void onSetCamera(Call call, String cameraId) {
+ if (call == null) {
+ return;
+ }
+
Log.i(this, "onSetCamera callId=%s, cameraId=%s", call.getId(), cameraId);
if (cameraId != null) {
- mAppOpsManager.startOp(AppOpsManager.OP_PHONE_CALL_CAMERA, myUid(),
- mContext.getOpPackageName(), false, null, null);
+ boolean shouldStart = mCallsUsingCamera.isEmpty();
+ if (!mCallsUsingCamera.contains(call.getId())) {
+ mCallsUsingCamera.add(call.getId());
+ }
+
+ if (shouldStart) {
+ mAppOpsManager.startOp(AppOpsManager.OP_PHONE_CALL_CAMERA, myUid(),
+ mContext.getOpPackageName(), false, null, null);
+ }
} else {
- mAppOpsManager.finishOp(AppOpsManager.OP_PHONE_CALL_CAMERA, myUid(),
- mContext.getOpPackageName(), null);
+ boolean hadCall = !mCallsUsingCamera.isEmpty();
+ mCallsUsingCamera.remove(call.getId());
+ if (hadCall && mCallsUsingCamera.isEmpty()) {
+ mAppOpsManager.finishOp(AppOpsManager.OP_PHONE_CALL_CAMERA, myUid(),
+ mContext.getOpPackageName(), null);
+ }
}
}
diff --git a/tests/src/com/android/server/telecom/tests/ComponentContextFixture.java b/tests/src/com/android/server/telecom/tests/ComponentContextFixture.java
index 76c6190..1b15039 100644
--- a/tests/src/com/android/server/telecom/tests/ComponentContextFixture.java
+++ b/tests/src/com/android/server/telecom/tests/ComponentContextFixture.java
@@ -58,6 +58,7 @@
import android.os.PowerWhitelistManager;
import android.os.UserHandle;
import android.os.UserManager;
+import android.os.VibratorManager;
import android.telecom.CallAudioState;
import android.telecom.ConnectionService;
import android.telecom.Log;
@@ -210,6 +211,8 @@
return mTelephonyRegistryManager;
case Context.UI_MODE_SERVICE:
return mUiModeManager;
+ case Context.VIBRATOR_MANAGER_SERVICE:
+ return mVibratorManager;
default:
return null;
}
@@ -233,6 +236,8 @@
return Context.TELEPHONY_REGISTRY_SERVICE;
} else if (svcClass == UiModeManager.class) {
return Context.UI_MODE_SERVICE;
+ } else if (svcClass == VibratorManager.class) {
+ return Context.VIBRATOR_MANAGER_SERVICE;
}
throw new UnsupportedOperationException();
}
@@ -493,6 +498,7 @@
private final RoleManager mRoleManager = mock(RoleManager.class);
private final TelephonyRegistryManager mTelephonyRegistryManager =
mock(TelephonyRegistryManager.class);
+ private final VibratorManager mVibratorManager = mock(VibratorManager.class);
private final UiModeManager mUiModeManager = mock(UiModeManager.class);
private final PermissionInfo mPermissionInfo = mock(PermissionInfo.class);
@@ -559,6 +565,7 @@
}
when(mPermissionInfo.isAppOp()).thenReturn(true);
+ when(mVibratorManager.getVibratorIds()).thenReturn(new int[0]);
// Used in CreateConnectionProcessor to rank emergency numbers by viability.
// For the test, make them all equal to INVALID so that the preferred PhoneAccount will be