SurfaceFlinger中Binder案例

SurfaceFlinger中Binder案例

  • 1、SurfaceFlinger服务init启动
  • 2、SurfaceFlinger服务继承BnSurfaceComposer端
    • 2.1 Code标签扩展
    • 2.2 Code标签扩展对应调用
  • 3、SurfaceFlinger服务的BpSurfaceComposer端
    • 3.1 FWK使用案例
    • 3.2 Native使用案例

android12-release


1、SurfaceFlinger服务init启动

SurfaceFlinger启动-Android12

SurfaceFlinger服务添加到ServiceManagersm->addService(String16(SurfaceFlinger::getServiceName()), flinger, ... ...)


static char const* getServiceName() ANDROID_API { return "SurfaceFlinger"; }

frameworks/native/services/surfaceflinger/main_surfaceflinger.cpp

int main(int, char**) {// ... ... ... ...// instantiate surfaceflingersp<SurfaceFlinger> flinger = surfaceflinger::createSurfaceFlinger();// Set the minimum policy of surfaceflinger node to be SCHED_FIFO.// So any thread with policy/priority lower than {SCHED_FIFO, 1}, will run// at least with SCHED_FIFO policy and priority 1.if (errorInPriorityModification == 0) {flinger->setMinSchedulerPolicy(SCHED_FIFO, newPriority);}setpriority(PRIO_PROCESS, 0, PRIORITY_URGENT_DISPLAY);set_sched_policy(0, SP_FOREGROUND);// Put most SurfaceFlinger threads in the system-background cpuset// Keeps us from unnecessarily using big cores// Do this after the binder thread pool initif (cpusets_enabled()) set_cpuset_policy(0, SP_SYSTEM);// initialize before clients can connectflinger->init();// publish surface flingersp<IServiceManager> sm(defaultServiceManager());sm->addService(String16(SurfaceFlinger::getServiceName()), flinger, false,IServiceManager::DUMP_FLAG_PRIORITY_CRITICAL | IServiceManager::DUMP_FLAG_PROTO);startDisplayService(); // dependency on SF getting registered aboveif (SurfaceFlinger::setSchedFifo(true) != NO_ERROR) {ALOGW("Couldn't set to SCHED_FIFO: %s", strerror(errno));}// run surface flinger in this threadflinger->run();return 0;
}

2、SurfaceFlinger服务继承BnSurfaceComposer端

SurfaceFlinger服务继承BnSurfaceComposer,实现onTransact方法一边Bp客户端调用,Code标签对应调用方法,Parcel& data参数,Parcel* reply接收返回值,flags = 0存在默认值。

在这里插入图片描述

frameworks/native/libs/gui/include/gui/ISurfaceComposer.h


