LoginSignup
2
1

More than 3 years have passed since last update.

Android端末に日本のSIMをさしたらカメラのシャッター音が強制鳴動するロジック

Posted at

Androidのソースを読んでいたら、なんと2012年時点でこんなロジックが存在してたの??という発見の共有。
https://android.googlesource.com/platform/frameworks/base/+/dd45d01128423a82652a3c9d77fa393631d95229

「日本のSIMをさしたら」の判定

core/res/res/values-mcc440/config.xml
    <!-- Whether camera shutter sound is forced or not  (country specific). -->
    <bool name="config_camera_sound_forced">true</bool>
core/res/res/values/config.xml
    <bool name="config_camera_sound_forced">false</bool>

厳密には、日本のSIMをさしているかどうかではなく、
MCC=440のモバイルネットワークに接続したら、読み込むXMLが変わり、config_camera_sound_forced=trueの方を使う。

https://developer.android.com/guide/topics/resources/providing-resources.html
image.png

個人的にはかなり目からウロコだったんだけども、よく見たらリファレンスにもしっかり書かれていたわ・・・。

「強制鳴動する」の実装

これはいろんな記事で言及されているのでさらっと。

config_camera_sound_forcedフラグがtrueだったら、音パスを AudioSystem.STREAM_SYSTEM_ENFORCED にしているだけ。

でも...

なお、日本では「シャッター音は何が何でも鳴らせ!」みたいな仕様をどこかの誰かが勝手に決めているので、この話は当てはまらないかもしれない。

だってほら、MCC=440関係ないWifiタブレットでもなぜかシャッター音鳴るじゃん?

2
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
1