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;
}
Aggregations