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.media.projection.StopReason; 21 import android.os.IBinder; 22 import android.app.ActivityOptions.LaunchCookie; 23 24 /** {@hide} */ 25 interface IMediaProjection { start(IMediaProjectionCallback callback)26 void start(IMediaProjectionCallback callback); stop(StopReason stopReason)27 void stop(StopReason stopReason); 28 canProjectAudio()29 boolean canProjectAudio(); canProjectVideo()30 boolean canProjectVideo(); canProjectSecureVideo()31 boolean canProjectSecureVideo(); 32 33 @EnforcePermission("MANAGE_MEDIA_PROJECTION") 34 @JavaPassthrough(annotation = "@android.annotation.RequiresPermission(android.Manifest" 35 + ".permission.MANAGE_MEDIA_PROJECTION)") applyVirtualDisplayFlags(int flags)36 int applyVirtualDisplayFlags(int flags); 37 registerCallback(IMediaProjectionCallback callback)38 void registerCallback(IMediaProjectionCallback callback); 39 unregisterCallback(IMediaProjectionCallback callback)40 void unregisterCallback(IMediaProjectionCallback callback); 41 42 /** 43 * Returns the {@link LaunchCookie} identifying the task to record. Will always be set 44 * regardless of starting a new task or recent task 45 */ 46 @EnforcePermission("MANAGE_MEDIA_PROJECTION") 47 @JavaPassthrough(annotation = "@android.annotation.RequiresPermission(android.Manifest" 48 + ".permission.MANAGE_MEDIA_PROJECTION)") getLaunchCookie()49 LaunchCookie getLaunchCookie(); 50 51 /** 52 * Returns the taskId identifying the task to record. Will only be set in the case of 53 * launching a recent task, otherwise set to -1. 54 */ 55 @EnforcePermission("MANAGE_MEDIA_PROJECTION") 56 @JavaPassthrough(annotation = "@android.annotation.RequiresPermission(android.Manifest" 57 + ".permission.MANAGE_MEDIA_PROJECTION)") getTaskId()58 int getTaskId(); 59 60 61 /** 62 * Returns the displayId identifying the display to record. This only applies to full screen 63 * recording. 64 */ getDisplayId()65 int getDisplayId(); 66 67 /** 68 * Updates the {@link LaunchCookie} identifying the task to record. 69 */ 70 @EnforcePermission("MANAGE_MEDIA_PROJECTION") 71 @JavaPassthrough(annotation = "@android.annotation.RequiresPermission(android.Manifest" 72 + ".permission.MANAGE_MEDIA_PROJECTION)") setLaunchCookie(in LaunchCookie launchCookie)73 void setLaunchCookie(in LaunchCookie launchCookie); 74 75 /** 76 * Updates the taskId identifying the task to record. 77 */ 78 @EnforcePermission("MANAGE_MEDIA_PROJECTION") 79 @JavaPassthrough(annotation = "@android.annotation.RequiresPermission(android.Manifest" 80 + ".permission.MANAGE_MEDIA_PROJECTION)") setTaskId(in int taskId)81 void setTaskId(in int taskId); 82 83 84 /** 85 * Returns {@code true} if this token is still valid. A token is valid as long as the token 86 * hasn't timed out before it was used, and the token is only used once. 87 * 88 * <p>If the {@link IMediaProjection} is not valid, then either throws an exception if the 89 * target SDK is at least {@code U}, or returns {@code false} for target SDK below {@code U}. 90 * 91 * @throws IllegalStateException If the caller's target SDK is at least {@code U} and the 92 * projection is not valid. 93 */ 94 @EnforcePermission("MANAGE_MEDIA_PROJECTION") 95 @JavaPassthrough(annotation = "@android.annotation.RequiresPermission(android.Manifest" 96 + ".permission.MANAGE_MEDIA_PROJECTION)") isValid()97 boolean isValid(); 98 99 /** 100 * Sets that {@link MediaProjection#createVirtualDisplay} has been invoked with this token (it 101 * should only be called once). 102 */ 103 @EnforcePermission("MANAGE_MEDIA_PROJECTION") 104 @JavaPassthrough(annotation = "@android.annotation.RequiresPermission(android.Manifest" 105 + ".permission.MANAGE_MEDIA_PROJECTION)") notifyVirtualDisplayCreated(int displayId)106 void notifyVirtualDisplayCreated(int displayId); 107 } 108