Settings关于本机界面修改

简介: 笔记

一、设备名称修改


1、 Setings源码

packages/apps/Settings/src/com/android/settings/deviceinfo/DeviceNamePreferenceController.java

private void initializeDeviceName() {
        mDeviceName = Settings.Global.getString(mContext.getContentResolver(),
                Settings.Global.DEVICE_NAME);
        if (mDeviceName == null) {
            mDeviceName = Build.MODEL;
        }
    }

可以修改数据库中Settings.Global.DEVICE_NAME字段或者修改Build.MODEL

2.DEVICE_NAME具体值如下:

frameworks/base/core/java/android/provider/Settings.java

/**
  * The name of the device
  */
 public static final String DEVICE_NAME = "device_name";

初始化的地方在SettingsProvider:

frameworks/base/packages/SettingsProvider/src/com/android/providers/settings/DatabaseHelper.java

private void loadGlobalSettings(SQLiteDatabase db) {
      ......
      loadSetting(stmt, Settings.Global.DEVICE_NAME, getDefaultDeviceName());
    ........
  }
   private String getDefaultDeviceName() {
       return mContext.getResources().getString(R.string.def_device_name_simple, Build.MODEL);
   }

res/values/defaults.xml
<string name="def_device_name_simple">%1$s</string>

3.Build.MODEL如下:

frameworks/base/core/java/android/os/Build.java

/** The end-user-visible name for the end product. */
  public static final String MODEL = getString("ro.product.model");

4.本项目中实际修改Build.MODEL,即ro.product.model属性值

sl8541e_1h10_32b/sl8541e_1h10_32b_Natv.mk 
-PRODUCT_MODEL := sl8541e_1h10_32b_Natv
+PRODUCT_MODEL := FT11


二、设备型号修改


1、Settings源码

packages/apps/Settings/src/com/android/settings/deviceinfo/HardwareInfoPreferenceController.java

public static String getDeviceModel() {
        FutureTask<String> msvSuffixTask = new FutureTask<>(() -> DeviceInfoUtils.getMsvSuffix());
        msvSuffixTask.run();
        try {
            // Wait for msv suffix value.
            final String msvSuffix = msvSuffixTask.get();
            return Build.MODEL + msvSuffix;
        } catch (ExecutionException e) {
            Log.e(TAG, "Execution error, so we only show model name");
        } catch (InterruptedException e) {
            Log.e(TAG, "Interruption error, so we only show model name");
        }
        // If we can't get an msv suffix value successfully,
        // it's better to return model name.
        return Build.MODEL;
    }

型号读取的也跟Build.MODEL有关,但是它可以还带后缀msvSuffix

  1. 后缀msvSuffix 的读取
    ``

private static final String FILENAME_MSV = "/sys/board_properties/soc/msv";
   public static String getMsvSuffix() {
       // Production devices should have a non-zero value. If we can't read it, assume it's a
       // production device so that we don't accidentally show that it's an ENGINEERING device.
       try {
           String msv = readLine(FILENAME_MSV);
           // Parse as a hex number. If it evaluates to a zero, then it's an engineering build.
           if (Long.parseLong(msv, 16) == 0) {
               return " (ENGINEERING)";
           }
       } catch (IOException|NumberFormatException e) {
           // Fail quietly, as the file may not exist on some devices, or may be unreadable
       }
       return "";
   }
  private static String readLine(String filename) throws IOException {
      BufferedReader reader = new BufferedReader(new FileReader(filename), 256);
      try {
          return reader.readLine();
      } finally {
          reader.close();
      }
  }

实际就是读取文件 "/sys/board_properties/soc/msv"的内容,而我们机器中不包含该文件,所以型号实际上还是Build.MODEL。


三、修改版本号显示


1.Settings源码

/packages/apps/Settings/src/com/android/settings/deviceinfo/BuildNumberPreferenceController.java

public CharSequence getSummary() {
      return BidiFormatter.getInstance().unicodeWrap(Build.DISPLAY);
  }

frameworks/base/core/java/android/os/Build.java

/** A build ID string meant for displaying to the user */
   public static final String DISPLAY = getString("ro.build.display.id");

实际上修改属性值ro.build.display.id

目录
相关文章
|
6月前
|
iOS开发 Perl
gitignore_global设置
gitignore_global设置
42 0
|
6月前
|
数据管理 中间件 数据库
settings.py文件
【2月更文挑战第11天】settings.py文件。
46 1
|
Unix Linux iOS开发
FastAPI(64)- Settings and Environment Variables 配置项和环境变量(下)
FastAPI(64)- Settings and Environment Variables 配置项和环境变量(下)
541 0
FastAPI(64)- Settings and Environment Variables 配置项和环境变量(下)
|
Android开发
AndroidQ(10.0) Settings DatePick bug修改
AndroidQ(10.0) Settings DatePick bug修改
83 0
|
存储 自然语言处理 数据库
Settings 和 Mappings_Settings_Ⅱ_实例 | 学习笔记
快速学习 Settings 和 Mappings_Settings_Ⅱ_实例
Settings 和 Mappings_Settings_Ⅱ_实例 | 学习笔记
|
存储 自然语言处理 数据库
Settings 和 Mappings_Settings_Ⅰ_介绍 | 学习笔记
快速学习 Settings 和 Mappings_Settings_Ⅰ_介绍
Settings 和 Mappings_Settings_Ⅰ_介绍 | 学习笔记
|
开发者 索引
Settings 和 Mappings_Settings | 学习笔记
快速学习 Settings 和 Mappings_Settings
Settings 和 Mappings_Settings | 学习笔记
|
搜索推荐 开发者 索引
Settings 和 Mappings_Settings|学习笔记
快速学习 Settings 和 Mappings_Settings。
|
API 数据库 数据安全/隐私保护
FastAPI(64)- Settings and Environment Variables 配置项和环境变量(上)
FastAPI(64)- Settings and Environment Variables 配置项和环境变量(上)
532 0
FastAPI(64)- Settings and Environment Variables 配置项和环境变量(上)
|
存储 C# 数据格式
C# Settings使用小结
原文:C# Settings使用小结 本篇博客将介绍C#中Settings的使用。 首先介绍一个桌面程序中的例子,当我们新安装一个软件,软件启动后会有例如新手指导等窗体弹出来,每次都需要自己去关闭它。
1486 0