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

Commit 4f875921 authored by Adam He's avatar Adam He Committed by android-build-merger
Browse files

Merge "ContentCaptureManager is notified when FLAG_SECURE is set dynamically...

Merge "ContentCaptureManager is notified when FLAG_SECURE is set dynamically on windows." into qt-dev
am: 0459aaab

Change-Id: I1d1eb7d988a0f815e4551f95a7044beeac203bf0
parents 9f09b027 0459aaab
Loading
Loading
Loading
Loading
+8 −7
Original line number Diff line number Diff line
@@ -126,7 +126,6 @@ import android.view.autofill.AutofillManager;
import android.view.autofill.AutofillManager.AutofillClient;
import android.view.autofill.AutofillPopupWindow;
import android.view.autofill.IAutofillWindowPresenter;
import android.view.contentcapture.ContentCaptureContext;
import android.view.contentcapture.ContentCaptureManager;
import android.view.contentcapture.ContentCaptureManager.ContentCaptureClient;
import android.widget.AdapterView;
@@ -840,7 +839,7 @@ public class Activity extends ContextThemeWrapper
    /** The autofill manager. Always access via {@link #getAutofillManager()}. */
    @Nullable private AutofillManager mAutofillManager;

    /** The content capture manager. Always access via {@link #getContentCaptureManager()}. */
    /** The content capture manager. Access via {@link #getContentCaptureManager()}. */
    @Nullable private ContentCaptureManager mContentCaptureManager;

    private final ArrayList<Application.ActivityLifecycleCallbacks> mActivityLifecycleCallbacks =
@@ -1092,12 +1091,11 @@ public class Activity extends ContextThemeWrapper
                case CONTENT_CAPTURE_START:
                    //TODO(b/111276913): decide whether the InteractionSessionId should be
                    // saved / restored in the activity bundle - probably not
                    int flags = 0;
                    if ((getWindow().getAttributes().flags
                            & WindowManager.LayoutParams.FLAG_SECURE) != 0) {
                        flags |= ContentCaptureContext.FLAG_DISABLED_BY_FLAG_SECURE;
                    final Window window = getWindow();
                    if (window != null) {
                        cm.updateWindowAttributes(window.getAttributes());
                    }
                    cm.onActivityCreated(mToken, getComponentName(), flags);
                    cm.onActivityCreated(mToken, getComponentName());
                    break;
                case CONTENT_CAPTURE_RESUME:
                    cm.onActivityResumed();
@@ -3785,6 +3783,9 @@ public class Activity extends ContextThemeWrapper
            View decor = mDecor;
            if (decor != null && decor.getParent() != null) {
                getWindowManager().updateViewLayout(decor, params);
                if (mContentCaptureManager != null) {
                    mContentCaptureManager.updateWindowAttributes(params);
                }
            }
        }
    }
+28 −2
Original line number Diff line number Diff line
@@ -37,6 +37,7 @@ import android.os.ServiceManager;
import android.util.Log;
import android.view.View;
import android.view.ViewStructure;
import android.view.WindowManager;
import android.view.contentcapture.ContentCaptureSession.FlushReason;

import com.android.internal.annotations.GuardedBy;
@@ -343,10 +344,9 @@ public final class ContentCaptureManager {
    /** @hide */
    @UiThread
    public void onActivityCreated(@NonNull IBinder applicationToken,
            @NonNull ComponentName activityComponent, int flags) {
            @NonNull ComponentName activityComponent) {
        if (mOptions.lite) return;
        synchronized (mLock) {
            mFlags |= flags;
            getMainContentCaptureSession().start(applicationToken, activityComponent, mFlags);
        }
    }
@@ -498,6 +498,32 @@ public final class ContentCaptureManager {
        }
    }

    /**
     * Called by apps to update flag secure when window attributes change.
     *
     * @hide
     */
    public void updateWindowAttributes(@NonNull WindowManager.LayoutParams params) {
        if (sDebug) {
            Log.d(TAG, "updateWindowAttributes(): window flags=" + params.flags);
        }
        final boolean flagSecureEnabled =
                (params.flags & WindowManager.LayoutParams.FLAG_SECURE) != 0;

        MainContentCaptureSession mainSession;
        synchronized (mLock) {
            if (flagSecureEnabled) {
                mFlags |= ContentCaptureContext.FLAG_DISABLED_BY_FLAG_SECURE;
            } else {
                mFlags &= ~ContentCaptureContext.FLAG_DISABLED_BY_FLAG_SECURE;
            }
            mainSession = mMainSession;
        }
        if (mainSession != null) {
            mainSession.setDisabled(flagSecureEnabled);
        }
    }

    /**
     * Gets whether content capture is enabled for the given user.
     *
+1 −1
Original line number Diff line number Diff line
@@ -593,7 +593,7 @@ public final class MainContentCaptureSession extends ContentCaptureSession {
    }

    /**
     * Called by ContentCaptureManager.setContentCaptureEnabled
     * Sets the disabled state of content capture.
     *
     * @return whether disabled state was changed.
     */