USB偏好设置-Android13

USB偏好设置

  • 1、USB偏好设置界面和入口
  • 2、USB功能设置
    • 2.1 USB功能对应模式
    • 2.2 点击设置
    • 2.3 广播监听刷新
  • 3、日志开关
    • 3.1 Evet日志
    • 3.2 代码中日志开关
    • 3.3 关键日志
  • 4、异常

1、USB偏好设置界面和入口

设置》已连接的设备》USB
packages/apps/Settings/src/com/android/settings/connecteddevice/usb/UsbDetailsFragment.java
packages/apps/Settings/res/xml/usb_details_fragment.xml
在这里插入图片描述

private static List<UsbDetailsController> createControllerList(Context context,UsbBackend usbBackend, UsbDetailsFragment fragment) {List<UsbDetailsController> ret = new ArrayList<>();ret.add(new UsbDetailsHeaderController(context, fragment, usbBackend));ret.add(new UsbDetailsDataRoleController(context, fragment, usbBackend));ret.add(new UsbDetailsFunctionsController(context, fragment, usbBackend));ret.add(new UsbDetailsPowerRoleController(context, fragment, usbBackend));ret.add(new UsbDetailsTranscodeMtpController(context, fragment, usbBackend));return ret;
}

2、USB功能设置

packages/apps/Settings/src/com/android/settings/connecteddevice/usb/UsbDetailsFunctionsController.java

2.1 USB功能对应模式

FWK模式对应值字符串显示节点
FUNCTION_NONE = 0NONE = 0
FUNCTION_MTP = GadgetFunction.MTPMTP = 1 << 2“文件传输”
FUNCTION_PTP = GadgetFunction.PTPPTP = 1 << 4“PTP”
FUNCTION_RNDIS = GadgetFunction.RNDISRNDIS = 1 << 5“USB 网络共享”
FUNCTION_MIDI = GadgetFunction.MIDIMIDI = 1 << 3“MIDI”
FUNCTION_ACCESSORY = GadgetFunction.ACCESSORYACCESSORY = 1 << 1
FUNCTION_AUDIO_SOURCE = GadgetFunction.AUDIO_SOURCEAUDIO_SOURCE = 1 << 6
FUNCTION_ADB = GadgetFunction.ADBADB = 1 << 0“不用于数据传输”

frameworks/base/core/java/android/hardware/usb/UsbManager.java
hardware/interfaces/usb/gadget/1.0/types.hal
frameworks/base/core/proto/android/service/usb.proto

/* Same as android.hardware.usb.gadget.V1_0.GadgetFunction.* */
enum Function {FUNCTION_ADB = 1;FUNCTION_ACCESSORY = 2;FUNCTION_MTP = 4;FUNCTION_MIDI = 8;FUNCTION_PTP = 16;FUNCTION_RNDIS = 32;FUNCTION_AUDIO_SOURCE = 64;
}

2.2 点击设置

mUsbBackend 通过UsbManager.java、UsbService.java、UsbDeviceManager.java设置

packages/apps/Settings/src/com/android/settings/connecteddevice/usb/UsbDetailsFunctionsController.java

