| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
package android.window; |
| 18 |
|
| 19 |
import android.annotation.CallSuper; |
| 20 |
import android.annotation.NonNull; |
| 21 |
import android.annotation.RequiresPermission; |
| 22 |
import android.annotation.TestApi; |
| 23 |
import android.os.RemoteException; |
| 24 |
import android.view.SurfaceControl; |
| 25 |
|
| 26 |
import java.util.List; |
| 27 |
import java.util.concurrent.Executor; |
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
@TestApi |
| 34 |
public class DisplayAreaOrganizer extends WindowOrganizer { |
| 35 |
|
| 36 |
|
| 37 |
|
| 38 |
|
| 39 |
|
| 40 |
|
| 41 |
|
| 42 |
|
| 43 |
public static final String KEY_ROOT_DISPLAY_AREA_ID = "root_display_area_id"; |
| 44 |
|
| 45 |
|
| 46 |
|
| 47 |
|
| 48 |
public static final int FEATURE_UNDEFINED = -1; |
| 49 |
|
| 50 |
|
| 51 |
|
| 52 |
|
| 53 |
public static final int FEATURE_SYSTEM_FIRST = 0; |
| 54 |
|
| 55 |
|
| 56 |
|
| 57 |
|
| 58 |
public static final int FEATURE_ROOT = FEATURE_SYSTEM_FIRST; |
| 59 |
|
| 60 |
|
| 61 |
|
| 62 |
|
| 63 |
public static final int FEATURE_DEFAULT_TASK_CONTAINER = FEATURE_SYSTEM_FIRST + 1; |
| 64 |
|
| 65 |
|
| 66 |
|
| 67 |
|
| 68 |
public static final int FEATURE_WINDOW_TOKENS = FEATURE_SYSTEM_FIRST + 2; |
| 69 |
|
| 70 |
|
| 71 |
|
| 72 |
|
| 73 |
public static final int FEATURE_ONE_HANDED = FEATURE_SYSTEM_FIRST + 3; |
| 74 |
|
| 75 |
|
| 76 |
|
| 77 |
|
| 78 |
|
| 79 |
|
| 80 |
public static final int FEATURE_WINDOWED_MAGNIFICATION = FEATURE_SYSTEM_FIRST + 4; |
| 81 |
|
| 82 |
|
| 83 |
|
| 84 |
|
| 85 |
|
| 86 |
|
| 87 |
|
| 88 |
public static final int FEATURE_FULLSCREEN_MAGNIFICATION = FEATURE_SYSTEM_FIRST + 5; |
| 89 |
|
| 90 |
|
| 91 |
|
| 92 |
|
| 93 |
|
| 94 |
public static final int FEATURE_HIDE_DISPLAY_CUTOUT = FEATURE_SYSTEM_FIRST + 6; |
| 95 |
|
| 96 |
|
| 97 |
|
| 98 |
|
| 99 |
|
| 100 |
|
| 101 |
public static final int FEATURE_IME_PLACEHOLDER = FEATURE_SYSTEM_FIRST + 7; |
| 102 |
|
| 103 |
|
| 104 |
|
| 105 |
|
| 106 |
|
| 107 |
|
| 108 |
|
| 109 |
|
| 110 |
|
| 111 |
|
| 112 |
public static final int FEATURE_IME = FEATURE_SYSTEM_FIRST + 8; |
| 113 |
|
| 114 |
|
| 115 |
|
| 116 |
|
| 117 |
public static final int FEATURE_SYSTEM_LAST = 10_000; |
| 118 |
|
| 119 |
|
| 120 |
|
| 121 |
|
| 122 |
public static final int FEATURE_VENDOR_FIRST = FEATURE_SYSTEM_LAST + 1; |
| 123 |
|
| 124 |
|
| 125 |
|
| 126 |
|
| 127 |
|
| 128 |
public static final int FEATURE_VENDOR_LAST = FEATURE_VENDOR_FIRST + 10_000; |
| 129 |
|
| 130 |
|
| 131 |
|
| 132 |
|
| 133 |
|
| 134 |
|
| 135 |
public static final int FEATURE_RUNTIME_TASK_CONTAINER_FIRST = FEATURE_VENDOR_LAST + 1; |
| 136 |
|
| 137 |
|
| 138 |
|
| 139 |
private final Executor mExecutor; |
| 140 |
|
| 141 |
|
| 142 |
public DisplayAreaOrganizer(@NonNull Executor executor) { |
| 143 |
mExecutor = executor; |
| 144 |
} |
| 145 |
|
| 146 |
|
| 147 |
|
| 148 |
|
| 149 |
|
| 150 |
@NonNull |
| 151 |
public Executor getExecutor() { |
| 152 |
return mExecutor; |
| 153 |
} |
| 154 |
|
| 155 |
|
| 156 |
|
| 157 |
|
| 158 |
|
| 159 |
|
| 160 |
|
| 161 |
|
| 162 |
@RequiresPermission(android.Manifest.permission.MANAGE_ACTIVITY_TASKS) |
| 163 |
@CallSuper |
| 164 |
@NonNull |
| 165 |
public List<DisplayAreaAppearedInfo> registerOrganizer(int displayAreaFeature) { |
| 166 |
try { |
| 167 |
return getController().registerOrganizer(mInterface, displayAreaFeature).getList(); |
| 168 |
} catch (RemoteException e) { |
| 169 |
throw e.rethrowFromSystemServer(); |
| 170 |
} |
| 171 |
} |
| 172 |
|
| 173 |
|
| 174 |
|
| 175 |
|
| 176 |
@RequiresPermission(android.Manifest.permission.MANAGE_ACTIVITY_TASKS) |
| 177 |
@CallSuper |
| 178 |
public void unregisterOrganizer() { |
| 179 |
try { |
| 180 |
getController().unregisterOrganizer(mInterface); |
| 181 |
} catch (RemoteException e) { |
| 182 |
throw e.rethrowFromSystemServer(); |
| 183 |
} |
| 184 |
} |
| 185 |
|
| 186 |
|
| 187 |
|
| 188 |
|
| 189 |
|
| 190 |
|
| 191 |
|
| 192 |
|
| 193 |
|
| 194 |
|
| 195 |
|
| 196 |
|
| 197 |
|
| 198 |
|
| 199 |
|
| 200 |
|
| 201 |
|
| 202 |
|
| 203 |
|
| 204 |
|
| 205 |
@RequiresPermission(android.Manifest.permission.MANAGE_ACTIVITY_TASKS) |
| 206 |
@CallSuper |
| 207 |
@NonNull |
| 208 |
public DisplayAreaAppearedInfo createTaskDisplayArea(int displayId, int parentFeatureId, |
| 209 |
@NonNull String name) { |
| 210 |
try { |
| 211 |
return getController().createTaskDisplayArea( |
| 212 |
mInterface, displayId, parentFeatureId, name); |
| 213 |
} catch (RemoteException e) { |
| 214 |
throw e.rethrowFromSystemServer(); |
| 215 |
} |
| 216 |
} |
| 217 |
|
| 218 |
|
| 219 |
|
| 220 |
|
| 221 |
|
| 222 |
|
| 223 |
|
| 224 |
@RequiresPermission(android.Manifest.permission.MANAGE_ACTIVITY_TASKS) |
| 225 |
@CallSuper |
| 226 |
public void deleteTaskDisplayArea(@NonNull WindowContainerToken taskDisplayArea) { |
| 227 |
try { |
| 228 |
getController().deleteTaskDisplayArea(taskDisplayArea); |
| 229 |
} catch (RemoteException e) { |
| 230 |
throw e.rethrowFromSystemServer(); |
| 231 |
} |
| 232 |
} |
| 233 |
|
| 234 |
|
| 235 |
|
| 236 |
|
| 237 |
|
| 238 |
|
| 239 |
public void onDisplayAreaAppeared(@NonNull DisplayAreaInfo displayAreaInfo, |
| 240 |
@NonNull SurfaceControl leash) {} |
| 241 |
|
| 242 |
public void onDisplayAreaVanished(@NonNull DisplayAreaInfo displayAreaInfo) {} |
| 243 |
|
| 244 |
|
| 245 |
|
| 246 |
|
| 247 |
public void onDisplayAreaInfoChanged(@NonNull DisplayAreaInfo displayAreaInfo) {} |
| 248 |
|
| 249 |
private final IDisplayAreaOrganizer mInterface = new IDisplayAreaOrganizer.Stub() { |
| 250 |
|
| 251 |
@Override |
| 252 |
public void onDisplayAreaAppeared(@NonNull DisplayAreaInfo displayAreaInfo, |
| 253 |
@NonNull SurfaceControl leash) { |
| 254 |
mExecutor.execute( |
| 255 |
() -> DisplayAreaOrganizer.this.onDisplayAreaAppeared(displayAreaInfo, leash)); |
| 256 |
} |
| 257 |
|
| 258 |
@Override |
| 259 |
public void onDisplayAreaVanished(@NonNull DisplayAreaInfo displayAreaInfo) { |
| 260 |
mExecutor.execute( |
| 261 |
() -> DisplayAreaOrganizer.this.onDisplayAreaVanished(displayAreaInfo)); |
| 262 |
} |
| 263 |
|
| 264 |
@Override |
| 265 |
public void onDisplayAreaInfoChanged(@NonNull DisplayAreaInfo displayAreaInfo) { |
| 266 |
mExecutor.execute( |
| 267 |
() -> DisplayAreaOrganizer.this.onDisplayAreaInfoChanged(displayAreaInfo)); |
| 268 |
} |
| 269 |
}; |
| 270 |
|
| 271 |
@RequiresPermission(android.Manifest.permission.MANAGE_ACTIVITY_TASKS) |
| 272 |
private IDisplayAreaOrganizerController getController() { |
| 273 |
try { |
| 274 |
return getWindowOrganizerController().getDisplayAreaOrganizerController(); |
| 275 |
} catch (RemoteException e) { |
| 276 |
return null; |
| 277 |
} |
| 278 |
} |
| 279 |
} |