1 /*
2  * Copyright (C) 2022 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 package com.android.launcher3.tapl;
17 
18 /** {@link Launchable} that can serve as a source for dragging and dropping to splitscreen. */
19 interface SplitscreenDragSource {
20 
21     /**
22      * Drags this app icon to the left (landscape) or bottom (portrait) of the screen, launching it
23      * in splitscreen.
24      *
25      * @param expectedNewPackageName package name of the app being dragged
26      * @param expectedExistingPackageName package name of the already-launched app
27      */
dragToSplitscreen( String expectedNewPackageName, String expectedExistingPackageName)28     default void dragToSplitscreen(
29             String expectedNewPackageName, String expectedExistingPackageName) {
30         Launchable launchable = getLaunchable();
31         LauncherInstrumentation launcher = launchable.mLauncher;
32         try (LauncherInstrumentation.Closable e = launcher.eventsCheck()) {
33             LaunchedAppState.dragToSplitscreen(
34                     launcher, launchable, expectedNewPackageName, expectedExistingPackageName);
35         }
36     }
37 
38     /** This method requires public access, however should not be called in tests. */
getLaunchable()39     Launchable getLaunchable();
40 }
41