class BnSurfaceComposer: public BnInterface<ISurfaceComposer> {
public:enum ISurfaceComposerTag {// Note: BOOT_FINISHED must remain this value, it is called from// Java by ActivityManagerService.BOOT_FINISHED = IBinder::FIRST_CALL_TRANSACTION,CREATE_CONNECTION,GET_STATIC_DISPLAY_INFO,CREATE_DISPLAY_EVENT_CONNECTION,CREATE_DISPLAY,DESTROY_DISPLAY,GET_PHYSICAL_DISPLAY_TOKEN,SET_TRANSACTION_STATE,AUTHENTICATE_SURFACE,GET_SUPPORTED_FRAME_TIMESTAMPS,GET_DISPLAY_MODES,       // Deprecated. Use GET_DYNAMIC_DISPLAY_INFO instead.GET_ACTIVE_DISPLAY_MODE, // Deprecated. Use GET_DYNAMIC_DISPLAY_INFO instead.GET_DISPLAY_STATE,CAPTURE_DISPLAY,CAPTURE_LAYERS,CLEAR_ANIMATION_FRAME_STATS,GET_ANIMATION_FRAME_STATS,SET_POWER_MODE,GET_DISPLAY_STATS,GET_HDR_CAPABILITIES,    // Deprecated. Use GET_DYNAMIC_DISPLAY_INFO instead.GET_DISPLAY_COLOR_MODES, // Deprecated. Use GET_DYNAMIC_DISPLAY_INFO instead.GET_ACTIVE_COLOR_MODE,   // Deprecated. Use GET_DYNAMIC_DISPLAY_INFO instead.SET_ACTIVE_COLOR_MODE,ENABLE_VSYNC_INJECTIONS,INJECT_VSYNC,GET_LAYER_DEBUG_INFO,GET_COMPOSITION_PREFERENCE,GET_COLOR_MANAGEMENT,GET_DISPLAYED_CONTENT_SAMPLING_ATTRIBUTES,SET_DISPLAY_CONTENT_SAMPLING_ENABLED,GET_DISPLAYED_CONTENT_SAMPLE,GET_PROTECTED_CONTENT_SUPPORT,IS_WIDE_COLOR_DISPLAY,GET_DISPLAY_NATIVE_PRIMARIES,GET_PHYSICAL_DISPLAY_IDS,ADD_REGION_SAMPLING_LISTENER,REMOVE_REGION_SAMPLING_LISTENER,SET_DESIRED_DISPLAY_MODE_SPECS,GET_DESIRED_DISPLAY_MODE_SPECS,GET_DISPLAY_BRIGHTNESS_SUPPORT,SET_DISPLAY_BRIGHTNESS,CAPTURE_DISPLAY_BY_ID,NOTIFY_POWER_BOOST,SET_GLOBAL_SHADOW_SETTINGS,GET_AUTO_LOW_LATENCY_MODE_SUPPORT, // Deprecated. Use GET_DYNAMIC_DISPLAY_INFO instead.SET_AUTO_LOW_LATENCY_MODE,GET_GAME_CONTENT_TYPE_SUPPORT, // Deprecated. Use GET_DYNAMIC_DISPLAY_INFO instead.SET_GAME_CONTENT_TYPE,SET_FRAME_RATE,ACQUIRE_FRAME_RATE_FLEXIBILITY_TOKEN,SET_FRAME_TIMELINE_INFO,ADD_TRANSACTION_TRACE_LISTENER,GET_GPU_CONTEXT_PRIORITY,GET_MAX_ACQUIRED_BUFFER_COUNT,GET_DYNAMIC_DISPLAY_INFO,ADD_FPS_LISTENER,REMOVE_FPS_LISTENER,OVERRIDE_HDR_TYPES,ADD_HDR_LAYER_INFO_LISTENER,REMOVE_HDR_LAYER_INFO_LISTENER,ON_PULL_ATOM,ADD_TUNNEL_MODE_ENABLED_LISTENER,REMOVE_TUNNEL_MODE_ENABLED_LISTENER,// Always append new enum to the end.};virtual status_t onTransact(uint32_t code, const Parcel& data,Parcel* reply, uint32_t flags = 0);
};

frameworks/native/libs/gui/ISurfaceComposer.cpp

status_t BnSurfaceComposer::onTransact(uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags)
{switch(code) {case CREATE_CONNECTION: {CHECK_INTERFACE(ISurfaceComposer, data, reply);sp<IBinder> b = IInterface::asBinder(createConnection());reply->writeStrongBinder(b);return NO_ERROR;}case SET_TRANSACTION_STATE: {CHECK_INTERFACE(ISurfaceComposer, data, reply);FrameTimelineInfo frameTimelineInfo;SAFE_PARCEL(frameTimelineInfo.read, data);uint32_t count = 0;SAFE_PARCEL_READ_SIZE(data.readUint32, &count, data.dataSize());Vector<ComposerState> state;state.setCapacity(count);for (size_t i = 0; i < count; i++) {ComposerState s;SAFE_PARCEL(s.read, data);state.add(s);}SAFE_PARCEL_READ_SIZE(data.readUint32, &count, data.dataSize());DisplayState d;Vector<DisplayState> displays;displays.setCapacity(count);for (size_t i = 0; i < count; i++) {SAFE_PARCEL(d.read, data);displays.add(d);}uint32_t stateFlags = 0;SAFE_PARCEL(data.readUint32, &stateFlags);sp<IBinder> applyToken;SAFE_PARCEL(data.readStrongBinder, &applyToken);InputWindowCommands inputWindowCommands;SAFE_PARCEL(inputWindowCommands.read, data);int64_t desiredPresentTime = 0;bool isAutoTimestamp = true;SAFE_PARCEL(data.readInt64, &desiredPresentTime);SAFE_PARCEL(data.readBool, &isAutoTimestamp);client_cache_t uncachedBuffer;sp<IBinder> tmpBinder;SAFE_PARCEL(data.readNullableStrongBinder, &tmpBinder);uncachedBuffer.token = tmpBinder;SAFE_PARCEL(data.readUint64, &uncachedBuffer.id);bool hasListenerCallbacks = false;SAFE_PARCEL(data.readBool, &hasListenerCallbacks);std::vector<ListenerCallbacks> listenerCallbacks;int32_t listenersSize = 0;SAFE_PARCEL_READ_SIZE(data.readInt32, &listenersSize, data.dataSize());for (int32_t i = 0; i < listenersSize; i++) {SAFE_PARCEL(data.readStrongBinder, &tmpBinder);std::vector<CallbackId> callbackIds;SAFE_PARCEL(data.readParcelableVector, &callbackIds);listenerCallbacks.emplace_back(tmpBinder, callbackIds);}uint64_t transactionId = -1;SAFE_PARCEL(data.readUint64, &transactionId);return setTransactionState(frameTimelineInfo, state, displays, stateFlags, applyToken,inputWindowCommands, desiredPresentTime, isAutoTimestamp,uncachedBuffer, hasListenerCallbacks, listenerCallbacks,transactionId);}case BOOT_FINISHED: {CHECK_INTERFACE(ISurfaceComposer, data, reply);bootFinished();return NO_ERROR;}case CAPTURE_DISPLAY: {CHECK_INTERFACE(ISurfaceComposer, data, reply);DisplayCaptureArgs args;sp<IScreenCaptureListener> captureListener;SAFE_PARCEL(args.read, data);SAFE_PARCEL(data.readStrongBinder, &captureListener);return captureDisplay(args, captureListener);}case CAPTURE_DISPLAY_BY_ID: {CHECK_INTERFACE(ISurfaceComposer, data, reply);uint64_t displayOrLayerStack = 0;sp<IScreenCaptureListener> captureListener;SAFE_PARCEL(data.readUint64, &displayOrLayerStack);SAFE_PARCEL(data.readStrongBinder, &captureListener);return captureDisplay(displayOrLayerStack, captureListener);}case CAPTURE_LAYERS: {CHECK_INTERFACE(ISurfaceComposer, data, reply);LayerCaptureArgs args;sp<IScreenCaptureListener> captureListener;SAFE_PARCEL(args.read, data);SAFE_PARCEL(data.readStrongBinder, &captureListener);return captureLayers(args, captureListener);}case AUTHENTICATE_SURFACE: {CHECK_INTERFACE(ISurfaceComposer, data, reply);sp<IGraphicBufferProducer> bufferProducer =interface_cast<IGraphicBufferProducer>(data.readStrongBinder());int32_t result = authenticateSurfaceTexture(bufferProducer) ? 1 : 0;reply->writeInt32(result);return NO_ERROR;}case GET_SUPPORTED_FRAME_TIMESTAMPS: {CHECK_INTERFACE(ISurfaceComposer, data, reply);std::vector<FrameEvent> supportedTimestamps;status_t result = getSupportedFrameTimestamps(&supportedTimestamps);status_t err = reply->writeInt32(result);if (err != NO_ERROR) {return err;}if (result != NO_ERROR) {return result;}std::vector<int32_t> supported;supported.reserve(supportedTimestamps.size());for (FrameEvent s : supportedTimestamps) {supported.push_back(static_cast<int32_t>(s));}return reply->writeInt32Vector(supported);}case CREATE_DISPLAY_EVENT_CONNECTION: {CHECK_INTERFACE(ISurfaceComposer, data, reply);auto vsyncSource = static_cast<ISurfaceComposer::VsyncSource>(data.readInt32());EventRegistrationFlags eventRegistration =static_cast<EventRegistration>(data.readUint32());sp<IDisplayEventConnection> connection(createDisplayEventConnection(vsyncSource, eventRegistration));reply->writeStrongBinder(IInterface::asBinder(connection));return NO_ERROR;}case CREATE_DISPLAY: {CHECK_INTERFACE(ISurfaceComposer, data, reply);String8 displayName;SAFE_PARCEL(data.readString8, &displayName);bool secure = false;SAFE_PARCEL(data.readBool, &secure);sp<IBinder> display = createDisplay(displayName, secure);SAFE_PARCEL(reply->writeStrongBinder, display);return NO_ERROR;}case DESTROY_DISPLAY: {CHECK_INTERFACE(ISurfaceComposer, data, reply);sp<IBinder> display = data.readStrongBinder();destroyDisplay(display);return NO_ERROR;}case GET_PHYSICAL_DISPLAY_TOKEN: {CHECK_INTERFACE(ISurfaceComposer, data, reply);PhysicalDisplayId displayId(data.readUint64());sp<IBinder> display = getPhysicalDisplayToken(displayId);reply->writeStrongBinder(display);return NO_ERROR;}case GET_DISPLAY_STATE: {CHECK_INTERFACE(ISurfaceComposer, data, reply);ui::DisplayState state;const sp<IBinder> display = data.readStrongBinder();const status_t result = getDisplayState(display, &state);reply->writeInt32(result);if (result == NO_ERROR) {memcpy(reply->writeInplace(sizeof(ui::DisplayState)), &state,sizeof(ui::DisplayState));}return NO_ERROR;}case GET_STATIC_DISPLAY_INFO: {CHECK_INTERFACE(ISurfaceComposer, data, reply);ui::StaticDisplayInfo info;const sp<IBinder> display = data.readStrongBinder();const status_t result = getStaticDisplayInfo(display, &info);SAFE_PARCEL(reply->writeInt32, result);if (result != NO_ERROR) return result;SAFE_PARCEL(reply->write, info);return NO_ERROR;}case GET_DYNAMIC_DISPLAY_INFO: {CHECK_INTERFACE(ISurfaceComposer, data, reply);ui::DynamicDisplayInfo info;const sp<IBinder> display = data.readStrongBinder();const status_t result = getDynamicDisplayInfo(display, &info);SAFE_PARCEL(reply->writeInt32, result);if (result != NO_ERROR) return result;SAFE_PARCEL(reply->write, info);return NO_ERROR;}case GET_DISPLAY_STATS: {CHECK_INTERFACE(ISurfaceComposer, data, reply);DisplayStatInfo stats;sp<IBinder> display = data.readStrongBinder();status_t result = getDisplayStats(display, &stats);reply->writeInt32(result);if (result == NO_ERROR) {memcpy(reply->writeInplace(sizeof(DisplayStatInfo)),&stats, sizeof(DisplayStatInfo));}return NO_ERROR;}case GET_DISPLAY_NATIVE_PRIMARIES: {CHECK_INTERFACE(ISurfaceComposer, data, reply);ui::DisplayPrimaries primaries;sp<IBinder> display = nullptr;status_t result = data.readStrongBinder(&display);if (result != NO_ERROR) {ALOGE("getDisplayNativePrimaries failed to readStrongBinder: %d", result);return result;}result = getDisplayNativePrimaries(display, primaries);reply->writeInt32(result);if (result == NO_ERROR) {memcpy(reply->writeInplace(sizeof(ui::DisplayPrimaries)), &primaries,sizeof(ui::DisplayPrimaries));}return NO_ERROR;}case SET_ACTIVE_COLOR_MODE: {CHECK_INTERFACE(ISurfaceComposer, data, reply);sp<IBinder> display = nullptr;status_t result = data.readStrongBinder(&display);if (result != NO_ERROR) {ALOGE("getActiveColorMode failed to readStrongBinder: %d", result);return result;}int32_t colorModeInt = 0;result = data.readInt32(&colorModeInt);if (result != NO_ERROR) {ALOGE("setActiveColorMode failed to readInt32: %d", result);return result;}result = setActiveColorMode(display,static_cast<ColorMode>(colorModeInt));result = reply->writeInt32(result);return result;}case SET_AUTO_LOW_LATENCY_MODE: {CHECK_INTERFACE(ISurfaceComposer, data, reply);sp<IBinder> display = nullptr;status_t result = data.readStrongBinder(&display);if (result != NO_ERROR) {ALOGE("setAutoLowLatencyMode failed to readStrongBinder: %d", result);return result;}bool setAllm = false;result = data.readBool(&setAllm);if (result != NO_ERROR) {ALOGE("setAutoLowLatencyMode failed to readBool: %d", result);return result;}setAutoLowLatencyMode(display, setAllm);return result;}case SET_GAME_CONTENT_TYPE: {CHECK_INTERFACE(ISurfaceComposer, data, reply);sp<IBinder> display = nullptr;status_t result = data.readStrongBinder(&display);if (result != NO_ERROR) {ALOGE("setGameContentType failed to readStrongBinder: %d", result);return result;}bool setGameContentTypeOn = false;result = data.readBool(&setGameContentTypeOn);if (result != NO_ERROR) {ALOGE("setGameContentType failed to readBool: %d", result);return result;}setGameContentType(display, setGameContentTypeOn);return result;}case CLEAR_ANIMATION_FRAME_STATS: {CHECK_INTERFACE(ISurfaceComposer, data, reply);status_t result = clearAnimationFrameStats();reply->writeInt32(result);return NO_ERROR;}case GET_ANIMATION_FRAME_STATS: {CHECK_INTERFACE(ISurfaceComposer, data, reply);FrameStats stats;status_t result = getAnimationFrameStats(&stats);reply->write(stats);reply->writeInt32(result);return NO_ERROR;}case SET_POWER_MODE: {CHECK_INTERFACE(ISurfaceComposer, data, reply);sp<IBinder> display = data.readStrongBinder();int32_t mode = data.readInt32();setPowerMode(display, mode);return NO_ERROR;}case ENABLE_VSYNC_INJECTIONS: {CHECK_INTERFACE(ISurfaceComposer, data, reply);bool enable = false;status_t result = data.readBool(&enable);if (result != NO_ERROR) {ALOGE("enableVSyncInjections failed to readBool: %d", result);return result;}return enableVSyncInjections(enable);}case INJECT_VSYNC: {CHECK_INTERFACE(ISurfaceComposer, data, reply);int64_t when = 0;status_t result = data.readInt64(&when);if (result != NO_ERROR) {ALOGE("enableVSyncInjections failed to readInt64: %d", result);return result;}return injectVSync(when);}case GET_LAYER_DEBUG_INFO: {CHECK_INTERFACE(ISurfaceComposer, data, reply);std::vector<LayerDebugInfo> outLayers;status_t result = getLayerDebugInfo(&outLayers);reply->writeInt32(result);if (result == NO_ERROR){result = reply->writeParcelableVector(outLayers);}return result;}case GET_COMPOSITION_PREFERENCE: {CHECK_INTERFACE(ISurfaceComposer, data, reply);ui::Dataspace defaultDataspace;ui::PixelFormat defaultPixelFormat;ui::Dataspace wideColorGamutDataspace;ui::PixelFormat wideColorGamutPixelFormat;status_t error =getCompositionPreference(&defaultDataspace, &defaultPixelFormat,&wideColorGamutDataspace, &wideColorGamutPixelFormat);reply->writeInt32(error);if (error == NO_ERROR) {reply->writeInt32(static_cast<int32_t>(defaultDataspace));reply->writeInt32(static_cast<int32_t>(defaultPixelFormat));reply->writeInt32(static_cast<int32_t>(wideColorGamutDataspace));reply->writeInt32(static_cast<int32_t>(wideColorGamutPixelFormat));}return error;}case GET_COLOR_MANAGEMENT: {CHECK_INTERFACE(ISurfaceComposer, data, reply);bool result;status_t error = getColorManagement(&result);if (error == NO_ERROR) {reply->writeBool(result);}return error;}case GET_DISPLAYED_CONTENT_SAMPLING_ATTRIBUTES: {CHECK_INTERFACE(ISurfaceComposer, data, reply);sp<IBinder> display = data.readStrongBinder();ui::PixelFormat format;ui::Dataspace dataspace;uint8_t component = 0;auto result =getDisplayedContentSamplingAttributes(display, &format, &dataspace, &component);if (result == NO_ERROR) {reply->writeUint32(static_cast<uint32_t>(format));reply->writeUint32(static_cast<uint32_t>(dataspace));reply->writeUint32(static_cast<uint32_t>(component));}return result;}case SET_DISPLAY_CONTENT_SAMPLING_ENABLED: {CHECK_INTERFACE(ISurfaceComposer, data, reply);sp<IBinder> display = nullptr;bool enable = false;int8_t componentMask = 0;uint64_t maxFrames = 0;status_t result = data.readStrongBinder(&display);if (result != NO_ERROR) {ALOGE("setDisplayContentSamplingEnabled failure in reading Display token: %d",result);return result;}result = data.readBool(&enable);if (result != NO_ERROR) {ALOGE("setDisplayContentSamplingEnabled failure in reading enable: %d", result);return result;}result = data.readByte(static_cast<int8_t*>(&componentMask));if (result != NO_ERROR) {ALOGE("setDisplayContentSamplingEnabled failure in reading component mask: %d",result);return result;}result = data.readUint64(&maxFrames);if (result != NO_ERROR) {ALOGE("setDisplayContentSamplingEnabled failure in reading max frames: %d", result);return result;}return setDisplayContentSamplingEnabled(display, enable,static_cast<uint8_t>(componentMask), maxFrames);}case GET_DISPLAYED_CONTENT_SAMPLE: {CHECK_INTERFACE(ISurfaceComposer, data, reply);sp<IBinder> display = data.readStrongBinder();uint64_t maxFrames = 0;uint64_t timestamp = 0;status_t result = data.readUint64(&maxFrames);if (result != NO_ERROR) {ALOGE("getDisplayedContentSample failure in reading max frames: %d", result);return result;}result = data.readUint64(&timestamp);if (result != NO_ERROR) {ALOGE("getDisplayedContentSample failure in reading timestamp: %d", result);return result;}DisplayedFrameStats stats;result = getDisplayedContentSample(display, maxFrames, timestamp, &stats);if (result == NO_ERROR) {reply->writeUint64(stats.numFrames);reply->writeUint64Vector(stats.component_0_sample);reply->writeUint64Vector(stats.component_1_sample);reply->writeUint64Vector(stats.component_2_sample);reply->writeUint64Vector(stats.component_3_sample);}return result;}case GET_PROTECTED_CONTENT_SUPPORT: {CHECK_INTERFACE(ISurfaceComposer, data, reply);bool result;status_t error = getProtectedContentSupport(&result);if (error == NO_ERROR) {reply->writeBool(result);}return error;}case IS_WIDE_COLOR_DISPLAY: {CHECK_INTERFACE(ISurfaceComposer, data, reply);sp<IBinder> display = nullptr;status_t error = data.readStrongBinder(&display);if (error != NO_ERROR) {return error;}bool result;error = isWideColorDisplay(display, &result);if (error == NO_ERROR) {reply->writeBool(result);}return error;}case GET_PHYSICAL_DISPLAY_IDS: {CHECK_INTERFACE(ISurfaceComposer, data, reply);std::vector<PhysicalDisplayId> ids = getPhysicalDisplayIds();std::vector<uint64_t> rawIds(ids.size());std::transform(ids.begin(), ids.end(), rawIds.begin(),[](PhysicalDisplayId id) { return id.value; });return reply->writeUint64Vector(rawIds);}case ADD_REGION_SAMPLING_LISTENER: {CHECK_INTERFACE(ISurfaceComposer, data, reply);Rect samplingArea;status_t result = data.read(samplingArea);if (result != NO_ERROR) {ALOGE("addRegionSamplingListener: Failed to read sampling area");return result;}sp<IBinder> stopLayerHandle;result = data.readNullableStrongBinder(&stopLayerHandle);if (result != NO_ERROR) {ALOGE("addRegionSamplingListener: Failed to read stop layer handle");return result;}sp<IRegionSamplingListener> listener;result = data.readNullableStrongBinder(&listener);if (result != NO_ERROR) {ALOGE("addRegionSamplingListener: Failed to read listener");return result;}return addRegionSamplingListener(samplingArea, stopLayerHandle, listener);}case REMOVE_REGION_SAMPLING_LISTENER: {CHECK_INTERFACE(ISurfaceComposer, data, reply);sp<IRegionSamplingListener> listener;status_t result = data.readNullableStrongBinder(&listener);if (result != NO_ERROR) {ALOGE("removeRegionSamplingListener: Failed to read listener");return result;}return removeRegionSamplingListener(listener);}case ADD_FPS_LISTENER: {CHECK_INTERFACE(ISurfaceComposer, data, reply);int32_t taskId;status_t result = data.readInt32(&taskId);if (result != NO_ERROR) {ALOGE("addFpsListener: Failed to read layer handle");return result;}sp<gui::IFpsListener> listener;result = data.readNullableStrongBinder(&listener);if (result != NO_ERROR) {ALOGE("addFpsListener: Failed to read listener");return result;}return addFpsListener(taskId, listener);}case REMOVE_FPS_LISTENER: {CHECK_INTERFACE(ISurfaceComposer, data, reply);sp<gui::IFpsListener> listener;status_t result = data.readNullableStrongBinder(&listener);if (result != NO_ERROR) {ALOGE("removeFpsListener: Failed to read listener");return result;}return removeFpsListener(listener);}case ADD_TUNNEL_MODE_ENABLED_LISTENER: {CHECK_INTERFACE(ISurfaceComposer, data, reply);sp<gui::ITunnelModeEnabledListener> listener;status_t result = data.readNullableStrongBinder(&listener);if (result != NO_ERROR) {ALOGE("addTunnelModeEnabledListener: Failed to read listener");return result;}return addTunnelModeEnabledListener(listener);}case REMOVE_TUNNEL_MODE_ENABLED_LISTENER: {CHECK_INTERFACE(ISurfaceComposer, data, reply);sp<gui::ITunnelModeEnabledListener> listener;status_t result = data.readNullableStrongBinder(&listener);if (result != NO_ERROR) {ALOGE("removeTunnelModeEnabledListener: Failed to read listener");return result;}return removeTunnelModeEnabledListener(listener);}case SET_DESIRED_DISPLAY_MODE_SPECS: {CHECK_INTERFACE(ISurfaceComposer, data, reply);sp<IBinder> displayToken = data.readStrongBinder();ui::DisplayModeId defaultMode;status_t result = data.readInt32(&defaultMode);if (result != NO_ERROR) {ALOGE("setDesiredDisplayModeSpecs: failed to read defaultMode: %d", result);return result;}if (defaultMode < 0) {ALOGE("%s: defaultMode must be non-negative but it was %d", __func__, defaultMode);return BAD_VALUE;}bool allowGroupSwitching;result = data.readBool(&allowGroupSwitching);if (result != NO_ERROR) {ALOGE("setDesiredDisplayModeSpecs: failed to read allowGroupSwitching: %d", result);return result;}float primaryRefreshRateMin;result = data.readFloat(&primaryRefreshRateMin);if (result != NO_ERROR) {ALOGE("setDesiredDisplayModeSpecs: failed to read primaryRefreshRateMin: %d",result);return result;}float primaryRefreshRateMax;result = data.readFloat(&primaryRefreshRateMax);if (result != NO_ERROR) {ALOGE("setDesiredDisplayModeSpecs: failed to read primaryRefreshRateMax: %d",result);return result;}float appRequestRefreshRateMin;result = data.readFloat(&appRequestRefreshRateMin);if (result != NO_ERROR) {ALOGE("setDesiredDisplayModeSpecs: failed to read appRequestRefreshRateMin: %d",result);return result;}float appRequestRefreshRateMax;result = data.readFloat(&appRequestRefreshRateMax);if (result != NO_ERROR) {ALOGE("setDesiredDisplayModeSpecs: failed to read appRequestRefreshRateMax: %d",result);return result;}result = setDesiredDisplayModeSpecs(displayToken, defaultMode, allowGroupSwitching,primaryRefreshRateMin, primaryRefreshRateMax,appRequestRefreshRateMin, appRequestRefreshRateMax);if (result != NO_ERROR) {ALOGE("setDesiredDisplayModeSpecs: failed to call setDesiredDisplayModeSpecs: ""%d",result);return result;}reply->writeInt32(result);return result;}case GET_DESIRED_DISPLAY_MODE_SPECS: {CHECK_INTERFACE(ISurfaceComposer, data, reply);sp<IBinder> displayToken = data.readStrongBinder();ui::DisplayModeId defaultMode;bool allowGroupSwitching;float primaryRefreshRateMin;float primaryRefreshRateMax;float appRequestRefreshRateMin;float appRequestRefreshRateMax;status_t result =getDesiredDisplayModeSpecs(displayToken, &defaultMode, &allowGroupSwitching,&primaryRefreshRateMin, &primaryRefreshRateMax,&appRequestRefreshRateMin,&appRequestRefreshRateMax);if (result != NO_ERROR) {ALOGE("getDesiredDisplayModeSpecs: failed to get getDesiredDisplayModeSpecs: ""%d",result);return result;}result = reply->writeInt32(defaultMode);if (result != NO_ERROR) {ALOGE("getDesiredDisplayModeSpecs: failed to write defaultMode: %d", result);return result;}result = reply->writeBool(allowGroupSwitching);if (result != NO_ERROR) {ALOGE("getDesiredDisplayModeSpecs: failed to write allowGroupSwitching: %d",result);return result;}result = reply->writeFloat(primaryRefreshRateMin);if (result != NO_ERROR) {ALOGE("getDesiredDisplayModeSpecs: failed to write primaryRefreshRateMin: %d",result);return result;}result = reply->writeFloat(primaryRefreshRateMax);if (result != NO_ERROR) {ALOGE("getDesiredDisplayModeSpecs: failed to write primaryRefreshRateMax: %d",result);return result;}result = reply->writeFloat(appRequestRefreshRateMin);if (result != NO_ERROR) {ALOGE("getDesiredDisplayModeSpecs: failed to write appRequestRefreshRateMin: %d",result);return result;}result = reply->writeFloat(appRequestRefreshRateMax);if (result != NO_ERROR) {ALOGE("getDesiredDisplayModeSpecs: failed to write appRequestRefreshRateMax: %d",result);return result;}reply->writeInt32(result);return result;}case GET_DISPLAY_BRIGHTNESS_SUPPORT: {CHECK_INTERFACE(ISurfaceComposer, data, reply);sp<IBinder> displayToken;status_t error = data.readNullableStrongBinder(&displayToken);if (error != NO_ERROR) {ALOGE("getDisplayBrightnessSupport: failed to read display token: %d", error);return error;}bool support = false;error = getDisplayBrightnessSupport(displayToken, &support);reply->writeBool(support);return error;}case SET_DISPLAY_BRIGHTNESS: {CHECK_INTERFACE(ISurfaceComposer, data, reply);sp<IBinder> displayToken;status_t error = data.readNullableStrongBinder(&displayToken);if (error != NO_ERROR) {ALOGE("setDisplayBrightness: failed to read display token: %d", error);return error;}gui::DisplayBrightness brightness;error = data.readParcelable(&brightness);if (error != NO_ERROR) {ALOGE("setDisplayBrightness: failed to read brightness: %d", error);return error;}return setDisplayBrightness(displayToken, brightness);}case ADD_HDR_LAYER_INFO_LISTENER: {CHECK_INTERFACE(ISurfaceComposer, data, reply);sp<IBinder> displayToken;status_t error = data.readNullableStrongBinder(&displayToken);if (error != NO_ERROR) {ALOGE("addHdrLayerInfoListener: Failed to read display token");return error;}sp<gui::IHdrLayerInfoListener> listener;error = data.readNullableStrongBinder(&listener);if (error != NO_ERROR) {ALOGE("addHdrLayerInfoListener: Failed to read listener");return error;}return addHdrLayerInfoListener(displayToken, listener);}case REMOVE_HDR_LAYER_INFO_LISTENER: {CHECK_INTERFACE(ISurfaceComposer, data, reply);sp<IBinder> displayToken;status_t error = data.readNullableStrongBinder(&displayToken);if (error != NO_ERROR) {ALOGE("removeHdrLayerInfoListener: Failed to read display token");return error;}sp<gui::IHdrLayerInfoListener> listener;error = data.readNullableStrongBinder(&listener);if (error != NO_ERROR) {ALOGE("removeHdrLayerInfoListener: Failed to read listener");return error;}return removeHdrLayerInfoListener(displayToken, listener);}case NOTIFY_POWER_BOOST: {CHECK_INTERFACE(ISurfaceComposer, data, reply);int32_t boostId;status_t error = data.readInt32(&boostId);if (error != NO_ERROR) {ALOGE("notifyPowerBoost: failed to read boostId: %d", error);return error;}return notifyPowerBoost(boostId);}case SET_GLOBAL_SHADOW_SETTINGS: {CHECK_INTERFACE(ISurfaceComposer, data, reply);std::vector<float> shadowConfig;status_t error = data.readFloatVector(&shadowConfig);if (error != NO_ERROR || shadowConfig.size() != 11) {ALOGE("setGlobalShadowSettings: failed to read shadowConfig: %d", error);return error;}half4 ambientColor = {shadowConfig[0], shadowConfig[1], shadowConfig[2],shadowConfig[3]};half4 spotColor = {shadowConfig[4], shadowConfig[5], shadowConfig[6], shadowConfig[7]};float lightPosY = shadowConfig[8];float lightPosZ = shadowConfig[9];float lightRadius = shadowConfig[10];return setGlobalShadowSettings(ambientColor, spotColor, lightPosY, lightPosZ,lightRadius);}case SET_FRAME_RATE: {CHECK_INTERFACE(ISurfaceComposer, data, reply);sp<IBinder> binder;SAFE_PARCEL(data.readStrongBinder, &binder);sp<IGraphicBufferProducer> surface = interface_cast<IGraphicBufferProducer>(binder);if (!surface) {ALOGE("setFrameRate: failed to cast to IGraphicBufferProducer");return BAD_VALUE;}float frameRate;SAFE_PARCEL(data.readFloat, &frameRate);int8_t compatibility;SAFE_PARCEL(data.readByte, &compatibility);int8_t changeFrameRateStrategy;SAFE_PARCEL(data.readByte, &changeFrameRateStrategy);status_t result =setFrameRate(surface, frameRate, compatibility, changeFrameRateStrategy);reply->writeInt32(result);return NO_ERROR;}case ACQUIRE_FRAME_RATE_FLEXIBILITY_TOKEN: {CHECK_INTERFACE(ISurfaceComposer, data, reply);sp<IBinder> token;status_t result = acquireFrameRateFlexibilityToken(&token);reply->writeInt32(result);if (result == NO_ERROR) {reply->writeStrongBinder(token);}return NO_ERROR;}case SET_FRAME_TIMELINE_INFO: {CHECK_INTERFACE(ISurfaceComposer, data, reply);sp<IBinder> binder;status_t err = data.readStrongBinder(&binder);if (err != NO_ERROR) {ALOGE("setFrameTimelineInfo: failed to read strong binder: %s (%d)", strerror(-err),-err);return err;}sp<IGraphicBufferProducer> surface = interface_cast<IGraphicBufferProducer>(binder);if (!surface) {ALOGE("setFrameTimelineInfo: failed to cast to IGraphicBufferProducer: %s (%d)",strerror(-err), -err);return err;}FrameTimelineInfo frameTimelineInfo;SAFE_PARCEL(frameTimelineInfo.read, data);status_t result = setFrameTimelineInfo(surface, frameTimelineInfo);reply->writeInt32(result);return NO_ERROR;}case ADD_TRANSACTION_TRACE_LISTENER: {CHECK_INTERFACE(ISurfaceComposer, data, reply);sp<gui::ITransactionTraceListener> listener;SAFE_PARCEL(data.readStrongBinder, &listener);return addTransactionTraceListener(listener);}case GET_GPU_CONTEXT_PRIORITY: {CHECK_INTERFACE(ISurfaceComposer, data, reply);int priority = getGPUContextPriority();SAFE_PARCEL(reply->writeInt32, priority);return NO_ERROR;}case GET_MAX_ACQUIRED_BUFFER_COUNT: {CHECK_INTERFACE(ISurfaceComposer, data, reply);int buffers = 0;int err = getMaxAcquiredBufferCount(&buffers);if (err != NO_ERROR) {return err;}SAFE_PARCEL(reply->writeInt32, buffers);return NO_ERROR;}case OVERRIDE_HDR_TYPES: {CHECK_INTERFACE(ISurfaceComposer, data, reply);sp<IBinder> display = nullptr;SAFE_PARCEL(data.readStrongBinder, &display);std::vector<int32_t> hdrTypes;SAFE_PARCEL(data.readInt32Vector, &hdrTypes);std::vector<ui::Hdr> hdrTypesVector;for (int i : hdrTypes) {hdrTypesVector.push_back(static_cast<ui::Hdr>(i));}return overrideHdrTypes(display, hdrTypesVector);}case ON_PULL_ATOM: {CHECK_INTERFACE(ISurfaceComposer, data, reply);int32_t atomId = 0;SAFE_PARCEL(data.readInt32, &atomId);std::string pulledData;bool success;status_t err = onPullAtom(atomId, &pulledData, &success);SAFE_PARCEL(reply->writeByteArray, pulledData.size(),reinterpret_cast<const uint8_t*>(pulledData.data()));SAFE_PARCEL(reply->writeBool, success);return err;}default: {return BBinder::onTransact(code, data, reply, flags);}}
}

2.1 Code标签扩展

