Skip to content

Commit 88400d3

Browse files
author
Craig Mautner
committed
Add flag for displaying non-user's Windows to user.
Created a new flag that indicates that a window should be shown to all users. For the flag to be valid the owner of the window must have system permissions. Also separated system window types into those that show to all users (e.g. StatusBar, Keyguard, ....) and those that appear only to the owning users (e.g. Drag, ANR, TOAST, ...). Those that appear only to their owner can override their default behavior using the new flag (e.g. LowBattery). Fixes bug 7211965. Change-Id: I1fdca25d57b7b523f0c7f8bceb819af656c388d4
1 parent 7fd1386 commit 88400d3

File tree

10 files changed

+173
-39
lines changed

10 files changed

+173
-39
lines changed

core/java/android/view/WindowManager.java

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -298,12 +298,14 @@ public static class LayoutParams extends ViewGroup.LayoutParams
298298
* Window type: the status bar. There can be only one status bar
299299
* window; it is placed at the top of the screen, and all other
300300
* windows are shifted down so they are below it.
301+
* In multiuser systems shows on all users' windows.
301302
*/
302303
public static final int TYPE_STATUS_BAR = FIRST_SYSTEM_WINDOW;
303304

304305
/**
305306
* Window type: the search bar. There can be only one search bar
306307
* window; it is placed at the top of the screen.
308+
* In multiuser systems shows on all users' windows.
307309
*/
308310
public static final int TYPE_SEARCH_BAR = FIRST_SYSTEM_WINDOW+1;
309311

@@ -312,76 +314,89 @@ public static class LayoutParams extends ViewGroup.LayoutParams
312314
* user interaction with the phone (in particular incoming calls).
313315
* These windows are normally placed above all applications, but behind
314316
* the status bar.
317+
* In multiuser systems shows on all users' windows.
315318
*/
316319
public static final int TYPE_PHONE = FIRST_SYSTEM_WINDOW+2;
317320

318321
/**
319322
* Window type: system window, such as low power alert. These windows
320323
* are always on top of application windows.
324+
* In multiuser systems shows only on the owning user's window.
321325
*/
322326
public static final int TYPE_SYSTEM_ALERT = FIRST_SYSTEM_WINDOW+3;
323327

324328
/**
325329
* Window type: keyguard window.
330+
* In multiuser systems shows on all users' windows.
326331
*/
327332
public static final int TYPE_KEYGUARD = FIRST_SYSTEM_WINDOW+4;
328333

329334
/**
330335
* Window type: transient notifications.
336+
* In multiuser systems shows only on the owning user's window.
331337
*/
332338
public static final int TYPE_TOAST = FIRST_SYSTEM_WINDOW+5;
333339

334340
/**
335341
* Window type: system overlay windows, which need to be displayed
336342
* on top of everything else. These windows must not take input
337343
* focus, or they will interfere with the keyguard.
344+
* In multiuser systems shows only on the owning user's window.
338345
*/
339346
public static final int TYPE_SYSTEM_OVERLAY = FIRST_SYSTEM_WINDOW+6;
340347

341348
/**
342349
* Window type: priority phone UI, which needs to be displayed even if
343350
* the keyguard is active. These windows must not take input
344351
* focus, or they will interfere with the keyguard.
352+
* In multiuser systems shows on all users' windows.
345353
*/
346354
public static final int TYPE_PRIORITY_PHONE = FIRST_SYSTEM_WINDOW+7;
347355

348356
/**
349357
* Window type: panel that slides out from the status bar
358+
* In multiuser systems shows on all users' windows.
350359
*/
351360
public static final int TYPE_SYSTEM_DIALOG = FIRST_SYSTEM_WINDOW+8;
352361

353362
/**
354363
* Window type: dialogs that the keyguard shows
364+
* In multiuser systems shows on all users' windows.
355365
*/
356366
public static final int TYPE_KEYGUARD_DIALOG = FIRST_SYSTEM_WINDOW+9;
357367

358368
/**
359369
* Window type: internal system error windows, appear on top of
360370
* everything they can.
371+
* In multiuser systems shows only on the owning user's window.
361372
*/
362373
public static final int TYPE_SYSTEM_ERROR = FIRST_SYSTEM_WINDOW+10;
363374

364375
/**
365376
* Window type: internal input methods windows, which appear above
366377
* the normal UI. Application windows may be resized or panned to keep
367378
* the input focus visible while this window is displayed.
379+
* In multiuser systems shows only on the owning user's window.
368380
*/
369381
public static final int TYPE_INPUT_METHOD = FIRST_SYSTEM_WINDOW+11;
370382

371383
/**
372384
* Window type: internal input methods dialog windows, which appear above
373385
* the current input method window.
386+
* In multiuser systems shows only on the owning user's window.
374387
*/
375388
public static final int TYPE_INPUT_METHOD_DIALOG= FIRST_SYSTEM_WINDOW+12;
376389

377390
/**
378391
* Window type: wallpaper window, placed behind any window that wants
379392
* to sit on top of the wallpaper.
393+
* In multiuser systems shows only on the owning user's window.
380394
*/
381395
public static final int TYPE_WALLPAPER = FIRST_SYSTEM_WINDOW+13;
382396

383397
/**
384398
* Window type: panel that slides out from over the status bar
399+
* In multiuser systems shows on all users' windows.
385400
*/
386401
public static final int TYPE_STATUS_BAR_PANEL = FIRST_SYSTEM_WINDOW+14;
387402

@@ -393,87 +408,109 @@ public static class LayoutParams extends ViewGroup.LayoutParams
393408
* This is exactly like {@link #TYPE_SYSTEM_OVERLAY} except that only the
394409
* system itself is allowed to create these overlays. Applications cannot
395410
* obtain permission to create secure system overlays.
411+
*
412+
* In multiuser systems shows only on the owning user's window.
396413
* @hide
397414
*/
398415
public static final int TYPE_SECURE_SYSTEM_OVERLAY = FIRST_SYSTEM_WINDOW+15;
399416

400417
/**
401418
* Window type: the drag-and-drop pseudowindow. There is only one
402419
* drag layer (at most), and it is placed on top of all other windows.
420+
* In multiuser systems shows only on the owning user's window.
403421
* @hide
404422
*/
405423
public static final int TYPE_DRAG = FIRST_SYSTEM_WINDOW+16;
406424

407425
/**
408426
* Window type: panel that slides out from under the status bar
427+
* In multiuser systems shows on all users' windows.
409428
* @hide
410429
*/
411430
public static final int TYPE_STATUS_BAR_SUB_PANEL = FIRST_SYSTEM_WINDOW+17;
412431

413432
/**
414433
* Window type: (mouse) pointer
434+
* In multiuser systems shows on all users' windows.
415435
* @hide
416436
*/
417437
public static final int TYPE_POINTER = FIRST_SYSTEM_WINDOW+18;
418438

419439
/**
420440
* Window type: Navigation bar (when distinct from status bar)
441+
* In multiuser systems shows on all users' windows.
421442
* @hide
422443
*/
423444
public static final int TYPE_NAVIGATION_BAR = FIRST_SYSTEM_WINDOW+19;
424445

425446
/**
426447
* Window type: The volume level overlay/dialog shown when the user
427448
* changes the system volume.
449+
* In multiuser systems shows on all users' windows.
428450
* @hide
429451
*/
430452
public static final int TYPE_VOLUME_OVERLAY = FIRST_SYSTEM_WINDOW+20;
431453

432454
/**
433455
* Window type: The boot progress dialog, goes on top of everything
434456
* in the world.
457+
* In multiuser systems shows on all users' windows.
435458
* @hide
436459
*/
437460
public static final int TYPE_BOOT_PROGRESS = FIRST_SYSTEM_WINDOW+21;
438461

439462
/**
440463
* Window type: Fake window to consume touch events when the navigation
441464
* bar is hidden.
465+
* In multiuser systems shows on all users' windows.
442466
* @hide
443467
*/
444468
public static final int TYPE_HIDDEN_NAV_CONSUMER = FIRST_SYSTEM_WINDOW+22;
445469

446470
/**
447471
* Window type: Dreams (screen saver) window, just above keyguard.
472+
* In multiuser systems shows only on the owning user's window.
448473
* @hide
449474
*/
450475
public static final int TYPE_DREAM = FIRST_SYSTEM_WINDOW+23;
451476

452477
/**
453478
* Window type: Navigation bar panel (when navigation bar is distinct from status bar)
479+
* In multiuser systems shows on all users' windows.
454480
* @hide
455481
*/
456482
public static final int TYPE_NAVIGATION_BAR_PANEL = FIRST_SYSTEM_WINDOW+24;
457483

458484
/**
459485
* Window type: Behind the universe of the real windows.
486+
* In multiuser systems shows on all users' windows.
460487
* @hide
461488
*/
462489
public static final int TYPE_UNIVERSE_BACKGROUND = FIRST_SYSTEM_WINDOW+25;
463490

464491
/**
465492
* Window type: Display overlay window. Used to simulate secondary display devices.
493+
* In multiuser systems shows on all users' windows.
466494
* @hide
467495
*/
468496
public static final int TYPE_DISPLAY_OVERLAY = FIRST_SYSTEM_WINDOW+26;
469497

470498
/**
471499
* Window type: Magnification overlay window. Used to highlight the magnified
472500
* portion of a display when accessibility magnification is enabled.
501+
* In multiuser systems shows on all users' windows.
473502
* @hide
474503
*/
475504
public static final int TYPE_MAGNIFICATION_OVERLAY = FIRST_SYSTEM_WINDOW+27;
476505

506+
/**
507+
* Window type: Recents. Same layer as {@link #TYPE_SYSTEM_DIALOG} but only appears on
508+
* one user's screen.
509+
* In multiuser systems shows on all users' windows.
510+
* @hide
511+
*/
512+
public static final int TYPE_RECENTS_OVERLAY = FIRST_SYSTEM_WINDOW+28;
513+
477514
/**
478515
* End of types of system windows.
479516
*/
@@ -879,6 +916,14 @@ public static class LayoutParams extends ViewGroup.LayoutParams
879916
*/
880917
public static final int PRIVATE_FLAG_SET_NEEDS_MENU_KEY = 0x00000008;
881918

919+
/** In a multiuser system if this flag is set and the owner is a system process then this
920+
* window will appear on all user screens. This overrides the default behavior of window
921+
* types that normally only appear on the owning user's screen. Refer to each window type
922+
* to determine its default behavior.
923+
*
924+
* {@hide} */
925+
public static final int PRIVATE_FLAG_SHOW_FOR_ALL_USERS = 0x00000010;
926+
882927
/**
883928
* Control flags that are private to the platform.
884929
* @hide

core/java/android/view/WindowManagerPolicy.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -499,6 +499,16 @@ public void init(Context context, IWindowManager windowManager,
499499
*/
500500
public int checkAddPermission(WindowManager.LayoutParams attrs);
501501

502+
/**
503+
* Check permissions when adding a window.
504+
*
505+
* @param attrs The window's LayoutParams.
506+
*
507+
* @return True if the window may only be shown to the current user, false if the window can
508+
* be shown on all users' windows.
509+
*/
510+
public boolean checkShowToOwnerOnly(WindowManager.LayoutParams attrs);
511+
502512
/**
503513
* Sanitize the layout parameters coming from a client. Allows the policy
504514
* to do things like ensure that windows of a specific type can't take

packages/SystemUI/src/com/android/systemui/power/PowerUI.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,7 @@ void showLowBatteryWarning() {
207207
if (intent.resolveActivity(mContext.getPackageManager()) != null) {
208208
b.setNegativeButton(R.string.battery_low_why,
209209
new DialogInterface.OnClickListener() {
210+
@Override
210211
public void onClick(DialogInterface dialog, int which) {
211212
mContext.startActivity(intent);
212213
dismissLowBatteryWarning();
@@ -216,12 +217,15 @@ public void onClick(DialogInterface dialog, int which) {
216217

217218
AlertDialog d = b.create();
218219
d.setOnDismissListener(new DialogInterface.OnDismissListener() {
220+
@Override
219221
public void onDismiss(DialogInterface dialog) {
220222
mLowBatteryDialog = null;
221223
mBatteryLevelTextView = null;
222224
}
223225
});
224226
d.getWindow().setType(WindowManager.LayoutParams.TYPE_SYSTEM_ALERT);
227+
d.getWindow().getAttributes().privateFlags |=
228+
WindowManager.LayoutParams.PRIVATE_FLAG_SHOW_FOR_ALL_USERS;
225229
d.show();
226230
mLowBatteryDialog = d;
227231
}

0 commit comments

Comments
 (0)