Commit 5f161562 authored by Chunlei Niu's avatar Chunlei Niu Committed by Commit Bot

Support multiple logs provider at the same time.

Now DEVICE_LOGS_PROVIDER_PACKAGE is a CSV and the first successfully resolved one would be used.


Bug: b/143482167
Change-Id: Ieaa204b1ea4ca8002f2711d60d103fc54178a51f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1887846Reviewed-by: default avatarLuke Halliwell (slow) <halliwell@chromium.org>
Reviewed-by: default avatarSimeon Anfinrud <sanfin@chromium.org>
Commit-Queue: Chunlei Niu <niuchl@google.com>
Auto-Submit: Chunlei Niu <niuchl@google.com>
Cr-Commit-Position: refs/heads/master@{#711525}
parent 705a648a
......@@ -34,11 +34,25 @@ class ExternalServiceDeviceLogcatProvider extends ElidedLogcatProvider {
Log.i(TAG, "Sending bind command");
Intent intent = new Intent();
Context appContext = ContextUtils.getApplicationContext();
boolean foundLogsProvider = false;
// TODO(sandv): Inject stub of service for testing
intent.setComponent(new ComponentName(
BuildConfig.DEVICE_LOGS_PROVIDER_PACKAGE, BuildConfig.DEVICE_LOGS_PROVIDER_CLASS));
for (String pkg : BuildConfig.DEVICE_LOGS_PROVIDER_PACKAGE.split(",")) {
intent.setComponent(new ComponentName(pkg, BuildConfig.DEVICE_LOGS_PROVIDER_CLASS));
if (appContext.getPackageManager().resolveService(intent, 0) != null) {
foundLogsProvider = true;
break;
}
}
if (!foundLogsProvider) {
Log.e(TAG,
"Failed to resolve logs provider: " + BuildConfig.DEVICE_LOGS_PROVIDER_PACKAGE
+ "/" + BuildConfig.DEVICE_LOGS_PROVIDER_CLASS);
return;
}
ContextUtils.getApplicationContext().bindService(intent, new ServiceConnection() {
appContext.bindService(intent, new ServiceConnection() {
@Override
public void onServiceConnected(ComponentName name, IBinder service) {
Log.i(TAG, "onServiceConnected for this");
......@@ -56,7 +70,7 @@ class ExternalServiceDeviceLogcatProvider extends ElidedLogcatProvider {
Log.e(TAG, "Can't get logs", e);
return new BufferedReader(new StringReader(""));
} finally {
ContextUtils.getApplicationContext().unbindService(conn);
appContext.unbindService(conn);
}
}, callback::onLogsDone);
}
......
......@@ -73,6 +73,7 @@ declare_args() {
# Set the package name and class path for the component which will provide device logs
# Values defined in eureka-internal
# These values are unused if use_remote_service_logcat is false
# device_logs_provider_package is a CSV, and the first resolved one would be used.
device_logs_provider_package = ""
device_logs_provider_class = ""
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment