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