Android Q自定义开关机动画

====== Step 1: Enable MtkBootanimation ======

/vendor/mediatek/proprietary/operator/frameworks/bootanimation/Rename Android_disable.mk to Android.mk /vendor/mediatek/proprietary/operator/frameworks/bootanimation/MtkBootanimation/Rename Android_disable.mk to Android.mk /frameworks/base/cmds/bootanimation/Rename Android.bp to Android.bp-

====== Step 2: Configure MtkBootanimation lib and exe ======

/vendor/mediatek/proprietary/operator/frameworks/bootanimation/MtkBootanimation/Android.mk

#####add by songhui for Bootanimation start include $(BUILD_EXECUTABLE)#####ifeq (OP01,$(word 1,$(subst _, ,$(OPTR_SPEC_SEG_DEF))))#    ifeq ($(strip $(MTK_BSP_PACKAGE)), yes)#        include $(BUILD_EXECUTABLE)#    endif#else ifeq (OP02,$(word 1,$(subst _, ,$(OPTR_SPEC_SEG_DEF))))#    ifeq ($(strip $(MTK_BSP_PACKAGE)), yes)#        include $(BUILD_EXECUTABLE)#    endif#else ifeq (OP09,$(word 1,$(subst _, ,$(OPTR_SPEC_SEG_DEF))))#    ifeq ($(strip $(MTK_BSP_PACKAGE)), yes)#        include $(BUILD_EXECUTABLE)#    endif#    endif#########add by songhui for Bootanimation end# libbootanimation# ===========================================================+LOCAL_SHARED_LIBRARIES += libterservice+LOCAL_C_INCLUDES += $(MTK_PATH_SOURCE)/hardware/terservice/include/##### add by songhui for Bootanimation startinclude $(BUILD_SHARED_LIBRARY)######ifeq (OP01,$(word 1,$(subst _, ,$(OPTR_SPEC_SEG_DEF))))#    ifeq ($(strip $(MTK_BSP_PACKAGE)), yes)#include $(BUILD_SHARED_LIBRARY)#    endif#else ifeq (OP02,$(word 1,$(subst _, ,$(OPTR_SPEC_SEG_DEF))))#    ifeq ($(strip $(MTK_BSP_PACKAGE)), yes)#        include $(BUILD_SHARED_LIBRARY)#endif#else ifeq (OP09,$(word 1,$(subst _, ,$(OPTR_SPEC_SEG_DEF))))#    ifeq ($(strip $(MTK_BSP_PACKAGE)), yes)#        include $(BUILD_SHARED_LIBRARY)#    endif#endif#####add by songhui for Bootanimation end

====== Step 3: Add resources ======

生成自定义bootanimation.zip和shutanimation.zip,并修改Makefile将resource文件放至目录system\media\,参考写法:

$(LOCAL_PATH)/bootanimation.zip:system/media/bootanimation.zip$(LOCAL_PATH)/shutanimation.zip:system/media/shutanimation.zip

具体改法请参考FAQ03051(包括开关机铃声文件生成),动画文件格式要求请参考FAQ10590。

====== Step 4: Enable Shutdown Animation 以及关机/重启时间控制======

