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

#else

LOCAL_SRC_FILES += \
    bootanimation_main.cpp \
    audioplay.cpp \

#endif  # PRODUCT_IOT

LOCAL_MODULE:= mtkbootanimation

LOCAL_INIT_RC := mtkbootanim.rc

ifdef 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
# endif

LOCAL_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 \
    libbase

LOCAL_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 
 
 #include 
 #include 
@@ -30,9 +31,10 @@
 #include 
 #include 
 
-
+#include 
 #include 
 
+#include 
 #include 
 #include 
 #include 
@@ -45,18 +47,16 @@
 #include 
 #include 
 #include 
-#include 
+#include 
 
 #include 
+#include 
 #include 
 #include 
 
 // TODO: Fix Skia.
 #pragma GCC diagnostic push
 #pragma GCC diagnostic ignored "-Wunused-parameter"
-#include 
-#include 
-#include 
 #pragma GCC diagnostic pop
 
 #include 
@@ -76,8 +76,11 @@
 #include 
 
 #define PATH_COUNT 3
-
-
+// add by songhui
+#include 
+#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&)
     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 data = SkData::MakeWithoutCopy(asset->getBuffer(false),
-            asset->getLength());
-    sk_sp 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{ 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 data = SkData::MakeWithoutCopy(map->getDataPtr(),
-            map->getDataLength());
-    sk_sp 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{ 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 dtoken(SurfaceComposerClient::getBuiltInDisplay(
-            ISurfaceComposer::eDisplayIdMain));
-    DisplayInfo dinfo;
-    status_t status = SurfaceComposerClient::getDisplayInfo(dtoken, &dinfo);
+    sp 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 surface
     sp 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;
-    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_PACK
     char OPTR[PROPERTY_VALUE_MAX];
     // ter-service

关于作者
地球边  微信号 ywysh1018

你可能感兴趣的:(开关机动画,android)