插入SD卡后自动运行SD卡根目录中的AutoRun.sh以实现动态替换linux logo,init logo和开机动画、安装SD卡中指定目录中的apk到系统中等

发布时间:2016-12-11 6:39:39 编辑:www.fx114.net 分享查询网我要评论
本篇文章主要介绍了"插入SD卡后自动运行SD卡根目录中的AutoRun.sh以实现动态替换linux logo,init logo和开机动画、安装SD卡中指定目录中的apk到系统中等",主要涉及到插入SD卡后自动运行SD卡根目录中的AutoRun.sh以实现动态替换linux logo,init logo和开机动画、安装SD卡中指定目录中的apk到系统中等方面的内容,对于插入SD卡后自动运行SD卡根目录中的AutoRun.sh以实现动态替换linux logo,init logo和开机动画、安装SD卡中指定目录中的apk到系统中等感兴趣的同学可以参考一下。

需求:“在工程版机器上插入SD卡后自动运行SD卡根目录中的AutoRun.sh以实现动态替换linux logo,init logo和开机动画、安装SD卡中指定目录中的apk到系统中等” 实现: 1) 修改device/vendor/productname/init.productname.rc文末添加以下内容: # added by deepin for: do autorun once an extra sd card inserted. 2013.09.02 ..start service extsdautorun /system/bin/busybox sh /mnt/extsd/AutoRun.sh     class main     user root     group root     disabled     oneshot on property:sys.extsdinserted=1     start extsdautorun on property:sys.extsdinserted=0     stop extsdautorun # added by deepin for: do autorun once an extra sd card inserted. 2013.09.02 ..end 2) 按如下所示修改frameworks/base/services/java/com/android/server/MountService.java:         // Tell PackageManager about changes to primary volume state, but only         // when not emulated.         if (volume.isPrimary() && !volume.isEmulated()) {             if (Environment.MEDIA_UNMOUNTED.equals(state)) {                 mPms.updateExternalMediaStatus(false, false);                 /*                  * Some OBBs might have been unmounted when this volume was                  * unmounted, so send a message to the handler to let it know to                  * remove those from the list of mounted OBBS.                  */                 mObbActionHandler.sendMessage(mObbActionHandler.obtainMessage(                         OBB_FLUSH_MOUNT_STATE, path));             } else if (Environment.MEDIA_MOUNTED.equals(state)) {                 mPms.updateExternalMediaStatus(true, false);             }         }               // added by deepin for: do autorun once an extra sd card inserted. 2013.09.02 ..start         Slog.d(TAG, "deepin volume state changed for " + path                 + " (" + oldState + " -> " + state + ")");         if (!volume.isPrimary() && !volume.isEmulated()) {             Slog.d(TAG, "deepin eee volume state changed for " + path                     + " (" + oldState + " -> " + state + ")");             if (Environment.MEDIA_UNMOUNTED.equals(state)) {                 if (path.equals("/mnt/extsd")) {                     SystemProperties.set("sys.extsdinserted", "0");                     Slog.d(TAG, "deepin extsd unmounted");                 }             } else if (Environment.MEDIA_MOUNTED.equals(state)) {                 if (path.equals("/mnt/extsd")) {                     SystemProperties.set("sys.extsdinserted", "1");                     Slog.d(TAG, "deepin extsd mounted");                 }             }         }      // added by deepin for: do autorun once an extra sd card inserted. 2013.09.02 ..end                  synchronized (mListeners) { 编译: mmm frameworks/base/services/java/ -j16   3) 写一个AudoRun.sh,内容如下: #!/system/bin/busybox sh echo "autorun job started" # enable adb setprop persist.service.adb.enable 1 # replace linux logo echo "replace linux logo..." busybox mkdir /mynanda busybox mount -t vfat /dev/block/nanda /mynanda busybox cp -rf /mnt/extsd/logo/linux.bmp  /mynanda/linux/linux.bmp  chmod 700 /mynanda/linux/linux.bmp busybox umount /mynanda busybox rmdir /mynanda && echo "linux logo replaced."  # replace init logo echo "replace init logo..." busybox cp -rf /mnt/extsd/logo/initlogo.rle /system/media/initlogo.rle && echo "init logo replaced."  chmod 664 /system/media/initlogo.rle # replace boot animation echo "replace boot animation..." rm /data/local/bootanimation.zip busybox cp -rf /mnt/extsd/logo/bootanimation.zip  /system/media/bootanimation.zip && echo "boot animation replaced." chmod 664 /system/media/bootanimation.zip # install apks echo "install apks..." busybox find /mnt/extsd/apk -name *.apk | busybox xargs /system/bin/sh /system/bin/pm install -r /system/bin/sh /system/bin/am start -a android.intent.action.VIEW -d "javascript:alert('All done, eject the sd card please.');" -n com.android.browser/com.android.browser.BrowserActivity 将AutoRun.sh放入SD卡的根目录下。 说明: a. 将要安装的apk放到SD卡的根目录下的“apk”文件夹内 b. 将要替换的linux logo重命名为“linux.bmp”并放到SD卡的根目录下的“logo”文件夹内 c. 将要替换的linux logo重命名为“initlogo.rle”并放到SD卡的根目录下的“logo”文件夹内 d. 将要替换的linux logo重命名为“bootanimation.zip”并放到SD卡的根目录下的“logo”文件夹内 4) initlogo.rle: a. 按如下所示修改:system/core/init/init.h //#define INIT_IMAGE_FILE    "/initlogo.rle" //comed by deepin for: put initlogo.rle in /system/media/. 2013.09.03 #define INIT_IMAGE_FILE    "/system/media/initlogo.rle" //added by deepin for: put initlogo.rle in /system/media/. 2013.09.03 b. 按如下所示修改:system/core/init/init.c     queue_builtin_action(wait_for_coldboot_done_action, "wait_for_coldboot_done");     queue_builtin_action(keychord_init_action, "keychord_init");     //queue_builtin_action(console_init_action, "console_init"); // comed by deepin for: put initlogo.rle in /system/media/. 2013.09.03     /* execute all the boot actions to get us started */ ...     /* skip mounting filesystems in charger mode */     if (!is_charger) {         action_for_each_trigger("early-fs", action_add_queue_tail);         action_for_each_trigger("fs", action_add_queue_tail);         action_for_each_trigger("post-fs", action_add_queue_tail);         action_for_each_trigger("post-fs-data", action_add_queue_tail);         queue_builtin_action(console_init_action, "console_init");// added by deepin for: put initlogo.rle in /system/media/. 2013.09.03     } c. 注意:initlogo.rle文件的分辨率要跟屏的分辨率匹配。 4) 重新编译android: make -j16 && pack (完)

上一篇:管理员如何操作才能提高raid5数据恢复成功率
下一篇:二叉搜索树的创建、遍历、插入、删除(C++版本)

相关文章

相关评论