android4.4 手机通话中收到短信,未有响铃或震动提示
来源:互联网 发布:乔大伯 知乎 编辑:程序博客网 时间:2024/04/30 12:05
frameworks/base/services/java/com/android/server/NotificationManagerService.java 1838
原来的代码
// If we're not supposed to beep, vibrate, etc. then don't.if (((mDisabledNotifications & StatusBarManager.DISABLE_NOTIFICATION_ALERTS) == 0 || (smsRingtone && mInCall)) && (!(old != null && (notification.flags & Notification.FLAG_ONLY_ALERT_ONCE) != 0 )) && (r.getUserId() == UserHandle.USER_ALL || (r.getUserId() == userId && r.getUserId() == currentUser)) && canInterrupt && mSystemReady) { final AudioManager audioManager = (AudioManager) mContext .getSystemService(Context.AUDIO_SERVICE); // sound // should we use the default notification sound? (indicated either by // DEFAULT_SOUND or because notification.sound is pointing at // Settings.System.NOTIFICATION_SOUND) final boolean useDefaultSound = (notification.defaults & Notification.DEFAULT_SOUND) != 0 || Settings.System.DEFAULT_NOTIFICATION_URI .equals(notification.sound); Uri soundUri = null; boolean hasValidSound = false; if (useDefaultSound) { soundUri = Settings.System.DEFAULT_NOTIFICATION_URI; // check to see if the default notification sound is silent ContentResolver resolver = mContext.getContentResolver(); hasValidSound = Settings.System.getString(resolver, Settings.System.NOTIFICATION_SOUND) != null; } else if (notification.sound != null) { soundUri = notification.sound; hasValidSound = (soundUri != null); } if (hasValidSound) { boolean looping = (notification.flags & Notification.FLAG_INSISTENT) != 0; int audioStreamType; if (notification.audioStreamType >= 0) { audioStreamType = notification.audioStreamType; } else { audioStreamType = DEFAULT_STREAM_TYPE; } mSoundNotification = r; // do not play notifications if stream volume is 0 (typically because // ringer mode is silent) or if there is a user of exclusive audio focus if ((audioManager.getStreamVolume(audioStreamType) != 0) && !audioManager.isAudioFocusExclusive()) { final long identity = Binder.clearCallingIdentity(); try { final IRingtonePlayer player = mAudioService.getRingtonePlayer(); if (player != null) { player.playAsync(soundUri, user, looping, audioStreamType); } } catch (RemoteException e) { } finally { Binder.restoreCallingIdentity(identity); } } }
修改后的代码
// If we're not supposed to beep, vibrate, etc. then don't.if ((!(old != null && (notification.flags & Notification.FLAG_ONLY_ALERT_ONCE) != 0 ))&& (r.getUserId() == UserHandle.USER_ALL || (r.getUserId() == userId && r.getUserId() == currentUser))&& canInterrupt&& mSystemReady) {final AudioManager audioManager = (AudioManager) mContext .getSystemService(Context.AUDIO_SERVICE);boolean hasValidSound = false;if (((mDisabledNotifications & StatusBarManager.DISABLE_NOTIFICATION_ALERTS) == 0 || (smsRingtone && mInCall)) ) { // sound // should we use the default notification sound? (indicated either by // DEFAULT_SOUND or because notification.sound is pointing at // Settings.System.NOTIFICATION_SOUND) final boolean useDefaultSound = (notification.defaults & Notification.DEFAULT_SOUND) != 0 || Settings.System.DEFAULT_NOTIFICATION_URI .equals(notification.sound); Uri soundUri = null; if (useDefaultSound) { soundUri = Settings.System.DEFAULT_NOTIFICATION_URI; // check to see if the default notification sound is silent ContentResolver resolver = mContext.getContentResolver(); hasValidSound = Settings.System.getString(resolver, Settings.System.NOTIFICATION_SOUND) != null; } else if (notification.sound != null) { soundUri = notification.sound; hasValidSound = (soundUri != null); } if (hasValidSound) { boolean looping = (notification.flags & Notification.FLAG_INSISTENT) != 0; int audioStreamType; if (notification.audioStreamType >= 0) { audioStreamType = notification.audioStreamType; } else { audioStreamType = DEFAULT_STREAM_TYPE; } mSoundNotification = r; // do not play notifications if stream volume is 0 (typically because // ringer mode is silent) or if there is a user of exclusive audio focus if ((audioManager.getStreamVolume(audioStreamType) != 0) && !audioManager.isAudioFocusExclusive()) { final long identity = Binder.clearCallingIdentity(); try { final IRingtonePlayer player = mAudioService.getRingtonePlayer(); if (player != null) { player.playAsync(soundUri, user, looping, audioStreamType); } } catch (RemoteException e) { } finally { Binder.restoreCallingIdentity(identity); } } }}if ((mDisabledNotifications & StatusBarManager.DISABLE_NOTIFICATION_ALERTS) == 0 || mInCall) { // vibrate // Does the notification want to specify its own vibration? final boolean hasCustomVibrate = notification.vibrate != null; // new in 4.2: if there was supposed to be a sound and we're in vibrate // mode, and no other vibration is specified, we fall back to vibration final boolean convertSoundToVibration = !hasCustomVibrate && hasValidSound && (audioManager.getRingerMode() == AudioManager.RINGER_MODE_VIBRATE); // The DEFAULT_VIBRATE flag trumps any custom vibration AND the fallback. final boolean useDefaultVibrate = (notification.defaults & Notification.DEFAULT_VIBRATE) != 0; if ((useDefaultVibrate || convertSoundToVibration || hasCustomVibrate) && !(audioManager.getRingerMode() == AudioManager.RINGER_MODE_SILENT)) { mVibrateNotification = r; if (useDefaultVibrate || convertSoundToVibration) { // Escalate privileges so we can use the vibrator even if the // notifying app does not have the VIBRATE permission. long identity = Binder.clearCallingIdentity(); try { mVibrator.vibrate(r.sbn.getUid(), r.sbn.getBasePkg(), useDefaultVibrate ? mDefaultVibrationPattern : mFallbackVibrationPattern, ((notification.flags & Notification.FLAG_INSISTENT) != 0) ? 0: -1); } finally { Binder.restoreCallingIdentity(identity); } } else if (notification.vibrate.length > 1) { // If you want your own vibration pattern, you need the VIBRATE // permission mVibrator.vibrate(r.sbn.getUid(), r.sbn.getBasePkg(), notification.vibrate, ((notification.flags & Notification.FLAG_INSISTENT) != 0) ? 0: -1); } }}}
0 0
- android4.4 手机通话中收到短信,未有响铃或震动提示
- Android--响铃、震动、状态栏提示
- Android中实现拨打电话、发送短信、响铃、震动和获取当前时间
- [Android实例]通话接通后震动提示
- [Android实例]通话接通后震动提示
- [Android实例]通话接通后震动提示
- 通话接通后震动提示 示例讲解
- 美轮美奂的phonegap(六)---自定义提示(框,响铃,震动)
- 我的Android心得(5)--响铃、震动、状态栏提示
- 我的Android心得(5)--响铃、震动、状态栏提示
- 查询手机通话清单短信内容
- 手机通话短信可以查询码?
- 监听手机收到短信并自动回复
- Android4.4以上手机拦截短信说明(三)
- Android--SensorEventListener和AudioManager实现根据条件转换手机震动和响铃
- Android--SensorEventListener和AudioManager实现根据条件转换手机震动和响铃
- Android中关于手机震动
- android收到短信,用Toast显示“有短信”提示
- 如何用matlab输出高分辨率同一大小的eps图片
- mysql master-master备份配置文档
- 适用于 Microsoft Windows(32 位)的 Instant Client
- 信息生命周期管理
- MyEclipse添加ibatis DTD文件实现xml的自动提示功能
- android4.4 手机通话中收到短信,未有响铃或震动提示
- 顺序图
- GUI_PICTURE以及context_menu学习笔记
- Jave文件操作(读取写入复制创建删除)
- 私有github搭建使用
- 加速度计的数据解读
- 闭锁CountDownLatch与栅栏CyclicBarrier
- 《思考的技术》--大前研一读书笔记
- Unity手游之路<七>角色控制器