Android 默认设置

时间:2021/03/05
之前公司不允许csdn,笔记写在其它地方。最近整理过来

1、framework中修改setting中的默认值

https://blog.csdn.net/deng0zhaotai/article/details/41380307

2、默认开启无障碍服务 AccessibilityService

//MyAccessibilityService

loadSetting(stmt,
        Settings.Secure.ACCESSIBILITY_ENABLED,1);
loadSetting(stmt,
        Settings.Secure.ENABLED_ACCESSIBILITY_SERVICES,
        "com.aarogyasetu.scanner/com.aarogyasetu.scanner.MyAccessibilityService");
loadSetting(stmt,
        Settings.Secure.TOUCH_EXPLORATION_GRANTED_ACCESSIBILITY_SERVICES,
        "com.aarogyasetu.scanner/com.aarogyasetu.scanner.MyAccessibilityService");

3、默认激活设备管理器

https://blog.csdn.net/zhanghao19960914/article/details/83934854

4、 敏感权限、默认权限配置

https://blog.csdn.net/qiangzai110110/article/details/51767485

//默认敏感权限配置
//xml配置
/system/etc/permissions/aaa.xml
//代码部分
frameworks/base/services/core/java/com/android/server/pm/permission/PermissionManagerService.java

private static final ArrayList<String> scannerPermissionList = new ArrayList();
static {
    scannerPermissionList.add("android.permission.CAMERA");
}
restorePermissionState()//add start
if("com.aarogyasetu.scanner".equals(pkg.packageName)){
    if(scannerPermissionList.contains(perm)){
        grant = GRANT_INSTALL;
    }
}
//add end
if (grant != GRANT_DENIED) {
    if (!ps.isSystem() && ps.areInstallPermissionsFixed() && !bp.isRuntime()) {
        // If this is an existing, non-system package, then
        // we can't add any new permissions to it. Runtime
        // permissions can be added any time - they ad dynamic.
        if (!allowedSig && !origPermissions.hasInstallPermission(perm)) {
            // Except...  if this is a permission that was added
            // to the platform (note: need to only do this when
            // updating the platform).
            if (!isNewPlatformPermissionForPackage(perm, pkg)) {
                grant = GRANT_DENIED;
            }
        }
    }

//省电模式策略 允许应用始终运行在后台默认配置权限
<allow-in-power-save package="com.aarogyasetu.scanner" />

5、双击灭屏

https://blog.csdn.net/dreamfly130/article/details/82759750

//PowerManager需要系统应用权限
PowerManager.goToSleep(SystemClock.uptimeMillis());

6、cpu状态策略

https://blog.csdn.net/su749520/article/details/79026493

https://blog.csdn.net/wejfoasdbsdg/article/details/50765409

7、taskview启动应用模糊问题

应用热启动时,go版本应用界面模糊再变清晰(比较明显)

Google解决热启动应用时,为了用户体验,先加载snapshot(一张图片,内容和退出应用时的内容相同)遮盖应用的启动流程,保证应用加载的流程性
出现该现象的原因为Google设计snapshot进行了压缩,snapshot的尺寸比应用分辨率低,导致从snapshot到应用真正的界面时出现清晰度的变化,
该功能定义在:frameworks/base/services/core/java/com/android/server/wm/TaskSnapshotPersister.java

如果想要修改,请修改TaskSnapshotPersister.java中如下变量:
图片的压缩参数
private static final float REDUCED_SCALE = .5f;
private static final float LOW_RAM_REDUCED_SCALE = .6f;
private static final float LOW_RAM_RECENTS_REDUCED_SCALE = .1f;
可以将上述值都修改为1f
修改可能导致打开应用时,内存的消耗变多

图片保存到本地的压缩质量:
private static final int QUALITY = 95
可以将其修改为
private static final int QUALITY = 100,
但是修改该值可能导致储存空间使用变多

还请评估下是否修改

8、展讯平台android11 默认解锁调试代码

--- a/idh.code/bsp/bootloader/u-boot15/lib/secureboot/common/sec_common.c
+++ b/idh.code/bsp/bootloader/u-boot15/lib/secureboot/common/sec_common.c
@@ -1324,12 +1324,17 @@ unsigned int get_lock_status(void)
        ret = sprd_sec_verify_lockstatus(lock_flag, PDT_INFO_LOCK_FLAG_MAX_SIZE);
-       if(ret != 0) {
-               g_DeviceStatus = VBOOT_STATUS_LOCK; /*default lock status.*/
-       }
-       else {
-               g_DeviceStatus = VBOOT_STATUS_UNLOCK; /*unlock status.*/
-       }
+    
+    if(ret != 0) {
+#ifdef DEBUG
+        g_DeviceStatus = VBOOT_STATUS_UNLOCK; /*default lock status.*/
+#else
+        g_DeviceStatus = VBOOT_STATUS_LOCK; /*default lock status.*/
+#endif
+    }
+    else {
+        g_DeviceStatus = VBOOT_STATUS_UNLOCK; /*unlock status.*/
+    }
        return g_DeviceStatus;
}

9、内置应用可卸载

9.1、mtk内置为系统应用

include $(CLEAR_VARS)
LOCAL_MODULE := facebook
LOCAL_MODULE_TAGS := optional
LOCAL_SRC_FILES := Facebook/system/app/facebook/facebook-stub.apk
LOCAL_MODULE_CLASS := APPS
LOCAL_DEX_PREOPT := true
LOCAL_MODULE_SUFFIX := $(COMMON_ANDROID_PACKAGE_SUFFIX)
LOCAL_CERTIFICATE := PRESIGNED
include $(BUILD_PREBUILT)

vendor/mediatek/proprietary/frameworks/base/data/etc/pms_sysapp_removable_system_list.txt加上应用包名

com.android.quicksearchbox
com.facebook.katana

9.2、展讯平台已经支持了preloadapp目录,可以直接预制

include $(CLEAR_VARS)
LOCAL_MODULE := facebook
LOCAL_MODULE_TAGS := optional
LOCAL_SRC_FILES := Facebook/base.apk
LOCAL_MODULE_CLASS := APPS
LOCAL_DEX_PREOPT := false
LOCAL_MODULE_SUFFIX := $(COMMON_ANDROID_PACKAGE_SUFFIX)
LOCAL_MODULE_PATH := $(TARGET_OUT)/preloadapp
LOCAL_CERTIFICATE := PRESIGNED
include $(BUILD_PREBUILT)

frameworks/base/core/java/android/content/pm/PackageManager.java中isPreloadOrVitalApp方法:

10、内置三方应用crash

https://blog.csdn.net/u014316462/article/details/76634235/

Log:avc:  denied
013F5 <5> [ 2003.716115][02-24 14:14:43.716] audit: type=1400 audit(1614154484.751:727): avc:  denied  { open } for  pid=15722 comm="m.facebook.lite" path="/data/app-lib/Lite/libsuperpack-jni.so" dev="mmcblk0p41" ino=478 scontext=u:r:untrusted_app:s0:c143,c256,c512,c768 tcontext=u:object_r:system_data_file:s0 tclass=file permissive=0

根据log添加对应权限
device/sprd/sharkl3/common/sepolicy/untrusted_app.te中

allow untrusted_app system_data_file:file { open execute };

你可能感兴趣的:(其它,frameworks,android,java)