带有隐藏状态栏的 Android 浮动窗口 辅助功能问题 [英] Android floating window with hidden statusbar Accessibility problems

查看:34
本文介绍了带有隐藏状态栏的 Android 浮动窗口 辅助功能问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 android 4.4.2 构建一个应用程序,该应用程序带有由无障碍服务创建的系统覆盖/浮动窗口.

I am working on android 4.4.2 building an application with a system overlay/floating window created by an accessibility service.

我希望能够全局隐藏状态栏(在任何应用程序中)(通过下面的代码实现)但是当显示叠加层时,我停止从侦听器接收 accessibilityEvents 并且软件/硬件后退按钮当浮动视图被注入到windowmanager中时:

I want to be able to hide the status bar GLOBALLY (in any app) (made possible by the code below) however when the overlay is shown i stop receiving acessibilityEvents from the listener and the software/hardware back button When the floating view is injected into windowmanager:

  1. AccessibilityEvent 侦听器未收到更新
  2. 软/硬件后退键未注册(家庭/最近注册)

为了隐藏状态栏 'FLAG_FULLSCREEN |需要 FLAG_NOT_TOUCH_MODAL' 以允许触摸屏幕的其余部分,并且 'View.SYSTEM_UI_FLAG_FULLSCREEN' 允许

in order to hide the status bar both 'FLAG_FULLSCREEN | FLAG_NOT_TOUCH_MODAL' are needed to allow touching the rest of the screen and 'View.SYSTEM_UI_FLAG_FULLSCREEN' allows

无障碍服务(连接方式):

  @Override
    public void onServiceConnected() {
        serviceInstance = this;
        windowManager = (WindowManager) getSystemService(WINDOW_SERVICE);

        FloatingView = new View(this);

        WindowManager.LayoutParams params = new WindowManager.LayoutParams(
                0, 0,
                0, 0,
                TYPE_PRIORITY_PHONE,
                FLAG_FULLSCREEN | FLAG_NOT_TOUCH_MODAL, PixelFormat.OPAQUE);
        params.gravity = Gravity.CENTER_HORIZONTAL | Gravity.BOTTOM;
        params.windowAnimations = android.R.style.Animation_Toast;
        params.gravity = Gravity.BOTTOM | Gravity.RIGHT;

            windowManager.addView(FloatingView, params);

 int uiOptions = View.SYSTEM_UI_FLAG_FULLSCREEN;
  FloatingView.setSystemUiVisibility(uiOptions);

        }

无障碍服务(连接方式):

@Override
public void onAccessibilityEvent(AccessibilityEvent accessibilityEvent) {
    Log.i("","Just log me some rubbish");

}

我的 AccessibilitySetup.xml:

<accessibility-service xmlns:android="http://schemas.android.com/apk/res/android"
    android:accessibilityEventTypes="typeAllMask"
    android:accessibilityFeedbackType="feedbackAllMask"
    android:notificationTimeout="0"
    android:accessibilityFlags="flagDefault"
    android:canRetrieveWindowContent="true"
    android:description="@string/notification_description"
    />

推荐答案

经过长时间和一周的研究,我发现由于安全限制,无法同时执行这两项操作.我将在我的应用的根模式中实现这些功能.

After long hours and a week of research i found theres is no way to do both of these due to security restrictions. i will implmenet these features in the root mode of my app.

我使用的解决方法是一个简单的按钮,它可以恢复系统 ui 并删除阻止可访问性输入的视图

the workaround i am using is a simple button that revives the system ui and removes the view that is blocking the accessibility input

这篇关于带有隐藏状态栏的 Android 浮动窗口 辅助功能问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