Java Code Examples for android.accessibilityservice.AccessibilityServiceInfo

The following examples show how to use android.accessibilityservice.AccessibilityServiceInfo. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
/**
 * Checks whether or not touch to explore is enabled on the system.
 */
public boolean accessibilityIsAvailable() {
    if (!getAccessibilityManager().isEnabled() ||
            mContentViewCore.getContentSettings() == null ||
            !mContentViewCore.getContentSettings().getJavaScriptEnabled()) {
        return false;
    }

    try {
        // Check that there is actually a service running that requires injecting this script.
        List<AccessibilityServiceInfo> services =
                getAccessibilityManager().getEnabledAccessibilityServiceList(
                        FEEDBACK_BRAILLE | AccessibilityServiceInfo.FEEDBACK_SPOKEN);
        return services.size() > 0;
    } catch (NullPointerException e) {
        // getEnabledAccessibilityServiceList() can throw an NPE due to a bad
        // AccessibilityService.
        return false;
    }
}
 
Example 2
Source Project: android_9.0.0_r45   Source File: UiAutomation.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Sets the {@link AccessibilityServiceInfo} that describes how this
 * UiAutomation will be handled by the platform accessibility layer.
 *
 * @param info The info.
 *
 * @see AccessibilityServiceInfo
 */
public final void setServiceInfo(AccessibilityServiceInfo info) {
    final IAccessibilityServiceConnection connection;
    synchronized (mLock) {
        throwIfNotConnectedLocked();
        AccessibilityInteractionClient.getInstance().clearCache();
        connection = AccessibilityInteractionClient.getInstance()
                .getConnection(mConnectionId);
    }
    // Calling out without a lock held.
    if (connection != null) {
        try {
            connection.setServiceInfo(info);
        } catch (RemoteException re) {
            Log.w(LOG_TAG, "Error while setting AccessibilityServiceInfo", re);
        }
    }
}
 
Example 3
Source Project: WeChatHongBao   Source File: QQFragment.java    License: Apache License 2.0 6 votes vote down vote up
private void updateServiceStatus() {
    boolean serviceEnabled = false;

    AccessibilityManager accessibilityManager =
            (AccessibilityManager) baseContext.getSystemService(Context.ACCESSIBILITY_SERVICE);
    List<AccessibilityServiceInfo> accessibilityServices =
            accessibilityManager.getEnabledAccessibilityServiceList(AccessibilityServiceInfo.FEEDBACK_GENERIC);
    for (AccessibilityServiceInfo info : accessibilityServices) {
        if (info.getId().equals(baseContext.getPackageName() + "/.services.QQService")) {
            serviceEnabled = true;
            break;
        }
    }

    if (!serviceEnabled) {
        btn.setText(R.string.service_open);
    } else {
        btn.setText(R.string.service_off);
    }
}
 
Example 4
Source Project: Float-Bar   Source File: MainActivity.java    License: Eclipse Public License 1.0 6 votes vote down vote up
@Override
protected void onResume() {
	super.onResume();
	AccessibilityManager manager = (AccessibilityManager) getSystemService(ACCESSIBILITY_SERVICE);
	List<AccessibilityServiceInfo> list = AccessibilityManagerCompat.getEnabledAccessibilityServiceList(manager,
			AccessibilityServiceInfo.FEEDBACK_ALL_MASK);
	System.out.println("list.size = " + list.size());
	for (int i = 0; i < list.size(); i++) {
		System.out.println("已经可用的服务列表 = " + list.get(i).getId());
		if ("com.kale.floatbar/.service.FloatService".equals(list.get(i).getId())) {
			System.out.println("已启用");
			isEnabled = true;
			break;
		}
	}
	if (!isEnabled) {
		showDialog(this, "激活悬浮窗", "您还没有激活悬浮窗。" + "在设置中:系统 → 辅助功能 → 服务 中激活" + getResources().getString(R.string.app_name)
				+ "后,便可安全稳定的使用悬浮窗啦~", "去激活", "取消");
	}
}
 
