Skip to content

Commit 6ee3fe8

Browse files
jsharkeyAndroid (Google) Code Review
authored andcommitted
Merge "Migrate ringtone playback to SystemUI." into jb-dev
2 parents 2c85f51 + 098d580 commit 6ee3fe8

File tree

14 files changed

+390
-128
lines changed

14 files changed

+390
-128
lines changed

Android.mk

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,7 @@ LOCAL_SRC_FILES += \
198198
media/java/android/media/IMediaScannerService.aidl \
199199
media/java/android/media/IRemoteControlClient.aidl \
200200
media/java/android/media/IRemoteControlDisplay.aidl \
201+
media/java/android/media/IRingtonePlayer.aidl \
201202
telephony/java/com/android/internal/telephony/IPhoneStateListener.aidl \
202203
telephony/java/com/android/internal/telephony/IPhoneSubInfo.aidl \
203204
telephony/java/com/android/internal/telephony/ITelephony.aidl \

core/java/android/app/Notification.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import android.content.Context;
2222
import android.content.Intent;
2323
import android.graphics.Bitmap;
24+
import android.media.AudioManager;
2425
import android.net.Uri;
2526
import android.os.Bundle;
2627
import android.os.IBinder;
@@ -213,7 +214,7 @@ public class Notification implements Parcelable
213214
/**
214215
* Use this constant as the value for audioStreamType to request that
215216
* the default stream type for notifications be used. Currently the
216-
* default stream type is STREAM_RING.
217+
* default stream type is {@link AudioManager#STREAM_NOTIFICATION}.
217218
*/
218219
public static final int STREAM_DEFAULT = -1;
219220

core/res/AndroidManifest.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -628,6 +628,11 @@
628628
android:permissionGroup="android.permission-group.SYSTEM_TOOLS"
629629
android:protectionLevel="signature" />
630630

631+
<!-- Allows registration for remote audio playback. @hide -->
632+
<permission android:name="android.permission.REMOTE_AUDIO_PLAYBACK"
633+
android:permissionGroup="android.permission-group.SYSTEM_TOOLS"
634+
android:protectionLevel="signature" />
635+
631636
<!-- =========================================== -->
632637
<!-- Permissions associated with telephony state -->
633638
<!-- =========================================== -->

media/java/android/media/AudioManager.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2306,4 +2306,12 @@ public int getDevicesForStream(int streamType) {
23062306
}
23072307
}
23082308

2309+
/** {@hide} */
2310+
public IRingtonePlayer getRingtonePlayer() {
2311+
try {
2312+
return getService().getRingtonePlayer();
2313+
} catch (RemoteException e) {
2314+
return null;
2315+
}
2316+
}
23092317
}

media/java/android/media/AudioService.java

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
package android.media;
1818

19+
import static android.Manifest.permission.REMOTE_AUDIO_PLAYBACK;
1920
import static android.media.AudioManager.RINGER_MODE_NORMAL;
2021
import static android.media.AudioManager.RINGER_MODE_SILENT;
2122
import static android.media.AudioManager.RINGER_MODE_VIBRATE;
@@ -360,7 +361,6 @@ public void onError(int error) {
360361
private int mPrevVolDirection = AudioManager.ADJUST_SAME;
361362
// Keyguard manager proxy
362363
private KeyguardManager mKeyguardManager;
363-
364364
// mVolumeControlStream is set by VolumePanel to temporarily force the stream type which volume
365365
// is controlled by Vol keys.
366366
private int mVolumeControlStream = -1;
@@ -369,6 +369,8 @@ public void onError(int error) {
369369
// server process so in theory it is not necessary to monitor the client death.
370370
// However it is good to be ready for future evolutions.
371371
private ForceControlStreamClient mForceControlStreamClient = null;
372+
// Used to play ringtones outside system_server
373+
private volatile IRingtonePlayer mRingtonePlayer;
372374

373375
///////////////////////////////////////////////////////////////////////////
374376
// Construction
@@ -4230,6 +4232,17 @@ public void remoteControlDisplayUsesBitmapSize(IRemoteControlDisplay rcd, int w,
42304232
}
42314233
}
42324234

4235+
@Override
4236+
public void setRingtonePlayer(IRingtonePlayer player) {
4237+
mContext.enforceCallingOrSelfPermission(REMOTE_AUDIO_PLAYBACK, null);
4238+
mRingtonePlayer = player;
4239+
}
4240+
4241+
@Override
4242+
public IRingtonePlayer getRingtonePlayer() {
4243+
return mRingtonePlayer;
4244+
}
4245+
42334246
@Override
42344247
protected void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
42354248
mContext.enforceCallingOrSelfPermission(android.Manifest.permission.DUMP, TAG);
@@ -4238,6 +4251,4 @@ protected void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
42384251
dumpFocusStack(pw);
42394252
dumpRCStack(pw);
42404253
}
4241-
4242-
42434254
}

media/java/android/media/IAudioService.aidl

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ import android.content.ComponentName;
2121
import android.media.IAudioFocusDispatcher;
2222
import android.media.IRemoteControlClient;
2323
import android.media.IRemoteControlDisplay;
24+
import android.media.IRingtonePlayer;
25+
import android.net.Uri;
2426

2527
/**
2628
* {@hide}
@@ -113,10 +115,11 @@ interface IAudioService {
113115
oneway void remoteControlDisplayUsesBitmapSize(in IRemoteControlDisplay rcd, int w, int h);
114116

115117
void startBluetoothSco(IBinder cb);
116-
117118
void stopBluetoothSco(IBinder cb);
118119

119120
void forceVolumeControlStream(int streamType, IBinder cb);
120121

122+
void setRingtonePlayer(IRingtonePlayer player);
123+
IRingtonePlayer getRingtonePlayer();
121124
int getMasterStreamType();
122125
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/*
2+
* Copyright (C) 2012 The Android Open Source Project
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package android.media;
18+
19+
import android.net.Uri;
20+
21+
/**
22+
* @hide
23+
*/
24+
interface IRingtonePlayer {
25+
/** Used for Ringtone.java playback */
26+
void play(IBinder token, in Uri uri, int streamType);
27+
void stop(IBinder token);
28+
boolean isPlaying(IBinder token);
29+
30+
/** Used for Notification sound playback. */
31+
void playAsync(in Uri uri, boolean looping, int streamType);
32+
void stopAsync();
33+
}

0 commit comments

Comments
 (0)