这里写目录标题
OTA代码下载
https://download.csdn.net/download/xuyewen288/85801495
1.Android.mk增加编译
这里编译到priv-app下面,权限更高
LOCAL_PATH:= $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := OTASdk
LOCAL_MODULE_TAGS := optional
LOCAL_SRC_FILES := $(LOCAL_MODULE).apk
LOCAL_MODULE_CLASS := APPS
LOCAL_MODULE_SUFFIX := $(COMMON_ANDROID_PACKAGE_SUFFIX)
LOCAL_PRIVILEGED_MODULE := true
LOCAL_CERTIFICATE := platform
# LOCAL_CERTIFICATE := testkey
include $(BUILD_PREBUILT)
2.增加priv-app OTA的权限
alps\frameworks\base\data\etc\privapp-permissions-platform.xml
<privapp-permissions package="com.xxx.xxxx">
<permission name="android.permission.REBOOT"/>
<permission name="android.permission.RECOVERY"/>
<permission name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<permission name="android.permission.READ_EXTERNAL_STORAGE"/>
<permission name="android.permission.MANAGE_EXTERNAL_STORAGE"/>
<permission name="android.permission.MOUNT_UNMOUNT_FILESYSTEMS"/>
<permission name="android.permission.RECEIVE_BOOT_COMPLETED"/>
</privapp-permissions>
3.新增se文件
/alps/device/mediatek/mt8168/sepolicy/basic/update_engine.te b/alps/device/mediatek/mt8168/sepolicy/basic/update_engine.te
update_engine.te 下面是修改系统的SE规则,不然会编译不过
allow update_engine metadata_file:dir { search };
allow update_engine sysfs_boot_type:file { read open getattr write unlink};
allow update_engine update_engine:capability dac_read_search;
allow update_engine update_engine:capability dac_override;
--- a/alps/system/sepolicy/prebuilts/api/29.0/private/domain.te
+++ b/alps/system/sepolicy/prebuilts/api/29.0/private/domain.te
@@ -271,6 +271,7 @@ define(`dac_override_allowed', `{
vold
vold_prepare_subdirs
zygote
+ update_engine
}')
neverallow ~dac_override_allowed self:global_capability_class_set dac_override;
# Since the kernel checks dac_read_search before dac_override, domains that
@@ -280,6 +281,7 @@ neverallow ~dac_override_allowed self:global_capability_class_set dac_override;
neverallow ~{
dac_override_allowed
traced_probes
+ update_engine
userdebug_or_eng(`heapprofd')
} self:global_capability_class_set dac_read_search;
diff --git a/alps/system/sepolicy/private/domain.te b/alps/system/sepolicy/private/domain.te
index 1d26761d6b..9ac13ce30e 100644
--- a/alps/system/sepolicy/private/domain.te
+++ b/alps/system/sepolicy/private/domain.te
@@ -271,6 +271,7 @@ define(`dac_override_allowed', `{
vold
vold_prepare_subdirs
zygote
+ update_engine
}')
neverallow ~dac_override_allowed self:global_capability_class_set dac_override;
# Since the kernel checks dac_read_search before dac_override, domains that
@@ -280,6 +281,7 @@ neverallow ~dac_override_allowed self:global_capability_class_set dac_override;
neverallow ~{
dac_override_allowed
traced_probes
+ update_engine
userdebug_or_eng(`heapprofd')
} self:global_capability_class_set dac_read_search;
4.添加系统能发送的广播,不然会报异常
--- a/alps/frameworks/base/services/core/java/com/android/server/am/ActivityManagerService.java
+++ b/alps/frameworks/base/services/core/java/com/android/server/am/ActivityManagerService.java
@@ -14915,6 +14915,11 @@ public class ActivityManagerService extends IActivityManager.Stub
// we've relaxed, so it's fine for system internals to send.
return;
}
+
+ if(action != null && (action.contains("android.intent.action.xxxx.ota") || action.contains("action.xxx.xxx"))){
+ return;
+ }
+
// This broadcast may be a problem... but there are often system components that
// want to send an internal broadcast to themselves, which is annoying to have to
5.MTK平台快霸增加白名单,不然如果是后台服务会把app被杀掉,其他平台根据情况定
--- a/alps/vendor/mediatek/proprietary/frameworks/base/services/core/java/com/mediatek/server/am/AmsExtImpl.java
+++ b/alps/vendor/mediatek/proprietary/frameworks/base/services/core/java/com/mediatek/server/am/AmsExtImpl.java
@@ -229,6 +229,26 @@ public class AmsExtImpl extends AmsExt {
mAalUtils = AalUtils.getInstance();
}
///@}
+
+ //add 过滤应用 begin
+ try {
+ Method method= mDuraSpeedService.getClass().getMethod("getPlatformWhitelist", null);
+ //获取白名单列表
+ Object obj = method.invoke(mDuraSpeedService);
+ if(obj != null && obj instanceof List) {
+ List<String> list = (List<String>) obj;
+ //加入自己的过滤app
+ list.add("com.xxx.xxxx");
+ //更新白名单
+ method = mDuraSpeedService.getClass().getMethod("setAppWhitelist", List.class);
+ method.invoke(mDuraSpeedService, list);
+ }
+ }catch (Exception e){
+ Slog.e("AmsExtImpl add app to whitelist ", e.toString());
+ }
+
+ //add 过滤应用 end
+
}