Example 5
Source Project: talkback   Source File: SwitchAccessService.java    License: Apache License 2.0 5 votes vote down vote up
private void updateServiceInfoIfFeedbackTypeChanged() {
  boolean spokenFeedbackEnabled = SwitchAccessPreferenceUtils.isSpokenFeedbackEnabled(this);
  boolean hapticFeedbackEnabled = SwitchAccessPreferenceUtils.shouldPlayVibrationFeedback(this);
  boolean auditoryFeedbackEnabled = SwitchAccessPreferenceUtils.shouldPlaySoundFeedback(this);

  if ((spokenFeedbackEnabled == spokenFeedbackEnabledInServiceInfo)
      && (hapticFeedbackEnabled == hapticFeedbackEnabledInServiceInfo)
      && (auditoryFeedbackEnabled == auditoryFeedbackEnabledInServiceInfo)) {
    return;
  }

  AccessibilityServiceInfo serviceInfo = getServiceInfo();
  if (serviceInfo == null) {
    LogUtils.e(TAG, "Failed to update feedback type, service info was null");
    return;
  }

  if (spokenFeedbackEnabled) {
    serviceInfo.feedbackType |= AccessibilityServiceInfo.FEEDBACK_SPOKEN;
  } else {
    serviceInfo.feedbackType &= ~AccessibilityServiceInfo.FEEDBACK_SPOKEN;
  }
  if (hapticFeedbackEnabled) {
    serviceInfo.feedbackType |= AccessibilityServiceInfo.FEEDBACK_HAPTIC;
  } else {
    serviceInfo.feedbackType &= ~AccessibilityServiceInfo.FEEDBACK_HAPTIC;
  }
  if (auditoryFeedbackEnabled) {
    serviceInfo.feedbackType |= AccessibilityServiceInfo.FEEDBACK_AUDIBLE;
  } else {
    serviceInfo.feedbackType &= ~AccessibilityServiceInfo.FEEDBACK_AUDIBLE;
  }
  setServiceInfo(serviceInfo);

  spokenFeedbackEnabledInServiceInfo = spokenFeedbackEnabled;
  hapticFeedbackEnabledInServiceInfo = hapticFeedbackEnabled;
  auditoryFeedbackEnabledInServiceInfo = auditoryFeedbackEnabled;
}
 
Example 6
Source Project: za-Farmer   Source File: UiDevice.java    License: MIT License 5 votes vote down vote up
/** Private constructor. Clients should use {@link UiDevice#getInstance(Instrumentation)}. */
private UiDevice(Instrumentation instrumentation) {
    mInstrumentation = instrumentation;
    UiAutomation uiAutomation = instrumentation.getUiAutomation();
    mUiAutomationBridge = new InstrumentationUiAutomatorBridge(
            instrumentation.getContext(), uiAutomation);

    // Enable multi-window support for API level 21 and up
    if (UiDevice.API_LEVEL_ACTUAL >= Build.VERSION_CODES.LOLLIPOP) {
        // Subscribe to window information
        AccessibilityServiceInfo info = uiAutomation.getServiceInfo();
        info.flags |= AccessibilityServiceInfo.FLAG_RETRIEVE_INTERACTIVE_WINDOWS;
        uiAutomation.setServiceInfo(info);
    }
}
 
Example 7
Source Project: android_9.0.0_r45   Source File: AccessibilityManager.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Returns the {@link AccessibilityServiceInfo}s of the installed accessibility services.
 *
 * @return An unmodifiable list with {@link AccessibilityServiceInfo}s.
 */
