idea_1:use ota replace bootanimation.zip
idea_2:创建一个新的分区,(用于存放bootanimation.zip)可以让上层读写.
idea_3:su cp
前提条件:userdebug版本, 默认关闭selLinux,可root
//df 查看设备分区情况,有些分区系统是不让去写的
adb shell
c4_t:/ $ df
Filesystem 1K-blocks Used Available Use% Mounted on
tmpfs 1001636 1296 1000340 1% /dev
tmpfs 1001636 0 1001636 0% /mnt
/dev/block/mmcblk2p11 10224 120 9620 2% /metadata
/dev/block/dm-0 977764 974804 0 100% /
/dev/block/dm-3 279816 278964 0 100% /vendor
/dev/block/dm-8 22236 22168 0 100% /odm
/dev/block/dm-1 232 36 192 16% /system_dlkm
/dev/block/dm-2 173584 173064 0 100% /system_ext
找到一个可以被命令操作的分区,然后复制动画.
IntentFilter intentFilter = new IntentFilter();
intentFilter.addAction(Intent.ACTION_MEDIA_MOUNTED);
intentFilter.addDataScheme("file");
registerReceiver(AnimationReceiver,intentFilter);
BroadcastReceiver AnimationReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
if (intent.getAction().equals(Intent.ACTION_MEDIA_MOUNTED)) {
String path = intent.getData().getPath() + "/bootanimation.zip";
File file = new File(path);
if (file.exists()) {
long file_size = file.length();
long file_mb = file_size / 1048576;
Log.d("tag", "file_mb size of = " + file_mb + "MB");
if (file_mb <= 30) {
execRootCmd(path);
}
}
}
}
};
private int execRootCmd(String path) {
int result = -1;
DataOutputStream dos = null;
try {
java.lang.Process process = Runtime.getRuntime().exec("/system/xbin/su");
dos = new DataOutputStream(process.getOutputStream());
dos.writeBytes("mount -o rw,remount /dev/block/dm-8 /odm" + "\n");//利用命令挂载
File seat_file = new File("/odm/boot/seat.zip");
if (seat_file.exists()) {
dos.writeBytes("rm -rf /odm/boot/seat.zip" + "\n");
dos.flush();
}
File mfile = new File("/odm/boot/");
if (!mfile.exists()) {
dos.writeBytes("mkdir /odm/boot/" + "\n");
dos.flush();
}
dos.writeBytes("cp " + path + " /odm/boot/" + "\n");
dos.flush();
dos.writeBytes("chmod 644 odm/boot/bootanimation.zip" + "\n");
dos.flush();
SystemClock.sleep(500);
dos.writeBytes("reboot\n");
dos.flush();
dos.writeBytes("exit\n");
dos.flush();
process.waitFor();
result = process.exitValue();
} catch (Exception e) {
e.printStackTrace();
} finally {
if (dos != null) {
try {
dos.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
return result;
}
补充:
Android Q(10)开始引进动态分区,分区的大小不好确定.可以去配置文件固定分区大小(不让其动态),或者弄一个文件占位.
bug:Android T bootanimation 时间过长(>50s),会触发bug,现象为System UI ANR.
BootAnimationShownTiming start time: 8562ms
BootAnimationShownTiming End time: 71253ms
BootAnimationStopTiming start time: 72395ms
error log:
2024-08-23 11:34:01.055 642-657 system_server system_process W Long monitor contention with owner binder:642_4 (811) at void com.android.server.am.ActivityManagerService.attachApplication(android.app.IApplicationThread, long)(ActivityManagerService.java:5061) waiters=2 in android.content.Intent com.android.server.am.ActivityManagerService.registerReceiverWithFeature(android.app.IApplicationThread, java.lang.String, java.lang.String, java.lang.String, android.content.IIntentReceiver, android.content.IntentFilter, java.lang.String, int, int) for 200ms
2024-08-23 11:34:01.160 642-669 system_server system_process W Long monitor contention with owner binder:642_3 (709) at void com.android.server.am.ActivityManagerService$AppDeathRecipient.binderDied()(ActivityManagerService.java:1479) waiters=3 in void com.android.server.am.BroadcastQueue.processNextBroadcast(boolean) for 315ms
2024-08-23 11:34:02.144 642-709 system_server system_process W Long monitor contention with owner binder:642_1 (656) at void com.android.server.am.CachedAppOptimizer.unfreezeTemporarily(com.android.server.am.ProcessRecord, java.lang.String)(CachedAppOptimizer.java:1045) waiters=0 in com.android.server.am.ProcessRecord com.android.server.am.ActivityManagerService.findAppProcess(android.os.IBinder, java.lang.String) for 218ms
2024-08-23 11:34:03.493 642-811 system_server system_process W Long monitor contention with owner PackageManager (699) at void com.android.server.pm.permission.LegacyPermissionSettings.writePermissionTrees(android.util.TypedXmlSerializer)(LegacyPermissionSettings.java:150) waiters=0 in com.android.server.pm.Computer com.android.server.pm.PackageManagerService.snapshotComputer() for 404ms
2024-08-23 11:34:07.830 642-663 system_server system_process W Long monitor contention with owner binder:642_2 (657) at void com.android.server.wm.ActivityClientController.setTaskDescription(android.os.IBinder, android.app.ActivityManager$TaskDescription)(ActivityClientController.java:1068) waiters=0 in void com.android.server.wm.ActivityRecord$2.run() for 732ms
2024-08-23 11:34:13.025 642-642 system_server system_process W Long monitor contention with owner ActivityManager (669) at void com.android.server.am.BroadcastQueue.processNextBroadcast(boolean)(BroadcastQueue.java:1156) waiters=0 in int com.android.server.am.ActivityManagerService.broadcastIntentWithFeature(android.app.IApplicationThread, java.lang.String, android.content.Intent, java.lang.String, android.content.IIntentReceiver, int, java.lang.String, android.os.Bundle, java.lang.String[], java.lang.String[], java.lang.String[], int, android.os.Bundle, boolean, boolean, int) for 370ms
2024-08-23 11:34:16.457 642-663 system_server system_process W Long monitor contention with owner binder:642_2 (657) at boolean com.android.server.wm.WindowManagerService.hasNavigationBar(int)(WindowManagerService.java:6591) waiters=0 in void com.android.server.wm.ActivityTaskManagerService$SleepTokenAcquirerImpl.release(int) for 128ms
2024-08-23 11:34:18.253 642-811 system_server system_process W Long monitor contention with owner binder:642_5 (998) at android.app.ContentProviderHolder com.android.server.am.ContentProviderHelper.getContentProviderImpl(android.app.IApplicationThread, java.lang.String, android.os.IBinder, int, java.lang.String, java.lang.String, boolean, int)(ContentProviderHelper.java:587) waiters=0 in android.content.Intent com.android.server.am.ActivityManagerService.registerReceiverWithFeature(android.app.IApplicationThread, java.lang.String, java.lang.String, java.lang.String, android.content.IIntentReceiver, android.content.IntentFilter, java.lang.String, int, int) for 1.930s
2024-08-23 11:34:18.666 642-663 system_server system_process W Long monitor contention with owner binder:642_5 (998) at android.app.ContentProviderHolder com.android.server.am.ContentProviderHelper.getContentProviderImpl(android.app.IApplicationThread, java.lang.String, android.os.IBinder, int, java.lang.String, java.lang.String, boolean, int)(ContentProviderHelper.java:587) waiters=2 in void com.android.server.am.ActivityManagerService.trimApplications(boolean, java.lang.String) for 1.377s
2024-08-23 11:34:20.096 642-663 system_server system_process W Long monitor contention with owner android.bg (668) at void com.android.server.am.AppProfiler.collectPssInBackground()(AppProfiler.java:535) waiters=0 in void com.android.server.am.AppProfiler.requestPssAllProcsLPr(long, boolean, boolean) for 444ms
2024-08-23 11:34:20.610 642-660 system_server system_process W Long monitor contention with owner watchdog (666) at void java.lang.Object.wait(long, int)(Object.java:-2) waiters=0 in void com.android.server.Watchdog$HandlerChecker.run() for 159ms
2024-08-23 11:34:24.251 642-661 system_server system_process W Long monitor contention with owner android.anim (664) at void com.android.server.wm.WindowSurfacePlacer$Traverser.run()(WindowSurfacePlacer.java:58) waiters=0 in boolean com.android.server.wm.DisplayPolicy.finishWindowsDrawn() for 2.290s
2024-08-23 11:34:25.777 642-661 system_server system_process W Long monitor contention with owner android.display (663) at void com.android.server.wm.WindowManagerService.performEnableScreen()(WindowManagerService.java:3772) waiters=0 in boolean com.android.server.wm.DisplayPolicy.finishScreenTurningOn() for 1.188s
2024-08-23 11:34:25.853 642-664 system_server system_process W Long monitor contention with owner android.display (663) at void com.android.server.wm.WindowManagerService.performEnableScreen()(WindowManagerService.java:3772) waiters=1 in void com.android.server.wm.WindowAnimator.lambda$new$1(long) for 954ms
2024-08-23 11:34:27.471 642-661 system_server system_process W Long monitor contention with owner android.anim (664) at void com.android.server.wm.WindowAnimator.lambda$new$1(long)(WindowAnimator.java:110) waiters=0 in void com.android.server.wm.WindowManagerService.enableScreenIfNeeded() for 1.108s
2024-08-23 11:34:28.244 642-660 system_server system_process W Long monitor contention with owner android.anim (664) at void com.android.server.wm.WindowAnimator.lambda$new$1(long)(WindowAnimator.java:110) waiters=1 in void com.android.server.wm.WindowManagerService.monitor() for 1.279s
2024-08-23 11:34:29.151 642-1070 system_server system_process W Long monitor contention with owner android.display (663) at void com.android.server.wm.WindowManagerService.performEnableScreen()(WindowManagerService.java:3772) waiters=0 in void com.android.server.wm.WindowProcessController.appEarlyNotResponding(java.lang.String, java.lang.Runnable) for 534ms
2024-08-23 11:34:34.274 642-669 system_server system_process W Long monitor contention with owner binder:642_4 (811) at android.content.Intent com.android.server.am.ActivityManagerService.registerReceiverWithFeature(android.app.IApplicationThread, java.lang.String, java.lang.String, java.lang.String, android.content.IIntentReceiver, android.content.IntentFilter, java.lang.String, int, int)(ActivityManagerService.java:13371) waiters=2 in void com.android.server.am.BroadcastQueue.processNextBroadcast(boolean) for 570ms
2024-08-23 11:34:35.356 642-1070 system_server system_process W Long monitor contention with owner binder:642_4 (811) at android.content.Intent com.android.server.am.ActivityManagerService.registerReceiverWithFeature(android.app.IApplicationThread, java.lang.String, java.lang.String, java.lang.String, android.content.IIntentReceiver, android.content.IntentFilter, java.lang.String, int, int)(ActivityManagerService.java:13371) waiters=3 in void com.android.server.am.ProcessErrorStateRecord.appNotResponding(java.lang.String, android.content.pm.ApplicationInfo, java.lang.String, com.android.server.wm.WindowProcessController, boolean, java.lang.String, boolean) for 1.602s
2024-08-23 11:34:37.001 642-780 system_server system_process W Long monitor contention with owner main (642) at java.util.Set com.android.server.audio.AudioService.getDeviceSetForStream(int)(AudioService.java:7020) waiters=0 in int com.android.server.audio.AudioService$VolumeStreamState.getIndex(int) for 6.290s
2024-08-23 11:34:37.494 642-678 system_server system_process W Long monitor contention with owner binder:642_1 (656) at void com.android.server.wallpaper.WallpaperManagerService.extractColors(com.android.server.wallpaper.WallpaperManagerService$WallpaperData)(WallpaperManagerService.java:555) waiters=0 in com.android.server.wallpaper.WallpaperManagerService$WallpaperData com.android.server.wallpaper.WallpaperManagerService$WallpaperObserver.dataForEvent(boolean, boolean) for 143ms
2024-08-23 11:34:38.890 642-811 system_server system_process W Long monitor contention with owner binder:642_5 (998) at void com.android.server.am.ActivityManagerService.publishService(android.os.IBinder, android.content.Intent, android.os.IBinder)(ActivityManagerService.java:12760) waiters=2 in android.content.Intent com.android.server.am.ActivityManagerService.registerReceiverWithFeature(android.app.IApplicationThread, java.lang.String, java.lang.String, java.lang.String, android.content.IIntentReceiver, android.content.IntentFilter, java.lang.String, int, int) for 616ms
2024-08-23 11:34:40.702 642-642 system_server system_process W Long monitor contention with owner android.bg (668) at void com.android.server.am.ProcessProfileRecord.addPss(long, long, long, boolean, int, long)(ProcessProfileRecord.java:578) waiters=0 in void com.android.server.am.OomAdjuster.updateOomAdjInnerLSP(java.lang.String, com.android.server.am.ProcessRecord, java.util.ArrayList, com.android.server.am.ActiveUids, boolean, boolean) for 269ms
2024-08-23 11:34:40.822 642-811 system_server system_process W Long monitor contention with owner main (642) at void com.android.server.am.ActivityManagerService.finishReceiver(android.os.IBinder, int, java.lang.String, android.os.Bundle, boolean, int)(ActivityManagerService.java:14648) waiters=0 in void com.android.server.am.ActivityManagerService$AppDeathRecipient.binderDied() for 1.284s
2024-08-23 11:34:43.842 642-686 system_server system_process W Long monitor contention with owner NetworkStats (758) at void com.android.server.power.PowerManagerService.acquireWakeLockInternal(android.os.IBinder, int, int, java.lang.String, java.lang.String, android.os.WorkSource, java.lang.String, int, int, android.os.IWakeLockCallback)(PowerManagerService.java:1559) waiters=0 in void com.android.server.power.PowerManagerService.handleSandman(int) for 562ms
2024-08-23 11:34:45.131 642-716 system_server system_process W Long monitor contention with owner WifiHandlerThread (761) at void com.android.server.alarm.AlarmManagerService$DeliveryTracker.alarmComplete(android.os.IBinder)(AlarmManagerService.java:5549) waiters=0 in void com.android.server.alarm.AlarmManagerService$9.updateAlarmsForUid(int) for 239ms
2024-08-23 11:34:45.131 642-676 system_server system_process W Long monitor contention with owner batterystats-handler (675) at void com.android.server.am.BatteryStatsService.lambda$noteAlarmFinish$21(java.lang.String, android.os.WorkSource, int, long, long)(BatteryStatsService.java:1001) waiters=0 in void com.android.server.am.BatteryStatsService.lambda$setBatteryState$95(int, int, int, int, int, int, int, int, long, long, long, long) for 400ms
2024-08-23 11:34:45.135 945-945 m.android.phone com.android.phone W Long monitor contention with owner SharedPreferencesImpl-load (1076) at void android.app.SharedPreferencesImpl.loadFromDisk()(SharedPreferencesImpl.java:154) waiters=0 in java.lang.String android.app.SharedPreferencesImpl.getString(java.lang.String, java.lang.String) for 404ms
2024-08-23 11:34:45.718 642-1074 system_server system_process W Long monitor contention with owner binder:642_4 (811) at com.android.server.am.ProcessRecord com.android.server.am.ProcessList.removeProcessNameLocked(java.lang.String, int, com.android.server.am.ProcessRecord)(ProcessList.java:3064) waiters=0 in boolean com.android.server.am.ActivityManagerService.isUidActive(int, java.lang.String) for 657ms
2024-08-23 11:34:47.311 642-760 system_server system_process W Long monitor contention with owner NetworkStats (758) at void com.android.server.net.NetworkStatsService.performPoll(int)(NetworkStatsService.java:2270) waiters=0 in void com.android.server.net.NetworkStatsService.noteUidForeground(int, boolean) for 1.155s
2024-08-23 11:34:47.659 642-811 system_server system_process W Long monitor contention with owner android.display (663) at void com.android.server.wm.WindowManagerService.performEnableScreen()(WindowManagerService.java:3822) waiters=0 in void com.android.server.wm.ActivityTaskManagerService$LocalService.clearHeavyWeightProcessIfEquals(com.android.server.wm.WindowProcessController) for 1.928s
2024-08-23 11:34:47.660 642-656 system_server system_process W Long monitor contention with owner android.display (663) at void com.android.server.wm.WindowManagerService.performEnableScreen()(WindowManagerService.java:3822) waiters=1 in float com.android.server.wm.WindowManagerService.getCurrentAnimatorScale() for 288ms
2024-08-23 11:34:47.668 642-660 system_server system_process W Long monitor contention with owner binder:642_4 (811) at void com.android.server.am.ActivityManagerService$AppDeathRecipient.binderDied()(ActivityManagerService.java:1479) waiters=1 in android.app.ActivityManagerInternal$ServiceNotificationPolicy com.android.server.am.ActivityManagerService$LocalService.applyForegroundServiceNotification(android.app.Notification, java.lang.String, int, java.lang.String, int) for 4.375s
2024-08-23 11:34:47.670 642-777 system_server system_process W Long monitor contention with owner binder:642_4 (811) at void com.android.server.am.ActivityManagerService$AppDeathRecipient.binderDied()(ActivityManagerService.java:1479) waiters=2 in android.content.Intent com.android.server.am.ActivityManagerService.registerReceiverWithFeature(android.app.IApplicationThread, java.lang.String, java.lang.String, java.lang.String, android.content.IIntentReceiver, android.content.IntentFilter, java.lang.String, int, int) for 2.980s
2024-08-23 11:34:47.671 642-642 system_server system_process W Long monitor contention with owner binder:642_4 (811) at void com.android.server.am.ActivityManagerService$AppDeathRecipient.binderDied()(ActivityManagerService.java:1479) waiters=3 in android.content.Intent com.android.server.am.ActivityManagerService.registerReceiverWithFeature(android.app.IApplicationThread, java.lang.String, java.lang.String, java.lang.String, android.content.IIntentReceiver, android.content.IntentFilter, java.lang.String, int, int) for 1.415s
2024-08-23 11:34:51.085 642-1314 UnsafeUtil system_process W platform method missing - proto runtime falling back to safer methods: java.lang.NoSuchMethodException: sun.misc.Unsafe.copyMemory [class java.lang.Object, long, class java.lang.Object, long, long]
2024-08-23 11:34:51.439 642-675 system_server system_process W Long monitor contention with owner batterystats-worker (676) at void com.android.server.am.BatteryExternalStatsWorker.updateExternalStatsLocked(java.lang.String, int, boolean, boolean, int, int[], boolean)(BatteryExternalStatsWorker.java:733) waiters=0 in void com.android.server.am.BatteryStatsService.lambda$noteStartWakelockFromSource$24(android.os.WorkSource, int, java.lang.String, java.lang.String, int, boolean, long, long) for 242ms
2024-08-23 11:34:52.182 642-1323 system_server system_process W Long monitor contention with owner backup (793) at void com.android.server.backup.UserBackupManagerService.initPackageTracking()(UserBackupManagerService.java:949) waiters=0 in void com.android.server.backup.UserBackupManagerService.dataChangedImpl(java.lang.String, java.util.HashSet) for 434ms
2024-08-23 11:34:52.546 642-793 system_server system_process W Long monitor contention with owner backup-0 (1323) at void com.android.server.backup.UserBackupManagerService.dataChangedImpl(java.lang.String, java.util.HashSet)(UserBackupManagerService.java:2495) waiters=0 in void com.android.server.backup.UserBackupManagerService.updateStateOnBackupEnabled(boolean, boolean) for 328ms
2024-08-23 11:34:52.895 642-657 system_server system_process W Long monitor contention with owner android.bg (668) at com.android.server.search.Searchables com.android.server.search.SearchManagerService.getSearchables(int, boolean)(SearchManagerService.java:130) waiters=0 in com.android.server.search.Searchables com.android.server.search.SearchManagerService.getSearchables(int, boolean) for 269ms
2024-08-23 11:34:53.321 1263-1263 UnsafeUtil com.android.launcher3 W platform method missing - proto runtime falling back to safer methods: java.lang.NoSuchMethodException: sun.misc.Unsafe.copyMemory [class java.lang.Object, long, class java.lang.Object, long, long]
2024-08-23 11:34:57.869 826-838 ndroid.systemui com.android.systemui I JIT allocated 55KB for compiled code of void androidx.constraintlayout.motion.widget.MotionController.setup(int, int, long)
2024-08-23 11:34:57.870 826-838 ndroid.systemui com.android.systemui I Compiler allocated 4812KB to compile void androidx.constraintlayout.motion.widget.MotionController.setup(int, int, long)
2024-08-23 11:34:59.236 826-838 ndroid.systemui com.android.systemui I JIT allocated 55KB for compiled code of void androidx.constraintlayout.motion.widget.MotionController.setup(int, int, long)
2024-08-23 11:34:59.236 826-838 ndroid.systemui com.android.systemui I Compiler allocated 4806KB to compile void androidx.constraintlayout.motion.widget.MotionController.setup(int, int, long)
2024-08-23 11:35:00.261 826-838 ndroid.systemui com.android.systemui I JIT allocated 55KB for compiled code of void androidx.constraintlayout.motion.widget.MotionController.setup(int, int, long)
2024-08-23 11:35:00.262 826-838 ndroid.systemui com.android.systemui I Compiler allocated 4806KB to compile void androidx.constraintlayout.motion.widget.MotionController.setup(int, int, long)
2024-08-23 11:35:00.697 826-838 ndroid.systemui com.android.systemui I JIT allocated 55KB for compiled code of void androidx.constraintlayout.motion.widget.MotionController.setup(int, int, long)
2024-08-23 11:35:00.698 826-838 ndroid.systemui com.android.systemui I Compiler allocated 4806KB to compile void androidx.constraintlayout.motion.widget.MotionController.setup(int, int, long)
2024-08-23 11:35:10.241 642-669 ActivityManager system_process I Waited long enough for: ServiceRecord{374152a u0 com.rockchip.devicetest/.service.TestService}
(希望大神能指导,给个bug解决思路)