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

Commit 9e2c7ecf authored by Jiaquan He's avatar Jiaquan He
Browse files

Add support for android.R.attr#onTopLauncher

This allows a launcher activity to always stay on top of all other
activities.

Bug: 28425537
Change-Id: Iad39a076b1e8c6a8304c3b218883a172c913a602
parent ab9c317d
Loading
Loading
Loading
Loading
+8 −0
Original line number Original line Diff line number Diff line
@@ -332,6 +332,14 @@ public class ActivityInfo extends ComponentInfo
     */
     */
    public static final int FLAG_ALWAYS_FOCUSABLE = 0x40000;
    public static final int FLAG_ALWAYS_FOCUSABLE = 0x40000;


    /**
     * Bit in {@link #flags} indicating if the activity is a launcher activity which should always
     * show up on the top of others.
     * See android.R.attr#onTopLauncher.
     * @hide
     */
    public static final int FLAG_ON_TOP_LAUNCHER = 0x80000;

    /**
    /**
     * @hide Bit in {@link #flags}: If set, this component will only be seen
     * @hide Bit in {@link #flags}: If set, this component will only be seen
     * by the system user.  Only works with broadcast receivers.  Set from the
     * by the system user.  Only works with broadcast receivers.  Set from the
+5 −0
Original line number Original line Diff line number Diff line
@@ -79,6 +79,7 @@ import libcore.io.IoUtils;


import static android.content.pm.ActivityInfo.FLAG_ALWAYS_FOCUSABLE;
import static android.content.pm.ActivityInfo.FLAG_ALWAYS_FOCUSABLE;
import static android.content.pm.ActivityInfo.FLAG_IMMERSIVE;
import static android.content.pm.ActivityInfo.FLAG_IMMERSIVE;
import static android.content.pm.ActivityInfo.FLAG_ON_TOP_LAUNCHER;
import static android.content.pm.ActivityInfo.RESIZE_MODE_FORCE_RESIZEABLE;
import static android.content.pm.ActivityInfo.RESIZE_MODE_FORCE_RESIZEABLE;
import static android.content.pm.ActivityInfo.RESIZE_MODE_RESIZEABLE;
import static android.content.pm.ActivityInfo.RESIZE_MODE_RESIZEABLE;
import static android.content.pm.ActivityInfo.RESIZE_MODE_RESIZEABLE_AND_PIPABLE;
import static android.content.pm.ActivityInfo.RESIZE_MODE_RESIZEABLE_AND_PIPABLE;
@@ -3567,6 +3568,10 @@ public class PackageParser {
                a.info.flags |= FLAG_ALWAYS_FOCUSABLE;
                a.info.flags |= FLAG_ALWAYS_FOCUSABLE;
            }
            }


            if (sa.getBoolean(R.styleable.AndroidManifestActivity_onTopLauncher, false)) {
                a.info.flags |= FLAG_ON_TOP_LAUNCHER;
            }

            a.info.lockTaskLaunchMode =
            a.info.lockTaskLaunchMode =
                    sa.getInt(R.styleable.AndroidManifestActivity_lockTaskMode, 0);
                    sa.getInt(R.styleable.AndroidManifestActivity_lockTaskMode, 0);


+3 −0
Original line number Original line Diff line number Diff line
@@ -1898,6 +1898,9 @@
             in a task/stack that isn't focusable. This flag allows them to be focusable.-->
             in a task/stack that isn't focusable. This flag allows them to be focusable.-->
        <attr name="alwaysFocusable" format="boolean" />
        <attr name="alwaysFocusable" format="boolean" />
        <attr name="enableVrMode" />
        <attr name="enableVrMode" />
        <!-- @hide This activity is a launcher which should always show up on the top of others.
             This attribute is ignored if the activity isn't a launcher. -->
        <attr name="onTopLauncher" format="boolean" />
    </declare-styleable>
    </declare-styleable>


    <!-- The <code>activity-alias</code> tag declares a new
    <!-- The <code>activity-alias</code> tag declares a new
+5 −0
Original line number Original line Diff line number Diff line
@@ -19,6 +19,7 @@ package com.android.server.am;
import static android.app.ActivityManager.StackId;
import static android.app.ActivityManager.StackId;
import static android.app.ActivityManager.StackId.FREEFORM_WORKSPACE_STACK_ID;
import static android.app.ActivityManager.StackId.FREEFORM_WORKSPACE_STACK_ID;
import static android.app.ActivityManager.StackId.PINNED_STACK_ID;
import static android.app.ActivityManager.StackId.PINNED_STACK_ID;
import static android.content.pm.ActivityInfo.FLAG_ON_TOP_LAUNCHER;
import static android.content.pm.ActivityInfo.RESIZE_MODE_CROP_WINDOWS;
import static android.content.pm.ActivityInfo.RESIZE_MODE_CROP_WINDOWS;
import static android.content.pm.ActivityInfo.FLAG_ALWAYS_FOCUSABLE;
import static android.content.pm.ActivityInfo.FLAG_ALWAYS_FOCUSABLE;
import static android.content.pm.ActivityInfo.RESIZE_MODE_RESIZEABLE;
import static android.content.pm.ActivityInfo.RESIZE_MODE_RESIZEABLE;
@@ -858,6 +859,10 @@ final class ActivityRecord {
        return (info.flags & FLAG_ALWAYS_FOCUSABLE) != 0;
        return (info.flags & FLAG_ALWAYS_FOCUSABLE) != 0;
    }
    }


    boolean isOnTopLauncher() {
        return isHomeActivity() && (info.flags & FLAG_ON_TOP_LAUNCHER) != 0;
    }

    void makeFinishingLocked() {
    void makeFinishingLocked() {
        if (!finishing) {
        if (!finishing) {
            if (task != null && task.stack != null
            if (task != null && task.stack != null