@Override
public void onRadioButtonClicked(SelectorWithWidgetPreference preference) {final long function = UsbBackend.usbFunctionsFromString(preference.getKey());final long previousFunction = mUsbBackend.getCurrentFunctions();if (DEBUG) {Log.d(TAG, "onRadioButtonClicked() function : " + function + ", toString() : "+ UsbManager.usbFunctionsToString(function) + ", previousFunction : "+ previousFunction + ", toString() : "+ UsbManager.usbFunctionsToString(previousFunction));}if (function != previousFunction && !Utils.isMonkeyRunning()&& !isClickEventIgnored(function, previousFunction)) {mPreviousFunction = previousFunction;//Update the UI in advance to make it looks smoothfinal SelectorWithWidgetPreference prevPref =(SelectorWithWidgetPreference) mProfilesContainer.findPreference(UsbBackend.usbFunctionsToString(mPreviousFunction));if (prevPref != null) {prevPref.setChecked(false);preference.setChecked(true);}if (function == UsbManager.FUNCTION_RNDIS || function == UsbManager.FUNCTION_NCM) {// We need to have entitlement check for usb tethering, so use API in// TetheringManager.mTetheringManager.startTethering(TetheringManager.TETHERING_USB, new HandlerExecutor(mHandler),mOnStartTetheringCallback);} else {mUsbBackend.setCurrentFunctions(function);}}
}

frameworks/base/services/usb/java/com/android/server/usb/UsbDeviceManager.java

public void setCurrentFunctions(long functions) {if (DEBUG) {Slog.d(TAG, "setCurrentFunctions(" + UsbManager.usbFunctionsToString(functions) + ")");}if (functions == UsbManager.FUNCTION_NONE) {MetricsLogger.action(mContext, MetricsEvent.ACTION_USB_CONFIG_CHARGING);} else if (functions == UsbManager.FUNCTION_MTP) {MetricsLogger.action(mContext, MetricsEvent.ACTION_USB_CONFIG_MTP);} else if (functions == UsbManager.FUNCTION_PTP) {MetricsLogger.action(mContext, MetricsEvent.ACTION_USB_CONFIG_PTP);} else if (functions == UsbManager.FUNCTION_MIDI) {MetricsLogger.action(mContext, MetricsEvent.ACTION_USB_CONFIG_MIDI);} else if (functions == UsbManager.FUNCTION_RNDIS) {MetricsLogger.action(mContext, MetricsEvent.ACTION_USB_CONFIG_RNDIS);} else if (functions == UsbManager.FUNCTION_ACCESSORY) {MetricsLogger.action(mContext, MetricsEvent.ACTION_USB_CONFIG_ACCESSORY);}mHandler.sendMessage(MSG_SET_CURRENT_FUNCTIONS, functions);}private boolean trySetEnabledFunctions(long usbFunctions, boolean forceRestart) {String functions = null;if (usbFunctions != UsbManager.FUNCTION_NONE) {functions = UsbManager.usbFunctionsToString(usbFunctions);}mCurrentFunctions = usbFunctions;if (functions == null || applyAdbFunction(functions).equals(UsbManager.USB_FUNCTION_NONE)) {functions = UsbManager.usbFunctionsToString(getChargingFunctions());}functions = applyAdbFunction(functions);String oemFunctions = applyOemOverrideFunction(functions);if (!isNormalBoot() && !mCurrentFunctionsStr.equals(functions)) {setSystemProperty(getPersistProp(true), functions);}if ((!functions.equals(oemFunctions)&& !mCurrentOemFunctions.equals(oemFunctions))|| !mCurrentFunctionsStr.equals(functions)|| !mCurrentFunctionsApplied|| forceRestart) {Slog.i(TAG, "Setting USB config to " + functions);mCurrentFunctionsStr = functions;mCurrentOemFunctions = oemFunctions;mCurrentFunctionsApplied = false;/*** Kick the USB stack to close existing connections.*/setUsbConfig(UsbManager.USB_FUNCTION_NONE);if (!waitForState(UsbManager.USB_FUNCTION_NONE)) {Slog.e(TAG, "Failed to kick USB config");return false;}/*** Set the new USB configuration.*/setUsbConfig(oemFunctions);if (mBootCompleted&& (containsFunction(functions, UsbManager.USB_FUNCTION_MTP)|| containsFunction(functions, UsbManager.USB_FUNCTION_PTP))) {/*** Start up dependent services.*/updateUsbStateBroadcastIfNeeded(getAppliedFunctions(mCurrentFunctions));}if (!waitForState(oemFunctions)) {Slog.e(TAG, "Failed to switch USB config to " + functions);return false;}mCurrentFunctionsApplied = true;}return true;}

hardware/interfaces/usb/gadget/1.2/default/UsbGadget.cpp

V1_0::Status UsbGadget::setupFunctions(uint64_t functions,const sp<V1_0::IUsbGadgetCallback>& callback,uint64_t timeout) {bool ffsEnabled = false;int i = 0;if (addGenericAndroidFunctions(&monitorFfs, functions, &ffsEnabled, &i) !=V1_0::Status::SUCCESS)return V1_0::Status::ERROR;if ((functions & V1_2::GadgetFunction::ADB) != 0) {ffsEnabled = true;if (addAdb(&monitorFfs, &i) != V1_0::Status::SUCCESS) return V1_0::Status::ERROR;}// Pull up the gadget right away when there are no ffs functions.if (!ffsEnabled) {if (!WriteStringToFile(kGadgetName, PULLUP_PATH)) return V1_0::Status::ERROR;mCurrentUsbFunctionsApplied = true;if (callback) callback->setCurrentUsbFunctionsCb(functions, V1_0::Status::SUCCESS);return V1_0::Status::SUCCESS;}monitorFfs.registerFunctionsAppliedCallback(&currentFunctionsAppliedCallback, this);// Monitors the ffs paths to pull up the gadget when descriptors are written.// Also takes of the pulling up the gadget again if the userspace process// dies and restarts.monitorFfs.startMonitor();if (kDebug) ALOGI("Mainthread in Cv");if (callback) {bool pullup = monitorFfs.waitForPullUp(timeout);Return<void> ret = callback->setCurrentUsbFunctionsCb(functions, pullup ? V1_0::Status::SUCCESS : V1_0::Status::ERROR);if (!ret.isOk()) ALOGE("setCurrentUsbFunctionsCb error %s", ret.description().c_str());}return V1_0::Status::SUCCESS;
}Return<void> UsbGadget::setCurrentUsbFunctions(uint64_t functions,const sp<V1_0::IUsbGadgetCallback>& callback,uint64_t timeout) {std::unique_lock<std::mutex> lk(mLockSetCurrentFunction);mCurrentUsbFunctions = functions;mCurrentUsbFunctionsApplied = false;// Unlink the gadget and stop the monitor if running.V1_0::Status status = tearDownGadget();if (status != V1_0::Status::SUCCESS) {goto error;}ALOGI("Returned from tearDown gadget");// Leave the gadget pulled down to give time for the host to sense disconnect.usleep(kDisconnectWaitUs);if (functions == static_cast<uint64_t>(V1_2::GadgetFunction::NONE)) {if (callback == NULL) return Void();Return<void> ret = callback->setCurrentUsbFunctionsCb(functions, V1_0::Status::SUCCESS);if (!ret.isOk())ALOGE("Error while calling setCurrentUsbFunctionsCb %s", ret.description().c_str());return Void();}status = validateAndSetVidPid(functions);if (status != V1_0::Status::SUCCESS) {goto error;}status = setupFunctions(functions, callback, timeout);if (status != V1_0::Status::SUCCESS) {goto error;}ALOGI("Usb Gadget setcurrent functions called successfully");return Void();error:ALOGI("Usb Gadget setcurrent functions failed");if (callback == NULL) return Void();Return<void> ret = callback->setCurrentUsbFunctionsCb(functions, status);if (!ret.isOk())ALOGE("Error while calling setCurrentUsbFunctionsCb %s", ret.description().c_str());return Void();
}

hardware/interfaces/usb/gadget/1.2/default/lib/UsbGadgetUtils.cpp

Status addGenericAndroidFunctions(MonitorFfs* monitorFfs, uint64_t functions, bool* ffsEnabled,int* functionCount) {if (((functions & GadgetFunction::MTP) != 0)) {*ffsEnabled = true;ALOGI("setCurrentUsbFunctions mtp");if (!WriteStringToFile("1", DESC_USE_PATH)) return Status::ERROR;if (!monitorFfs->addInotifyFd("/dev/usb-ffs/mtp/")) return Status::ERROR;if (linkFunction("ffs.mtp", (*functionCount)++)) return Status::ERROR;// Add endpoints to be monitored.monitorFfs->addEndPoint("/dev/usb-ffs/mtp/ep1");monitorFfs->addEndPoint("/dev/usb-ffs/mtp/ep2");monitorFfs->addEndPoint("/dev/usb-ffs/mtp/ep3");} else if (((functions & GadgetFunction::PTP) != 0)) {*ffsEnabled = true;ALOGI("setCurrentUsbFunctions ptp");if (!WriteStringToFile("1", DESC_USE_PATH)) return Status::ERROR;if (!monitorFfs->addInotifyFd("/dev/usb-ffs/ptp/")) return Status::ERROR;if (linkFunction("ffs.ptp", (*functionCount)++)) return Status::ERROR;// Add endpoints to be monitored.monitorFfs->addEndPoint("/dev/usb-ffs/ptp/ep1");monitorFfs->addEndPoint("/dev/usb-ffs/ptp/ep2");monitorFfs->addEndPoint("/dev/usb-ffs/ptp/ep3");}if ((functions & GadgetFunction::MIDI) != 0) {ALOGI("setCurrentUsbFunctions MIDI");if (linkFunction("midi.gs5", (*functionCount)++)) return Status::ERROR;}if ((functions & GadgetFunction::ACCESSORY) != 0) {ALOGI("setCurrentUsbFunctions Accessory");if (linkFunction("accessory.gs2", (*functionCount)++)) return Status::ERROR;}if ((functions & GadgetFunction::AUDIO_SOURCE) != 0) {ALOGI("setCurrentUsbFunctions Audio Source");if (linkFunction("audio_source.gs3", (*functionCount)++)) return Status::ERROR;}if ((functions & GadgetFunction::RNDIS) != 0) {ALOGI("setCurrentUsbFunctions rndis");if (linkFunction("gsi.rndis", (*functionCount)++)) return Status::ERROR;std::string rndisFunction = GetProperty(kVendorRndisConfig, "");if (rndisFunction != "") {if (linkFunction(rndisFunction.c_str(), (*functionCount)++)) return Status::ERROR;} else {// link gsi.rndis for older pixel projectsif (linkFunction("gsi.rndis", (*functionCount)++)) return Status::ERROR;}}if ((functions & GadgetFunction::NCM) != 0) {ALOGI("setCurrentUsbFunctions ncm");if (linkFunction("ncm.gs6", (*functionCount)++)) return Status::ERROR;}return Status::SUCCESS;
}

了解 USB Gadget HAL API 架构
在这里插入图片描述

2.3 广播监听刷新

广播监听刷新 onUsbConnectionChanged > refresh
packages/apps/Settings/src/com/android/settings/connecteddevice/usb/UsbConnectionBroadcastReceiver.java
packages/apps/Settings/src/com/android/settings/connecteddevice/usb/UsbDetailsFragment.java
packages/apps/Settings/src/com/android/settings/connecteddevice/usb/UsbDetailsFunctionsController.java

/*** Interface definition for a callback to be invoked when usb connection is changed.*/
interface UsbConnectionListener {void onUsbConnectionChanged(boolean connected, long functions, int powerRole, int dataRole,boolean isUsbConfigured);
}
private UsbConnectionBroadcastReceiver.UsbConnectionListener mUsbConnectionListener =(connected, functions, powerRole, dataRole, isUsbFigured) -> {for (UsbDetailsController controller : mControllers) {controller.refresh(connected, functions, powerRole, dataRole);}};

3、日志开关

3.1 Evet日志

如:MetricsLogger.action(mContext, MetricsEvent.ACTION_USB_CONFIG_MTP);

frameworks/base/core/java/com/android/internal/logging/MetricsLogger.java
frameworks/base/core/java/android/metrics/LogMaker.java
frameworks/base/proto/src/metrics_constants/metrics_constants.proto

   // The view or control was activated.TYPE_ACTION = 4;// These values should never appear in log outputs - they are reserved for// internal platform metrics use.RESERVED_FOR_LOGBUILDER_CATEGORY = 757;RESERVED_FOR_LOGBUILDER_TYPE = 758;RESERVED_FOR_LOGBUILDER_SUBTYPE = 759;// ACTION: Usb config has been changed to charging// CATEGORY: SETTINGS// OS: PACTION_USB_CONFIG_CHARGING = 1275;// ACTION: Usb config has been changed to mtp (file transfer)// CATEGORY: SETTINGS// OS: PACTION_USB_CONFIG_MTP = 1276;// ACTION: Usb config has been changed to ptp (photo transfer)// CATEGORY: SETTINGS// OS: PACTION_USB_CONFIG_PTP = 1277;// ACTION: Usb config has been changed to rndis (usb tethering)// CATEGORY: SETTINGS// OS: PACTION_USB_CONFIG_RNDIS = 1278;// ACTION: Usb config has been changed to midi// CATEGORY: SETTINGS// OS: PACTION_USB_CONFIG_MIDI = 1279;// ACTION: Usb config has been changed to accessory// CATEGORY: SETTINGS// OS: PACTION_USB_CONFIG_ACCESSORY = 1280;

3.2 代码中日志开关

adb 打开:需要重启Settings进程

adb shell setprop log.tag.UsbFunctionsCtrl D
adb shell setprop log.tag.UsbBroadcastReceiver D

packages/apps/Settings/src/com/android/settings/connecteddevice/usb/UsbDetailsFunctionsController.java

private static final String TAG = "UsbFunctionsCtrl";
private static final boolean DEBUG = Log.isLoggable(TAG, Log.DEBUG);

3.3 关键日志

start u|SettingsActivity: Switching to|UsbFunctionsCtrl:|UsbDetailsFragment:|UsbBroadcastReceiver:|UsbDeviceManager:|sysui_multi_action: [757,.*,758,4]

android.hardware.usb.gadget@1.1-service-qti:|libusbconfigfs:

4、异常

symlink失败:"Cannot create symlink %s -> %s errno:%d"

hardware/interfaces/usb/gadget/1.2/default/lib/include/UsbGadgetCommon.h

#define GADGET_PATH "/config/usb_gadget/g1/"
#define PULLUP_PATH GADGET_PATH "UDC"
#define PERSISTENT_BOOT_MODE "ro.bootmode"
#define VENDOR_ID_PATH GADGET_PATH "idVendor"
#define PRODUCT_ID_PATH GADGET_PATH "idProduct"
#define DEVICE_CLASS_PATH GADGET_PATH "bDeviceClass"
#define DEVICE_SUB_CLASS_PATH GADGET_PATH "bDeviceSubClass"
#define DEVICE_PROTOCOL_PATH GADGET_PATH "bDeviceProtocol"
#define DESC_USE_PATH GADGET_PATH "os_desc/use"
#define OS_DESC_PATH GADGET_PATH "os_desc/b.1"
#define CONFIG_PATH GADGET_PATH "configs/b.1/"
#define FUNCTIONS_PATH GADGET_PATH "functions/"
#define FUNCTION_NAME "function"
#define FUNCTION_PATH CONFIG_PATH FUNCTION_NAME
#define RNDIS_PATH FUNCTIONS_PATH "gsi.rndis"

在这里插入图片描述
hardware/interfaces/usb/gadget/1.2/default/lib/UsbGadgetUtils.cpp

int linkFunction(const char* function, int index) {char functionPath[kMaxFilePathLength];char link[kMaxFilePathLength];sprintf(functionPath, "%s%s", FUNCTIONS_PATH, function);sprintf(link, "%s%d", FUNCTION_PATH, index);if (symlink(functionPath, link)) {ALOGE("Cannot create symlink %s -> %s errno:%d", link, functionPath, errno);return -1;}return 0;
}Status addGenericAndroidFunctions(MonitorFfs* monitorFfs, uint64_t functions, bool* ffsEnabled,int* functionCount) {if (((functions & GadgetFunction::MTP) != 0)) {*ffsEnabled = true;ALOGI("setCurrentUsbFunctions mtp");if (!WriteStringToFile("1", DESC_USE_PATH)) return Status::ERROR;if (!monitorFfs->addInotifyFd("/dev/usb-ffs/mtp/")) return Status::ERROR;if (linkFunction("ffs.mtp", (*functionCount)++)) return Status::ERROR;// Add endpoints to be monitored.monitorFfs->addEndPoint("/dev/usb-ffs/mtp/ep1");monitorFfs->addEndPoint("/dev/usb-ffs/mtp/ep2");monitorFfs->addEndPoint("/dev/usb-ffs/mtp/ep3");} else if (((functions & GadgetFunction::PTP) != 0)) {*ffsEnabled = true;ALOGI("setCurrentUsbFunctions ptp");if (!WriteStringToFile("1", DESC_USE_PATH)) return Status::ERROR;if (!monitorFfs->addInotifyFd("/dev/usb-ffs/ptp/")) return Status::ERROR;if (linkFunction("ffs.ptp", (*functionCount)++)) return Status::ERROR;// Add endpoints to be monitored.monitorFfs->addEndPoint("/dev/usb-ffs/ptp/ep1");monitorFfs->addEndPoint("/dev/usb-ffs/ptp/ep2");monitorFfs->addEndPoint("/dev/usb-ffs/ptp/ep3");}if ((functions & GadgetFunction::MIDI) != 0) {ALOGI("setCurrentUsbFunctions MIDI");if (linkFunction("midi.gs5", (*functionCount)++)) return Status::ERROR;}if ((functions & GadgetFunction::ACCESSORY) != 0) {ALOGI("setCurrentUsbFunctions Accessory");if (linkFunction("accessory.gs2", (*functionCount)++)) return Status::ERROR;}if ((functions & GadgetFunction::AUDIO_SOURCE) != 0) {ALOGI("setCurrentUsbFunctions Audio Source");if (linkFunction("audio_source.gs3", (*functionCount)++)) return Status::ERROR;}if ((functions & GadgetFunction::RNDIS) != 0) {ALOGI("setCurrentUsbFunctions rndis");if (linkFunction("gsi.rndis", (*functionCount)++)) return Status::ERROR;std::string rndisFunction = GetProperty(kVendorRndisConfig, "");if (rndisFunction != "") {if (linkFunction(rndisFunction.c_str(), (*functionCount)++)) return Status::ERROR;} else {// link gsi.rndis for older pixel projectsif (linkFunction("gsi.rndis", (*functionCount)++)) return Status::ERROR;}}if ((functions & GadgetFunction::NCM) != 0) {ALOGI("setCurrentUsbFunctions ncm");if (linkFunction("ncm.gs6", (*functionCount)++)) return Status::ERROR;}return Status::SUCCESS;
}

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

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

相关文章

Java 设计模式——享元模式

目录 1.概述2.结构3.实现3.1.抽象享元3.2.具体享元3.3.享元工厂3.4.测试 4.优缺点5.使用场景6.JDK 源码解析——Integer 类 1.概述 &#xff08;1&#xff09;享元模式 (Flyweight Pattern) 是一种结构型设计模式&#xff0c;主要通过共享对象来减少系统中的对象数量&#xff…

MUYUCMS v2.1:一款开源、轻量级的内容管理系统基于Thinkphp开发

MuYuCMS&#xff1a;一款基于Thinkphp开发的轻量级开源内容管理系统&#xff0c;为企业、个人站长提供快速建站解决方案。它具有以下的环境要求&#xff1a; 支持系统&#xff1a;Windows/Linux/Mac WEB服务器&#xff1a;Apache/Nginx/ISS PHP版本&#xff1a;php > 5.6 (…

达梦数据库答案

1、 创建数据库实例&#xff0c;到/dm8/data下&#xff0c;数据库名&#xff1a;DEMO&#xff0c;实例名DEMOSERVER&#xff08;10分&#xff09; [dmdbadmServer ~]$ cd /dm8/tool [dmdbadmServer tool]$ ./dbca.sh1、 簇大小32&#xff0c;页大小16&#xff0c;登录密码&…

挑战100天 AI In LeetCode Day08(热题+面试经典150题)

挑战100天 AI In LeetCode Day08&#xff08;热题面试经典150题&#xff09; 一、LeetCode介绍二、LeetCode 热题 HOT 100-102.1 题目2.2 题解 三、面试经典 150 题-103.1 题目3.2 题解 一、LeetCode介绍 LeetCode是一个在线编程网站&#xff0c;提供各种算法和数据结构的题目&…

tcpdump抓包的字节数量与ethtool统计数据不同的原因

情况介绍 在进行RDMA抓包流量分析时&#xff0c;我使用ethtool工具统计了RDMA网卡的流量发送数据数量&#xff0c;然后使用tcpdump进行抓包。 经过分析发现&#xff0c;tcpdump得到的数据数量总是大于ethtool得到的数据数量&#xff0c;而且每个数据包会多出4个字节。 分析 …

eclipse安装lombok插件

lombok插件下载:Download 下载完成&#xff0c;lombok.jar放到eclipse根目录&#xff0c;双击jar运行 运行界面&#xff0c;点击Install安装。 安装完成&#xff0c;重启IDE&#xff0c;rebuild 项目。 rebuild 项目

【分享】Excel“只读方式”的两种模式

查阅Excel表格的时候&#xff0c;担心不小心修改了内容&#xff0c;可以给Excel设置以“只读方式”打开&#xff0c;这样就算修改了内容也不能直接保存表格。Excel表格可以设置两种“只读方式”&#xff0c;一起来看看吧&#xff01; “只读方式” 1&#xff1a; 打开Excel表…

cgo与调用c的回调函数指针

cgo直接调用函数&#xff0c;使用基本数据类型非常简单&#xff0c;包括一些结构体也比较简单&#xff0c;嵌套的稍微复杂些&#xff0c;但也可以&#xff0c;但有的时候&#xff0c;cgo调用c函数&#xff0c;会需要传递一个回调函数的指针&#xff0c;这时候就比较复杂了&…

基于PHP的设云尘资讯网站设计与实现

项目描述 临近学期结束&#xff0c;还是毕业设计&#xff0c;你还在做java程序网络编程&#xff0c;期末作业&#xff0c;老师的作业要求觉得大了吗?不知道毕业设计该怎么办?网页功能的数量是否太多?没有合适的类型或系统?等等。你想解决的问题&#xff0c;今天给大家介绍…

工作记录--(用HTTPS,为啥能被查出浏览记录?如何解决?)---每天学习多一点

由于网络通信有很多层&#xff0c;即使加密通信&#xff0c;仍有很多途径暴露你的访问地址&#xff0c;比如&#xff1a; DNS查询&#xff1a;通常DNS查询是不会加密的&#xff0c;所以&#xff0c;能看到你DNS查询的观察者&#xff08;比如运营商&#xff09;是可以推断出访问…

平安人寿基于 Apache Doris 统一 OLAP 技术栈实践

导读&#xff1a;平安人寿作为保险行业领军企业&#xff0c;坚持技术创新&#xff0c;以数据业务双轮驱动的理念和更加开放的思路来应对不断增长的数据分析和应用需求&#xff1b;以深挖数据价值、保障业务用数效率为目标持续升级大数据产品体系。自 2022 年起平安人寿开始引入…

初始MySQL(五)(自我复制数据,合并查询,外连接,MySQL约束:主键,not null,unique,foreign key)

目录 表复制 自我复制数据(蠕虫复制) 合并查询 union all(不会去重) union(会自动去重) MySQL表的外连接 左连接 右连接 MySQL的约束 主键 not null unique(唯一) foreign key(外键) 表复制 自我复制数据(蠕虫复制) #为了对某个sql语句进行效率测试,我们需要海量…

No195.精选前端面试题,享受每天的挑战和学习

🤍 前端开发工程师(主业)、技术博主(副业)、已过CET6 🍨 阿珊和她的猫_CSDN个人主页 🕠 牛客高级专题作者、在牛客打造高质量专栏《前端面试必备》 🍚 蓝桥云课签约作者、已在蓝桥云课上架的前后端实战课程《Vue.js 和 Egg.js 开发企业级健康管理项目》、《带你从入…

【华为OD题库-007】代表团坐车-Java

题目 某组织举行会议&#xff0c;来了多个代表团同时到达&#xff0c;接待处只有一辆汽车&#xff0c;可以同时接待多个代表团&#xff0c;为了提高车辆利用率&#xff0c;请帮接待员计算可以坐满车的接待方案&#xff0c;输出方案数量。 约束: 1.一个团只能上一辆车&#xff0…

监控和数据采集软件架构和详细设计

介绍 监控和数据采集软件通过提供实时监控、数据收集和分析功能&#xff0c;在各个行业中发挥着至关重要的作用。这些软件应用程序可帮助企业收集有价值的见解、优化流程并做出明智的决策。在本文中&#xff0c;我们将探讨监测和数据采集软件的软件架构、编程技术和详细设计规范…

【STM32 CAN】STM32G47x 单片机FDCAN作为普通CAN外设使用教程

STM32G47x 单片机FDCAN作为普通CAN外设使用教程 控制器局域网总线&#xff08;CAN&#xff0c;Controller Area Network&#xff09;是一种用于实时应用的串行通讯协议总线&#xff0c;它可以使用双绞线来传输信号&#xff0c;是世界上应用最广泛的现场总线之一。CAN协议用于汽…

拓扑排序软件设计——ToplogicalSort_app(含有源码、需求分析、可行性分析、概要设计、用户使用手册)

拓扑排序软件设计 前言1. 需求分析2. 可行性分析2.1 简介2.2 技术可行性分析2.2.1 技术实现方案2.2.2 开发人员技能要求2.2.3 可行性 2.3 操作可行性分析2.4 结论 3. 项目报告3.1 修订历史记录3.2 软硬件环境3.3 需求分析3.4 详细设计3.4.1 类设计3.4.2 核心流程描述3.4.3 核心…

Spring Cloud LoadBalancer基础知识

LoadBalancer 概念常见的负载均衡策略使用随机选择的负载均衡策略创建随机选择负载均衡器配置 Nacos 权重负载均衡器创建 Nacos 负载均衡器配置 自定义负载均衡器(根据IP哈希策略选择)创建自定义负载均衡器封装自定义负载均衡器配置 缓存 概念 LoadBalancer(负载均衡器)是一种…

2023年数维杯国际大学生数学建模挑战赛

当大家面临着复杂的数学建模问题时&#xff0c;你是否曾经感到茫然无措&#xff1f;作为2022年美国大学生数学建模比赛的O奖得主&#xff0c;我为大家提供了一套优秀的解题思路&#xff0c;让你轻松应对各种难题。 cs数模团队在数维杯前为大家提供了许多资料的内容呀&#xff0…

Redis应用之二分布式锁2

一、前言 前一篇 Redis应用之二分布式锁 我们介绍了使用SETNX来实现分布式锁&#xff0c;并且还遗留了一个Bug&#xff0c;今天我们对代码进行优化&#xff0c;然后介绍一下Redisson以及数据库的乐观锁悲观锁怎么用。 二、SetNX分布式锁优化后代码 RedisService.java Inven…