1 /*
2  * Copyright (C) 2014 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 
17 package android.media.projection;
18 
19 import android.media.projection.IMediaProjectionCallback;
20 import android.os.IBinder;
21 
22 /** {@hide} */
23 interface IMediaProjection {
start(IMediaProjectionCallback callback)24     void start(IMediaProjectionCallback callback);
stop()25     void stop();
26 
canProjectAudio()27     boolean canProjectAudio();
canProjectVideo()28     boolean canProjectVideo();
canProjectSecureVideo()29     boolean canProjectSecureVideo();
30 
31     @JavaPassthrough(annotation = "@android.annotation.RequiresPermission(android.Manifest"
32             + ".permission.MANAGE_MEDIA_PROJECTION)")
applyVirtualDisplayFlags(int flags)33     int applyVirtualDisplayFlags(int flags);
34 
registerCallback(IMediaProjectionCallback callback)35     void registerCallback(IMediaProjectionCallback callback);
36 
unregisterCallback(IMediaProjectionCallback callback)37     void unregisterCallback(IMediaProjectionCallback callback);
38 
39     /**
40      * Returns the {@link android.os.IBinder} identifying the task to record, or {@code null} if
41      * there is none.
42      */
43     @JavaPassthrough(annotation = "@android.annotation.RequiresPermission(android.Manifest"
44             + ".permission.MANAGE_MEDIA_PROJECTION)")
getLaunchCookie()45     IBinder getLaunchCookie();
46 
47     /**
48      * Updates the {@link android.os.IBinder} identifying the task to record, or {@code null} if
49      * there is none.
50      */
51     @JavaPassthrough(annotation = "@android.annotation.RequiresPermission(android.Manifest"
52             + ".permission.MANAGE_MEDIA_PROJECTION)")
setLaunchCookie(in IBinder launchCookie)53     void setLaunchCookie(in IBinder launchCookie);
54 
55     /**
56      * Returns {@code true} if this token is still valid. A token is valid as long as the token
57      * hasn't timed out before it was used, and the token is only used once.
58      *
59      * <p>If the {@link IMediaProjection} is not valid, then either throws an exception if the
60      * target SDK is at least {@code U}, or returns {@code false} for target SDK below {@code U}.
61      *
62      * @throws IllegalStateException If the caller's target SDK is at least {@code U} and the
63      * projection is not valid.
64      */
65     @JavaPassthrough(annotation = "@android.annotation.RequiresPermission(android.Manifest"
66             + ".permission.MANAGE_MEDIA_PROJECTION)")
isValid()67     boolean isValid();
68 
69     /**
70      * Sets that {@link MediaProjection#createVirtualDisplay} has been invoked with this token (it
71      * should only be called once).
72      */
73     @JavaPassthrough(annotation = "@android.annotation.RequiresPermission(android.Manifest"
74             + ".permission.MANAGE_MEDIA_PROJECTION)")
notifyVirtualDisplayCreated(int displayId)75     void notifyVirtualDisplayCreated(int displayId);
76 }
77