Search in sources :

Example 16 with AccessibilityServiceInfo

use of android.accessibilityservice.AccessibilityServiceInfo in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class ToggleAccessibilityServicePreferenceFragment method createEnableDialogContentView.

private View createEnableDialogContentView(AccessibilityServiceInfo info) {
    LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    View content = inflater.inflate(R.layout.enable_accessibility_service_dialog_content, null);
    TextView encryptionWarningView = (TextView) content.findViewById(R.id.encryption_warning);
    if (isFullDiskEncrypted()) {
        String text = getString(R.string.enable_service_encryption_warning, info.getResolveInfo().loadLabel(getPackageManager()));
        encryptionWarningView.setText(text);
        encryptionWarningView.setVisibility(View.VISIBLE);
    } else {
        encryptionWarningView.setVisibility(View.GONE);
    }
    TextView capabilitiesHeaderView = (TextView) content.findViewById(R.id.capabilities_header);
    capabilitiesHeaderView.setText(getString(R.string.capabilities_list_title, info.getResolveInfo().loadLabel(getPackageManager())));
    LinearLayout capabilitiesView = (LinearLayout) content.findViewById(R.id.capabilities);
    // This capability is implicit for all services.
    View capabilityView = inflater.inflate(com.android.internal.R.layout.app_permission_item_old, null);
    ImageView imageView = (ImageView) capabilityView.findViewById(com.android.internal.R.id.perm_icon);
    imageView.setImageDrawable(getActivity().getDrawable(com.android.internal.R.drawable.ic_text_dot));
    TextView labelView = (TextView) capabilityView.findViewById(com.android.internal.R.id.permission_group);
    labelView.setText(getString(R.string.capability_title_receiveAccessibilityEvents));
    TextView descriptionView = (TextView) capabilityView.findViewById(com.android.internal.R.id.permission_list);
    descriptionView.setText(getString(R.string.capability_desc_receiveAccessibilityEvents));
    List<AccessibilityServiceInfo.CapabilityInfo> capabilities = info.getCapabilityInfos();
    capabilitiesView.addView(capabilityView);
    // Service specific capabilities.
    final int capabilityCount = capabilities.size();
    for (int i = 0; i < capabilityCount; i++) {
        AccessibilityServiceInfo.CapabilityInfo capability = capabilities.get(i);
        capabilityView = inflater.inflate(com.android.internal.R.layout.app_permission_item_old, null);
        imageView = (ImageView) capabilityView.findViewById(com.android.internal.R.id.perm_icon);
        imageView.setImageDrawable(getActivity().getDrawable(com.android.internal.R.drawable.ic_text_dot));
        labelView = (TextView) capabilityView.findViewById(com.android.internal.R.id.permission_group);
        labelView.setText(getString(capability.titleResId));
        descriptionView = (TextView) capabilityView.findViewById(com.android.internal.R.id.permission_list);
        descriptionView.setText(getString(capability.descResId));
        capabilitiesView.addView(capabilityView);
    }
    return content;
}
Also used : AccessibilityServiceInfo(android.accessibilityservice.AccessibilityServiceInfo) LayoutInflater(android.view.LayoutInflater) TextView(android.widget.TextView) ImageView(android.widget.ImageView) ImageView(android.widget.ImageView) View(android.view.View) TextView(android.widget.TextView) LinearLayout(android.widget.LinearLayout)

Example 17 with AccessibilityServiceInfo

use of android.accessibilityservice.AccessibilityServiceInfo in project android_frameworks_base by ResurrectionRemix.

the class UiAutomationConnection method registerUiTestAutomationServiceLocked.

private void registerUiTestAutomationServiceLocked(IAccessibilityServiceClient client, int flags) {
    IAccessibilityManager manager = IAccessibilityManager.Stub.asInterface(ServiceManager.getService(Context.ACCESSIBILITY_SERVICE));
    final AccessibilityServiceInfo info = new AccessibilityServiceInfo();
    info.eventTypes = AccessibilityEvent.TYPES_ALL_MASK;
    info.feedbackType = AccessibilityServiceInfo.FEEDBACK_GENERIC;
    info.flags |= AccessibilityServiceInfo.FLAG_INCLUDE_NOT_IMPORTANT_VIEWS | AccessibilityServiceInfo.FLAG_REPORT_VIEW_IDS | AccessibilityServiceInfo.FLAG_FORCE_DIRECT_BOOT_AWARE;
    info.setCapabilities(AccessibilityServiceInfo.CAPABILITY_CAN_RETRIEVE_WINDOW_CONTENT | AccessibilityServiceInfo.CAPABILITY_CAN_REQUEST_TOUCH_EXPLORATION | AccessibilityServiceInfo.CAPABILITY_CAN_REQUEST_ENHANCED_WEB_ACCESSIBILITY | AccessibilityServiceInfo.CAPABILITY_CAN_REQUEST_FILTER_KEY_EVENTS);
    try {
        // Calling out with a lock held is fine since if the system
        // process is gone the client calling in will be killed.
        manager.registerUiTestAutomationService(mToken, client, info, flags);
        mClient = client;
    } catch (RemoteException re) {
        throw new IllegalStateException("Error while registering UiTestAutomationService.", re);
    }
}
Also used : IAccessibilityManager(android.view.accessibility.IAccessibilityManager) AccessibilityServiceInfo(android.accessibilityservice.AccessibilityServiceInfo) RemoteException(android.os.RemoteException)

Example 18 with AccessibilityServiceInfo

use of android.accessibilityservice.AccessibilityServiceInfo in project android_frameworks_base by ResurrectionRemix.

the class DevicePolicyManagerService method setPermittedAccessibilityServices.

@Override
public boolean setPermittedAccessibilityServices(ComponentName who, List packageList) {
    if (!mHasFeature) {
        return false;
    }
    Preconditions.checkNotNull(who, "ComponentName is null");
    if (packageList != null) {
        int userId = UserHandle.getCallingUserId();
        List<AccessibilityServiceInfo> enabledServices = null;
        long id = mInjector.binderClearCallingIdentity();
        try {
            UserInfo user = getUserInfo(userId);
            if (user.isManagedProfile()) {
                userId = user.profileGroupId;
            }
            AccessibilityManager accessibilityManager = getAccessibilityManagerForUser(userId);
            enabledServices = accessibilityManager.getEnabledAccessibilityServiceList(AccessibilityServiceInfo.FEEDBACK_ALL_MASK);
        } finally {
            mInjector.binderRestoreCallingIdentity(id);
        }
        if (enabledServices != null) {
            List<String> enabledPackages = new ArrayList<String>();
            for (AccessibilityServiceInfo service : enabledServices) {
                enabledPackages.add(service.getResolveInfo().serviceInfo.packageName);
            }
            if (!checkPackagesInPermittedListOrSystem(enabledPackages, packageList, userId)) {
                Slog.e(LOG_TAG, "Cannot set permitted accessibility services, " + "because it contains already enabled accesibility services.");
                return false;
            }
        }
    }
    synchronized (this) {
        ActiveAdmin admin = getActiveAdminForCallerLocked(who, DeviceAdminInfo.USES_POLICY_PROFILE_OWNER);
        admin.permittedAccessiblityServices = packageList;
        saveSettingsLocked(UserHandle.getCallingUserId());
    }
    return true;
}
Also used : AccessibilityServiceInfo(android.accessibilityservice.AccessibilityServiceInfo) AccessibilityManager(android.view.accessibility.AccessibilityManager) IAccessibilityManager(android.view.accessibility.IAccessibilityManager) ArrayList(java.util.ArrayList) UserInfo(android.content.pm.UserInfo) ParcelableString(com.android.internal.util.ParcelableString)

Example 19 with AccessibilityServiceInfo

use of android.accessibilityservice.AccessibilityServiceInfo in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class AccessibilitySettings method updateServicesPreferences.

private void updateServicesPreferences() {
    // Since services category is auto generated we have to do a pass
    // to generate it since services can come and go and then based on
    // the global accessibility state to decided whether it is enabled.
    // Generate.
    mServicesCategory.removeAll();
    AccessibilityManager accessibilityManager = AccessibilityManager.getInstance(getActivity());
    List<AccessibilityServiceInfo> installedServices = accessibilityManager.getInstalledAccessibilityServiceList();
    Set<ComponentName> enabledServices = AccessibilityUtils.getEnabledServicesFromSettings(getActivity());
    List<String> permittedServices = mDpm.getPermittedAccessibilityServices(UserHandle.myUserId());
    final boolean accessibilityEnabled = Settings.Secure.getInt(getContentResolver(), Settings.Secure.ACCESSIBILITY_ENABLED, 0) == 1;
    for (int i = 0, count = installedServices.size(); i < count; ++i) {
        AccessibilityServiceInfo info = installedServices.get(i);
        RestrictedPreference preference = new RestrictedPreference(getActivity());
        String title = info.getResolveInfo().loadLabel(getPackageManager()).toString();
        ServiceInfo serviceInfo = info.getResolveInfo().serviceInfo;
        ComponentName componentName = new ComponentName(serviceInfo.packageName, serviceInfo.name);
        preference.setKey(componentName.flattenToString());
        preference.setTitle(title);
        final boolean serviceEnabled = accessibilityEnabled && enabledServices.contains(componentName);
        String serviceEnabledString;
        if (serviceEnabled) {
            serviceEnabledString = getString(R.string.accessibility_feature_state_on);
        } else {
            serviceEnabledString = getString(R.string.accessibility_feature_state_off);
        }
        // Disable all accessibility services that are not permitted.
        String packageName = serviceInfo.packageName;
        boolean serviceAllowed = permittedServices == null || permittedServices.contains(packageName);
        if (!serviceAllowed && !serviceEnabled) {
            EnforcedAdmin admin = RestrictedLockUtils.checkIfAccessibilityServiceDisallowed(getActivity(), serviceInfo.packageName, UserHandle.myUserId());
            if (admin != null) {
                preference.setDisabledByAdmin(admin);
            } else {
                preference.setEnabled(false);
            }
        } else {
            preference.setEnabled(true);
        }
        preference.setSummary(serviceEnabledString);
        preference.setOrder(i);
        preference.setFragment(ToggleAccessibilityServicePreferenceFragment.class.getName());
        preference.setPersistent(true);
        Bundle extras = preference.getExtras();
        extras.putString(EXTRA_PREFERENCE_KEY, preference.getKey());
        extras.putBoolean(EXTRA_CHECKED, serviceEnabled);
        extras.putString(EXTRA_TITLE, title);
        String description = info.loadDescription(getPackageManager());
        if (TextUtils.isEmpty(description)) {
            description = getString(R.string.accessibility_service_default_description);
        }
        extras.putString(EXTRA_SUMMARY, description);
        String settingsClassName = info.getSettingsActivityName();
        if (!TextUtils.isEmpty(settingsClassName)) {
            extras.putString(EXTRA_SETTINGS_TITLE, getString(R.string.accessibility_menu_item_settings));
            extras.putString(EXTRA_SETTINGS_COMPONENT_NAME, new ComponentName(info.getResolveInfo().serviceInfo.packageName, settingsClassName).flattenToString());
        }
        extras.putParcelable(EXTRA_COMPONENT_NAME, componentName);
        mServicesCategory.addPreference(preference);
    }
    if (mServicesCategory.getPreferenceCount() == 0) {
        if (mNoServicesMessagePreference == null) {
            mNoServicesMessagePreference = new Preference(getPrefContext());
            mNoServicesMessagePreference.setPersistent(false);
            mNoServicesMessagePreference.setLayoutResource(R.layout.text_description_preference);
            mNoServicesMessagePreference.setSelectable(false);
            mNoServicesMessagePreference.setSummary(getString(R.string.accessibility_no_services_installed));
        }
        mServicesCategory.addPreference(mNoServicesMessagePreference);
    }
}
Also used : Bundle(android.os.Bundle) EnforcedAdmin(com.android.settingslib.RestrictedLockUtils.EnforcedAdmin) AccessibilityServiceInfo(android.accessibilityservice.AccessibilityServiceInfo) ServiceInfo(android.content.pm.ServiceInfo) AccessibilityServiceInfo(android.accessibilityservice.AccessibilityServiceInfo) AccessibilityManager(android.view.accessibility.AccessibilityManager) RestrictedPreference(com.android.settingslib.RestrictedPreference) ListPreference(android.support.v7.preference.ListPreference) RestrictedPreference(com.android.settingslib.RestrictedPreference) Preference(android.support.v7.preference.Preference) SwitchPreference(android.support.v14.preference.SwitchPreference) ComponentName(android.content.ComponentName)

Example 20 with AccessibilityServiceInfo

use of android.accessibilityservice.AccessibilityServiceInfo in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class AccessibilitySettingsForSetupWizard method updateScreenReaderPreference.

private void updateScreenReaderPreference() {
    // Find a screen reader.
    AccessibilityServiceInfo info = findFirstServiceWithSpokenFeedback();
    if (info == null) {
        getPreferenceScreen().removePreference(mScreenReaderPreference);
        return;
    } else {
        mScreenReaderPreference.setEnabled(true);
        ServiceInfo serviceInfo = info.getResolveInfo().serviceInfo;
        String title = info.getResolveInfo().loadLabel(getPackageManager()).toString();
        mScreenReaderPreference.setTitle(title);
        ComponentName componentName = new ComponentName(serviceInfo.packageName, serviceInfo.name);
        mScreenReaderPreference.setKey(componentName.flattenToString());
        // Update the extras.
        Bundle extras = mScreenReaderPreference.getExtras();
        extras.putParcelable(AccessibilitySettings.EXTRA_COMPONENT_NAME, componentName);
        extras.putString(AccessibilitySettings.EXTRA_PREFERENCE_KEY, mScreenReaderPreference.getKey());
        extras.putString(AccessibilitySettings.EXTRA_TITLE, title);
        String description = info.loadDescription(getPackageManager());
        if (TextUtils.isEmpty(description)) {
            description = getString(R.string.accessibility_service_default_description);
        }
        extras.putString(AccessibilitySettings.EXTRA_SUMMARY, description);
    }
}
Also used : AccessibilityServiceInfo(android.accessibilityservice.AccessibilityServiceInfo) ServiceInfo(android.content.pm.ServiceInfo) AccessibilityServiceInfo(android.accessibilityservice.AccessibilityServiceInfo) Bundle(android.os.Bundle) ComponentName(android.content.ComponentName)

Aggregations

AccessibilityServiceInfo (android.accessibilityservice.AccessibilityServiceInfo)210 ServiceInfo (android.content.pm.ServiceInfo)69 ComponentName (android.content.ComponentName)64 AccessibilityManager (android.view.accessibility.AccessibilityManager)54 ArrayList (java.util.ArrayList)50 ResolveInfo (android.content.pm.ResolveInfo)45 Point (android.graphics.Point)30 LargeTest (android.test.suitebuilder.annotation.LargeTest)25 AccessibilityEvent (android.view.accessibility.AccessibilityEvent)20 Bundle (android.os.Bundle)17 IAccessibilityManager (android.view.accessibility.IAccessibilityManager)17 AccessibilityService (android.accessibilityservice.AccessibilityService)13 Drawable (android.graphics.drawable.Drawable)13 CopyOnWriteArrayList (java.util.concurrent.CopyOnWriteArrayList)13 Intent (android.content.Intent)12 HashSet (java.util.HashSet)12 RemoteException (android.os.RemoteException)9 EnforcedAdmin (com.android.settingslib.RestrictedLockUtils.EnforcedAdmin)8 RestrictedPreference (com.android.settingslib.RestrictedPreference)8 IOException (java.io.IOException)8