16e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn/* 26e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn * Copyright (C) 2011 The Android Open Source Project 36e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn * 46e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn * Licensed under the Apache License, Version 2.0 (the "License"); 56e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn * you may not use this file except in compliance with the License. 66e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn * You may obtain a copy of the License at 76e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn * 86e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn * http://www.apache.org/licenses/LICENSE-2.0 96e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn * 106e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn * Unless required by applicable law or agreed to in writing, software 116e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn * distributed under the License is distributed on an "AS IS" BASIS, 126e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 136e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn * See the License for the specific language governing permissions and 146e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn * limitations under the License. 156e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn */ 166e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn 176e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackbornpackage com.android.server.wm; 186e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn 196e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackbornimport com.android.internal.view.IInputContext; 206e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackbornimport com.android.internal.view.IInputMethodClient; 216e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackbornimport com.android.internal.view.IInputMethodManager; 226e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackbornimport com.android.server.wm.WindowManagerService.H; 236e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn 246e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackbornimport android.content.ClipData; 256e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackbornimport android.content.Context; 266e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackbornimport android.content.res.Configuration; 276e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackbornimport android.graphics.Rect; 286e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackbornimport android.graphics.Region; 296e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackbornimport android.os.Binder; 306e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackbornimport android.os.Bundle; 316e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackbornimport android.os.IBinder; 326e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackbornimport android.os.Parcel; 336e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackbornimport android.os.RemoteException; 346e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackbornimport android.os.ServiceManager; 356e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackbornimport android.util.Slog; 366e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackbornimport android.view.IWindow; 376e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackbornimport android.view.IWindowSession; 386e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackbornimport android.view.InputChannel; 396e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackbornimport android.view.Surface; 406e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackbornimport android.view.SurfaceSession; 416e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackbornimport android.view.WindowManager; 426e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn 436e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackbornimport java.io.PrintWriter; 446e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn 456e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn/** 466e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn * This class represents an active client session. There is generally one 476e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn * Session object per process that is interacting with the window manager. 486e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn */ 496e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackbornfinal class Session extends IWindowSession.Stub 506e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn implements IBinder.DeathRecipient { 516e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn final WindowManagerService mService; 526e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn final IInputMethodClient mClient; 536e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn final IInputContext mInputContext; 546e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn final int mUid; 556e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn final int mPid; 566e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn final String mStringName; 576e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn SurfaceSession mSurfaceSession; 586e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn int mNumWindow = 0; 596e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn boolean mClientDead = false; 606e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn 616e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn public Session(WindowManagerService service, IInputMethodClient client, 626e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn IInputContext inputContext) { 636e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn mService = service; 646e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn mClient = client; 656e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn mInputContext = inputContext; 666e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn mUid = Binder.getCallingUid(); 676e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn mPid = Binder.getCallingPid(); 686e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn StringBuilder sb = new StringBuilder(); 696e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn sb.append("Session{"); 706e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn sb.append(Integer.toHexString(System.identityHashCode(this))); 716e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn sb.append(" uid "); 726e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn sb.append(mUid); 736e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn sb.append("}"); 746e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn mStringName = sb.toString(); 756e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn 766e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn synchronized (mService.mWindowMap) { 776e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn if (mService.mInputMethodManager == null && mService.mHaveInputMethods) { 786e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn IBinder b = ServiceManager.getService( 796e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn Context.INPUT_METHOD_SERVICE); 806e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn mService.mInputMethodManager = IInputMethodManager.Stub.asInterface(b); 816e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn } 826e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn } 836e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn long ident = Binder.clearCallingIdentity(); 846e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn try { 856e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn // Note: it is safe to call in to the input method manager 866e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn // here because we are not holding our lock. 876e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn if (mService.mInputMethodManager != null) { 886e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn mService.mInputMethodManager.addClient(client, inputContext, 896e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn mUid, mPid); 906e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn } else { 916e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn client.setUsingInputMethod(false); 926e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn } 936e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn client.asBinder().linkToDeath(this, 0); 946e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn } catch (RemoteException e) { 956e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn // The caller has died, so we can just forget about this. 966e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn try { 976e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn if (mService.mInputMethodManager != null) { 986e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn mService.mInputMethodManager.removeClient(client); 996e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn } 1006e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn } catch (RemoteException ee) { 1016e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn } 1026e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn } finally { 1036e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn Binder.restoreCallingIdentity(ident); 1046e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn } 1056e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn } 1066e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn 1076e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn @Override 1086e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn public boolean onTransact(int code, Parcel data, Parcel reply, int flags) 1096e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn throws RemoteException { 1106e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn try { 1116e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn return super.onTransact(code, data, reply, flags); 1126e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn } catch (RuntimeException e) { 1136e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn // Log all 'real' exceptions thrown to the caller 1146e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn if (!(e instanceof SecurityException)) { 1156e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn Slog.e(WindowManagerService.TAG, "Window Session Crash", e); 1166e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn } 1176e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn throw e; 1186e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn } 1196e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn } 1206e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn 1216e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn public void binderDied() { 1226e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn // Note: it is safe to call in to the input method manager 1236e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn // here because we are not holding our lock. 1246e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn try { 1256e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn if (mService.mInputMethodManager != null) { 1266e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn mService.mInputMethodManager.removeClient(mClient); 1276e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn } 1286e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn } catch (RemoteException e) { 1296e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn } 1306e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn synchronized(mService.mWindowMap) { 1316e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn mClient.asBinder().unlinkToDeath(this, 0); 1326e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn mClientDead = true; 1336e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn killSessionLocked(); 1346e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn } 1356e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn } 1366e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn 1379a230e01a1237749a8a19a5de8d46531b0c8ca6aDianne Hackborn public int add(IWindow window, int seq, WindowManager.LayoutParams attrs, 1386e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn int viewVisibility, Rect outContentInsets, InputChannel outInputChannel) { 1399a230e01a1237749a8a19a5de8d46531b0c8ca6aDianne Hackborn return mService.addWindow(this, window, seq, attrs, viewVisibility, outContentInsets, 1406e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn outInputChannel); 1416e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn } 1426e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn 1439a230e01a1237749a8a19a5de8d46531b0c8ca6aDianne Hackborn public int addWithoutInputChannel(IWindow window, int seq, WindowManager.LayoutParams attrs, 1446e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn int viewVisibility, Rect outContentInsets) { 1459a230e01a1237749a8a19a5de8d46531b0c8ca6aDianne Hackborn return mService.addWindow(this, window, seq, attrs, viewVisibility, outContentInsets, null); 1466e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn } 1476e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn 1486e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn public void remove(IWindow window) { 1496e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn mService.removeWindow(this, window); 1506e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn } 1516e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn 1529a230e01a1237749a8a19a5de8d46531b0c8ca6aDianne Hackborn public int relayout(IWindow window, int seq, WindowManager.LayoutParams attrs, 1536e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn int requestedWidth, int requestedHeight, int viewFlags, 15485afd1b6f871d471fdff1980134676a5f1690525Dianne Hackborn int flags, Rect outFrame, Rect outContentInsets, 1556e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn Rect outVisibleInsets, Configuration outConfig, Surface outSurface) { 156b961cd2c80abf1d2834e5ad690904da4fe56d755Dianne Hackborn if (false) Slog.d(WindowManagerService.TAG, ">>>>>> ENTERED relayout from " 157b961cd2c80abf1d2834e5ad690904da4fe56d755Dianne Hackborn + Binder.getCallingPid()); 1589a230e01a1237749a8a19a5de8d46531b0c8ca6aDianne Hackborn int res = mService.relayoutWindow(this, window, seq, attrs, 1596d05fd3c795088ac60f86382df5a66d631e8a0cbDianne Hackborn requestedWidth, requestedHeight, viewFlags, flags, 16085afd1b6f871d471fdff1980134676a5f1690525Dianne Hackborn outFrame, outContentInsets, outVisibleInsets, 1615c58de3a523a384c47b0b1e0f5dd9728a74cd9f7Dianne Hackborn outConfig, outSurface); 162b961cd2c80abf1d2834e5ad690904da4fe56d755Dianne Hackborn if (false) Slog.d(WindowManagerService.TAG, "<<<<<< EXITING relayout to " 163b961cd2c80abf1d2834e5ad690904da4fe56d755Dianne Hackborn + Binder.getCallingPid()); 1646e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn return res; 1656e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn } 1666e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn 1676d05fd3c795088ac60f86382df5a66d631e8a0cbDianne Hackborn public void performDeferredDestroy(IWindow window) { 1686d05fd3c795088ac60f86382df5a66d631e8a0cbDianne Hackborn mService.performDeferredDestroyWindow(this, window); 1696d05fd3c795088ac60f86382df5a66d631e8a0cbDianne Hackborn } 1706d05fd3c795088ac60f86382df5a66d631e8a0cbDianne Hackborn 171648251710162cdaf7371012a1cbb79b9bc5bc0e4Dianne Hackborn public boolean outOfMemory(IWindow window) { 172648251710162cdaf7371012a1cbb79b9bc5bc0e4Dianne Hackborn return mService.outOfMemoryWindow(this, window); 173648251710162cdaf7371012a1cbb79b9bc5bc0e4Dianne Hackborn } 174648251710162cdaf7371012a1cbb79b9bc5bc0e4Dianne Hackborn 1756e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn public void setTransparentRegion(IWindow window, Region region) { 1766e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn mService.setTransparentRegionWindow(this, window, region); 1776e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn } 1786e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn 1796e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn public void setInsets(IWindow window, int touchableInsets, 1806e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn Rect contentInsets, Rect visibleInsets, Region touchableArea) { 1816e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn mService.setInsetsWindow(this, window, touchableInsets, contentInsets, 1826e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn visibleInsets, touchableArea); 1836e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn } 1846e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn 1856e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn public void getDisplayFrame(IWindow window, Rect outDisplayFrame) { 1866e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn mService.getWindowDisplayFrame(this, window, outDisplayFrame); 1876e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn } 1886e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn 1896e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn public void finishDrawing(IWindow window) { 1906e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn if (WindowManagerService.localLOGV) Slog.v( 1916e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn WindowManagerService.TAG, "IWindow finishDrawing called for " + window); 1926e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn mService.finishDrawingWindow(this, window); 1936e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn } 1946e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn 1956e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn public void setInTouchMode(boolean mode) { 1966e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn synchronized(mService.mWindowMap) { 1976e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn mService.mInTouchMode = mode; 1986e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn } 1996e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn } 2006e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn 2016e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn public boolean getInTouchMode() { 2026e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn synchronized(mService.mWindowMap) { 2036e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn return mService.mInTouchMode; 2046e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn } 2056e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn } 2066e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn 2076e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn public boolean performHapticFeedback(IWindow window, int effectId, 2086e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn boolean always) { 2096e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn synchronized(mService.mWindowMap) { 2106e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn long ident = Binder.clearCallingIdentity(); 2116e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn try { 2126e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn return mService.mPolicy.performHapticFeedbackLw( 2136e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn mService.windowForClientLocked(this, window, true), 2146e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn effectId, always); 2156e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn } finally { 2166e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn Binder.restoreCallingIdentity(ident); 2176e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn } 2186e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn } 2196e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn } 2206e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn 2216e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn /* Drag/drop */ 2226e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn public IBinder prepareDrag(IWindow window, int flags, 2236e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn int width, int height, Surface outSurface) { 2246e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn return mService.prepareDragSurface(window, mSurfaceSession, flags, 2256e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn width, height, outSurface); 2266e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn } 2276e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn 2286e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn public boolean performDrag(IWindow window, IBinder dragToken, 2296e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn float touchX, float touchY, float thumbCenterX, float thumbCenterY, 2306e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn ClipData data) { 2316e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn if (WindowManagerService.DEBUG_DRAG) { 2326e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn Slog.d(WindowManagerService.TAG, "perform drag: win=" + window + " data=" + data); 2336e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn } 2346e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn 2356e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn synchronized (mService.mWindowMap) { 2366e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn if (mService.mDragState == null) { 2376e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn Slog.w(WindowManagerService.TAG, "No drag prepared"); 2386e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn throw new IllegalStateException("performDrag() without prepareDrag()"); 2396e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn } 2406e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn 2416e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn if (dragToken != mService.mDragState.mToken) { 2426e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn Slog.w(WindowManagerService.TAG, "Performing mismatched drag"); 2436e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn throw new IllegalStateException("performDrag() does not match prepareDrag()"); 2446e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn } 2456e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn 2466e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn WindowState callingWin = mService.windowForClientLocked(null, window, false); 2476e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn if (callingWin == null) { 2486e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn Slog.w(WindowManagerService.TAG, "Bad requesting window " + window); 2496e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn return false; // !!! TODO: throw here? 2506e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn } 2516e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn 2526e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn // !!! TODO: if input is not still focused on the initiating window, fail 2536e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn // the drag initiation (e.g. an alarm window popped up just as the application 2546e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn // called performDrag() 2556e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn 2566e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn mService.mH.removeMessages(H.DRAG_START_TIMEOUT, window.asBinder()); 2576e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn 2586e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn // !!! TODO: extract the current touch (x, y) in screen coordinates. That 2596e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn // will let us eliminate the (touchX,touchY) parameters from the API. 2606e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn 2616e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn // !!! FIXME: put all this heavy stuff onto the mH looper, as well as 2626e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn // the actual drag event dispatch stuff in the dragstate 2636e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn 2646e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn mService.mDragState.register(); 2656e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn mService.mInputMonitor.updateInputWindowsLw(true /*force*/); 2666e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn if (!mService.mInputManager.transferTouchFocus(callingWin.mInputChannel, 2676e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn mService.mDragState.mServerChannel)) { 2686e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn Slog.e(WindowManagerService.TAG, "Unable to transfer touch focus"); 2696e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn mService.mDragState.unregister(); 2706e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn mService.mDragState = null; 2716e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn mService.mInputMonitor.updateInputWindowsLw(true /*force*/); 2726e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn return false; 2736e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn } 2746e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn 2756e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn mService.mDragState.mData = data; 2766e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn mService.mDragState.mCurrentX = touchX; 2776e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn mService.mDragState.mCurrentY = touchY; 2786e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn mService.mDragState.broadcastDragStartedLw(touchX, touchY); 2796e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn 2806e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn // remember the thumb offsets for later 2816e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn mService.mDragState.mThumbOffsetX = thumbCenterX; 2826e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn mService.mDragState.mThumbOffsetY = thumbCenterY; 2836e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn 2846e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn // Make the surface visible at the proper location 2856e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn final Surface surface = mService.mDragState.mSurface; 28636991744a221c30a47085442e6416bdde40b85e8Dianne Hackborn if (WindowManagerService.SHOW_LIGHT_TRANSACTIONS) Slog.i( 28736991744a221c30a47085442e6416bdde40b85e8Dianne Hackborn WindowManagerService.TAG, ">>> OPEN TRANSACTION performDrag"); 2886e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn Surface.openTransaction(); 2896e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn try { 290d040edbae968d826aa2c82d382345811a45c646bDianne Hackborn surface.setPosition(touchX - thumbCenterX, 291d040edbae968d826aa2c82d382345811a45c646bDianne Hackborn touchY - thumbCenterY); 2926e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn surface.setAlpha(.7071f); 2936e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn surface.setLayer(mService.mDragState.getDragLayerLw()); 2946e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn surface.show(); 2956e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn } finally { 2966e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn Surface.closeTransaction(); 29736991744a221c30a47085442e6416bdde40b85e8Dianne Hackborn if (WindowManagerService.SHOW_LIGHT_TRANSACTIONS) Slog.i( 29836991744a221c30a47085442e6416bdde40b85e8Dianne Hackborn WindowManagerService.TAG, "<<< CLOSE TRANSACTION performDrag"); 2996e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn } 3006e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn } 3016e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn 3026e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn return true; // success! 3036e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn } 3046e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn 3056e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn public void reportDropResult(IWindow window, boolean consumed) { 3066e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn IBinder token = window.asBinder(); 3076e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn if (WindowManagerService.DEBUG_DRAG) { 3086e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn Slog.d(WindowManagerService.TAG, "Drop result=" + consumed + " reported by " + token); 3096e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn } 3106e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn 3116e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn synchronized (mService.mWindowMap) { 3126e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn long ident = Binder.clearCallingIdentity(); 3136e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn try { 31405e9c65a53002e39306a0581310b4b0fceed7433Christopher Tate if (mService.mDragState == null) { 31505e9c65a53002e39306a0581310b4b0fceed7433Christopher Tate // Most likely the drop recipient ANRed and we ended the drag 31605e9c65a53002e39306a0581310b4b0fceed7433Christopher Tate // out from under it. Log the issue and move on. 31705e9c65a53002e39306a0581310b4b0fceed7433Christopher Tate Slog.w(WindowManagerService.TAG, "Drop result given but no drag in progress"); 31805e9c65a53002e39306a0581310b4b0fceed7433Christopher Tate return; 31905e9c65a53002e39306a0581310b4b0fceed7433Christopher Tate } 32005e9c65a53002e39306a0581310b4b0fceed7433Christopher Tate 32105e9c65a53002e39306a0581310b4b0fceed7433Christopher Tate if (mService.mDragState.mToken != token) { 32205e9c65a53002e39306a0581310b4b0fceed7433Christopher Tate // We're in a drag, but the wrong window has responded. 3236e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn Slog.w(WindowManagerService.TAG, "Invalid drop-result claim by " + window); 3246e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn throw new IllegalStateException("reportDropResult() by non-recipient"); 3256e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn } 3266e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn 3276e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn // The right window has responded, even if it's no longer around, 3286e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn // so be sure to halt the timeout even if the later WindowState 3296e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn // lookup fails. 3306e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn mService.mH.removeMessages(H.DRAG_END_TIMEOUT, window.asBinder()); 3316e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn WindowState callingWin = mService.windowForClientLocked(null, window, false); 3326e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn if (callingWin == null) { 3336e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn Slog.w(WindowManagerService.TAG, "Bad result-reporting window " + window); 3346e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn return; // !!! TODO: throw here? 3356e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn } 3366e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn 3376e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn mService.mDragState.mDragResult = consumed; 3386e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn mService.mDragState.endDragLw(); 3396e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn } finally { 3406e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn Binder.restoreCallingIdentity(ident); 3416e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn } 3426e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn } 3436e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn } 3446e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn 3456e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn public void dragRecipientEntered(IWindow window) { 3466e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn if (WindowManagerService.DEBUG_DRAG) { 3476e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn Slog.d(WindowManagerService.TAG, "Drag into new candidate view @ " + window.asBinder()); 3486e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn } 3496e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn } 3506e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn 3516e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn public void dragRecipientExited(IWindow window) { 3526e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn if (WindowManagerService.DEBUG_DRAG) { 3536e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn Slog.d(WindowManagerService.TAG, "Drag from old candidate view @ " + window.asBinder()); 3546e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn } 3556e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn } 3566e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn 3576e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn public void setWallpaperPosition(IBinder window, float x, float y, float xStep, float yStep) { 3586e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn synchronized(mService.mWindowMap) { 3596e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn long ident = Binder.clearCallingIdentity(); 3606e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn try { 3616e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn mService.setWindowWallpaperPositionLocked( 3626e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn mService.windowForClientLocked(this, window, true), 3636e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn x, y, xStep, yStep); 3646e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn } finally { 3656e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn Binder.restoreCallingIdentity(ident); 3666e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn } 3676e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn } 3686e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn } 3696e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn 3706e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn public void wallpaperOffsetsComplete(IBinder window) { 3716e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn mService.wallpaperOffsetsComplete(window); 3726e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn } 3736e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn 3746e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn public Bundle sendWallpaperCommand(IBinder window, String action, int x, int y, 3756e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn int z, Bundle extras, boolean sync) { 3766e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn synchronized(mService.mWindowMap) { 3776e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn long ident = Binder.clearCallingIdentity(); 3786e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn try { 3796e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn return mService.sendWindowWallpaperCommandLocked( 3806e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn mService.windowForClientLocked(this, window, true), 3816e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn action, x, y, z, extras, sync); 3826e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn } finally { 3836e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn Binder.restoreCallingIdentity(ident); 3846e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn } 3856e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn } 3866e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn } 3876e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn 3886e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn public void wallpaperCommandComplete(IBinder window, Bundle result) { 3896e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn mService.wallpaperCommandComplete(window, result); 3906e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn } 3916e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn 3926e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn void windowAddedLocked() { 3936e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn if (mSurfaceSession == null) { 3946e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn if (WindowManagerService.localLOGV) Slog.v( 3956e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn WindowManagerService.TAG, "First window added to " + this + ", creating SurfaceSession"); 3966e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn mSurfaceSession = new SurfaceSession(); 3976e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn if (WindowManagerService.SHOW_TRANSACTIONS) Slog.i( 3986e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn WindowManagerService.TAG, " NEW SURFACE SESSION " + mSurfaceSession); 3996e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn mService.mSessions.add(this); 4006e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn } 4016e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn mNumWindow++; 4026e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn } 4036e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn 4046e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn void windowRemovedLocked() { 4056e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn mNumWindow--; 4066e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn killSessionLocked(); 4076e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn } 4086e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn 4096e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn void killSessionLocked() { 4106e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn if (mNumWindow <= 0 && mClientDead) { 4116e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn mService.mSessions.remove(this); 4126e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn if (mSurfaceSession != null) { 4136e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn if (WindowManagerService.localLOGV) Slog.v( 4146e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn WindowManagerService.TAG, "Last window removed from " + this 4156e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn + ", destroying " + mSurfaceSession); 4166e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn if (WindowManagerService.SHOW_TRANSACTIONS) Slog.i( 4176e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn WindowManagerService.TAG, " KILL SURFACE SESSION " + mSurfaceSession); 4186e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn try { 4196e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn mSurfaceSession.kill(); 4206e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn } catch (Exception e) { 4216e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn Slog.w(WindowManagerService.TAG, "Exception thrown when killing surface session " 4226e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn + mSurfaceSession + " in session " + this 4236e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn + ": " + e.toString()); 4246e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn } 4256e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn mSurfaceSession = null; 4266e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn } 4276e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn } 4286e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn } 4296e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn 4306e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn void dump(PrintWriter pw, String prefix) { 4316e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn pw.print(prefix); pw.print("mNumWindow="); pw.print(mNumWindow); 4326e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn pw.print(" mClientDead="); pw.print(mClientDead); 4336e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn pw.print(" mSurfaceSession="); pw.println(mSurfaceSession); 4346e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn } 4356e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn 4366e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn @Override 4376e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn public String toString() { 4386e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn return mStringName; 4396e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn } 4406e1eb76f02ccc9dbc309b938f62d39312da8cafeDianne Hackborn}