Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(970)

Unified Diff: media/base/android/java/src/org/chromium/media/MediaPlayerListener.java

Issue 12480009: remove READ_PHONE_STATE permission as AudioManager can achieve the same functionality (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/shell/android/shell_apk/AndroidManifest.xml ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/base/android/java/src/org/chromium/media/MediaPlayerListener.java
diff --git a/media/base/android/java/src/org/chromium/media/MediaPlayerListener.java b/media/base/android/java/src/org/chromium/media/MediaPlayerListener.java
index 47bda73f55c0d477ac90aec0e79acb813bbe0af1..ba080c85e3383222d460e944b41d3bd55225bacd 100644
--- a/media/base/android/java/src/org/chromium/media/MediaPlayerListener.java
+++ b/media/base/android/java/src/org/chromium/media/MediaPlayerListener.java
@@ -9,8 +9,6 @@ import android.content.Context;
import android.content.pm.PackageManager;
import android.media.AudioManager;
import android.media.MediaPlayer;
-import android.telephony.PhoneStateListener;
-import android.telephony.TelephonyManager;
import org.chromium.base.CalledByNative;
import org.chromium.base.JNINamespace;
@@ -18,7 +16,7 @@ import org.chromium.base.JNINamespace;
// This class implements all the listener interface for android mediaplayer.
// Callbacks will be sent to the native class for processing.
@JNINamespace("media")
-class MediaPlayerListener extends PhoneStateListener implements MediaPlayer.OnPreparedListener,
+class MediaPlayerListener implements MediaPlayer.OnPreparedListener,
MediaPlayer.OnCompletionListener,
MediaPlayer.OnBufferingUpdateListener,
MediaPlayer.OnSeekCompleteListener,
@@ -106,15 +104,9 @@ class MediaPlayerListener extends PhoneStateListener implements MediaPlayer.OnPr
}
@Override
- public void onCallStateChanged(int type, String number) {
- if (type != TelephonyManager.CALL_STATE_IDLE) {
- nativeOnMediaInterrupted(mNativeMediaPlayerListener);
- }
- }
-
- @Override
public void onAudioFocusChange(int focusChange) {
- if (focusChange == AudioManager.AUDIOFOCUS_LOSS) {
+ if (focusChange == AudioManager.AUDIOFOCUS_LOSS ||
+ focusChange == AudioManager.AUDIOFOCUS_LOSS_TRANSIENT) {
nativeOnMediaInterrupted(mNativeMediaPlayerListener);
}
}
@@ -122,16 +114,6 @@ class MediaPlayerListener extends PhoneStateListener implements MediaPlayer.OnPr
@CalledByNative
public void releaseResources() {
if (mContext != null) {
- if (PackageManager.PERMISSION_GRANTED ==
- mContext.checkCallingOrSelfPermission(permission.READ_PHONE_STATE)) {
- // Unregister the listener.
- TelephonyManager mgr =
- (TelephonyManager) mContext.getSystemService(Context.TELEPHONY_SERVICE);
- if (mgr != null) {
- mgr.listen(this, PhoneStateListener.LISTEN_NONE);
- }
- }
-
// Unregister the wish for audio focus.
AudioManager am = (AudioManager) mContext.getSystemService(Context.AUDIO_SERVICE);
if (am != null) {
@@ -144,7 +126,7 @@ class MediaPlayerListener extends PhoneStateListener implements MediaPlayer.OnPr
private static MediaPlayerListener create(int nativeMediaPlayerListener,
Context context, MediaPlayer mediaPlayer) {
final MediaPlayerListener listener =
- new MediaPlayerListener(nativeMediaPlayerListener, context);
+ new MediaPlayerListener(nativeMediaPlayerListener, context);
mediaPlayer.setOnBufferingUpdateListener(listener);
mediaPlayer.setOnCompletionListener(listener);
mediaPlayer.setOnErrorListener(listener);
@@ -156,15 +138,6 @@ class MediaPlayerListener extends PhoneStateListener implements MediaPlayer.OnPr
mediaPlayer.setWakeMode(context, android.os.PowerManager.FULL_WAKE_LOCK);
}
- if (PackageManager.PERMISSION_GRANTED ==
- context.checkCallingOrSelfPermission(permission.READ_PHONE_STATE)) {
- TelephonyManager mgr =
- (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
- if (mgr != null) {
- mgr.listen(listener, PhoneStateListener.LISTEN_CALL_STATE);
- }
- }
-
AudioManager am = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE);
am.requestAudioFocus(
listener,
« no previous file with comments | « content/shell/android/shell_apk/AndroidManifest.xml ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698