/vendor/mediatek/proprietary/frameworks/base/services/core/java/com/mediatek/server/MtkShutdownThread.java

    ///added for Shutdown animation @{         -private static final int MIN_SHUTDOWN_ANIMATION_PLAY_TIME = 5 * 1000;    +private static int MIN_SHUTDOWN_ANIMATION_PLAY_TIME = 5 * 1000;    @Override    protected boolean mIsShowShutdownSysui() {     +        if(SystemProperties.getInt("persist.sys.shutanimation", 0) == 0){     +            return true;+        } else        // for Shutdown animation        if(isCustBootAnim()== ANIMATION_MODE) {                 //Show Animation ,No Sysui.            return false;        }        // Show Shutdown SysUI        return true;    }    // added for Shutdown animation    private void shutdownAnimationService() {             if(isCustBootAnim()!= ANIMATION_MODE) {                     return;        }        /* M: fix shutdown animation timing issue */        Log.i(TAG, "set service.shutanim.running to 1");        SystemProperties.set("service.shutanim.running", "1");        //*/ hct.sjt, 2019-02-20, modify for reboot animation play time delay start.+        if (((MtkShutdownThread)sInstance)+                    .mContext.getResources().getBoolean(+                    com.mediatek.internal.R.bool.reboot_animation_play_time_delay) || (mReboot == true)) {     +            Log.i(TAG, "hct shutdownAnimationService delayForPlayAnimation");+            delayForPlayAnimation();+        } else if ((mReboot == true && mReason != null && mReason.equals("recovery")) ||                (mReboot == false)) {                 delayForPlayAnimation();        }    }    private boolean showShutdownAnimation(Context context) {     +        if(SystemProperties.getInt("persist.sys.shutanimation", 0) == 0){     +            return false;+        }        beginAnimationTime = 0;        if (isCustBootAnim()== ANIMATION_MODE) {                 configShutdownAnimation(context);            // Show Shutdown Animation            bootanimCust(context);            return true;        }        return false;    }    private static void bootanimCust(Context context) {             boolean isRotaionEnabled = false;        // [MTK] fix shutdown animation timing issue        SystemProperties.set("service.shutanim.running", "0");        Log.i(TAG, "set service.shutanim.running to 0");        try {                 isRotaionEnabled = Settings.System.getInt(context.getContentResolver(),                    Settings.System.ACCELEROMETER_ROTATION, 1) != 0;            if (isRotaionEnabled) {                     final IWindowManager wm = IWindowManager.Stub.asInterface(                        ServiceManager.getService(Context.WINDOW_SERVICE));                if (wm != null) {                         wm.freezeRotation(Surface.ROTATION_0);                }                Settings.System.putInt(context.getContentResolver(),                        Settings.System.ACCELEROMETER_ROTATION, 0);                Settings.System.putInt(context.getContentResolver(),                        MtkSettingsExt.System.ACCELEROMETER_ROTATION_RESTORE, 1);            }        } catch (NullPointerException ex) {                 Log.e(TAG, "check Rotation: context object is null when get Rotation");        } catch (RemoteException e) {                 e.printStackTrace();        }+        // hct add for shutdown animation play time start at 2018-05-22+        if (context.getResources().getInteger(+                com.mediatek.internal.R.integer.shutdown_animation_play_time) != 0) {     +            MIN_SHUTDOWN_ANIMATION_PLAY_TIME = context.getResources().getInteger(+                    com.mediatek.internal.R.integer.shutdown_animation_play_time);+            Log.i(TAG, "hct  mtkShutdownThread bootanimCust MIN_SHUTDOWN_ANIMATION_PLAY_TIME = " + MIN_SHUTDOWN_ANIMATION_PLAY_TIME);+        }+        // hct add for shutdown animation play time end at 2018-05-22        beginAnimationTime = SystemClock.elapsedRealtime() + MIN_SHUTDOWN_ANIMATION_PLAY_TIME;        //Disable key dispatch        try {                 final IWindowManager wm = IWindowManager.Stub.asInterface(                    ServiceManager.getService(Context.WINDOW_SERVICE));            if (wm != null) {                     wm.setEventDispatching(false);            }        } catch (RemoteException e) {                 e.printStackTrace();        }        //Disable key dispatch        startBootAnimation();    }    private static int getScreenTurnOffTime(Context context) {             int screenTurnOffTime = 0;        try {                 screenTurnOffTime = getScreenTurnOffTime();+            // hct add for shutdown animation play time start at 2018-05-22+            if (context.getResources().getInteger(+                    com.mediatek.internal.R.integer.shutdown_animation_play_time) != 0) {     +                screenTurnOffTime = context.getResources().getInteger(+                        com.mediatek.internal.R.integer.shutdown_animation_play_time);+                Log.i(TAG, "hct screen turn off time shutdown_animation_play_time =" + context.getResources().getInteger(+                        com.mediatek.internal.R.integer.shutdown_animation_play_time));+            }+            // hct add for shutdown animation play time end at 2018-05-22            Log.i(TAG, "screen turn off time screenTurnOffTime =" + screenTurnOffTime);        } catch (Exception e) {                 e.printStackTrace();        }        return screenTurnOffTime;    }    public static int isCustBootAnim() {     +        int mode = DEFAULT_MODE;+        if(mShutOffAnimation == -1) {     +            mode = ANIMATION_MODE; //Enable Shutdown Animation+            mShutOffAnimation = mode;+            Log.i(TAG,"mShutOffAnimation: " + mode);+            return mode;+        } else {                 return mShutOffAnimation;        }    }}

vendor/mediatek/proprietary/frameworks / base/res/res/values/config.xml

    <integer name="shutdown_animation_play_time">6000</integer>    <bool name="reboot_animation_play_time_delay">true</bool>

