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

Commit 0fb1cb56 authored by Craig Mautner's avatar Craig Mautner
Browse files

Add lockTaskOnLaunch attribute.

The new AndroidManifest activity attribute, lockTaskOnLaunch attribute
is a boolean that puts the system in lockTask mode when true and if
the activity specified is the root of a privileged task.

This bug also fixes lockTask mode for root activities that finish
themselves. Previously finish was not allowed even if there were
activities left in the task that were still valid.

A NullPointerException for lock task toasts has also been fixed.

Fixes bug 19995702.

Change-Id: Iba6976b1a0cc5a22eb526db66d2e9af66445541f
parent 63473869
Loading
Loading
Loading
Loading
+13 −3
Original line number Diff line number Diff line
@@ -648,6 +648,12 @@ public class ActivityInfo extends ComponentInfo
     */
    public boolean resizeable;

    /**
     * Value indicating if the activity is to be locked at startup.
     * @hide
     */
    public boolean lockTaskOnLaunch;

    public ActivityInfo() {
    }

@@ -665,6 +671,8 @@ public class ActivityInfo extends ComponentInfo
        uiOptions = orig.uiOptions;
        parentActivityName = orig.parentActivityName;
        maxRecents = orig.maxRecents;
        resizeable = orig.resizeable;
        lockTaskOnLaunch = orig.lockTaskOnLaunch;
    }

    /**
@@ -709,7 +717,7 @@ public class ActivityInfo extends ComponentInfo
        if (uiOptions != 0) {
            pw.println(prefix + " uiOptions=0x" + Integer.toHexString(uiOptions));
        }
        pw.println(prefix + "resizeable=" + resizeable);
        pw.println(prefix + "resizeable=" + resizeable + " lockTaskOnLaunch=" + lockTaskOnLaunch);
        super.dumpBack(pw, prefix);
    }
    
@@ -739,6 +747,7 @@ public class ActivityInfo extends ComponentInfo
        dest.writeInt(persistableMode);
        dest.writeInt(maxRecents);
        dest.writeInt(resizeable ? 1 : 0);
        dest.writeInt(lockTaskOnLaunch ? 1 : 0);
    }

    public static final Parcelable.Creator<ActivityInfo> CREATOR
@@ -767,5 +776,6 @@ public class ActivityInfo extends ComponentInfo
        persistableMode = source.readInt();
        maxRecents = source.readInt();
        resizeable = (source.readInt() == 1);
        lockTaskOnLaunch = (source.readInt() == 1);
    }
}
+3 −0
Original line number Diff line number Diff line
@@ -3113,6 +3113,9 @@ public class PackageParser {
                        R.styleable.AndroidManifestActivity_screenOrientation,
                        ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED);
            }

            a.info.lockTaskOnLaunch =
                    sa.getBoolean(R.styleable.AndroidManifestActivity_lockTaskOnLaunch, false);
        } else {
            a.info.launchMode = ActivityInfo.LAUNCH_MULTIPLE;
            a.info.configChanges = 0;
+13 −5
Original line number Diff line number Diff line
@@ -1038,6 +1038,13 @@
         activity. -->
    <attr name="resizeableActivity" format="boolean" />

    <!-- Tasks rooted at this activity will start up in lock-task mode. That means that they
         cannot be navigated away from until they finish or explicitly release lock-task mode.
         This only works for system privileged activities. An exception will be thrown for
         non-privileged activities that use this attribute.
         @hide -->
    <attr name="lockTaskOnLaunch" format="boolean" />

    <!-- When set installer will extract native libraries. If set to false
         libraries in the apk must be stored and page-aligned.  -->
    <attr name="extractNativeLibs" format="boolean"/>
@@ -1749,6 +1756,7 @@
        <attr name="relinquishTaskIdentity" />
        <attr name="resumeWhilePausing" />
        <attr name="resizeableActivity" />
        <attr name="lockTaskOnLaunch" />
    </declare-styleable>
    
    <!-- The <code>activity-alias</code> tag declares a new
+1 −0
Original line number Diff line number Diff line
@@ -2657,4 +2657,5 @@
  <!--IntentFilter auto verification -->
  <public type="attr" name="autoVerify" />

  <public type="attr" name="lockTaskOnLaunch" />
</resources>
+5 −5
Original line number Diff line number Diff line
@@ -3911,9 +3911,9 @@ public final class ActivityManagerService extends ActivityManagerNative
            }
            // Do not allow task to finish in Lock Task mode.
            if (tr == mStackSupervisor.mLockTaskModeTask) {
                if (rootR == r) {
                if (rootR == r && tr.getTopActivity() == r) {
                    Slog.i(TAG, "Not finishing task in lock task mode");
                    mStackSupervisor.showLockTaskToast();
                    mStackSupervisor.showLockTaskToastLocked();
                    return false;
                }
            }
@@ -4074,7 +4074,7 @@ public final class ActivityManagerService extends ActivityManagerNative
                // Do not allow task to finish in Lock Task mode.
                if (r.task == mStackSupervisor.mLockTaskModeTask) {
                    if (rootR == r) {
                        mStackSupervisor.showLockTaskToast();
                        mStackSupervisor.showLockTaskToastLocked();
                        return false;
                    }
                }
@@ -8238,7 +8238,7 @@ public final class ActivityManagerService extends ActivityManagerNative
                return;
            }
            if (mStackSupervisor.isLockTaskModeViolation(task)) {
                mStackSupervisor.showLockTaskToast();
                mStackSupervisor.showLockTaskToastLocked();
                Slog.e(TAG, "moveTaskToFront: Attempt to violate Lock Task Mode");
                return;
            }
@@ -8272,7 +8272,7 @@ public final class ActivityManagerService extends ActivityManagerNative
                if (taskId >= 0) {
                    if ((mStackSupervisor.mLockTaskModeTask != null)
                            && (mStackSupervisor.mLockTaskModeTask.taskId == taskId)) {
                        mStackSupervisor.showLockTaskToast();
                        mStackSupervisor.showLockTaskToastLocked();
                        return false;
                    }
                    return ActivityRecord.getStackLocked(token).moveTaskToBackLocked(taskId);
Loading