Search in sources :

Example 1 with WindowManagerInternal

use of android.view.WindowManagerInternal in project platform_frameworks_base by android.

the class EnableAccessibilityController method enableAccessibility.

public static boolean enableAccessibility(Context context) {
    final IAccessibilityManager accessibilityManager = IAccessibilityManager.Stub.asInterface(ServiceManager.getService("accessibility"));
    final WindowManagerInternal windowManager = LocalServices.getService(WindowManagerInternal.class);
    final UserManager userManager = (UserManager) context.getSystemService(Context.USER_SERVICE);
    ComponentName componentName = getInstalledSpeakingAccessibilityServiceComponent(context);
    if (componentName == null) {
        return false;
    }
    boolean keyguardLocked = windowManager.isKeyguardLocked();
    final boolean hasMoreThanOneUser = userManager.getUsers().size() > 1;
    try {
        if (!keyguardLocked || !hasMoreThanOneUser) {
            final int userId = ActivityManager.getCurrentUser();
            accessibilityManager.enableAccessibilityService(componentName, userId);
        } else if (keyguardLocked) {
            accessibilityManager.temporaryEnableAccessibilityStateUntilKeyguardRemoved(componentName, true);
        }
    } catch (RemoteException e) {
        Log.e(TAG, "cannot enable accessibilty: " + e);
    }
    return true;
}
Also used : WindowManagerInternal(android.view.WindowManagerInternal) IAccessibilityManager(android.view.accessibility.IAccessibilityManager) UserManager(android.os.UserManager) ComponentName(android.content.ComponentName) RemoteException(android.os.RemoteException)

Example 2 with WindowManagerInternal

use of android.view.WindowManagerInternal in project android_frameworks_base by DirtyUnicorns.

the class EnableAccessibilityController method enableAccessibility.

public static boolean enableAccessibility(Context context) {
    final IAccessibilityManager accessibilityManager = IAccessibilityManager.Stub.asInterface(ServiceManager.getService("accessibility"));
    final WindowManagerInternal windowManager = LocalServices.getService(WindowManagerInternal.class);
    final UserManager userManager = (UserManager) context.getSystemService(Context.USER_SERVICE);
    ComponentName componentName = getInstalledSpeakingAccessibilityServiceComponent(context);
    if (componentName == null) {
        return false;
    }
    boolean keyguardLocked = windowManager.isKeyguardLocked();
    final boolean hasMoreThanOneUser = userManager.getUsers().size() > 1;
    try {
        if (!keyguardLocked || !hasMoreThanOneUser) {
            final int userId = ActivityManager.getCurrentUser();
            accessibilityManager.enableAccessibilityService(componentName, userId);
        } else if (keyguardLocked) {
            accessibilityManager.temporaryEnableAccessibilityStateUntilKeyguardRemoved(componentName, true);
        }
    } catch (RemoteException e) {
        Log.e(TAG, "cannot enable accessibilty: " + e);
    }
    return true;
}
Also used : WindowManagerInternal(android.view.WindowManagerInternal) IAccessibilityManager(android.view.accessibility.IAccessibilityManager) UserManager(android.os.UserManager) ComponentName(android.content.ComponentName) RemoteException(android.os.RemoteException)

Example 3 with WindowManagerInternal

use of android.view.WindowManagerInternal in project android_frameworks_base by ResurrectionRemix.

the class EnableAccessibilityController method enableAccessibility.

public static boolean enableAccessibility(Context context) {
    final IAccessibilityManager accessibilityManager = IAccessibilityManager.Stub.asInterface(ServiceManager.getService("accessibility"));
    final WindowManagerInternal windowManager = LocalServices.getService(WindowManagerInternal.class);
    final UserManager userManager = (UserManager) context.getSystemService(Context.USER_SERVICE);
    ComponentName componentName = getInstalledSpeakingAccessibilityServiceComponent(context);
    if (componentName == null) {
        return false;
    }
    boolean keyguardLocked = windowManager.isKeyguardLocked();
    final boolean hasMoreThanOneUser = userManager.getUsers().size() > 1;
    try {
        if (!keyguardLocked || !hasMoreThanOneUser) {
            final int userId = ActivityManager.getCurrentUser();
            accessibilityManager.enableAccessibilityService(componentName, userId);
        } else if (keyguardLocked) {
            accessibilityManager.temporaryEnableAccessibilityStateUntilKeyguardRemoved(componentName, true);
        }
    } catch (RemoteException e) {
        Log.e(TAG, "cannot enable accessibilty: " + e);
    }
    return true;
}
Also used : WindowManagerInternal(android.view.WindowManagerInternal) IAccessibilityManager(android.view.accessibility.IAccessibilityManager) UserManager(android.os.UserManager) ComponentName(android.content.ComponentName) RemoteException(android.os.RemoteException)

Example 4 with WindowManagerInternal

use of android.view.WindowManagerInternal in project android_frameworks_base by crdroidandroid.

the class EnableAccessibilityController method enableAccessibility.

public static boolean enableAccessibility(Context context) {
    final IAccessibilityManager accessibilityManager = IAccessibilityManager.Stub.asInterface(ServiceManager.getService("accessibility"));
    final WindowManagerInternal windowManager = LocalServices.getService(WindowManagerInternal.class);
    final UserManager userManager = (UserManager) context.getSystemService(Context.USER_SERVICE);
    ComponentName componentName = getInstalledSpeakingAccessibilityServiceComponent(context);
    if (componentName == null) {
        return false;
    }
    boolean keyguardLocked = windowManager.isKeyguardLocked();
    final boolean hasMoreThanOneUser = userManager.getUsers().size() > 1;
    try {
        if (!keyguardLocked || !hasMoreThanOneUser) {
            final int userId = ActivityManager.getCurrentUser();
            accessibilityManager.enableAccessibilityService(componentName, userId);
        } else if (keyguardLocked) {
            accessibilityManager.temporaryEnableAccessibilityStateUntilKeyguardRemoved(componentName, true);
        }
    } catch (RemoteException e) {
        Log.e(TAG, "cannot enable accessibilty: " + e);
    }
    return true;
}
Also used : WindowManagerInternal(android.view.WindowManagerInternal) IAccessibilityManager(android.view.accessibility.IAccessibilityManager) UserManager(android.os.UserManager) ComponentName(android.content.ComponentName) RemoteException(android.os.RemoteException)

Aggregations

ComponentName (android.content.ComponentName)4 RemoteException (android.os.RemoteException)4 UserManager (android.os.UserManager)4 WindowManagerInternal (android.view.WindowManagerInternal)4 IAccessibilityManager (android.view.accessibility.IAccessibilityManager)4