• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2018 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #include <jni.h>
18 
19 #include "perfetto/traced/traced.h"
20 
21 #include "src/base/test/test_task_runner.h"
22 #include "src/tracing/ipc/default_socket.h"
23 
24 #include "test/fake_producer.h"
25 
26 namespace perfetto {
27 namespace {
ListenAndRespond(const std::string & name)28 void ListenAndRespond(const std::string& name) {
29   base::TestTaskRunner task_runner;
30   FakeProducer producer(name);
31   producer.Connect(GetProducerSocket(), &task_runner, [] {}, [] {});
32   task_runner.Run();
33 }
34 }  // namespace
35 }  // namespace perfetto
36 
37 extern "C" JNIEXPORT void JNICALL
Java_android_perfetto_producer_ProducerActivity_setupProducer(JNIEnv *,jclass)38 Java_android_perfetto_producer_ProducerActivity_setupProducer(JNIEnv*, jclass) {
39   perfetto::ListenAndRespond("android.perfetto.cts.ProducerActivity");
40 }
41 
42 extern "C" JNIEXPORT void JNICALL
Java_android_perfetto_producer_ProducerIsolatedService_setupProducer(JNIEnv *,jclass)43 Java_android_perfetto_producer_ProducerIsolatedService_setupProducer(JNIEnv*,
44                                                                      jclass) {
45   perfetto::ListenAndRespond("android.perfetto.cts.ProducerIsolatedService");
46 }
47 
48 extern "C" JNIEXPORT void JNICALL
Java_android_perfetto_producer_ProducerService_setupProducer(JNIEnv *,jclass)49 Java_android_perfetto_producer_ProducerService_setupProducer(JNIEnv*, jclass) {
50   perfetto::ListenAndRespond("android.perfetto.cts.ProducerService");
51 }
52