需求:客户要求开机之后,自己手动修改开机动画,并且重启 恢复出厂设置,都不会是修改的动画还原回刷机的动画。
初始做法:把开机动画保存在data分区,然后开机的播动画的时候,去播放。后面发现有概率不播放这个动画,去播放原来刷机的动画。进一步发现是,data分区开机动画播放的时候没加载到。
然后各种想办法,都没用。
最终做法:后面和OMD商量找到 /mnt/vendor/persist/ 这个路径也可以播放动画,经过N次+权限之后,动画播放正常。
会长的代码修改如下:
优化动态修改开机动画概率不生效的问题,修改保存路径 /mnt/vendor/persist/
diff --git a/device/qcom/common/rootdir/etc/init.qcom.rc b/device/qcom/common/rootdir/etc/init.qcom.rc
index af40c59..c329996 100755
--- a/device/qcom/common/rootdir/etc/init.qcom.rc
+++ b/device/qcom/common/rootdir/etc/init.qcom.rc
@@ -159,9 +159,9 @@ on boot
# ReadMin, ReadInitial, ReadMax, WriteMin, WriteInitial, WriteMax,
setprop net.tcp.buffersize.wifi 524288,2097152,4194304,262144,524288,1048576
-
setprop ro.telephony.call_ring.multiple false
+ chmod 0666 /mnt/vendor/persist/bootanimation.zip
#Remove SUID bit for iproute2 ip tool
chmod 0755 /system/bin/ip
diff --git a/device/qcom/sepolicy/vendor/common/bootanim.te b/device/qcom/sepolicy/vendor/common/bootanim.te
old mode 100644
new mode 100755
index ee1340b..2376003
--- a/device/qcom/sepolicy/vendor/common/bootanim.te
+++ b/device/qcom/sepolicy/vendor/common/bootanim.te
@@ -29,4 +29,7 @@
typeattribute bootanim system_writes_vendor_properties_violators;
binder_call(bootanim, mediaserver);
allow bootanim mediaserver_service:service_manager find;
+allow bootanim mnt_user_file:dir { getattr search open read };
+allow bootanim mnt_vendor_file:dir { getattr search open read write};
+allow bootanim mnt_vendor_file:file {open read create write};
userdebug_or_eng(`allow bootanim self:process execmem;')
diff --git a/device/qcom/sepolicy/vendor/common/domain.te b/device/qcom/sepolicy/vendor/common/domain.te
old mode 100644
new mode 100755
index 3fcbc83..3fa5e7a
--- a/device/qcom/sepolicy/vendor/common/domain.te
+++ b/device/qcom/sepolicy/vendor/common/domain.te
@@ -27,6 +27,8 @@ neverallow {
coredomain
-init
-ueventd
+ -bootanim
+ -system_app
} vendor_persist_type: { dir file } *;
allow { domain - coredomain } mnt_vendor_file:lnk_file r_file_perms;
diff --git a/device/qcom/sepolicy/vendor/common/system_app.te b/device/qcom/sepolicy/vendor/common/system_app.te
index b34b832..243f09d 100755
--- a/device/qcom/sepolicy/vendor/common/system_app.te
+++ b/device/qcom/sepolicy/vendor/common/system_app.te
@@ -227,4 +227,7 @@ allow system_app sysfs_battery_supply:file { read getattr open };
allow system_app system_data_file:dir create_dir_perms;
allow system_app system_data_file:file create_file_perms;
+allow system_app mnt_vendor_file:dir create_dir_perms;
+allow system_app mnt_vendor_file:file create_file_perms;
+
allow system_app vendor_file:file { write read open getattr};
diff --git a/frameworks/base/cmds/bootanimation/BootAnimation.cpp b/frameworks/base/cmds/bootanimation/BootAnimation.cpp
index 59851d3..60467ae 100755
--- a/frameworks/base/cmds/bootanimation/BootAnimation.cpp
+++ b/frameworks/base/cmds/bootanimation/BootAnimation.cpp
@@ -66,7 +66,7 @@
namespace android {
static const char OEM_BOOTANIMATION_FILE[] = "/oem/media/bootanimation.zip";
-static const char PRODUCT_BOOTANIMATION_FILE[] = "/data/bootanimation.zip";
+static const char PRODUCT_BOOTANIMATION_FILE[] = "/mnt/vendor/persist/bootanimation.zip";//"/data/bootanimation.zip";
static const char SYSTEM_BOOTANIMATION_FILE[] = "/system/media/bootanimation.zip";
static const char PRODUCT_ENCRYPTED_BOOTANIMATION_FILE[] = "/product/media/bootanimation-encrypted.zip";
static const char SYSTEM_ENCRYPTED_BOOTANIMATION_FILE[] = "/system/media/bootanimation-encrypted.zip";
diff --git a/packages/apps/Settings/res/layout/cw_mode_activity_main.xml b/packages/apps/Settings/res/layout/cw_mode_activity_main.xml
index 484ba75..4c233c6 100755
--- a/packages/apps/Settings/res/layout/cw_mode_activity_main.xml
+++ b/packages/apps/Settings/res/layout/cw_mode_activity_main.xml
@@ -43,6 +43,18 @@
android:text="Set bootanimation"
tools:layout_editor_absoluteX="90dp"
tools:layout_editor_absoluteY="190dp" />
+ <TextView
+ android:id="@+id/bootanexist"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="bootaimation not exists" />
+ <Button
+ android:id="@+id/remove_bootan"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="Remove bootanimation"
+ tools:layout_editor_absoluteX="90dp"
+ tools:layout_editor_absoluteY="190dp" />
</LinearLayout>
diff --git a/packages/apps/Settings/src/com/android/settings/CW_ModelActivity.java b/packages/apps/Settings/src/com/android/settings/CW_ModelActivity.java
index 087061d..4ce2e80 100755
--- a/packages/apps/Settings/src/com/android/settings/CW_ModelActivity.java
+++ b/packages/apps/Settings/src/com/android/settings/CW_ModelActivity.java
@@ -9,6 +9,7 @@ import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
+import android.widget.TextView;
import android.widget.Toast;
import java.io.File;
@@ -23,14 +24,17 @@ import android.provider.Settings.System;
import android.provider.Settings;
import android.text.BidiFormatter;
import android.os.Build;
+import android.graphics.Color;
public class CW_ModelActivity extends Activity {
- Button button ,model,updatelogo ,display;
+ Button button ,remove_bootan,model,updatelogo ,display;
EditText modeleditText, dispalyeditText;
+ TextView bootanexist;
private final String sdcardBootAnimation = "/mnt/sdcard/Android/bootanimation.zip";
private final String sdcardShutAnimation = "/mnt/sdcard/Android/shutanimation.zip";
- private final String customBootAnimation = "/data/bootanimation.zip";
+ // private final String customBootAnimation = "/data/bootanimation.zip";
+ private final String customBootAnimation = "/mnt/vendor/persist/bootanimation.zip";
private final String customShutAnimation = "/data/shutanimation.zip";
private final String customModelNumber = "/data/model";
private final String customDispaly = "/data/dispaly";
@@ -46,6 +50,8 @@ public class CW_ModelActivity extends Activity {
super.onCreate(savedInstanceState);
setContentView(R.layout.cw_mode_activity_main);
button =findViewById(R.id.button);
+ remove_bootan =findViewById(R.id.remove_bootan);
+ bootanexist =findViewById(R.id.bootanexist);
display = findViewById(R.id.dispaly);
model=findViewById(R.id.model);
modeleditText =findViewById(R.id.set_model_et);
@@ -59,6 +65,14 @@ public class CW_ModelActivity extends Activity {
modeleditText.setText(mDeviceName);
String dispaly = BidiFormatter.getInstance().unicodeWrap(Build.DISPLAY) ;
dispalyeditText.setText(dispaly);
+ if(sfile.exists()){
+ bootanexist.setText("BootAnimation is exist");
+ bootanexist.setTextColor(Color.GREEN);
+ }else{
+ bootanexist.setText("BootAnimation is null");
+ bootanexist.setTextColor(Color.GRAY);
+ }
+
button.setOnClickListener(new View.OnClickListener() {
@Override
@@ -77,6 +91,40 @@ public class CW_ModelActivity extends Activity {
}else{
Toast.makeText(getApplicationContext(),"file not exit",Toast.LENGTH_SHORT).show();
}
+
+ if(sfile.exists()){
+ bootanexist.setText("BootAnimation is exist");
+ bootanexist.setTextColor(Color.GREEN);
+ }else{
+ bootanexist.setText("BootAnimation is null");
+ bootanexist.setTextColor(Color.GRAY);
+ }
+ }
+ });
+
+ remove_bootan.setOnClickListener(new View.OnClickListener() {
+
+ @Override
+ public void onClick(View v) {
+ Log.i("--Method--", "rrrrrrrrrr remove_bootan customBootAnimation==========");
+
+ if(sfile.exists()){
+ if (sfile.delete()) {
+ Toast.makeText(getApplicationContext(),"BootAnimation exist,file is deleted",Toast.LENGTH_SHORT).show();
+ }
+
+ }else{
+ Toast.makeText(getApplicationContext(),"BootAnimation not exit",Toast.LENGTH_SHORT).show();
+ }
+
+ if(sfile.exists()){
+ bootanexist.setText("BootAnimation is exist");
+ bootanexist.setTextColor(Color.GREEN);
+ }else{
+ bootanexist.setText("BootAnimation is null");
+ bootanexist.setTextColor(Color.GRAY);
+ }
+
}
});
diff --git a/system/sepolicy/prebuilts/api/28.0/public/bootanim.te b/system/sepolicy/prebuilts/api/28.0/public/bootanim.te
index dd6a868..de41779 100755
--- a/system/sepolicy/prebuilts/api/28.0/public/bootanim.te
+++ b/system/sepolicy/prebuilts/api/28.0/public/bootanim.te
@@ -40,6 +40,14 @@ allow bootanim system_file:dir r_dir_perms;
# Read ro.boot.bootreason b/30654343
get_prop(bootanim, bootloader_boot_reason_prop)
+allow bootanim audioserver:binder call;
+
#Read the bootanimtion
allow bootanim system_data_file:dir create_dir_perms;
allow bootanim system_data_file:file {read open};
+
+allow bootanim storage_file:dir create_dir_perms;
+allow bootanim storage_file:file {read open};
+allow bootanim storage_file:lnk_file {read open};
+
+
diff --git a/system/sepolicy/prebuilts/api/28.0/public/domain.te b/system/sepolicy/prebuilts/api/28.0/public/domain.te
index 9fbbc3e..c347764 100755
--- a/system/sepolicy/prebuilts/api/28.0/public/domain.te
+++ b/system/sepolicy/prebuilts/api/28.0/public/domain.te
@@ -1410,4 +1410,6 @@ neverallow {
coredomain
-init
-ueventd
+ -bootanim
+ -system_app
} mnt_vendor_file:dir *;
diff --git a/system/sepolicy/public/bootanim.te b/system/sepolicy/public/bootanim.te
index dd6a868..de41779 100755
--- a/system/sepolicy/public/bootanim.te
+++ b/system/sepolicy/public/bootanim.te
@@ -40,6 +40,14 @@ allow bootanim system_file:dir r_dir_perms;
# Read ro.boot.bootreason b/30654343
get_prop(bootanim, bootloader_boot_reason_prop)
+allow bootanim audioserver:binder call;
+
#Read the bootanimtion
allow bootanim system_data_file:dir create_dir_perms;
allow bootanim system_data_file:file {read open};
+
+allow bootanim storage_file:dir create_dir_perms;
+allow bootanim storage_file:file {read open};
+allow bootanim storage_file:lnk_file {read open};
+
+
diff --git a/system/sepolicy/public/domain.te b/system/sepolicy/public/domain.te
index 9fbbc3e..c347764 100755
--- a/system/sepolicy/public/domain.te
+++ b/system/sepolicy/public/domain.te
@@ -1410,4 +1410,6 @@ neverallow {
coredomain
-init
-ueventd
+ -bootanim
+ -system_app
} mnt_vendor_file:dir *;