Window.java revision d4f2b641d32f4c0f73b21c4436e5a14c4f569633
1/*
2 * Copyright (C) 2006 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
17package android.view;
18
19import android.annotation.ColorInt;
20import android.annotation.DrawableRes;
21import android.annotation.IdRes;
22import android.annotation.LayoutRes;
23import android.annotation.NonNull;
24import android.annotation.Nullable;
25import android.annotation.StyleRes;
26import android.annotation.SystemApi;
27import android.content.Context;
28import android.content.res.Configuration;
29import android.content.res.Resources;
30import android.content.res.TypedArray;
31import android.graphics.PixelFormat;
32import android.graphics.drawable.Drawable;
33import android.media.session.MediaController;
34import android.net.Uri;
35import android.os.Bundle;
36import android.os.IBinder;
37import android.os.RemoteException;
38import android.os.SystemProperties;
39import android.transition.Scene;
40import android.transition.Transition;
41import android.transition.TransitionManager;
42import android.view.accessibility.AccessibilityEvent;
43
44/**
45 * Abstract base class for a top-level window look and behavior policy.  An
46 * instance of this class should be used as the top-level view added to the
47 * window manager. It provides standard UI policies such as a background, title
48 * area, default key processing, etc.
49 *
50 * <p>The only existing implementation of this abstract class is
51 * android.view.PhoneWindow, which you should instantiate when needing a
52 * Window.
53 */
54public abstract class Window {
55    /** Flag for the "options panel" feature.  This is enabled by default. */
56    public static final int FEATURE_OPTIONS_PANEL = 0;
57    /** Flag for the "no title" feature, turning off the title at the top
58     *  of the screen. */
59    public static final int FEATURE_NO_TITLE = 1;
60
61    /**
62     * Flag for the progress indicator feature.
63     *
64     * @deprecated No longer supported starting in API 21.
65     */
66    @Deprecated
67    public static final int FEATURE_PROGRESS = 2;
68
69    /** Flag for having an icon on the left side of the title bar */
70    public static final int FEATURE_LEFT_ICON = 3;
71    /** Flag for having an icon on the right side of the title bar */
72    public static final int FEATURE_RIGHT_ICON = 4;
73
74    /**
75     * Flag for indeterminate progress.
76     *
77     * @deprecated No longer supported starting in API 21.
78     */
79    @Deprecated
80    public static final int FEATURE_INDETERMINATE_PROGRESS = 5;
81
82    /** Flag for the context menu.  This is enabled by default. */
83    public static final int FEATURE_CONTEXT_MENU = 6;
84    /** Flag for custom title. You cannot combine this feature with other title features. */
85    public static final int FEATURE_CUSTOM_TITLE = 7;
86    /**
87     * Flag for enabling the Action Bar.
88     * This is enabled by default for some devices. The Action Bar
89     * replaces the title bar and provides an alternate location
90     * for an on-screen menu button on some devices.
91     */
92    public static final int FEATURE_ACTION_BAR = 8;
93    /**
94     * Flag for requesting an Action Bar that overlays window content.
95     * Normally an Action Bar will sit in the space above window content, but if this
96     * feature is requested along with {@link #FEATURE_ACTION_BAR} it will be layered over
97     * the window content itself. This is useful if you would like your app to have more control
98     * over how the Action Bar is displayed, such as letting application content scroll beneath
99     * an Action Bar with a transparent background or otherwise displaying a transparent/translucent
100     * Action Bar over application content.
101     *
102     * <p>This mode is especially useful with {@link View#SYSTEM_UI_FLAG_FULLSCREEN
103     * View.SYSTEM_UI_FLAG_FULLSCREEN}, which allows you to seamlessly hide the
104     * action bar in conjunction with other screen decorations.
105     *
106     * <p>As of {@link android.os.Build.VERSION_CODES#JELLY_BEAN}, when an
107     * ActionBar is in this mode it will adjust the insets provided to
108     * {@link View#fitSystemWindows(android.graphics.Rect) View.fitSystemWindows(Rect)}
109     * to include the content covered by the action bar, so you can do layout within
110     * that space.
111     */
112    public static final int FEATURE_ACTION_BAR_OVERLAY = 9;
113    /**
114     * Flag for specifying the behavior of action modes when an Action Bar is not present.
115     * If overlay is enabled, the action mode UI will be allowed to cover existing window content.
116     */
117    public static final int FEATURE_ACTION_MODE_OVERLAY = 10;
118    /**
119     * Flag for requesting a decoration-free window that is dismissed by swiping from the left.
120     */
121    public static final int FEATURE_SWIPE_TO_DISMISS = 11;
122    /**
123     * Flag for requesting that window content changes should be animated using a
124     * TransitionManager.
125     *
126     * <p>The TransitionManager is set using
127     * {@link #setTransitionManager(android.transition.TransitionManager)}. If none is set,
128     * a default TransitionManager will be used.</p>
129     *
130     * @see #setContentView
131     */
132    public static final int FEATURE_CONTENT_TRANSITIONS = 12;
133
134    /**
135     * Enables Activities to run Activity Transitions either through sending or receiving
136     * ActivityOptions bundle created with
137     * {@link android.app.ActivityOptions#makeSceneTransitionAnimation(android.app.Activity,
138     * android.util.Pair[])} or {@link android.app.ActivityOptions#makeSceneTransitionAnimation(
139     * android.app.Activity, View, String)}.
140     */
141    public static final int FEATURE_ACTIVITY_TRANSITIONS = 13;
142
143    /**
144     * Max value used as a feature ID
145     * @hide
146     */
147    public static final int FEATURE_MAX = FEATURE_ACTIVITY_TRANSITIONS;
148
149    /**
150     * Flag for setting the progress bar's visibility to VISIBLE.
151     *
152     * @deprecated {@link #FEATURE_PROGRESS} and related methods are no longer
153     *             supported starting in API 21.
154     */
155    @Deprecated
156    public static final int PROGRESS_VISIBILITY_ON = -1;
157
158    /**
159     * Flag for setting the progress bar's visibility to GONE.
160     *
161     * @deprecated {@link #FEATURE_PROGRESS} and related methods are no longer
162     *             supported starting in API 21.
163     */
164    @Deprecated
165    public static final int PROGRESS_VISIBILITY_OFF = -2;
166
167    /**
168     * Flag for setting the progress bar's indeterminate mode on.
169     *
170     * @deprecated {@link #FEATURE_INDETERMINATE_PROGRESS} and related methods
171     *             are no longer supported starting in API 21.
172     */
173    @Deprecated
174    public static final int PROGRESS_INDETERMINATE_ON = -3;
175
176    /**
177     * Flag for setting the progress bar's indeterminate mode off.
178     *
179     * @deprecated {@link #FEATURE_INDETERMINATE_PROGRESS} and related methods
180     *             are no longer supported starting in API 21.
181     */
182    @Deprecated
183    public static final int PROGRESS_INDETERMINATE_OFF = -4;
184
185    /**
186     * Starting value for the (primary) progress.
187     *
188     * @deprecated {@link #FEATURE_PROGRESS} and related methods are no longer
189     *             supported starting in API 21.
190     */
191    @Deprecated
192    public static final int PROGRESS_START = 0;
193
194    /**
195     * Ending value for the (primary) progress.
196     *
197     * @deprecated {@link #FEATURE_PROGRESS} and related methods are no longer
198     *             supported starting in API 21.
199     */
200    @Deprecated
201    public static final int PROGRESS_END = 10000;
202
203    /**
204     * Lowest possible value for the secondary progress.
205     *
206     * @deprecated {@link #FEATURE_PROGRESS} and related methods are no longer
207     *             supported starting in API 21.
208     */
209    @Deprecated
210    public static final int PROGRESS_SECONDARY_START = 20000;
211
212    /**
213     * Highest possible value for the secondary progress.
214     *
215     * @deprecated {@link #FEATURE_PROGRESS} and related methods are no longer
216     *             supported starting in API 21.
217     */
218    @Deprecated
219    public static final int PROGRESS_SECONDARY_END = 30000;
220
221    /**
222     * The transitionName for the status bar background View when a custom background is used.
223     * @see android.view.Window#setStatusBarColor(int)
224     */
225    public static final String STATUS_BAR_BACKGROUND_TRANSITION_NAME = "android:status:background";
226
227    /**
228     * The transitionName for the navigation bar background View when a custom background is used.
229     * @see android.view.Window#setNavigationBarColor(int)
230     */
231    public static final String NAVIGATION_BAR_BACKGROUND_TRANSITION_NAME =
232            "android:navigation:background";
233
234    /**
235     * The default features enabled.
236     * @deprecated use {@link #getDefaultFeatures(android.content.Context)} instead.
237     */
238    @Deprecated
239    @SuppressWarnings({"PointlessBitwiseExpression"})
240    protected static final int DEFAULT_FEATURES = (1 << FEATURE_OPTIONS_PANEL) |
241            (1 << FEATURE_CONTEXT_MENU);
242
243    /**
244     * The ID that the main layout in the XML layout file should have.
245     */
246    public static final int ID_ANDROID_CONTENT = com.android.internal.R.id.content;
247
248    private static final String PROPERTY_HARDWARE_UI = "persist.sys.ui.hw";
249
250    private final Context mContext;
251
252    private TypedArray mWindowStyle;
253    private Callback mCallback;
254    private OnWindowDismissedCallback mOnWindowDismissedCallback;
255    private WindowControllerCallback mWindowControllerCallback;
256    private WindowManager mWindowManager;
257    private IBinder mAppToken;
258    private String mAppName;
259    private boolean mHardwareAccelerated;
260    private Window mContainer;
261    private Window mActiveChild;
262    private boolean mIsActive = false;
263    private boolean mHasChildren = false;
264    private boolean mCloseOnTouchOutside = false;
265    private boolean mSetCloseOnTouchOutside = false;
266    private int mForcedWindowFlags = 0;
267
268    private int mFeatures;
269    private int mLocalFeatures;
270
271    private boolean mHaveWindowFormat = false;
272    private boolean mHaveDimAmount = false;
273    private int mDefaultWindowFormat = PixelFormat.OPAQUE;
274
275    private boolean mHasSoftInputMode = false;
276
277    private boolean mDestroyed;
278
279    // The current window attributes.
280    private final WindowManager.LayoutParams mWindowAttributes =
281        new WindowManager.LayoutParams();
282
283    /**
284     * API from a Window back to its caller.  This allows the client to
285     * intercept key dispatching, panels and menus, etc.
286     */
287    public interface Callback {
288        /**
289         * Called to process key events.  At the very least your
290         * implementation must call
291         * {@link android.view.Window#superDispatchKeyEvent} to do the
292         * standard key processing.
293         *
294         * @param event The key event.
295         *
296         * @return boolean Return true if this event was consumed.
297         */
298        public boolean dispatchKeyEvent(KeyEvent event);
299
300        /**
301         * Called to process a key shortcut event.
302         * At the very least your implementation must call
303         * {@link android.view.Window#superDispatchKeyShortcutEvent} to do the
304         * standard key shortcut processing.
305         *
306         * @param event The key shortcut event.
307         * @return True if this event was consumed.
308         */
309        public boolean dispatchKeyShortcutEvent(KeyEvent event);
310
311        /**
312         * Called to process touch screen events.  At the very least your
313         * implementation must call
314         * {@link android.view.Window#superDispatchTouchEvent} to do the
315         * standard touch screen processing.
316         *
317         * @param event The touch screen event.
318         *
319         * @return boolean Return true if this event was consumed.
320         */
321        public boolean dispatchTouchEvent(MotionEvent event);
322
323        /**
324         * Called to process trackball events.  At the very least your
325         * implementation must call
326         * {@link android.view.Window#superDispatchTrackballEvent} to do the
327         * standard trackball processing.
328         *
329         * @param event The trackball event.
330         *
331         * @return boolean Return true if this event was consumed.
332         */
333        public boolean dispatchTrackballEvent(MotionEvent event);
334
335        /**
336         * Called to process generic motion events.  At the very least your
337         * implementation must call
338         * {@link android.view.Window#superDispatchGenericMotionEvent} to do the
339         * standard processing.
340         *
341         * @param event The generic motion event.
342         *
343         * @return boolean Return true if this event was consumed.
344         */
345        public boolean dispatchGenericMotionEvent(MotionEvent event);
346
347        /**
348         * Called to process population of {@link AccessibilityEvent}s.
349         *
350         * @param event The event.
351         *
352         * @return boolean Return true if event population was completed.
353         */
354        public boolean dispatchPopulateAccessibilityEvent(AccessibilityEvent event);
355
356        /**
357         * Instantiate the view to display in the panel for 'featureId'.
358         * You can return null, in which case the default content (typically
359         * a menu) will be created for you.
360         *
361         * @param featureId Which panel is being created.
362         *
363         * @return view The top-level view to place in the panel.
364         *
365         * @see #onPreparePanel
366         */
367        @Nullable
368        public View onCreatePanelView(int featureId);
369
370        /**
371         * Initialize the contents of the menu for panel 'featureId'.  This is
372         * called if onCreatePanelView() returns null, giving you a standard
373         * menu in which you can place your items.  It is only called once for
374         * the panel, the first time it is shown.
375         *
376         * <p>You can safely hold on to <var>menu</var> (and any items created
377         * from it), making modifications to it as desired, until the next
378         * time onCreatePanelMenu() is called for this feature.
379         *
380         * @param featureId The panel being created.
381         * @param menu The menu inside the panel.
382         *
383         * @return boolean You must return true for the panel to be displayed;
384         *         if you return false it will not be shown.
385         */
386        public boolean onCreatePanelMenu(int featureId, Menu menu);
387
388        /**
389         * Prepare a panel to be displayed.  This is called right before the
390         * panel window is shown, every time it is shown.
391         *
392         * @param featureId The panel that is being displayed.
393         * @param view The View that was returned by onCreatePanelView().
394         * @param menu If onCreatePanelView() returned null, this is the Menu
395         *             being displayed in the panel.
396         *
397         * @return boolean You must return true for the panel to be displayed;
398         *         if you return false it will not be shown.
399         *
400         * @see #onCreatePanelView
401         */
402        public boolean onPreparePanel(int featureId, View view, Menu menu);
403
404        /**
405         * Called when a panel's menu is opened by the user. This may also be
406         * called when the menu is changing from one type to another (for
407         * example, from the icon menu to the expanded menu).
408         *
409         * @param featureId The panel that the menu is in.
410         * @param menu The menu that is opened.
411         * @return Return true to allow the menu to open, or false to prevent
412         *         the menu from opening.
413         */
414        public boolean onMenuOpened(int featureId, Menu menu);
415
416        /**
417         * Called when a panel's menu item has been selected by the user.
418         *
419         * @param featureId The panel that the menu is in.
420         * @param item The menu item that was selected.
421         *
422         * @return boolean Return true to finish processing of selection, or
423         *         false to perform the normal menu handling (calling its
424         *         Runnable or sending a Message to its target Handler).
425         */
426        public boolean onMenuItemSelected(int featureId, MenuItem item);
427
428        /**
429         * This is called whenever the current window attributes change.
430         *
431         */
432        public void onWindowAttributesChanged(WindowManager.LayoutParams attrs);
433
434        /**
435         * This hook is called whenever the content view of the screen changes
436         * (due to a call to
437         * {@link Window#setContentView(View, android.view.ViewGroup.LayoutParams)
438         * Window.setContentView} or
439         * {@link Window#addContentView(View, android.view.ViewGroup.LayoutParams)
440         * Window.addContentView}).
441         */
442        public void onContentChanged();
443
444        /**
445         * This hook is called whenever the window focus changes.  See
446         * {@link View#onWindowFocusChanged(boolean)
447         * View.onWindowFocusChangedNotLocked(boolean)} for more information.
448         *
449         * @param hasFocus Whether the window now has focus.
450         */
451        public void onWindowFocusChanged(boolean hasFocus);
452
453        /**
454         * Called when the window has been attached to the window manager.
455         * See {@link View#onAttachedToWindow() View.onAttachedToWindow()}
456         * for more information.
457         */
458        public void onAttachedToWindow();
459
460        /**
461         * Called when the window has been attached to the window manager.
462         * See {@link View#onDetachedFromWindow() View.onDetachedFromWindow()}
463         * for more information.
464         */
465        public void onDetachedFromWindow();
466
467        /**
468         * Called when a panel is being closed.  If another logical subsequent
469         * panel is being opened (and this panel is being closed to make room for the subsequent
470         * panel), this method will NOT be called.
471         *
472         * @param featureId The panel that is being displayed.
473         * @param menu If onCreatePanelView() returned null, this is the Menu
474         *            being displayed in the panel.
475         */
476        public void onPanelClosed(int featureId, Menu menu);
477
478        /**
479         * Called when the user signals the desire to start a search.
480         *
481         * @return true if search launched, false if activity refuses (blocks)
482         *
483         * @see android.app.Activity#onSearchRequested()
484         */
485        public boolean onSearchRequested();
486
487        /**
488         * Called when the user signals the desire to start a search.
489         *
490         * @param searchEvent A {@link SearchEvent} describing the signal to
491         *                   start a search.
492         * @return true if search launched, false if activity refuses (blocks)
493         */
494        public boolean onSearchRequested(SearchEvent searchEvent);
495
496        /**
497         * Called when an action mode is being started for this window. Gives the
498         * callback an opportunity to handle the action mode in its own unique and
499         * beautiful way. If this method returns null the system can choose a way
500         * to present the mode or choose not to start the mode at all. This is equivalent
501         * to {@link #onWindowStartingActionMode(android.view.ActionMode.Callback, int)}
502         * with type {@link ActionMode#TYPE_PRIMARY}.
503         *
504         * @param callback Callback to control the lifecycle of this action mode
505         * @return The ActionMode that was started, or null if the system should present it
506         */
507        @Nullable
508        public ActionMode onWindowStartingActionMode(ActionMode.Callback callback);
509
510        /**
511         * Called when an action mode is being started for this window. Gives the
512         * callback an opportunity to handle the action mode in its own unique and
513         * beautiful way. If this method returns null the system can choose a way
514         * to present the mode or choose not to start the mode at all.
515         *
516         * @param callback Callback to control the lifecycle of this action mode
517         * @param type One of {@link ActionMode#TYPE_PRIMARY} or {@link ActionMode#TYPE_FLOATING}.
518         * @return The ActionMode that was started, or null if the system should present it
519         */
520        @Nullable
521        public ActionMode onWindowStartingActionMode(ActionMode.Callback callback, int type);
522
523        /**
524         * Called when an action mode has been started. The appropriate mode callback
525         * method will have already been invoked.
526         *
527         * @param mode The new mode that has just been started.
528         */
529        public void onActionModeStarted(ActionMode mode);
530
531        /**
532         * Called when an action mode has been finished. The appropriate mode callback
533         * method will have already been invoked.
534         *
535         * @param mode The mode that was just finished.
536         */
537        public void onActionModeFinished(ActionMode mode);
538    }
539
540    /** @hide */
541    public interface OnWindowDismissedCallback {
542        /**
543         * Called when a window is dismissed. This informs the callback that the
544         * window is gone, and it should finish itself.
545         * @param finishTask True if the task should also be finished.
546         */
547        void onWindowDismissed(boolean finishTask);
548    }
549
550    /** @hide */
551    public interface WindowControllerCallback {
552        /**
553         * Called to move the window and its activity/task to a different stack container.
554         * For example, a window can move between
555         * {@link android.app.ActivityManager#FULLSCREEN_WORKSPACE_STACK_ID} stack and
556         * {@link android.app.ActivityManager#FREEFORM_WORKSPACE_STACK_ID} stack.
557         *
558         * @param stackId stack Id to change to.
559         */
560        void changeWindowStack(int stackId) throws RemoteException;
561
562        /** Returns the current stack Id for the window. */
563        int getWindowStackId() throws RemoteException;
564    }
565
566    public Window(Context context) {
567        mContext = context;
568        mFeatures = mLocalFeatures = getDefaultFeatures(context);
569    }
570
571    /**
572     * Return the Context this window policy is running in, for retrieving
573     * resources and other information.
574     *
575     * @return Context The Context that was supplied to the constructor.
576     */
577    public final Context getContext() {
578        return mContext;
579    }
580
581    /**
582     * Return the {@link android.R.styleable#Window} attributes from this
583     * window's theme.
584     */
585    public final TypedArray getWindowStyle() {
586        synchronized (this) {
587            if (mWindowStyle == null) {
588                mWindowStyle = mContext.obtainStyledAttributes(
589                        com.android.internal.R.styleable.Window);
590            }
591            return mWindowStyle;
592        }
593    }
594
595    /**
596     * Set the container for this window.  If not set, the DecorWindow
597     * operates as a top-level window; otherwise, it negotiates with the
598     * container to display itself appropriately.
599     *
600     * @param container The desired containing Window.
601     */
602    public void setContainer(Window container) {
603        mContainer = container;
604        if (container != null) {
605            // Embedded screens never have a title.
606            mFeatures |= 1<<FEATURE_NO_TITLE;
607            mLocalFeatures |= 1<<FEATURE_NO_TITLE;
608            container.mHasChildren = true;
609        }
610    }
611
612    /**
613     * Return the container for this Window.
614     *
615     * @return Window The containing window, or null if this is a
616     *         top-level window.
617     */
618    public final Window getContainer() {
619        return mContainer;
620    }
621
622    public final boolean hasChildren() {
623        return mHasChildren;
624    }
625
626    /** @hide */
627    public final void destroy() {
628        mDestroyed = true;
629    }
630
631    /** @hide */
632    public final boolean isDestroyed() {
633        return mDestroyed;
634    }
635
636    /**
637     * Set the window manager for use by this Window to, for example,
638     * display panels.  This is <em>not</em> used for displaying the
639     * Window itself -- that must be done by the client.
640     *
641     * @param wm The window manager for adding new windows.
642     */
643    public void setWindowManager(WindowManager wm, IBinder appToken, String appName) {
644        setWindowManager(wm, appToken, appName, false);
645    }
646
647    /**
648     * Set the window manager for use by this Window to, for example,
649     * display panels.  This is <em>not</em> used for displaying the
650     * Window itself -- that must be done by the client.
651     *
652     * @param wm The window manager for adding new windows.
653     */
654    public void setWindowManager(WindowManager wm, IBinder appToken, String appName,
655            boolean hardwareAccelerated) {
656        mAppToken = appToken;
657        mAppName = appName;
658        mHardwareAccelerated = hardwareAccelerated
659                || SystemProperties.getBoolean(PROPERTY_HARDWARE_UI, false);
660        if (wm == null) {
661            wm = (WindowManager)mContext.getSystemService(Context.WINDOW_SERVICE);
662        }
663        mWindowManager = ((WindowManagerImpl)wm).createLocalWindowManager(this);
664    }
665
666    void adjustLayoutParamsForSubWindow(WindowManager.LayoutParams wp) {
667        CharSequence curTitle = wp.getTitle();
668        if (wp.type >= WindowManager.LayoutParams.FIRST_SUB_WINDOW &&
669                wp.type <= WindowManager.LayoutParams.LAST_SUB_WINDOW) {
670            if (wp.token == null) {
671                View decor = peekDecorView();
672                if (decor != null) {
673                    wp.token = decor.getWindowToken();
674                }
675            }
676            if (curTitle == null || curTitle.length() == 0) {
677                String title;
678                if (wp.type == WindowManager.LayoutParams.TYPE_APPLICATION_MEDIA) {
679                    title = "Media";
680                } else if (wp.type == WindowManager.LayoutParams.TYPE_APPLICATION_MEDIA_OVERLAY) {
681                    title = "MediaOvr";
682                } else if (wp.type == WindowManager.LayoutParams.TYPE_APPLICATION_PANEL) {
683                    title = "Panel";
684                } else if (wp.type == WindowManager.LayoutParams.TYPE_APPLICATION_SUB_PANEL) {
685                    title = "SubPanel";
686                } else if (wp.type == WindowManager.LayoutParams.TYPE_APPLICATION_ABOVE_SUB_PANEL) {
687                    title = "AboveSubPanel";
688                } else if (wp.type == WindowManager.LayoutParams.TYPE_APPLICATION_ATTACHED_DIALOG) {
689                    title = "AtchDlg";
690                } else {
691                    title = Integer.toString(wp.type);
692                }
693                if (mAppName != null) {
694                    title += ":" + mAppName;
695                }
696                wp.setTitle(title);
697            }
698        } else if (wp.type >= WindowManager.LayoutParams.FIRST_SYSTEM_WINDOW &&
699                wp.type <= WindowManager.LayoutParams.LAST_SYSTEM_WINDOW) {
700            // We don't set the app token to this system window because the life cycles should be
701            // independent. If an app creates a system window and then the app goes to the stopped
702            // state, the system window should not be affected (can still show and receive input
703            // events).
704            if (curTitle == null || curTitle.length() == 0) {
705                String title = "Sys" + Integer.toString(wp.type);
706                if (mAppName != null) {
707                    title += ":" + mAppName;
708                }
709                wp.setTitle(title);
710            }
711        } else {
712            if (wp.token == null) {
713                wp.token = mContainer == null ? mAppToken : mContainer.mAppToken;
714            }
715            if ((curTitle == null || curTitle.length() == 0)
716                    && mAppName != null) {
717                wp.setTitle(mAppName);
718            }
719        }
720        if (wp.packageName == null) {
721            wp.packageName = mContext.getPackageName();
722        }
723        if (mHardwareAccelerated) {
724            wp.flags |= WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED;
725        }
726    }
727
728    /**
729     * Return the window manager allowing this Window to display its own
730     * windows.
731     *
732     * @return WindowManager The ViewManager.
733     */
734    public WindowManager getWindowManager() {
735        return mWindowManager;
736    }
737
738    /**
739     * Set the Callback interface for this window, used to intercept key
740     * events and other dynamic operations in the window.
741     *
742     * @param callback The desired Callback interface.
743     */
744    public void setCallback(Callback callback) {
745        mCallback = callback;
746    }
747
748    /**
749     * Return the current Callback interface for this window.
750     */
751    public final Callback getCallback() {
752        return mCallback;
753    }
754
755    /** @hide */
756    public final void setOnWindowDismissedCallback(OnWindowDismissedCallback dcb) {
757        mOnWindowDismissedCallback = dcb;
758    }
759
760    /** @hide */
761    public final void dispatchOnWindowDismissed(boolean finishTask) {
762        if (mOnWindowDismissedCallback != null) {
763            mOnWindowDismissedCallback.onWindowDismissed(finishTask);
764        }
765    }
766
767    /** @hide */
768    public final void setWindowControllerCallback(WindowControllerCallback wccb) {
769        mWindowControllerCallback = wccb;
770    }
771
772    /** @hide */
773    public final WindowControllerCallback getWindowControllerCallback() {
774        return mWindowControllerCallback;
775    }
776
777    /**
778     * Take ownership of this window's surface.  The window's view hierarchy
779     * will no longer draw into the surface, though it will otherwise continue
780     * to operate (such as for receiving input events).  The given SurfaceHolder
781     * callback will be used to tell you about state changes to the surface.
782     */
783    public abstract void takeSurface(SurfaceHolder.Callback2 callback);
784
785    /**
786     * Take ownership of this window's InputQueue.  The window will no
787     * longer read and dispatch input events from the queue; it is your
788     * responsibility to do so.
789     */
790    public abstract void takeInputQueue(InputQueue.Callback callback);
791
792    /**
793     * Return whether this window is being displayed with a floating style
794     * (based on the {@link android.R.attr#windowIsFloating} attribute in
795     * the style/theme).
796     *
797     * @return Returns true if the window is configured to be displayed floating
798     * on top of whatever is behind it.
799     */
800    public abstract boolean isFloating();
801
802    /**
803     * Set the width and height layout parameters of the window.  The default
804     * for both of these is MATCH_PARENT; you can change them to WRAP_CONTENT
805     * or an absolute value to make a window that is not full-screen.
806     *
807     * @param width The desired layout width of the window.
808     * @param height The desired layout height of the window.
809     *
810     * @see ViewGroup.LayoutParams#height
811     * @see ViewGroup.LayoutParams#width
812     */
813    public void setLayout(int width, int height) {
814        final WindowManager.LayoutParams attrs = getAttributes();
815        attrs.width = width;
816        attrs.height = height;
817        dispatchWindowAttributesChanged(attrs);
818    }
819
820    /**
821     * Set the gravity of the window, as per the Gravity constants.  This
822     * controls how the window manager is positioned in the overall window; it
823     * is only useful when using WRAP_CONTENT for the layout width or height.
824     *
825     * @param gravity The desired gravity constant.
826     *
827     * @see Gravity
828     * @see #setLayout
829     */
830    public void setGravity(int gravity)
831    {
832        final WindowManager.LayoutParams attrs = getAttributes();
833        attrs.gravity = gravity;
834        dispatchWindowAttributesChanged(attrs);
835    }
836
837    /**
838     * Set the type of the window, as per the WindowManager.LayoutParams
839     * types.
840     *
841     * @param type The new window type (see WindowManager.LayoutParams).
842     */
843    public void setType(int type) {
844        final WindowManager.LayoutParams attrs = getAttributes();
845        attrs.type = type;
846        dispatchWindowAttributesChanged(attrs);
847    }
848
849    /**
850     * Set the format of window, as per the PixelFormat types.  This overrides
851     * the default format that is selected by the Window based on its
852     * window decorations.
853     *
854     * @param format The new window format (see PixelFormat).  Use
855     *               PixelFormat.UNKNOWN to allow the Window to select
856     *               the format.
857     *
858     * @see PixelFormat
859     */
860    public void setFormat(int format) {
861        final WindowManager.LayoutParams attrs = getAttributes();
862        if (format != PixelFormat.UNKNOWN) {
863            attrs.format = format;
864            mHaveWindowFormat = true;
865        } else {
866            attrs.format = mDefaultWindowFormat;
867            mHaveWindowFormat = false;
868        }
869        dispatchWindowAttributesChanged(attrs);
870    }
871
872    /**
873     * Specify custom animations to use for the window, as per
874     * {@link WindowManager.LayoutParams#windowAnimations
875     * WindowManager.LayoutParams.windowAnimations}.  Providing anything besides
876     * 0 here will override the animations the window would
877     * normally retrieve from its theme.
878     */
879    public void setWindowAnimations(@StyleRes int resId) {
880        final WindowManager.LayoutParams attrs = getAttributes();
881        attrs.windowAnimations = resId;
882        dispatchWindowAttributesChanged(attrs);
883    }
884
885    /**
886     * Specify an explicit soft input mode to use for the window, as per
887     * {@link WindowManager.LayoutParams#softInputMode
888     * WindowManager.LayoutParams.softInputMode}.  Providing anything besides
889     * "unspecified" here will override the input mode the window would
890     * normally retrieve from its theme.
891     */
892    public void setSoftInputMode(int mode) {
893        final WindowManager.LayoutParams attrs = getAttributes();
894        if (mode != WindowManager.LayoutParams.SOFT_INPUT_STATE_UNSPECIFIED) {
895            attrs.softInputMode = mode;
896            mHasSoftInputMode = true;
897        } else {
898            mHasSoftInputMode = false;
899        }
900        dispatchWindowAttributesChanged(attrs);
901    }
902
903    /**
904     * Convenience function to set the flag bits as specified in flags, as
905     * per {@link #setFlags}.
906     * @param flags The flag bits to be set.
907     * @see #setFlags
908     * @see #clearFlags
909     */
910    public void addFlags(int flags) {
911        setFlags(flags, flags);
912    }
913
914    /** @hide */
915    public void addPrivateFlags(int flags) {
916        setPrivateFlags(flags, flags);
917    }
918
919    /**
920     * Convenience function to clear the flag bits as specified in flags, as
921     * per {@link #setFlags}.
922     * @param flags The flag bits to be cleared.
923     * @see #setFlags
924     * @see #addFlags
925     */
926    public void clearFlags(int flags) {
927        setFlags(0, flags);
928    }
929
930    /**
931     * Set the flags of the window, as per the
932     * {@link WindowManager.LayoutParams WindowManager.LayoutParams}
933     * flags.
934     *
935     * <p>Note that some flags must be set before the window decoration is
936     * created (by the first call to
937     * {@link #setContentView(View, android.view.ViewGroup.LayoutParams)} or
938     * {@link #getDecorView()}:
939     * {@link WindowManager.LayoutParams#FLAG_LAYOUT_IN_SCREEN} and
940     * {@link WindowManager.LayoutParams#FLAG_LAYOUT_INSET_DECOR}.  These
941     * will be set for you based on the {@link android.R.attr#windowIsFloating}
942     * attribute.
943     *
944     * @param flags The new window flags (see WindowManager.LayoutParams).
945     * @param mask Which of the window flag bits to modify.
946     * @see #addFlags
947     * @see #clearFlags
948     */
949    public void setFlags(int flags, int mask) {
950        final WindowManager.LayoutParams attrs = getAttributes();
951        attrs.flags = (attrs.flags&~mask) | (flags&mask);
952        mForcedWindowFlags |= mask;
953        dispatchWindowAttributesChanged(attrs);
954    }
955
956    private void setPrivateFlags(int flags, int mask) {
957        final WindowManager.LayoutParams attrs = getAttributes();
958        attrs.privateFlags = (attrs.privateFlags & ~mask) | (flags & mask);
959        dispatchWindowAttributesChanged(attrs);
960    }
961
962    /**
963     * {@hide}
964     */
965    protected void setNeedsMenuKey(int value) {
966        final WindowManager.LayoutParams attrs = getAttributes();
967        attrs.needsMenuKey = value;
968        dispatchWindowAttributesChanged(attrs);
969    }
970
971    /**
972     * {@hide}
973     */
974    protected void dispatchWindowAttributesChanged(WindowManager.LayoutParams attrs) {
975        if (mCallback != null) {
976            mCallback.onWindowAttributesChanged(attrs);
977        }
978    }
979
980    /**
981     * Set the amount of dim behind the window when using
982     * {@link WindowManager.LayoutParams#FLAG_DIM_BEHIND}.  This overrides
983     * the default dim amount of that is selected by the Window based on
984     * its theme.
985     *
986     * @param amount The new dim amount, from 0 for no dim to 1 for full dim.
987     */
988    public void setDimAmount(float amount) {
989        final WindowManager.LayoutParams attrs = getAttributes();
990        attrs.dimAmount = amount;
991        mHaveDimAmount = true;
992        dispatchWindowAttributesChanged(attrs);
993    }
994
995    /**
996     * Specify custom window attributes.  <strong>PLEASE NOTE:</strong> the
997     * layout params you give here should generally be from values previously
998     * retrieved with {@link #getAttributes()}; you probably do not want to
999     * blindly create and apply your own, since this will blow away any values
1000     * set by the framework that you are not interested in.
1001     *
1002     * @param a The new window attributes, which will completely override any
1003     *          current values.
1004     */
1005    public void setAttributes(WindowManager.LayoutParams a) {
1006        mWindowAttributes.copyFrom(a);
1007        dispatchWindowAttributesChanged(mWindowAttributes);
1008    }
1009
1010    /**
1011     * Retrieve the current window attributes associated with this panel.
1012     *
1013     * @return WindowManager.LayoutParams Either the existing window
1014     *         attributes object, or a freshly created one if there is none.
1015     */
1016    public final WindowManager.LayoutParams getAttributes() {
1017        return mWindowAttributes;
1018    }
1019
1020    /**
1021     * Return the window flags that have been explicitly set by the client,
1022     * so will not be modified by {@link #getDecorView}.
1023     */
1024    protected final int getForcedWindowFlags() {
1025        return mForcedWindowFlags;
1026    }
1027
1028    /**
1029     * Has the app specified their own soft input mode?
1030     */
1031    protected final boolean hasSoftInputMode() {
1032        return mHasSoftInputMode;
1033    }
1034
1035    /** @hide */
1036    public void setCloseOnTouchOutside(boolean close) {
1037        mCloseOnTouchOutside = close;
1038        mSetCloseOnTouchOutside = true;
1039    }
1040
1041    /** @hide */
1042    public void setCloseOnTouchOutsideIfNotSet(boolean close) {
1043        if (!mSetCloseOnTouchOutside) {
1044            mCloseOnTouchOutside = close;
1045            mSetCloseOnTouchOutside = true;
1046        }
1047    }
1048
1049    /** @hide */
1050    @SystemApi
1051    public void setDisableWallpaperTouchEvents(boolean disable) {
1052        setPrivateFlags(disable
1053                ? WindowManager.LayoutParams.PRIVATE_FLAG_DISABLE_WALLPAPER_TOUCH_EVENTS : 0,
1054                WindowManager.LayoutParams.PRIVATE_FLAG_DISABLE_WALLPAPER_TOUCH_EVENTS);
1055    }
1056
1057    /** @hide */
1058    public abstract void alwaysReadCloseOnTouchAttr();
1059
1060    /** @hide */
1061    public boolean shouldCloseOnTouch(Context context, MotionEvent event) {
1062        if (mCloseOnTouchOutside && event.getAction() == MotionEvent.ACTION_DOWN
1063                && isOutOfBounds(context, event) && peekDecorView() != null) {
1064            return true;
1065        }
1066        return false;
1067    }
1068
1069    private boolean isOutOfBounds(Context context, MotionEvent event) {
1070        final int x = (int) event.getX();
1071        final int y = (int) event.getY();
1072        final int slop = ViewConfiguration.get(context).getScaledWindowTouchSlop();
1073        final View decorView = getDecorView();
1074        return (x < -slop) || (y < -slop)
1075                || (x > (decorView.getWidth()+slop))
1076                || (y > (decorView.getHeight()+slop));
1077    }
1078
1079    /**
1080     * Enable extended screen features.  This must be called before
1081     * setContentView().  May be called as many times as desired as long as it
1082     * is before setContentView().  If not called, no extended features
1083     * will be available.  You can not turn off a feature once it is requested.
1084     * You canot use other title features with {@link #FEATURE_CUSTOM_TITLE}.
1085     *
1086     * @param featureId The desired features, defined as constants by Window.
1087     * @return The features that are now set.
1088     */
1089    public boolean requestFeature(int featureId) {
1090        final int flag = 1<<featureId;
1091        mFeatures |= flag;
1092        mLocalFeatures |= mContainer != null ? (flag&~mContainer.mFeatures) : flag;
1093        return (mFeatures&flag) != 0;
1094    }
1095
1096    /**
1097     * @hide Used internally to help resolve conflicting features.
1098     */
1099    protected void removeFeature(int featureId) {
1100        final int flag = 1<<featureId;
1101        mFeatures &= ~flag;
1102        mLocalFeatures &= ~(mContainer != null ? (flag&~mContainer.mFeatures) : flag);
1103    }
1104
1105    public final void makeActive() {
1106        if (mContainer != null) {
1107            if (mContainer.mActiveChild != null) {
1108                mContainer.mActiveChild.mIsActive = false;
1109            }
1110            mContainer.mActiveChild = this;
1111        }
1112        mIsActive = true;
1113        onActive();
1114    }
1115
1116    public final boolean isActive()
1117    {
1118        return mIsActive;
1119    }
1120
1121    /**
1122     * Finds a view that was identified by the id attribute from the XML that
1123     * was processed in {@link android.app.Activity#onCreate}.  This will
1124     * implicitly call {@link #getDecorView} for you, with all of the
1125     * associated side-effects.
1126     *
1127     * @return The view if found or null otherwise.
1128     */
1129    @Nullable
1130    public View findViewById(@IdRes int id) {
1131        return getDecorView().findViewById(id);
1132    }
1133
1134    /**
1135     * Convenience for
1136     * {@link #setContentView(View, android.view.ViewGroup.LayoutParams)}
1137     * to set the screen content from a layout resource.  The resource will be
1138     * inflated, adding all top-level views to the screen.
1139     *
1140     * @param layoutResID Resource ID to be inflated.
1141     * @see #setContentView(View, android.view.ViewGroup.LayoutParams)
1142     */
1143    public abstract void setContentView(@LayoutRes int layoutResID);
1144
1145    /**
1146     * Convenience for
1147     * {@link #setContentView(View, android.view.ViewGroup.LayoutParams)}
1148     * set the screen content to an explicit view.  This view is placed
1149     * directly into the screen's view hierarchy.  It can itself be a complex
1150     * view hierarhcy.
1151     *
1152     * @param view The desired content to display.
1153     * @see #setContentView(View, android.view.ViewGroup.LayoutParams)
1154     */
1155    public abstract void setContentView(View view);
1156
1157    /**
1158     * Set the screen content to an explicit view.  This view is placed
1159     * directly into the screen's view hierarchy.  It can itself be a complex
1160     * view hierarchy.
1161     *
1162     * <p>Note that calling this function "locks in" various characteristics
1163     * of the window that can not, from this point forward, be changed: the
1164     * features that have been requested with {@link #requestFeature(int)},
1165     * and certain window flags as described in {@link #setFlags(int, int)}.</p>
1166     *
1167     * <p>If {@link #FEATURE_CONTENT_TRANSITIONS} is set, the window's
1168     * TransitionManager will be used to animate content from the current
1169     * content View to view.</p>
1170     *
1171     * @param view The desired content to display.
1172     * @param params Layout parameters for the view.
1173     * @see #getTransitionManager()
1174     * @see #setTransitionManager(android.transition.TransitionManager)
1175     */
1176    public abstract void setContentView(View view, ViewGroup.LayoutParams params);
1177
1178    /**
1179     * Variation on
1180     * {@link #setContentView(View, android.view.ViewGroup.LayoutParams)}
1181     * to add an additional content view to the screen.  Added after any existing
1182     * ones in the screen -- existing views are NOT removed.
1183     *
1184     * @param view The desired content to display.
1185     * @param params Layout parameters for the view.
1186     */
1187    public abstract void addContentView(View view, ViewGroup.LayoutParams params);
1188
1189    /**
1190     * Remove the view that was used as the screen content.
1191     *
1192     * @hide
1193     */
1194    public abstract void clearContentView();
1195
1196    /**
1197     * Return the view in this Window that currently has focus, or null if
1198     * there are none.  Note that this does not look in any containing
1199     * Window.
1200     *
1201     * @return View The current View with focus or null.
1202     */
1203    @Nullable
1204    public abstract View getCurrentFocus();
1205
1206    /**
1207     * Quick access to the {@link LayoutInflater} instance that this Window
1208     * retrieved from its Context.
1209     *
1210     * @return LayoutInflater The shared LayoutInflater.
1211     */
1212    @NonNull
1213    public abstract LayoutInflater getLayoutInflater();
1214
1215    public abstract void setTitle(CharSequence title);
1216
1217    @Deprecated
1218    public abstract void setTitleColor(@ColorInt int textColor);
1219
1220    public abstract void openPanel(int featureId, KeyEvent event);
1221
1222    public abstract void closePanel(int featureId);
1223
1224    public abstract void togglePanel(int featureId, KeyEvent event);
1225
1226    public abstract void invalidatePanelMenu(int featureId);
1227
1228    public abstract boolean performPanelShortcut(int featureId,
1229                                                 int keyCode,
1230                                                 KeyEvent event,
1231                                                 int flags);
1232    public abstract boolean performPanelIdentifierAction(int featureId,
1233                                                 int id,
1234                                                 int flags);
1235
1236    public abstract void closeAllPanels();
1237
1238    public abstract boolean performContextMenuIdentifierAction(int id, int flags);
1239
1240    /**
1241     * Should be called when the configuration is changed.
1242     *
1243     * @param newConfig The new configuration.
1244     */
1245    public abstract void onConfigurationChanged(Configuration newConfig);
1246
1247    /**
1248     * Sets the window elevation.
1249     * <p>
1250     * Changes to this property take effect immediately and will cause the
1251     * window surface to be recreated. This is an expensive operation and as a
1252     * result, this property should not be animated.
1253     *
1254     * @param elevation The window elevation.
1255     * @see View#setElevation(float)
1256     * @see android.R.styleable#Window_windowElevation
1257     */
1258    public void setElevation(float elevation) {}
1259
1260    /**
1261     * Gets the window elevation.
1262     *
1263     * @hide
1264     */
1265    public float getElevation() {
1266        return 0.0f;
1267    }
1268
1269    /**
1270     * Sets whether window content should be clipped to the outline of the
1271     * window background.
1272     *
1273     * @param clipToOutline Whether window content should be clipped to the
1274     *                      outline of the window background.
1275     * @see View#setClipToOutline(boolean)
1276     * @see android.R.styleable#Window_windowClipToOutline
1277     */
1278    public void setClipToOutline(boolean clipToOutline) {}
1279
1280    /**
1281     * Change the background of this window to a Drawable resource. Setting the
1282     * background to null will make the window be opaque. To make the window
1283     * transparent, you can use an empty drawable (for instance a ColorDrawable
1284     * with the color 0 or the system drawable android:drawable/empty.)
1285     *
1286     * @param resId The resource identifier of a drawable resource which will
1287     *              be installed as the new background.
1288     */
1289    public void setBackgroundDrawableResource(@DrawableRes int resId) {
1290        setBackgroundDrawable(mContext.getDrawable(resId));
1291    }
1292
1293    /**
1294     * Change the background of this window to a custom Drawable. Setting the
1295     * background to null will make the window be opaque. To make the window
1296     * transparent, you can use an empty drawable (for instance a ColorDrawable
1297     * with the color 0 or the system drawable android:drawable/empty.)
1298     *
1299     * @param drawable The new Drawable to use for this window's background.
1300     */
1301    public abstract void setBackgroundDrawable(Drawable drawable);
1302
1303    /**
1304     * Set the value for a drawable feature of this window, from a resource
1305     * identifier.  You must have called requestFeature(featureId) before
1306     * calling this function.
1307     *
1308     * @see android.content.res.Resources#getDrawable(int)
1309     *
1310     * @param featureId The desired drawable feature to change, defined as a
1311     * constant by Window.
1312     * @param resId Resource identifier of the desired image.
1313     */
1314    public abstract void setFeatureDrawableResource(int featureId, @DrawableRes int resId);
1315
1316    /**
1317     * Set the value for a drawable feature of this window, from a URI. You
1318     * must have called requestFeature(featureId) before calling this
1319     * function.
1320     *
1321     * <p>The only URI currently supported is "content:", specifying an image
1322     * in a content provider.
1323     *
1324     * @see android.widget.ImageView#setImageURI
1325     *
1326     * @param featureId The desired drawable feature to change. Features are
1327     * constants defined by Window.
1328     * @param uri The desired URI.
1329     */
1330    public abstract void setFeatureDrawableUri(int featureId, Uri uri);
1331
1332    /**
1333     * Set an explicit Drawable value for feature of this window. You must
1334     * have called requestFeature(featureId) before calling this function.
1335     *
1336     * @param featureId The desired drawable feature to change. Features are
1337     *                  constants defined by Window.
1338     * @param drawable A Drawable object to display.
1339     */
1340    public abstract void setFeatureDrawable(int featureId, Drawable drawable);
1341
1342    /**
1343     * Set a custom alpha value for the given drawable feature, controlling how
1344     * much the background is visible through it.
1345     *
1346     * @param featureId The desired drawable feature to change. Features are
1347     *                  constants defined by Window.
1348     * @param alpha The alpha amount, 0 is completely transparent and 255 is
1349     *              completely opaque.
1350     */
1351    public abstract void setFeatureDrawableAlpha(int featureId, int alpha);
1352
1353    /**
1354     * Set the integer value for a feature. The range of the value depends on
1355     * the feature being set. For {@link #FEATURE_PROGRESS}, it should go from
1356     * 0 to 10000. At 10000 the progress is complete and the indicator hidden.
1357     *
1358     * @param featureId The desired feature to change. Features are constants
1359     *                  defined by Window.
1360     * @param value The value for the feature. The interpretation of this
1361     *              value is feature-specific.
1362     */
1363    public abstract void setFeatureInt(int featureId, int value);
1364
1365    /**
1366     * Request that key events come to this activity. Use this if your
1367     * activity has no views with focus, but the activity still wants
1368     * a chance to process key events.
1369     */
1370    public abstract void takeKeyEvents(boolean get);
1371
1372    /**
1373     * Used by custom windows, such as Dialog, to pass the key press event
1374     * further down the view hierarchy. Application developers should
1375     * not need to implement or call this.
1376     *
1377     */
1378    public abstract boolean superDispatchKeyEvent(KeyEvent event);
1379
1380    /**
1381     * Used by custom windows, such as Dialog, to pass the key shortcut press event
1382     * further down the view hierarchy. Application developers should
1383     * not need to implement or call this.
1384     *
1385     */
1386    public abstract boolean superDispatchKeyShortcutEvent(KeyEvent event);
1387
1388    /**
1389     * Used by custom windows, such as Dialog, to pass the touch screen event
1390     * further down the view hierarchy. Application developers should
1391     * not need to implement or call this.
1392     *
1393     */
1394    public abstract boolean superDispatchTouchEvent(MotionEvent event);
1395
1396    /**
1397     * Used by custom windows, such as Dialog, to pass the trackball event
1398     * further down the view hierarchy. Application developers should
1399     * not need to implement or call this.
1400     *
1401     */
1402    public abstract boolean superDispatchTrackballEvent(MotionEvent event);
1403
1404    /**
1405     * Used by custom windows, such as Dialog, to pass the generic motion event
1406     * further down the view hierarchy. Application developers should
1407     * not need to implement or call this.
1408     *
1409     */
1410    public abstract boolean superDispatchGenericMotionEvent(MotionEvent event);
1411
1412    /**
1413     * Retrieve the top-level window decor view (containing the standard
1414     * window frame/decorations and the client's content inside of that), which
1415     * can be added as a window to the window manager.
1416     *
1417     * <p><em>Note that calling this function for the first time "locks in"
1418     * various window characteristics as described in
1419     * {@link #setContentView(View, android.view.ViewGroup.LayoutParams)}.</em></p>
1420     *
1421     * @return Returns the top-level window decor view.
1422     */
1423    public abstract View getDecorView();
1424
1425    /**
1426     * Retrieve the current decor view, but only if it has already been created;
1427     * otherwise returns null.
1428     *
1429     * @return Returns the top-level window decor or null.
1430     * @see #getDecorView
1431     */
1432    public abstract View peekDecorView();
1433
1434    public abstract Bundle saveHierarchyState();
1435
1436    public abstract void restoreHierarchyState(Bundle savedInstanceState);
1437
1438    protected abstract void onActive();
1439
1440    /**
1441     * Return the feature bits that are enabled.  This is the set of features
1442     * that were given to requestFeature(), and are being handled by this
1443     * Window itself or its container.  That is, it is the set of
1444     * requested features that you can actually use.
1445     *
1446     * <p>To do: add a public version of this API that allows you to check for
1447     * features by their feature ID.
1448     *
1449     * @return int The feature bits.
1450     */
1451    protected final int getFeatures()
1452    {
1453        return mFeatures;
1454    }
1455
1456    /**
1457     * Return the feature bits set by default on a window.
1458     * @param context The context used to access resources
1459     */
1460    public static int getDefaultFeatures(Context context) {
1461        int features = 0;
1462
1463        final Resources res = context.getResources();
1464        if (res.getBoolean(com.android.internal.R.bool.config_defaultWindowFeatureOptionsPanel)) {
1465            features |= 1 << FEATURE_OPTIONS_PANEL;
1466        }
1467
1468        if (res.getBoolean(com.android.internal.R.bool.config_defaultWindowFeatureContextMenu)) {
1469            features |= 1 << FEATURE_CONTEXT_MENU;
1470        }
1471
1472        return features;
1473    }
1474
1475    /**
1476     * Query for the availability of a certain feature.
1477     *
1478     * @param feature The feature ID to check
1479     * @return true if the feature is enabled, false otherwise.
1480     */
1481    public boolean hasFeature(int feature) {
1482        return (getFeatures() & (1 << feature)) != 0;
1483    }
1484
1485    /**
1486     * Return the feature bits that are being implemented by this Window.
1487     * This is the set of features that were given to requestFeature(), and are
1488     * being handled by only this Window itself, not by its containers.
1489     *
1490     * @return int The feature bits.
1491     */
1492    protected final int getLocalFeatures()
1493    {
1494        return mLocalFeatures;
1495    }
1496
1497    /**
1498     * Set the default format of window, as per the PixelFormat types.  This
1499     * is the format that will be used unless the client specifies in explicit
1500     * format with setFormat();
1501     *
1502     * @param format The new window format (see PixelFormat).
1503     *
1504     * @see #setFormat
1505     * @see PixelFormat
1506     */
1507    protected void setDefaultWindowFormat(int format) {
1508        mDefaultWindowFormat = format;
1509        if (!mHaveWindowFormat) {
1510            final WindowManager.LayoutParams attrs = getAttributes();
1511            attrs.format = format;
1512            dispatchWindowAttributesChanged(attrs);
1513        }
1514    }
1515
1516    /** @hide */
1517    protected boolean haveDimAmount() {
1518        return mHaveDimAmount;
1519    }
1520
1521    public abstract void setChildDrawable(int featureId, Drawable drawable);
1522
1523    public abstract void setChildInt(int featureId, int value);
1524
1525    /**
1526     * Is a keypress one of the defined shortcut keys for this window.
1527     * @param keyCode the key code from {@link android.view.KeyEvent} to check.
1528     * @param event the {@link android.view.KeyEvent} to use to help check.
1529     */
1530    public abstract boolean isShortcutKey(int keyCode, KeyEvent event);
1531
1532    /**
1533     * @see android.app.Activity#setVolumeControlStream(int)
1534     */
1535    public abstract void setVolumeControlStream(int streamType);
1536
1537    /**
1538     * @see android.app.Activity#getVolumeControlStream()
1539     */
1540    public abstract int getVolumeControlStream();
1541
1542    /**
1543     * Sets a {@link MediaController} to send media keys and volume changes to.
1544     * If set, this should be preferred for all media keys and volume requests
1545     * sent to this window.
1546     *
1547     * @param controller The controller for the session which should receive
1548     *            media keys and volume changes.
1549     * @see android.app.Activity#setMediaController(android.media.session.MediaController)
1550     */
1551    public void setMediaController(MediaController controller) {
1552    }
1553
1554    /**
1555     * Gets the {@link MediaController} that was previously set.
1556     *
1557     * @return The controller which should receive events.
1558     * @see #setMediaController(android.media.session.MediaController)
1559     * @see android.app.Activity#getMediaController()
1560     */
1561    public MediaController getMediaController() {
1562        return null;
1563    }
1564
1565    /**
1566     * Set extra options that will influence the UI for this window.
1567     * @param uiOptions Flags specifying extra options for this window.
1568     */
1569    public void setUiOptions(int uiOptions) { }
1570
1571    /**
1572     * Set extra options that will influence the UI for this window.
1573     * Only the bits filtered by mask will be modified.
1574     * @param uiOptions Flags specifying extra options for this window.
1575     * @param mask Flags specifying which options should be modified. Others will remain unchanged.
1576     */
1577    public void setUiOptions(int uiOptions, int mask) { }
1578
1579    /**
1580     * Set the primary icon for this window.
1581     *
1582     * @param resId resource ID of a drawable to set
1583     */
1584    public void setIcon(@DrawableRes int resId) { }
1585
1586    /**
1587     * Set the default icon for this window.
1588     * This will be overridden by any other icon set operation which could come from the
1589     * theme or another explicit set.
1590     *
1591     * @hide
1592     */
1593    public void setDefaultIcon(@DrawableRes int resId) { }
1594
1595    /**
1596     * Set the logo for this window. A logo is often shown in place of an
1597     * {@link #setIcon(int) icon} but is generally wider and communicates window title information
1598     * as well.
1599     *
1600     * @param resId resource ID of a drawable to set
1601     */
1602    public void setLogo(@DrawableRes int resId) { }
1603
1604    /**
1605     * Set the default logo for this window.
1606     * This will be overridden by any other logo set operation which could come from the
1607     * theme or another explicit set.
1608     *
1609     * @hide
1610     */
1611    public void setDefaultLogo(@DrawableRes int resId) { }
1612
1613    /**
1614     * Set focus locally. The window should have the
1615     * {@link WindowManager.LayoutParams#FLAG_LOCAL_FOCUS_MODE} flag set already.
1616     * @param hasFocus Whether this window has focus or not.
1617     * @param inTouchMode Whether this window is in touch mode or not.
1618     */
1619    public void setLocalFocus(boolean hasFocus, boolean inTouchMode) { }
1620
1621    /**
1622     * Inject an event to window locally.
1623     * @param event A key or touch event to inject to this window.
1624     */
1625    public void injectInputEvent(InputEvent event) { }
1626
1627    /**
1628     * Retrieve the {@link TransitionManager} responsible for  for default transitions
1629     * in this window. Requires {@link #FEATURE_CONTENT_TRANSITIONS}.
1630     *
1631     * <p>This method will return non-null after content has been initialized (e.g. by using
1632     * {@link #setContentView}) if {@link #FEATURE_CONTENT_TRANSITIONS} has been granted.</p>
1633     *
1634     * @return This window's content TransitionManager or null if none is set.
1635     * @attr ref android.R.styleable#Window_windowContentTransitionManager
1636     */
1637    public TransitionManager getTransitionManager() {
1638        return null;
1639    }
1640
1641    /**
1642     * Set the {@link TransitionManager} to use for default transitions in this window.
1643     * Requires {@link #FEATURE_CONTENT_TRANSITIONS}.
1644     *
1645     * @param tm The TransitionManager to use for scene changes.
1646     * @attr ref android.R.styleable#Window_windowContentTransitionManager
1647     */
1648    public void setTransitionManager(TransitionManager tm) {
1649        throw new UnsupportedOperationException();
1650    }
1651
1652    /**
1653     * Retrieve the {@link Scene} representing this window's current content.
1654     * Requires {@link #FEATURE_CONTENT_TRANSITIONS}.
1655     *
1656     * <p>This method will return null if the current content is not represented by a Scene.</p>
1657     *
1658     * @return Current Scene being shown or null
1659     */
1660    public Scene getContentScene() {
1661        return null;
1662    }
1663
1664    /**
1665     * Sets the Transition that will be used to move Views into the initial scene. The entering
1666     * Views will be those that are regular Views or ViewGroups that have
1667     * {@link ViewGroup#isTransitionGroup} return true. Typical Transitions will extend
1668     * {@link android.transition.Visibility} as entering is governed by changing visibility from
1669     * {@link View#INVISIBLE} to {@link View#VISIBLE}. If <code>transition</code> is null,
1670     * entering Views will remain unaffected.
1671     *
1672     * @param transition The Transition to use to move Views into the initial Scene.
1673     * @attr ref android.R.styleable#Window_windowEnterTransition
1674     */
1675    public void setEnterTransition(Transition transition) {}
1676
1677    /**
1678     * Sets the Transition that will be used to move Views out of the scene when the Window is
1679     * preparing to close, for example after a call to
1680     * {@link android.app.Activity#finishAfterTransition()}. The exiting
1681     * Views will be those that are regular Views or ViewGroups that have
1682     * {@link ViewGroup#isTransitionGroup} return true. Typical Transitions will extend
1683     * {@link android.transition.Visibility} as entering is governed by changing visibility from
1684     * {@link View#VISIBLE} to {@link View#INVISIBLE}. If <code>transition</code> is null,
1685     * entering Views will remain unaffected. If nothing is set, the default will be to
1686     * use the same value as set in {@link #setEnterTransition(android.transition.Transition)}.
1687     *
1688     * @param transition The Transition to use to move Views out of the Scene when the Window
1689     *                   is preparing to close.
1690     * @attr ref android.R.styleable#Window_windowReturnTransition
1691     */
1692    public void setReturnTransition(Transition transition) {}
1693
1694    /**
1695     * Sets the Transition that will be used to move Views out of the scene when starting a
1696     * new Activity. The exiting Views will be those that are regular Views or ViewGroups that
1697     * have {@link ViewGroup#isTransitionGroup} return true. Typical Transitions will extend
1698     * {@link android.transition.Visibility} as exiting is governed by changing visibility
1699     * from {@link View#VISIBLE} to {@link View#INVISIBLE}. If transition is null, the views will
1700     * remain unaffected. Requires {@link #FEATURE_ACTIVITY_TRANSITIONS}.
1701     *
1702     * @param transition The Transition to use to move Views out of the scene when calling a
1703     *                   new Activity.
1704     * @attr ref android.R.styleable#Window_windowExitTransition
1705     */
1706    public void setExitTransition(Transition transition) {}
1707
1708    /**
1709     * Sets the Transition that will be used to move Views in to the scene when returning from
1710     * a previously-started Activity. The entering Views will be those that are regular Views
1711     * or ViewGroups that have {@link ViewGroup#isTransitionGroup} return true. Typical Transitions
1712     * will extend {@link android.transition.Visibility} as exiting is governed by changing
1713     * visibility from {@link View#VISIBLE} to {@link View#INVISIBLE}. If transition is null,
1714     * the views will remain unaffected. If nothing is set, the default will be to use the same
1715     * transition as {@link #setExitTransition(android.transition.Transition)}.
1716     * Requires {@link #FEATURE_ACTIVITY_TRANSITIONS}.
1717     *
1718     * @param transition The Transition to use to move Views into the scene when reentering from a
1719     *                   previously-started Activity.
1720     * @attr ref android.R.styleable#Window_windowReenterTransition
1721     */
1722    public void setReenterTransition(Transition transition) {}
1723
1724    /**
1725     * Returns the transition used to move Views into the initial scene. The entering
1726     * Views will be those that are regular Views or ViewGroups that have
1727     * {@link ViewGroup#isTransitionGroup} return true. Typical Transitions will extend
1728     * {@link android.transition.Visibility} as entering is governed by changing visibility from
1729     * {@link View#INVISIBLE} to {@link View#VISIBLE}. If <code>transition</code> is null,
1730     * entering Views will remain unaffected.  Requires {@link #FEATURE_ACTIVITY_TRANSITIONS}.
1731     *
1732     * @return the Transition to use to move Views into the initial Scene.
1733     * @attr ref android.R.styleable#Window_windowEnterTransition
1734     */
1735    public Transition getEnterTransition() { return null; }
1736
1737    /**
1738     * Returns he Transition that will be used to move Views out of the scene when the Window is
1739     * preparing to close, for example after a call to
1740     * {@link android.app.Activity#finishAfterTransition()}. The exiting
1741     * Views will be those that are regular Views or ViewGroups that have
1742     * {@link ViewGroup#isTransitionGroup} return true. Typical Transitions will extend
1743     * {@link android.transition.Visibility} as entering is governed by changing visibility from
1744     * {@link View#VISIBLE} to {@link View#INVISIBLE}.
1745     *
1746     * @return The Transition to use to move Views out of the Scene when the Window
1747     *         is preparing to close.
1748     * @attr ref android.R.styleable#Window_windowReturnTransition
1749     */
1750    public Transition getReturnTransition() { return null; }
1751
1752    /**
1753     * Returns the Transition that will be used to move Views out of the scene when starting a
1754     * new Activity. The exiting Views will be those that are regular Views or ViewGroups that
1755     * have {@link ViewGroup#isTransitionGroup} return true. Typical Transitions will extend
1756     * {@link android.transition.Visibility} as exiting is governed by changing visibility
1757     * from {@link View#VISIBLE} to {@link View#INVISIBLE}. If transition is null, the views will
1758     * remain unaffected. Requires {@link #FEATURE_ACTIVITY_TRANSITIONS}.
1759     *
1760     * @return the Transition to use to move Views out of the scene when calling a
1761     * new Activity.
1762     * @attr ref android.R.styleable#Window_windowExitTransition
1763     */
1764    public Transition getExitTransition() { return null; }
1765
1766    /**
1767     * Returns the Transition that will be used to move Views in to the scene when returning from
1768     * a previously-started Activity. The entering Views will be those that are regular Views
1769     * or ViewGroups that have {@link ViewGroup#isTransitionGroup} return true. Typical Transitions
1770     * will extend {@link android.transition.Visibility} as exiting is governed by changing
1771     * visibility from {@link View#VISIBLE} to {@link View#INVISIBLE}.
1772     * Requires {@link #FEATURE_ACTIVITY_TRANSITIONS}.
1773     *
1774     * @return The Transition to use to move Views into the scene when reentering from a
1775     *         previously-started Activity.
1776     * @attr ref android.R.styleable#Window_windowReenterTransition
1777     */
1778    public Transition getReenterTransition() { return null; }
1779
1780    /**
1781     * Sets the Transition that will be used for shared elements transferred into the content
1782     * Scene. Typical Transitions will affect size and location, such as
1783     * {@link android.transition.ChangeBounds}. A null
1784     * value will cause transferred shared elements to blink to the final position.
1785     * Requires {@link #FEATURE_ACTIVITY_TRANSITIONS}.
1786     *
1787     * @param transition The Transition to use for shared elements transferred into the content
1788     *                   Scene.
1789     * @attr ref android.R.styleable#Window_windowSharedElementEnterTransition
1790     */
1791    public void setSharedElementEnterTransition(Transition transition) {}
1792
1793    /**
1794     * Sets the Transition that will be used for shared elements transferred back to a
1795     * calling Activity. Typical Transitions will affect size and location, such as
1796     * {@link android.transition.ChangeBounds}. A null
1797     * value will cause transferred shared elements to blink to the final position.
1798     * If no value is set, the default will be to use the same value as
1799     * {@link #setSharedElementEnterTransition(android.transition.Transition)}.
1800     * Requires {@link #FEATURE_ACTIVITY_TRANSITIONS}.
1801     *
1802     * @param transition The Transition to use for shared elements transferred out of the content
1803     *                   Scene.
1804     * @attr ref android.R.styleable#Window_windowSharedElementReturnTransition
1805     */
1806    public void setSharedElementReturnTransition(Transition transition) {}
1807
1808    /**
1809     * Returns the Transition that will be used for shared elements transferred into the content
1810     * Scene. Requires {@link #FEATURE_ACTIVITY_TRANSITIONS}.
1811     *
1812     * @return Transition to use for sharend elements transferred into the content Scene.
1813     * @attr ref android.R.styleable#Window_windowSharedElementEnterTransition
1814     */
1815    public Transition getSharedElementEnterTransition() { return null; }
1816
1817    /**
1818     * Returns the Transition that will be used for shared elements transferred back to a
1819     * calling Activity. Requires {@link #FEATURE_ACTIVITY_TRANSITIONS}.
1820     *
1821     * @return Transition to use for sharend elements transferred into the content Scene.
1822     * @attr ref android.R.styleable#Window_windowSharedElementReturnTransition
1823     */
1824    public Transition getSharedElementReturnTransition() { return null; }
1825
1826    /**
1827     * Sets the Transition that will be used for shared elements after starting a new Activity
1828     * before the shared elements are transferred to the called Activity. If the shared elements
1829     * must animate during the exit transition, this Transition should be used. Upon completion,
1830     * the shared elements may be transferred to the started Activity.
1831     * Requires {@link #FEATURE_ACTIVITY_TRANSITIONS}.
1832     *
1833     * @param transition The Transition to use for shared elements in the launching Window
1834     *                   prior to transferring to the launched Activity's Window.
1835     * @attr ref android.R.styleable#Window_windowSharedElementExitTransition
1836     */
1837    public void setSharedElementExitTransition(Transition transition) {}
1838
1839    /**
1840     * Sets the Transition that will be used for shared elements reentering from a started
1841     * Activity after it has returned the shared element to it start location. If no value
1842     * is set, this will default to
1843     * {@link #setSharedElementExitTransition(android.transition.Transition)}.
1844     * Requires {@link #FEATURE_ACTIVITY_TRANSITIONS}.
1845     *
1846     * @param transition The Transition to use for shared elements in the launching Window
1847     *                   after the shared element has returned to the Window.
1848     * @attr ref android.R.styleable#Window_windowSharedElementReenterTransition
1849     */
1850    public void setSharedElementReenterTransition(Transition transition) {}
1851
1852    /**
1853     * Returns the Transition to use for shared elements in the launching Window prior
1854     * to transferring to the launched Activity's Window.
1855     * Requires {@link #FEATURE_ACTIVITY_TRANSITIONS}.
1856     *
1857     * @return the Transition to use for shared elements in the launching Window prior
1858     * to transferring to the launched Activity's Window.
1859     * @attr ref android.R.styleable#Window_windowSharedElementExitTransition
1860     */
1861    public Transition getSharedElementExitTransition() { return null; }
1862
1863    /**
1864     * Returns the Transition that will be used for shared elements reentering from a started
1865     * Activity after it has returned the shared element to it start location.
1866     * Requires {@link #FEATURE_ACTIVITY_TRANSITIONS}.
1867     *
1868     * @return the Transition that will be used for shared elements reentering from a started
1869     * Activity after it has returned the shared element to it start location.
1870     * @attr ref android.R.styleable#Window_windowSharedElementReenterTransition
1871     */
1872    public Transition getSharedElementReenterTransition() { return null; }
1873
1874    /**
1875     * Controls how the transition set in
1876     * {@link #setEnterTransition(android.transition.Transition)} overlaps with the exit
1877     * transition of the calling Activity. When true, the transition will start as soon as possible.
1878     * When false, the transition will wait until the remote exiting transition completes before
1879     * starting.
1880     *
1881     * @param allow true to start the enter transition when possible or false to
1882     *              wait until the exiting transition completes.
1883     * @attr ref android.R.styleable#Window_windowAllowEnterTransitionOverlap
1884     */
1885    public void setAllowEnterTransitionOverlap(boolean allow) {}
1886
1887    /**
1888     * Returns how the transition set in
1889     * {@link #setEnterTransition(android.transition.Transition)} overlaps with the exit
1890     * transition of the calling Activity. When true, the transition will start as soon as possible.
1891     * When false, the transition will wait until the remote exiting transition completes before
1892     * starting.
1893     *
1894     * @return true when the enter transition should start as soon as possible or false to
1895     * when it should wait until the exiting transition completes.
1896     * @attr ref android.R.styleable#Window_windowAllowEnterTransitionOverlap
1897     */
1898    public boolean getAllowEnterTransitionOverlap() { return true; }
1899
1900    /**
1901     * Controls how the transition set in
1902     * {@link #setExitTransition(android.transition.Transition)} overlaps with the exit
1903     * transition of the called Activity when reentering after if finishes. When true,
1904     * the transition will start as soon as possible. When false, the transition will wait
1905     * until the called Activity's exiting transition completes before starting.
1906     *
1907     * @param allow true to start the transition when possible or false to wait until the
1908     *              called Activity's exiting transition completes.
1909     * @attr ref android.R.styleable#Window_windowAllowReturnTransitionOverlap
1910     */
1911    public void setAllowReturnTransitionOverlap(boolean allow) {}
1912
1913    /**
1914     * Returns how the transition set in
1915     * {@link #setExitTransition(android.transition.Transition)} overlaps with the exit
1916     * transition of the called Activity when reentering after if finishes. When true,
1917     * the transition will start as soon as possible. When false, the transition will wait
1918     * until the called Activity's exiting transition completes before starting.
1919     *
1920     * @return true when the transition should start when possible or false when it should wait
1921     * until the called Activity's exiting transition completes.
1922     * @attr ref android.R.styleable#Window_windowAllowReturnTransitionOverlap
1923     */
1924    public boolean getAllowReturnTransitionOverlap() { return true; }
1925
1926    /**
1927     * Returns the duration, in milliseconds, of the window background fade
1928     * when transitioning into or away from an Activity when called with an Activity Transition.
1929     * <p>When executing the enter transition, the background starts transparent
1930     * and fades in. This requires {@link #FEATURE_ACTIVITY_TRANSITIONS}. The default is
1931     * 300 milliseconds.</p>
1932     *
1933     * @return The duration of the window background fade to opaque during enter transition.
1934     * @see #getEnterTransition()
1935     * @attr ref android.R.styleable#Window_windowTransitionBackgroundFadeDuration
1936     */
1937    public long getTransitionBackgroundFadeDuration() { return 0; }
1938
1939    /**
1940     * Sets the duration, in milliseconds, of the window background fade
1941     * when transitioning into or away from an Activity when called with an Activity Transition.
1942     * <p>When executing the enter transition, the background starts transparent
1943     * and fades in. This requires {@link #FEATURE_ACTIVITY_TRANSITIONS}. The default is
1944     * 300 milliseconds.</p>
1945     *
1946     * @param fadeDurationMillis The duration of the window background fade to or from opaque
1947     *                           during enter transition.
1948     * @see #setEnterTransition(android.transition.Transition)
1949     * @attr ref android.R.styleable#Window_windowTransitionBackgroundFadeDuration
1950     */
1951    public void setTransitionBackgroundFadeDuration(long fadeDurationMillis) { }
1952
1953    /**
1954     * Returns <code>true</code> when shared elements should use an Overlay during
1955     * shared element transitions or <code>false</code> when they should animate as
1956     * part of the normal View hierarchy. The default value is true.
1957     *
1958     * @return <code>true</code> when shared elements should use an Overlay during
1959     * shared element transitions or <code>false</code> when they should animate as
1960     * part of the normal View hierarchy.
1961     * @attr ref android.R.styleable#Window_windowSharedElementsUseOverlay
1962     */
1963    public boolean getSharedElementsUseOverlay() { return true; }
1964
1965    /**
1966     * Sets whether or not shared elements should use an Overlay during shared element transitions.
1967     * The default value is true.
1968     *
1969     * @param sharedElementsUseOverlay <code>true</code> indicates that shared elements should
1970     *                                 be transitioned with an Overlay or <code>false</code>
1971     *                                 to transition within the normal View hierarchy.
1972     * @attr ref android.R.styleable#Window_windowSharedElementsUseOverlay
1973     */
1974    public void setSharedElementsUseOverlay(boolean sharedElementsUseOverlay) { }
1975
1976    /**
1977     * @return the color of the status bar.
1978     */
1979    @ColorInt
1980    public abstract int getStatusBarColor();
1981
1982    /**
1983     * Sets the color of the status bar to {@code color}.
1984     *
1985     * For this to take effect,
1986     * the window must be drawing the system bar backgrounds with
1987     * {@link android.view.WindowManager.LayoutParams#FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS} and
1988     * {@link android.view.WindowManager.LayoutParams#FLAG_TRANSLUCENT_STATUS} must not be set.
1989     *
1990     * If {@code color} is not opaque, consider setting
1991     * {@link android.view.View#SYSTEM_UI_FLAG_LAYOUT_STABLE} and
1992     * {@link android.view.View#SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN}.
1993     * <p>
1994     * The transitionName for the view background will be "android:status:background".
1995     * </p>
1996     */
1997    public abstract void setStatusBarColor(@ColorInt int color);
1998
1999    /**
2000     * @return the color of the navigation bar.
2001     */
2002    @ColorInt
2003    public abstract int getNavigationBarColor();
2004
2005    /**
2006     * Sets the color of the navigation bar to {@param color}.
2007     *
2008     * For this to take effect,
2009     * the window must be drawing the system bar backgrounds with
2010     * {@link android.view.WindowManager.LayoutParams#FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS} and
2011     * {@link android.view.WindowManager.LayoutParams#FLAG_TRANSLUCENT_NAVIGATION} must not be set.
2012     *
2013     * If {@param color} is not opaque, consider setting
2014     * {@link android.view.View#SYSTEM_UI_FLAG_LAYOUT_STABLE} and
2015     * {@link android.view.View#SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION}.
2016     * <p>
2017     * The transitionName for the view background will be "android:navigation:background".
2018     * </p>
2019     */
2020    public abstract void setNavigationBarColor(@ColorInt int color);
2021
2022    /** @hide */
2023    public void setTheme(int resId) {
2024    }
2025}
2026