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

Commit baf62d25 authored by Ahaan Ugale's avatar Ahaan Ugale Committed by Android (Google) Code Review
Browse files

Merge "Show Toast on applying SensitiveContentProtection" into main

parents c1ab554c a278221e
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -6443,6 +6443,9 @@ ul.</string>
    <!-- Notification action title used instead of a notification's normal title sensitive [CHAR_LIMIT=NOTIF_BODY] -->
    <string name="redacted_notification_action_title"></string>

    <!-- Toast when an app's content is hidden from screen share (user can still see content) due to potential security risks of showing the content (such as a password or OTP) - [CHAR_LIMIT=TOAST] -->
    <string name="screen_not_shared_sensitive_content">App content hidden from screen share for security</string>

    <!-- Satellite related messages -->
    <!-- Notification title when satellite service is connected. -->
    <string name="satellite_notification_title">Auto connected to satellite</string>
+2 −1
Original line number Diff line number Diff line
@@ -5207,9 +5207,10 @@
  <java-symbol type="string" name="keyboard_layout_notification_multiple_selected_title"/>
  <java-symbol type="string" name="keyboard_layout_notification_multiple_selected_message"/>

  <!-- For redacted notifications -->
  <!-- For redacted notifications and screen sharing-->
  <java-symbol type="string" name="redacted_notification_message"/>
  <java-symbol type="string" name="redacted_notification_action_title"/>
  <java-symbol type="string" name="screen_not_shared_sensitive_content"/>

  <java-symbol type="bool" name="config_batteryStatsResetOnUnplugHighBatteryLevel" />
  <java-symbol type="bool" name="config_batteryStatsResetOnUnplugAfterSignificantCharge" />
−166 B (52.8 KiB)

File changed.

No diff preview for this file type.

+35 −0
Original line number Diff line number Diff line
@@ -43,6 +43,7 @@ import static android.os.Process.SYSTEM_UID;
import static android.os.Process.myPid;
import static android.os.Process.myUid;
import static android.os.Trace.TRACE_TAG_WINDOW_MANAGER;
import static android.permission.flags.Flags.sensitiveContentImprovements;
import static android.provider.Settings.Global.DEVELOPMENT_ENABLE_FREEFORM_WINDOWS_SUPPORT;
import static android.provider.Settings.Global.DEVELOPMENT_ENABLE_NON_RESIZABLE_MULTI_WINDOW;
import static android.provider.Settings.Global.DEVELOPMENT_FORCE_DESKTOP_MODE_ON_EXTERNAL_DISPLAYS;
@@ -306,6 +307,7 @@ import android.view.WindowManagerPolicyConstants.PointerEventListener;
import android.view.displayhash.DisplayHash;
import android.view.displayhash.VerifiedDisplayHash;
import android.view.inputmethod.ImeTracker;
import android.widget.Toast;
import android.window.ActivityWindowInfo;
import android.window.AddToSurfaceSyncGroupResult;
import android.window.ClientWindowFrames;
@@ -8722,6 +8724,15 @@ public class WindowManagerService extends IWindowManager.Stub
                        mSensitiveContentPackages.addBlockScreenCaptureForApps(packageInfos);
                if (modified) {
                    WindowManagerService.this.refreshScreenCaptureDisabled();
                    if (sensitiveContentImprovements()) {
                        // TODO(b/331842561): Combine this traversal with the one inside
                        // refreshScreenCaptureDisabled above.
                        mRoot.forAllWindows((w) -> {
                            if (w.isVisible()) {
                                WindowManagerService.this.showToastIfBlockingScreenCapture(w);
                            }
                        }, /* traverseTopToBottom= */ true);
                    }
                }
            }
        }
@@ -10130,4 +10141,28 @@ public class WindowManagerService extends IWindowManager.Stub
    boolean getDisableSecureWindows() {
        return mDisableSecureWindows;
    }

    /**
     * Called to notify WMS that the specified window has become visible. This shows a Toast if the
     * window is deemed to hold sensitive content.
     */
    void onWindowVisible(@NonNull WindowState w) {
        showToastIfBlockingScreenCapture(w);
    }

    /**
     * Shows a Toast if the specified window is
     * {@link LocalService#addBlockScreenCaptureForApps(ArraySet) blocked} from screen capture based
     * on sensitive content protections.
     */
    private void showToastIfBlockingScreenCapture(@NonNull WindowState w) {
        // TODO(b/323580163): Check if already shown and update shown state.
        if (mSensitiveContentPackages.shouldBlockScreenCaptureForApp(w.getOwningPackage(),
                w.getOwningUid(), w.getWindowToken())) {
            Toast.makeText(mContext, Looper.getMainLooper(),
                            mContext.getString(R.string.screen_not_shared_sensitive_content),
                            Toast.LENGTH_SHORT)
                    .show();
        }
    }
}
+4 −0
Original line number Diff line number Diff line
@@ -28,6 +28,7 @@ import static android.graphics.GraphicsProtos.dumpPointProto;
import static android.os.InputConstants.DEFAULT_DISPATCHING_TIMEOUT_MILLIS;
import static android.os.PowerManager.DRAW_WAKE_LOCK;
import static android.os.Trace.TRACE_TAG_WINDOW_MANAGER;
import static android.permission.flags.Flags.sensitiveContentImprovements;
import static android.view.SurfaceControl.Transaction;
import static android.view.ViewTreeObserver.InternalInsetsInfo.TOUCHABLE_INSETS_CONTENT;
import static android.view.ViewTreeObserver.InternalInsetsInfo.TOUCHABLE_INSETS_FRAME;
@@ -2127,6 +2128,9 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP
                }
            }
            setDisplayLayoutNeeded();
            if (sensitiveContentImprovements() && visible) {
                mWmService.onWindowVisible(this);
            }
        }
    }