1

I've got a bug report that sound doesn't work on an ASUS Transformer tablet running 3.0.

I don't do anything too weird, just use MediaPlayer and it seems to work on a wide range of phones. However, I use the method described in this post to disable sounds if getRingerMode() returns something other than RINGER_MODE_NORMAL. That way if the user has their phone on "vibrate only" they don't get surprising sound output (since media and ringer use separate volume controls).

Is it possible that on an Android tablet the getRingerMode() function returns RINGER_MODE_SILENT if the tablet doesn't have phone capabilities?

EDIT: Just a note that on the emulator without changing anything I get RINGER_MODE_NORMAL.

EDIT 2: In a final act of desperation, I removed the ringer mode check and re-published on the Market. The guy has just confirmed that sounds now work. It seems that getRingerMode() returns something other than RINGER_MODE_NORMAL on some tablets at least.

Community
  • 1
  • 1
richq
  • 55,548
  • 20
  • 150
  • 144

1 Answers1

2

This is the code from GingerBread. It will return RINGER_MODE_NORMAL if IAudioService can't return getRingerMode();

/**
 * Returns the current ringtone mode.
 *
 * @return The current ringtone mode, one of {@link #RINGER_MODE_NORMAL},
 *         {@link #RINGER_MODE_SILENT}, or {@link #RINGER_MODE_VIBRATE}.
 * @see #setRingerMode(int)
 */
public int getRingerMode() {
    IAudioService service = getService();
    try {
        return service.getRingerMode();
    } catch (RemoteException e) {
        Log.e(TAG, "Dead object in getRingerMode", e);
        return RINGER_MODE_NORMAL;
    }
}

http://grepcode.com/file/repository.grepcode.com/java/ext/com.google.android/android/2.3_r1/android/media/AudioManager.java/?v=source

One step below,

IAudioService#getRingerMode() throws android.os.RemoteException

The only difference in Honeycomb (reading the chengelog) in AudioManager is:

Added Fields int MODE_IN_COMMUNICATION

And nothing in 3.1 in this class, so I assume the Gingerbread code is still valid.

http://developer.android.com/sdk/api_diff/11/changes.html

Aleadam
  • 40,203
  • 9
  • 86
  • 108
  • +1 Makes sense, my only doubt is that IAudioService implementation could be doing anything with the actual preferences behind the scenes. I think I'm just going to have to "suck it and see", remove the check, see if that fixes the problem. – richq May 15 '11 at 20:12
  • @rich I was unable to follow exactly what IAudioService was doing, and we don't have access to 3.0 source, so I can't tell you more than what I wrote, unfortunately. – Aleadam May 15 '11 at 20:30
  • 4 months later, after trying this on an actual ASUS device it really does return NORMAL. Another day, another inexplicable user phantom bug report on Android. – richq Sep 18 '11 at 21:31