public List<AccessibilityServiceInfo> getInstalledAccessibilityServiceList() {
    final IAccessibilityManager service;
    final int userId;
    synchronized (mLock) {
        service = getServiceLocked();
        if (service == null) {
            return Collections.emptyList();
        }
        userId = mUserId;
    }

    List<AccessibilityServiceInfo> services = null;
    try {
        services = service.getInstalledAccessibilityServiceList(userId);
        if (DEBUG) {
            Log.i(LOG_TAG, "Installed AccessibilityServices " + services);
        }
    } catch (RemoteException re) {
        Log.e(LOG_TAG, "Error while obtaining the installed AccessibilityServices. ", re);
    }
    if (mAccessibilityPolicy != null) {
        services = mAccessibilityPolicy.getInstalledAccessibilityServiceList(services);
    }
    if (services != null) {
        return Collections.unmodifiableList(services);
    } else {
        return Collections.emptyList();
    }
}
 
Example 8
Source Project: android_9.0.0_r45   Source File: AccessibilityManager.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Check if the accessibility volume stream is active.
 *
 * @return True if accessibility volume is active (i.e. some service has requested it). False
 * otherwise.
 * @hide
 */
public boolean isAccessibilityVolumeStreamActive() {
    List<AccessibilityServiceInfo> serviceInfos =
            getEnabledAccessibilityServiceList(AccessibilityServiceInfo.FEEDBACK_ALL_MASK);
    for (int i = 0; i < serviceInfos.size(); i++) {
        if ((serviceInfos.get(i).flags & FLAG_ENABLE_ACCESSIBILITY_VOLUME) != 0) {
            return true;
        }
    }
    return false;
}
 
Example 9
Source Project: android_9.0.0_r45   Source File: AccessibilityManager.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Find an installed service with the specified {@link ComponentName}.
 *
 * @param componentName The name to match to the service.
 *
 * @return The info corresponding to the installed service, or {@code null} if no such service
 * is installed.
 * @hide
 */
public AccessibilityServiceInfo getInstalledServiceInfoWithComponentName(
        ComponentName componentName) {
    final List<AccessibilityServiceInfo> installedServiceInfos =
            getInstalledAccessibilityServiceList();
    if ((installedServiceInfos == null) || (componentName == null)) {
        return null;
    }
    for (int i = 0; i < installedServiceInfos.size(); i++) {
        if (componentName.equals(installedServiceInfos.get(i).getComponentName())) {
            return installedServiceInfos.get(i);
        }
    }
    return null;
}
 
Example 10
Source Project: VoIpUSSD   Source File: USSDController.java    License: Apache License 2.0 5 votes vote down vote up
protected static boolean isAccessiblityServicesEnable(Context context) {
    AccessibilityManager am = (AccessibilityManager) context
            .getSystemService(Context.ACCESSIBILITY_SERVICE);
    if (am != null) {
        for (AccessibilityServiceInfo service : am.getInstalledAccessibilityServiceList()) {
            if (service.getId().contains(context.getPackageName())) {
                return USSDController.isAccessibilitySettingsOn(context, service.getId());
            }
        }
    }
    return false;
}
 
Example 11
Source Project: NewsPushMonitor   Source File: MainActivity.java    License: Apache License 2.0 5 votes vote down vote up
private boolean isServiceEnabled() {
    List<AccessibilityServiceInfo> accessibilityServices =
            accessibilityManager.getEnabledAccessibilityServiceList(AccessibilityServiceInfo.FEEDBACK_GENERIC);
    for (AccessibilityServiceInfo info : accessibilityServices) {
        if (info.getId().equals(getPackageName() + "/.PushMonitorAccessibilityService")) {
            return true;
        }
    }
    return false;
}
 
Example 12
Source Project: V.FlyoutTest   Source File: AccessibilityServiceInfoCompat.java    License: MIT License 5 votes vote down vote up
@Override
public int getCapabilities(AccessibilityServiceInfo info) {
    if (getCanRetrieveWindowContent(info)) {
        return CAPABILITY_CAN_RETRIEVE_WINDOW_CONTENT;
    }
    return 0;
}
 
