res_config_settings_views.xml 详解

本文详细介绍了Odoo中res_config_settings_views.xml文件的作用,它用于定义自定义配置项在设置界面的显示方式。内容涵盖视图记录、模型、继承以及视图布局的XML描述。通过在__manifest__.py文件中引用,实现UI元素的加载和显示。重点讲解了视图的继承机制和XPath表达式的使用,用于在原有视图基础上进行修改和增强。示例代码展示了如何在页面中插入新的表单内容。

res_config_settings_views.xml 文件位于Views文件夹下。
在这里插入图片描述
这个文件主要用于定义我们前面自定义的配置项在ODOO 设置中的显示方式。
在这里插入图片描述
要使这个文件起作用还需要在__manifest__.py文件中,进行引用。
在这里插入图片描述
接下来我们看一下主要的代码:

<record id="res_config_settings_view_form" model="ir.ui.view">

一个view记录是一个ir.ui.view模型的一条数据记录,用户界面的每个组件都以记录的形式存储在数据库中,模块从XML文件加载相应的数据时会向数据库添加UI元素,然后odoo从数据库读取UI元素进行显示。
定义出的视图作用是将模型中的记录数据展示出来。每一种视图类型代表一个可视化模式。可以通过视图类别显示出通用的视图界面,也可以指定对应的记录id访问特定的记录。对于一般的请求,将使用正确且最低优先级的视图,每种类型最低优先级的视图是该类型的默认视图。视图类型隐藏在arch的field标签属性中。 view视图定义在XML文件中,在arch字段中必须定义 type="xml"属性。

<field name="name">res.config.settings.view.form.inherit.aliyundrive</field>

field name属性值为name表示页面的名称

<field name="model">res.config.settings</field>

field name属性值为model表示页面的名称,表示该视图关联的模型,对应到数据库就是数据库中的某张表,模型中放的字段就是对应到数据库表中的字段。

<field name="inherit_id" ref="base_setup.res_config_settings_view_form"/>

field name属性值为inherit_id表示通过继承的方式来改写已经存在的view,ref指向要改写的view。

<field name="arch" type="xml">

field name属性值为arch表示视图布局的描述,采用的是xml来展现视图
该字段中的属性值关联的是模型中的字段,体现在页面中就是需要填写的表单内容。

<xpath expr="//div[@name='integration']" position="inside">

在arch里用xpath定位改写的元素,找到名为integration的div,在内部结尾插入代码。

  • 注意找到的元素必须是一个,如果定位出多个元素或者是空,都会报错。
  • expr Xpath表达式用来选择父视图中的某个元素,如果没找到或找到多个元素会抛出一个异常

position定位有如下选择

  • inside 在内部结尾插入元素
  • replace 替换元素
  • before 在之前插入元素
  • after 在其后插入元素
  • attributes 修改xml的属性

接下来就是一些CSS代码,这里不再赘述。
在这里插入图片描述
​演示:

https://demo.tderp.com

用户名:admin
密码:admin

