Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b98a658c authored by lucychang's avatar lucychang Committed by Lucy Chang
Browse files

Prompt notifications for non-accessibility services

Prompts a notification for the non-accessibility category service after
24 hours enabled to alert users the service has powerful permissions to
view and control the device. And the notification won't be resend to
the same service by saving the dismiss record to Settings.

Bug: 176965357
Test: atest AccessibilitySecurityPolicyTest
      atest PolicyWarningUIControllerTest
      and manually test

Change-Id: Id5daf7b14dc88cf3f71a53f46fa9a8f1dee91822
parent 4e942668
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
@@ -7036,6 +7036,15 @@ public final class Settings {
        public static final String ENABLED_ACCESSIBILITY_SERVICES =
            "enabled_accessibility_services";
        /**
         * List of the notified non-accessibility category accessibility services.
         *
         * @hide
         */
        @Readable
        public static final String NOTIFIED_NON_ACCESSIBILITY_CATEGORY_SERVICES =
                "notified_non_accessibility_category_services";
        /**
         * List of the accessibility services to which the user has granted
         * permission to put the device into touch exploration mode.
+7 −0
Original line number Diff line number Diff line
@@ -58,6 +58,7 @@ public class SystemNotificationChannels {
    public static String SYSTEM_CHANGES = "SYSTEM_CHANGES";
    public static String DO_NOT_DISTURB = "DO_NOT_DISTURB";
    public static String ACCESSIBILITY_MAGNIFICATION = "ACCESSIBILITY_MAGNIFICATION";
    public static String ACCESSIBILITY_SECURITY_POLICY = "ACCESSIBILITY_SECURITY_POLICY";

    public static void createAll(Context context) {
        final NotificationManager nm = context.getSystemService(NotificationManager.class);
@@ -199,6 +200,12 @@ public class SystemNotificationChannels {
        newFeaturePrompt.setBlockable(true);
        channelsList.add(newFeaturePrompt);

        final NotificationChannel accessibilitySecurityPolicyChannel = new NotificationChannel(
                ACCESSIBILITY_SECURITY_POLICY,
                context.getString(R.string.notification_channel_accessibility_security_policy),
                NotificationManager.IMPORTANCE_LOW);
        channelsList.add(accessibilitySecurityPolicyChannel);

        nm.createNotificationChannels(channelsList);
    }

+27 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!--
  Copyright (C) 2021 The Android Open Source Project

  Licensed under the Apache License, Version 2.0 (the "License");
  you may not use this file except in compliance with the License.
  You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

  Unless required by applicable law or agreed to in writing, software
  distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the specific language governing permissions and
  limitations under the License.
  -->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
        android:width="21dp"
        android:height="21dp"
        android:viewportWidth="24"
        android:viewportHeight="24">
    <path
        android:pathData="M20.5,6c-2.61,0.7 -5.67,1 -8.5,1S6.11,6.7 3.5,6L3,8c1.86,0.5 4,0.83 6,
        1v13h2v-6h2v6h2V9c2,-0.17 4.14,-0.5 6,-1L20.5,6zM12,6c1.1,0 2,-0.9 2,-2s-0.9,-2 -2,-2s-2,
        0.9 -2,2S10.9,6 12,6z"
        android:fillColor="#FF000000"/>
</vector>
 No newline at end of file
+9 −0
Original line number Diff line number Diff line
@@ -743,6 +743,10 @@
         magnification. [CHAR_LIMIT=NONE]-->
    <string name="notification_channel_accessibility_magnification">Magnification</string>

    <!-- Text shown when viewing channel settings for notifications related to accessibility
         security policy. [CHAR_LIMIT=NONE]-->
    <string name="notification_channel_accessibility_security_policy">Accessibility security policy</string>

    <!-- Label for foreground service notification when one app is running.
    [CHAR LIMIT=NONE BACKUP_MESSAGE_ID=6826789589341671842] -->
    <string name="foreground_service_app_in_background"><xliff:g id="app_name">%1$s</xliff:g> is
@@ -5910,4 +5914,9 @@ ul.</string>
    <string name="splash_screen_view_icon_description">Application icon</string>
    <!-- Content description for the branding image on the splash screen. [CHAR LIMIT=50] -->
    <string name="splash_screen_view_branding_description">Application branding image</string>

    <!-- Notification title to prompt the user that some accessibility service has view and control access. [CHAR LIMIT=50] -->
    <string name="view_and_control_notification_title">Check access settings</string>
    <!-- Notification content to prompt the user that some accessibility service has view and control access. [CHAR LIMIT=none] -->
    <string name="view_and_control_notification_content"><xliff:g id="service_name" example="TalkBack">%s</xliff:g> can view and control your screen. Tap to review.</string>
</resources>
+6 −0
Original line number Diff line number Diff line
@@ -3541,6 +3541,7 @@
  <java-symbol type="string" name="notification_channel_system_changes" />
  <java-symbol type="string" name="notification_channel_do_not_disturb" />
  <java-symbol type="string" name="notification_channel_accessibility_magnification" />
  <java-symbol type="string" name="notification_channel_accessibility_security_policy" />
  <java-symbol type="string" name="config_defaultAutofillService" />
  <java-symbol type="string" name="config_defaultOnDeviceSpeechRecognitionService" />
  <java-symbol type="string" name="config_defaultTextClassifierPackage" />
@@ -4323,4 +4324,9 @@
  <java-symbol type="id" name="remote_views_next_child" />
  <java-symbol type="id" name="remote_views_stable_id" />
  <java-symbol type="id" name="remote_views_override_id" />

  <!-- View and control prompt -->
  <java-symbol type="drawable" name="ic_accessibility_24dp" />
  <java-symbol type="string" name="view_and_control_notification_title" />
  <java-symbol type="string" name="view_and_control_notification_content" />
</resources>
Loading