MTK Android 13平台开关机动画铃声客制化
MTK Android 13平台开关机动画铃声客制化
Android T和S的差异很大
主要是MtkShutdownThread.java和ShutdownThread.java差异
未完,待更新,填坑
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-
2.Configure MtkBootanimation Android.mk
vendor/mediatek/proprietary/operator/frameworks/bootanimation/MtkBootanimation/Android.mk
直接覆盖原来mk文件即可
bootanimation_CommonCFlags = -DGL_GLEXT_PROTOTYPES -DEGL_EGLEXT_PROTOTYPES
#####add by tom for Bootanimation start
#bootanimation_CommonCFlags += -Wall -Werror -Wunused -Wunreachable-code
bootanimation_CommonCFlags += -Wall -Werror -Wunused -Wunreachable-code -Wno-deprecated-declarations# bootanimation executable
# =========================================================LOCAL_PATH:= $(call my-dir)
include $(CLEAR_VARS)LOCAL_CFLAGS += ${bootanimation_CommonCFlags}LOCAL_SHARED_LIBRARIES := \libOpenSLES \libandroidfw \libbase \libbinder \libmtkbootanimation \libcutils \liblog \libutils \LOCAL_SRC_FILES:= \BootAnimationUtil.cpp \#ifeq ($(PRODUCT_IOT),true)
#LOCAL_SRC_FILES += \
# iot/iotbootanimation_main.cpp \
# iot/BootAction.cpp#LOCAL_SHARED_LIBRARIES += \
# libandroidthings \
# libbase \
# libbinder#LOCAL_STATIC_LIBRARIES += cpufeatures#elseLOCAL_SRC_FILES += \bootanimation_main.cpp \audioplay.cpp \#endif # PRODUCT_IOTLOCAL_MODULE:= mtkbootanimationLOCAL_INIT_RC := mtkbootanim.rcifdef TARGET_32_BIT_SURFACEFLINGER
LOCAL_32_BIT_ONLY := true
endif
#####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
# ===========================================================include $(CLEAR_VARS)
LOCAL_MODULE := libmtkbootanimation
LOCAL_CFLAGS += ${bootanimation_CommonCFlags}LOCAL_SRC_FILES:= \BootAnimation.cpp# add by songhui
# ifdef MSSI_MTK_CARRIEREXPRESS_PACK
# ifneq ($(strip $(MSSI_MTK_CARRIEREXPRESS_PACK)), no)
# LOCAL_CFLAGS += -DMSSI_MTK_CARRIEREXPRESS_PACK
# LOCAL_CPPFLAGS += -DMSSI_MTK_CARRIEREXPRESS_PACK
# endif
# endifLOCAL_CFLAGS += ${bootanimation_CommonCFlags}
LOCAL_C_INCLUDES += \external/tinyalsa/include \frameworks/wilhelm/include#### merge from frameworks/base/cmds/bootanimation by tom
###libhwui ----> libjnigraphics
LOCAL_SHARED_LIBRARIES := \libcutils \liblog \libandroidfw \libutils \libbinder \libui \libjnigraphics \libEGL \libETC1 \libGLESv2 \libmedia \libGLESv1_CM \libgui \libtinyalsa \libbaseLOCAL_SHARED_LIBRARIES += libterservice
LOCAL_C_INCLUDES += $(MTK_PATH_SOURCE)/hardware/terservice/include/LOCAL_C_INCLUDES += $(TOP)/$(MTK_ROOT)/frameworks-ext/native/include
LOCAL_C_INCLUDES += external/skia/include
ifdef TARGET_32_BIT_SURFACEFLINGER
LOCAL_32_BIT_ONLY := true
endif##### add by songhui for Bootanimation start
include $(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
3.vendor/mediatek/proprietary/frameworks/bootanimation/MtkBootanimation/BootAnimation.cpp
index 9a6706a..a23d62b 100644
@@ -16,6 +16,7 @@#define LOG_NDEBUG 0#define LOG_TAG "MtkBootAnimation"
+#include <vector>#include <stdint.h>#include <inttypes.h>
@@ -30,9 +31,10 @@#include <time.h>#include <string.h>-
+#include <cutils/atomic.h>#include <cutils/properties.h>+#include <android/imagedecoder.h>#include <androidfw/AssetManager.h>#include <binder/IPCThreadState.h>#include <utils/Atomic.h>
@@ -45,18 +47,16 @@#include <ui/PixelFormat.h>#include <ui/Rect.h>#include <ui/Region.h>
-#include <ui/DisplayInfo.h>
+#include <ui/DisplayMode.h>#include <gui/ISurfaceComposer.h>
+#include <gui/DisplayEventReceiver.h>#include <gui/Surface.h>#include <gui/SurfaceComposerClient.h>// TODO: Fix Skia.#pragma GCC diagnostic push#pragma GCC diagnostic ignored "-Wunused-parameter"
-#include <SkBitmap.h>
-#include <SkImage.h>
-#include <SkStream.h>#pragma GCC diagnostic pop#include <GLES/gl.h>
@@ -76,8 +76,11 @@#include <binder/Parcel.h>#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#ifdef MSSI_MTK_CARRIEREXPRESS_PACK#define GLOBAL_DEVICE_BOOTANIM_OPTR_NAME "persist.vendor.operator.optr"#define PATH_COUNT_USP 2
@@ -123,6 +126,9 @@ static const char* mResourcePath[MNC_COUNT][PATH_COUNT] =namespace android {+// merge from frameworks/base/cmds/bootanimation by tom
+using ui::DisplayMode;
+static const char CUSTOM_BOOTANIMATION_FILE[] = "/custom/media/bootanimation.zip";static const char USER_BOOTANIMATION_FILE[] = "/data/local/bootanimation.zip";static const char SYSTEM_SHUTANIMATION_FILE[] = "/system/media/shutanimation.zip";
@@ -277,22 +283,52 @@ void BootAnimation::binderDied(const wp<IBinder>&)requestExit();}+// merge from frameworks/base/cmds/bootanimation by tom
+static void* decodeImage(const void* encodedData, size_t dataLength, AndroidBitmapInfo* outInfo) {
+ AImageDecoder* decoder = nullptr;
+ AImageDecoder_createFromBuffer(encodedData, dataLength, &decoder);
+ if (!decoder) {
+ return nullptr;
+ }
+
+ const AImageDecoderHeaderInfo* info = AImageDecoder_getHeaderInfo(decoder);
+ outInfo->width = AImageDecoderHeaderInfo_getWidth(info);
+ outInfo->height = AImageDecoderHeaderInfo_getHeight(info);
+ outInfo->format = AImageDecoderHeaderInfo_getAndroidBitmapFormat(info);
+ outInfo->stride = AImageDecoder_getMinimumStride(decoder);
+ outInfo->flags = 0;
+
+ const size_t size = outInfo->stride * outInfo->height;
+ void* pixels = malloc(size);
+ int result = AImageDecoder_decodeImage(decoder, pixels, outInfo->stride, size);
+ AImageDecoder_delete(decoder);
+
+ if (result != ANDROID_IMAGE_DECODER_SUCCESS) {
+ free(pixels);
+ return nullptr;
+ }
+ return pixels;
+}
+status_t BootAnimation::initTexture(Texture* texture, AssetManager& assets,const char* name) {Asset* asset = assets.open(name, Asset::ACCESS_BUFFER);
- if (asset == NULL)
+ if (asset == nullptr)return NO_INIT;
- SkBitmap bitmap;
- sk_sp<SkData> data = SkData::MakeWithoutCopy(asset->getBuffer(false),
- asset->getLength());
- sk_sp<SkImage> image = SkImage::MakeFromEncoded(data);
- image->asLegacyBitmap(&bitmap, SkImage::kRO_LegacyBitmapMode);
+
+ AndroidBitmapInfo bitmapInfo;
+ void* pixels = decodeImage(asset->getBuffer(false), asset->getLength(), &bitmapInfo);
+ auto pixelDeleter = std::unique_ptr<void, decltype(free)*>{ pixels, free };
+asset->close();delete asset;- const int w = bitmap.width();
- const int h = bitmap.height();
- const void* p = bitmap.getPixels();
+ if (!pixels) {
+ return NO_INIT;
+ }
+
+ const int w = bitmapInfo.width;
+ const int h = bitmapInfo.height;GLint crop[4] = { 0, h, w, -h };texture->w = w;
@@ -301,22 +337,22 @@ status_t BootAnimation::initTexture(Texture* texture, AssetManager& assets,glGenTextures(1, &texture->name);glBindTexture(GL_TEXTURE_2D, texture->name);- switch (bitmap.colorType()) {
- case kAlpha_8_SkColorType:
+ switch (bitmapInfo.format) {
+ case ANDROID_BITMAP_FORMAT_A_8:glTexImage2D(GL_TEXTURE_2D, 0, GL_ALPHA, w, h, 0, GL_ALPHA,
- GL_UNSIGNED_BYTE, p);
+ GL_UNSIGNED_BYTE, pixels);break;
- case kARGB_4444_SkColorType:
+ case ANDROID_BITMAP_FORMAT_RGBA_4444:glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, w, h, 0, GL_RGBA,
- GL_UNSIGNED_SHORT_4_4_4_4, p);
+ GL_UNSIGNED_SHORT_4_4_4_4, pixels);break;
- case kN32_SkColorType:
+ case ANDROID_BITMAP_FORMAT_RGBA_8888:glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, w, h, 0, GL_RGBA,
- GL_UNSIGNED_BYTE, p);
+ GL_UNSIGNED_BYTE, pixels);break;
- case kRGB_565_SkColorType:
+ case ANDROID_BITMAP_FORMAT_RGB_565:glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, w, h, 0, GL_RGB,
- GL_UNSIGNED_SHORT_5_6_5, p);
+ GL_UNSIGNED_SHORT_5_6_5, pixels);break;default:break;
@@ -333,20 +369,21 @@ status_t BootAnimation::initTexture(Texture* texture, AssetManager& assets,status_t BootAnimation::initTexture(FileMap* map, int* width, int* height){
- SkBitmap bitmap;
- sk_sp<SkData> data = SkData::MakeWithoutCopy(map->getDataPtr(),
- map->getDataLength());
- sk_sp<SkImage> image = SkImage::MakeFromEncoded(data);
- image->asLegacyBitmap(&bitmap, SkImage::kRO_LegacyBitmapMode);
+ AndroidBitmapInfo bitmapInfo;
+ void* pixels = decodeImage(map->getDataPtr(), map->getDataLength(), &bitmapInfo);
+ auto pixelDeleter = std::unique_ptr<void, decltype(free)*>{ pixels, free };// FileMap memory is never released until application exit.// Release it now as the texture is already loaded and the memory used for// the packed resource can be released.delete map;- const int w = bitmap.width();
- const int h = bitmap.height();
- const void* p = bitmap.getPixels();
+ if (!pixels) {
+ return NO_INIT;
+ }
+
+ const int w = bitmapInfo.width;
+ const int h = bitmapInfo.height;GLint crop[4] = { 0, h, w, -h };int tw = 1 << (31 - __builtin_clz(w));
@@ -354,28 +391,28 @@ status_t BootAnimation::initTexture(FileMap* map, int* width, int* height)if (tw < w) tw <<= 1;if (th < h) th <<= 1;- switch (bitmap.colorType()) {
- case kN32_SkColorType:
+ switch (bitmapInfo.format) {
+ case ANDROID_BITMAP_FORMAT_RGBA_8888:if (!mUseNpotTextures && (tw != w || th != h)) {glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, tw, th, 0, GL_RGBA,
- GL_UNSIGNED_BYTE, 0);
+ GL_UNSIGNED_BYTE, nullptr);glTexSubImage2D(GL_TEXTURE_2D, 0,
- 0, 0, w, h, GL_RGBA, GL_UNSIGNED_BYTE, p);
+ 0, 0, w, h, GL_RGBA, GL_UNSIGNED_BYTE, pixels);} else {glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, w, h, 0, GL_RGBA,
- GL_UNSIGNED_BYTE, p);
+ GL_UNSIGNED_BYTE, pixels);}break;- case kRGB_565_SkColorType:
+ case ANDROID_BITMAP_FORMAT_RGB_565:if (!mUseNpotTextures && (tw != w || th != h)) {glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, tw, th, 0, GL_RGB,
- GL_UNSIGNED_SHORT_5_6_5, 0);
+ GL_UNSIGNED_SHORT_5_6_5, nullptr);glTexSubImage2D(GL_TEXTURE_2D, 0,
- 0, 0, w, h, GL_RGB, GL_UNSIGNED_SHORT_5_6_5, p);
+ 0, 0, w, h, GL_RGB, GL_UNSIGNED_SHORT_5_6_5, pixels);} else {glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, w, h, 0, GL_RGB,
- GL_UNSIGNED_SHORT_5_6_5, p);
+ GL_UNSIGNED_SHORT_5_6_5, pixels);}break;default:
@@ -412,19 +449,20 @@ status_t BootAnimation::readyToRun() {mAssets.addDefaultAssets();- sp<IBinder> dtoken(SurfaceComposerClient::getBuiltInDisplay(
- ISurfaceComposer::eDisplayIdMain));
- DisplayInfo dinfo;
- status_t status = SurfaceComposerClient::getDisplayInfo(dtoken, &dinfo);
+ sp<IBinder> dtoken = SurfaceComposerClient::getInternalDisplayToken();
+ DisplayMode displayMode;
+ status_t status = SurfaceComposerClient::getActiveDisplayMode(dtoken, &displayMode);if (status)return -1;
+ ui::Size resolution = displayMode.resolution;/// M: The tablet rotation maybe 90/270 degrees, so set the lcm config for tablet//SurfaceComposerClient::setDisplayProjection(dtoken, DisplayState::eOrientationDefault, Rect(dinfo.w, dinfo.h), Rect(dinfo.w, dinfo.h));
- t.setDisplayProjection(dtoken, DisplayState::eOrientationDefault, Rect(dinfo.w, dinfo.h), Rect(dinfo.w, dinfo.h));
+ t.setDisplayProjection(dtoken, ui::ROTATION_0, Rect(resolution.getWidth(), resolution.getHeight()),
+ Rect(resolution.getWidth(), resolution.getHeight()));t.apply();// create the native surfacesp<SurfaceControl> control = session()->createSurface(String8("BootAnimation"),
- dinfo.w, dinfo.h, PIXEL_FORMAT_RGB_565);
+ resolution.getWidth(), resolution.getHeight(), PIXEL_FORMAT_RGB_565);/*SurfaceComposerClient::openGlobalTransaction();
@@ -538,7 +576,8 @@ bool BootAnimation::threadLoop()// We have no bootanimation file, so we use the stock android logo// animation.sp<MediaPlayer> mediaplayer;
- const char* resourcePath = NULL;
+ // add by songhui
+ const char* resourcePath = initAudioPath();status_t mediastatus = NO_ERROR;if (resourcePath != NULL) {bPlayMP3 = true;
@@ -1510,6 +1549,8 @@ const char* BootAnimation::initAudioPath() {void BootAnimation::initBootanimationZip() {ZipFileRO* zipFile = NULL;String8 ZipFileName;
+ // add by songhui
+ char BootanimFileName[PROPERTY_VALUE_MAX];#ifdef MSSI_MTK_CARRIEREXPRESS_PACKchar OPTR[PROPERTY_VALUE_MAX];// ter-service
关于作者
地球边 微信号 ywysh1018
MTK Android 13平台开关机动画铃声客制化相关推荐
- MTK平台Android 12自定义开关机动画铃声
完整的patch见 https://download.csdn.net/download/a785722173/87036230 修改文件和Q平台大同小异 Android Q自定义开关机动画_a785 ...
- android开关机动画铃声
1. 开 关机 动画的启动 Android系统在init.rc中定义了很多Service,具体定义格式可以参考<Android Platform Developer's Guide>中的& ...
- Android 9.0 开关机动画流程分析
Android开机动画流程的启动主要是在Surfaseflinger里面完成的,具体代码如下: /frameworks/native/services/surfaceflinger/StartProp ...
- Android Q MTK平台开关机铃声
google 默认开机动画代码在framework/base/cmds/bootanimation MTK 开机动画代码在vendor/mediatek/proprietary/operator/fr ...
- android开关机动画和铃声配置 MTK编译笔记
1, MTK平台开关机动画配置, 将需要调整的开关机动画和铃声放到alps\frameworks\base\data\sounds 这个目录下面,打开 该目录下的Android.mk文件,增加下面的编 ...
- Android 手机按键客制化详解
在Android 中会有以下5个按键(Back.Home.Menu.Power.Volume)与用户进行交互,Framework 层中实现按键功能,因此,从手机系统定制的角度,可以满足客户的客制化要求 ...
- MTK平台修改Android动画,Android MTK平台修改开关机动画和开机logo
转载请注明出处:http://blog.csdn.net/u011479494/article/details/50682089 一.修改开机logo 由于我的机器分辨率为540*960 替换:med ...
- Android MTK平台修改开关机动画和开机logo
转载请注明出处:http://blog.csdn.net/u011479494/article/details/50682089 一.修改开机logo 由于我的机器分辨率为540*960 替换:med ...
- Android 系统性能优化(57)---MTK 平台开关机、重启时间优化
MTK 平台开关机.重启时间优化 开关机.重启时间优化 开机性能优化:是用功能和其它因素多方面平衡的结果,片面追求单方面的性能没有太大意义: 有些产品设计开机动画非常酷炫,动画图片过多.高帧率 ...
最新文章
- 站长用实际体验评测六大CDN服务商
- c中写汇编语言,将汇编程序写在一个文件里,能否直接在C中调用
- SpringBoot 2.0 + 阿里巴巴 Sentinel 动态限流实战
- 观察多个线程同时运行|| 查看进程线程的方法——未完待续
- html5 提交from,刨根问底:HTML中form的隐式提交
- robotstudio仿真搬运编程_敲黑板 | 机器人是怎么完成任务的?这三种编程方式的区别你造吗...
- 周昌印:忘记技术 从用户与市场考虑问题
- 计算机应用基础重点分析,计算机应用基础整体设计重点分析.doc
- [转]用android LinearLayout和RelativeLayout实现精确布局
- nexbox本地网络调试工具下载_「下载」 Windows 10 WinDBG 分析转储日志和蓝屏日志排查错误原因...
- 鸿蒙系统将登陆2亿台华为手机,“别的厂商想用,我们会支持!”
- 信息收集--IP扫描 (上篇)
- Ubuntu下安装Oracle Instant Client
- OpenSTA —— 高效的 web 性能测试工具
- 伺服系统(自动控制系统)
- 关于笔记本加固态硬盘装系统的问题的解决办法
- ElasticSearch报错:FORBIDDEN/12/index read-only / allow delete (api)无法写入
- Python快速实现一键抠图
- 战争艺术 java_战争艺术2网络对战版
- 谷歌研究总监Peter Norvig赴斯坦福任教,著有《人工智能:一种现代方法》