Merge "Introduce TracingServiceProxy System Services" am: 4512e77b7c
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1527766 MUST ONLY BE SUBMITTED BY AUTOMERGER Change-Id: I0beefb006286785dcc84bed138921d87992fbf87
This commit is contained in:
committed by
Automerger Merge Worker
commit
a8d0cc257e
@@ -7,3 +7,8 @@ filegroup {
|
||||
name: "IDropBoxManagerService.aidl",
|
||||
srcs: ["com/android/internal/os/IDropBoxManagerService.aidl"],
|
||||
}
|
||||
|
||||
filegroup {
|
||||
name: "ITracingServiceProxy.aidl",
|
||||
srcs: ["android/tracing/ITracingServiceProxy.aidl"],
|
||||
}
|
||||
|
||||
32
core/java/android/tracing/ITracingServiceProxy.aidl
Normal file
32
core/java/android/tracing/ITracingServiceProxy.aidl
Normal file
@@ -0,0 +1,32 @@
|
||||
/**
|
||||
* Copyright (c) 2020, 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.
|
||||
*/
|
||||
|
||||
package android.tracing;
|
||||
|
||||
/**
|
||||
* Binder interface for the TracingServiceProxy running in system_server.
|
||||
*
|
||||
* {@hide}
|
||||
*/
|
||||
interface ITracingServiceProxy
|
||||
{
|
||||
/**
|
||||
* Notifies system tracing app that a tracing session has ended. If a session is repurposed
|
||||
* for use in a bugreport, sessionStolen can be set to indicate that tracing has ended but
|
||||
* there is no buffer available to dump.
|
||||
*/
|
||||
oneway void notifyTraceSessionEnded(boolean sessionStolen);
|
||||
}
|
||||
2
core/java/android/tracing/OWNERS
Normal file
2
core/java/android/tracing/OWNERS
Normal file
@@ -0,0 +1,2 @@
|
||||
cfijalkovich@google.com
|
||||
carmenjackson@google.com
|
||||
@@ -460,6 +460,8 @@ applications that come with the platform
|
||||
<permission name="android.permission.START_FOREGROUND_SERVICES_FROM_BACKGROUND"/>
|
||||
<!-- Permissions required for quick settings tile -->
|
||||
<permission name="android.permission.STATUS_BAR"/>
|
||||
<!-- Permissions required to query Betterbug -->
|
||||
<permission name="android.permission.QUERY_ALL_PACKAGES"/>
|
||||
</privapp-permissions>
|
||||
|
||||
<privapp-permissions package="com.android.tv">
|
||||
|
||||
42
libs/tracingproxy/Android.bp
Normal file
42
libs/tracingproxy/Android.bp
Normal file
@@ -0,0 +1,42 @@
|
||||
// Copyright (C) 2020 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.
|
||||
|
||||
// Provides C++ wrappers for system services.
|
||||
|
||||
cc_library_shared {
|
||||
name: "libtracingproxy",
|
||||
|
||||
aidl: {
|
||||
export_aidl_headers: true,
|
||||
include_dirs: [
|
||||
"frameworks/base/core/java",
|
||||
],
|
||||
},
|
||||
|
||||
srcs: [
|
||||
":ITracingServiceProxy.aidl",
|
||||
],
|
||||
|
||||
shared_libs: [
|
||||
"libbinder",
|
||||
"libutils",
|
||||
],
|
||||
|
||||
cflags: [
|
||||
"-Wall",
|
||||
"-Werror",
|
||||
"-Wunused",
|
||||
"-Wunreachable-code",
|
||||
],
|
||||
}
|
||||
2
services/core/java/com/android/server/tracing/OWNERS
Normal file
2
services/core/java/com/android/server/tracing/OWNERS
Normal file
@@ -0,0 +1,2 @@
|
||||
cfijalkovich@google.com
|
||||
carmenjackson@google.com
|
||||
@@ -0,0 +1,99 @@
|
||||
/*
|
||||
* Copyright 2020 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.
|
||||
*/
|
||||
package com.android.server.tracing;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.PackageInfo;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.content.pm.PackageManager.NameNotFoundException;
|
||||
import android.os.UserHandle;
|
||||
import android.tracing.ITracingServiceProxy;
|
||||
import android.util.Log;
|
||||
|
||||
import com.android.server.SystemService;
|
||||
|
||||
/**
|
||||
* TracingServiceProxy is the system_server intermediary between the Perfetto tracing daemon and the
|
||||
* system tracing app Traceur.
|
||||
*
|
||||
* @hide
|
||||
*/
|
||||
public class TracingServiceProxy extends SystemService {
|
||||
private static final String TAG = "TracingServiceProxy";
|
||||
|
||||
public static final String TRACING_SERVICE_PROXY_BINDER_NAME = "tracing.proxy";
|
||||
|
||||
private static final String TRACING_APP_PACKAGE_NAME = "com.android.traceur";
|
||||
private static final String TRACING_APP_ACTIVITY = "com.android.traceur.StopTraceService";
|
||||
|
||||
// Keep this in sync with the definitions in TraceService
|
||||
private static final String INTENT_ACTION_NOTIFY_SESSION_STOPPED =
|
||||
"com.android.traceur.NOTIFY_SESSION_STOPPED";
|
||||
private static final String INTENT_ACTION_NOTIFY_SESSION_STOLEN =
|
||||
"com.android.traceur.NOTIFY_SESSION_STOLEN";
|
||||
|
||||
private final Context mContext;
|
||||
private final PackageManager mPackageManager;
|
||||
|
||||
private final ITracingServiceProxy.Stub mTracingServiceProxy = new ITracingServiceProxy.Stub() {
|
||||
/**
|
||||
* Notifies system tracing app that a tracing session has ended. If a session is repurposed
|
||||
* for use in a bugreport, sessionStolen can be set to indicate that tracing has ended but
|
||||
* there is no buffer available to dump.
|
||||
*/
|
||||
@Override
|
||||
public void notifyTraceSessionEnded(boolean sessionStolen) {
|
||||
notifyTraceur(sessionStolen);
|
||||
}
|
||||
};
|
||||
|
||||
public TracingServiceProxy(Context context) {
|
||||
super(context);
|
||||
mContext = context;
|
||||
mPackageManager = context.getPackageManager();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStart() {
|
||||
publishBinderService(TRACING_SERVICE_PROXY_BINDER_NAME, mTracingServiceProxy);
|
||||
}
|
||||
|
||||
private void notifyTraceur(boolean sessionStolen) {
|
||||
final Intent intent = new Intent();
|
||||
|
||||
try {
|
||||
// Validate that Traceur is a system app.
|
||||
PackageInfo info = mPackageManager.getPackageInfo(TRACING_APP_PACKAGE_NAME,
|
||||
PackageManager.MATCH_SYSTEM_ONLY);
|
||||
|
||||
intent.setClassName(info.packageName, TRACING_APP_ACTIVITY);
|
||||
if (sessionStolen) {
|
||||
intent.setAction(INTENT_ACTION_NOTIFY_SESSION_STOLEN);
|
||||
} else {
|
||||
intent.setAction(INTENT_ACTION_NOTIFY_SESSION_STOPPED);
|
||||
}
|
||||
|
||||
try {
|
||||
mContext.startForegroundServiceAsUser(intent, UserHandle.SYSTEM);
|
||||
} catch (RuntimeException e) {
|
||||
Log.e(TAG, "Failed to notifyTraceSessionEnded", e);
|
||||
}
|
||||
} catch (NameNotFoundException e) {
|
||||
Log.e(TAG, "Failed to locate Traceur", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -175,6 +175,7 @@ import com.android.server.telecom.TelecomLoaderService;
|
||||
import com.android.server.testharness.TestHarnessModeService;
|
||||
import com.android.server.textclassifier.TextClassificationManagerService;
|
||||
import com.android.server.textservices.TextServicesManagerService;
|
||||
import com.android.server.tracing.TracingServiceProxy;
|
||||
import com.android.server.trust.TrustManagerService;
|
||||
import com.android.server.tv.TvInputManagerService;
|
||||
import com.android.server.tv.TvRemoteService;
|
||||
@@ -2207,6 +2208,11 @@ public final class SystemServer {
|
||||
mSystemServiceManager.startService(AppBindingService.Lifecycle.class);
|
||||
t.traceEnd();
|
||||
|
||||
// Perfetto TracingServiceProxy
|
||||
t.traceBegin("startTracingServiceProxy");
|
||||
mSystemServiceManager.startService(TracingServiceProxy.class);
|
||||
t.traceEnd();
|
||||
|
||||
// It is now time to start up the app processes...
|
||||
|
||||
t.traceBegin("MakeVibratorServiceReady");
|
||||
|
||||
Reference in New Issue
Block a user