Skip to content

Commit 8d48b75

Browse files
Teng-Hui ZhuAndroid (Google) Code Review
authored andcommitted
Merge "Double check the permission before setting the Wake Lock"
2 parents cbb62bb + fb2fd5f commit 8d48b75

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

core/java/android/webkit/HTML5VideoInline.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11

22
package android.webkit;
33

4+
import android.Manifest.permission;
5+
import android.content.pm.PackageManager;
46
import android.graphics.SurfaceTexture;
57
import android.media.MediaPlayer;
68
import android.webkit.HTML5VideoView;
@@ -52,7 +54,12 @@ public void decideDisplayMode() {
5254
public void prepareDataAndDisplayMode(HTML5VideoViewProxy proxy) {
5355
super.prepareDataAndDisplayMode(proxy);
5456
setFrameAvailableListener(proxy);
55-
mPlayer.setWakeMode(proxy.getContext(), PowerManager.FULL_WAKE_LOCK);
57+
// TODO: This is a workaround, after b/5375681 fixed, we should switch
58+
// to the better way.
59+
if (mProxy.getContext().checkCallingOrSelfPermission(permission.WAKE_LOCK)
60+
== PackageManager.PERMISSION_GRANTED) {
61+
mPlayer.setWakeMode(proxy.getContext(), PowerManager.FULL_WAKE_LOCK);
62+
}
5663
}
5764

5865
// Pause the play and update the play/pause button

0 commit comments

Comments
 (0)