(转)音频管理器服务
mAudioManager所在服务如下:
文件: frameworks/base/media/java/android/media/AudioManager.java
java代码:
- public static final int RINGER_MODE_SILENT = 0;
- public static final int RINGER_MODE_VIBRATE = 1;
- public static final int RINGER_MODE_NORMAL = 2;
- public void setRingerMode(int ringerMode) {
- IAudioService service = getService();
- try {
- service.setRingerMode(ringerMode);
- } catch (RemoteException e) {
- Log.e(TAG, "Dead object in setRingerMode", e);
- }
- }
将铃响模式值传给音频接口服务IaudioService
java代码:
- public static final int VIBRATE_TYPE_RINGER = 0;
- public static final int VIBRATE_TYPE_NOTIFICATION = 1;
- public static final int VIBRATE_SETTING_OFF = 0;
- public static final int VIBRATE_SETTING_ON = 1;
- public static final int VIBRATE_SETTING_ONLY_SILENT = 2;
- public void setVibrateSetting(int vibrateTyp , int vibrateSetting) {
- IAudioService service = getService();
- try {
- service.setVibrateSetting(vibrateType, vibrateSetting);
- } catch (RemoteException e) {
- Log.e(TAG, "Dead object in setVibrateSetting", e);
- }
- }
将振动类型和振动设置传给音频接口服务IaudioService,IaudioService的定义如下:
frameworks/base/media/java/android/media/IAudioService.aidl
frameworks/base/media/java/android/media/AudioService.java
文件: frameworks/base/media/java/android/media/AudioService.java
文件: frameworks/base/core/java/android/provider/Settings.java
java代码:
- public void setRingerMode(int ringerMode) {
- synchronized (mSettingsLock) {
- if (ringerMode != mRingerMode) {
- setRingerModeInt(ringerMode, true);
- // Send sticky broadcast
- broadcastRingerMode();
- }
- }
- }