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

Commit dbaaa753 authored by Android Build Coastguard Worker's avatar Android Build Coastguard Worker
Browse files

Snap for 9417701 from b9b84486 to tm-qpr2-release

Change-Id: If4d9e8104bcc0311d051d1b0757a7dcf53c9c72d
parents bdc3e04c b9b84486
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -15,6 +15,7 @@
 */
package android.service.quicksettings;

import android.app.PendingIntent;
import android.content.ComponentName;
import android.graphics.drawable.Icon;
import android.service.quicksettings.Tile;
@@ -29,10 +30,10 @@ interface IQSService {
            String contentDescription);
    void onShowDialog(in IBinder tile);
    void onStartActivity(in IBinder tile);
    void startActivity(in IBinder tile, in PendingIntent pendingIntent);
    boolean isLocked();
    boolean isSecure();
    void startUnlockAndRun(in IBinder tile);

    void onDialogHidden(in IBinder tile);
    void onStartSuccessful(in IBinder tile);
}
+41 −0
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@
package android.service.quicksettings;

import android.annotation.Nullable;
import android.app.PendingIntent;
import android.graphics.drawable.Icon;
import android.os.IBinder;
import android.os.Parcel;
@@ -66,6 +67,7 @@ public final class Tile implements Parcelable {
    private CharSequence mSubtitle;
    private CharSequence mContentDescription;
    private CharSequence mStateDescription;
    private PendingIntent mPendingIntent;
    // Default to inactive until clients of the new API can update.
    private int mState = STATE_INACTIVE;

@@ -223,6 +225,34 @@ public final class Tile implements Parcelable {
        }
    }

    /**
     * Gets the Activity {@link PendingIntent} to be launched when the tile is clicked.
     * @hide
     */
    @Nullable
    public PendingIntent getActivityLaunchForClick() {
        return mPendingIntent;
    }

    /**
     * Sets an Activity {@link PendingIntent} to be launched when the tile is clicked.
     *
     * The last value set here will be launched when the user clicks in the tile, instead of
     * forwarding the `onClick` message to the {@link TileService}. Set to {@code null} to handle
     * the `onClick` in the `TileService`
     * (This is the default behavior if this method is never called.)
     * @param pendingIntent a PendingIntent for an activity to be launched onclick, or {@code null}
     *                      to handle the clicks in the `TileService`.
     * @hide
     */
    public void setActivityLaunchForClick(@Nullable PendingIntent pendingIntent) {
        if (pendingIntent != null && !pendingIntent.isActivity()) {
            throw new IllegalArgumentException();
        } else {
            mPendingIntent = pendingIntent;
        }
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        if (mIcon != null) {
@@ -231,6 +261,12 @@ public final class Tile implements Parcelable {
        } else {
            dest.writeByte((byte) 0);
        }
        if (mPendingIntent != null) {
            dest.writeByte((byte) 1);
            mPendingIntent.writeToParcel(dest, flags);
        } else {
            dest.writeByte((byte) 0);
        }
        dest.writeInt(mState);
        TextUtils.writeToParcel(mLabel, dest, flags);
        TextUtils.writeToParcel(mSubtitle, dest, flags);
@@ -244,6 +280,11 @@ public final class Tile implements Parcelable {
        } else {
            mIcon = null;
        }
        if (source.readByte() != 0) {
            mPendingIntent = PendingIntent.CREATOR.createFromParcel(source);
        } else {
            mPendingIntent = null;
        }
        mState = source.readInt();
        mLabel = TextUtils.CHAR_SEQUENCE_CREATOR.createFromParcel(source);
        mSubtitle = TextUtils.CHAR_SEQUENCE_CREATOR.createFromParcel(source);
+15 −0
Original line number Diff line number Diff line
@@ -20,6 +20,7 @@ import android.annotation.SdkConstant.SdkConstantType;
import android.annotation.SystemApi;
import android.annotation.TestApi;
import android.app.Dialog;
import android.app.PendingIntent;
import android.app.Service;
import android.app.StatusBarManager;
import android.content.ComponentName;
@@ -335,6 +336,20 @@ public class TileService extends Service {
        }
    }

    /**
     * Starts an {@link android.app.Activity}.
     * Will collapse Quick Settings after launching.
     *
     * @param pendingIntent A PendingIntent for an Activity to be launched immediately.
     * @hide
     */
    public void startActivityAndCollapse(PendingIntent pendingIntent) {
        try {
            mService.startActivity(mTileToken, pendingIntent);
        } catch (RemoteException e) {
        }
    }

    /**
     * Gets the {@link Tile} for this service.
     * <p/>
+18 −23
Original line number Diff line number Diff line
@@ -204,10 +204,6 @@ public class StageCoordinator implements SplitLayout.SplitLayoutHandler,
    private boolean mIsDropEntering;
    private boolean mIsExiting;

    /** The target stage to dismiss to when unlock after folded. */
    @StageType
    private int mTopStageAfterFoldDismiss = STAGE_TYPE_UNDEFINED;

    private DefaultMixedHandler mMixedHandler;
    private final Toast mSplitUnsupportedToast;

@@ -976,20 +972,6 @@ public class StageCoordinator implements SplitLayout.SplitLayoutHandler,
            return;
        }

        if (!mKeyguardShowing && mTopStageAfterFoldDismiss != STAGE_TYPE_UNDEFINED) {
            if (ENABLE_SHELL_TRANSITIONS) {
                final WindowContainerTransaction wct = new WindowContainerTransaction();
                prepareExitSplitScreen(mTopStageAfterFoldDismiss, wct);
                mSplitTransitions.startDismissTransition(wct, this,
                        mTopStageAfterFoldDismiss, EXIT_REASON_DEVICE_FOLDED);
            } else {
                exitSplitScreen(
                        mTopStageAfterFoldDismiss == STAGE_TYPE_MAIN ? mMainStage : mSideStage,
                        EXIT_REASON_DEVICE_FOLDED);
            }
            return;
        }

        setDividerVisibility(!mKeyguardShowing, null);
    }

