Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit caf294d0 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Make remote player support ramping ringer"

parents c3a11501 eac542e7
Loading
Loading
Loading
Loading
+3 −0
Original line number Original line Diff line number Diff line
@@ -17,6 +17,7 @@
package android.media;
package android.media;


import android.media.AudioAttributes;
import android.media.AudioAttributes;
import android.media.VolumeShaper;
import android.net.Uri;
import android.net.Uri;
import android.os.ParcelFileDescriptor;
import android.os.ParcelFileDescriptor;
import android.os.UserHandle;
import android.os.UserHandle;
@@ -27,6 +28,8 @@ import android.os.UserHandle;
interface IRingtonePlayer {
interface IRingtonePlayer {
    /** Used for Ringtone.java playback */
    /** Used for Ringtone.java playback */
    oneway void play(IBinder token, in Uri uri, in AudioAttributes aa, float volume, boolean looping);
    oneway void play(IBinder token, in Uri uri, in AudioAttributes aa, float volume, boolean looping);
    oneway void playWithVolumeShaping(IBinder token, in Uri uri, in AudioAttributes aa,
        float volume, boolean looping, in @nullable VolumeShaper.Configuration volumeShaperConfig);
    oneway void stop(IBinder token);
    oneway void stop(IBinder token);
    boolean isPlaying(IBinder token);
    boolean isPlaying(IBinder token);
    oneway void setPlaybackProperties(IBinder token, float volume, boolean looping);
    oneway void setPlaybackProperties(IBinder token, float volume, boolean looping);
+2 −1
Original line number Original line Diff line number Diff line
@@ -381,7 +381,8 @@ public class Ringtone {
                volume = mVolume;
                volume = mVolume;
            }
            }
            try {
            try {
                mRemotePlayer.play(mRemoteToken, canonicalUri, mAudioAttributes, volume, looping);
                mRemotePlayer.playWithVolumeShaping(mRemoteToken, canonicalUri, mAudioAttributes,
                        volume, looping, mVolumeShaperConfig);
            } catch (RemoteException e) {
            } catch (RemoteException e) {
                if (!playFallbackRingtone()) {
                if (!playFallbackRingtone()) {
                    Log.w(TAG, "Problem playing ringtone: " + e);
                    Log.w(TAG, "Problem playing ringtone: " + e);
+19 −0
Original line number Original line Diff line number Diff line
/* Copyright 2019, The Android Open Source Project
**
** Licensed under the Apache License, Version 2.0 (the "License");
** you may not use this file except in compliance with the License.
** You may obtain a copy of the License at
**
**     http://www.apache.org/licenses/LICENSE-2.0
**
** Unless required by applicable law or agreed to in writing, software
** distributed under the License is distributed on an "AS IS" BASIS,
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
** See the License for the specific language governing permissions and
** limitations under the License.
*/

package android.media;

parcelable VolumeShaper;
parcelable VolumeShaper.Configuration;
+15 −2
Original line number Original line Diff line number Diff line
@@ -16,6 +16,7 @@


package com.android.systemui.media;
package com.android.systemui.media;


import android.annotation.Nullable;
import android.content.ContentResolver;
import android.content.ContentResolver;
import android.content.Context;
import android.content.Context;
import android.content.pm.PackageManager.NameNotFoundException;
import android.content.pm.PackageManager.NameNotFoundException;
@@ -24,6 +25,7 @@ import android.media.AudioAttributes;
import android.media.IAudioService;
import android.media.IAudioService;
import android.media.IRingtonePlayer;
import android.media.IRingtonePlayer;
import android.media.Ringtone;
import android.media.Ringtone;
import android.media.VolumeShaper;
import android.net.Uri;
import android.net.Uri;
import android.os.Binder;
import android.os.Binder;
import android.os.IBinder;
import android.os.IBinder;
@@ -78,11 +80,16 @@ public class RingtonePlayer extends SystemUI {
        private final Ringtone mRingtone;
        private final Ringtone mRingtone;


        public Client(IBinder token, Uri uri, UserHandle user, AudioAttributes aa) {
        public Client(IBinder token, Uri uri, UserHandle user, AudioAttributes aa) {
            this(token, uri, user, aa, null);
        }

        Client(IBinder token, Uri uri, UserHandle user, AudioAttributes aa,
                @Nullable VolumeShaper.Configuration volumeShaperConfig) {
            mToken = token;
            mToken = token;


            mRingtone = new Ringtone(getContextForUser(user), false);
            mRingtone = new Ringtone(getContextForUser(user), false);
            mRingtone.setAudioAttributes(aa);
            mRingtone.setAudioAttributes(aa);
            mRingtone.setUri(uri);
            mRingtone.setUri(uri, volumeShaperConfig);
        }
        }


        @Override
        @Override
@@ -99,6 +106,12 @@ public class RingtonePlayer extends SystemUI {
        @Override
        @Override
        public void play(IBinder token, Uri uri, AudioAttributes aa, float volume, boolean looping)
        public void play(IBinder token, Uri uri, AudioAttributes aa, float volume, boolean looping)
                throws RemoteException {
                throws RemoteException {
            playWithVolumeShaping(token, uri, aa, volume, looping, null);
        }
        @Override
        public void playWithVolumeShaping(IBinder token, Uri uri, AudioAttributes aa, float volume,
                boolean looping, @Nullable VolumeShaper.Configuration volumeShaperConfig)
                throws RemoteException {
            if (LOGD) {
            if (LOGD) {
                Log.d(TAG, "play(token=" + token + ", uri=" + uri + ", uid="
                Log.d(TAG, "play(token=" + token + ", uri=" + uri + ", uid="
                        + Binder.getCallingUid() + ")");
                        + Binder.getCallingUid() + ")");
@@ -108,7 +121,7 @@ public class RingtonePlayer extends SystemUI {
                client = mClients.get(token);
                client = mClients.get(token);
                if (client == null) {
                if (client == null) {
                    final UserHandle user = Binder.getCallingUserHandle();
                    final UserHandle user = Binder.getCallingUserHandle();
                    client = new Client(token, uri, user, aa);
                    client = new Client(token, uri, user, aa, volumeShaperConfig);
                    token.linkToDeath(client, 0);
                    token.linkToDeath(client, 0);
                    mClients.put(token, client);
                    mClients.put(token, client);
                }
                }