Example usage for android.view.accessibility AccessibilityNodeInfo getPackageName

List of usage examples for android.view.accessibility AccessibilityNodeInfo getPackageName

Introduction

In this page you can find the example usage for android.view.accessibility AccessibilityNodeInfo getPackageName.

Prototype

public CharSequence getPackageName() 

Source Link

Document

Gets the package this node comes from.

Usage

From source file:com.android.talkback.eventprocessor.ProcessorScreen.java

private CharSequence getWindowTitleForFeedback(int windowId) {
    CharSequence title = getWindowTitle(windowId);

    // Try to fall back to application label if window title is not available.
    if (title == null) {
        CharSequence packageName = mWindowToPackageName.get(windowId);

        // Try to get package name from accessibility window info if it's not in the map.
        if (packageName == null && Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
            for (AccessibilityWindowInfo window : mService.getWindows()) {
                if (window.getId() == windowId) {
                    AccessibilityNodeInfo rootNode = window.getRoot();
                    if (rootNode != null) {
                        packageName = rootNode.getPackageName();
                        rootNode.recycle();
                    }/*from  www  . java  2s.c om*/
                }
            }
        }

        if (packageName != null) {
            title = mService.getApplicationLabel(packageName);
        }
    }

    title = WindowManager.formatWindowTitleForFeedback(title, mService);

    if (isAlertDialog(windowId)) {
        title = mService.getString(R.string.template_alert_dialog_template, title);
    }

    return title;
}

From source file:com.google.android.apps.common.testing.accessibility.framework.uielement.ViewHierarchyElement.java

ViewHierarchyElement(int id, @Nullable ViewHierarchyElement parent, AccessibilityNodeInfo fromInfo) {
    // Bookkeeping
    this.id = id;
    this.parentId = (parent != null) ? parent.getId() : null;

    // API 18+ properties
    this.resourceName = AT_18 ? fromInfo.getViewIdResourceName() : null;
    this.editable = AT_18 ? fromInfo.isEditable() : null;

    // API 16+ properties
    this.visibleToUser = AT_16 ? fromInfo.isVisibleToUser() : null;

    // Base properties
    this.className = fromInfo.getClassName();
    this.packageName = fromInfo.getPackageName();
    this.accessibilityClassName = fromInfo.getClassName();
    this.contentDescription = SpannableString.valueOf(fromInfo.getContentDescription());
    this.text = SpannableString.valueOf(fromInfo.getText());
    this.importantForAccessibility = true;
    this.clickable = fromInfo.isClickable();
    this.longClickable = fromInfo.isLongClickable();
    this.focusable = fromInfo.isFocusable();
    this.scrollable = fromInfo.isScrollable();
    this.canScrollForward = ((fromInfo.getActions() & AccessibilityNodeInfo.ACTION_SCROLL_FORWARD) != 0);
    this.canScrollBackward = ((fromInfo.getActions() & AccessibilityNodeInfo.ACTION_SCROLL_BACKWARD) != 0);
    this.checkable = fromInfo.isCheckable();
    this.checked = fromInfo.isChecked();
    this.hasTouchDelegate = false; /* Touch delegates are not considered by AccessibilityServices */
    android.graphics.Rect tempRect = new android.graphics.Rect();
    fromInfo.getBoundsInScreen(tempRect);
    this.boundsInScreen = new Rect(tempRect);
    this.nonclippedHeight = null; /* AccessibilityServices cannot discover nonclipped dimensions */
    this.nonclippedWidth = null; /* AccessibilityServices cannot discover nonclipped dimensions */
    this.textSize = null;
    this.textColor = null;
    this.backgroundDrawableColor = null;
    this.typefaceStyle = null;
    this.enabled = fromInfo.isEnabled();
}