Android 9.0 添加关机铃声功能实现
1.前言
在9.0的系统rom定制化开发中,在原生系统中,关于开机铃声和关机铃声是默认不支持的,系统默认支持开机动画和关机动画等功能,所以关于增加开机铃声和关机
铃声的相关功能,需要自己增加相关的关机铃声功能
2.添加关机铃声功能实现的核心类
frameworks\base\cmds\bootanimation\BootAnimation.h
frameworks\base\cmds\bootanimation\BootAnimation.cpp
3.添加关机铃声功能实现的核心功能分析和实现
3.1在BootAnimation.h中添加播放关机铃声所需的变量和方法
class BootAnimation : public Thread, public IBinder::DeathRecipient
{
....
private:
bool mTimeFormat12Hour;
bool mShuttingDown;
String8 mZipFileName;
SortedVector<String8> mLoadedFiles;
sp<TimeCheckThread> mTimeCheckThread = nullptr;
sp<Callbacks> mCallbacks;
//add core start
bool soundplay();
bool soundstop();
bool playSoundsAllowed();
String8 mSoundFileName;
sp<MediaPlayer> mp;
int mfd;
bool mSystemCalled;
bool mWaitFor