Example 13
Source Project: Noyze   Source File: VolumeAccessibilityService.java    License: Apache License 2.0 5 votes vote down vote up
protected void initServiceInfo() {
	mInfo.eventTypes = AccessibilityEvent.TYPES_ALL_MASK;
    mInfo.notificationTimeout = 100;
    
    // This is the KEY (to KeyEvents)! Sweet deal.
    mInfo.flags = AccessibilityServiceInfo.FLAG_REQUEST_FILTER_KEY_EVENTS;

	// We'll respond with a popup (visual), and possibly a noise (audible)
	// and/ or a vibration (haptic). No spoken feedback here!
    mInfo.feedbackType = (AccessibilityServiceInfo.FEEDBACK_VISUAL	|
    					  AccessibilityServiceInfo.FEEDBACK_AUDIBLE	|
    					  AccessibilityServiceInfo.FEEDBACK_HAPTIC	);
    
    setServiceInfo(mInfo);
}
 
Example 14
Source Project: kernel_adiutor   Source File: Per_App.java    License: Apache License 2.0 5 votes vote down vote up
public static boolean isAccessibilityEnabled(Context context, String id) {

        AccessibilityManager am = (AccessibilityManager) context
                .getSystemService(Context.ACCESSIBILITY_SERVICE);

        List<AccessibilityServiceInfo> runningServices = am
                .getEnabledAccessibilityServiceList(AccessibilityEvent.TYPES_ALL_MASK);
        for (AccessibilityServiceInfo service : runningServices) {
            if (id != null && id.equals(service.getId())) {
                return true;
            }
        }

        return false;
    }
 
Example 15
Source Project: HeadsUp   Source File: AccessibilityService.java    License: GNU General Public License v2.0 5 votes vote down vote up
@Override
public void onServiceConnected() {
    AccessibilityServiceInfo info = new AccessibilityServiceInfo();
    info.eventTypes = AccessibilityEvent.TYPE_NOTIFICATION_STATE_CHANGED;
    info.feedbackType = AccessibilityServiceInfo.FEEDBACK_GENERIC;
    info.notificationTimeout = 100;
    setServiceInfo(info);
}
 
Example 16
@Override
public int getCapabilities(AccessibilityServiceInfo info) {
    if (getCanRetrieveWindowContent(info)) {
        return CAPABILITY_CAN_RETRIEVE_WINDOW_CONTENT;
    }
    return 0;
}
 
Example 17
Source Project: test-butler   Source File: ButlerService.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void onCreate() {
    super.onCreate();

    Log.d(TAG, "ButlerService starting up...");

    AppSettingsAccessor settings = new AppSettingsAccessor(getContentResolver());

    gsmDataDisabler = new GsmDataDisabler();
    permissionGranter = new PermissionGranter();
    InstalledAccessibilityServiceProvider serviceProvider = new InstalledAccessibilityServiceProvider() {
        @NonNull
        @Override
        public List<AccessibilityServiceInfo> getInstalledAccessibilityServiceList() {
            AccessibilityManager manager = (AccessibilityManager) getApplicationContext()
                    .getSystemService(ACCESSIBILITY_SERVICE);
            if (manager == null) {
                return Collections.emptyList();
            }
            return manager.getInstalledAccessibilityServiceList();
        }
    };
    accessibilityServiceEnabler = new AccessibilityServiceEnabler(serviceProvider, settings);
    accessibilityServiceWaiter = new AccessibilityServiceWaiter();
    locks = new CommonDeviceLocks();
    locks.acquire(this);

    butlerApi.onCreate(settings);

    // Install custom IActivityController to prevent system dialogs from appearing if apps crash or ANR
    NoDialogActivityController.install();
}
 
Example 18
Source Project: test-butler   Source File: AccessibilityServiceEnabler.java    License: Apache License 2.0 5 votes vote down vote up
@Nullable
private String findButlerAccessibilityServiceId() throws RemoteException {
    List<AccessibilityServiceInfo> accessibilityServices =
            serviceProvider.getInstalledAccessibilityServiceList();
    for (AccessibilityServiceInfo service : accessibilityServices) {
        String serviceId = service.getId();
        if (serviceId.endsWith(ButlerAccessibilityService.SERVICE_NAME)) {
            return serviceId;
        }
    }
    return null;
}
 
Example 19
/**
 * Sets the {@link AccessibilityServiceInfo} which informs the system how to
 * handle this {@link AccessibilityService}.
 *
 * @param feedbackType The type of feedback this service will provide.
 * <p>
 *   Note: The feedbackType parameter is an bitwise or of all
 *   feedback types this service would like to provide.
 * </p>
 */
private void setServiceInfo(int feedbackType) {
    AccessibilityServiceInfo info = new AccessibilityServiceInfo();
    // We are interested in all types of accessibility events.
    info.eventTypes = AccessibilityEvent.TYPES_ALL_MASK;
    // We want to provide specific type of feedback.
    info.feedbackType = feedbackType;
    // We want to receive events in a certain interval.
    info.notificationTimeout = EVENT_NOTIFICATION_TIMEOUT_MILLIS;
    // We want to receive accessibility events only from certain packages.
    info.packageNames = PACKAGE_NAMES;
    setServiceInfo(info);
}
 
Example 20
Source Project: V.FlyoutTest   Source File: AccessibilityManagerCompat.java    License: MIT License 4 votes vote down vote up
public List<AccessibilityServiceInfo> getInstalledAccessibilityServiceList(
        AccessibilityManager manager) {
    return Collections.emptyList();
}
 
Example 21
Source Project: V.FlyoutTest   Source File: AccessibilityManagerCompat.java    License: MIT License 4 votes vote down vote up
@Override
public List<AccessibilityServiceInfo> getInstalledAccessibilityServiceList(
        AccessibilityManager manager) {
    return AccessibilityManagerCompatIcs.getInstalledAccessibilityServiceList(manager);
}
 
Example 22
public static String getId(AccessibilityServiceInfo info) {
    return info.getId();
}
 
Example 23
Source Project: V.FlyoutTest   Source File: AccessibilityManagerCompatIcs.java    License: MIT License 4 votes vote down vote up
public static List<AccessibilityServiceInfo> getEnabledAccessibilityServiceList(
        AccessibilityManager manager,int feedbackTypeFlags) {
    return manager.getEnabledAccessibilityServiceList(feedbackTypeFlags);
}
 
Example 24
Source Project: guideshow   Source File: AccessibilityServiceInfoCompat.java    License: MIT License 4 votes vote down vote up
public String getDescription(AccessibilityServiceInfo info) {
    return null;
}
 
Example 25
Source Project: V.FlyoutTest   Source File: AccessibilityServiceInfoCompat.java    License: MIT License 4 votes vote down vote up
public int getCapabilities(AccessibilityServiceInfo info) {
    return 0;
}
 
Example 26
Source Project: V.FlyoutTest   Source File: AccessibilityServiceInfoCompat.java    License: MIT License 4 votes vote down vote up
public String getDescription(AccessibilityServiceInfo info) {
    return null;
}
 
Example 27
public boolean getCanRetrieveWindowContent(AccessibilityServiceInfo info) {
    return false;
}
 
Example 28
Source Project: MiBandDecompiled   Source File: e.java    License: Apache License 2.0 4 votes vote down vote up
public static String e(AccessibilityServiceInfo accessibilityserviceinfo)
{
    return accessibilityserviceinfo.getSettingsActivityName();
}
 
Example 29
Source Project: guideshow   Source File: AccessibilityServiceInfoCompat.java    License: MIT License 4 votes vote down vote up
@Override
public String getSettingsActivityName(AccessibilityServiceInfo info) {
    return AccessibilityServiceInfoCompatIcs.getSettingsActivityName(info);
}
 
Example 30
Source Project: guideshow   Source File: AccessibilityServiceInfoCompat.java    License: MIT License 4 votes vote down vote up
public String getSettingsActivityName(AccessibilityServiceInfo info) {
    return null;
}