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

Commit 74e1eb22 authored by Issei Suzuki's avatar Issei Suzuki
Browse files

Add inheritShowWhenLocked System API to activity.

Let an activity show on top of the lock screen if the activity behind
this can be shown on top of the screen. This is pre-requisite for
showing permission dialog on top of the lock screen only when it makes
sence.

Bug: 109754623
Test: atest server.am.KeyguardTests
Change-Id: Ideaa2b77519649a70c682bc95277e451e149adad
parent caa6519f
Loading
Loading
Loading
Loading
+2 −0
Original line number Original line Diff line number Diff line
@@ -197,6 +197,7 @@ package android {
  }
  }


  public static final class R.attr {
  public static final class R.attr {
    field public static final int inheritShowWhenLocked = 16844194; // 0x10105a2
    field public static final int isVrOnly = 16844152; // 0x1010578
    field public static final int isVrOnly = 16844152; // 0x1010578
    field public static final int requiredSystemPropertyName = 16844133; // 0x1010565
    field public static final int requiredSystemPropertyName = 16844133; // 0x1010565
    field public static final int requiredSystemPropertyValue = 16844134; // 0x1010566
    field public static final int requiredSystemPropertyValue = 16844134; // 0x1010566
@@ -256,6 +257,7 @@ package android.app {
    method public boolean convertToTranslucent(android.app.Activity.TranslucentConversionListener, android.app.ActivityOptions);
    method public boolean convertToTranslucent(android.app.Activity.TranslucentConversionListener, android.app.ActivityOptions);
    method public deprecated boolean isBackgroundVisibleBehind();
    method public deprecated boolean isBackgroundVisibleBehind();
    method public deprecated void onBackgroundVisibleBehindChanged(boolean);
    method public deprecated void onBackgroundVisibleBehindChanged(boolean);
    method public void setInheritShowWhenLocked(boolean);
  }
  }


  public static abstract interface Activity.TranslucentConversionListener {
  public static abstract interface Activity.TranslucentConversionListener {
+1 −0
Original line number Original line Diff line number Diff line
@@ -28,6 +28,7 @@ package android.app {


  public class Activity extends android.view.ContextThemeWrapper implements android.content.ComponentCallbacks2 android.view.KeyEvent.Callback android.view.LayoutInflater.Factory2 android.view.View.OnCreateContextMenuListener android.view.Window.Callback {
  public class Activity extends android.view.ContextThemeWrapper implements android.content.ComponentCallbacks2 android.view.KeyEvent.Callback android.view.LayoutInflater.Factory2 android.view.View.OnCreateContextMenuListener android.view.Window.Callback {
    method public void onMovedToDisplay(int, android.content.res.Configuration);
    method public void onMovedToDisplay(int, android.content.res.Configuration);
    method public void setInheritShowWhenLocked(boolean);
  }
  }


  public class ActivityManager {
  public class ActivityManager {
+27 −0
Original line number Original line Diff line number Diff line
@@ -8281,6 +8281,33 @@ public class Activity extends ContextThemeWrapper
        }
        }
    }
    }


    /**
     * Specifies whether this {@link Activity} should be shown on top of the lock screen whenever
     * the lockscreen is up and this activity has another activity behind it with the showWhenLock
     * attribute set. That is, this activity is only visible on the lock screen if there is another
     * activity with the showWhenLock attribute visible at the same time on the lock screen. A use
     * case for this is permission dialogs, that should only be visible on the lock screen if their
     * requesting activity is also visible. This value can be set as a manifest attribute using
     * android.R.attr#inheritShowWhenLocked.
     *
     * @param inheritShowWhenLocked {@code true} to show the {@link Activity} on top of the lock
     *                              screen when this activity has another activity behind it with
     *                              the showWhenLock attribute set; {@code false} otherwise.
     * @see #setShowWhenLocked(boolean)
     * See android.R.attr#inheritShowWhenLocked
     * @hide
     */
    @SystemApi
    @TestApi
    public void setInheritShowWhenLocked(boolean inheritShowWhenLocked) {
        try {
            ActivityTaskManager.getService().setInheritShowWhenLocked(
                    mToken, inheritShowWhenLocked);
        } catch (RemoteException e) {
            Log.e(TAG, "Failed to call setInheritShowWhenLocked", e);
        }
    }

    /**
    /**
     * Specifies whether the screen should be turned on when the {@link Activity} is resumed.
     * Specifies whether the screen should be turned on when the {@link Activity} is resumed.
     * Normally an activity will be transitioned to the stopped state if it is started while the
     * Normally an activity will be transitioned to the stopped state if it is started while the
+1 −0
Original line number Original line Diff line number Diff line
@@ -419,6 +419,7 @@ interface IActivityTaskManager {
    void updateLockTaskFeatures(int userId, int flags);
    void updateLockTaskFeatures(int userId, int flags);


    void setShowWhenLocked(in IBinder token, boolean showWhenLocked);
    void setShowWhenLocked(in IBinder token, boolean showWhenLocked);
    void setInheritShowWhenLocked(in IBinder token, boolean setInheritShownWhenLocked);
    void setTurnScreenOn(in IBinder token, boolean turnScreenOn);
    void setTurnScreenOn(in IBinder token, boolean turnScreenOn);


    /**
    /**
+21 −1
Original line number Original line Diff line number Diff line
@@ -505,6 +505,22 @@ public class ActivityInfo extends ComponentInfo implements Parcelable {
     */
     */
    public int flags;
    public int flags;


    /**
     * Bit in {@link #privateFlags} indicating if the activity should be shown when locked in case
     * an activity behind this can also be shown when locked.
     * See android.R.attr#inheritShowWhenLocked
     * @hide
     */
    public static final int FLAG_INHERIT_SHOW_WHEN_LOCKED = 0x1;

    /**
     * Options that have been set in the activity declaration in the manifest.
     * These include:
     * {@link #FLAG_INHERIT_SHOW_WHEN_LOCKED}.
     * @hide
     */
    public int privateFlags;

    /** @hide */
    /** @hide */
    @IntDef(prefix = { "SCREEN_ORIENTATION_" }, value = {
    @IntDef(prefix = { "SCREEN_ORIENTATION_" }, value = {
            SCREEN_ORIENTATION_UNSET,
            SCREEN_ORIENTATION_UNSET,
@@ -975,6 +991,7 @@ public class ActivityInfo extends ComponentInfo implements Parcelable {
        taskAffinity = orig.taskAffinity;
        taskAffinity = orig.taskAffinity;
        targetActivity = orig.targetActivity;
        targetActivity = orig.targetActivity;
        flags = orig.flags;
        flags = orig.flags;
        privateFlags = orig.privateFlags;
        screenOrientation = orig.screenOrientation;
        screenOrientation = orig.screenOrientation;
        configChanges = orig.configChanges;
        configChanges = orig.configChanges;
        softInputMode = orig.softInputMode;
        softInputMode = orig.softInputMode;
@@ -1122,9 +1139,10 @@ public class ActivityInfo extends ComponentInfo implements Parcelable {
                    + " targetActivity=" + targetActivity
                    + " targetActivity=" + targetActivity
                    + " persistableMode=" + persistableModeToString());
                    + " persistableMode=" + persistableModeToString());
        }
        }
        if (launchMode != 0 || flags != 0 || theme != 0) {
        if (launchMode != 0 || flags != 0 || privateFlags != 0 || theme != 0) {
            pw.println(prefix + "launchMode=" + launchMode
            pw.println(prefix + "launchMode=" + launchMode
                    + " flags=0x" + Integer.toHexString(flags)
                    + " flags=0x" + Integer.toHexString(flags)
                    + " privateFlags=0x" + Integer.toHexString(privateFlags)
                    + " theme=0x" + Integer.toHexString(theme));
                    + " theme=0x" + Integer.toHexString(theme));
        }
        }
        if (screenOrientation != SCREEN_ORIENTATION_UNSPECIFIED
        if (screenOrientation != SCREEN_ORIENTATION_UNSPECIFIED
@@ -1178,6 +1196,7 @@ public class ActivityInfo extends ComponentInfo implements Parcelable {
        dest.writeString(targetActivity);
        dest.writeString(targetActivity);
        dest.writeString(launchToken);
        dest.writeString(launchToken);
        dest.writeInt(flags);
        dest.writeInt(flags);
        dest.writeInt(privateFlags);
        dest.writeInt(screenOrientation);
        dest.writeInt(screenOrientation);
        dest.writeInt(configChanges);
        dest.writeInt(configChanges);
        dest.writeInt(softInputMode);
        dest.writeInt(softInputMode);
@@ -1307,6 +1326,7 @@ public class ActivityInfo extends ComponentInfo implements Parcelable {
        targetActivity = source.readString();
        targetActivity = source.readString();
        launchToken = source.readString();
        launchToken = source.readString();
        flags = source.readInt();
        flags = source.readInt();
        privateFlags = source.readInt();
        screenOrientation = source.readInt();
        screenOrientation = source.readInt();
        configChanges = source.readInt();
        configChanges = source.readInt();
        softInputMode = source.readInt();
        softInputMode = source.readInt();
Loading