第一种方法
montecarloh53b getVehicleModel:default
error: frameworks/native/services/surfaceflinger/Android.bp:248:1: module "surfaceflinger" variant "android_arm64_armv8-a": depends on //system/unwinding/libbacktrace:libbacktrace which is not visible to this module
You may need to add "//frameworks/native/services/surfaceflinger" to its visibility
09:58:02 soong bootstrap failed with: exit status 1
diff --git a/libbacktrace/Android.bp b/libbacktrace/Android.bp
index af14cde..38ea6f5 100644
--- a/libbacktrace/Android.bp
+++ b/libbacktrace/Android.bp
@@ -128,6 +128,7 @@ cc_library {
"//packages/modules/Bluetooth/system/gd",
"//system/core/init",
"//system/core/libutils",
+ "//frameworks/native/services/surfaceflinger",
],
min_sdk_version: "apex_inherit",
添加头文件和库
index 000a2cb0d3..f99582d469 100644
--- a/services/surfaceflinger/Android.bp
+++ b/services/surfaceflinger/Android.bp
@@ -69,6 +69,7 @@ cc_defaults {
"libui",
"libinput",
"libutils",
+ "libbacktrace",
"libSurfaceFlingerProp",
"server_configurable_flags",
],
@@ -84,6 +85,7 @@ cc_defaults {
"libshaders",
"libtonemap",
"libtrace_proto",
+ "libSFTest",
],
header_libs: [
"android.hardware.graphics.composer@2.1-command-buffer",
@@ -177,6 +179,7 @@ filegroup {
"RefreshRateOverlay.cpp",
"RegionSamplingThread.cpp",
"RenderArea.cpp",
+ "Scheduler/MyTestRef.cpp",
"Scheduler/DispSyncSource.cpp",
"Scheduler/EventThread.cpp",
"Scheduler/FrameRateOverrideMappings.cpp",
@@ -255,6 +258,9 @@ cc_binary {
shared_libs: [
"libSurfaceFlingerProp",
],
+ header_libs: [
+ "libscheduler_headers",
+ ],
添加头文件和调用
+++ b/services/surfaceflinger/BufferQueueLayer.cpp
@@ -34,6 +34,12 @@
#include "Scheduler/LayerHistory.h"
#include "TimeStats/TimeStats.h"
+#undef LOG_NDEBUG
+#define LOG_NDEBUG 1
+#include <utils/Log.h>
+//#include <utils/CallStack.h>
+#include "CallStack.h"
+
namespace android {
using PresentState = frametimeline::SurfaceFrame::PresentState;
@@ -444,6 +450,9 @@ void BufferQueueLayer::onSidebandStreamChanged() {
void BufferQueueLayer::onFirstRef() {
BufferLayer::onFirstRef();
+ CallStack cs;
+ cs.log("setMaxDequeueBuffer");
+
创建 CallStack.h 文件
16
17 #pragma once
18
19 #include <backtrace/Backtrace.h>
20 #include <log/log.h>
21
22 #include <memory>
23
24 class CallStack {
25 public:
26 // Create a callstack with the current thread's stack trace.
27 // Immediately dump it to logcat using the given logtag.
28 static void log(const char* logtag) noexcept {
29 std::unique_ptr<Backtrace> backtrace(
30 Backtrace::Create(BACKTRACE_CURRENT_PROCESS, BACKTRACE_CURRENT_THREAD));
31 if (backtrace->Unwind(2)) {
32 for (size_t i = 0, c = backtrace->NumFrames(); i < c; i++) {
33 __android_log_print(ANDROID_LOG_ERROR, logtag, "%s",
34 backtrace->FormatFrameData(i).c_str());
35 }
36 }
37 }
38 };
~
~
第二种方法:
添加库和头文件库
+++ b/services/surfaceflinger/Android.bp
@@ -69,6 +69,7 @@ cc_defaults {
"libui",
"libinput",
"libutils",
+ "libcutils",
"libSurfaceFlingerProp",
"server_configurable_flags",
],
@@ -91,6 +92,7 @@ cc_defaults {
"android.hardware.graphics.composer@2.3-command-buffer",
"android.hardware.graphics.composer@2.4-command-buffer",
"android.hardware.graphics.composer3-command-buffer",
+ "libutils_headers",
],
export_static_lib_headers: [
"libcompositionengine",
@@ -125,9 +127,7 @@ cc_defaults {
whole_program_vtables: true, // Requires ThinLTO
afdo: true,
// TODO(b/131771163): Fix broken fuzzer support with LTO.
- sanitize: {
- fuzzer: false,
- },
+ sanitize: {never:true,},
}
cc_library_headers {
@@ -227,6 +227,7 @@ cc_defaults {
"libprocessgroup",
"libsync",
"libutils",
+ "libutilscallstack",
],
static_libs: [
"libserviceutils",
代码添加头文件和代码
+++ b/services/surfaceflinger/BufferQueueLayer.cpp
@@ -34,6 +34,11 @@
#include "Scheduler/LayerHistory.h"
#include "TimeStats/TimeStats.h"
+#undef LOG_NDEBUG
+#define LOG_NDEBUG 1
+#include <utils/Log.h>
+#include <utils/CallStack.h>
+
namespace android {
using PresentState = frametimeline::SurfaceFrame::PresentState;
@@ -444,6 +449,10 @@ void BufferQueueLayer::onSidebandStreamChanged() {
void BufferQueueLayer::onFirstRef() {
BufferLayer::onFirstRef();
+ android::CallStack cs("setMaxDequeueBuffer",10);
+ cs.update(10);
+ cs.log("setMaxDequeueBuffer",ANDROID_LOG_ERROR,"=========");
+