WindowState.java revision 812d2ca475e88d4e52870a4eeeb096a411f0f077
1/*
2 * Copyright (C) 2011 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 com.android.server.wm;
18
19import static android.view.WindowManager.LayoutParams.FIRST_SUB_WINDOW;
20import static android.view.WindowManager.LayoutParams.FLAG_COMPATIBLE_WINDOW;
21import static android.view.WindowManager.LayoutParams.LAST_SUB_WINDOW;
22import static android.view.WindowManager.LayoutParams.TYPE_INPUT_METHOD;
23import static android.view.WindowManager.LayoutParams.TYPE_INPUT_METHOD_DIALOG;
24import static android.view.WindowManager.LayoutParams.TYPE_WALLPAPER;
25import static android.view.WindowManager.LayoutParams.TYPE_BASE_APPLICATION;
26import static android.view.WindowManager.LayoutParams.LAST_APPLICATION_WINDOW;
27import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION_STARTING;
28
29import com.android.server.input.InputWindowHandle;
30
31import android.content.Context;
32import android.content.res.Configuration;
33import android.graphics.Matrix;
34import android.graphics.PixelFormat;
35import android.graphics.Rect;
36import android.graphics.RectF;
37import android.graphics.Region;
38import android.os.IBinder;
39import android.os.Process;
40import android.os.RemoteException;
41import android.os.UserHandle;
42import android.util.Slog;
43import android.view.DisplayInfo;
44import android.view.Gravity;
45import android.view.IApplicationToken;
46import android.view.IWindow;
47import android.view.InputChannel;
48import android.view.View;
49import android.view.ViewTreeObserver;
50import android.view.WindowManager;
51import android.view.WindowManagerPolicy;
52
53import java.io.PrintWriter;
54import java.util.ArrayList;
55
56class WindowList extends ArrayList<WindowState> {
57}
58
59/**
60 * A window in the window manager.
61 */
62final class WindowState implements WindowManagerPolicy.WindowState {
63    static final String TAG = "WindowState";
64
65    static final boolean DEBUG_VISIBILITY = WindowManagerService.DEBUG_VISIBILITY;
66    static final boolean SHOW_TRANSACTIONS = WindowManagerService.SHOW_TRANSACTIONS;
67    static final boolean SHOW_LIGHT_TRANSACTIONS = WindowManagerService.SHOW_LIGHT_TRANSACTIONS;
68    static final boolean SHOW_SURFACE_ALLOC = WindowManagerService.SHOW_SURFACE_ALLOC;
69
70    final WindowManagerService mService;
71    final WindowManagerPolicy mPolicy;
72    final Context mContext;
73    final Session mSession;
74    final IWindow mClient;
75    WindowToken mToken;
76    WindowToken mRootToken;
77    AppWindowToken mAppToken;
78    AppWindowToken mTargetAppToken;
79
80    // mAttrs.flags is tested in animation without being locked. If the bits tested are ever
81    // modified they will need to be locked.
82    final WindowManager.LayoutParams mAttrs = new WindowManager.LayoutParams();
83    final DeathRecipient mDeathRecipient;
84    final WindowState mAttachedWindow;
85    final ArrayList<WindowState> mChildWindows = new ArrayList<WindowState>();
86    final int mBaseLayer;
87    final int mSubLayer;
88    final boolean mLayoutAttached;
89    final boolean mIsImWindow;
90    final boolean mIsWallpaper;
91    final boolean mIsFloatingLayer;
92    int mSeq;
93    boolean mEnforceSizeCompat;
94    int mViewVisibility;
95    int mSystemUiVisibility;
96    boolean mPolicyVisibility = true;
97    boolean mPolicyVisibilityAfterAnim = true;
98    boolean mAppFreezing;
99    boolean mAttachedHidden;    // is our parent window hidden?
100    boolean mWallpaperVisible;  // for wallpaper, what was last vis report?
101
102    /**
103     * The window size that was requested by the application.  These are in
104     * the application's coordinate space (without compatibility scale applied).
105     */
106    int mRequestedWidth;
107    int mRequestedHeight;
108    int mLastRequestedWidth;
109    int mLastRequestedHeight;
110
111    int mLayer;
112    boolean mHaveFrame;
113    boolean mObscured;
114    boolean mTurnOnScreen;
115
116    int mLayoutSeq = -1;
117
118    Configuration mConfiguration = null;
119
120    /**
121     * Actual frame shown on-screen (may be modified by animation).  These
122     * are in the screen's coordinate space (WITH the compatibility scale
123     * applied).
124     */
125    final RectF mShownFrame = new RectF();
126
127    /**
128     * Insets that determine the actually visible area.  These are in the application's
129     * coordinate space (without compatibility scale applied).
130     */
131    final Rect mVisibleInsets = new Rect();
132    final Rect mLastVisibleInsets = new Rect();
133    boolean mVisibleInsetsChanged;
134
135    /**
136     * Insets that are covered by system windows (such as the status bar) and
137     * transient docking windows (such as the IME).  These are in the application's
138     * coordinate space (without compatibility scale applied).
139     */
140    final Rect mContentInsets = new Rect();
141    final Rect mLastContentInsets = new Rect();
142    boolean mContentInsetsChanged;
143
144    /**
145     * Set to true if we are waiting for this window to receive its
146     * given internal insets before laying out other windows based on it.
147     */
148    boolean mGivenInsetsPending;
149
150    /**
151     * These are the content insets that were given during layout for
152     * this window, to be applied to windows behind it.
153     */
154    final Rect mGivenContentInsets = new Rect();
155
156    /**
157     * These are the visible insets that were given during layout for
158     * this window, to be applied to windows behind it.
159     */
160    final Rect mGivenVisibleInsets = new Rect();
161
162    /**
163     * This is the given touchable area relative to the window frame, or null if none.
164     */
165    final Region mGivenTouchableRegion = new Region();
166
167    /**
168     * Flag indicating whether the touchable region should be adjusted by
169     * the visible insets; if false the area outside the visible insets is
170     * NOT touchable, so we must use those to adjust the frame during hit
171     * tests.
172     */
173    int mTouchableInsets = ViewTreeObserver.InternalInsetsInfo.TOUCHABLE_INSETS_FRAME;
174
175    /**
176     * This is rectangle of the window's surface that is not covered by
177     * system decorations.
178     */
179    final Rect mSystemDecorRect = new Rect();
180    final Rect mLastSystemDecorRect = new Rect();
181
182    // Current transformation being applied.
183    float mGlobalScale=1;
184    float mInvGlobalScale=1;
185    float mHScale=1, mVScale=1;
186    float mLastHScale=1, mLastVScale=1;
187    final Matrix mTmpMatrix = new Matrix();
188
189    // "Real" frame that the application sees, in display coordinate space.
190    final Rect mFrame = new Rect();
191    final Rect mLastFrame = new Rect();
192    // Frame that is scaled to the application's coordinate space when in
193    // screen size compatibility mode.
194    final Rect mCompatFrame = new Rect();
195
196    final Rect mContainingFrame = new Rect();
197    final Rect mDisplayFrame = new Rect();
198    final Rect mContentFrame = new Rect();
199    final Rect mParentFrame = new Rect();
200    final Rect mVisibleFrame = new Rect();
201
202    boolean mContentChanged;
203
204    // If a window showing a wallpaper: the requested offset for the
205    // wallpaper; if a wallpaper window: the currently applied offset.
206    float mWallpaperX = -1;
207    float mWallpaperY = -1;
208
209    // If a window showing a wallpaper: what fraction of the offset
210    // range corresponds to a full virtual screen.
211    float mWallpaperXStep = -1;
212    float mWallpaperYStep = -1;
213
214    // Wallpaper windows: pixels offset based on above variables.
215    int mXOffset;
216    int mYOffset;
217
218    // This is set after IWindowSession.relayout() has been called at
219    // least once for the window.  It allows us to detect the situation
220    // where we don't yet have a surface, but should have one soon, so
221    // we can give the window focus before waiting for the relayout.
222    boolean mRelayoutCalled;
223
224    // If the application has called relayout() with changes that can
225    // impact its window's size, we need to perform a layout pass on it
226    // even if it is not currently visible for layout.  This is set
227    // when in that case until the layout is done.
228    boolean mLayoutNeeded;
229
230    // Currently running an exit animation?
231    boolean mExiting;
232
233    // Currently on the mDestroySurface list?
234    boolean mDestroying;
235
236    // Completely remove from window manager after exit animation?
237    boolean mRemoveOnExit;
238
239    // Set when the orientation is changing and this window has not yet
240    // been updated for the new orientation.
241    boolean mOrientationChanging;
242
243    // Is this window now (or just being) removed?
244    boolean mRemoved;
245
246    // Temp for keeping track of windows that have been removed when
247    // rebuilding window list.
248    boolean mRebuilding;
249
250    // Input channel and input window handle used by the input dispatcher.
251    final InputWindowHandle mInputWindowHandle;
252    InputChannel mInputChannel;
253
254    // Used to improve performance of toString()
255    String mStringNameCache;
256    CharSequence mLastTitle;
257    boolean mWasPaused;
258
259    final WindowStateAnimator mWinAnimator;
260
261    boolean mHasSurface = false;
262
263    DisplayContent  mDisplayContent;
264
265    // UserId and appId of the owner. Don't display windows of non-current user.
266    final int mOwnerUid;
267
268    WindowState(WindowManagerService service, Session s, IWindow c, WindowToken token,
269           WindowState attachedWindow, int seq, WindowManager.LayoutParams a,
270           int viewVisibility, final DisplayContent displayContent) {
271        mService = service;
272        mSession = s;
273        mClient = c;
274        mToken = token;
275        mOwnerUid = s.mUid;
276        mAttrs.copyFrom(a);
277        mViewVisibility = viewVisibility;
278        mDisplayContent = displayContent;
279        mPolicy = mService.mPolicy;
280        mContext = mService.mContext;
281        DeathRecipient deathRecipient = new DeathRecipient();
282        mSeq = seq;
283        mEnforceSizeCompat = (mAttrs.flags & FLAG_COMPATIBLE_WINDOW) != 0;
284        if (WindowManagerService.localLOGV) Slog.v(
285            TAG, "Window " + this + " client=" + c.asBinder()
286            + " token=" + token + " (" + mAttrs.token + ")");
287        try {
288            c.asBinder().linkToDeath(deathRecipient, 0);
289        } catch (RemoteException e) {
290            mDeathRecipient = null;
291            mAttachedWindow = null;
292            mLayoutAttached = false;
293            mIsImWindow = false;
294            mIsWallpaper = false;
295            mIsFloatingLayer = false;
296            mBaseLayer = 0;
297            mSubLayer = 0;
298            mInputWindowHandle = null;
299            mWinAnimator = null;
300            return;
301        }
302        mDeathRecipient = deathRecipient;
303
304        if ((mAttrs.type >= FIRST_SUB_WINDOW &&
305                mAttrs.type <= LAST_SUB_WINDOW)) {
306            // The multiplier here is to reserve space for multiple
307            // windows in the same type layer.
308            mBaseLayer = mPolicy.windowTypeToLayerLw(
309                    attachedWindow.mAttrs.type) * WindowManagerService.TYPE_LAYER_MULTIPLIER
310                    + WindowManagerService.TYPE_LAYER_OFFSET;
311            mSubLayer = mPolicy.subWindowTypeToLayerLw(a.type);
312            mAttachedWindow = attachedWindow;
313            if (WindowManagerService.DEBUG_ADD_REMOVE) Slog.v(TAG, "Adding " + this + " to " + mAttachedWindow);
314            mAttachedWindow.mChildWindows.add(this);
315            mLayoutAttached = mAttrs.type !=
316                    WindowManager.LayoutParams.TYPE_APPLICATION_ATTACHED_DIALOG;
317            mIsImWindow = attachedWindow.mAttrs.type == TYPE_INPUT_METHOD
318                    || attachedWindow.mAttrs.type == TYPE_INPUT_METHOD_DIALOG;
319            mIsWallpaper = attachedWindow.mAttrs.type == TYPE_WALLPAPER;
320            mIsFloatingLayer = mIsImWindow || mIsWallpaper;
321        } else {
322            // The multiplier here is to reserve space for multiple
323            // windows in the same type layer.
324            mBaseLayer = mPolicy.windowTypeToLayerLw(a.type)
325                    * WindowManagerService.TYPE_LAYER_MULTIPLIER
326                    + WindowManagerService.TYPE_LAYER_OFFSET;
327            mSubLayer = 0;
328            mAttachedWindow = null;
329            mLayoutAttached = false;
330            mIsImWindow = mAttrs.type == TYPE_INPUT_METHOD
331                    || mAttrs.type == TYPE_INPUT_METHOD_DIALOG;
332            mIsWallpaper = mAttrs.type == TYPE_WALLPAPER;
333            mIsFloatingLayer = mIsImWindow || mIsWallpaper;
334        }
335
336        WindowState appWin = this;
337        while (appWin.mAttachedWindow != null) {
338            appWin = appWin.mAttachedWindow;
339        }
340        WindowToken appToken = appWin.mToken;
341        while (appToken.appWindowToken == null) {
342            WindowToken parent = mService.mTokenMap.get(appToken.token);
343            if (parent == null || appToken == parent) {
344                break;
345            }
346            appToken = parent;
347        }
348        mRootToken = appToken;
349        mAppToken = appToken.appWindowToken;
350
351        mWinAnimator = new WindowStateAnimator(this);
352        mWinAnimator.mAlpha = a.alpha;
353
354        mRequestedWidth = 0;
355        mRequestedHeight = 0;
356        mLastRequestedWidth = 0;
357        mLastRequestedHeight = 0;
358        mXOffset = 0;
359        mYOffset = 0;
360        mLayer = 0;
361        mInputWindowHandle = new InputWindowHandle(
362                mAppToken != null ? mAppToken.mInputApplicationHandle : null, this,
363                displayContent.getDisplayId());
364    }
365
366    void attach() {
367        if (WindowManagerService.localLOGV) Slog.v(
368            TAG, "Attaching " + this + " token=" + mToken
369            + ", list=" + mToken.windows);
370        mSession.windowAddedLocked();
371    }
372
373    @Override
374    public void computeFrameLw(Rect pf, Rect df, Rect cf, Rect vf) {
375        mHaveFrame = true;
376
377        final Rect container = mContainingFrame;
378        container.set(pf);
379
380        final Rect display = mDisplayFrame;
381        display.set(df);
382
383        final int pw = container.right - container.left;
384        final int ph = container.bottom - container.top;
385
386        int w,h;
387        if ((mAttrs.flags & WindowManager.LayoutParams.FLAG_SCALED) != 0) {
388            if (mAttrs.width < 0) {
389                w = pw;
390            } else if (mEnforceSizeCompat) {
391                w = (int)(mAttrs.width * mGlobalScale + .5f);
392            } else {
393                w = mAttrs.width;
394            }
395            if (mAttrs.height < 0) {
396                h = ph;
397            } else if (mEnforceSizeCompat) {
398                h = (int)(mAttrs.height * mGlobalScale + .5f);
399            } else {
400                h = mAttrs.height;
401            }
402        } else {
403            if (mAttrs.width == WindowManager.LayoutParams.MATCH_PARENT) {
404                w = pw;
405            } else if (mEnforceSizeCompat) {
406                w = (int)(mRequestedWidth * mGlobalScale + .5f);
407            } else {
408                w = mRequestedWidth;
409            }
410            if (mAttrs.height == WindowManager.LayoutParams.MATCH_PARENT) {
411                h = ph;
412            } else if (mEnforceSizeCompat) {
413                h = (int)(mRequestedHeight * mGlobalScale + .5f);
414            } else {
415                h = mRequestedHeight;
416            }
417        }
418
419        if (!mParentFrame.equals(pf)) {
420            //Slog.i(TAG, "Window " + this + " content frame from " + mParentFrame
421            //        + " to " + pf);
422            mParentFrame.set(pf);
423            mContentChanged = true;
424        }
425        if (mRequestedWidth != mLastRequestedWidth || mRequestedHeight != mLastRequestedHeight) {
426            mLastRequestedWidth = mRequestedWidth;
427            mLastRequestedHeight = mRequestedHeight;
428            mContentChanged = true;
429        }
430
431        final Rect content = mContentFrame;
432        content.set(cf);
433
434        final Rect visible = mVisibleFrame;
435        visible.set(vf);
436
437        final Rect frame = mFrame;
438        final int fw = frame.width();
439        final int fh = frame.height();
440
441        //System.out.println("In: w=" + w + " h=" + h + " container=" +
442        //                   container + " x=" + mAttrs.x + " y=" + mAttrs.y);
443
444        float x, y;
445        if (mEnforceSizeCompat) {
446            x = mAttrs.x * mGlobalScale;
447            y = mAttrs.y * mGlobalScale;
448        } else {
449            x = mAttrs.x;
450            y = mAttrs.y;
451        }
452
453        Gravity.apply(mAttrs.gravity, w, h, container,
454                (int) (x + mAttrs.horizontalMargin * pw),
455                (int) (y + mAttrs.verticalMargin * ph), frame);
456
457        //System.out.println("Out: " + mFrame);
458
459        // Now make sure the window fits in the overall display.
460        Gravity.applyDisplay(mAttrs.gravity, df, frame);
461
462        // Make sure the system, content and visible frames are inside of the
463        // final window frame.
464        if (content.left < frame.left) content.left = frame.left;
465        if (content.top < frame.top) content.top = frame.top;
466        if (content.right > frame.right) content.right = frame.right;
467        if (content.bottom > frame.bottom) content.bottom = frame.bottom;
468        if (visible.left < frame.left) visible.left = frame.left;
469        if (visible.top < frame.top) visible.top = frame.top;
470        if (visible.right > frame.right) visible.right = frame.right;
471        if (visible.bottom > frame.bottom) visible.bottom = frame.bottom;
472
473        final Rect contentInsets = mContentInsets;
474        contentInsets.left = content.left-frame.left;
475        contentInsets.top = content.top-frame.top;
476        contentInsets.right = frame.right-content.right;
477        contentInsets.bottom = frame.bottom-content.bottom;
478
479        final Rect visibleInsets = mVisibleInsets;
480        visibleInsets.left = visible.left-frame.left;
481        visibleInsets.top = visible.top-frame.top;
482        visibleInsets.right = frame.right-visible.right;
483        visibleInsets.bottom = frame.bottom-visible.bottom;
484
485        mCompatFrame.set(frame);
486        if (mEnforceSizeCompat) {
487            // If there is a size compatibility scale being applied to the
488            // window, we need to apply this to its insets so that they are
489            // reported to the app in its coordinate space.
490            contentInsets.scale(mInvGlobalScale);
491            visibleInsets.scale(mInvGlobalScale);
492
493            // Also the scaled frame that we report to the app needs to be
494            // adjusted to be in its coordinate space.
495            mCompatFrame.scale(mInvGlobalScale);
496        }
497
498        if (mIsWallpaper && (fw != frame.width() || fh != frame.height())) {
499            final DisplayInfo displayInfo = mDisplayContent.getDisplayInfo();
500            mService.updateWallpaperOffsetLocked(this, displayInfo.appWidth, displayInfo.appHeight,
501                    false);
502        }
503
504        if (WindowManagerService.localLOGV) {
505            //if ("com.google.android.youtube".equals(mAttrs.packageName)
506            //        && mAttrs.type == WindowManager.LayoutParams.TYPE_APPLICATION_PANEL) {
507                Slog.v(TAG, "Resolving (mRequestedWidth="
508                        + mRequestedWidth + ", mRequestedheight="
509                        + mRequestedHeight + ") to" + " (pw=" + pw + ", ph=" + ph
510                        + "): frame=" + mFrame.toShortString()
511                        + " ci=" + contentInsets.toShortString()
512                        + " vi=" + visibleInsets.toShortString());
513            //}
514        }
515    }
516
517    MagnificationSpec getWindowMagnificationSpecLocked() {
518        MagnificationSpec spec = mDisplayContent.mMagnificationSpec;
519        if (spec != null && !spec.isNop()) {
520            if (mAttachedWindow != null) {
521                if (!mPolicy.canMagnifyWindowLw(mAttachedWindow.mAttrs)) {
522                    return null;
523                }
524            }
525            if (!mPolicy.canMagnifyWindowLw(mAttrs)) {
526                return null;
527            }
528        }
529        return spec;
530    }
531
532    @Override
533    public Rect getFrameLw() {
534        return mFrame;
535    }
536
537    @Override
538    public RectF getShownFrameLw() {
539        return mShownFrame;
540    }
541
542    @Override
543    public Rect getDisplayFrameLw() {
544        return mDisplayFrame;
545    }
546
547    @Override
548    public Rect getContentFrameLw() {
549        return mContentFrame;
550    }
551
552    @Override
553    public Rect getVisibleFrameLw() {
554        return mVisibleFrame;
555    }
556
557    @Override
558    public boolean getGivenInsetsPendingLw() {
559        return mGivenInsetsPending;
560    }
561
562    @Override
563    public Rect getGivenContentInsetsLw() {
564        return mGivenContentInsets;
565    }
566
567    @Override
568    public Rect getGivenVisibleInsetsLw() {
569        return mGivenVisibleInsets;
570    }
571
572    @Override
573    public WindowManager.LayoutParams getAttrs() {
574        return mAttrs;
575    }
576
577    @Override
578    public boolean getNeedsMenuLw(WindowManagerPolicy.WindowState bottom) {
579        int index = -1;
580        WindowState ws = this;
581        WindowList windows = getWindowList();
582        while (true) {
583            if ((ws.mAttrs.privateFlags
584                    & WindowManager.LayoutParams.PRIVATE_FLAG_SET_NEEDS_MENU_KEY) != 0) {
585                return (ws.mAttrs.flags & WindowManager.LayoutParams.FLAG_NEEDS_MENU_KEY) != 0;
586            }
587            // If we reached the bottom of the range of windows we are considering,
588            // assume no menu is needed.
589            if (ws == bottom) {
590                return false;
591            }
592            // The current window hasn't specified whether menu key is needed;
593            // look behind it.
594            // First, we may need to determine the starting position.
595            if (index < 0) {
596                index = windows.indexOf(ws);
597            }
598            index--;
599            if (index < 0) {
600                return false;
601            }
602            ws = windows.get(index);
603        }
604    }
605
606    @Override
607    public int getSystemUiVisibility() {
608        return mSystemUiVisibility;
609    }
610
611    @Override
612    public int getSurfaceLayer() {
613        return mLayer;
614    }
615
616    @Override
617    public IApplicationToken getAppToken() {
618        return mAppToken != null ? mAppToken.appToken : null;
619    }
620
621    public int getDisplayId() {
622        return mDisplayContent.getDisplayId();
623    }
624
625    public long getInputDispatchingTimeoutNanos() {
626        return mAppToken != null
627                ? mAppToken.inputDispatchingTimeoutNanos
628                : WindowManagerService.DEFAULT_INPUT_DISPATCHING_TIMEOUT_NANOS;
629    }
630
631    public boolean hasAppShownWindows() {
632        return mAppToken != null && (mAppToken.firstWindowDrawn || mAppToken.startingDisplayed);
633    }
634
635    boolean isIdentityMatrix(float dsdx, float dtdx, float dsdy, float dtdy) {
636        if (dsdx < .99999f || dsdx > 1.00001f) return false;
637        if (dtdy < .99999f || dtdy > 1.00001f) return false;
638        if (dtdx < -.000001f || dtdx > .000001f) return false;
639        if (dsdy < -.000001f || dsdy > .000001f) return false;
640        return true;
641    }
642
643    void prelayout() {
644        if (mEnforceSizeCompat) {
645            mGlobalScale = mService.mCompatibleScreenScale;
646            mInvGlobalScale = 1/mGlobalScale;
647        } else {
648            mGlobalScale = mInvGlobalScale = 1;
649        }
650    }
651
652    /**
653     * Is this window visible?  It is not visible if there is no
654     * surface, or we are in the process of running an exit animation
655     * that will remove the surface, or its app token has been hidden.
656     */
657    public boolean isVisibleLw() {
658        final AppWindowToken atoken = mAppToken;
659        return mHasSurface && mPolicyVisibility && !mAttachedHidden
660                && (atoken == null || !atoken.hiddenRequested)
661                && !mExiting && !mDestroying;
662    }
663
664    /**
665     * Like {@link #isVisibleLw}, but also counts a window that is currently
666     * "hidden" behind the keyguard as visible.  This allows us to apply
667     * things like window flags that impact the keyguard.
668     * XXX I am starting to think we need to have ANOTHER visibility flag
669     * for this "hidden behind keyguard" state rather than overloading
670     * mPolicyVisibility.  Ungh.
671     */
672    public boolean isVisibleOrBehindKeyguardLw() {
673        if (mRootToken.waitingToShow &&
674                mService.mNextAppTransition != WindowManagerPolicy.TRANSIT_UNSET) {
675            return false;
676        }
677        final AppWindowToken atoken = mAppToken;
678        final boolean animating = atoken != null
679                ? (atoken.mAppAnimator.animation != null) : false;
680        return mHasSurface && !mDestroying && !mExiting
681                && (atoken == null ? mPolicyVisibility : !atoken.hiddenRequested)
682                && ((!mAttachedHidden && mViewVisibility == View.VISIBLE
683                                && !mRootToken.hidden)
684                        || mWinAnimator.mAnimation != null || animating);
685    }
686
687    /**
688     * Is this window visible, ignoring its app token?  It is not visible
689     * if there is no surface, or we are in the process of running an exit animation
690     * that will remove the surface.
691     */
692    public boolean isWinVisibleLw() {
693        final AppWindowToken atoken = mAppToken;
694        return mHasSurface && mPolicyVisibility && !mAttachedHidden
695                && (atoken == null || !atoken.hiddenRequested || atoken.mAppAnimator.animating)
696                && !mExiting && !mDestroying;
697    }
698
699    /**
700     * The same as isVisible(), but follows the current hidden state of
701     * the associated app token, not the pending requested hidden state.
702     */
703    boolean isVisibleNow() {
704        return mHasSurface && mPolicyVisibility && !mAttachedHidden
705                && !mRootToken.hidden && !mExiting && !mDestroying;
706    }
707
708    /**
709     * Can this window possibly be a drag/drop target?  The test here is
710     * a combination of the above "visible now" with the check that the
711     * Input Manager uses when discarding windows from input consideration.
712     */
713    boolean isPotentialDragTarget() {
714        return isVisibleNow() && !mRemoved
715                && mInputChannel != null && mInputWindowHandle != null;
716    }
717
718    /**
719     * Same as isVisible(), but we also count it as visible between the
720     * call to IWindowSession.add() and the first relayout().
721     */
722    boolean isVisibleOrAdding() {
723        final AppWindowToken atoken = mAppToken;
724        return (mHasSurface || (!mRelayoutCalled && mViewVisibility == View.VISIBLE))
725                && mPolicyVisibility && !mAttachedHidden
726                && (atoken == null || !atoken.hiddenRequested)
727                && !mExiting && !mDestroying;
728    }
729
730    /**
731     * Is this window currently on-screen?  It is on-screen either if it
732     * is visible or it is currently running an animation before no longer
733     * being visible.
734     */
735    boolean isOnScreen() {
736        if (!mHasSurface || !mPolicyVisibility || mDestroying) {
737            return false;
738        }
739        final AppWindowToken atoken = mAppToken;
740        if (atoken != null) {
741            return ((!mAttachedHidden && !atoken.hiddenRequested)
742                            || mWinAnimator.mAnimation != null || atoken.mAppAnimator.animation != null);
743        }
744        return !mAttachedHidden || mWinAnimator.mAnimation != null;
745    }
746
747    /**
748     * Like isOnScreen(), but we don't return true if the window is part
749     * of a transition that has not yet been started.
750     */
751    boolean isReadyForDisplay() {
752        if (mRootToken.waitingToShow &&
753                mService.mNextAppTransition != WindowManagerPolicy.TRANSIT_UNSET) {
754            return false;
755        }
756        return mHasSurface && mPolicyVisibility && !mDestroying
757                && ((!mAttachedHidden && mViewVisibility == View.VISIBLE
758                                && !mRootToken.hidden)
759                        || mWinAnimator.mAnimation != null
760                        || ((mAppToken != null) && (mAppToken.mAppAnimator.animation != null)));
761    }
762
763    /**
764     * Like isReadyForDisplay(), but ignores any force hiding of the window due
765     * to the keyguard.
766     */
767    boolean isReadyForDisplayIgnoringKeyguard() {
768        if (mRootToken.waitingToShow &&
769                mService.mNextAppTransition != WindowManagerPolicy.TRANSIT_UNSET) {
770            return false;
771        }
772        final AppWindowToken atoken = mAppToken;
773        if (atoken == null && !mPolicyVisibility) {
774            // If this is not an app window, and the policy has asked to force
775            // hide, then we really do want to hide.
776            return false;
777        }
778        return mHasSurface && !mDestroying
779                && ((!mAttachedHidden && mViewVisibility == View.VISIBLE
780                                && !mRootToken.hidden)
781                        || mWinAnimator.mAnimation != null
782                        || ((atoken != null) && (atoken.mAppAnimator.animation != null)
783                                && !mWinAnimator.isDummyAnimation()));
784    }
785
786    /**
787     * Like isOnScreen, but returns false if the surface hasn't yet
788     * been drawn.
789     */
790    public boolean isDisplayedLw() {
791        final AppWindowToken atoken = mAppToken;
792        return isDrawnLw() && mPolicyVisibility
793            && ((!mAttachedHidden &&
794                    (atoken == null || !atoken.hiddenRequested))
795                    || mWinAnimator.mAnimating);
796    }
797
798    /**
799     * Return true if this window (or a window it is attached to, but not
800     * considering its app token) is currently animating.
801     */
802    public boolean isAnimatingLw() {
803        return mWinAnimator.mAnimation != null;
804    }
805
806    @Override
807    public boolean isGoneForLayoutLw() {
808        final AppWindowToken atoken = mAppToken;
809        return mViewVisibility == View.GONE
810                || !mRelayoutCalled
811                || (atoken == null && mRootToken.hidden)
812                || (atoken != null && (atoken.hiddenRequested || atoken.hidden))
813                || mAttachedHidden
814                || mExiting || mDestroying;
815    }
816
817    /**
818     * Returns true if the window has a surface that it has drawn a
819     * complete UI in to.
820     */
821    public boolean isDrawnLw() {
822        return mHasSurface && !mDestroying &&
823                (mWinAnimator.mDrawState == WindowStateAnimator.READY_TO_SHOW
824                || mWinAnimator.mDrawState == WindowStateAnimator.HAS_DRAWN);
825    }
826
827    /**
828     * Return true if the window is opaque and fully drawn.  This indicates
829     * it may obscure windows behind it.
830     */
831    boolean isOpaqueDrawn() {
832        return (mAttrs.format == PixelFormat.OPAQUE
833                        || mAttrs.type == TYPE_WALLPAPER)
834                && isDrawnLw() && mWinAnimator.mAnimation == null
835                && (mAppToken == null || mAppToken.mAppAnimator.animation == null);
836    }
837
838    /**
839     * Return whether this window is wanting to have a translation
840     * animation applied to it for an in-progress move.  (Only makes
841     * sense to call from performLayoutAndPlaceSurfacesLockedInner().)
842     */
843    boolean shouldAnimateMove() {
844        return mContentChanged && !mExiting && !mWinAnimator.mLastHidden && mService.okToDisplay()
845                && (mFrame.top != mLastFrame.top
846                        || mFrame.left != mLastFrame.left)
847                && (mAttachedWindow == null || !mAttachedWindow.shouldAnimateMove());
848    }
849
850    boolean isFullscreen(int screenWidth, int screenHeight) {
851        return mFrame.left <= 0 && mFrame.top <= 0 &&
852                mFrame.right >= screenWidth && mFrame.bottom >= screenHeight;
853    }
854
855    boolean isConfigChanged() {
856        return mConfiguration != mService.mCurConfiguration
857                && (mConfiguration == null
858                        || (mConfiguration.diff(mService.mCurConfiguration) != 0));
859    }
860
861    boolean isConfigDiff(int mask) {
862        return mConfiguration != mService.mCurConfiguration
863                && mConfiguration != null
864                && (mConfiguration.diff(mService.mCurConfiguration) & mask) != 0;
865    }
866
867    void removeLocked() {
868        disposeInputChannel();
869
870        if (mAttachedWindow != null) {
871            if (WindowManagerService.DEBUG_ADD_REMOVE) Slog.v(TAG, "Removing " + this + " from " + mAttachedWindow);
872            mAttachedWindow.mChildWindows.remove(this);
873        }
874        mWinAnimator.destroyDeferredSurfaceLocked();
875        mWinAnimator.destroySurfaceLocked();
876        mSession.windowRemovedLocked();
877        try {
878            mClient.asBinder().unlinkToDeath(mDeathRecipient, 0);
879        } catch (RuntimeException e) {
880            // Ignore if it has already been removed (usually because
881            // we are doing this as part of processing a death note.)
882        }
883    }
884
885    void setInputChannel(InputChannel inputChannel) {
886        if (mInputChannel != null) {
887            throw new IllegalStateException("Window already has an input channel.");
888        }
889
890        mInputChannel = inputChannel;
891        mInputWindowHandle.inputChannel = inputChannel;
892    }
893
894    void disposeInputChannel() {
895        if (mInputChannel != null) {
896            mService.mInputManager.unregisterInputChannel(mInputChannel);
897
898            mInputChannel.dispose();
899            mInputChannel = null;
900        }
901
902        mInputWindowHandle.inputChannel = null;
903    }
904
905    private class DeathRecipient implements IBinder.DeathRecipient {
906        public void binderDied() {
907            try {
908                synchronized(mService.mWindowMap) {
909                    WindowState win = mService.windowForClientLocked(mSession, mClient, false);
910                    Slog.i(TAG, "WIN DEATH: " + win);
911                    if (win != null) {
912                        mService.removeWindowLocked(mSession, win);
913                    }
914                }
915            } catch (IllegalArgumentException ex) {
916                // This will happen if the window has already been
917                // removed.
918            }
919        }
920    }
921
922    /** Returns true if this window desires key events.
923     * TODO(cmautner): Is this the same as {@link WindowManagerService#canBeImeTarget}
924     */
925    public final boolean canReceiveKeys() {
926        return     isVisibleOrAdding()
927                && (mViewVisibility == View.VISIBLE)
928                && ((mAttrs.flags & WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE) == 0);
929    }
930
931    @Override
932    public boolean hasDrawnLw() {
933        return mWinAnimator.mDrawState == WindowStateAnimator.HAS_DRAWN;
934    }
935
936    @Override
937    public boolean showLw(boolean doAnimation) {
938        return showLw(doAnimation, true);
939    }
940
941    boolean showLw(boolean doAnimation, boolean requestAnim) {
942        if (isOtherUsersAppWindow()) {
943            Slog.w(TAG, "Current user " + mService.mCurrentUserId + " trying to display "
944                    + this + ", type " + mAttrs.type + ", belonging to " + mOwnerUid);
945            return false;
946        }
947        if (mPolicyVisibility && mPolicyVisibilityAfterAnim) {
948            // Already showing.
949            return false;
950        }
951        if (DEBUG_VISIBILITY) Slog.v(TAG, "Policy visibility true: " + this);
952        if (doAnimation) {
953            if (DEBUG_VISIBILITY) Slog.v(TAG, "doAnimation: mPolicyVisibility="
954                    + mPolicyVisibility + " mAnimation=" + mWinAnimator.mAnimation);
955            if (!mService.okToDisplay()) {
956                doAnimation = false;
957            } else if (mPolicyVisibility && mWinAnimator.mAnimation == null) {
958                // Check for the case where we are currently visible and
959                // not animating; we do not want to do animation at such a
960                // point to become visible when we already are.
961                doAnimation = false;
962            }
963        }
964        mPolicyVisibility = true;
965        mPolicyVisibilityAfterAnim = true;
966        if (doAnimation) {
967            mWinAnimator.applyAnimationLocked(WindowManagerPolicy.TRANSIT_ENTER, true);
968        }
969        if (requestAnim) {
970            mService.updateLayoutToAnimationLocked();
971        }
972        return true;
973    }
974
975    @Override
976    public boolean hideLw(boolean doAnimation) {
977        return hideLw(doAnimation, true);
978    }
979
980    boolean hideLw(boolean doAnimation, boolean requestAnim) {
981        if (doAnimation) {
982            if (!mService.okToDisplay()) {
983                doAnimation = false;
984            }
985        }
986        boolean current = doAnimation ? mPolicyVisibilityAfterAnim
987                : mPolicyVisibility;
988        if (!current) {
989            // Already hiding.
990            return false;
991        }
992        if (doAnimation) {
993            mWinAnimator.applyAnimationLocked(WindowManagerPolicy.TRANSIT_EXIT, false);
994            if (mWinAnimator.mAnimation == null) {
995                doAnimation = false;
996            }
997        }
998        if (doAnimation) {
999            mPolicyVisibilityAfterAnim = false;
1000        } else {
1001            if (DEBUG_VISIBILITY) Slog.v(TAG, "Policy visibility false: " + this);
1002            mPolicyVisibilityAfterAnim = false;
1003            mPolicyVisibility = false;
1004            // Window is no longer visible -- make sure if we were waiting
1005            // for it to be displayed before enabling the display, that
1006            // we allow the display to be enabled now.
1007            mService.enableScreenIfNeededLocked();
1008            if (mService.mCurrentFocus == this) {
1009                mService.mFocusMayChange = true;
1010            }
1011        }
1012        if (requestAnim) {
1013            mService.updateLayoutToAnimationLocked();
1014        }
1015        return true;
1016    }
1017
1018    @Override
1019    public boolean isAlive() {
1020        return mClient.asBinder().isBinderAlive();
1021    }
1022
1023    @Override
1024    public boolean isDefaultDisplay() {
1025        return mDisplayContent.isDefaultDisplay;
1026    }
1027
1028    boolean isOtherUsersAppWindow() {
1029        final int type = mAttrs.type;
1030        if ((UserHandle.getUserId(mOwnerUid) != mService.mCurrentUserId)
1031                && (mOwnerUid != Process.SYSTEM_UID)
1032                && (type >= TYPE_BASE_APPLICATION) && (type <= LAST_APPLICATION_WINDOW)
1033                && (type != TYPE_APPLICATION_STARTING)) {
1034            return true;
1035        }
1036        return false;
1037    }
1038
1039    private static void applyInsets(Region outRegion, Rect frame, Rect inset) {
1040        outRegion.set(
1041                frame.left + inset.left, frame.top + inset.top,
1042                frame.right - inset.right, frame.bottom - inset.bottom);
1043    }
1044
1045    public void getTouchableRegion(Region outRegion) {
1046        final Rect frame = mFrame;
1047        switch (mTouchableInsets) {
1048            default:
1049            case ViewTreeObserver.InternalInsetsInfo.TOUCHABLE_INSETS_FRAME:
1050                outRegion.set(frame);
1051                break;
1052            case ViewTreeObserver.InternalInsetsInfo.TOUCHABLE_INSETS_CONTENT:
1053                applyInsets(outRegion, frame, mGivenContentInsets);
1054                break;
1055            case ViewTreeObserver.InternalInsetsInfo.TOUCHABLE_INSETS_VISIBLE:
1056                applyInsets(outRegion, frame, mGivenVisibleInsets);
1057                break;
1058            case ViewTreeObserver.InternalInsetsInfo.TOUCHABLE_INSETS_REGION: {
1059                final Region givenTouchableRegion = mGivenTouchableRegion;
1060                outRegion.set(givenTouchableRegion);
1061                outRegion.translate(frame.left, frame.top);
1062                break;
1063            }
1064        }
1065    }
1066
1067    WindowList getWindowList() {
1068        return mDisplayContent.getWindowList();
1069    }
1070
1071    void dump(PrintWriter pw, String prefix, boolean dumpAll) {
1072        pw.print(prefix); pw.print("mDisplayId="); pw.print(mDisplayContent.getDisplayId());
1073                pw.print(" mSession="); pw.print(mSession);
1074                pw.print(" mClient="); pw.println(mClient.asBinder());
1075        pw.print(prefix); pw.print("mAttrs="); pw.println(mAttrs);
1076        pw.print(prefix); pw.print("Requested w="); pw.print(mRequestedWidth);
1077                pw.print(" h="); pw.print(mRequestedHeight);
1078                pw.print(" mLayoutSeq="); pw.println(mLayoutSeq);
1079        if (mRequestedWidth != mLastRequestedWidth || mRequestedHeight != mLastRequestedHeight) {
1080            pw.print(prefix); pw.print("LastRequested w="); pw.print(mLastRequestedWidth);
1081                    pw.print(" h="); pw.println(mLastRequestedHeight);
1082        }
1083        if (mAttachedWindow != null || mLayoutAttached) {
1084            pw.print(prefix); pw.print("mAttachedWindow="); pw.print(mAttachedWindow);
1085                    pw.print(" mLayoutAttached="); pw.println(mLayoutAttached);
1086        }
1087        if (mIsImWindow || mIsWallpaper || mIsFloatingLayer) {
1088            pw.print(prefix); pw.print("mIsImWindow="); pw.print(mIsImWindow);
1089                    pw.print(" mIsWallpaper="); pw.print(mIsWallpaper);
1090                    pw.print(" mIsFloatingLayer="); pw.print(mIsFloatingLayer);
1091                    pw.print(" mWallpaperVisible="); pw.println(mWallpaperVisible);
1092        }
1093        if (dumpAll) {
1094            pw.print(prefix); pw.print("mBaseLayer="); pw.print(mBaseLayer);
1095                    pw.print(" mSubLayer="); pw.print(mSubLayer);
1096                    pw.print(" mAnimLayer="); pw.print(mLayer); pw.print("+");
1097                    pw.print((mTargetAppToken != null ?
1098                            mTargetAppToken.mAppAnimator.animLayerAdjustment
1099                          : (mAppToken != null ? mAppToken.mAppAnimator.animLayerAdjustment : 0)));
1100                    pw.print("="); pw.print(mWinAnimator.mAnimLayer);
1101                    pw.print(" mLastLayer="); pw.println(mWinAnimator.mLastLayer);
1102        }
1103        if (dumpAll) {
1104            pw.print(prefix); pw.print("mToken="); pw.println(mToken);
1105            pw.print(prefix); pw.print("mRootToken="); pw.println(mRootToken);
1106            if (mAppToken != null) {
1107                pw.print(prefix); pw.print("mAppToken="); pw.println(mAppToken);
1108            }
1109            if (mTargetAppToken != null) {
1110                pw.print(prefix); pw.print("mTargetAppToken="); pw.println(mTargetAppToken);
1111            }
1112            pw.print(prefix); pw.print("mViewVisibility=0x");
1113            pw.print(Integer.toHexString(mViewVisibility));
1114            pw.print(" mHaveFrame="); pw.print(mHaveFrame);
1115            pw.print(" mObscured="); pw.println(mObscured);
1116            pw.print(prefix); pw.print("mSeq="); pw.print(mSeq);
1117            pw.print(" mSystemUiVisibility=0x");
1118            pw.println(Integer.toHexString(mSystemUiVisibility));
1119        }
1120        if (!mPolicyVisibility || !mPolicyVisibilityAfterAnim || mAttachedHidden) {
1121            pw.print(prefix); pw.print("mPolicyVisibility=");
1122                    pw.print(mPolicyVisibility);
1123                    pw.print(" mPolicyVisibilityAfterAnim=");
1124                    pw.print(mPolicyVisibilityAfterAnim);
1125                    pw.print(" mAttachedHidden="); pw.println(mAttachedHidden);
1126        }
1127        if (!mRelayoutCalled || mLayoutNeeded) {
1128            pw.print(prefix); pw.print("mRelayoutCalled="); pw.print(mRelayoutCalled);
1129                    pw.print(" mLayoutNeeded="); pw.println(mLayoutNeeded);
1130        }
1131        if (mXOffset != 0 || mYOffset != 0) {
1132            pw.print(prefix); pw.print("Offsets x="); pw.print(mXOffset);
1133                    pw.print(" y="); pw.println(mYOffset);
1134        }
1135        if (dumpAll) {
1136            pw.print(prefix); pw.print("mGivenContentInsets=");
1137                    mGivenContentInsets.printShortString(pw);
1138                    pw.print(" mGivenVisibleInsets=");
1139                    mGivenVisibleInsets.printShortString(pw);
1140                    pw.println();
1141            if (mTouchableInsets != 0 || mGivenInsetsPending) {
1142                pw.print(prefix); pw.print("mTouchableInsets="); pw.print(mTouchableInsets);
1143                        pw.print(" mGivenInsetsPending="); pw.println(mGivenInsetsPending);
1144                Region region = new Region();
1145                getTouchableRegion(region);
1146                pw.print(prefix); pw.print("touchable region="); pw.println(region);
1147            }
1148            pw.print(prefix); pw.print("mConfiguration="); pw.println(mConfiguration);
1149        }
1150        pw.print(prefix); pw.print("mHasSurface="); pw.print(mHasSurface);
1151                pw.print(" mShownFrame="); mShownFrame.printShortString(pw);
1152                pw.print(" isReadyForDisplay()="); pw.println(isReadyForDisplay());
1153        if (dumpAll) {
1154            pw.print(prefix); pw.print("mFrame="); mFrame.printShortString(pw);
1155                    pw.print(" last="); mLastFrame.printShortString(pw);
1156                    pw.println();
1157            pw.print(prefix); pw.print("mSystemDecorRect="); mSystemDecorRect.printShortString(pw);
1158                    pw.print(" last="); mLastSystemDecorRect.printShortString(pw);
1159                    pw.println();
1160        }
1161        if (mEnforceSizeCompat) {
1162            pw.print(prefix); pw.print("mCompatFrame="); mCompatFrame.printShortString(pw);
1163                    pw.println();
1164        }
1165        if (dumpAll) {
1166            pw.print(prefix); pw.print("Frames: containing=");
1167                    mContainingFrame.printShortString(pw);
1168                    pw.print(" parent="); mParentFrame.printShortString(pw);
1169                    pw.print(" display="); mDisplayFrame.printShortString(pw);
1170                    pw.println();
1171            pw.print(prefix); pw.print("    content="); mContentFrame.printShortString(pw);
1172                    pw.print(" visible="); mVisibleFrame.printShortString(pw);
1173                    pw.println();
1174            pw.print(prefix); pw.print("Cur insets: content=");
1175                    mContentInsets.printShortString(pw);
1176                    pw.print(" visible="); mVisibleInsets.printShortString(pw);
1177                    pw.println();
1178            pw.print(prefix); pw.print("Lst insets: content=");
1179                    mLastContentInsets.printShortString(pw);
1180                    pw.print(" visible="); mLastVisibleInsets.printShortString(pw);
1181                    pw.println();
1182        }
1183        mWinAnimator.dump(pw, prefix, dumpAll);
1184        if (mExiting || mRemoveOnExit || mDestroying || mRemoved) {
1185            pw.print(prefix); pw.print("mExiting="); pw.print(mExiting);
1186                    pw.print(" mRemoveOnExit="); pw.print(mRemoveOnExit);
1187                    pw.print(" mDestroying="); pw.print(mDestroying);
1188                    pw.print(" mRemoved="); pw.println(mRemoved);
1189        }
1190        if (mOrientationChanging || mAppFreezing || mTurnOnScreen) {
1191            pw.print(prefix); pw.print("mOrientationChanging=");
1192                    pw.print(mOrientationChanging);
1193                    pw.print(" mAppFreezing="); pw.print(mAppFreezing);
1194                    pw.print(" mTurnOnScreen="); pw.println(mTurnOnScreen);
1195        }
1196        if (mHScale != 1 || mVScale != 1) {
1197            pw.print(prefix); pw.print("mHScale="); pw.print(mHScale);
1198                    pw.print(" mVScale="); pw.println(mVScale);
1199        }
1200        if (mWallpaperX != -1 || mWallpaperY != -1) {
1201            pw.print(prefix); pw.print("mWallpaperX="); pw.print(mWallpaperX);
1202                    pw.print(" mWallpaperY="); pw.println(mWallpaperY);
1203        }
1204        if (mWallpaperXStep != -1 || mWallpaperYStep != -1) {
1205            pw.print(prefix); pw.print("mWallpaperXStep="); pw.print(mWallpaperXStep);
1206                    pw.print(" mWallpaperYStep="); pw.println(mWallpaperYStep);
1207        }
1208    }
1209
1210    String makeInputChannelName() {
1211        return Integer.toHexString(System.identityHashCode(this))
1212            + " " + mAttrs.getTitle();
1213    }
1214
1215    @Override
1216    public String toString() {
1217        if (mStringNameCache == null || mLastTitle != mAttrs.getTitle()
1218                || mWasPaused != mToken.paused) {
1219            mLastTitle = mAttrs.getTitle();
1220            mWasPaused = mToken.paused;
1221            mStringNameCache = "Window{" + Integer.toHexString(System.identityHashCode(this))
1222                    + " " + mLastTitle + " paused=" + mWasPaused + "}";
1223        }
1224        return mStringNameCache;
1225    }
1226}
1227