  • status_t err = BnSurfaceComposer::onTransact(code, data, reply, flags)对应BnSurfaceComposer中Code标签
  • code标签 1000~1040

frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp

status_t SurfaceFlinger::onTransact(uint32_t code, const Parcel& data, Parcel* reply,uint32_t flags) {status_t credentialCheck = CheckTransactCodeCredentials(code);if (credentialCheck != OK) {return credentialCheck;}status_t err = BnSurfaceComposer::onTransact(code, data, reply, flags);if (err == UNKNOWN_TRANSACTION || err == PERMISSION_DENIED) {CHECK_INTERFACE(ISurfaceComposer, data, reply);IPCThreadState* ipc = IPCThreadState::self();const int uid = ipc->getCallingUid();if (CC_UNLIKELY(uid != AID_SYSTEM&& !PermissionCache::checkCallingPermission(sHardwareTest))) {const int pid = ipc->getCallingPid();ALOGE("Permission Denial: ""can't access SurfaceFlinger pid=%d, uid=%d", pid, uid);return PERMISSION_DENIED;}int n;switch (code) {case 1000: // SHOW_CPU, NOT SUPPORTED ANYMOREcase 1001: // SHOW_FPS, NOT SUPPORTED ANYMOREreturn NO_ERROR;case 1002:  // SHOW_UPDATESn = data.readInt32();mDebugRegion = n ? n : (mDebugRegion ? 0 : 1);invalidateHwcGeometry();repaintEverything();return NO_ERROR;case 1004:{ // repaint everythingrepaintEverything();return NO_ERROR;}case 1005:{ // force transactionMutex::Autolock _l(mStateLock);setTransactionFlags(eTransactionNeeded|eDisplayTransactionNeeded|eTraversalNeeded);return NO_ERROR;}case 1006:{ // send empty updatesignalRefresh();return NO_ERROR;}case 1008:  // toggle use of hw composern = data.readInt32();mDebugDisableHWC = n != 0;invalidateHwcGeometry();repaintEverything();return NO_ERROR;case 1009:  // toggle use of transform hintn = data.readInt32();mDebugDisableTransformHint = n != 0;invalidateHwcGeometry();repaintEverything();return NO_ERROR;case 1010:  // interrogate.reply->writeInt32(0);reply->writeInt32(0);reply->writeInt32(mDebugRegion);reply->writeInt32(0);reply->writeInt32(mDebugDisableHWC);return NO_ERROR;case 1013: {const auto display = getDefaultDisplayDevice();if (!display) {return NAME_NOT_FOUND;}reply->writeInt32(display->getPageFlipCount());return NO_ERROR;}case 1014: {Mutex::Autolock _l(mStateLock);// daltonizen = data.readInt32();switch (n % 10) {case 1:mDaltonizer.setType(ColorBlindnessType::Protanomaly);break;case 2:mDaltonizer.setType(ColorBlindnessType::Deuteranomaly);break;case 3:mDaltonizer.setType(ColorBlindnessType::Tritanomaly);break;default:mDaltonizer.setType(ColorBlindnessType::None);break;}if (n >= 10) {mDaltonizer.setMode(ColorBlindnessMode::Correction);} else {mDaltonizer.setMode(ColorBlindnessMode::Simulation);}updateColorMatrixLocked();return NO_ERROR;}case 1015: {Mutex::Autolock _l(mStateLock);// apply a color matrixn = data.readInt32();if (n) {// color matrix is sent as a column-major mat4 matrixfor (size_t i = 0 ; i < 4; i++) {for (size_t j = 0; j < 4; j++) {mClientColorMatrix[i][j] = data.readFloat();}}} else {mClientColorMatrix = mat4();}// Check that supplied matrix's last row is {0,0,0,1} so we can avoid// the division by w in the fragment shaderfloat4 lastRow(transpose(mClientColorMatrix)[3]);if (any(greaterThan(abs(lastRow - float4{0, 0, 0, 1}), float4{1e-4f}))) {ALOGE("The color transform's last row must be (0, 0, 0, 1)");}updateColorMatrixLocked();return NO_ERROR;}case 1016: { // Unused.return NAME_NOT_FOUND;}case 1017: {n = data.readInt32();mForceFullDamage = n != 0;return NO_ERROR;}case 1018: { // Modify Choreographer's durationn = data.readInt32();mScheduler->setDuration(mAppConnectionHandle, std::chrono::nanoseconds(n), 0ns);return NO_ERROR;}case 1019: { // Modify SurfaceFlinger's durationn = data.readInt32();mScheduler->setDuration(mSfConnectionHandle, std::chrono::nanoseconds(n), 0ns);return NO_ERROR;}case 1020: { // Layer updates interceptorn = data.readInt32();if (n) {ALOGV("Interceptor enabled");mInterceptor->enable(mDrawingState.layersSortedByZ, mDrawingState.displays);}else{ALOGV("Interceptor disabled");mInterceptor->disable();}return NO_ERROR;}case 1021: { // Disable HWC virtual displaysconst bool enable = data.readInt32() != 0;static_cast<void>(schedule([this, enable] { enableHalVirtualDisplays(enable); }));return NO_ERROR;}case 1022: { // Set saturation boostMutex::Autolock _l(mStateLock);mGlobalSaturationFactor = std::max(0.0f, std::min(data.readFloat(), 2.0f));updateColorMatrixLocked();return NO_ERROR;}case 1023: { // Set native modeint32_t colorMode;mDisplayColorSetting = static_cast<DisplayColorSetting>(data.readInt32());if (data.readInt32(&colorMode) == NO_ERROR) {mForceColorMode = static_cast<ColorMode>(colorMode);}invalidateHwcGeometry();repaintEverything();return NO_ERROR;}// Deprecate, use 1030 to check whether the device is color managed.case 1024: {return NAME_NOT_FOUND;}case 1025: { // Set layer tracingn = data.readInt32();bool tracingEnabledChanged;if (n) {ALOGD("LayerTracing enabled");tracingEnabledChanged = mTracing.enable();if (tracingEnabledChanged) {schedule([&]() MAIN_THREAD { mTracing.notify("start"); }).wait();}} else {ALOGD("LayerTracing disabled");tracingEnabledChanged = mTracing.disable();}mTracingEnabledChanged = tracingEnabledChanged;reply->writeInt32(NO_ERROR);return NO_ERROR;}case 1026: { // Get layer tracing statusreply->writeBool(mTracing.isEnabled());return NO_ERROR;}// Is a DisplayColorSetting supported?case 1027: {const auto display = getDefaultDisplayDevice();if (!display) {return NAME_NOT_FOUND;}DisplayColorSetting setting = static_cast<DisplayColorSetting>(data.readInt32());switch (setting) {case DisplayColorSetting::kManaged:reply->writeBool(useColorManagement);break;case DisplayColorSetting::kUnmanaged:reply->writeBool(true);break;case DisplayColorSetting::kEnhanced:reply->writeBool(display->hasRenderIntent(RenderIntent::ENHANCE));break;default: // vendor display color settingreply->writeBool(display->hasRenderIntent(static_cast<RenderIntent>(setting)));break;}return NO_ERROR;}case 1028: { // Unused.return NAME_NOT_FOUND;}// Set buffer size for SF tracing (value in KB)case 1029: {n = data.readInt32();if (n <= 0 || n > MAX_TRACING_MEMORY) {ALOGW("Invalid buffer size: %d KB", n);reply->writeInt32(BAD_VALUE);return BAD_VALUE;}ALOGD("Updating trace buffer to %d KB", n);mTracing.setBufferSize(n * 1024);reply->writeInt32(NO_ERROR);return NO_ERROR;}// Is device color managed?case 1030: {reply->writeBool(useColorManagement);return NO_ERROR;}// Override default composition data space// adb shell service call SurfaceFlinger 1031 i32 1 DATASPACE_NUMBER DATASPACE_NUMBER \// && adb shell stop zygote && adb shell start zygote// to restore: adb shell service call SurfaceFlinger 1031 i32 0 && \// adb shell stop zygote && adb shell start zygotecase 1031: {Mutex::Autolock _l(mStateLock);n = data.readInt32();if (n) {n = data.readInt32();if (n) {Dataspace dataspace = static_cast<Dataspace>(n);if (!validateCompositionDataspace(dataspace)) {return BAD_VALUE;}mDefaultCompositionDataspace = dataspace;}n = data.readInt32();if (n) {Dataspace dataspace = static_cast<Dataspace>(n);if (!validateCompositionDataspace(dataspace)) {return BAD_VALUE;}mWideColorGamutCompositionDataspace = dataspace;}} else {// restore composition data space.mDefaultCompositionDataspace = defaultCompositionDataspace;mWideColorGamutCompositionDataspace = wideColorGamutCompositionDataspace;}return NO_ERROR;}// Set trace flagscase 1033: {n = data.readUint32();ALOGD("Updating trace flags to 0x%x", n);mTracing.setTraceFlags(n);reply->writeInt32(NO_ERROR);return NO_ERROR;}case 1034: {switch (n = data.readInt32()) {case 0:case 1:enableRefreshRateOverlay(static_cast<bool>(n));break;default: {Mutex::Autolock lock(mStateLock);reply->writeBool(mRefreshRateOverlay != nullptr);}}return NO_ERROR;}case 1035: {const int modeId = data.readInt32();mDebugDisplayModeSetByBackdoor = false;const auto displayId = [&]() -> std::optional<PhysicalDisplayId> {uint64_t inputDisplayId = 0;if (data.readUint64(&inputDisplayId) == NO_ERROR) {const auto token = getPhysicalDisplayToken(static_cast<PhysicalDisplayId>(inputDisplayId));if (!token) {ALOGE("No display with id: %" PRIu64, inputDisplayId);return std::nullopt;}return std::make_optional<PhysicalDisplayId>(inputDisplayId);}return getInternalDisplayId();}();if (!displayId) {ALOGE("No display found");return NO_ERROR;}status_t result = setActiveMode(getPhysicalDisplayToken(*displayId), modeId);if (result != NO_ERROR) {return result;}mDebugDisplayModeSetByBackdoor = true;return NO_ERROR;}case 1036: {if (data.readInt32() > 0) {status_t result =acquireFrameRateFlexibilityToken(&mDebugFrameRateFlexibilityToken);if (result != NO_ERROR) {return result;}} else {mDebugFrameRateFlexibilityToken = nullptr;}return NO_ERROR;}// Inject a hotplug connected event for the primary display. This will deallocate and// reallocate the display state including framebuffers.case 1037: {std::optional<hal::HWDisplayId> hwcId;{Mutex::Autolock lock(mStateLock);hwcId = getHwComposer().getInternalHwcDisplayId();}onComposerHalHotplug(*hwcId, hal::Connection::CONNECTED);return NO_ERROR;}// Modify the max number of display frames stored within FrameTimelinecase 1038: {n = data.readInt32();if (n < 0 || n > MAX_ALLOWED_DISPLAY_FRAMES) {ALOGW("Invalid max size. Maximum allowed is %d", MAX_ALLOWED_DISPLAY_FRAMES);return BAD_VALUE;}if (n == 0) {// restore to defaultmFrameTimeline->reset();return NO_ERROR;}mFrameTimeline->setMaxDisplayFrames(n);return NO_ERROR;}case 1039: {PhysicalDisplayId displayId = [&]() {Mutex::Autolock lock(mStateLock);return getDefaultDisplayDeviceLocked()->getPhysicalId();}();auto inUid = static_cast<uid_t>(data.readInt32());const auto refreshRate = data.readFloat();mScheduler->setPreferredRefreshRateForUid(FrameRateOverride{inUid, refreshRate});mScheduler->onFrameRateOverridesChanged(mAppConnectionHandle, displayId);return NO_ERROR;}// Toggle caching feature// First argument is an int32 - nonzero enables caching and zero disables caching// Second argument is an optional uint64 - if present, then limits enabling/disabling// caching to a particular physical displaycase 1040: {status_t error =schedule([&] {n = data.readInt32();std::optional<PhysicalDisplayId> inputId = std::nullopt;if (uint64_t inputDisplayId;data.readUint64(&inputDisplayId) == NO_ERROR) {const auto token = getPhysicalDisplayToken(static_cast<PhysicalDisplayId>(inputDisplayId));if (!token) {ALOGE("No display with id: %" PRIu64, inputDisplayId);return NAME_NOT_FOUND;}inputId = std::make_optional<PhysicalDisplayId>(inputDisplayId);}{Mutex::Autolock lock(mStateLock);mLayerCachingEnabled = n != 0;for (const auto& [_, display] : mDisplays) {if (!inputId || *inputId == display->getPhysicalId()) {display->enableLayerCaching(mLayerCachingEnabled);}}}return OK;}).get();if (error != OK) {return error;}invalidateHwcGeometry();repaintEverything();return NO_ERROR;}}}return err;
}

2.2 Code标签扩展对应调用

Code扩展标签调用
1000SHOW_CPU, NOT SUPPORTED ANYMORE
1001SHOW_FPS, NOT SUPPORTED ANYMORE
1002ShowSurfaceUpdatesPreferenceController.java、DevelopmentFragment.java
1004
1008HardwareOverlaysPreferenceController.java、DevelopmentFragment.java
1010HardwareOverlaysPreferenceController.java、ShowSurfaceUpdatesPreferenceController.java、DevelopmentFragment.java
1014DisplayTransformManager.java
1015DisplayTransformManager.java
1022DisplayTransformManager.java
1023DisplayTransformManager.java
1025DevelopmentTiles.java、WindowManagerService.java、DevelopmentTiles.java
1026DevelopmentTiles.java、WindowManagerService.java、DevelopmentTiles.java
1030DisplayTransformManager.java
1033WindowManagerService.java
1034ShowRefreshRatePreferenceController.java
1035
1039
1040

3、SurfaceFlinger服务的BpSurfaceComposer端

frameworks/native/libs/gui/include/gui/ISurfaceComposer.h
frameworks/native/libs/gui/ISurfaceComposer.cpp

class BpSurfaceComposer : public BpInterface<ISurfaceComposer>
{
public:explicit BpSurfaceComposer(const sp<IBinder>& impl): BpInterface<ISurfaceComposer>(impl){}virtual ~BpSurfaceComposer();virtual sp<ISurfaceComposerClient> createConnection(){Parcel data, reply;data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());remote()->transact(BnSurfaceComposer::CREATE_CONNECTION, data, &reply);return interface_cast<ISurfaceComposerClient>(reply.readStrongBinder());}status_t setTransactionState(const FrameTimelineInfo& frameTimelineInfo,const Vector<ComposerState>& state,const Vector<DisplayState>& displays, uint32_t flags,const sp<IBinder>& applyToken, const InputWindowCommands& commands,int64_t desiredPresentTime, bool isAutoTimestamp,const client_cache_t& uncacheBuffer, bool hasListenerCallbacks,const std::vector<ListenerCallbacks>& listenerCallbacks,uint64_t transactionId) override {Parcel data, reply;data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());SAFE_PARCEL(frameTimelineInfo.write, data);SAFE_PARCEL(data.writeUint32, static_cast<uint32_t>(state.size()));for (const auto& s : state) {SAFE_PARCEL(s.write, data);}SAFE_PARCEL(data.writeUint32, static_cast<uint32_t>(displays.size()));for (const auto& d : displays) {SAFE_PARCEL(d.write, data);}SAFE_PARCEL(data.writeUint32, flags);SAFE_PARCEL(data.writeStrongBinder, applyToken);SAFE_PARCEL(commands.write, data);SAFE_PARCEL(data.writeInt64, desiredPresentTime);SAFE_PARCEL(data.writeBool, isAutoTimestamp);SAFE_PARCEL(data.writeStrongBinder, uncacheBuffer.token.promote());SAFE_PARCEL(data.writeUint64, uncacheBuffer.id);SAFE_PARCEL(data.writeBool, hasListenerCallbacks);SAFE_PARCEL(data.writeVectorSize, listenerCallbacks);for (const auto& [listener, callbackIds] : listenerCallbacks) {SAFE_PARCEL(data.writeStrongBinder, listener);SAFE_PARCEL(data.writeParcelableVector, callbackIds);}SAFE_PARCEL(data.writeUint64, transactionId);return remote()->transact(BnSurfaceComposer::SET_TRANSACTION_STATE, data, &reply);}void bootFinished() override {Parcel data, reply;data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());remote()->transact(BnSurfaceComposer::BOOT_FINISHED, data, &reply);}status_t captureDisplay(const DisplayCaptureArgs& args,const sp<IScreenCaptureListener>& captureListener) override {Parcel data, reply;data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());SAFE_PARCEL(args.write, data);SAFE_PARCEL(data.writeStrongBinder, IInterface::asBinder(captureListener));return remote()->transact(BnSurfaceComposer::CAPTURE_DISPLAY, data, &reply);}status_t captureDisplay(uint64_t displayOrLayerStack,const sp<IScreenCaptureListener>& captureListener) override {Parcel data, reply;data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());SAFE_PARCEL(data.writeUint64, displayOrLayerStack);SAFE_PARCEL(data.writeStrongBinder, IInterface::asBinder(captureListener));return remote()->transact(BnSurfaceComposer::CAPTURE_DISPLAY_BY_ID, data, &reply);}status_t captureLayers(const LayerCaptureArgs& args,const sp<IScreenCaptureListener>& captureListener) override {Parcel data, reply;data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());SAFE_PARCEL(args.write, data);SAFE_PARCEL(data.writeStrongBinder, IInterface::asBinder(captureListener));return remote()->transact(BnSurfaceComposer::CAPTURE_LAYERS, data, &reply);}bool authenticateSurfaceTexture(const sp<IGraphicBufferProducer>& bufferProducer) const override {Parcel data, reply;int err = NO_ERROR;err = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());if (err != NO_ERROR) {ALOGE("ISurfaceComposer::authenticateSurfaceTexture: error writing ""interface descriptor: %s (%d)", strerror(-err), -err);return false;}err = data.writeStrongBinder(IInterface::asBinder(bufferProducer));if (err != NO_ERROR) {ALOGE("ISurfaceComposer::authenticateSurfaceTexture: error writing ""strong binder to parcel: %s (%d)", strerror(-err), -err);return false;}err = remote()->transact(BnSurfaceComposer::AUTHENTICATE_SURFACE, data,&reply);if (err != NO_ERROR) {ALOGE("ISurfaceComposer::authenticateSurfaceTexture: error ""performing transaction: %s (%d)", strerror(-err), -err);return false;}int32_t result = 0;err = reply.readInt32(&result);if (err != NO_ERROR) {ALOGE("ISurfaceComposer::authenticateSurfaceTexture: error ""retrieving result: %s (%d)", strerror(-err), -err);return false;}return result != 0;}status_t getSupportedFrameTimestamps(std::vector<FrameEvent>* outSupported) const override {if (!outSupported) {return UNEXPECTED_NULL;}outSupported->clear();Parcel data, reply;status_t err = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());if (err != NO_ERROR) {return err;}err = remote()->transact(BnSurfaceComposer::GET_SUPPORTED_FRAME_TIMESTAMPS,data, &reply);if (err != NO_ERROR) {return err;}int32_t result = 0;err = reply.readInt32(&result);if (err != NO_ERROR) {return err;}if (result != NO_ERROR) {return result;}std::vector<int32_t> supported;err = reply.readInt32Vector(&supported);if (err != NO_ERROR) {return err;}outSupported->reserve(supported.size());for (int32_t s : supported) {outSupported->push_back(static_cast<FrameEvent>(s));}return NO_ERROR;}sp<IDisplayEventConnection> createDisplayEventConnection(VsyncSource vsyncSource, EventRegistrationFlags eventRegistration) override {Parcel data, reply;sp<IDisplayEventConnection> result;int err = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());if (err != NO_ERROR) {return result;}data.writeInt32(static_cast<int32_t>(vsyncSource));data.writeUint32(eventRegistration.get());err = remote()->transact(BnSurfaceComposer::CREATE_DISPLAY_EVENT_CONNECTION,data, &reply);if (err != NO_ERROR) {ALOGE("ISurfaceComposer::createDisplayEventConnection: error performing ""transaction: %s (%d)", strerror(-err), -err);return result;}result = interface_cast<IDisplayEventConnection>(reply.readStrongBinder());return result;}sp<IBinder> createDisplay(const String8& displayName, bool secure) override {Parcel data, reply;data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());status_t status = data.writeString8(displayName);if (status) {return nullptr;}status = data.writeBool(secure);if (status) {return nullptr;}status = remote()->transact(BnSurfaceComposer::CREATE_DISPLAY, data, &reply);if (status) {return nullptr;}sp<IBinder> display;status = reply.readNullableStrongBinder(&display);if (status) {return nullptr;}return display;}void destroyDisplay(const sp<IBinder>& display) override {Parcel data, reply;data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());data.writeStrongBinder(display);remote()->transact(BnSurfaceComposer::DESTROY_DISPLAY, data, &reply);}std::vector<PhysicalDisplayId> getPhysicalDisplayIds() const override {Parcel data, reply;data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());if (remote()->transact(BnSurfaceComposer::GET_PHYSICAL_DISPLAY_IDS, data, &reply) ==NO_ERROR) {std::vector<uint64_t> rawIds;if (reply.readUint64Vector(&rawIds) == NO_ERROR) {std::vector<PhysicalDisplayId> displayIds(rawIds.size());std::transform(rawIds.begin(), rawIds.end(), displayIds.begin(),[](uint64_t rawId) { return PhysicalDisplayId(rawId); });return displayIds;}}return {};}sp<IBinder> getPhysicalDisplayToken(PhysicalDisplayId displayId) const override {Parcel data, reply;data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());data.writeUint64(displayId.value);remote()->transact(BnSurfaceComposer::GET_PHYSICAL_DISPLAY_TOKEN, data, &reply);return reply.readStrongBinder();}void setPowerMode(const sp<IBinder>& display, int mode) override {Parcel data, reply;data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());data.writeStrongBinder(display);data.writeInt32(mode);remote()->transact(BnSurfaceComposer::SET_POWER_MODE, data, &reply);}status_t getDisplayState(const sp<IBinder>& display, ui::DisplayState* state) override {Parcel data, reply;data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());data.writeStrongBinder(display);remote()->transact(BnSurfaceComposer::GET_DISPLAY_STATE, data, &reply);const status_t result = reply.readInt32();if (result == NO_ERROR) {memcpy(state, reply.readInplace(sizeof(ui::DisplayState)), sizeof(ui::DisplayState));}return result;}status_t getStaticDisplayInfo(const sp<IBinder>& display,ui::StaticDisplayInfo* info) override {Parcel data, reply;data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());data.writeStrongBinder(display);remote()->transact(BnSurfaceComposer::GET_STATIC_DISPLAY_INFO, data, &reply);const status_t result = reply.readInt32();if (result != NO_ERROR) return result;return reply.read(*info);}status_t getDynamicDisplayInfo(const sp<IBinder>& display,ui::DynamicDisplayInfo* info) override {Parcel data, reply;data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());data.writeStrongBinder(display);remote()->transact(BnSurfaceComposer::GET_DYNAMIC_DISPLAY_INFO, data, &reply);const status_t result = reply.readInt32();if (result != NO_ERROR) return result;return reply.read(*info);}status_t getDisplayStats(const sp<IBinder>& display, DisplayStatInfo* stats) override {Parcel data, reply;data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());data.writeStrongBinder(display);remote()->transact(BnSurfaceComposer::GET_DISPLAY_STATS, data, &reply);status_t result = reply.readInt32();if (result == NO_ERROR) {memcpy(stats,reply.readInplace(sizeof(DisplayStatInfo)),sizeof(DisplayStatInfo));}return result;}status_t getDisplayNativePrimaries(const sp<IBinder>& display,ui::DisplayPrimaries& primaries) override {Parcel data, reply;status_t result = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());if (result != NO_ERROR) {ALOGE("getDisplayNativePrimaries failed to writeInterfaceToken: %d", result);return result;}result = data.writeStrongBinder(display);if (result != NO_ERROR) {ALOGE("getDisplayNativePrimaries failed to writeStrongBinder: %d", result);return result;}result = remote()->transact(BnSurfaceComposer::GET_DISPLAY_NATIVE_PRIMARIES, data, &reply);if (result != NO_ERROR) {ALOGE("getDisplayNativePrimaries failed to transact: %d", result);return result;}result = reply.readInt32();if (result == NO_ERROR) {memcpy(&primaries, reply.readInplace(sizeof(ui::DisplayPrimaries)),sizeof(ui::DisplayPrimaries));}return result;}status_t setActiveColorMode(const sp<IBinder>& display, ColorMode colorMode) override {Parcel data, reply;status_t result = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());if (result != NO_ERROR) {ALOGE("setActiveColorMode failed to writeInterfaceToken: %d", result);return result;}result = data.writeStrongBinder(display);if (result != NO_ERROR) {ALOGE("setActiveColorMode failed to writeStrongBinder: %d", result);return result;}result = data.writeInt32(static_cast<int32_t>(colorMode));if (result != NO_ERROR) {ALOGE("setActiveColorMode failed to writeInt32: %d", result);return result;}result = remote()->transact(BnSurfaceComposer::SET_ACTIVE_COLOR_MODE, data, &reply);if (result != NO_ERROR) {ALOGE("setActiveColorMode failed to transact: %d", result);return result;}return static_cast<status_t>(reply.readInt32());}void setAutoLowLatencyMode(const sp<IBinder>& display, bool on) override {Parcel data, reply;status_t result = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());if (result != NO_ERROR) {ALOGE("setAutoLowLatencyMode failed to writeInterfaceToken: %d", result);return;}result = data.writeStrongBinder(display);if (result != NO_ERROR) {ALOGE("setAutoLowLatencyMode failed to writeStrongBinder: %d", result);return;}result = data.writeBool(on);if (result != NO_ERROR) {ALOGE("setAutoLowLatencyMode failed to writeBool: %d", result);return;}result = remote()->transact(BnSurfaceComposer::SET_AUTO_LOW_LATENCY_MODE, data, &reply);if (result != NO_ERROR) {ALOGE("setAutoLowLatencyMode failed to transact: %d", result);return;}}void setGameContentType(const sp<IBinder>& display, bool on) override {Parcel data, reply;status_t result = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());if (result != NO_ERROR) {ALOGE("setGameContentType failed to writeInterfaceToken: %d", result);return;}result = data.writeStrongBinder(display);if (result != NO_ERROR) {ALOGE("setGameContentType failed to writeStrongBinder: %d", result);return;}result = data.writeBool(on);if (result != NO_ERROR) {ALOGE("setGameContentType failed to writeBool: %d", result);return;}result = remote()->transact(BnSurfaceComposer::SET_GAME_CONTENT_TYPE, data, &reply);if (result != NO_ERROR) {ALOGE("setGameContentType failed to transact: %d", result);}}status_t clearAnimationFrameStats() override {Parcel data, reply;status_t result = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());if (result != NO_ERROR) {ALOGE("clearAnimationFrameStats failed to writeInterfaceToken: %d", result);return result;}result = remote()->transact(BnSurfaceComposer::CLEAR_ANIMATION_FRAME_STATS, data, &reply);if (result != NO_ERROR) {ALOGE("clearAnimationFrameStats failed to transact: %d", result);return result;}return reply.readInt32();}status_t getAnimationFrameStats(FrameStats* outStats) const override {Parcel data, reply;data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());remote()->transact(BnSurfaceComposer::GET_ANIMATION_FRAME_STATS, data, &reply);reply.read(*outStats);return reply.readInt32();}virtual status_t overrideHdrTypes(const sp<IBinder>& display,const std::vector<ui::Hdr>& hdrTypes) {Parcel data, reply;SAFE_PARCEL(data.writeInterfaceToken, ISurfaceComposer::getInterfaceDescriptor());SAFE_PARCEL(data.writeStrongBinder, display);std::vector<int32_t> hdrTypesVector;for (ui::Hdr i : hdrTypes) {hdrTypesVector.push_back(static_cast<int32_t>(i));}SAFE_PARCEL(data.writeInt32Vector, hdrTypesVector);status_t result = remote()->transact(BnSurfaceComposer::OVERRIDE_HDR_TYPES, data, &reply);if (result != NO_ERROR) {ALOGE("overrideHdrTypes failed to transact: %d", result);return result;}return result;}status_t onPullAtom(const int32_t atomId, std::string* pulledData, bool* success) {Parcel data, reply;SAFE_PARCEL(data.writeInterfaceToken, ISurfaceComposer::getInterfaceDescriptor());SAFE_PARCEL(data.writeInt32, atomId);status_t err = remote()->transact(BnSurfaceComposer::ON_PULL_ATOM, data, &reply);if (err != NO_ERROR) {ALOGE("onPullAtom failed to transact: %d", err);return err;}int32_t size = 0;SAFE_PARCEL(reply.readInt32, &size);const void* dataPtr = reply.readInplace(size);if (dataPtr == nullptr) {return UNEXPECTED_NULL;}pulledData->assign((const char*)dataPtr, size);SAFE_PARCEL(reply.readBool, success);return NO_ERROR;}status_t enableVSyncInjections(bool enable) override {Parcel data, reply;status_t result = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());if (result != NO_ERROR) {ALOGE("enableVSyncInjections failed to writeInterfaceToken: %d", result);return result;}result = data.writeBool(enable);if (result != NO_ERROR) {ALOGE("enableVSyncInjections failed to writeBool: %d", result);return result;}result = remote()->transact(BnSurfaceComposer::ENABLE_VSYNC_INJECTIONS, data, &reply,IBinder::FLAG_ONEWAY);if (result != NO_ERROR) {ALOGE("enableVSyncInjections failed to transact: %d", result);return result;}return result;}status_t injectVSync(nsecs_t when) override {Parcel data, reply;status_t result = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());if (result != NO_ERROR) {ALOGE("injectVSync failed to writeInterfaceToken: %d", result);return result;}result = data.writeInt64(when);if (result != NO_ERROR) {ALOGE("injectVSync failed to writeInt64: %d", result);return result;}result = remote()->transact(BnSurfaceComposer::INJECT_VSYNC, data, &reply,IBinder::FLAG_ONEWAY);if (result != NO_ERROR) {ALOGE("injectVSync failed to transact: %d", result);return result;}return result;}status_t getLayerDebugInfo(std::vector<LayerDebugInfo>* outLayers) override {if (!outLayers) {return UNEXPECTED_NULL;}Parcel data, reply;status_t err = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());if (err != NO_ERROR) {return err;}err = remote()->transact(BnSurfaceComposer::GET_LAYER_DEBUG_INFO, data, &reply);if (err != NO_ERROR) {return err;}int32_t result = 0;err = reply.readInt32(&result);if (err != NO_ERROR) {return err;}if (result != NO_ERROR) {return result;}outLayers->clear();return reply.readParcelableVector(outLayers);}status_t getCompositionPreference(ui::Dataspace* defaultDataspace,ui::PixelFormat* defaultPixelFormat,ui::Dataspace* wideColorGamutDataspace,ui::PixelFormat* wideColorGamutPixelFormat) const override {Parcel data, reply;status_t error = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());if (error != NO_ERROR) {return error;}error = remote()->transact(BnSurfaceComposer::GET_COMPOSITION_PREFERENCE, data, &reply);if (error != NO_ERROR) {return error;}error = static_cast<status_t>(reply.readInt32());if (error == NO_ERROR) {*defaultDataspace = static_cast<ui::Dataspace>(reply.readInt32());*defaultPixelFormat = static_cast<ui::PixelFormat>(reply.readInt32());*wideColorGamutDataspace = static_cast<ui::Dataspace>(reply.readInt32());*wideColorGamutPixelFormat = static_cast<ui::PixelFormat>(reply.readInt32());}return error;}status_t getColorManagement(bool* outGetColorManagement) const override {Parcel data, reply;data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());remote()->transact(BnSurfaceComposer::GET_COLOR_MANAGEMENT, data, &reply);bool result;status_t err = reply.readBool(&result);if (err == NO_ERROR) {*outGetColorManagement = result;}return err;}status_t getDisplayedContentSamplingAttributes(const sp<IBinder>& display,ui::PixelFormat* outFormat,ui::Dataspace* outDataspace,uint8_t* outComponentMask) const override {if (!outFormat || !outDataspace || !outComponentMask) return BAD_VALUE;Parcel data, reply;data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());data.writeStrongBinder(display);status_t error =remote()->transact(BnSurfaceComposer::GET_DISPLAYED_CONTENT_SAMPLING_ATTRIBUTES,data, &reply);if (error != NO_ERROR) {return error;}uint32_t value = 0;error = reply.readUint32(&value);if (error != NO_ERROR) {return error;}*outFormat = static_cast<ui::PixelFormat>(value);error = reply.readUint32(&value);if (error != NO_ERROR) {return error;}*outDataspace = static_cast<ui::Dataspace>(value);error = reply.readUint32(&value);if (error != NO_ERROR) {return error;}*outComponentMask = static_cast<uint8_t>(value);return error;}status_t setDisplayContentSamplingEnabled(const sp<IBinder>& display, bool enable,uint8_t componentMask, uint64_t maxFrames) override {Parcel data, reply;data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());data.writeStrongBinder(display);data.writeBool(enable);data.writeByte(static_cast<int8_t>(componentMask));data.writeUint64(maxFrames);status_t result =remote()->transact(BnSurfaceComposer::SET_DISPLAY_CONTENT_SAMPLING_ENABLED, data,&reply);return result;}status_t getDisplayedContentSample(const sp<IBinder>& display, uint64_t maxFrames,uint64_t timestamp,DisplayedFrameStats* outStats) const override {if (!outStats) return BAD_VALUE;Parcel data, reply;data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());data.writeStrongBinder(display);data.writeUint64(maxFrames);data.writeUint64(timestamp);status_t result =remote()->transact(BnSurfaceComposer::GET_DISPLAYED_CONTENT_SAMPLE, data, &reply);if (result != NO_ERROR) {return result;}result = reply.readUint64(&outStats->numFrames);if (result != NO_ERROR) {return result;}result = reply.readUint64Vector(&outStats->component_0_sample);if (result != NO_ERROR) {return result;}result = reply.readUint64Vector(&outStats->component_1_sample);if (result != NO_ERROR) {return result;}result = reply.readUint64Vector(&outStats->component_2_sample);if (result != NO_ERROR) {return result;}result = reply.readUint64Vector(&outStats->component_3_sample);return result;}status_t getProtectedContentSupport(bool* outSupported) const override {Parcel data, reply;data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());status_t error =remote()->transact(BnSurfaceComposer::GET_PROTECTED_CONTENT_SUPPORT, data, &reply);if (error != NO_ERROR) {return error;}error = reply.readBool(outSupported);return error;}status_t isWideColorDisplay(const sp<IBinder>& token,bool* outIsWideColorDisplay) const override {Parcel data, reply;status_t error = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());if (error != NO_ERROR) {return error;}error = data.writeStrongBinder(token);if (error != NO_ERROR) {return error;}error = remote()->transact(BnSurfaceComposer::IS_WIDE_COLOR_DISPLAY, data, &reply);if (error != NO_ERROR) {return error;}error = reply.readBool(outIsWideColorDisplay);return error;}status_t addRegionSamplingListener(const Rect& samplingArea, const sp<IBinder>& stopLayerHandle,const sp<IRegionSamplingListener>& listener) override {Parcel data, reply;status_t error = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());if (error != NO_ERROR) {ALOGE("addRegionSamplingListener: Failed to write interface token");return error;}error = data.write(samplingArea);if (error != NO_ERROR) {ALOGE("addRegionSamplingListener: Failed to write sampling area");return error;}error = data.writeStrongBinder(stopLayerHandle);if (error != NO_ERROR) {ALOGE("addRegionSamplingListener: Failed to write stop layer handle");return error;}error = data.writeStrongBinder(IInterface::asBinder(listener));if (error != NO_ERROR) {ALOGE("addRegionSamplingListener: Failed to write listener");return error;}error = remote()->transact(BnSurfaceComposer::ADD_REGION_SAMPLING_LISTENER, data, &reply);if (error != NO_ERROR) {ALOGE("addRegionSamplingListener: Failed to transact");}return error;}status_t removeRegionSamplingListener(const sp<IRegionSamplingListener>& listener) override {Parcel data, reply;status_t error = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());if (error != NO_ERROR) {ALOGE("removeRegionSamplingListener: Failed to write interface token");return error;}error = data.writeStrongBinder(IInterface::asBinder(listener));if (error != NO_ERROR) {ALOGE("removeRegionSamplingListener: Failed to write listener");return error;}error = remote()->transact(BnSurfaceComposer::REMOVE_REGION_SAMPLING_LISTENER, data,&reply);if (error != NO_ERROR) {ALOGE("removeRegionSamplingListener: Failed to transact");}return error;}virtual status_t addFpsListener(int32_t taskId, const sp<gui::IFpsListener>& listener) {Parcel data, reply;SAFE_PARCEL(data.writeInterfaceToken, ISurfaceComposer::getInterfaceDescriptor());SAFE_PARCEL(data.writeInt32, taskId);SAFE_PARCEL(data.writeStrongBinder, IInterface::asBinder(listener));const status_t error =remote()->transact(BnSurfaceComposer::ADD_FPS_LISTENER, data, &reply);if (error != OK) {ALOGE("addFpsListener: Failed to transact");}return error;}virtual status_t removeFpsListener(const sp<gui::IFpsListener>& listener) {Parcel data, reply;SAFE_PARCEL(data.writeInterfaceToken, ISurfaceComposer::getInterfaceDescriptor());SAFE_PARCEL(data.writeStrongBinder, IInterface::asBinder(listener));const status_t error =remote()->transact(BnSurfaceComposer::REMOVE_FPS_LISTENER, data, &reply);if (error != OK) {ALOGE("removeFpsListener: Failed to transact");}return error;}virtual status_t addTunnelModeEnabledListener(const sp<gui::ITunnelModeEnabledListener>& listener) {Parcel data, reply;SAFE_PARCEL(data.writeInterfaceToken, ISurfaceComposer::getInterfaceDescriptor());SAFE_PARCEL(data.writeStrongBinder, IInterface::asBinder(listener));const status_t error =remote()->transact(BnSurfaceComposer::ADD_TUNNEL_MODE_ENABLED_LISTENER, data,&reply);if (error != NO_ERROR) {ALOGE("addTunnelModeEnabledListener: Failed to transact");}return error;}virtual status_t removeTunnelModeEnabledListener(const sp<gui::ITunnelModeEnabledListener>& listener) {Parcel data, reply;SAFE_PARCEL(data.writeInterfaceToken, ISurfaceComposer::getInterfaceDescriptor());SAFE_PARCEL(data.writeStrongBinder, IInterface::asBinder(listener));const status_t error =remote()->transact(BnSurfaceComposer::REMOVE_TUNNEL_MODE_ENABLED_LISTENER, data,&reply);if (error != NO_ERROR) {ALOGE("removeTunnelModeEnabledListener: Failed to transact");}return error;}status_t setDesiredDisplayModeSpecs(const sp<IBinder>& displayToken,ui::DisplayModeId defaultMode, bool allowGroupSwitching,float primaryRefreshRateMin, float primaryRefreshRateMax,float appRequestRefreshRateMin,float appRequestRefreshRateMax) override {Parcel data, reply;status_t result = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());if (result != NO_ERROR) {ALOGE("setDesiredDisplayModeSpecs: failed to writeInterfaceToken: %d", result);return result;}result = data.writeStrongBinder(displayToken);if (result != NO_ERROR) {ALOGE("setDesiredDisplayModeSpecs: failed to write display token: %d", result);return result;}result = data.writeInt32(defaultMode);if (result != NO_ERROR) {ALOGE("setDesiredDisplayModeSpecs failed to write defaultMode: %d", result);return result;}result = data.writeBool(allowGroupSwitching);if (result != NO_ERROR) {ALOGE("setDesiredDisplayModeSpecs failed to write allowGroupSwitching: %d", result);return result;}result = data.writeFloat(primaryRefreshRateMin);if (result != NO_ERROR) {ALOGE("setDesiredDisplayModeSpecs failed to write primaryRefreshRateMin: %d", result);return result;}result = data.writeFloat(primaryRefreshRateMax);if (result != NO_ERROR) {ALOGE("setDesiredDisplayModeSpecs failed to write primaryRefreshRateMax: %d", result);return result;}result = data.writeFloat(appRequestRefreshRateMin);if (result != NO_ERROR) {ALOGE("setDesiredDisplayModeSpecs failed to write appRequestRefreshRateMin: %d",result);return result;}result = data.writeFloat(appRequestRefreshRateMax);if (result != NO_ERROR) {ALOGE("setDesiredDisplayModeSpecs failed to write appRequestRefreshRateMax: %d",result);return result;}result =remote()->transact(BnSurfaceComposer::SET_DESIRED_DISPLAY_MODE_SPECS, data, &reply);if (result != NO_ERROR) {ALOGE("setDesiredDisplayModeSpecs failed to transact: %d", result);return result;}return reply.readInt32();}status_t getDesiredDisplayModeSpecs(const sp<IBinder>& displayToken,ui::DisplayModeId* outDefaultMode,bool* outAllowGroupSwitching,float* outPrimaryRefreshRateMin,float* outPrimaryRefreshRateMax,float* outAppRequestRefreshRateMin,float* outAppRequestRefreshRateMax) override {if (!outDefaultMode || !outAllowGroupSwitching || !outPrimaryRefreshRateMin ||!outPrimaryRefreshRateMax || !outAppRequestRefreshRateMin ||!outAppRequestRefreshRateMax) {return BAD_VALUE;}Parcel data, reply;status_t result = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());if (result != NO_ERROR) {ALOGE("getDesiredDisplayModeSpecs failed to writeInterfaceToken: %d", result);return result;}result = data.writeStrongBinder(displayToken);if (result != NO_ERROR) {ALOGE("getDesiredDisplayModeSpecs failed to writeStrongBinder: %d", result);return result;}result =remote()->transact(BnSurfaceComposer::GET_DESIRED_DISPLAY_MODE_SPECS, data, &reply);if (result != NO_ERROR) {ALOGE("getDesiredDisplayModeSpecs failed to transact: %d", result);return result;}result = reply.readInt32(outDefaultMode);if (result != NO_ERROR) {ALOGE("getDesiredDisplayModeSpecs failed to read defaultMode: %d", result);return result;}if (*outDefaultMode < 0) {ALOGE("%s: defaultMode must be non-negative but it was %d", __func__, *outDefaultMode);return BAD_VALUE;}result = reply.readBool(outAllowGroupSwitching);if (result != NO_ERROR) {ALOGE("getDesiredDisplayModeSpecs failed to read allowGroupSwitching: %d", result);return result;}result = reply.readFloat(outPrimaryRefreshRateMin);if (result != NO_ERROR) {ALOGE("getDesiredDisplayModeSpecs failed to read primaryRefreshRateMin: %d", result);return result;}result = reply.readFloat(outPrimaryRefreshRateMax);if (result != NO_ERROR) {ALOGE("getDesiredDisplayModeSpecs failed to read primaryRefreshRateMax: %d", result);return result;}result = reply.readFloat(outAppRequestRefreshRateMin);if (result != NO_ERROR) {ALOGE("getDesiredDisplayModeSpecs failed to read appRequestRefreshRateMin: %d", result);return result;}result = reply.readFloat(outAppRequestRefreshRateMax);if (result != NO_ERROR) {ALOGE("getDesiredDisplayModeSpecs failed to read appRequestRefreshRateMax: %d", result);return result;}return reply.readInt32();}status_t getDisplayBrightnessSupport(const sp<IBinder>& displayToken,bool* outSupport) const override {Parcel data, reply;status_t error = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());if (error != NO_ERROR) {ALOGE("getDisplayBrightnessSupport: failed to write interface token: %d", error);return error;}error = data.writeStrongBinder(displayToken);if (error != NO_ERROR) {ALOGE("getDisplayBrightnessSupport: failed to write display token: %d", error);return error;}error = remote()->transact(BnSurfaceComposer::GET_DISPLAY_BRIGHTNESS_SUPPORT, data, &reply);if (error != NO_ERROR) {ALOGE("getDisplayBrightnessSupport: failed to transact: %d", error);return error;}bool support;error = reply.readBool(&support);if (error != NO_ERROR) {ALOGE("getDisplayBrightnessSupport: failed to read support: %d", error);return error;}*outSupport = support;return NO_ERROR;}status_t setDisplayBrightness(const sp<IBinder>& displayToken,const gui::DisplayBrightness& brightness) override {Parcel data, reply;status_t error = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());if (error != NO_ERROR) {ALOGE("setDisplayBrightness: failed to write interface token: %d", error);return error;}error = data.writeStrongBinder(displayToken);if (error != NO_ERROR) {ALOGE("setDisplayBrightness: failed to write display token: %d", error);return error;}error = data.writeParcelable(brightness);if (error != NO_ERROR) {ALOGE("setDisplayBrightness: failed to write brightness: %d", error);return error;}error = remote()->transact(BnSurfaceComposer::SET_DISPLAY_BRIGHTNESS, data, &reply);if (error != NO_ERROR) {ALOGE("setDisplayBrightness: failed to transact: %d", error);return error;}return NO_ERROR;}status_t addHdrLayerInfoListener(const sp<IBinder>& displayToken,const sp<gui::IHdrLayerInfoListener>& listener) override {Parcel data, reply;SAFE_PARCEL(data.writeInterfaceToken, ISurfaceComposer::getInterfaceDescriptor());SAFE_PARCEL(data.writeStrongBinder, displayToken);SAFE_PARCEL(data.writeStrongBinder, IInterface::asBinder(listener));const status_t error =remote()->transact(BnSurfaceComposer::ADD_HDR_LAYER_INFO_LISTENER, data, &reply);if (error != OK) {ALOGE("addHdrLayerInfoListener: Failed to transact; error = %d", error);}return error;}status_t removeHdrLayerInfoListener(const sp<IBinder>& displayToken,const sp<gui::IHdrLayerInfoListener>& listener) override {Parcel data, reply;SAFE_PARCEL(data.writeInterfaceToken, ISurfaceComposer::getInterfaceDescriptor());SAFE_PARCEL(data.writeStrongBinder, displayToken);SAFE_PARCEL(data.writeStrongBinder, IInterface::asBinder(listener));const status_t error =remote()->transact(BnSurfaceComposer::REMOVE_HDR_LAYER_INFO_LISTENER, data, &reply);if (error != OK) {ALOGE("removeHdrLayerInfoListener: Failed to transact; error = %d", error);}return error;}status_t notifyPowerBoost(int32_t boostId) override {Parcel data, reply;status_t error = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());if (error != NO_ERROR) {ALOGE("notifyPowerBoost: failed to write interface token: %d", error);return error;}error = data.writeInt32(boostId);if (error != NO_ERROR) {ALOGE("notifyPowerBoost: failed to write boostId: %d", error);return error;}error = remote()->transact(BnSurfaceComposer::NOTIFY_POWER_BOOST, data, &reply,IBinder::FLAG_ONEWAY);if (error != NO_ERROR) {ALOGE("notifyPowerBoost: failed to transact: %d", error);return error;}return NO_ERROR;}status_t setGlobalShadowSettings(const half4& ambientColor, const half4& spotColor,float lightPosY, float lightPosZ, float lightRadius) override {Parcel data, reply;status_t error = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());if (error != NO_ERROR) {ALOGE("setGlobalShadowSettings: failed to write interface token: %d", error);return error;}std::vector<float> shadowConfig = {ambientColor.r, ambientColor.g, ambientColor.b,ambientColor.a, spotColor.r,    spotColor.g,spotColor.b,    spotColor.a,    lightPosY,lightPosZ,      lightRadius};error = data.writeFloatVector(shadowConfig);if (error != NO_ERROR) {ALOGE("setGlobalShadowSettings: failed to write shadowConfig: %d", error);return error;}error = remote()->transact(BnSurfaceComposer::SET_GLOBAL_SHADOW_SETTINGS, data, &reply,IBinder::FLAG_ONEWAY);if (error != NO_ERROR) {ALOGE("setGlobalShadowSettings: failed to transact: %d", error);return error;}return NO_ERROR;}status_t setFrameRate(const sp<IGraphicBufferProducer>& surface, float frameRate,int8_t compatibility, int8_t changeFrameRateStrategy) override {Parcel data, reply;SAFE_PARCEL(data.writeInterfaceToken, ISurfaceComposer::getInterfaceDescriptor());SAFE_PARCEL(data.writeStrongBinder, IInterface::asBinder(surface));SAFE_PARCEL(data.writeFloat, frameRate);SAFE_PARCEL(data.writeByte, compatibility);SAFE_PARCEL(data.writeByte, changeFrameRateStrategy);status_t err = remote()->transact(BnSurfaceComposer::SET_FRAME_RATE, data, &reply);if (err != NO_ERROR) {ALOGE("setFrameRate: failed to transact: %s (%d)", strerror(-err), err);return err;}return reply.readInt32();}status_t acquireFrameRateFlexibilityToken(sp<IBinder>* outToken) override {if (!outToken) return BAD_VALUE;Parcel data, reply;status_t err = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());if (err != NO_ERROR) {ALOGE("acquireFrameRateFlexibilityToken: failed writing interface token: %s (%d)",strerror(-err), -err);return err;}err = remote()->transact(BnSurfaceComposer::ACQUIRE_FRAME_RATE_FLEXIBILITY_TOKEN, data,&reply);if (err != NO_ERROR) {ALOGE("acquireFrameRateFlexibilityToken: failed to transact: %s (%d)", strerror(-err),err);return err;}err = reply.readInt32();if (err != NO_ERROR) {ALOGE("acquireFrameRateFlexibilityToken: call failed: %s (%d)", strerror(-err), err);return err;}err = reply.readStrongBinder(outToken);if (err != NO_ERROR) {ALOGE("acquireFrameRateFlexibilityToken: failed reading binder token: %s (%d)",strerror(-err), err);return err;}return NO_ERROR;}status_t setFrameTimelineInfo(const sp<IGraphicBufferProducer>& surface,const FrameTimelineInfo& frameTimelineInfo) override {Parcel data, reply;status_t err = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());if (err != NO_ERROR) {ALOGE("%s: failed writing interface token: %s (%d)", __func__, strerror(-err), -err);return err;}err = data.writeStrongBinder(IInterface::asBinder(surface));if (err != NO_ERROR) {ALOGE("%s: failed writing strong binder: %s (%d)", __func__, strerror(-err), -err);return err;}SAFE_PARCEL(frameTimelineInfo.write, data);err = remote()->transact(BnSurfaceComposer::SET_FRAME_TIMELINE_INFO, data, &reply);if (err != NO_ERROR) {ALOGE("%s: failed to transact: %s (%d)", __func__, strerror(-err), err);return err;}return reply.readInt32();}status_t addTransactionTraceListener(const sp<gui::ITransactionTraceListener>& listener) override {Parcel data, reply;SAFE_PARCEL(data.writeInterfaceToken, ISurfaceComposer::getInterfaceDescriptor());SAFE_PARCEL(data.writeStrongBinder, IInterface::asBinder(listener));return remote()->transact(BnSurfaceComposer::ADD_TRANSACTION_TRACE_LISTENER, data, &reply);}/*** Get priority of the RenderEngine in surface flinger.*/int getGPUContextPriority() override {Parcel data, reply;data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());status_t err =remote()->transact(BnSurfaceComposer::GET_GPU_CONTEXT_PRIORITY, data, &reply);if (err != NO_ERROR) {ALOGE("getGPUContextPriority failed to read data:  %s (%d)", strerror(-err), err);return 0;}return reply.readInt32();}status_t getMaxAcquiredBufferCount(int* buffers) const override {Parcel data, reply;data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());status_t err =remote()->transact(BnSurfaceComposer::GET_MAX_ACQUIRED_BUFFER_COUNT, data, &reply);if (err != NO_ERROR) {ALOGE("getMaxAcquiredBufferCount failed to read data:  %s (%d)", strerror(-err), err);return err;}return reply.readInt32(buffers);}
};// Out-of-line virtual method definition to trigger vtable emission in this
// translation unit (see clang warning -Wweak-vtables)
BpSurfaceComposer::~BpSurfaceComposer() {}

