【问题标题】:How to determine if application is running on stock ROM如何确定应用程序是否在库存 ROM 上运行
【发布时间】:2013-12-25 12:24:43
【问题描述】:

我正在编写一个需要区分 Android Stock ROM 和其他 ROM(如 SenseUI 等)的应用。

如何在我的应用程序中做到这一点?

谢谢。

【问题讨论】:

    标签: android samsung-mobile htcsense


    【解决方案1】:

    我发现使用getprop 查询ro.product.brand 会产生我所需要的结果。

    /**
     * Returns the ROM manufacturer.
     *
     * @return The ROM manufacturer, or NULL if not found.
     */
    public static String getROMManufacturer() {
        String line;
        BufferedReader input = null;
        try {
            Process p = Runtime.getRuntime().exec("getprop ro.product.brand");
            input = new BufferedReader(new InputStreamReader(p.getInputStream()), 1024);
            line = input.readLine();
            input.close();
        }
        catch (IOException ex) {
            Log.e(TAG, "Unable to read sysprop ro.product.brand", ex);
            return null;
        }
        finally {
            if (input != null) {
                try {
                    input.close();
                }
                catch (IOException e) {
                    Log.e(TAG, "Exception while closing InputStream", e);
                }
            }
        }
        return line;
    }
    

    对于库存 ROM,我们返回的值是 google
    以 SenseUI 为例,我们将返回 HTC

    上述方法将返回唯一的googleHTC等...

    我希望它也对其他人有所帮助。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2022-01-26
      • 2021-06-30
      • 2011-05-30
      • 2016-11-01
      • 1970-01-01
      相关资源
      最近更新 更多