Commit 8f8174a5 authored by Jean-Michel Trivi's avatar Jean-Michel Trivi
Browse files

Add support for AudioAttributes flags in RingtonePickerActivity

Read EXTRA_RINGTONE_AUDIO_ATTRIBUTES_FLAGS from intent to change
  the AudioAttributes flags on the Ringtone instance used to play
  the selected ringtone.

Bug 19407114

Change-Id: I2d923ef27e8db19b2560a129ba2462c90a07a997
parent f331540e
......@@ -19,6 +19,7 @@ package com.android.providers.media;
import android.content.DialogInterface;
import android.content.Intent;
import android.database.Cursor;
import android.media.AudioAttributes;
import android.media.Ringtone;
import android.media.RingtoneManager;
import android.net.Uri;
......@@ -99,6 +100,8 @@ public final class RingtonePickerActivity extends AlertActivity implements
*/
private Ringtone mCurrentRingtone;
private int mAttributesFlags;
/**
* Keep the currently playing ringtone around when changing orientation, so that it
* can be stopped later, after the activity is recreated.
......@@ -144,6 +147,10 @@ public final class RingtonePickerActivity extends AlertActivity implements
}
// Get whether to show the 'Silent' item
mHasSilentItem = intent.getBooleanExtra(RingtoneManager.EXTRA_RINGTONE_SHOW_SILENT, true);
// AudioAttributes flags
mAttributesFlags |= intent.getIntExtra(
RingtoneManager.EXTRA_RINGTONE_AUDIO_ATTRIBUTES_FLAGS,
0 /*defaultValue == no flags*/);
// Give the Activity so it can do managed queries
mRingtoneManager = new RingtoneManager(this);
......@@ -326,6 +333,12 @@ public final class RingtonePickerActivity extends AlertActivity implements
}
if (ringtone != null) {
if (mAttributesFlags != 0) {
ringtone.setAudioAttributes(
new AudioAttributes.Builder(ringtone.getAudioAttributes())
.setFlags(mAttributesFlags)
.build());
}
ringtone.play();
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment