Loading core/java/com/android/internal/accessibility/util/AccessibilityStatsLogUtils.java +30 −0 Original line number Diff line number Diff line Loading @@ -39,6 +39,9 @@ import static com.android.internal.util.FrameworkStatsLog.MAGNIFICATION_USAGE_RE import static com.android.internal.util.FrameworkStatsLog.MAGNIFICATION_USAGE_REPORTED__ACTIVATED_MODE__MAGNIFICATION_FULL_SCREEN; import static com.android.internal.util.FrameworkStatsLog.MAGNIFICATION_USAGE_REPORTED__ACTIVATED_MODE__MAGNIFICATION_UNKNOWN_MODE; import static com.android.internal.util.FrameworkStatsLog.MAGNIFICATION_USAGE_REPORTED__ACTIVATED_MODE__MAGNIFICATION_WINDOW; import static com.android.internal.util.FrameworkStatsLog.NON_A11Y_TOOL_SERVICE_WARNING_REPORTED__STATUS__WARNING_CLICKED; import static com.android.internal.util.FrameworkStatsLog.NON_A11Y_TOOL_SERVICE_WARNING_REPORTED__STATUS__WARNING_SERVICE_DISABLED; import static com.android.internal.util.FrameworkStatsLog.NON_A11Y_TOOL_SERVICE_WARNING_REPORTED__STATUS__WARNING_SHOWN; import android.content.ComponentName; import android.content.Context; Loading @@ -50,6 +53,16 @@ import com.android.internal.util.FrameworkStatsLog; /** Methods for logging accessibility states. */ public final class AccessibilityStatsLogUtils { /** The status represents an accessibility privacy warning has been shown. */ public static int ACCESSIBILITY_PRIVACY_WARNING_STATUS_SHOWN = NON_A11Y_TOOL_SERVICE_WARNING_REPORTED__STATUS__WARNING_SHOWN; /** The status represents an accessibility privacy warning has been clicked to review. */ public static int ACCESSIBILITY_PRIVACY_WARNING_STATUS_CLICKED = NON_A11Y_TOOL_SERVICE_WARNING_REPORTED__STATUS__WARNING_CLICKED; /** The status represents an accessibility privacy warning service has been disabled. */ public static int ACCESSIBILITY_PRIVACY_WARNING_STATUS_SERVICE_DISABLED = NON_A11Y_TOOL_SERVICE_WARNING_REPORTED__STATUS__WARNING_SERVICE_DISABLED; private static final int UNKNOWN_STATUS = ACCESSIBILITY_SHORTCUT_REPORTED__SERVICE_STATUS__UNKNOWN; Loading Loading @@ -154,6 +167,23 @@ public final class AccessibilityStatsLogUtils { convertToLoggingMagnificationMode(mode)); } /** * Logs the warning status of the non-a11yTool service. Calls this when the warning status is * changed. * * @param packageName The package name of the non-a11yTool service * @param status The warning status of the non-a11yTool service, it should be one of * {@code ACCESSIBILITY_PRIVACY_WARNING_STATUS_SHOWN},{@code * ACCESSIBILITY_PRIVACY_WARNING_STATUS_CLICKED} and {@code * ACCESSIBILITY_PRIVACY_WARNING_STATUS_SERVICE_DISABLED} * @param durationMillis The duration in milliseconds between current and previous status */ public static void logNonA11yToolServiceWarningReported(String packageName, int status, long durationMillis) { FrameworkStatsLog.write(FrameworkStatsLog.NON_A11Y_TOOL_SERVICE_WARNING_REPORT, packageName, status, durationMillis); } private static boolean isAccessibilityFloatingMenuEnabled(Context context) { return Settings.Secure.getInt(context.getContentResolver(), Settings.Secure.ACCESSIBILITY_BUTTON_MODE, /* def= */ -1) Loading services/accessibility/java/com/android/server/accessibility/PolicyWarningUIController.java +29 −8 Original line number Diff line number Diff line Loading @@ -40,6 +40,7 @@ import android.graphics.Bitmap; import android.graphics.drawable.Drawable; import android.os.Bundle; import android.os.Handler; import android.os.SystemClock; import android.os.UserHandle; import android.provider.Settings; import android.text.TextUtils; Loading @@ -47,6 +48,7 @@ import android.util.ArraySet; import android.view.accessibility.AccessibilityManager; import com.android.internal.R; import com.android.internal.accessibility.util.AccessibilityStatsLogUtils; import com.android.internal.annotations.VisibleForTesting; import com.android.internal.notification.SystemNotificationChannels; import com.android.internal.util.ImageUtils; Loading @@ -71,6 +73,7 @@ public class PolicyWarningUIController { @VisibleForTesting protected static final String ACTION_DISMISS_NOTIFICATION = TAG + ".ACTION_DISMISS_NOTIFICATION"; private static final String EXTRA_TIME_FOR_LOGGING = "start_time_to_log_a11y_tool"; private static final int SEND_NOTIFICATION_DELAY_HOURS = 24; /** Current enabled accessibility services. */ Loading Loading @@ -179,7 +182,8 @@ public class PolicyWarningUIController { intent.setPackage(context.getPackageName()) .setIdentifier(serviceComponentName.flattenToShortString()) .putExtra(Intent.EXTRA_COMPONENT_NAME, serviceComponentName) .putExtra(Intent.EXTRA_USER_ID, userId); .putExtra(Intent.EXTRA_USER_ID, userId) .putExtra(Intent.EXTRA_TIME, SystemClock.elapsedRealtime()); return intent; } Loading Loading @@ -214,11 +218,24 @@ public class PolicyWarningUIController { if (TextUtils.isEmpty(action) || componentName == null) { return; } final long startTimeMills = intent.getLongExtra(Intent.EXTRA_TIME, 0); final long durationMills = startTimeMills > 0 ? SystemClock.elapsedRealtime() - startTimeMills : 0; final int userId = intent.getIntExtra(Intent.EXTRA_USER_ID, UserHandle.USER_SYSTEM); if (ACTION_SEND_NOTIFICATION.equals(action)) { trySendNotification(userId, componentName); if (trySendNotification(userId, componentName)) { AccessibilityStatsLogUtils.logNonA11yToolServiceWarningReported( componentName.getPackageName(), AccessibilityStatsLogUtils.ACCESSIBILITY_PRIVACY_WARNING_STATUS_SHOWN, durationMills); } } else if (ACTION_A11Y_SETTINGS.equals(action)) { launchSettings(userId, componentName); if (tryLaunchSettings(userId, componentName)) { AccessibilityStatsLogUtils.logNonA11yToolServiceWarningReported( componentName.getPackageName(), AccessibilityStatsLogUtils.ACCESSIBILITY_PRIVACY_WARNING_STATUS_CLICKED, durationMills); } mNotificationManager.cancel(componentName.flattenToShortString(), NOTE_A11Y_VIEW_AND_CONTROL_ACCESS); onNotificationCanceled(userId, componentName); Loading @@ -240,12 +257,12 @@ public class PolicyWarningUIController { } } private void trySendNotification(int userId, ComponentName componentName) { private boolean trySendNotification(int userId, ComponentName componentName) { if (!AccessibilitySecurityPolicy.POLICY_WARNING_ENABLED) { return; return false; } if (userId != mCurrentUserId) { return; return false; } List<AccessibilityServiceInfo> enabledServiceInfos = getEnabledServiceInfos(); Loading @@ -264,23 +281,27 @@ public class PolicyWarningUIController { android.R.dimen.app_icon_size); sendNotification(userId, componentName, displayName, ImageUtils.buildScaledBitmap(drawable, size, size)); return true; } break; } } return false; } private void launchSettings(int userId, ComponentName componentName) { private boolean tryLaunchSettings(int userId, ComponentName componentName) { if (userId != mCurrentUserId) { return; return false; } final Intent intent = new Intent(Settings.ACTION_ACCESSIBILITY_DETAILS_SETTINGS); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK); intent.putExtra(Intent.EXTRA_COMPONENT_NAME, componentName.flattenToShortString()); intent.putExtra(EXTRA_TIME_FOR_LOGGING, SystemClock.elapsedRealtime()); final Bundle bundle = ActivityOptions.makeBasic().setLaunchDisplayId( mContext.getDisplayId()).toBundle(); mContext.startActivityAsUser(intent, bundle, UserHandle.of(userId)); mContext.getSystemService(StatusBarManager.class).collapsePanels(); return true; } protected void onNotificationCanceled(int userId, ComponentName componentName) { Loading Loading
core/java/com/android/internal/accessibility/util/AccessibilityStatsLogUtils.java +30 −0 Original line number Diff line number Diff line Loading @@ -39,6 +39,9 @@ import static com.android.internal.util.FrameworkStatsLog.MAGNIFICATION_USAGE_RE import static com.android.internal.util.FrameworkStatsLog.MAGNIFICATION_USAGE_REPORTED__ACTIVATED_MODE__MAGNIFICATION_FULL_SCREEN; import static com.android.internal.util.FrameworkStatsLog.MAGNIFICATION_USAGE_REPORTED__ACTIVATED_MODE__MAGNIFICATION_UNKNOWN_MODE; import static com.android.internal.util.FrameworkStatsLog.MAGNIFICATION_USAGE_REPORTED__ACTIVATED_MODE__MAGNIFICATION_WINDOW; import static com.android.internal.util.FrameworkStatsLog.NON_A11Y_TOOL_SERVICE_WARNING_REPORTED__STATUS__WARNING_CLICKED; import static com.android.internal.util.FrameworkStatsLog.NON_A11Y_TOOL_SERVICE_WARNING_REPORTED__STATUS__WARNING_SERVICE_DISABLED; import static com.android.internal.util.FrameworkStatsLog.NON_A11Y_TOOL_SERVICE_WARNING_REPORTED__STATUS__WARNING_SHOWN; import android.content.ComponentName; import android.content.Context; Loading @@ -50,6 +53,16 @@ import com.android.internal.util.FrameworkStatsLog; /** Methods for logging accessibility states. */ public final class AccessibilityStatsLogUtils { /** The status represents an accessibility privacy warning has been shown. */ public static int ACCESSIBILITY_PRIVACY_WARNING_STATUS_SHOWN = NON_A11Y_TOOL_SERVICE_WARNING_REPORTED__STATUS__WARNING_SHOWN; /** The status represents an accessibility privacy warning has been clicked to review. */ public static int ACCESSIBILITY_PRIVACY_WARNING_STATUS_CLICKED = NON_A11Y_TOOL_SERVICE_WARNING_REPORTED__STATUS__WARNING_CLICKED; /** The status represents an accessibility privacy warning service has been disabled. */ public static int ACCESSIBILITY_PRIVACY_WARNING_STATUS_SERVICE_DISABLED = NON_A11Y_TOOL_SERVICE_WARNING_REPORTED__STATUS__WARNING_SERVICE_DISABLED; private static final int UNKNOWN_STATUS = ACCESSIBILITY_SHORTCUT_REPORTED__SERVICE_STATUS__UNKNOWN; Loading Loading @@ -154,6 +167,23 @@ public final class AccessibilityStatsLogUtils { convertToLoggingMagnificationMode(mode)); } /** * Logs the warning status of the non-a11yTool service. Calls this when the warning status is * changed. * * @param packageName The package name of the non-a11yTool service * @param status The warning status of the non-a11yTool service, it should be one of * {@code ACCESSIBILITY_PRIVACY_WARNING_STATUS_SHOWN},{@code * ACCESSIBILITY_PRIVACY_WARNING_STATUS_CLICKED} and {@code * ACCESSIBILITY_PRIVACY_WARNING_STATUS_SERVICE_DISABLED} * @param durationMillis The duration in milliseconds between current and previous status */ public static void logNonA11yToolServiceWarningReported(String packageName, int status, long durationMillis) { FrameworkStatsLog.write(FrameworkStatsLog.NON_A11Y_TOOL_SERVICE_WARNING_REPORT, packageName, status, durationMillis); } private static boolean isAccessibilityFloatingMenuEnabled(Context context) { return Settings.Secure.getInt(context.getContentResolver(), Settings.Secure.ACCESSIBILITY_BUTTON_MODE, /* def= */ -1) Loading
services/accessibility/java/com/android/server/accessibility/PolicyWarningUIController.java +29 −8 Original line number Diff line number Diff line Loading @@ -40,6 +40,7 @@ import android.graphics.Bitmap; import android.graphics.drawable.Drawable; import android.os.Bundle; import android.os.Handler; import android.os.SystemClock; import android.os.UserHandle; import android.provider.Settings; import android.text.TextUtils; Loading @@ -47,6 +48,7 @@ import android.util.ArraySet; import android.view.accessibility.AccessibilityManager; import com.android.internal.R; import com.android.internal.accessibility.util.AccessibilityStatsLogUtils; import com.android.internal.annotations.VisibleForTesting; import com.android.internal.notification.SystemNotificationChannels; import com.android.internal.util.ImageUtils; Loading @@ -71,6 +73,7 @@ public class PolicyWarningUIController { @VisibleForTesting protected static final String ACTION_DISMISS_NOTIFICATION = TAG + ".ACTION_DISMISS_NOTIFICATION"; private static final String EXTRA_TIME_FOR_LOGGING = "start_time_to_log_a11y_tool"; private static final int SEND_NOTIFICATION_DELAY_HOURS = 24; /** Current enabled accessibility services. */ Loading Loading @@ -179,7 +182,8 @@ public class PolicyWarningUIController { intent.setPackage(context.getPackageName()) .setIdentifier(serviceComponentName.flattenToShortString()) .putExtra(Intent.EXTRA_COMPONENT_NAME, serviceComponentName) .putExtra(Intent.EXTRA_USER_ID, userId); .putExtra(Intent.EXTRA_USER_ID, userId) .putExtra(Intent.EXTRA_TIME, SystemClock.elapsedRealtime()); return intent; } Loading Loading @@ -214,11 +218,24 @@ public class PolicyWarningUIController { if (TextUtils.isEmpty(action) || componentName == null) { return; } final long startTimeMills = intent.getLongExtra(Intent.EXTRA_TIME, 0); final long durationMills = startTimeMills > 0 ? SystemClock.elapsedRealtime() - startTimeMills : 0; final int userId = intent.getIntExtra(Intent.EXTRA_USER_ID, UserHandle.USER_SYSTEM); if (ACTION_SEND_NOTIFICATION.equals(action)) { trySendNotification(userId, componentName); if (trySendNotification(userId, componentName)) { AccessibilityStatsLogUtils.logNonA11yToolServiceWarningReported( componentName.getPackageName(), AccessibilityStatsLogUtils.ACCESSIBILITY_PRIVACY_WARNING_STATUS_SHOWN, durationMills); } } else if (ACTION_A11Y_SETTINGS.equals(action)) { launchSettings(userId, componentName); if (tryLaunchSettings(userId, componentName)) { AccessibilityStatsLogUtils.logNonA11yToolServiceWarningReported( componentName.getPackageName(), AccessibilityStatsLogUtils.ACCESSIBILITY_PRIVACY_WARNING_STATUS_CLICKED, durationMills); } mNotificationManager.cancel(componentName.flattenToShortString(), NOTE_A11Y_VIEW_AND_CONTROL_ACCESS); onNotificationCanceled(userId, componentName); Loading @@ -240,12 +257,12 @@ public class PolicyWarningUIController { } } private void trySendNotification(int userId, ComponentName componentName) { private boolean trySendNotification(int userId, ComponentName componentName) { if (!AccessibilitySecurityPolicy.POLICY_WARNING_ENABLED) { return; return false; } if (userId != mCurrentUserId) { return; return false; } List<AccessibilityServiceInfo> enabledServiceInfos = getEnabledServiceInfos(); Loading @@ -264,23 +281,27 @@ public class PolicyWarningUIController { android.R.dimen.app_icon_size); sendNotification(userId, componentName, displayName, ImageUtils.buildScaledBitmap(drawable, size, size)); return true; } break; } } return false; } private void launchSettings(int userId, ComponentName componentName) { private boolean tryLaunchSettings(int userId, ComponentName componentName) { if (userId != mCurrentUserId) { return; return false; } final Intent intent = new Intent(Settings.ACTION_ACCESSIBILITY_DETAILS_SETTINGS); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK); intent.putExtra(Intent.EXTRA_COMPONENT_NAME, componentName.flattenToShortString()); intent.putExtra(EXTRA_TIME_FOR_LOGGING, SystemClock.elapsedRealtime()); final Bundle bundle = ActivityOptions.makeBasic().setLaunchDisplayId( mContext.getDisplayId()).toBundle(); mContext.startActivityAsUser(intent, bundle, UserHandle.of(userId)); mContext.getSystemService(StatusBarManager.class).collapsePanels(); return true; } protected void onNotificationCanceled(int userId, ComponentName componentName) { Loading