vendor/mediatek/proprietary/frameworks / base/res/res/values/symbols.xml

  <java-symbol type="integer" name="shutdown_animation_play_time" />  <java-symbol type="bool" name="reboot_animation_play_time_delay" />

====== Step5: Init AudioPath ======

vendor/mediatek/proprietary/operator/frameworks/bootanimation/MtkBootanimation/BootAnimation.cpp

#define PATH_COUNT 3// add by songhui#include <binder/IServiceManager.h>#include "ITerService.h"#define REGIONAL_BOOTANIM_GET_MNC   "persist.vendor.bootanim.mnc"// add by songhui    mAssets.addDefaultAssets();// add by songhui//    sp dtoken(SurfaceComposerClient::getBuiltInDisplay(//            ISurfaceComposer::eDisplayIdMain));  +  sp<IBinder> dtoken(SurfaceComposerClient::getInternalDisplayToken()); // add by songhui    DisplayInfo dinfo;   sp<MediaPlayer> mediaplayer;// add by songhui +   const char* resourcePath = initAudioPath();void BootAnimation::initBootanimationZip() {         ZipFileRO* zipFile = NULL;    String8     ZipFileName;// add by songhui+    char BootanimFileName[PROPERTY_VALUE_MAX];#ifdef MSSI_MTK_CARRIEREXPRESS_PACK    char OPTR[PROPERTY_VALUE_MAX];

====== Step6: Add mtkbootanimation Packages ======

Add mtkbootanimation packages to device.mk, and make clean before rebuild all load.

Add below codes in alps\device\mediatek$(platform_name)\device.mk

ifeq ($(strip $(HCT_BOOTANIM)), yes)    PRODUCT_SYSTEM_DEFAULT_PROPERTIES += \    persist.sys.bootanimation=1 endififeq ($(strip $(HCT_SHUTANIM)), yes)    PRODUCT_SYSTEM_DEFAULT_PROPERTIES += \    persist.sys.shutanimation=1 endif  PRODUCT_PACKAGES += mtkbootanimation \                        libmtkbootanimation

====== Step7: add selinux ======
/device/mediatek/sepolicy/basic/non_plat/mtkbootanimation.te
#add
#add by songhui

allowxperm mtkbootanimation proc_ged:file ioctl {     0x6700 0x6704 0x6765 0x6766 0x6767};allowxperm mtkbootanimation proc_perfmgr:file ioctl {     0x6701 0x6703 0x6710 0x6763 0x670f};

#add
====== Step8: 解决首次开机无铃声======
frameworks/av/services/audioflinger/Threads.cpp

                // if stream volume was successfully sent to the HAL, mLeftVolFloat == v here and we                // remove stream volume contribution from software volume.                if (v != 0.0f && mLeftVolFloat == v) {                        vlf = min(1.0f, vlf / v);                   vrf = min(1.0f, vrf / v);                   vaf = min(1.0f, vaf / v);               }            }//add by songhui beginchar mvalue[PROPERTY_VALUE_MAX] = {      1 };property_get("service.bootanim.exit", mvalue, "");if (strcmp(mvalue,"0") == 0){     ALOGE("bootanim volume setting");vlf = 0.25f;vrf = 0.25f;}//add by songhui end                        // XXX: these things DON'T need to be done each time            mAudioMixer->setBufferProvider(trackId, track);            mAudioMixer->enable(trackId);

device/mediatek/sepolicy/basic/non_plat/audioserver.te

# add boot audioallow audioserver bootanim:binder call;

更多相关文章

  1. Android使用GET_CONTENT Action获取打开相应文件类型的应用
  2. Android简单文件浏览器源代码
  3. android播放音频文件(MediaPlayer)和录音(MediaRecorder)--播放
  4. 文件操作与SDCard读写访问
  5. Android Studio 小技巧(1):如何导入AAR文件
  6. android 开发-文件存储之读写sdcard
  7. 怎么在android的XML文件里加入凝视
  8. android下大文件分割上传

随机推荐

  1. Android中系统自带的锁:WalkLock、Keyguar
  2. Android(安卓)沉浸式状态栏归纳
  3. Android(安卓)- Unable to execute dex:
  4. Android,一个函数实现摇一摇
  5. Android(安卓)依赖注入: Dagger 2 实例讲
  6. 状态栏提示Notification
  7. android使用广播退出应用程序
  8. 第九章、 四大组件的工作过程
  9. Android的OutOfMemory解决
  10. 探讨NDK编译错误ld.exe: Dwarf Error: ma