2025-09-03 20:41:06.091 718-744 AppHibernationService system_server E Package com.example.myapplication is not installed for user 0 2025-09-03 20:41:06.091 718-744 AppHibernationService system_server E Package com.example.myapplication is not installed for any user 2025-09-03 20:41:06.091 718-744 AppHibernationService system_server E Package com.example.myapplication is not installed for user 0 2025-09-03 20:41:06.091 718-744 AppHibernationService system_server E Package com.example.myapplication is not installed for any user 2025-09-03 20:54:02.033 718-858 InputDispatcher system_server E channel '6a720b8 com.example.myapplication/com.example.myapplication.MainActivity' ~ Channel is unrecoverably broken and will be disposed! 2025-09-03 21:00:20.868 718-858 InputDispatcher system_server E channel '207de1e com.example.myapplication/com.example.myapplication.MainActivity' ~ Channel is unrecoverably broken and will be disposed! 2025-09-03 21:05:38.221 718-858 InputDispatcher system_server E channel 'c1f632b com.example.myapplication/com.example.myapplication.MainActivity' ~ Channel is unrecoverably broken and will be disposed! 2025-09-07 20:44:52.229 1830-1942 .apps.wellbeing com.google.android.apps.wellbeing E Failed to open APK '/data/app/~~dJ88ZxVdANwbzdqaLfO8BA==/com.example.myapplication-Oci8KYGLbCHl-jUio4U6EQ==/base.apk': I/O error 2025-09-07 20:44:52.232 1830-1942 .apps.wellbeing com.google.android.apps.wellbeing E Failed to open APK '/data/app/~~dJ88ZxVdANwbzdqaLfO8BA==/com.example.myapplication-Oci8KYGLbCHl-jUio4U6EQ==/base.apk': I/O error 2025-09-07 20:44:52.232 1830-1942 ResourcesManager com.google.android.apps.wellbeing E failed to add asset path '/data/app/~~dJ88ZxVdANwbzdqaLfO8BA==/com.example.myapplication-Oci8KYGLbCHl-jUio4U6EQ==/base.apk' java.io.IOException: Failed to load asset path /data/app/~~dJ88ZxVdANwbzdqaLfO8BA==/com.example.myapplication-Oci8KYGLbCHl-jUio4U6EQ==/base.apk at android.content.res.ApkAssets.nativeLoad(Native Method) at android.content.res.ApkAssets.<init>(ApkAssets.java:322) at android.content.res.ApkAssets.loadFromPath(ApkAssets.java:171) at android.app.ResourcesManager.loadApkAssets(ResourcesManager.java:618) at android.app.ResourcesManager$ApkAssetsSupplier.load(ResourcesManager.java:287) at android.app.ResourcesManager.createAssetManager(ResourcesManager.java:714) at android.app.ResourcesManager.createResourcesImpl(ResourcesManager.java:801) at android.app.ResourcesManager.findOrCreateResourcesImplForKeyLocked(ResourcesManager.java:854) at android.app.ResourcesManager.createResources(ResourcesManager.java:1199) at android.app.ResourcesManager.getResources(ResourcesManager.java:1301) at android.app.ActivityThread.getTopLevelResources(ActivityThread.java:2979) at android.app.ApplicationPackageManager.getResourcesForApplication(ApplicationPackageManager.java:2154) at android.app.ApplicationPackageManager.getResourcesForApplication(ApplicationPackageManager.java:2140) at android.app.ApplicationPackageManager.getText(ApplicationPackageManager.java:2481) at android.content.pm.PackageItemInfo.loadUnsafeLabel(PackageItemInfo.java:237) at android.content.pm.PackageItemInfo.loadLabel(PackageItemInfo.java:226) at android.app.ApplicationPackageManager.getApplicationLabel(ApplicationPackageManager.java:2526) at cut.c(PG:38) at cfv.apply(PG:391) at e$$ExternalSyntheticApiModelOutline1.m(D8$$SyntheticClass:47) at lcx.accept(PG:44) at j$.util.stream.M0.accept(SourceFile:3) at j$.util.D.x(SourceFile:24) at j$.util.T.forEachRemaining(SourceFile:24) at j$.util.stream.b.c(SourceFile:21) at j$.util.stream.b.y(SourceFile:8) at j$.util.stream.F.b(SourceFile:5) at j$.util.stream.b.f(SourceFile:35) at j$.util.stream.c1.collect(SourceFile:83) at bva.a(PG:99) at kbp.a(PG:301) at kbp.a(PG:38) at ltp.a(PG:3) at lsv.run(PG:19) at ltr.run(PG:5) at lrz.run(PG:17) at idd.run(PG:3) at loz.run(PG:50) at hsu.run(PG:768) at java.lang.Thread.run(Thread.java:1119) at ieo.run(PG:63) 2025-09-07 20:47:00.731 718-858 InputDispatcher system_server E channel 'd671972 com.example.myapplication/com.example.myapplication.MainActivity' ~ Channel is unrecoverably broken and will be disposed! 2025-09-07 20:52:16.888 718-858 InputDispatcher system_server E channel '54ceef5 com.example.myapplication/com.example.myapplication.MainActivity' ~ Channel is unrecoverably broken and will be disposed! 2025-09-10 08:19:19.039 718-858 InputDispatcher system_server E channel 'da9443c com.example.myapplication/com.example.myapplication.MainActivity' ~ Channel is unrecoverably broken and will be disposed! 2025-09-10 08:28:44.520 718-858 InputDispatcher system_server E channel 'fb3dc4e com.example.myapplication/com.example.myapplication.MainActivity' ~ Channel is unrecoverably broken and will be disposed! 2025-09-10 08:31:15.953 718-858 InputDispatcher system_server E channel '50c58e2 com.example.myapplication/com.example.myapplication.MainActivity' ~ Channel is unrecoverably broken and will be disposed! 2025-09-10 09:08:31.738 718-1763 TransitionController system_server E Set visible without transition ActivityRecord{10540855 u0 com.example.myapplication/.MainActivity t25} playing=true caller=com.android.server.wm.TaskFragment.resumeTopActivity:1629 2025-09-10 09:46:26.507 718-858 InputDispatcher system_server E channel 'dc063cb com.example.myapplication/com.example.myapplication.MainActivity' ~ Channel is unrecoverably broken and will be disposed! 2025-09-17 08:57:50.144 718-858 InputDispatcher system_server E channel '1f6629d com.example.myapplication/com.example.myapplication.MainActivity' ~ Channel is unrecoverably broken and will be disposed! 2025-09-17 09:00:15.359 718-858 InputDispatcher system_server E channel 'b8ebe12 com.example.myapplication/com.example.myapplication.MainActivity' ~ Channel is unrecoverably broken and will be disposed! 2025-09-17 09:08:43.780 718-858 InputDispatcher system_server E channel 'b3a4af9 com.example.myapplication/com.example.myapplication.MainActivity' ~ Channel is unrecoverably broken and will be disposed! 2025-09-17 09:09:46.460 718-858 InputDispatcher system_server E channel 'e65939a com.example.myapplication/com.example.myapplication.MainActivity' ~ Channel is unrecoverably broken and will be disposed! 2025-09-17 09:10:18.549 718-858 InputDispatcher system_server E channel '97c3cce com.example.myapplication/com.example.myapplication.MainActivity' ~ Channel is unrecoverably broken and will be disposed! 2025-09-17 09:10:20.415 718-858 InputDispatcher system_server E channel '4a4890c com.example.myapplication/com.example.myapplication.MainActivity' ~ Channel is unrecoverably broken and will be disposed! 2025-09-17 09:15:34.082 718-858 InputDispatcher system_server E channel '5112bb7 com.example.myapplication/com.example.myapplication.MainActivity' ~ Channel is unrecoverably broken and will be disposed! 2025-09-17 09:20:13.015 718-858 InputDispatcher system_server E channel 'd3fcd81 com.example.myapplication/com.example.myapplication.MainActivity' ~ Channel is unrecoverably broken and will be disposed! 2025-09-17 09:21:45.786 718-858 InputDispatcher system_server E channel '83178b7 com.example.myapplication/com.example.myapplication.MainActivity' ~ Channel is unrecoverably broken and will be disposed! 2025-09-17 09:40:09.328 718-858 InputDispatcher system_server E channel 'b88d2d6 com.example.myapplication/com.example.myapplication.MainActivity' ~ Channel is unrecoverably broken and will be disposed! 2025-09-22 17:06:13.033 13959-13959 TransactionExecutor pid-13959 E Failed to execute the transaction: tId:-782804407 ClientTransaction{ tId:-782804407 transactionItems=[ tId:-782804407 LaunchActivityItem{activityToken=android.os.BinderProxy@be43358,intent=Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10000000 xflg=0x4 cmp=com.example.myapplication/.MainActivity },ident=184265485,info=ActivityInfo{a09354c com.example.myapplication.MainActivity},curConfig={1.0 310mcc260mnc [en_US] ldltr sw411dp w411dp h914dp 420dpi nrml long port finger qwerty/v/v dpad/v winConfig={ mBounds=Rect(0, 0 - 1080, 2400) mAppBounds=Rect(0, 0 - 1080, 2400) mMaxBounds=Rect(0, 0 - 1080, 2400) mDisplayRotation=ROTATION_0 mWindowingMode=fullscreen mActivityType=undefined mAlwaysOnTop=undefined mRotation=ROTATION_0} as.2 s.535 fontWeightAdjustment=0},overrideConfig={1.0 310mcc260mnc [en_US] ldltr sw411dp w411dp h914dp 420dpi nrml long port finger qwerty/v/v dpad/v winConfig={ mBounds=Rect(0, 0 - 1080, 2400) mAppBounds=Rect(0, 0 - 1080, 2400) mMaxBounds=Rect(0, 0 - 1080, 2400) mDisplayRotation=ROTATION_0 mWindowingMode=fullscreen mActivityType=standard mAlwaysOnTop=undefined mRotation=ROTATION_0} as.2 s.2 fontWeightAdjustment=0},deviceId=0,referrer=com.android.shell,procState=2,state=null,persistentState=null,pendingResults=null,pendingNewIntents=null,sceneTransitionInfo=null,profilerInfo=null,assistToken=android.os.BinderProxy@456b8d9,shareableActivityToken=android.os.BinderProxy@615029e,activityWindowInfo=ActivityWindowInfo{isEmbedded=false, taskBounds=Rect(0, 0 - 1080, 2400), taskFragmentBounds=Rect(0, 0 - 1080, 2400)}} tId:-782804407 ResumeActivityItem{mActivityToken=android.os.BinderProxy@be43358,procState=-1,isForward=true,shouldSendCompatFakeFocus=false} tId:-782804407 Target activity: com.example.myapplication.MainActivity tId:-782804407 ] tId:-782804407 } 2025-09-22 17:06:13.036 13959-13959 AndroidRuntime pid-13959 E FATAL EXCEPTION: main Process: com.example.myapplication, PID: 13959 java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.myapplication/com.example.myapplication.MainActivity}: java.lang.ClassCastException: androidx.appcompat.widget.AppCompatImageButton cannot be cast to android.widget.Button at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:4280) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:4467) at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:222) at android.app.servertransaction.TransactionExecutor.executeNonLifecycleItem(TransactionExecutor.java:133) at android.app.servertransaction.TransactionExecutor.executeTransactionItems(TransactionExecutor.java:103) at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:80) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2823) at android.os.Handler.dispatchMessage(Handler.java:110) at android.os.Looper.loopOnce(Looper.java:248) at android.os.Looper.loop(Looper.java:338) at android.app.ActivityThread.main(ActivityThread.java:9067) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:593) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:932) Caused by: java.lang.ClassCastException: androidx.appcompat.widget.AppCompatImageButton cannot be cast to android.widget.Button at com.example.myapplication.MainActivity.setButtonListeners(MainActivity.java:107) at com.example.myapplication.MainActivity.onCreate(MainActivity.java:28) at android.app.Activity.performCreate(Activity.java:9155) at android.app.Activity.performCreate(Activity.java:9133) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1521) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:4262) ... 13 more 2025-09-22 17:08:39.215 14080-14080 TransactionExecutor pid-14080 E Failed to execute the transaction: tId:1940201582 ClientTransaction{ tId:1940201582 transactionItems=[ tId:1940201582 LaunchActivityItem{activityToken=android.os.BinderProxy@7091517,intent=Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10000000 xflg=0x4 cmp=com.example.myapplication/.MainActivity },ident=36553713,info=ActivityInfo{8c6a69b com.example.myapplication.MainActivity},curConfig={1.0 310mcc260mnc [en_US] ldltr sw411dp w411dp h914dp 420dpi nrml long port finger qwerty/v/v dpad/v winConfig={ mBounds=Rect(0, 0 - 1080, 2400) mAppBounds=Rect(0, 0 - 1080, 2400) mMaxBounds=Rect(0, 0 - 1080, 2400) mDisplayRotation=ROTATION_0 mWindowingMode=fullscreen mActivityType=undefined mAlwaysOnTop=undefined mRotation=ROTATION_0} as.2 s.536 fontWeightAdjustment=0},overrideConfig={1.0 310mcc260mnc [en_US] ldltr sw411dp w411dp h914dp 420dpi nrml long port finger qwerty/v/v dpad/v winConfig={ mBounds=Rect(0, 0 - 1080, 2400) mAppBounds=Rect(0, 0 - 1080, 2400) mMaxBounds=Rect(0, 0 - 1080, 2400) mDisplayRotation=ROTATION_0 mWindowingMode=fullscreen mActivityType=standard mAlwaysOnTop=undefined mRotation=ROTATION_0} as.2 s.2 fontWeightAdjustment=0},deviceId=0,referrer=com.android.shell,procState=2,state=null,persistentState=null,pendingResults=null,pendingNewIntents=null,sceneTransitionInfo=null,profilerInfo=null,assistToken=android.os.BinderProxy@a09354c,shareableActivityToken=android.os.BinderProxy@8f10995,activityWindowInfo=ActivityWindowInfo{isEmbedded=false, taskBounds=Rect(0, 0 - 1080, 2400), taskFragmentBounds=Rect(0, 0 - 1080, 2400)}} tId:1940201582 ResumeActivityItem{mActivityToken=android.os.BinderProxy@7091517,procState=-1,isForward=true,shouldSendCompatFakeFocus=false} tId:1940201582 Target activity: com.example.myapplication.MainActivity tId:1940201582 ] tId:1940201582 } 2025-09-22 17:08:39.218 14080-14080 AndroidRuntime pid-14080 E FATAL EXCEPTION: main Process: com.example.myapplication, PID: 14080 java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.myapplication/com.example.myapplication.MainActivity}: java.lang.ClassCastException: androidx.appcompat.widget.AppCompatImageButton cannot be cast to android.widget.Button at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:4280) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:4467) at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:222) at android.app.servertransaction.TransactionExecutor.executeNonLifecycleItem(TransactionExecutor.java:133) at android.app.servertransaction.TransactionExecutor.executeTransactionItems(TransactionExecutor.java:103) at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:80) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2823) at android.os.Handler.dispatchMessage(Handler.java:110) at android.os.Looper.loopOnce(Looper.java:248) at android.os.Looper.loop(Looper.java:338) at android.app.ActivityThread.main(ActivityThread.java:9067) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:593) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:932) Caused by: java.lang.ClassCastException: androidx.appcompat.widget.AppCompatImageButton cannot be cast to android.widget.Button at com.example.myapplication.MainActivity.setButtonListeners(MainActivity.java:107) at com.example.myapplication.MainActivity.onCreate(MainActivity.java:28) at android.app.Activity.performCreate(Activity.java:9155) at android.app.Activity.performCreate(Activity.java:9133) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1521) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:4262) ... 13 more 2025-09-22 17:16:44.788 14174-14174 AndroidRuntime pid-14174 E FATAL EXCEPTION: main Process: com.example.myapplication, PID: 14174 java.lang.ClassCastException: androidx.appcompat.widget.AppCompatImageButton cannot be cast to android.widget.TextView at com.example.myapplication.MainActivity.lambda$setButtonListeners$0$com-example-myapplication-MainActivity(MainActivity.java:41) at com.example.myapplication.MainActivity$$ExternalSyntheticLambda0.onClick(D8$$SyntheticClass:0) at android.view.View.performClick(View.java:8083) at android.view.View.performClickInternal(View.java:8060) at android.view.View.-$$Nest$mperformClickInternal(Unknown Source:0) at android.view.View$PerformClick.run(View.java:31549) at android.os.Handler.handleCallback(Handler.java:995) at android.os.Handler.dispatchMessage(Handler.java:103) at android.os.Looper.loopOnce(Looper.java:248) at android.os.Looper.loop(Looper.java:338) at android.app.ActivityThread.main(ActivityThread.java:9067) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:593) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:932) 2025-09-22 17:16:44.809 718-858 InputDispatcher system_server E channel '15505d9 com.example.myapplication/com.example.myapplication.MainActivity' ~ Channel is unrecoverably broken and will be disposed! 2025-09-22 17:23:26.582 718-858 InputDispatcher system_server E channel '7ce91bf com.example.myapplication/com.example.myapplication.MainActivity' ~ Channel is unrecoverably broken and will be disposed! 2025-09-22 17:23:49.591 14368-14368 AndroidRuntime pid-14368 E FATAL EXCEPTION: main Process: com.example.myapplication, PID: 14368 java.lang.ClassCastException: androidx.appcompat.widget.AppCompatImageButton cannot be cast to android.widget.TextView at com.example.myapplication.MainActivity.lambda$setButtonListeners$0$com-example-myapplication-MainActivity(MainActivity.java:41) at com.example.myapplication.MainActivity$$ExternalSyntheticLambda0.onClick(D8$$SyntheticClass:0) at android.view.View.performClick(View.java:8083) at android.view.View.performClickInternal(View.java:8060) at android.view.View.-$$Nest$mperformClickInternal(Unknown Source:0) at android.view.View$PerformClick.run(View.java:31549) at android.os.Handler.handleCallback(Handler.java:995) at android.os.Handler.dispatchMessage(Handler.java:103) at android.os.Looper.loopOnce(Looper.java:248) at android.os.Looper.loop(Looper.java:338) at android.app.ActivityThread.main(ActivityThread.java:9067) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:593) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:932) 2025-09-22 17:23:49.608 718-858 InputDispatcher system_server E channel '9cce75c com.example.myapplication/com.example.myapplication.MainActivity' ~ Channel is unrecoverably broken and will be disposed! 2025-09-22 17:32:56.477 14730-14730 e.myapplication com.example.myapplication I Late-enabling -Xcheck:jni 2025-09-22 17:32:56.504 14730-14730 e.myapplication com.example.myapplication I Using CollectorTypeCMC GC. 2025-09-22 17:32:56.505 14730-14730 e.myapplication com.example.myapplication W Unexpected CPU variant for x86: x86_64. Known variants: atom, sandybridge, silvermont, goldmont, goldmont-plus, goldmont-without-sha-xsaves, tremont, kabylake, alderlake, default 2025-09-22 17:32:56.517 14730-14730 nativeloader com.example.myapplication D Load libframework-connectivity-tiramisu-jni.so using APEX ns com_android_tethering for caller /apex/com.android.tethering/javalib/framework-connectivity-t.jar: ok 2025-09-22 17:32:56.731 14730-14730 nativeloader com.example.myapplication D Configuring clns-9 for other apk /data/app/~~BU8Zpa-Ptb6zWCD1jUuDVQ==/com.example.myapplication-bvhvD7PKJdnssUQso6AYEw==/base.apk. target_sdk_version=36, uses_libraries=, library_path=/data/app/~~BU8Zpa-Ptb6zWCD1jUuDVQ==/com.example.myapplication-bvhvD7PKJdnssUQso6AYEw==/lib/x86_64:/data/app/~~BU8Zpa-Ptb6zWCD1jUuDVQ==/com.example.myapplication-bvhvD7PKJdnssUQso6AYEw==/base.apk!/lib/x86_64, permitted_path=/data:/mnt/expand:/data/user/0/com.example.myapplication 2025-09-22 17:32:56.737 14730-14730 e.myapplication com.example.myapplication I AssetManager2(0x79d591a4c758) locale list changing from [] to [en-US] 2025-09-22 17:32:56.744 14730-14730 GraphicsEnvironment com.example.myapplication V Currently set values for: 2025-09-22 17:32:56.744 14730-14730 GraphicsEnvironment com.example.myapplication V angle_gl_driver_selection_pkgs=[] 2025-09-22 17:32:56.744 14730-14730 GraphicsEnvironment com.example.myapplication V angle_gl_driver_selection_values=[] 2025-09-22 17:32:56.744 14730-14730 GraphicsEnvironment com.example.myapplication V com.example.myapplication is not listed in per-application setting 2025-09-22 17:32:56.744 14730-14730 GraphicsEnvironment com.example.myapplication V ANGLE allowlist from config: com.dreamgames.royalmatch com.dts.freefiremax com.dxx.firenow com.gramgames.mergedragons com.ludo.king com.mojang.minecraftpe com.my.defense com.nintendo.zaka com.os.airforce com.playrix.fishdomdd.gplay io.teslatech.callbreak jp.konami.prospia net.peakgames.toonblast 2025-09-22 17:32:56.744 14730-14730 GraphicsEnvironment com.example.myapplication V com.example.myapplication is not listed in ANGLE allowlist or settings, returning default 2025-09-22 17:32:56.745 14730-14730 GraphicsEnvironment com.example.myapplication V Neither updatable production driver nor prerelease driver is supported. 2025-09-22 17:32:56.799 14730-14766 DisplayManager com.example.myapplication I Choreographer implicitly registered for the refresh rate. 2025-09-22 17:32:56.802 14730-14730 e.myapplication com.example.myapplication I AssetManager2(0x79d591a488d8) locale list changing from [] to [en-US] 2025-09-22 17:32:56.834 14730-14766 EGL_emulation com.example.myapplication I Opening libGLESv1_CM_emulation.so 2025-09-22 17:32:56.835 14730-14766 EGL_emulation com.example.myapplication I Opening libGLESv2_emulation.so 2025-09-22 17:32:56.841 14730-14766 HWUI com.example.myapplication W Failed to choose config with EGL_SWAP_BEHAVIOR_PRESERVED, retrying without... 2025-09-22 17:32:56.841 14730-14766 HWUI com.example.myapplication W Failed to initialize 101010-2 format, error = EGL_SUCCESS 2025-09-22 17:32:56.881 14730-14730 AppCompatDelegate com.example.myapplication D Checking for metadata for AppLocalesMetadataHolderService : Service not found 2025-09-22 17:32:56.883 14730-14730 e.myapplication com.example.myapplication I AssetManager2(0x79d591a4f638) locale list changing from [] to [en-US] 2025-09-22 17:32:56.894 14730-14730 ashmem com.example.myapplication E Pinning is deprecated since Android Q. Please use trim or other methods. 2025-09-22 17:32:56.978 14730-14730 e.myapplication com.example.myapplication I hiddenapi: Accessing hidden method Landroid/view/View;->computeFitSystemWindows(Landroid/graphics/Rect;Landroid/graphics/Rect;)Z (runtime_flags=0, domain=platform, api=unsupported) from Landroidx/appcompat/widget/ViewUtils; (domain=app) using reflection: allowed 2025-09-22 17:32:57.083 14730-14730 CompatChangeReporter com.example.myapplication D Compat change id reported: 377864165; UID 10217; state: ENABLED 2025-09-22 17:32:57.085 14730-14730 DesktopModeFlags com.example.myapplication D Toggle override initialized to: OVERRIDE_UNSET 2025-09-22 17:32:57.137 14730-14730 HWUI com.example.myapplication W Image decoding logging dropped! 2025-09-22 17:32:57.143 14730-14730 e.myapplication com.example.myapplication I hiddenapi: Accessing hidden method Landroid/view/ViewGroup;->makeOptionalFitsSystemWindows()V (runtime_flags=0, domain=platform, api=unsupported) from Landroidx/appcompat/widget/ViewUtils; (domain=app) using reflection: allowed 2025-09-22 17:32:57.205 14730-14730 HWUI com.example.myapplication W Unknown dataspace 0 2025-09-22 17:32:57.499 14730-14730 InsetsController com.example.myapplication D hide(ime(), fromIme=false) 2025-09-22 17:32:57.499 14730-14730 ImeTracker com.example.myapplication I com.example.myapplication:120293d6: onCancelled at PHASE_CLIENT_ALREADY_HIDDEN 2025-09-22 17:32:57.728 14730-14735 e.myapplication com.example.myapplication I Compiler allocated 5042KB to compile void android.view.ViewRootImpl.performTraversals() 2025-09-22 17:33:01.507 14730-14744 HWUI com.example.myapplication I Davey! duration=701ms; Flags=0, FrameTimelineVsyncId=339287, IntendedVsync=12434071552112, Vsync=12434071552112, InputEventId=0, HandleInputStart=12434073050000, AnimationStart=12434073070200, PerformTraversalsStart=12434073339500, DrawStart=12434073461500, FrameDeadline=12434104885444, FrameStartTime=12434073038200, FrameInterval=16666666, WorkloadTarget=16666666, SyncQueued=12434073835100, SyncStart=12434073973100, IssueDrawCommandsStart=12434074070700, SwapBuffers=12434077768700, FrameCompleted=12434772941900, DequeueBufferDuration=51900, QueueBufferDuration=249800, GpuCompleted=12434772941900, SwapBuffersCompleted=12434078695800, DisplayPresentTime=0, CommandSubmissionCompleted=12434077768700, 2025-09-22 17:33:01.516 14730-14730 Choreographer com.example.myapplication I Skipped 41 frames! The application may be doing too much work on its main thread. 2025-09-22 17:33:01.525 14730-14730 AssistStructure com.example.myapplication I Flattened final assist data: 3948 bytes, containing 1 windows, 27 views 2025-09-22 17:33:03.060 14730-14782 ProfileInstaller com.example.myapplication D Installing profile for com.example.myapplication 2025-09-22 17:34:16.254 718-858 InputDispatcher system_server E channel 'c4201b3 com.example.myapplication/com.example.myapplication.MainActivity' ~ Channel is unrecoverably broken and will be disposed! 2025-09-22 17:34:17.321 14830-14830 e.myapplication com.example.myapplication I Late-enabling -Xcheck:jni 2025-09-22 17:34:17.358 14830-14830 e.myapplication com.example.myapplication I Using CollectorTypeCMC GC. 2025-09-22 17:34:17.359 14830-14830 e.myapplication com.example.myapplication W Unexpected CPU variant for x86: x86_64. Known variants: atom, sandybridge, silvermont, goldmont, goldmont-plus, goldmont-without-sha-xsaves, tremont, kabylake, alderlake, default 2025-09-22 17:34:17.372 14830-14830 nativeloader com.example.myapplication D Load libframework-connectivity-tiramisu-jni.so using APEX ns com_android_tethering for caller /apex/com.android.tethering/javalib/framework-connectivity-t.jar: ok 2025-09-22 17:34:17.419 14830-14830 nativeloader com.example.myapplication D Load /data/user/0/com.example.myapplication/code_cache/startup_agents/3fc68f17-agent.so using system ns (caller=<unknown>): ok 2025-09-22 17:34:17.415 14830-14830 re-initialized> com.example.myapplication W type=1400 audit(0.0:2120): avc: granted { execute } for path="/data/data/com.example.myapplication/code_cache/startup_agents/3fc68f17-agent.so" dev="dm-55" ino=352933 scontext=u:r:untrusted_app:s0:c217,c256,c512,c768 tcontext=u:object_r:app_data_file:s0:c217,c256,c512,c768 tclass=file app=com.example.myapplication 2025-09-22 17:34:17.427 14830-14830 e.myapplication com.example.myapplication W hiddenapi: DexFile /data/data/com.example.myapplication/code_cache/.studio/instruments-c9b0d10a.jar is in boot class path but is not in a known location 2025-09-22 17:34:17.587 14830-14830 e.myapplication com.example.myapplication W Redefining intrinsic method java.lang.Thread java.lang.Thread.currentThread(). This may cause the unexpected use of the original definition of java.lang.Thread java.lang.Thread.currentThread()in methods that have already been compiled. 2025-09-22 17:34:17.587 14830-14830 e.myapplication com.example.myapplication W Redefining intrinsic method boolean java.lang.Thread.interrupted(). This may cause the unexpected use of the original definition of boolean java.lang.Thread.interrupted()in methods that have already been compiled. 2025-09-22 17:34:17.743 14830-14830 nativeloader com.example.myapplication D Configuring clns-9 for other apk /data/app/~~BU8Zpa-Ptb6zWCD1jUuDVQ==/com.example.myapplication-bvhvD7PKJdnssUQso6AYEw==/base.apk. target_sdk_version=36, uses_libraries=, library_path=/data/app/~~BU8Zpa-Ptb6zWCD1jUuDVQ==/com.example.myapplication-bvhvD7PKJdnssUQso6AYEw==/lib/x86_64:/data/app/~~BU8Zpa-Ptb6zWCD1jUuDVQ==/com.example.myapplication-bvhvD7PKJdnssUQso6AYEw==/base.apk!/lib/x86_64, permitted_path=/data:/mnt/expand:/data/user/0/com.example.myapplication 2025-09-22 17:34:17.750 14830-14830 e.myapplication com.example.myapplication I AssetManager2(0x79d591a4c758) locale list changing from [] to [en-US] 2025-09-22 17:34:17.752 14830-14830 e.myapplication com.example.myapplication I AssetManager2(0x79d591a46fd8) locale list changing from [] to [en-US] 2025-09-22 17:34:17.760 14830-14830 GraphicsEnvironment com.example.myapplication V Currently set values for: 2025-09-22 17:34:17.761 14830-14830 GraphicsEnvironment com.example.myapplication V angle_gl_driver_selection_pkgs=[] 2025-09-22 17:34:17.761 14830-14830 GraphicsEnvironment com.example.myapplication V angle_gl_driver_selection_values=[] 2025-09-22 17:34:17.761 14830-14830 GraphicsEnvironment com.example.myapplication V com.example.myapplication is not listed in per-application setting 2025-09-22 17:34:17.761 14830-14830 GraphicsEnvironment com.example.myapplication V ANGLE allowlist from config: com.dreamgames.royalmatch com.dts.freefiremax com.dxx.firenow com.gramgames.mergedragons com.ludo.king com.mojang.minecraftpe com.my.defense com.nintendo.zaka com.os.airforce com.playrix.fishdomdd.gplay io.teslatech.callbreak jp.konami.prospia net.peakgames.toonblast 2025-09-22 17:34:17.761 14830-14830 GraphicsEnvironment com.example.myapplication V com.example.myapplication is not listed in ANGLE allowlist or settings, returning default 2025-09-22 17:34:17.762 14830-14830 GraphicsEnvironment com.example.myapplication V Neither updatable production driver nor prerelease driver is supported. 2025-09-22 17:34:17.810 14830-14845 DisplayManager com.example.myapplication I Choreographer implicitly registered for the refresh rate. 2025-09-22 17:34:17.813 14830-14830 e.myapplication com.example.myapplication I AssetManager2(0x79d591a4f638) locale list changing from [] to [en-US] 2025-09-22 17:34:17.842 14830-14845 EGL_emulation com.example.myapplication I Opening libGLESv1_CM_emulation.so 2025-09-22 17:34:17.842 14830-14845 EGL_emulation com.example.myapplication I Opening libGLESv2_emulation.so 2025-09-22 17:34:17.870 14830-14845 HWUI com.example.myapplication W Failed to choose config with EGL_SWAP_BEHAVIOR_PRESERVED, retrying without... 2025-09-22 17:34:17.870 14830-14845 HWUI com.example.myapplication W Failed to initialize 101010-2 format, error = EGL_SUCCESS 2025-09-22 17:34:17.889 14830-14830 AppCompatDelegate com.example.myapplication D Checking for metadata for AppLocalesMetadataHolderService : Service not found 2025-09-22 17:34:17.890 14830-14830 e.myapplication com.example.myapplication I AssetManager2(0x79d591a4da18) locale list changing from [] to [en-US] 2025-09-22 17:34:17.896 14830-14830 ashmem com.example.myapplication E Pinning is deprecated since Android Q. Please use trim or other methods. 2025-09-22 17:34:17.968 14830-14830 e.myapplication com.example.myapplication I hiddenapi: Accessing hidden method Landroid/view/View;->computeFitSystemWindows(Landroid/graphics/Rect;Landroid/graphics/Rect;)Z (runtime_flags=0, domain=platform, api=unsupported) from Landroidx/appcompat/widget/ViewUtils; (domain=app) using reflection: allowed 2025-09-22 17:34:18.052 14830-14830 CompatChangeReporter com.example.myapplication D Compat change id reported: 377864165; UID 10217; state: ENABLED 2025-09-22 17:34:18.053 14830-14830 DesktopModeFlags com.example.myapplication D Toggle override initialized to: OVERRIDE_UNSET 2025-09-22 17:34:18.079 14830-14830 HWUI com.example.myapplication W Image decoding logging dropped! 2025-09-22 17:34:18.084 14830-14830 e.myapplication com.example.myapplication I hiddenapi: Accessing hidden method Landroid/view/ViewGroup;->makeOptionalFitsSystemWindows()V (runtime_flags=0, domain=platform, api=unsupported) from Landroidx/appcompat/widget/ViewUtils; (domain=app) using reflection: allowed 2025-09-22 17:34:18.134 14830-14830 HWUI com.example.myapplication W Unknown dataspace 0 2025-09-22 17:34:18.402 14830-14830 InsetsController com.example.myapplication D hide(ime(), fromIme=false) 2025-09-22 17:34:18.403 14830-14830 ImeTracker com.example.myapplication I com.example.myapplication:a102fc0: onCancelled at PHASE_CLIENT_ALREADY_HIDDEN 2025-09-22 17:34:18.561 14830-14835 e.myapplication com.example.myapplication I Compiler allocated 5042KB to compile void android.view.ViewRootImpl.performTraversals() 2025-09-22 17:34:20.485 14830-14830 AssistStructure com.example.myapplication I Flattened final assist data: 3948 bytes, containing 1 windows, 27 views 2025-09-22 17:34:22.900 14830-14859 ProfileInstaller com.example.myapplication D Installing profile for com.example.myapplication
最新发布
09-23
<think>我们正在查找Android源码中settings_secure.xml文件的位置。根据Android系统开发经验,这个文件通常位于frameworks/base/core/res/res/values目录下。但为了确保准确性,我们可以通过以下步骤进行验证: 1. **Android源码结构**:在AOSP(Android Open Source Project)中,系统级的资源文件通常放在`frameworks/base/core/res/res`目录下,其中`values`子目录存放各种XML资源文件。 2. **文件作用**:`settings_secure.xml`定义了系统安全相关的设置项,这些设置项会存储在`Secure`命名空间下(通过`Settings.Secure`类访问)。 3. **具体路径**:完整的路径应该是: ``` frameworks/base/core/res/res/values/settings_secure.xml ``` 4. **验证方法**:我们可以查看AOSP的官方源码仓库,例如在Google的AOSP镜像中查看该文件: [AOSP frameworks/base/core/res/res/values/settings_secure.xml](https://android.googlesource.com/platform/frameworks/base/+/refs/heads/master/core/res/res/values/settings_secure.xml) 5. **文件内容示例**:该文件通常包含类似以下内容: ```xml <?xml version="1.0" encoding="utf-8"?> <resources> <!-- 定义安全设置项 --> <string name="secure_setting_name">setting_default_value</string> ... </resources> ``` 6. **注意**:不同版本的Android源码路径可能略有不同,但基本结构一致。如果是在特定分支(如android-13.0.0_r7)下,路径相同。 因此,我们可以确定该文件位于: `frameworks/base/core/res/res/values/settings_secure.xml` ### 相关问题 1. 如何修改`settings_secure.xml`中的默认设置值? 2. 在应用层如何读取`settings_secure.xml`中定义的设置项? 3. `settings_secure.xml`和`settings_global.xml`、`settings_system.xml`有什么区别? 4. 如何为自定义设备添加新的安全设置项? 5. 修改`settings_secure.xml`后如何重新编译系统镜像? [^1]: 参考AOSP源码中`LocationMode`的初始化逻辑,该逻辑会读取`settings_secure.xml`中定义的默认值。</think>### Android源码中`settings_secure.xml`的位置 在Android源码中,`settings_secure.xml`文件位于以下路径: ```bash frameworks/base/core/res/res/values/settings_secure.xml ``` #### 关键说明: 1. **文件作用** 该文件定义了系统安全设置(`Settings.Secure`)的默认值和元数据,包含位置服务、备份配置等敏感权限设置。如您提供的引用[1]所示,`Secure.LOCATION_MODE`等关键配置的默认值就是在此定义的[^1]。 2. **文件结构示例**: ```xml <!-- frameworks/base/core/res/res/values/settings_secure.xml --> <resources> <string name="def_location_mode" translatable="false">1</string> <string name="location_providers_allowed" translatable="false">gps,network</string> <!-- 其他安全相关配置 --> </resources> ``` 3. **相关源码调用** 系统通过`SettingsState`类读取这些配置(如您提供的代码片段): ```java // 在com.android.server.SettingsState.java中 final SettingsState secureSettings = getSecureSettingsLocked(userId); Setting locationMode = secureSettings.getSettingLocked(Secure.LOCATION_MODE); if (locationMode.isNull()) { // 使用settings_secure.xml中的默认值 int defLocationMode = getContext().getResources().getInteger(R.integer.def_location_mode); } ``` 4. **编译后位置** 编译后,该文件会被打包到: ```bash out/target/product/<device>/system/framework/framework-res.apk ``` 可通过反编译APK查看最终生成的资源文件。 --- ### 📌 相关问题 1. 如何修改`settings_secure.xml`中的默认值并重新编译系统? 2. `Settings.Secure`与`Settings.System`和`Settings.Global`有何区别? 3. 应用层如何安全地读取`Secure`设置(如`Settings.Secure.LOCATION_MODE`)? 4. 修改`Secure`设置需要哪些特殊权限? 5. 如何为自定义设备添加新的`Secure`设置项? [^1]: 如您提供的源码片段所示,当`Secure.LOCATION_MODE`未设置时,系统会从资源文件读取默认值`R.integer.def_location_mode`,该值定义在`settings_secure.xml`中。 [^2]: 文件系统权限错误可能影响`Secure`设置的持久化存储,如您日志中的`vold`错误所示。 [^3]: 类似于Django的静态资源配置,Android资源文件也通过路径映射机制被系统识别。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

r_nznf

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值