Unity在development模式下的一个坑

最近发现unity生成的包在Nexus上如果打开带Input控件的界面时,关闭屏幕再打开,则永远无法显示输入法界面了。

一开始还以为是unity自己本身的bug,后来发现release版本并无这个问题,于是弄了个最简单的测试版本分别打了

两个包,然后apktool解码对比发现,com/unity3d/player/UnityPlayer.smali在development模式下多了几行代码如下:

diff -r Untitled/smali/com/unity3d/player/UnityPlayer.smali keyboard/smali/com/unity3d/player/UnityPlayer.smali
310a311,355
>     iget-object v0, p0, Lcom/unity3d/player/UnityPlayer;->h:Landroid/content/ContextWrapper;

>     instance-of v0, v0, Landroid/app/Activity;

>     if-eqz v0, :cond_5

>     iget-object v0, p0, Lcom/unity3d/player/UnityPlayer;->h:Landroid/content/ContextWrapper;

>     check-cast v0, Landroid/app/Activity;

>     invoke-virtual {v0}, Landroid/app/Activity;->getWindow()Landroid/view/Window;

>     move-result-object v0

>     const/high16 v1, 0x200000

>     invoke-virtual {v0, v1}, Landroid/view/Window;->addFlags(I)V

>     const/high16 v1, 0x80000

>     invoke-virtual {v0, v1}, Landroid/view/Window;->addFlags(I)V

>     const/high16 v1, 0x400000

>     invoke-virtual {v0, v1}, Landroid/view/Window;->addFlags(I)V


addFlags这种函数之前还真没用过,于是查了一下文档发现如下说明:


public static final int FLAG_SHOW_WHEN_LOCKED

Added in API level 5

Window flag: special flag to let windows be shown when the screen is locked. This will let application windows take precedence over key guard or any other lock screens. Can be used withFLAG_KEEP_SCREEN_ON to turn screen on and display windows directly before showing the key guard window. Can be used withFLAG_DISMISS_KEYGUARD to automatically fully dismisss non-secure keyguards. This flag only applies to the top-most full-screen window.

Constant Value: 524288 (0x00080000)


public static final int FLAG_DISMISS_KEYGUARD

Added in API level 5

Window flag: when set the window will cause the keyguard to be dismissed, only if it is not a secure lock keyguard. Because such a keyguard is not needed for security, it will never re-appear if the user navigates to another window (in contrast to FLAG_SHOW_WHEN_LOCKED, which will only temporarily hide both secure and non-secure keyguards but ensure they reappear when the user moves to another UI that doesn't hide them). If the keyguard is currently active and is secure (requires an unlock pattern) than the user will still need to confirm it before seeing this window, unlessFLAG_SHOW_WHEN_LOCKED has also been set.

Constant Value: 4194304 (0x00400000)



这个参数的结果就是输入法界面不显示了,这也不知道android确实是这么设计的还是个bug了。

你可能感兴趣的:(杂项)