private boolean isAccessibleEnabled() {
    AccessibilityManager manager =
        (AccessibilityManager) getSystemService(Context.ACCESSIBILITY_SERVICE);

    List<AccessibilityServiceInfo> runningServices =
        manager.getEnabledAccessibilityServiceList(AccessibilityEvent.TYPES_ALL_MASK);
    for (AccessibilityServiceInfo info : runningServices) {
      if (info.getId().equals(getPackageName() + "/.MonitorService")) {
        return true;
      }
    }
    return false;
  }
예제 #2
0
 public boolean isSupportAccessibility() {
   MainActivity mainActivity = (MainActivity) mMainMediator;
   boolean result = false;
   AccessibilityManager accessibilityManager =
       (AccessibilityManager) mainActivity.getSystemService(Context.ACCESSIBILITY_SERVICE);
   List<AccessibilityServiceInfo> list =
       accessibilityManager.getEnabledAccessibilityServiceList(
           AccessibilityServiceInfo.FEEDBACK_ALL_MASK);
   for (AccessibilityServiceInfo info : list) {
     if (info.getId().equals(mainActivity.getPackageName() + Constants.ACCESSIBILITY_SERVICE_NAME))
       result = true;
   }
   Logger.d(InputAccessibilityService.class.getCanonicalName());
   return result;
 }
예제 #3
0
  private void updateServiceStatus() {
    boolean serviceEnabled = false;

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

    if (serviceEnabled) {
      switchPlugin.setText("关闭插件");
      // Prevent screen from dimming
      getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
    } else {
      switchPlugin.setText("开启插件");
      getWindow().clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
    }
  }
 public static String getId(AccessibilityServiceInfo info) {
   return info.getId();
 }