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

Commit 14c45fc9 authored by Aditya Singh's avatar Aditya Singh
Browse files

Prevent clickjacking attack in DocsUi.

* Added permission `HIDE_OVERLAY_WINDOWS` in the Manifest.
* Set the flag to hide overlay windows to true in BaseActivity and
  ConfirmFragment.

Bug: 233605527
Test: Manually, see http://b/233605527#comment4
Flag: EXEMPT bugfix
Change-Id: I511730856be58cad3e13fa50bfac1e1ee2f5fee0
Merged-In: I511730856be58cad3e13fa50bfac1e1ee2f5fee0
parent 6ed9513e
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -31,6 +31,7 @@
    <uses-permission android:name="android.permission.INTERACT_ACROSS_USERS" />
    <uses-permission android:name="android.permission.MODIFY_QUIET_MODE" />
    <uses-permission android:name="android.permission.QUERY_ALL_PACKAGES" />
    <uses-permission android:name="android.permission.HIDE_OVERLAY_WINDOWS"/>

    <!-- Permissions required for reading and logging compat changes -->
    <uses-permission android:name="android.permission.LOG_COMPAT_CHANGE"/>
+4 −0
Original line number Diff line number Diff line
@@ -134,6 +134,10 @@ public abstract class BaseActivity
        // Record the time when onCreate is invoked for metric.
        mStartTime = new Date().getTime();

        if (Build.VERSION.SDK_INT >= 31) {
            getWindow().setHideOverlayWindows(true);
        }

        // ToDo Create tool to check resource version before applyStyle for the theme
        // If version code is not match, we should reset overlay package to default,
        // in case Activity continueusly encounter resource not found exception
+6 −1
Original line number Diff line number Diff line
@@ -21,6 +21,7 @@ import static com.android.documentsui.base.Shared.getCallingAppName;
import android.app.Dialog;
import android.content.DialogInterface;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;

import androidx.fragment.app.DialogFragment;
@@ -102,7 +103,11 @@ public class ConfirmFragment extends DialogFragment {
        builder.setNegativeButton(android.R.string.cancel,
                (DialogInterface dialog, int id) -> pickResult.increaseActionCount());

        return builder.create();
        Dialog dialog = builder.create();
        if (Build.VERSION.SDK_INT >= 31) {
            dialog.getWindow().setHideOverlayWindows(true);
        }
        return dialog;
    }

    @Override