当前位置: 代码迷 >> Android >> Android 移动终端camera 防窃*拍设置
  详细解决方案

Android 移动终端camera 防窃*拍设置

热度:66   发布时间:2016-05-01 13:23:14.0
Android 移动终端camera 防偷*拍设置

目前市面上的所有移动终端几乎都有camera应用,但Android.html">Android原生系统在静音模式下拍照是没有声音的,大部分国家的终端都有法规限制,如防止偷*拍,不管什么模式下拍照都应该发出快门音,针对此问题只要修改Android.html">Android原生cameraservice.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);        }    }} 
  相关解决方案