iis服务器助手广告广告
返回顶部
首页 > 资讯 > 移动开发 >Android cpu信息获取/修改
  • 453
分享到

Android cpu信息获取/修改

android 2023-09-30 09:09:56 453人浏览 泡泡鱼
摘要

CPU信息查看 通过 cat proc/cpuinfo 查看 processor : 7BoGoMIPS : 38.40Features : fp asimd evtstrm aes pmull sh

CPU信息查看

通过 cat proc/cpuinfo 查看

processor       : 7BoGoMIPS        : 38.40Features        : fp asimd evtstrm aes pmull sha1 sha2 crc32 cpuidCPU implementer : 0x51CPU architecture: 8CPU variant     : 0xaCPU part        : 0x800CPU revision    : 2Hardware        : Qualcomm Technologies, Inc

应用端,类似某兔兔中CPU信息应该也是从这里获取的

CPU信息修改 

 cpuinfo 文件内容是在 kernel/msm-4.19/arch/arm64/kernel/cpuinfo.c 中 c_show 函数中写入的

static int c_show(struct seq_file *m, void *v){int i, j;bool compat = personality(current->personality) == PER_LINUX32;seq_printf(m, "Processor\t: AArch64 Processor rev %d (%s)\n",read_cpuid_id() & 15, ELF_PLATFORM);for_each_present_cpu(i) {struct cpuinfo_arm64 *cpuinfo = &per_cpu(cpu_data, i);u32 midr = cpuinfo->reg_midr;seq_printf(m, "processor\t: %d\n", i);if (compat)seq_printf(m, "model name\t: ARMv8 Processor rev %d (%s)\n",   MIDR_REVISION(midr), COMPAT_ELF_PLATFORM);seq_printf(m, "BogoMIPS\t: %lu.%02lu\n",   loops_per_jiffy / (500000UL/HZ),   loops_per_jiffy / (5000UL/HZ) % 100);seq_puts(m, "Features\t:");if (compat) {#ifdef CONFIG_COMPATfor (j = 0; compat_hwcap_str[j]; j++)if (compat_elf_hwcap & (1 << j))seq_printf(m, " %s", compat_hwcap_str[j]);for (j = 0; compat_hwcap2_str[j]; j++)if (compat_elf_hwcap2 & (1 << j))seq_printf(m, " %s", compat_hwcap2_str[j]);#endif } else {for (j = 0; hwcap_str[j]; j++)if (elf_hwcap & (1 << j))seq_printf(m, " %s", hwcap_str[j]);}seq_puts(m, "\n");seq_printf(m, "CPU implementer\t: 0x%02x\n",   MIDR_IMPLEMENTOR(midr));seq_printf(m, "CPU architecture: 8\n");seq_printf(m, "CPU variant\t: 0x%x\n", MIDR_VARIANT(midr));seq_printf(m, "CPU part\t: 0x%03x\n", MIDR_PARTNUM(midr));seq_printf(m, "CPU revision\t: %d\n\n", MIDR_REVISION(midr));}if (!arch_read_hardware_id)seq_printf(m, "Hardware\t: %s\n", Machine_name);elseseq_printf(m, "Hardware\t: %s\n", arch_read_hardware_id());return 0;}

注:上面 arch_read_hardware_id 函数,高通平台是在 kernel/msm-4.19/drivers/soc/qcom/socinfo.c 文件中,等于 msm_read_hardware_id 函数

static char *msm_read_hardware_id(void){static char msm_soc_str[256] = "Qualcomm Technologies, Inc ";static bool string_generated;int ret = 0;if (string_generated)return msm_soc_str;if (!socinfo)goto err_path;if (!cpu_of_id[socinfo->v0_1.id].soc_id_string)goto err_path;ret = strlcat(msm_soc_str, cpu_of_id[socinfo->v0_1.id].soc_id_string,sizeof(msm_soc_str));if (ret > sizeof(msm_soc_str))goto err_path;string_generated = true;return msm_soc_str;err_path:return "UNKNOWN SOC TYPE";}

这里就是将高通和芯片名称 soc_id_string 进行拼接下。上面 msm_soc_info cpu_of_id[] 中枚举了相关芯片信息

static struct msm_soc_info cpu_of_id[] = {[0]  = {MSM_CPU_UNKNOWN, "Unknown CPU"},[87] = {MSM_CPU_8960, "MSM8960"},[109] = {MSM_CPU_8064, "APQ8064"},[122] = {MSM_CPU_8960, "MSM8960"},... ...

根据 socinfo->v0_1.id 进行匹配,这个 id 等于项目的 dtsi 中配置的 qcom,msm-id 

/ {model = "Qualcomm Technologies, Inc. xxx";compatible = "xxx";qcom,msm-id = , ;

注意:

Android版本,修改 cpu_of_id 可能会影响CTS testConfigHardwareMitigations 此项。相关源码cts/hostsidetests/security/src/android/security/cts/KernelConfigTest.java

    private Map hardwareMitigations = new HashMap() {    {        put("EXYNOS990", null);        put("EXYNOS980", null);        put("EXYNOS850", null);        put("EXYNOS3830", null);        put("EXYNOS9630", null);        put("EXYNOS9830", null);        put("EXYNOS7870", null);        put("EXYNOS7880", null);        put("EXYNOS7570", null);        put("EXYNOS7872", new String[]{"CONFIG_HARDEN_BRANCH_PREDICTOR=y"});        put("EXYNOS7885", new String[]{"CONFIG_HARDEN_BRANCH_PREDICTOR=y"});        put("EXYNOS9610", new String[]{"CONFIG_HARDEN_BRANCH_PREDICTOR=y"});        put("Kirin980", new String[]{"CONFIG_HARDEN_BRANCH_PREDICTOR=y"});        put("Kirin970", new String[]{"CONFIG_HARDEN_BRANCH_PREDICTOR=y"});        put("Kirin810", null);        put("Kirin710", new String[]{"CONFIG_HARDEN_BRANCH_PREDICTOR=y"});        put("SDMMAGPIE", new String[]{"CONFIG_HARDEN_BRANCH_PREDICTOR=y"});        put("SM6150", new String[]{"CONFIG_HARDEN_BRANCH_PREDICTOR=y"});        put("SM7150", new String[]{"CONFIG_HARDEN_BRANCH_PREDICTOR=y"});        put("LITO", null);        put("SM8150", new String[]{"CONFIG_HARDEN_BRANCH_PREDICTOR=y"});        put("SM8150P", new String[]{"CONFIG_HARDEN_BRANCH_PREDICTOR=y"});        put("KONA", null);        put("SDM429", null);        put("SDM439", null);        put("QM215", null);        put("BENGAL", new String[]{"CONFIG_HARDEN_BRANCH_PREDICTOR=y"});        put("DEFAULT", new String[]{"CONFIG_HARDEN_BRANCH_PREDICTOR=y",            "CONFIG_UNMAP_KERNEL_AT_EL0=y"});    }};    private String[] lookupMitigations() throws Exception {        return hardwareMitigations.get(getHardware());    }        @CddTest(requirement="9.7")    public void testConfigHardwareMitigations() throws Exception {        String mitigations[];        if (PropertyUtil.getFirstapiLevel(mDevice) < 28) {            return;        }        if (CpuFeatures.isArm64(mDevice) && !CpuFeatures.kernelVersionLessThan(mDevice, 4, 4)) {            mitigations = lookupMitigations();            if (mitigations != null) {                for (String mitigation : mitigations) {                    assertTrue("linux kernel must have " + mitigation + " enabled.",configSet.contains(mitigation));                }            }        } else if (CpuFeatures.isX86(mDevice)) {            assertTrue("Linux kernel must have KPTI enabled: CONFIG_PAGE_TABLE_ISOLATION=y",                    configSet.contains("CONFIG_PAGE_TABLE_ISOLATION=y"));        }    }

测试会根据 hardwareMitigations 中CPU型号,确认需要开启的宏,所以修改CPU名称后需要确认相关宏是否开启。

来源地址:https://blog.csdn.net/tq501501/article/details/131514655

--结束END--

本文标题: Android cpu信息获取/修改

本文链接: https://www.lsjlt.com/news/421791.html(转载时请注明来源链接)

有问题或投稿请发送至: 邮箱/279061341@qq.com    QQ/279061341

本篇文章演示代码以及资料文档资料下载

下载Word文档到电脑,方便收藏和打印~

下载Word文档
猜你喜欢
  • Android cpu信息获取/修改
    CPU信息查看 通过 cat proc/cpuinfo 查看 processor : 7BogoMIPS : 38.40Features : fp asimd evtstrm aes pmull sh...
    99+
    2023-09-30
    android
  • C++中怎么获取CPU信息
    C++中怎么获取CPU信息,很多新手对此不是很清楚,为了帮助大家解决这个难题,下面小编将为大家详细讲解,有这方面需求的人可以来学习下,希望你能有所收获。C++获取CPU信息之获得CPU的制造商信息(Vender ID String)把eax...
    99+
    2023-06-17
  • linux如何修改cpu信息
    要修改Linux上的CPU信息,您可以尝试以下方法之一:1. 使用lscpu命令查看CPU信息,然后根据需要修改/proc/cpui...
    99+
    2023-09-08
    linux
  • Android之 获取定位信息总结
    一,概述: 1  android原生是有定位api的,但稳定性和准确度远远不够,所以通常需要借助三方SDK获取位置信息 2 国内SDK选择性较多,百度,腾讯,高德等定位api,但都是需要在平台建立应用,配置key的,包括基础的定位。 3 国...
    99+
    2023-09-11
    android
  • android调用webservice接口获取信息
    我的有一篇博客上讲了如何基于CXF搭建webservice,service层的接口会被部署到tomcat上,这一篇我就讲一下如何在安卓中调用这些接口传递参数。在lib中放入ksoap2的jar包并导入在xml 配置文件中加入:<!--...
    99+
    2023-05-30
    android webservice 接口
  • android怎么修改定位信息
    若要修改Android设备的定位信息,可以按照以下步骤进行操作:1. 打开设备的设置菜单,找到“位置”或“定位服务”选项。不同设备的...
    99+
    2023-08-16
    android
  • Android利用ContentProvider获取联系人信息
    本文实例为大家分享了Android利用ContentProvider获取联系人信息的具体代码,供大家参考,具体内容如下 在写代码前我们首先看一下运行的效果 运行效果如下: 点了获取...
    99+
    2024-04-02
  • 获取MP3信息
      很多时候,我们有必要的到一些歌曲的信息,比如歌手的专辑,歌手名 歌曲名,下面就是java写的获取MP3歌曲信息首先加入 jid3lib-0.5.4.jar包  import java.io.IOException;import org....
    99+
    2023-01-31
    信息
  • go获取服务器信息(主机、CPU、内存、硬盘)
    使用github.com/shirou/gopsutil库来获取机器信息,您可以按照以下步骤进行: 1、安装相关库 go get github.com/shirou/gopsutilgo get gi...
    99+
    2023-09-24
    golang
  • android adb 获取电池信息以及设置
    本文主要包含 1、设置adb 无线调试桥连接步骤 2、打印设备电池状态(当前电量、充电状态、充放电电流大小、电池种类等) 3、更改电池充电状态、电量百分比、电池还原命令 4、断开adb 远程调试桥 ---------------------...
    99+
    2023-08-16
    android adb
  • 获取对象信息
    type()函数   type()函数用于判断基本类型 type(123) #输出:<class 'int'> type('str') #输出:<class 'str'> ty...
    99+
    2023-01-31
    对象 信息
  • python获取Linux信息
      刚开始学习Python,用Python写了一个获取Linux服务器信息的脚本,在debian和centos上测试通过。首先需要安装一个psutil库,在安装psutil之前需要安装python的开发工具包#debian  apt-get...
    99+
    2023-01-31
    信息 python Linux
  • android微信授权获取用户个人信息代码
    微信官方文档API:https://developers.weixin.qq.com/doc/oplatform/Mobile_App/WeChat_Login/Developmen...
    99+
    2024-04-02
  • android微信授权怎么获取用户个人信息
    本篇内容主要讲解“android微信授权怎么获取用户个人信息”,感兴趣的朋友不妨来看看。本文介绍的方法操作简单快捷,实用性强。下面就让小编来带大家学习“android微信授权怎么获取用户个人信息”吧!微信官方文档API:https://de...
    99+
    2023-06-22
  • 如何在Linux中获取CPU信息的简单CLI工具
    这篇文章主要讲解了“如何在Linux中获取CPU信息的简单CLI工具”,文中的讲解内容简单清晰,易于学习与理解,下面请大家跟着小编的思路慢慢深入,一起来研究和学习“如何在Linux中获取CPU信息的简单CLI工具”吧!CPUFetch是一个...
    99+
    2023-06-15
  • 如何在Android中获取系统储存信息
    这篇文章给大家介绍如何在Android中获取系统储存信息,内容非常详细,感兴趣的小伙伴们可以参考借鉴,希望对大家能有所帮助。获取SD卡上的储存信息:    private String&nb...
    99+
    2023-05-30
    android
  • Android App获取不到pkgInfo信息问题原因
    目录 Android APP 系统签名及权限设置 获取Apk信息 高版本Android系统权限设置 Android APP 系统签名及权限设置 本文主要讨论在Android平台上,关于应用(APP)系统签名以及权限设置的相关知识。...
    99+
    2023-09-14
    android
  • Python3:获取天气信息
    防伪码:没有相当程度的孤独是不可能有内心的平和。Python版本Python3.5.3天气预报 Web 服务参考http://www.webxml.com.cn/WebServices/WeatherWebService.asmxop=ge...
    99+
    2023-01-31
    天气 信息
  • python获取mysql表信息
    使用python获取mysql相关信息,使用python执行mysql相关语句test1 #!/bin/env python #coding=utf-8 #by songry #date 2018-01-09 #time 11:18 #po...
    99+
    2023-01-31
    信息 python mysql
  • Android使用adb命令查看CPU信息
    Android使用adb命令查看CPU信息 在开发和调试Android应用程序的过程中,了解设备的硬件信息是非常重要的。而其中一个关键信息就是设备的CPU信息。通过使用adb命令,我们可以轻松地查看A...
    99+
    2023-09-24
    android adb Android
软考高级职称资格查询
编程网,编程工程师的家园,是目前国内优秀的开源技术社区之一,形成了由开源软件库、代码分享、资讯、协作翻译、讨论区和博客等几大频道内容,为IT开发者提供了一个发现、使用、并交流开源技术的平台。
  • 官方手机版

  • 微信公众号

  • 商务合作