Add telecom log marking shell command.

We often get bugs where testers have executed a LONG list of test steps.
It becomes extremely difficult to know where in the logs corresponds to
which test script step.

This adds a new telecom shell command:
adb shell telecom log-mark Testing 1 2 3

This command adds a USER_LOG_MARK event log item to all ongoing calls and
to the general telecom logs with the specified message.

Test: Tested using the new shell command to mark the telecom logs in and out of calls.
Fixes: 228895073
Change-Id: Ic11edc777e57a4fc8748a42c931379faf7cea671
This commit is contained in:
Tyler Gunn
2022-04-11 17:13:53 -07:00
parent d9e8a4f5ff
commit 043bb30f98
2 changed files with 21 additions and 0 deletions

View File

@@ -37,6 +37,8 @@ import com.android.internal.os.BaseCommand;
import com.android.internal.telecom.ITelecomService;
import java.io.PrintStream;
import java.util.Arrays;
import java.util.stream.Collectors;
public final class Telecom extends BaseCommand {
@@ -88,6 +90,10 @@ public final class Telecom extends BaseCommand {
private static final String COMMAND_GET_MAX_PHONES = "get-max-phones";
private static final String COMMAND_SET_TEST_EMERGENCY_PHONE_ACCOUNT_PACKAGE_FILTER =
"set-test-emergency-phone-account-package-filter";
/**
* Command used to emit a distinct "mark" in the logs.
*/
private static final String COMMAND_LOG_MARK = "log-mark";
private ComponentName mComponent;
private String mAccountId;
@@ -156,6 +162,8 @@ public final class Telecom extends BaseCommand {
+ " package name that will be used for test emergency calls. To clear,"
+ " send an empty package name. Real emergency calls will still be placed"
+ " over Telephony.\n"
+ "telecom log-mark <MESSAGE>: emits a message into the telecom logs. Useful for "
+ "testers to indicate where in the logs various test steps take place.\n"
);
}
@@ -257,6 +265,9 @@ public final class Telecom extends BaseCommand {
case COMMAND_SET_TEST_EMERGENCY_PHONE_ACCOUNT_PACKAGE_FILTER:
runSetEmergencyPhoneAccountPackageFilter();
break;
case COMMAND_LOG_MARK:
runLogMark();
break;
default:
Log.w(this, "onRun: unknown command: %s", command);
throw new IllegalArgumentException ("unknown command '" + command + "'");
@@ -429,6 +440,11 @@ public final class Telecom extends BaseCommand {
}
private void runLogMark() throws RemoteException {
String message = Arrays.stream(mArgs.peekRemainingArgs()).collect(Collectors.joining(" "));
mTelecomService.requestLogMark(message);
}
private PhoneAccountHandle getPhoneAccountHandleFromArgs() throws RemoteException {
if (TextUtils.isEmpty(mArgs.peekNextArg())) {
return null;

View File

@@ -344,6 +344,11 @@ interface ITelecomService {
void setTestDefaultCallRedirectionApp(String packageName);
/**
* @see TelecomServiceImpl#requestLogMark
*/
void requestLogMark(in String message);
void setTestPhoneAcctSuggestionComponent(String flattenedComponentName);
void setTestDefaultCallScreeningApp(String packageName);