MTK Android 13平台开关机动画铃声客制化
生活随笔
收集整理的這篇文章主要介紹了
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文件即可
?
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平台开关机动画铃声客制化的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: ksweb如何安装php5.6_KSWE
- 下一篇: 深入浅出FPGA-18-VPI