带有AccessibilityService的Chrome重定向

时间:2018-07-17 06:33:18

标签: android accessibilityservice

借助辅助功能服务,我可以跟踪所打开的URL。如何使用Accessibility Service重定向或呈现本地页面。这是一个片段。

 @Override
    public void onAccessibilityEvent(AccessibilityEvent accessibilityEvent) {
        Log.d(TAG, "onAccessibilityEvent");
        final String sourcePackageName = (String) accessibilityEvent.getPackageName();
        currntApplicationPackage = sourcePackageName;
//        Log.d(TAG, "sourcePackageName:" + sourcePackageName);
        Log.d(TAG, "parcelable:" + accessibilityEvent.getText().toString());


        windowManager = (WindowManager) getSystemService(WINDOW_SERVICE);


        if (accessibilityEvent.getPackageName() == null || !(accessibilityEvent.getPackageName().equals("com.bsb.hike") || !(accessibilityEvent.getPackageName().equals("com.whatsapp") || accessibilityEvent.getPackageName().equals("com.facebook.orca") || accessibilityEvent.getPackageName().equals("com.twitter.android") || accessibilityEvent.getPackageName().equals("com.facebook.katana") || accessibilityEvent.getPackageName().equals("com.facebook.lite"))))
            showWindow = false;

//        Log.d("event type", "" + accessibilityEvent.getEventType());
        if (accessibilityEvent.getEventType() == AccessibilityEvent.TYPE_WINDOW_CONTENT_CHANGED) {
            if (accessibilityEvent.getPackageName().equals("com.android.chrome")) {

                AccessibilityNodeInfo nodeInfo = accessibilityEvent.getSource();
                dfs(nodeInfo);
//                if (accessibilityEvent.getText().toString().contains("https://www.linda")){
//                    Log.e("change","content change");
//                }
            }
        }
}

基本上,我想防止chrome加载某些网站,或者如果加载了某些网站,则重定向到另一个页面。

0 个答案:

没有答案