3.1 FWK使用案例

Android 显示刷新频率
(2.2 Code标签扩展对应调用有很多对应)

  • 功能:开发者选项->显示刷新频率
  • fwk代码路径:packages/apps/Settings/src/com/android/settings/development/ShowRefreshRatePreferenceController.java
  • 获取SurfaceFlinger服务:mSurfaceFlinger = ServiceManager.getService(SURFACE_FLINGER_SERVICE_KEY)
  • 调用方法Code Tag:static final int SURFACE_FLINGER_CODE = 1034;
  • 调用方法Code Tag对应方法并传递参数data:mSurfaceFlinger.transact(SURFACE_FLINGER_CODE, data, reply, 0 /* flags */);mSurfaceFlinger.transact(SURFACE_FLINGER_CODE, data, null /* reply */, 0 /* flags */);
  • SurfaceFlinger.cpp对应如下代码,enableRefreshRateOverlay(static_cast<bool>(n))方法创建RefreshRateOverlay 对应Layer显示刷新频率;这里会先校验CHECK_INTERFACE(ISurfaceComposer, data, reply)data.writeInterfaceToken(SURFACE_COMPOSER_INTERFACE_KEY);

frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp

status_t SurfaceFlinger::onTransact(uint32_t code, const Parcel& data, Parcel* reply,uint32_t flags) {status_t credentialCheck = CheckTransactCodeCredentials(code);if (credentialCheck != OK) {return credentialCheck;}status_t err = BnSurfaceComposer::onTransact(code, data, reply, flags);if (err == UNKNOWN_TRANSACTION || err == PERMISSION_DENIED) {// ... ...switch (code) {// ... ...case 1034: {switch (n = data.readInt32()) {case 0:case 1:enableRefreshRateOverlay(static_cast<bool>(n));break;default: {Mutex::Autolock lock(mStateLock);reply->writeBool(mRefreshRateOverlay != nullptr);}}return NO_ERROR;}// ... ...}}return err;
}

3.2 Native使用案例

目前没有找到相关defaultServiceManager()->getService(String16("SurfaceFlinger"))

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/61109.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

在Visual Studio 2017上配置Glut

上篇 已经介绍了如何配置OpenGL&#xff0c;但缺点是每次新建一个项目时&#xff0c;都应重新安装 “nupengl.core.redist” 与 “nupengl.core” 这两个文件&#xff0c;这在有网的情况下还是可以实现的&#xff0c;但不是一个长久之计。现在介绍另一种方法&#xff0c;用Glut…

C#---第二十:不同类型方法的执行顺序(new / virtual / common / override)

本文介绍不同类型的方法&#xff0c;在代码中的执行顺序问题&#xff1a; 构造方法普通方法&#xff08;暂用common代替&#xff09;、虚方法&#xff08;Virtual修饰&#xff09;、New方法&#xff08;new修饰&#xff09;三个优先级相同overide方法&#xff08;会替换virtual…

【AI辅助办公】PDF转PPT,移除水印

PDF转PPT 将PDF上传链接即可转换成PPT。​​​​​​ ​​​​​​​ https://www.camscanner.com/pdftoppthttps://www.camscanner.com/pdftoppt​​​​​​​​​​​​​​移除水印 第一步&#xff1a;打开视图-宏 第二步&#xff1a;输入宏名&#xff08;可以是人以文字…

记录一次Modbus通信的置位错误

老套路&#xff0c;一图胜千言&#xff0c;框图可能有点随意&#xff0c;后面我会解释 先描述下背景&#xff0c;编程语言是QT5 C,在Modbus线程内有一个死循环&#xff0c;一直在读8个线圈的状态&#xff0c;该线程内读到的消息会直接发送给UI线程&#xff0c;UI线程会解析Modb…

联想电脑装系统无法按F9后无法从系统盘启动的解决方案

开机时按F9发现没有加载系统盘. 打开BIOS设置界面&#xff0c;调整设置如下: BOOT MODE: Legacy Support.允许legacy方式boot. BOOT PRIORITY: Legacy First. Legacy方式作为首选的boot方式. USB BOOT: ENABLED. 允许以usb方式boot. Legacy: 这里设置legacy boot的优先级,…

CSAPP的Lab学习——BombLab

文章目录 前言一、一号炸弹&#xff08;小试牛刀&#xff09;二、二号炸弹&#xff08;六重循环&#xff09;三、三号炸弹&#xff08;不同输入&#xff0c;不同答案&#xff09;四、四号炸弹&#xff08;判断语句的实现&#xff09;五、五号炸弹&#xff08;跳转&#xff0c;循…

创建git项目并提交

1.创建仓库 2.点击创建 3复制gitee码云的HttpS连接 4 提交上传 打开项目并点击菜单栏上的【CVS】–》【Import into version control】–》【Create Git Repository】创建本地仓库 在打开的【Create Git Repository】对话框内选择本地仓库的位置&#xff0c;这里我选择…

C语言(第三十天)

1. 什么是bug bug本意是昆虫”或“虫子”&#xff0c;现在一般是指在电脑系统或程序中&#xff0c;隐藏着的一些未被发现的缺陷或问 题&#xff0c;简称程序漏洞。 “Bug” 的创始人格蕾丝赫柏&#xff08;Grace Murray Hopper&#xff09;&#xff0c;她是一位为美国海军工作的…

React面向组件编程

往期回顾&#xff1a;# React基础入门之虚拟Dom【一】 面向组件编程 react是面向组件编程的一种模式&#xff0c;它包含两种组件类型&#xff1a;函数式组件及类式组件 函数式组件 注&#xff1a;react17开始&#xff0c;函数式组件成为主流 一个基本的函数组件长这个样子 …

three.js(十):线性几何体

线性几何体 WireframeGeometry 网格几何体EdgesGeometry 边缘几何体 WireframeGeometry 网格几何体 WireframeGeometry( geometry : BufferGeometry ) geometry — 任意几何体对象。 const geometry new SphereGeometry(); const wireframe new WireframeGeometry(geometr…

python爬取bilibili,下载视频

一. 内容简介 python爬取bilibili&#xff0c;下载视频 二. 软件环境 2.1vsCode 2.2Anaconda version: conda 22.9.0 2.3代码 链接&#xff1a;https://pan.baidu.com/s/1WuXTso_iltLlnrLffi1kYQ?pwd1234 三.主要流程 3.1 下载单个视频 代码 import requests impor…

优思学院|六西格玛中的概率分布有哪些?

为什么概率分布重要&#xff1f; 概率分布是统计学中一个重要的概念&#xff0c;它帮助我们理解随机变量的分布情况以及与之相关的概率。在面对具体问题时&#xff0c;了解概率分布可以帮助我们选择适当的检验或分析策略&#xff0c;以解决问题并做出合理的决策。 常见的概率…

Redis问题集合(三)在Redis容器里设置键值对

前言 前提是已经拉取了Redis镜像并创建了对应的容器做个记录&#xff0c;方便后续查看 步骤 查看Redis容器的ID&#xff1a;docker ps -a 进入容器&#xff1a;docker exec -it 容器ID /bin/bash进入redis命令行&#xff1a;redis-cli输入密码&#xff1a;auth 配置密码 查看…

Apipost:为什么是开发者首选的API调试工具

文章目录 前言正文接口调试接口公共参数、环境全局参数的使用快速生成并导出接口文档研发协作接口压测和自动化测试结论 前言 Apipost是一款支持 RESTful API、SOAP API、GraphQL API等多种API类型&#xff0c;支持 HTTPS、WebSocket、gRPC多种通信协议的API调试工具。除此之外…

【使用DataEase数据可视化分析工具访问cpolar】

DataEase 是开源的数据可视化分析工具&#xff0c;帮助用户快速分析数据并洞察业务趋势&#xff0c;从而实现业务的改进与优化。是开源的数据可视化分析工具&#xff0c;帮助用户快速分析数据并洞察业务趋势&#xff0c;从而实现业务的改进与优化。 在本地搭建后,借助cpolar 内…

Java-泛型

文章目录 Java泛型什么是泛型&#xff1f;在哪里使用泛型&#xff1f;设计出泛型的好处是什么&#xff1f;动手设计一个泛型泛型的限定符泛型擦除泛型的通配符 结论 Java泛型 什么是泛型&#xff1f; Java泛型是一种编程技术&#xff0c;它允许在编译期间指定使用的数据类型。…

E9—TEMAC IP实现千兆网口UDP传输2023-08-28

1.关于IP收费的问题 Tri Mode Ethernet MAC是收费IP&#xff0c;打开IP后&#xff0c;当左下角显示Bought IP license available则IP可用。 2.功能说明 应用搭建的场景是&#xff0c;上位机发送数据&#xff0c;首先发起arp请求&#xff0c;随后下位机给出arp应答响应&#…

说说我最近筛简历和面试的感受。。

大家好&#xff0c;我是鱼皮。 都说现在行情不好、找工作难&#xff0c;但招人又谈何容易&#xff1f;&#xff01; 最近我们公司在招开发&#xff0c;实习社招都有。我收到的简历很多&#xff0c;但认真投递的、符合要求的却寥寥无几&#xff0c;而且都是我自己看简历、选人…

【Unity-Cinemachine相机】虚拟相机(Virtual Camera)的本质与基本属性

我们可以在游戏进行时修改各个属性&#xff0c;但在概念上&#xff0c;最好将Virtual Camera 当作一种相机行为的“配置文件”&#xff0c;而不是一个组件。 我们的相机有几种行为就为它准备几种虚拟相机&#xff0c;比如角色移动就为它第三人称相机&#xff0c;瞄准就准备一个…

驾驶员监控系统DMS系统功能规范

概述 文档范围 该文档阐述了DMS系统的功能场景、系统组成、接口需求等。 目的 该功能规范为DMS系统及周边件的开发提供参考。 缩写与定义 英文缩写 英文全称 中文描述 DMS: Driver Monitoring System 驾驶员监控系统 MPU: Micro Processor Unit 微处理器单元 IECU: …