当前位置:   article > 正文

Android 7.1 ro.rk.install_non_market_apps属性无效

install_non_market_apps

平台

RK3288/RK3368 + Android 7.12
  • 1

问题

在旧的SDK上, 可以通过设置默认 ro.rk.install_non_market_apps=true, 默认打开安装未知来源应用 在新的代码上此属性不生效

解决

diff --git a/frameworks/base/packages/SettingsProvider/src/com/android/providers/settings/DatabaseHelper.java b/frameworks/base/packages/SettingsProvider/src/com/android/providers/settings/DatabaseHelper.java
old mode 100644
new mode 100755
index 9ed6063..dac22e1
--- a/frameworks/base/packages/SettingsProvider/src/com/android/providers/settings/DatabaseHelper.java
+++ b/frameworks/base/packages/SettingsProvider/src/com/android/providers/settings/DatabaseHelper.java
@@ -2522,8 +2522,13 @@ class DatabaseHelper extends SQLiteOpenHelper {
             loadStringSetting(stmt, Settings.Secure.IMMERSIVE_MODE_CONFIRMATIONS,
                         R.string.def_immersive_mode_confirmations);
 
-            loadBooleanSetting(stmt, Settings.Secure.INSTALL_NON_MARKET_APPS,
-                    R.bool.def_install_non_market_apps);
+            String propNonMarket = android.os.SystemProperties.get("ro.rk.install_non_market_apps");
+            if(propNonMarket.equals("true")){
+                loadSetting(stmt, Settings.Secure.INSTALL_NON_MARKET_APPS, "1");
+            }else{
+                loadBooleanSetting(stmt, Settings.Secure.INSTALL_NON_MARKET_APPS,
+                        R.bool.def_install_non_market_apps);
+            }
 
             loadBooleanSetting(stmt, Settings.Secure.WAKE_GESTURE_ENABLED,
                     R.bool.def_wake_gesture_enabled);

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • frameworks/base/packages/SettingsProvider/src/com/android/providers/settings/DatabaseHelper.java
    private void loadSecureSettings(SQLiteDatabase db) {
        SQLiteStatement stmt = null;
        try {
        //...省略代码...
            String propNonMarket = android.os.SystemProperties.get("ro.rk.install_non_market_apps");
            if(propNonMarket.equals("true")){
                loadSetting(stmt, Settings.Secure.INSTALL_NON_MARKET_APPS, "1");
            }else{
                loadBooleanSetting(stmt, Settings.Secure.INSTALL_NON_MARKET_APPS,
                        R.bool.def_install_non_market_apps);
            }
		//...省略代码...
	}
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13

插曲

  • 刚开始加的代码是:
            loadBooleanSetting(stmt, Settings.Secure.INSTALL_NON_MARKET_APPS,
                        R.bool.def_install_non_market_apps);
            String propNonMarket = android.os.SystemProperties.get("ro.rk.install_non_market_apps");
            if(propNonMarket.equals("true")){
                loadSetting(stmt, Settings.Secure.INSTALL_NON_MARKET_APPS, "1");
            }
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6

这是无效的, 原因是, 第一行的代码已经往数据库里插入了数据. 见下面SQLiteStatement 的赋值方式:

        SQLiteStatement stmt = null;
        stmt = db.compileStatement("INSERT OR IGNORE INTO secure(name,value)"
                    + " VALUES(?,?);");
  • 1
  • 2
  • 3
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/2023面试高手/article/detail/153044
推荐阅读
相关标签
  

闽ICP备14008679号