Android(安卓)移动终端camera 防偷*拍设置
16lz
2021-12-04
目前市面上的所有移动终端几乎都有camera 应用,但Android .html">Android 原生系统在静音模式下拍照是没有声音的,大部分国家的终端都有法规限制,如防止偷*拍 ,不管什么模式下拍照都应该发出快门音,针对此问题只要修改Android .html">Android 原生camera service.cpp中playSound函数即可,
android 4.0.3声音分类
typedef enum { AUDIO_STREAM_DEFAULT = -1, AUDIO_STREAM_VOICE_CALL = 0, AUDIO_STREAM_SYSTEM = 1, AUDIO_STREAM_RING = 2, AUDIO_STREAM_MUSIC = 3, AUDIO_STREAM_ALARM = 4, AUDIO_STREAM_NOTIFICATION = 5, AUDIO_STREAM_BLUETOOTH_SCO = 6, AUDIO_STREAM_ENFORCED_AUDIBLE = 7, /* Sounds that cannot be muted byuser and must be routed to speaker */ AUDIO_STREAM_DTMF = 8, AUDIO_STREAM_TTS = 9, AUDIO_STREAM_FM = 10, AUDIO_STREAM_MATV = 11, AUDIO_STREAM_BOOT = 12, //only used for bootanimationand output from speaker and headset AUDIO_STREAM_CNT, AUDIO_STREAM_MAX = AUDIO_STREAM_CNT - 1,} audio_stream_type_t;
修改后的方法如下:
void cameraService::playSound(sound_kind kind) { LOG1("playSound(%d)", kind); Mutex::Autolock lock(mSoundLock); sp<MediaPlayer> player = mSoundPlayer[kind]; if (player != 0) { // do not play the sound if stream volume is 0 // (typically because ringer mode is silent). int index; AudioSystem::getStreamVolumeIndex(AUDIO_STREAM_ENFORCED_AUDIBLE, &index); if (index != 0) { AudioSystem::setStreamVolumeIndex(AUDIO_STREAM_ENFORCED_AUDIBLE,index); player->seekTo(0); player->start(); } else { AudioSystem::setStreamVolumeIndex(AUDIO_STREAM_ENFORCED_AUDIBLE,7); player->seekTo(0); player->start(); usleep(300000); AudioSystem::setStreamVolumeIndex(AUDIO_STREAM_ENFORCED_AUDIBLE,0); } }}
更多相关文章
- Android(安卓)Add-ons
- Android(安卓)设置声音时出现按键音
- android 调用摄像头
- 使用Javascript判断浏览器终端设备(PC、IOS(iphone)、Android)
- 无法安装ADT(无法访问https://dl-ssl.google.com/android/eclipse
- Android之拍照
- 为什么说Android令人沮丧!?
- js判断手机是Android还是iOS
- 【Android车载系统 News | Tech 5】车载设计开发