微波EDA网,见证研发工程师的成长!
首页 > 研发问答 > 手机设计讨论 > MTK手机平台交流 > 如何实现通过工程指令切换开关机动画铃声的功能

如何实现通过工程指令切换开关机动画铃声的功能

时间:10-02 整理:3721RD 点击:
[DESCRIPTION]

通过工程指令切换开关机动画铃声的功能;
输入正确的指令(例如:*#123890#)后,返回home界面,即完成两套开关机动画铃声的切换动作
[SOLUTION]

一、修改文件 /mediatek/config/${Project}/init.rc
在文件的末尾添加:
# Change the bootanimation and bootaudio
on property:persist.radio.change.bootanim=1
user root
group root
write /proc/bootprof "INIT:NAND:Mount_START"
# Mount /system rw first to give the filesystem a chance to save a
checkpoint
mount yaffs2 mtd@system /system nandboot
chmod 0777 /system/media
copy /system/bootanim/bootanimation.zip /system/media/bootanimation.zip
copy /system/bootanim/bootaudio.mp3 /system/media/bootaudio.mp3
copy /system/bootanim/shutanimation.zip /system/media/shutanimation.zip
copy /system/bootanim/shutaudio.mp3 /system/media/shutaudio.mp3
setprop persist.radio.change.bootanim 0
mount yaffs2 mtd@system /system ro remount nandboot
write /proc/bootprof "INIT:NAND:Mount_END"
二、修改文件
packages/apps/Contacts/src/com/android/contacts/SpecialCharSequenceMgr.jav
a
添加 Code:
//设置处理更换开关机动画和铃声的命令
private static final String CHANGE_BOOTANIM = "*#123890#";
修改 Code:
static boolean handleChars(Context context, String input, boolean
useSystemWindow,
EditText textField) {
Log.d(TAG, "handleChars() dialString:" + input);
//get rid of the separators so that the string gets parsed correctly
String dialString = PhoneNumberUtils.stripSeparators(input);
if (handleIMEIDisplay(context, dialString, useSystemWindow)
|| handlePinEntry(context, dialString)
|| handleAdnEntry(context, dialString, textField)
|| handleSecretCode(context, dialString)
|| handleChangeBootanim(context, dialString)) {
//此处添加处理更换开关机动画和铃声的 Code
return true;
}
return false;
}
添加函数:
static boolean handleChangeBootanim(Context context, String input) {
if (input.equals(CHANGE_BOOTANIM)) {
Intent it = new Intent();
it.setAction("persist.radio.change.bootanim");
context.sendBroADCast(it);
Intent intent = new Intent("android.intent.action.MAIN");
intent.addCategory(Intent.CATEGORY_HOME);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(intent);
return true;
}
return false;
}
三、创建一个 APK,这个 APK 的 android:sharedUserId="android.uid.phone",并签上
系统签名;
这个 APK 里面只有一个 BroadCastReceiver,onReceive 函数里面的内容是:
if(intent.getAction().equals("persist.radio.change.bootanim")){
android.os.SystemProperties.set("persist.radio.change.bootanim", "1");
}
AndroiDMAnifest.xml 里面内容如下:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.change.bootanim"
android:versionCode="1"
android:versionName="1.0"
android:sharedUserId="android.uid.phone">
<uses-SDK android:minSdkVersion="10" />
<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name" >
<receiver
android:label="@string/app_name"
android:name=".ChangeBootanimReceiver" >
<intent-fiLTEr >
<action android:name="persist.radio.change.bootanim"/>
<category android:name="android.intent.category.DEFAULT"/>
</intent-filter>
</receiver>
</application>
</manifest>
四、请贵司在如下目录下直接创建 bootanim
/vendor/mediatek/${Project}/artifacts/out/target/product/${Project}/system
/
然后将 bootanimation.zip、bootaudio.mp3、shutanimation.zip 和 shutaudio.mp3
拷贝到该目录下,然后重新编译工程即可。

Copyright © 2017-2020 微波EDA网 版权所有

网站地图

Top