Search in sources :

Example 1 with SaiyAccessibilityService

use of ai.saiy.android.accessibility.SaiyAccessibilityService in project Saiy-PS by brandall76.

the class SelfAwareHelper method saiyAccessibilityRunning.

/**
 * Check the running condition of {@link SaiyAccessibilityService}
 *
 * @param ctx the application context
 */
public static boolean saiyAccessibilityRunning(@NonNull final Context ctx) {
    if (DEBUG) {
        MyLog.i(CLS_NAME, "saiyAccessibilityRunning");
    }
    final AccessibilityManager aManager = (AccessibilityManager) ctx.getSystemService(Context.ACCESSIBILITY_SERVICE);
    String className;
    for (final AccessibilityServiceInfo service : aManager.getEnabledAccessibilityServiceList(AccessibilityServiceInfo.FEEDBACK_ALL_MASK)) {
        try {
            className = service.getId();
            if (className != null) {
                if (className.trim().endsWith(SaiyAccessibilityService.class.getSimpleName())) {
                    if (DEBUG) {
                        MyLog.i(CLS_NAME, "SaiyAccessibilityService running");
                    }
                    return true;
                }
            }
        } catch (final NullPointerException e) {
            if (DEBUG) {
                MyLog.w(CLS_NAME, "NullPointerException");
            }
        } catch (final Exception e) {
            if (DEBUG) {
                MyLog.w(CLS_NAME, "Exception");
            }
        }
    }
    if (DEBUG) {
        MyLog.i(CLS_NAME, "SaiyAccessibilityService not running");
    }
    return false;
}
Also used : AccessibilityServiceInfo(android.accessibilityservice.AccessibilityServiceInfo) AccessibilityManager(android.view.accessibility.AccessibilityManager) UtilsString(ai.saiy.android.utils.UtilsString) SaiyAccessibilityService(ai.saiy.android.accessibility.SaiyAccessibilityService) RemoteException(android.os.RemoteException)

Aggregations

SaiyAccessibilityService (ai.saiy.android.accessibility.SaiyAccessibilityService)1 UtilsString (ai.saiy.android.utils.UtilsString)1 AccessibilityServiceInfo (android.accessibilityservice.AccessibilityServiceInfo)1 RemoteException (android.os.RemoteException)1 AccessibilityManager (android.view.accessibility.AccessibilityManager)1