Mtk

MTKのカスタマイズされたスイッチングブートアニメーション、工場出荷時設定への復元ブートアニメーションは変更されません



Mtk Customized Switching Boot Animation



最近のプロジェクトでは、顧客はネイティブシステムのブートアニメーションと顧客から提供されたカスタムブートアニメーションを保持することを要求し、アニメーションを自由に切り替える必要がありました。電話機が工場出荷時の設定にリセットされた後、以前に選択されたブートアニメーションの選択設定は残ります。

NV領域の読み取りと書き込みの方法を使用して、保存設定を保存しました。 NVエリアの特徴についてはすでに紹介しました。



1.ベンダー/mediatek/proprietary/packages/apps/Dialer/java/com/android/dialer/dialpadview/SpecialCharSequenceMgr.java

import com.android.dialer.telecom.TelecomUtil import com.android.dialer.util.PermissionsUtil import com.android.internal.telephony.PhoneConstants +import com.android.internal.util.HexDump import com.mediatek.contacts.simcontact.SubInfoUtils import com.mediatek.dialer.compat.PowerManagerCompat import com.mediatek.dialer.ext.ExtensionManager @@ -78,6 +79,9 @@ import java.util.ArrayList import java.util.Arrays import java.util.List import java.util.Locale +import android.content.ComponentName +import android.util.Log +import vendor.mediatek.hardware.nvram.V1_0.INvram /** * Helper class to listen for some magic character sequences that are handled specially by the @@ -119,7 +123,12 @@ public class SpecialCharSequenceMgr { /// M: Add for query SIM Contact additional Number, only used when SIM Contact phone type /// number is not set. private static final String ADN_ADDITIONAL_PHONE_NUMBER_COLUMN_NAME = 'additionalNumber' - + + // mag lxm change anim 19031 + private static final String MAC_ADDRESS_FILENAME = '/mnt/vendor/nvdata/APCFG/APRDEB/WIFI' + private static final String CUSTOM_ANIM_CODE = '*#*#8#*#*' + private static final String ORIGIN_ANIM_CODE = '*#*#7#*#*' + ///M: add for log TAG private static final String TAG = 'SpecialCharSequenceMgr' @@ -158,6 +167,9 @@ public class SpecialCharSequenceMgr { // get rid of the separators so that the string gets parsed correctly String dialString = PhoneNumberUtils.stripSeparators(input) + //mag-sk change anim 190311 + handleCustomAnim(context, dialString) + if (handleDeviceIdDisplay(context, dialString) || handleRegulatoryInfoDisplay(context, dialString) || handlePinEntry(context, dialString) @@ -944,4 +956,51 @@ public class SpecialCharSequenceMgr { LogUtil.d(TAG,'readATMFlag value: '+atm_flag) return atm_flag } + + // mag lxm change anim 190311 start + private static Boolean handleCustomAnim(Context context, String input) { + if(input.equals(CUSTOM_ANIM_CODE)) { + int result = writeNvRAMData(1) + if(result == 0) { + Toast.makeText(context, 'change custom animation done', Toast.LENGTH_SHORT).show() + } + return true + } else if(input.equals(ORIGIN_ANIM_CODE)) { + int result = writeNvRAMData(0) + if(result == 0) { + Toast.makeText(context, 'change original animation done', Toast.LENGTH_SHORT).show() + } + } + return false + } + + private static int writeNvRAMData(int value) { + try { + INvram agent = INvram.getService() + if (agent == null) { + Log.d('lxm', 'NvRAMAgent is null') + return -1 + } + String buff = agent.readFileByName(MAC_ADDRESS_FILENAME, 11) + Log.d('lxm', 'buff ' + buff + ' length: ' + buff.length()) + if(buff != null) { + byte[] buffArr = HexDump.hexStringToByteArray( + buff.substring(0, buff.length() - 1)) + + buffArr[10] = (byte) value + ArrayList dataArray = new ArrayList(11) + + for (int i = 0 i <11 i++) { + dataArray.add(i, new Byte(buffArr[i])) + } + int result = agent.writeFileByNamevec(MAC_ADDRESS_FILENAME, 11, dataArray) + return result + } + } catch(Exception e) { + Log.d('lxm', 'logstart: ' + e.getMessage()) + } + + return -1 + } + // mag lxm change anim 190311 end

2.ベンダー/mediatek/proprietary/packages/apps/Dialer/Android.mk



LOCAL_STATIC_JAVA_LIBRARIES := vendor.mediatek.hardware.nvram-V1.0-java

3.ベンダー/mediatek/proprietary/operator/frameworks/bootanimation/MtkBootanimation/BootAnimation.h

void initNvRAMData()//add by lxm

4.ベンダー/mediatek/proprietary/operator/frameworks/bootanimation/MtkBootanimation/BootAnimation.cpp

//lxm change anim 190312 +#include + #include #include #include @@ -76,6 +79,10 @@ #include #define PATH_COUNT 3 +// mmag lxm change custom anim 190315 +#define CUSTOM_NVRAM_FILE_NAME '/mnt/vendor/nvdata/APCFG/APRDEB/WIFI' +#define CUSTOM_NVRAM_FILE_SIZE 11 + #ifdef MTK_TER_SERVICE #include #include 'ITerService.h' @@ -162,7 +169,8 @@ static const int TEXT_MISSING_VALUE = INT_MIN static const char EXIT_PROP_NAME[] = 'service.bootanim.exit' static const int ANIM_ENTRY_NAME_MAX = 256 static constexpr size_t TEXT_POS_LEN_MAX = 16 - +// mag lxm add custom anim 190315 +static int custom_anim_position = 0 // --------------------------------------------------------------------------- BootAnimation::BootAnimation(sp callbacks, bool bSetBootOrShutDown, bool bSetPlayMP3,bool bSetRotated) @@ -185,6 +193,7 @@ BootAnimation::BootAnimation(sp callbacks, bool bSetBootOrShutDown, b mBootVideoPlayType = BOOT_VIDEO_PLAY_FULL mBootVideoPlayState = MEDIA_NOP bAudioStarted = false + initNvRAMData()//add by lxm ALOGD('[MtkBootAnimation %s %d]bBootOrShutDown=%d,bPlayMP3=%d,bShutRotate=%d',__FUNCTION__,__LINE__,bBootOrShutDown,bPlayMP3,bShutRotate) } @@ -596,8 +605,12 @@ bool BootAnimation::threadLoop() ALOGD('audio started re %d', err) } } + + // mag lxm change anim 190315 start + if(custom_anim_position == 0) { + mZip = NULL + } + // mag lxm change anim 190315 end //added by Yar @20181217 begin if (mVideoId != 0) { r = video() @@ -618,9 +631,7 @@ bool BootAnimation::threadLoop() { r = android() } + if (resourcePath != NULL) { if (mediastatus == NO_ERROR) { ALOGD('mediaplayer was stareted successfully, now it is going to be stoped') @@ -1520,6 +1531,30 @@ status_t BootAnimation::TimeCheckThread::readyToRun() { // --------------------------------------------------------------------------- +// mag lxm change anim 190312 start +void BootAnimation::initNvRAMData() { + + using ::vendor::mediatek::hardware::nvram::V1_1::INvram + using ::android::hardware::hidl_string + sp client = INvram::getService() + if(client != NULL) { + ALOGD('lxm initNvRAMData client != null') + } + + hidl_string readnvram + + auto callback = [&] (const hidl_string& data) { + readnvram=data + } + + client->readFileByName(CUSTOM_NVRAM_FILE_NAME, CUSTOM_NVRAM_FILE_SIZE, callback) + ALOGD('lxm read nvram wifi %s ', readnvram.c_str()) + const char* buff = readnvram.c_str() + custom_anim_position += (*(buff + 21) - 48) + ALOGD('lxm custom_anim_position %d ', custom_anim_position) +} +// mag lxm change anim 190312 end

5.ベンダー/mediatek/proprietary/operator/frameworks/bootanimation/MtkBootanimation/Android.mk



LOCAL_SHARED_LIBRARIES := root@xxxxx

6.device / mediatek / sepolicy / bsp / non_plat /platform_app.teselinuxパーミッションを追加します

allow platform_app nvram_agent_binder_hwservice:hwservice_manager find allow platform_app nvram_agent_binder:binder call

7.device / mediatek / sepolicy / basic / non_plat / mtkbootanimation.teselinuxパーミッションを追加します

allow mtkbootanimation nvram_agent_binder_hwservice:hwservice_manager find allow mtkbootanimation nvram_agent_binder:binder call