@@ -1828,14 +1810,28 @@ public class StageCoordinator implements SplitLayout.SplitLayoutHandler,
        sendOnBoundsChanged();
    }

    private void onFoldedStateChanged(boolean folded) {
        mTopStageAfterFoldDismiss = STAGE_TYPE_UNDEFINED;
    @VisibleForTesting
    void onFoldedStateChanged(boolean folded) {
        int topStageAfterFoldDismiss = STAGE_TYPE_UNDEFINED;
        if (!folded) return;

        if (!mMainStage.isActive()) return;

        if (mMainStage.isFocused()) {
            mTopStageAfterFoldDismiss = STAGE_TYPE_MAIN;
            topStageAfterFoldDismiss = STAGE_TYPE_MAIN;
        } else if (mSideStage.isFocused()) {
            mTopStageAfterFoldDismiss = STAGE_TYPE_SIDE;
            topStageAfterFoldDismiss = STAGE_TYPE_SIDE;
        }

        if (ENABLE_SHELL_TRANSITIONS) {
            final WindowContainerTransaction wct = new WindowContainerTransaction();
            prepareExitSplitScreen(topStageAfterFoldDismiss, wct);
            mSplitTransitions.startDismissTransition(wct, this,
                    topStageAfterFoldDismiss, EXIT_REASON_DEVICE_FOLDED);
        } else {
            exitSplitScreen(
                    topStageAfterFoldDismiss == STAGE_TYPE_MAIN ? mMainStage : mSideStage,
                    EXIT_REASON_DEVICE_FOLDED);
        }
    }

@@ -2118,7 +2114,6 @@ public class StageCoordinator implements SplitLayout.SplitLayoutHandler,
            // Update divider state after animation so that it is still around and positioned
            // properly for the animation itself.
            mSplitLayout.release();
            mTopStageAfterFoldDismiss = STAGE_TYPE_UNDEFINED;
        }
    }

+15 −3
Original line number Diff line number Diff line
@@ -155,7 +155,7 @@ public class StageCoordinatorTests extends ShellTestCase {
        final ActivityManager.RunningTaskInfo task = new TestRunningTaskInfoBuilder().build();

        // Verify move to undefined stage while split screen not activated moves task to side stage.
        when(mMainStage.isActive()).thenReturn(false);
        when(mStageCoordinator.isSplitScreenVisible()).thenReturn(false);
        mStageCoordinator.setSideStagePosition(SPLIT_POSITION_TOP_OR_LEFT, null);
        mStageCoordinator.moveToStage(task, STAGE_TYPE_UNDEFINED, SPLIT_POSITION_BOTTOM_OR_RIGHT,
                new WindowContainerTransaction());
@@ -163,7 +163,7 @@ public class StageCoordinatorTests extends ShellTestCase {
        assertEquals(SPLIT_POSITION_BOTTOM_OR_RIGHT, mStageCoordinator.getSideStagePosition());

        // Verify move to undefined stage after split screen activated moves task based on position.
        when(mMainStage.isActive()).thenReturn(true);
        when(mStageCoordinator.isSplitScreenVisible()).thenReturn(true);
        assertEquals(SPLIT_POSITION_TOP_OR_LEFT, mStageCoordinator.getMainStagePosition());
        mStageCoordinator.moveToStage(task, STAGE_TYPE_UNDEFINED, SPLIT_POSITION_TOP_OR_LEFT,
                new WindowContainerTransaction());
@@ -262,7 +262,7 @@ public class StageCoordinatorTests extends ShellTestCase {

    @Test
    public void testResolveStartStage_afterSplitActivated_retrievesStagePosition() {
        when(mMainStage.isActive()).thenReturn(true);
        when(mStageCoordinator.isSplitScreenVisible()).thenReturn(true);
        mStageCoordinator.setSideStagePosition(SPLIT_POSITION_TOP_OR_LEFT, null /* wct */);

        mStageCoordinator.resolveStartStage(STAGE_TYPE_UNDEFINED, SPLIT_POSITION_TOP_OR_LEFT,
@@ -320,4 +320,16 @@ public class StageCoordinatorTests extends ShellTestCase {
        assertTrue(options.getBoolean(
                KEY_PENDING_INTENT_BACKGROUND_ACTIVITY_ALLOWED_BY_PERMISSION));
    }

    @Test
    public void testExitSplitScreenAfterFolded() {
        when(mMainStage.isActive()).thenReturn(true);
        when(mMainStage.isFocused()).thenReturn(true);
        when(mMainStage.getTopVisibleChildTaskId()).thenReturn(INVALID_TASK_ID);

        mStageCoordinator.onFoldedStateChanged(true);

        verify(mStageCoordinator).onSplitScreenExit();
        verify(mMainStage).deactivate(any(WindowContainerTransaction.class), eq(false));
    }
}
Loading