0

I need to know where exactly sound has been implemented in back and recent function. When I touch/click, home and recent icon has sound. I don't want to do in user application. I have aosp source code for Android 10. So I need to know in which folder/ method, this sound has been implemented for back and recent?

Star
  • 735
  • 3
  • 13
  • 34

1 Answers1

0

Check the AudioManager.playSoundEffect() methods: https://cs.android.com/android/platform/superproject/+/master:frameworks/base/media/java/android/media/AudioManager.java;l=2596;drc=master;bpv=1;bpt=1

The Javadoc for that method says:

  /**
     * Plays a sound effect (Key clicks, lid open/close...)
     * @param effectType The type of sound effect. One of
     *            {@link #FX_KEY_CLICK},
     *            {@link #FX_FOCUS_NAVIGATION_UP},
     *            {@link #FX_FOCUS_NAVIGATION_DOWN},
     *            {@link #FX_FOCUS_NAVIGATION_LEFT},
     *            {@link #FX_FOCUS_NAVIGATION_RIGHT},
     *            {@link #FX_KEYPRESS_STANDARD},
     *            {@link #FX_KEYPRESS_SPACEBAR},
     *            {@link #FX_KEYPRESS_DELETE},
     *            {@link #FX_KEYPRESS_RETURN},
     *            {@link #FX_KEYPRESS_INVALID},
     * NOTE: This version uses the UI settings to determine
     * whether sounds are heard or not.
     */

Using that, you cand decide to skip the playing for the sound effect you want.

If you want to instead disable all the sound effects, there is a Settings entry for this:

See frameworks/base/core/java/android/provider/Settings.java:

/**
* Whether the sounds effects (key clicks, lid open ...) are enabled. The value is
* boolean (1 or 0).
*/
public static final String SOUND_EFFECTS_ENABLED = "sound_effects_enabled";

You can modify that by:

Settings.System.putInt(mContext.getContentResolver(), SOUND_EFFECTS_ENABLED, 0);
Rick Sanchez
  • 4,528
  • 2
  • 27
  • 53