| Index: content/public/android/java/src/org/chromium/content/browser/MediaSessionDelegate.java
|
| diff --git a/content/public/android/java/src/org/chromium/content/browser/MediaSessionDelegate.java b/content/public/android/java/src/org/chromium/content/browser/MediaSessionDelegate.java
|
| deleted file mode 100644
|
| index 36f1c0146bc6eb7b42a7429f401783e43a8dd583..0000000000000000000000000000000000000000
|
| --- a/content/public/android/java/src/org/chromium/content/browser/MediaSessionDelegate.java
|
| +++ /dev/null
|
| @@ -1,115 +0,0 @@
|
| -// Copyright 2015 The Chromium Authors. All rights reserved.
|
| -// Use of this source code is governed by a BSD-style license that can be
|
| -// found in the LICENSE file.
|
| -
|
| -package org.chromium.content.browser;
|
| -
|
| -import android.content.Context;
|
| -import android.media.AudioManager;
|
| -
|
| -import org.chromium.base.Log;
|
| -import org.chromium.base.ThreadUtils;
|
| -import org.chromium.base.annotations.CalledByNative;
|
| -import org.chromium.base.annotations.JNINamespace;
|
| -
|
| -/**
|
| - * MediaSession is the Java counterpart of content::MediaSessionDelegateAndroid.
|
| - * It is being used to communicate from content::MediaSessionDelegateAndroid
|
| - * (C++) to the Android system. A MediaSessionDelegate is implementingf
|
| - * OnAudioFocusChangeListener, making it an audio focus holder for Android. Thus
|
| - * two instances of MediaSessionDelegate can't have audio focus at the same
|
| - * time. A MediaSessionDelegate will use the type requested from its C++
|
| - * counterpart and will resume its play using the same type if it were to
|
| - * happen, for example, when it got temporarily suspended by a transient sound
|
| - * like a notification.
|
| - */
|
| -@JNINamespace("content")
|
| -public class MediaSessionDelegate implements AudioManager.OnAudioFocusChangeListener {
|
| - private static final String TAG = "MediaSession";
|
| -
|
| - private Context mContext;
|
| - private int mFocusType;
|
| - private boolean mIsDucking = false;
|
| -
|
| - // Native pointer to C++ content::MediaSessionDelegateAndroid.
|
| - // It will be set to 0 when the native MediaSessionDelegateAndroid object is destroyed.
|
| - private long mNativeMediaSessionDelegateAndroid;
|
| -
|
| - private MediaSessionDelegate(final Context context, long nativeMediaSessionDelegateAndroid) {
|
| - mContext = context;
|
| - mNativeMediaSessionDelegateAndroid = nativeMediaSessionDelegateAndroid;
|
| - }
|
| -
|
| - @CalledByNative
|
| - private static MediaSessionDelegate create(Context context,
|
| - long nativeMediaSessionDelegateAndroid) {
|
| - return new MediaSessionDelegate(context, nativeMediaSessionDelegateAndroid);
|
| - }
|
| -
|
| - @CalledByNative
|
| - private void tearDown() {
|
| - assert ThreadUtils.runningOnUiThread();
|
| - abandonAudioFocus();
|
| - mNativeMediaSessionDelegateAndroid = 0;
|
| - }
|
| -
|
| - @CalledByNative
|
| - private boolean requestAudioFocus(boolean transientFocus) {
|
| - assert ThreadUtils.runningOnUiThread();
|
| - mFocusType = transientFocus ? AudioManager.AUDIOFOCUS_GAIN_TRANSIENT_MAY_DUCK
|
| - : AudioManager.AUDIOFOCUS_GAIN;
|
| - return requestAudioFocusInternal();
|
| - }
|
| -
|
| - @CalledByNative
|
| - private void abandonAudioFocus() {
|
| - assert ThreadUtils.runningOnUiThread();
|
| - AudioManager am = (AudioManager) mContext.getSystemService(Context.AUDIO_SERVICE);
|
| - am.abandonAudioFocus(this);
|
| - }
|
| -
|
| - private boolean requestAudioFocusInternal() {
|
| - AudioManager am = (AudioManager) mContext.getSystemService(Context.AUDIO_SERVICE);
|
| -
|
| - int result = am.requestAudioFocus(this, AudioManager.STREAM_MUSIC, mFocusType);
|
| - return result == AudioManager.AUDIOFOCUS_REQUEST_GRANTED;
|
| - }
|
| -
|
| - @Override
|
| - public void onAudioFocusChange(int focusChange) {
|
| - assert ThreadUtils.runningOnUiThread();
|
| - if (mNativeMediaSessionDelegateAndroid == 0) return;
|
| -
|
| - switch (focusChange) {
|
| - case AudioManager.AUDIOFOCUS_GAIN:
|
| - if (mIsDucking) {
|
| - nativeOnStopDucking(mNativeMediaSessionDelegateAndroid);
|
| - mIsDucking = false;
|
| - } else {
|
| - nativeOnResume(mNativeMediaSessionDelegateAndroid);
|
| - }
|
| - break;
|
| - case AudioManager.AUDIOFOCUS_LOSS_TRANSIENT:
|
| - nativeOnSuspend(mNativeMediaSessionDelegateAndroid, true);
|
| - break;
|
| - case AudioManager.AUDIOFOCUS_LOSS_TRANSIENT_CAN_DUCK:
|
| - mIsDucking = true;
|
| - nativeRecordSessionDuck(mNativeMediaSessionDelegateAndroid);
|
| - nativeOnStartDucking(mNativeMediaSessionDelegateAndroid);
|
| - break;
|
| - case AudioManager.AUDIOFOCUS_LOSS:
|
| - abandonAudioFocus();
|
| - nativeOnSuspend(mNativeMediaSessionDelegateAndroid, false);
|
| - break;
|
| - default:
|
| - Log.w(TAG, "onAudioFocusChange called with unexpected value %d", focusChange);
|
| - break;
|
| - }
|
| - }
|
| -
|
| - private native void nativeOnSuspend(long nativeMediaSessionDelegateAndroid, boolean temporary);
|
| - private native void nativeOnResume(long nativeMediaSessionDelegateAndroid);
|
| - private native void nativeOnStartDucking(long nativeMediaSessionDelegateAndroid);
|
| - private native void nativeOnStopDucking(long nativeMediaSessionDelegateAndroid);
|
| - private native void nativeRecordSessionDuck(long nativeMediaSessionDelegateAndroid);
|
| -}
|
|
|