Loading packages/SystemUI/aconfig/systemui.aconfig +10 −0 Original line number Diff line number Diff line Loading @@ -522,6 +522,16 @@ flag { } } flag { name: "screenshot_private_profile_accessibility_announcement_fix" namespace: "systemui" description: "Modified a11y announcement for private space screenshots" bug: "326941376" metadata { purpose: PURPOSE_BUGFIX } } flag { name: "screenshot_private_profile_behavior_fix" namespace: "systemui" Loading packages/SystemUI/res/values/strings.xml +2 −0 Original line number Diff line number Diff line Loading @@ -214,6 +214,8 @@ <string name="screenshot_saving_title">Saving screenshot\u2026</string> <!-- Informs the user that a screenshot is being saved. [CHAR LIMIT=50] --> <string name="screenshot_saving_work_profile_title">Saving screenshot to work profile\u2026</string> <!-- Informs the user that a screenshot is being saved to the private profile. [CHAR LIMIT=100] --> <string name="screenshot_saving_private_profile">Saving screenshot to private</string> <!-- Notification title displayed when a screenshot is saved to the Gallery. [CHAR LIMIT=50] --> <string name="screenshot_saved_title">Screenshot saved</string> <!-- Notification title displayed when we fail to take a screenshot. [CHAR LIMIT=50] --> Loading packages/SystemUI/src/com/android/systemui/screenshot/AnnouncementResolver.kt 0 → 100644 +47 −0 Original line number Diff line number Diff line /* * Copyright (C) 2024 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. */ package com.android.systemui.screenshot import com.android.systemui.dagger.qualifiers.Application import com.android.systemui.screenshot.data.model.ProfileType import com.android.systemui.screenshot.data.repository.ProfileTypeRepository import com.android.systemui.screenshot.resources.Messages import java.util.function.Consumer import javax.inject.Inject import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.launch /** Logic for determining the announcement that a screenshot has been taken (for accessibility). */ class AnnouncementResolver @Inject constructor( private val messages: Messages, private val profileTypes: ProfileTypeRepository, @Application private val mainScope: CoroutineScope, ) { suspend fun getScreenshotAnnouncement(userId: Int): String = when (profileTypes.getProfileType(userId)) { ProfileType.PRIVATE -> messages.savingToPrivateProfileAnnouncement ProfileType.WORK -> messages.savingToWorkProfileAnnouncement else -> messages.savingScreenshotAnnouncement } fun getScreenshotAnnouncement(userId: Int, announceCallback: Consumer<String>) { mainScope.launch { announceCallback.accept(getScreenshotAnnouncement(userId)) } } } packages/SystemUI/src/com/android/systemui/screenshot/ScreenshotController.java +17 −5 Original line number Diff line number Diff line Loading @@ -19,6 +19,7 @@ package com.android.systemui.screenshot; import static android.content.res.Configuration.ORIENTATION_PORTRAIT; import static android.view.WindowManager.LayoutParams.TYPE_SCREENSHOT; import static com.android.systemui.Flags.screenshotPrivateProfileAccessibilityAnnouncementFix; import static com.android.systemui.Flags.screenshotShelfUi2; import static com.android.systemui.screenshot.LogConfig.DEBUG_ANIM; import static com.android.systemui.screenshot.LogConfig.DEBUG_CALLBACK; Loading Loading @@ -218,6 +219,7 @@ public class ScreenshotController { private final AssistContentRequester mAssistContentRequester; private final MessageContainerController mMessageContainerController; private final AnnouncementResolver mAnnouncementResolver; private Bitmap mScreenBitmap; private SaveImageInBackgroundTask mSaveInBgTask; private boolean mScreenshotTakenInPortrait; Loading Loading @@ -269,6 +271,7 @@ public class ScreenshotController { AssistContentRequester assistContentRequester, MessageContainerController messageContainerController, Provider<ScreenshotSoundController> screenshotSoundController, AnnouncementResolver announcementResolver, @Assisted Display display, @Assisted boolean showUIOnExternalDisplay ) { Loading Loading @@ -298,6 +301,7 @@ public class ScreenshotController { mUserManager = userManager; mMessageContainerController = messageContainerController; mAssistContentRequester = assistContentRequester; mAnnouncementResolver = announcementResolver; mViewProxy = viewProxyFactory.getProxy(mContext, mDisplay.getDisplayId()); Loading Loading @@ -461,6 +465,13 @@ public class ScreenshotController { void prepareViewForNewScreenshot(@NonNull ScreenshotData screenshot, String oldPackageName) { withWindowAttached(() -> { if (screenshotPrivateProfileAccessibilityAnnouncementFix()) { mAnnouncementResolver.getScreenshotAnnouncement( screenshot.getUserHandle().getIdentifier(), announcement -> { mViewProxy.announceForAccessibility(announcement); }); } else { if (mUserManager.isManagedProfile(screenshot.getUserHandle().getIdentifier())) { mViewProxy.announceForAccessibility(mContext.getResources().getString( R.string.screenshot_saving_work_profile_title)); Loading @@ -468,6 +479,7 @@ public class ScreenshotController { mViewProxy.announceForAccessibility( mContext.getResources().getString(R.string.screenshot_saving_title)); } } }); mViewProxy.reset(); Loading packages/SystemUI/src/com/android/systemui/screenshot/resources/Messages.kt 0 → 100644 +40 −0 Original line number Diff line number Diff line /* * Copyright (C) 2024 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. */ package com.android.systemui.screenshot.resources import android.content.Context import androidx.annotation.OpenForTesting import com.android.systemui.dagger.SysUISingleton import com.android.systemui.res.R import javax.inject.Inject /** String values from resources, for easy injection. */ @OpenForTesting @SysUISingleton open class Messages @Inject constructor(private val context: Context) { open val savingScreenshotAnnouncement by lazy { requireNotNull(context.resources.getString(R.string.screenshot_saving_title)) } open val savingToWorkProfileAnnouncement by lazy { requireNotNull(context.resources.getString(R.string.screenshot_saving_work_profile_title)) } open val savingToPrivateProfileAnnouncement by lazy { requireNotNull(context.resources.getString(R.string.screenshot_saving_private_profile)) } } Loading
packages/SystemUI/aconfig/systemui.aconfig +10 −0 Original line number Diff line number Diff line Loading @@ -522,6 +522,16 @@ flag { } } flag { name: "screenshot_private_profile_accessibility_announcement_fix" namespace: "systemui" description: "Modified a11y announcement for private space screenshots" bug: "326941376" metadata { purpose: PURPOSE_BUGFIX } } flag { name: "screenshot_private_profile_behavior_fix" namespace: "systemui" Loading
packages/SystemUI/res/values/strings.xml +2 −0 Original line number Diff line number Diff line Loading @@ -214,6 +214,8 @@ <string name="screenshot_saving_title">Saving screenshot\u2026</string> <!-- Informs the user that a screenshot is being saved. [CHAR LIMIT=50] --> <string name="screenshot_saving_work_profile_title">Saving screenshot to work profile\u2026</string> <!-- Informs the user that a screenshot is being saved to the private profile. [CHAR LIMIT=100] --> <string name="screenshot_saving_private_profile">Saving screenshot to private</string> <!-- Notification title displayed when a screenshot is saved to the Gallery. [CHAR LIMIT=50] --> <string name="screenshot_saved_title">Screenshot saved</string> <!-- Notification title displayed when we fail to take a screenshot. [CHAR LIMIT=50] --> Loading
packages/SystemUI/src/com/android/systemui/screenshot/AnnouncementResolver.kt 0 → 100644 +47 −0 Original line number Diff line number Diff line /* * Copyright (C) 2024 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. */ package com.android.systemui.screenshot import com.android.systemui.dagger.qualifiers.Application import com.android.systemui.screenshot.data.model.ProfileType import com.android.systemui.screenshot.data.repository.ProfileTypeRepository import com.android.systemui.screenshot.resources.Messages import java.util.function.Consumer import javax.inject.Inject import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.launch /** Logic for determining the announcement that a screenshot has been taken (for accessibility). */ class AnnouncementResolver @Inject constructor( private val messages: Messages, private val profileTypes: ProfileTypeRepository, @Application private val mainScope: CoroutineScope, ) { suspend fun getScreenshotAnnouncement(userId: Int): String = when (profileTypes.getProfileType(userId)) { ProfileType.PRIVATE -> messages.savingToPrivateProfileAnnouncement ProfileType.WORK -> messages.savingToWorkProfileAnnouncement else -> messages.savingScreenshotAnnouncement } fun getScreenshotAnnouncement(userId: Int, announceCallback: Consumer<String>) { mainScope.launch { announceCallback.accept(getScreenshotAnnouncement(userId)) } } }
packages/SystemUI/src/com/android/systemui/screenshot/ScreenshotController.java +17 −5 Original line number Diff line number Diff line Loading @@ -19,6 +19,7 @@ package com.android.systemui.screenshot; import static android.content.res.Configuration.ORIENTATION_PORTRAIT; import static android.view.WindowManager.LayoutParams.TYPE_SCREENSHOT; import static com.android.systemui.Flags.screenshotPrivateProfileAccessibilityAnnouncementFix; import static com.android.systemui.Flags.screenshotShelfUi2; import static com.android.systemui.screenshot.LogConfig.DEBUG_ANIM; import static com.android.systemui.screenshot.LogConfig.DEBUG_CALLBACK; Loading Loading @@ -218,6 +219,7 @@ public class ScreenshotController { private final AssistContentRequester mAssistContentRequester; private final MessageContainerController mMessageContainerController; private final AnnouncementResolver mAnnouncementResolver; private Bitmap mScreenBitmap; private SaveImageInBackgroundTask mSaveInBgTask; private boolean mScreenshotTakenInPortrait; Loading Loading @@ -269,6 +271,7 @@ public class ScreenshotController { AssistContentRequester assistContentRequester, MessageContainerController messageContainerController, Provider<ScreenshotSoundController> screenshotSoundController, AnnouncementResolver announcementResolver, @Assisted Display display, @Assisted boolean showUIOnExternalDisplay ) { Loading Loading @@ -298,6 +301,7 @@ public class ScreenshotController { mUserManager = userManager; mMessageContainerController = messageContainerController; mAssistContentRequester = assistContentRequester; mAnnouncementResolver = announcementResolver; mViewProxy = viewProxyFactory.getProxy(mContext, mDisplay.getDisplayId()); Loading Loading @@ -461,6 +465,13 @@ public class ScreenshotController { void prepareViewForNewScreenshot(@NonNull ScreenshotData screenshot, String oldPackageName) { withWindowAttached(() -> { if (screenshotPrivateProfileAccessibilityAnnouncementFix()) { mAnnouncementResolver.getScreenshotAnnouncement( screenshot.getUserHandle().getIdentifier(), announcement -> { mViewProxy.announceForAccessibility(announcement); }); } else { if (mUserManager.isManagedProfile(screenshot.getUserHandle().getIdentifier())) { mViewProxy.announceForAccessibility(mContext.getResources().getString( R.string.screenshot_saving_work_profile_title)); Loading @@ -468,6 +479,7 @@ public class ScreenshotController { mViewProxy.announceForAccessibility( mContext.getResources().getString(R.string.screenshot_saving_title)); } } }); mViewProxy.reset(); Loading
packages/SystemUI/src/com/android/systemui/screenshot/resources/Messages.kt 0 → 100644 +40 −0 Original line number Diff line number Diff line /* * Copyright (C) 2024 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. */ package com.android.systemui.screenshot.resources import android.content.Context import androidx.annotation.OpenForTesting import com.android.systemui.dagger.SysUISingleton import com.android.systemui.res.R import javax.inject.Inject /** String values from resources, for easy injection. */ @OpenForTesting @SysUISingleton open class Messages @Inject constructor(private val context: Context) { open val savingScreenshotAnnouncement by lazy { requireNotNull(context.resources.getString(R.string.screenshot_saving_title)) } open val savingToWorkProfileAnnouncement by lazy { requireNotNull(context.resources.getString(R.string.screenshot_saving_work_profile_title)) } open val savingToPrivateProfileAnnouncement by lazy { requireNotNull(context.resources.getString(R.string.screenshot_saving_private_profile)) } }