Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

android.permission.WAKE_LOCK #373

Closed
xiaozhizhong opened this issue Jun 2, 2020 · 4 comments
Closed

android.permission.WAKE_LOCK #373

xiaozhizhong opened this issue Jun 2, 2020 · 4 comments

Comments

@xiaozhizhong
Copy link

Flutter version: 1.17.2
Plugin version: 3.3.0
Android version: Android 10

Sometimes Flutter reports an exception: java.lang.SecurityException: Neither user 10133 nor current process has android.permission.WAKE_LOCK after created a InAppWebView, and after that InAppWebView not work at all.
After I add <uses-permission android:name="android.permission.WAKE_LOCK"/> into the AndroidManifest, the problem solved.
I've test it with 4 different Android 10 devices and it's all the same. But another Android 8 don't have this problem.

Log is added below:

E/InputMethodManager( 5541): b/117267690: Failed to get fallback IMM with expected displayId=2 actual IMM#displayId=0 view=com.pichillilorenzo.flutter_inappwebview.InAppWebView.InAppWebView{d681577 VFEDHVCL. ........ 0,0-1440,1000}
D/EGL_emulation( 5541): eglMakeCurrent: 0xe9263280: ver 3 0 (tinfo 0xddd83f50)
D/EGL_emulation( 5541): eglMakeCurrent: 0xe9263280: ver 3 0 (tinfo 0xddd83f50)
E/eglCodecCommon( 5541): glUtilsParamSize: unknow param 0x000088ef
E/eglCodecCommon( 5541): glUtilsParamSize: unknow param 0x000088ef
E/InputMethodManager( 5541): b/117267690: Failed to get fallback IMM with expected displayId=3 actual IMM#displayId=0 view=com.pichillilorenzo.flutter_inappwebview.InAppWebView.InAppWebView{d681577 VFEDHVCL. ........ 0,0-1440,1987}
E/MethodChannel#flutter/platform_views( 5541): Failed to handle method call
E/MethodChannel#flutter/platform_views( 5541): java.lang.SecurityException: Neither user 10133 nor current process has android.permission.WAKE_LOCK.
E/MethodChannel#flutter/platform_views( 5541): 	at android.os.Parcel.createException(Parcel.java:2071)
E/MethodChannel#flutter/platform_views( 5541): 	at android.os.Parcel.readException(Parcel.java:2039)
E/MethodChannel#flutter/platform_views( 5541): 	at android.os.Parcel.readException(Parcel.java:1987)
E/MethodChannel#flutter/platform_views( 5541): 	at android.view.IWindowSession$Stub$Proxy.addToDisplay(IWindowSession.java:1242)
E/MethodChannel#flutter/platform_views( 5541): 	at android.view.ViewRootImpl.setView(ViewRootImpl.java:864)
E/MethodChannel#flutter/platform_views( 5541): 	at android.view.WindowManagerGlobal.addView(WindowManagerGlobal.java:387)
E/MethodChannel#flutter/platform_views( 5541): 	at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:95)
E/MethodChannel#flutter/platform_views( 5541): 	at android.app.Dialog.show(Dialog.java:342)
E/MethodChannel#flutter/platform_views( 5541): 	at android.app.Presentation.show(Presentation.java:250)
E/MethodChannel#flutter/platform_views( 5541): 	at io.flutter.plugin.platform.VirtualDisplayController.resize(VirtualDisplayController.java:160)
E/MethodChannel#flutter/platform_views( 5541): 	at io.flutter.plugin.platform.PlatformViewsController$1.resizePlatformView(PlatformViewsController.java:191)
E/MethodChannel#flutter/platform_views( 5541): 	at io.flutter.embedding.engine.systemchannels.PlatformViewsChannel$1.resize(PlatformViewsChannel.java:120)
E/MethodChannel#flutter/platform_views( 5541): 	at io.flutter.embedding.engine.systemchannels.PlatformViewsChannel$1.onMethodCall(PlatformViewsChannel.java:65)
E/MethodChannel#flutter/platform_views( 5541): 	at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:226)
E/MethodChannel#flutter/platform_views( 5541): 	at io.flutter.embedding.engine.dart.DartMessenger.handleMessageFromDart(DartMessenger.java:85)
E/MethodChannel#flutter/platform_views( 5541): 	at io.flutter.embedding.engine.FlutterJNI.handlePlatformMessage(FlutterJNI.java:631)
E/MethodChannel#flutter/platform_views( 5541): 	at android.os.MessageQueue.nativePollOnce(Native Method)
E/MethodChannel#flutter/platform_views( 5541): 	at android.os.MessageQueue.next(MessageQueue.java:336)
E/MethodChannel#flutter/platform_views( 5541): 	at android.os.Looper.loop(Looper.java:174)
E/MethodChannel#flutter/platform_views( 5541): 	at android.app.ActivityThread.main(ActivityThread.java:7356)
E/MethodChannel#flutter/platform_views( 5541): 	at java.lang.reflect.Method.invoke(Native Method)
E/MethodChannel#flutter/platform_views( 5541): 	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
E/MethodChannel#flutter/platform_views( 5541): 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930)
E/MethodChannel#flutter/platform_views( 5541): Caused by: android.os.RemoteException: Remote stack trace:
E/MethodChannel#flutter/platform_views( 5541): 	at android.app.ContextImpl.enforce(ContextImpl.java:1896)
E/MethodChannel#flutter/platform_views( 5541): 	at android.app.ContextImpl.enforceCallingOrSelfPermission(ContextImpl.java:1924)
E/MethodChannel#flutter/platform_views( 5541): 	at com.android.server.power.PowerManagerService$BinderService.acquireWakeLock(PowerManagerService.java:4270)
E/MethodChannel#flutter/platform_views( 5541): 	at android.os.PowerManager$WakeLock.acquireLocked(PowerManager.java:2186)
E/MethodChannel#flutter/platform_views( 5541): 	at android.os.PowerManager$WakeLock.acquire(PowerManager.java:2152)
E/MethodChannel#flutter/platform_views( 5541): 
I/n.creation_lin( 5541): Waiting for a blocking GC ProfileSaver
@pichillilorenzo
Copy link
Owner

I think that is related to how Flutter manages native views through native Java API. I don't use WAKE_LOCK permission inside my plugin code (anyone can see this, just check my Java code).

However, it seems that other plugins have this issue, such as the official webview_flutter plugin (flutter/flutter#49912), or google_maps_flutter plugin (flutter/flutter#42451).

Probably there is something wrong inside the Flutter Java native API.

For now, the only possible way is to add in your AndroidManifest.xml:

<uses-permission android:name="android.permission.WAKE_LOCK"/>

as you did.

@phanirithvij
Copy link

@pichillilorenzo do you think it's a good idea to have the wake_lock permission in the manifest lying there? Does it have any bad implications?

@yangdengxueshi
Copy link

<uses-permission
    android:name="android.permission.WAKE_LOCK"
    tools:node="replace" />

Copy link

github-actions bot commented Oct 7, 2024

This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug and a minimal reproduction of the issue.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 7, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants