Pass the TelecomManager#placecall calling package through to TC logs.
Ensure the calling package is logged in the telecom dumpsys when an outgoing call is placed. Makes it easier to diagnose when a mysterious call was placed but we don't know the origin. Also add notification channel for test app so we can actually see the notifications it posts. Test: Ran unit tests for regression checking. Test: Manual - inspection of logs. Bug: 119185776 Change-Id: Id348aeeb5f55cc2da06101cc6ab8342a46fc3616
This commit is contained in:
parent
8981d49699
commit
1087f6d0b8
|
@ -536,12 +536,12 @@ public class Call implements CreateConnectionResponse, EventManager.Loggable,
|
|||
* @param handle The handle to dial.
|
||||
* @param gatewayInfo Gateway information to use for the call.
|
||||
* @param connectionManagerPhoneAccountHandle Account to use for the service managing the call.
|
||||
* This account must be one that was registered with the
|
||||
* {@link PhoneAccount#CAPABILITY_CONNECTION_MANAGER} flag.
|
||||
* This account must be one that was registered with the
|
||||
* {@link PhoneAccount#CAPABILITY_CONNECTION_MANAGER} flag.
|
||||
* @param targetPhoneAccountHandle Account information to use for the call. This account must be
|
||||
* one that was registered with the {@link PhoneAccount#CAPABILITY_CALL_PROVIDER} flag.
|
||||
* one that was registered with the {@link PhoneAccount#CAPABILITY_CALL_PROVIDER} flag.
|
||||
* @param callDirection one of CALL_DIRECTION_INCOMING, CALL_DIRECTION_OUTGOING,
|
||||
* or CALL_DIRECTION_UNKNOWN.
|
||||
* or CALL_DIRECTION_UNKNOWN.
|
||||
* @param shouldAttachToExistingConnection Set to true to attach the call to an existing
|
||||
* @param clockProxy
|
||||
*/
|
||||
|
@ -643,6 +643,10 @@ public class Call implements CreateConnectionResponse, EventManager.Loggable,
|
|||
}
|
||||
|
||||
public void initAnalytics() {
|
||||
initAnalytics(null);
|
||||
}
|
||||
|
||||
public void initAnalytics(String callingPackage) {
|
||||
int analyticsDirection;
|
||||
switch (mCallDirection) {
|
||||
case CALL_DIRECTION_OUTGOING:
|
||||
|
@ -658,7 +662,7 @@ public class Call implements CreateConnectionResponse, EventManager.Loggable,
|
|||
}
|
||||
mAnalytics = Analytics.initiateCallAnalytics(mId, analyticsDirection);
|
||||
mAnalytics.setCallIsEmergency(mIsEmergencyCall);
|
||||
Log.addEvent(this, LogUtils.Events.CREATED);
|
||||
Log.addEvent(this, LogUtils.Events.CREATED, callingPackage);
|
||||
}
|
||||
|
||||
public Analytics.CallInfo getAnalytics() {
|
||||
|
|
|
@ -28,7 +28,7 @@ import android.widget.Toast;
|
|||
public class CallIntentProcessor {
|
||||
public interface Adapter {
|
||||
void processOutgoingCallIntent(Context context, CallsManager callsManager,
|
||||
Intent intent);
|
||||
Intent intent, String callingPackage);
|
||||
void processIncomingCallIntent(CallsManager callsManager, Intent intent);
|
||||
void processUnknownCallIntent(CallsManager callsManager, Intent intent);
|
||||
}
|
||||
|
@ -36,8 +36,9 @@ public class CallIntentProcessor {
|
|||
public static class AdapterImpl implements Adapter {
|
||||
@Override
|
||||
public void processOutgoingCallIntent(Context context, CallsManager callsManager,
|
||||
Intent intent) {
|
||||
CallIntentProcessor.processOutgoingCallIntent(context, callsManager, intent);
|
||||
Intent intent, String callingPackage) {
|
||||
CallIntentProcessor.processOutgoingCallIntent(context, callsManager, intent,
|
||||
callingPackage);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -73,7 +74,7 @@ public class CallIntentProcessor {
|
|||
this.mCallsManager = callsManager;
|
||||
}
|
||||
|
||||
public void processIntent(Intent intent) {
|
||||
public void processIntent(Intent intent, String callingPackage) {
|
||||
final boolean isUnknownCall = intent.getBooleanExtra(KEY_IS_UNKNOWN_CALL, false);
|
||||
Log.i(this, "onReceive - isUnknownCall: %s", isUnknownCall);
|
||||
|
||||
|
@ -81,7 +82,7 @@ public class CallIntentProcessor {
|
|||
if (isUnknownCall) {
|
||||
processUnknownCallIntent(mCallsManager, intent);
|
||||
} else {
|
||||
processOutgoingCallIntent(mContext, mCallsManager, intent);
|
||||
processOutgoingCallIntent(mContext, mCallsManager, intent, callingPackage);
|
||||
}
|
||||
Trace.endSection();
|
||||
}
|
||||
|
@ -91,11 +92,13 @@ public class CallIntentProcessor {
|
|||
* Processes CALL, CALL_PRIVILEGED, and CALL_EMERGENCY intents.
|
||||
*
|
||||
* @param intent Call intent containing data about the handle to call.
|
||||
* @param callingPackage The package which initiated the outgoing call (if known).
|
||||
*/
|
||||
static void processOutgoingCallIntent(
|
||||
Context context,
|
||||
CallsManager callsManager,
|
||||
Intent intent) {
|
||||
Intent intent,
|
||||
String callingPackage) {
|
||||
|
||||
Uri handle = intent.getData();
|
||||
String scheme = handle.getScheme();
|
||||
|
@ -145,7 +148,7 @@ public class CallIntentProcessor {
|
|||
// Send to CallsManager to ensure the InCallUI gets kicked off before the broadcast returns
|
||||
Call call = callsManager
|
||||
.startOutgoingCall(handle, phoneAccountHandle, clientExtras, initiatingUser,
|
||||
intent);
|
||||
intent, callingPackage);
|
||||
|
||||
if (call != null) {
|
||||
sendNewOutgoingCallIntent(context, call, callsManager, intent);
|
||||
|
|
|
@ -1164,10 +1164,11 @@ public class CallsManager extends Call.ListenerBase
|
|||
* @param extras The optional extras Bundle passed with the intent used for the incoming call.
|
||||
* @param initiatingUser {@link UserHandle} of user that place the outgoing call.
|
||||
* @param originalIntent
|
||||
* @param callingPackage the package name of the app which initiated the outgoing call.
|
||||
*/
|
||||
@VisibleForTesting
|
||||
public Call startOutgoingCall(Uri handle, PhoneAccountHandle phoneAccountHandle, Bundle extras,
|
||||
UserHandle initiatingUser, Intent originalIntent) {
|
||||
UserHandle initiatingUser, Intent originalIntent, String callingPackage) {
|
||||
boolean isReusedCall = true;
|
||||
Call call = reuseOutgoingCall(handle);
|
||||
|
||||
|
@ -1193,7 +1194,7 @@ public class CallsManager extends Call.ListenerBase
|
|||
false /* forceAttachToExistingConnection */,
|
||||
false, /* isConference */
|
||||
mClockProxy);
|
||||
call.initAnalytics();
|
||||
call.initAnalytics(callingPackage);
|
||||
|
||||
// Ensure new calls related to self-managed calls/connections are set as such. This
|
||||
// will be overridden when the actual connection is returned in startCreateConnection,
|
||||
|
@ -3324,7 +3325,7 @@ public class CallsManager extends Call.ListenerBase
|
|||
|
||||
/**
|
||||
* Used to confirm creation of an outgoing call which was marked as pending confirmation in
|
||||
* {@link #startOutgoingCall(Uri, PhoneAccountHandle, Bundle, UserHandle, Intent)}.
|
||||
* {@link #startOutgoingCall(Uri, PhoneAccountHandle, Bundle, UserHandle, Intent, String)}.
|
||||
* Called via {@link TelecomBroadcastIntentProcessor} for a call which was confirmed via
|
||||
* {@link ConfirmCallDialogActivity}.
|
||||
* @param callId The call ID of the call to confirm.
|
||||
|
@ -3349,7 +3350,7 @@ public class CallsManager extends Call.ListenerBase
|
|||
|
||||
/**
|
||||
* Used to cancel an outgoing call which was marked as pending confirmation in
|
||||
* {@link #startOutgoingCall(Uri, PhoneAccountHandle, Bundle, UserHandle, Intent)}.
|
||||
* {@link #startOutgoingCall(Uri, PhoneAccountHandle, Bundle, UserHandle, Intent, String)}.
|
||||
* Called via {@link TelecomBroadcastIntentProcessor} for a call which was confirmed via
|
||||
* {@link ConfirmCallDialogActivity}.
|
||||
* @param callId The call ID of the call to cancel.
|
||||
|
@ -3365,7 +3366,7 @@ public class CallsManager extends Call.ListenerBase
|
|||
}
|
||||
|
||||
/**
|
||||
* Called from {@link #startOutgoingCall(Uri, PhoneAccountHandle, Bundle, UserHandle, Intent)} when
|
||||
* Called from {@link #startOutgoingCall(Uri, PhoneAccountHandle, Bundle, UserHandle, Intent, String)} when
|
||||
* a managed call is added while there are ongoing self-managed calls. Starts
|
||||
* {@link ConfirmCallDialogActivity} to prompt the user to see if they wish to place the
|
||||
* outgoing call or not.
|
||||
|
@ -3596,7 +3597,8 @@ public class CallsManager extends Call.ListenerBase
|
|||
extras.putParcelable(TelecomManager.EXTRA_CALL_AUDIO_STATE,
|
||||
mCallAudioManager.getCallAudioState());
|
||||
Call handoverToCall = startOutgoingCall(handoverFromCall.getHandle(), handoverToHandle,
|
||||
extras, getCurrentUserHandle(), null /* originalIntent */);
|
||||
extras, getCurrentUserHandle(), null /* originalIntent */,
|
||||
null /* callingPackage */);
|
||||
if (handoverToCall == null) {
|
||||
handoverFromCall.sendCallEvent(android.telecom.Call.EVENT_HANDOVER_FAILED, null);
|
||||
return;
|
||||
|
|
|
@ -1657,7 +1657,7 @@ public class TelecomServiceImpl {
|
|||
try {
|
||||
Log.i(this, "handleCallIntent: handling call intent");
|
||||
mCallIntentProcessorAdapter.processOutgoingCallIntent(mContext,
|
||||
mCallsManager, intent);
|
||||
mCallsManager, intent, null /* callingPackage */);
|
||||
} finally {
|
||||
Binder.restoreCallingIdentity(token);
|
||||
}
|
||||
|
|
|
@ -159,7 +159,7 @@ public class UserCallIntentProcessor {
|
|||
// Save the user handle of current user before forwarding the intent to primary user.
|
||||
intent.putExtra(CallIntentProcessor.KEY_INITIATING_USER, mUserHandle);
|
||||
|
||||
sendIntentToDestination(intent, isLocalInvocation);
|
||||
sendIntentToDestination(intent, isLocalInvocation, callingPackageName);
|
||||
}
|
||||
|
||||
private boolean isDefaultOrSystemDialer(String callingPackageName) {
|
||||
|
@ -193,7 +193,8 @@ public class UserCallIntentProcessor {
|
|||
* If the caller is local to the Telecom service, we send the intent to Telecom without
|
||||
* sending it through TelecomServiceImpl.
|
||||
*/
|
||||
private boolean sendIntentToDestination(Intent intent, boolean isLocalInvocation) {
|
||||
private boolean sendIntentToDestination(Intent intent, boolean isLocalInvocation,
|
||||
String callingPackage) {
|
||||
intent.putExtra(CallIntentProcessor.KEY_IS_INCOMING_CALL, false);
|
||||
intent.setFlags(Intent.FLAG_RECEIVER_FOREGROUND);
|
||||
if (isLocalInvocation) {
|
||||
|
@ -202,7 +203,8 @@ public class UserCallIntentProcessor {
|
|||
// TODO: We should not be using an intent here; this whole flows needs cleanup.
|
||||
Log.i(this, "sendIntentToDestination: send intent to Telecom directly.");
|
||||
synchronized (TelecomSystem.getInstance().getLock()) {
|
||||
TelecomSystem.getInstance().getCallIntentProcessor().processIntent(intent);
|
||||
TelecomSystem.getInstance().getCallIntentProcessor().processIntent(intent,
|
||||
callingPackage);
|
||||
}
|
||||
} else {
|
||||
// We're calling from the UserCallActivity, so the TelecomSystem is not in the same
|
||||
|
|
|
@ -19,6 +19,7 @@ package com.android.server.telecom.testapps;
|
|||
import com.android.server.telecom.testapps.R;
|
||||
|
||||
import android.app.Notification;
|
||||
import android.app.NotificationChannel;
|
||||
import android.app.NotificationManager;
|
||||
import android.app.PendingIntent;
|
||||
import android.content.ComponentName;
|
||||
|
@ -26,6 +27,7 @@ import android.content.Context;
|
|||
import android.content.Intent;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.drawable.Icon;
|
||||
import android.media.AudioAttributes;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.telecom.PhoneAccount;
|
||||
|
@ -45,6 +47,7 @@ import java.util.Map;
|
|||
*/
|
||||
public class CallServiceNotifier {
|
||||
private static final CallServiceNotifier INSTANCE = new CallServiceNotifier();
|
||||
private static final String CHANNEL_ID = "channel1";
|
||||
|
||||
public static final String CALL_PROVIDER_ID = "testapps_TestConnectionService_CALL_PROVIDER_ID";
|
||||
public static final String SIM_SUBSCRIPTION_ID =
|
||||
|
@ -86,6 +89,9 @@ public class CallServiceNotifier {
|
|||
*/
|
||||
public void updateNotification(Context context) {
|
||||
log("adding the notification ------------");
|
||||
NotificationChannel channel = new NotificationChannel(CHANNEL_ID, "Test Channel",
|
||||
NotificationManager.IMPORTANCE_DEFAULT);
|
||||
getNotificationManager(context).createNotificationChannel(channel);
|
||||
getNotificationManager(context).notify(CALL_NOTIFICATION_ID, getMainNotification(context));
|
||||
getNotificationManager(context).notify(
|
||||
PHONE_ACCOUNT_NOTIFICATION_ID, getPhoneAccountNotification(context));
|
||||
|
@ -219,7 +225,7 @@ public class CallServiceNotifier {
|
|||
* Creates a notification object for using the telecom APIs.
|
||||
*/
|
||||
private Notification getPhoneAccountNotification(Context context) {
|
||||
final Notification.Builder builder = new Notification.Builder(context);
|
||||
final Notification.Builder builder = new Notification.Builder(context, CHANNEL_ID);
|
||||
// Both notifications have buttons and only the first one with buttons will show its
|
||||
// buttons. Since the phone accounts notification is always first, setting false ensures
|
||||
// it can be dismissed to use the other notification.
|
||||
|
@ -244,7 +250,7 @@ public class CallServiceNotifier {
|
|||
* Creates a notification object out of the current calls state.
|
||||
*/
|
||||
private Notification getMainNotification(Context context) {
|
||||
final Notification.Builder builder = new Notification.Builder(context);
|
||||
final Notification.Builder builder = new Notification.Builder(context, CHANNEL_ID);
|
||||
builder.setOngoing(true);
|
||||
builder.setPriority(Notification.PRIORITY_HIGH);
|
||||
builder.setSmallIcon(android.R.drawable.stat_sys_phone_call);
|
||||
|
|
|
@ -100,7 +100,7 @@ public class TelecomServiceImplTest extends TelecomTestCase {
|
|||
public static class CallIntentProcessAdapterFake implements CallIntentProcessor.Adapter {
|
||||
@Override
|
||||
public void processOutgoingCallIntent(Context context, CallsManager callsManager,
|
||||
Intent intent) {
|
||||
Intent intent, String callingPackage) {
|
||||
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue