Loading core/java/android/view/accessibility/AccessibilityManager.java +52 −0 Original line number Diff line number Diff line Loading @@ -2116,6 +2116,58 @@ public final class AccessibilityManager { } } /** * Determines if the accessibility target is allowed. * * @param packageName The name of the application attempting to perform the operation. * @param uid The user id of the application attempting to perform the operation. * @param userId The id of the user for whom to perform the operation. * @return {@code true} the accessibility target is allowed. * @hide */ public boolean isAccessibilityTargetAllowed(String packageName, int uid, int userId) { final IAccessibilityManager service; synchronized (mLock) { service = getServiceLocked(); if (service == null) { return false; } } try { return service.isAccessibilityTargetAllowed(packageName, uid, userId); } catch (RemoteException re) { Log.e(LOG_TAG, "Error while check accessibility target status", re); return false; } } /** * Sends restricted dialog intent if the accessibility target is disallowed. * * @param packageName The name of the application attempting to perform the operation. * @param uid The user id of the application attempting to perform the operation. * @param userId The id of the user for whom to perform the operation. * @return {@code true} if the restricted dialog is shown. * @hide */ public boolean sendRestrictedDialogIntent(String packageName, int uid, int userId) { final IAccessibilityManager service; synchronized (mLock) { service = getServiceLocked(); if (service == null) { return false; } } try { return service.sendRestrictedDialogIntent(packageName, uid, userId); } catch (RemoteException re) { Log.e(LOG_TAG, "Error while show restricted dialog", re); return false; } } private IAccessibilityManager getServiceLocked() { if (mService == null) { tryConnectToServiceLocked(null); Loading core/java/android/view/accessibility/IAccessibilityManager.aidl +3 −0 Original line number Diff line number Diff line Loading @@ -124,6 +124,9 @@ interface IAccessibilityManager { boolean stopFlashNotificationSequence(String opPkg); boolean startFlashNotificationEvent(String opPkg, int reason, String reasonPkg); boolean isAccessibilityTargetAllowed(String packageName, int uid, int userId); boolean sendRestrictedDialogIntent(String packageName, int uid, int userId); parcelable WindowTransformationSpec { float[] transformationMatrix; MagnificationSpec magnificationSpec; Loading core/java/com/android/internal/accessibility/dialog/AccessibilityActivityTarget.java +18 −0 Original line number Diff line number Diff line Loading @@ -26,6 +26,7 @@ import android.content.Context; import android.view.accessibility.AccessibilityManager.ShortcutType; import com.android.internal.accessibility.common.ShortcutConstants.AccessibilityFragmentType; import com.android.internal.accessibility.common.ShortcutConstants.ShortcutMenuMode; /** * Base class for creating accessibility activity target. Loading @@ -40,8 +41,25 @@ class AccessibilityActivityTarget extends AccessibilityTarget { isShortcutContained(context, shortcutType, shortcutInfo.getComponentName().flattenToString()), shortcutInfo.getComponentName().flattenToString(), shortcutInfo.getActivityInfo().applicationInfo.uid, shortcutInfo.getActivityInfo().loadLabel(context.getPackageManager()), shortcutInfo.getActivityInfo().loadIcon(context.getPackageManager()), convertToKey(convertToUserType(shortcutType))); } @Override public void updateActionItem(@NonNull TargetAdapter.ViewHolder holder, @ShortcutMenuMode int shortcutMenuMode) { super.updateActionItem(holder, shortcutMenuMode); final boolean isAllowed = AccessibilityTargetHelper.isAccessibilityTargetAllowed( getContext(), getComponentName().getPackageName(), getUid()); final boolean isEditMenuMode = shortcutMenuMode == ShortcutMenuMode.EDIT; final boolean enabled = isAllowed || (isEditMenuMode && isShortcutEnabled()); holder.mCheckBoxView.setEnabled(enabled); holder.mIconView.setEnabled(enabled); holder.mLabelView.setEnabled(enabled); holder.mStatusView.setEnabled(enabled); } } core/java/com/android/internal/accessibility/dialog/AccessibilityServiceTarget.java +18 −0 Original line number Diff line number Diff line Loading @@ -26,6 +26,7 @@ import android.content.Context; import android.view.accessibility.AccessibilityManager.ShortcutType; import com.android.internal.accessibility.common.ShortcutConstants.AccessibilityFragmentType; import com.android.internal.accessibility.common.ShortcutConstants.ShortcutMenuMode; /** * Base class for creating accessibility service target with various fragment types related to Loading @@ -42,8 +43,25 @@ class AccessibilityServiceTarget extends AccessibilityTarget { isShortcutContained(context, shortcutType, serviceInfo.getComponentName().flattenToString()), serviceInfo.getComponentName().flattenToString(), serviceInfo.getResolveInfo().serviceInfo.applicationInfo.uid, serviceInfo.getResolveInfo().loadLabel(context.getPackageManager()), serviceInfo.getResolveInfo().loadIcon(context.getPackageManager()), convertToKey(convertToUserType(shortcutType))); } @Override public void updateActionItem(@NonNull TargetAdapter.ViewHolder holder, @ShortcutMenuMode int shortcutMenuMode) { super.updateActionItem(holder, shortcutMenuMode); final boolean isAllowed = AccessibilityTargetHelper.isAccessibilityTargetAllowed( getContext(), getComponentName().getPackageName(), getUid()); final boolean isEditMenuMode = shortcutMenuMode == ShortcutMenuMode.EDIT; final boolean enabled = isAllowed || (isEditMenuMode && isShortcutEnabled()); holder.mCheckBoxView.setEnabled(enabled); holder.mIconView.setEnabled(enabled); holder.mLabelView.setEnabled(enabled); holder.mStatusView.setEnabled(enabled); } } core/java/com/android/internal/accessibility/dialog/AccessibilityShortcutChooserActivity.java +36 −3 Original line number Diff line number Diff line Loading @@ -95,6 +95,13 @@ public class AccessibilityShortcutChooserActivity extends Activity { private void onTargetSelected(AdapterView<?> parent, View view, int position, long id) { final AccessibilityTarget target = mTargets.get(position); if (target instanceof AccessibilityServiceTarget || target instanceof AccessibilityActivityTarget) { if (sendRestrictedDialogIntentIfNeeded(target)) { return; } } target.onSelected(); mMenuDialog.dismiss(); } Loading @@ -102,15 +109,41 @@ public class AccessibilityShortcutChooserActivity extends Activity { private void onTargetChecked(AdapterView<?> parent, View view, int position, long id) { final AccessibilityTarget target = mTargets.get(position); if ((target instanceof AccessibilityServiceTarget) && !target.isShortcutEnabled()) { showPermissionDialogIfNeeded(this, (AccessibilityServiceTarget) target, mTargetAdapter); if (!target.isShortcutEnabled()) { if (target instanceof AccessibilityServiceTarget || target instanceof AccessibilityActivityTarget) { if (sendRestrictedDialogIntentIfNeeded(target)) { return; } } if (target instanceof AccessibilityServiceTarget) { showPermissionDialogIfNeeded(this, (AccessibilityServiceTarget) target, mTargetAdapter); return; } } target.onCheckedChanged(!target.isShortcutEnabled()); mTargetAdapter.notifyDataSetChanged(); } /** * Sends restricted dialog intent if the accessibility target is disallowed. * * @return true if sends restricted dialog intent, otherwise false. */ private boolean sendRestrictedDialogIntentIfNeeded(AccessibilityTarget target) { if (AccessibilityTargetHelper.isAccessibilityTargetAllowed(this, target.getComponentName().getPackageName(), target.getUid())) { return false; } AccessibilityTargetHelper.sendRestrictedDialogIntent(this, target.getComponentName().getPackageName(), target.getUid()); return true; } private void showPermissionDialogIfNeeded(Context context, AccessibilityServiceTarget serviceTarget, ShortcutTargetAdapter targetAdapter) { if (mPermissionDialog != null) { Loading Loading
core/java/android/view/accessibility/AccessibilityManager.java +52 −0 Original line number Diff line number Diff line Loading @@ -2116,6 +2116,58 @@ public final class AccessibilityManager { } } /** * Determines if the accessibility target is allowed. * * @param packageName The name of the application attempting to perform the operation. * @param uid The user id of the application attempting to perform the operation. * @param userId The id of the user for whom to perform the operation. * @return {@code true} the accessibility target is allowed. * @hide */ public boolean isAccessibilityTargetAllowed(String packageName, int uid, int userId) { final IAccessibilityManager service; synchronized (mLock) { service = getServiceLocked(); if (service == null) { return false; } } try { return service.isAccessibilityTargetAllowed(packageName, uid, userId); } catch (RemoteException re) { Log.e(LOG_TAG, "Error while check accessibility target status", re); return false; } } /** * Sends restricted dialog intent if the accessibility target is disallowed. * * @param packageName The name of the application attempting to perform the operation. * @param uid The user id of the application attempting to perform the operation. * @param userId The id of the user for whom to perform the operation. * @return {@code true} if the restricted dialog is shown. * @hide */ public boolean sendRestrictedDialogIntent(String packageName, int uid, int userId) { final IAccessibilityManager service; synchronized (mLock) { service = getServiceLocked(); if (service == null) { return false; } } try { return service.sendRestrictedDialogIntent(packageName, uid, userId); } catch (RemoteException re) { Log.e(LOG_TAG, "Error while show restricted dialog", re); return false; } } private IAccessibilityManager getServiceLocked() { if (mService == null) { tryConnectToServiceLocked(null); Loading
core/java/android/view/accessibility/IAccessibilityManager.aidl +3 −0 Original line number Diff line number Diff line Loading @@ -124,6 +124,9 @@ interface IAccessibilityManager { boolean stopFlashNotificationSequence(String opPkg); boolean startFlashNotificationEvent(String opPkg, int reason, String reasonPkg); boolean isAccessibilityTargetAllowed(String packageName, int uid, int userId); boolean sendRestrictedDialogIntent(String packageName, int uid, int userId); parcelable WindowTransformationSpec { float[] transformationMatrix; MagnificationSpec magnificationSpec; Loading
core/java/com/android/internal/accessibility/dialog/AccessibilityActivityTarget.java +18 −0 Original line number Diff line number Diff line Loading @@ -26,6 +26,7 @@ import android.content.Context; import android.view.accessibility.AccessibilityManager.ShortcutType; import com.android.internal.accessibility.common.ShortcutConstants.AccessibilityFragmentType; import com.android.internal.accessibility.common.ShortcutConstants.ShortcutMenuMode; /** * Base class for creating accessibility activity target. Loading @@ -40,8 +41,25 @@ class AccessibilityActivityTarget extends AccessibilityTarget { isShortcutContained(context, shortcutType, shortcutInfo.getComponentName().flattenToString()), shortcutInfo.getComponentName().flattenToString(), shortcutInfo.getActivityInfo().applicationInfo.uid, shortcutInfo.getActivityInfo().loadLabel(context.getPackageManager()), shortcutInfo.getActivityInfo().loadIcon(context.getPackageManager()), convertToKey(convertToUserType(shortcutType))); } @Override public void updateActionItem(@NonNull TargetAdapter.ViewHolder holder, @ShortcutMenuMode int shortcutMenuMode) { super.updateActionItem(holder, shortcutMenuMode); final boolean isAllowed = AccessibilityTargetHelper.isAccessibilityTargetAllowed( getContext(), getComponentName().getPackageName(), getUid()); final boolean isEditMenuMode = shortcutMenuMode == ShortcutMenuMode.EDIT; final boolean enabled = isAllowed || (isEditMenuMode && isShortcutEnabled()); holder.mCheckBoxView.setEnabled(enabled); holder.mIconView.setEnabled(enabled); holder.mLabelView.setEnabled(enabled); holder.mStatusView.setEnabled(enabled); } }
core/java/com/android/internal/accessibility/dialog/AccessibilityServiceTarget.java +18 −0 Original line number Diff line number Diff line Loading @@ -26,6 +26,7 @@ import android.content.Context; import android.view.accessibility.AccessibilityManager.ShortcutType; import com.android.internal.accessibility.common.ShortcutConstants.AccessibilityFragmentType; import com.android.internal.accessibility.common.ShortcutConstants.ShortcutMenuMode; /** * Base class for creating accessibility service target with various fragment types related to Loading @@ -42,8 +43,25 @@ class AccessibilityServiceTarget extends AccessibilityTarget { isShortcutContained(context, shortcutType, serviceInfo.getComponentName().flattenToString()), serviceInfo.getComponentName().flattenToString(), serviceInfo.getResolveInfo().serviceInfo.applicationInfo.uid, serviceInfo.getResolveInfo().loadLabel(context.getPackageManager()), serviceInfo.getResolveInfo().loadIcon(context.getPackageManager()), convertToKey(convertToUserType(shortcutType))); } @Override public void updateActionItem(@NonNull TargetAdapter.ViewHolder holder, @ShortcutMenuMode int shortcutMenuMode) { super.updateActionItem(holder, shortcutMenuMode); final boolean isAllowed = AccessibilityTargetHelper.isAccessibilityTargetAllowed( getContext(), getComponentName().getPackageName(), getUid()); final boolean isEditMenuMode = shortcutMenuMode == ShortcutMenuMode.EDIT; final boolean enabled = isAllowed || (isEditMenuMode && isShortcutEnabled()); holder.mCheckBoxView.setEnabled(enabled); holder.mIconView.setEnabled(enabled); holder.mLabelView.setEnabled(enabled); holder.mStatusView.setEnabled(enabled); } }
core/java/com/android/internal/accessibility/dialog/AccessibilityShortcutChooserActivity.java +36 −3 Original line number Diff line number Diff line Loading @@ -95,6 +95,13 @@ public class AccessibilityShortcutChooserActivity extends Activity { private void onTargetSelected(AdapterView<?> parent, View view, int position, long id) { final AccessibilityTarget target = mTargets.get(position); if (target instanceof AccessibilityServiceTarget || target instanceof AccessibilityActivityTarget) { if (sendRestrictedDialogIntentIfNeeded(target)) { return; } } target.onSelected(); mMenuDialog.dismiss(); } Loading @@ -102,15 +109,41 @@ public class AccessibilityShortcutChooserActivity extends Activity { private void onTargetChecked(AdapterView<?> parent, View view, int position, long id) { final AccessibilityTarget target = mTargets.get(position); if ((target instanceof AccessibilityServiceTarget) && !target.isShortcutEnabled()) { showPermissionDialogIfNeeded(this, (AccessibilityServiceTarget) target, mTargetAdapter); if (!target.isShortcutEnabled()) { if (target instanceof AccessibilityServiceTarget || target instanceof AccessibilityActivityTarget) { if (sendRestrictedDialogIntentIfNeeded(target)) { return; } } if (target instanceof AccessibilityServiceTarget) { showPermissionDialogIfNeeded(this, (AccessibilityServiceTarget) target, mTargetAdapter); return; } } target.onCheckedChanged(!target.isShortcutEnabled()); mTargetAdapter.notifyDataSetChanged(); } /** * Sends restricted dialog intent if the accessibility target is disallowed. * * @return true if sends restricted dialog intent, otherwise false. */ private boolean sendRestrictedDialogIntentIfNeeded(AccessibilityTarget target) { if (AccessibilityTargetHelper.isAccessibilityTargetAllowed(this, target.getComponentName().getPackageName(), target.getUid())) { return false; } AccessibilityTargetHelper.sendRestrictedDialogIntent(this, target.getComponentName().getPackageName(), target.getUid()); return true; } private void showPermissionDialogIfNeeded(Context context, AccessibilityServiceTarget serviceTarget, ShortcutTargetAdapter targetAdapter) { if (mPermissionDialog != null) { Loading