- 浏览: 677344 次
- 性别:
- 来自: 西安
文章分类
- 全部博客 (440)
- c++学习笔记 (89)
- 如何适应变化 (1)
- VC常见问题 (7)
- Brew开发12月9日至12月26日 (1)
- 软件架构 (3)
- 自己动手写C语言编译器之文档翻译工作 (1)
- 自己动手写C语言编译器 (6)
- 网站资源 (1)
- 郝彬英文教程 (1)
- 45度斜角地图 (0)
- 35.264等角视图 (0)
- 30等角视图 (1)
- 如何搞opengl (1)
- 卷积。 (1)
- Android解析日记 (5)
- Linux基础教学 (9)
- Android游戏框架 (9)
- Android游戏开发之OpenGL之坐标矩阵 (2)
- Android异常处理 (1)
- 资源网站 (1)
- ARM汇编学习 (1)
- game (0)
- 自己动手实现OpenGL(准备开始!后面有空补充) (3)
- 云计算 (1)
- Android面试题目 (17)
- 深度学习 (1)
- OpenGL实践 (1)
- 神经网络学习-翻译 (4)
最新评论
-
3482561:
Android 面试题目之 线程池 -
daojin:
直接布局。
安卓高手之路之图形系统(6)requestLayout的流程 -
hety163:
没明白楼主所说的最后两段。如果一个相对布局中有多个子view, ...
安卓高手之路之图形系统(6)requestLayout的流程 -
jackuhan:
100篇!!!膜拜
安卓高手之路之 图形系统之 图形框架(1) -
ritterliu:
不错,按照流程把关键代码都贴出来了。谢谢分享
Android输入输出系统之TouchEvent流程
Android之基础建设之IWindow和IWindowSession
- 博客分类:
- Android游戏框架
static class W extends IWindow.Stub { private final WeakReference<ViewRoot> mViewRoot; public W(ViewRoot viewRoot, Context context) { mViewRoot = new WeakReference<ViewRoot>(viewRoot); } public void resized(int w, int h, Rect coveredInsets, Rect visibleInsets, boolean reportDraw, Configuration newConfig) { final ViewRoot viewRoot = mViewRoot.get(); if (viewRoot != null) { viewRoot.dispatchResized(w, h, coveredInsets, visibleInsets, reportDraw, newConfig); } } public void dispatchAppVisibility(boolean visible) { final ViewRoot viewRoot = mViewRoot.get(); if (viewRoot != null) { viewRoot.dispatchAppVisibility(visible); } } public void dispatchGetNewSurface() { final ViewRoot viewRoot = mViewRoot.get(); if (viewRoot != null) { viewRoot.dispatchGetNewSurface(); } } public void windowFocusChanged(boolean hasFocus, boolean inTouchMode) { final ViewRoot viewRoot = mViewRoot.get(); if (viewRoot != null) { viewRoot.windowFocusChanged(hasFocus, inTouchMode); } } private static int checkCallingPermission(String permission) { if (!Process.supportsProcesses()) { return PackageManager.PERMISSION_GRANTED; } try { return ActivityManagerNative.getDefault().checkPermission( permission, Binder.getCallingPid(), Binder.getCallingUid()); } catch (RemoteException e) { return PackageManager.PERMISSION_DENIED; } } public void executeCommand(String command, String parameters, ParcelFileDescriptor out) { final ViewRoot viewRoot = mViewRoot.get(); if (viewRoot != null) { final View view = viewRoot.mView; if (view != null) { if (checkCallingPermission(Manifest.permission.DUMP) != PackageManager.PERMISSION_GRANTED) { throw new SecurityException("Insufficient permissions to invoke" + " executeCommand() from pid=" + Binder.getCallingPid() + ", uid=" + Binder.getCallingUid()); } OutputStream clientStream = null; try { clientStream = new ParcelFileDescriptor.AutoCloseOutputStream(out); ViewDebug.dispatchCommand(view, command, parameters, clientStream); } catch (IOException e) { e.printStackTrace(); } finally { if (clientStream != null) { try { clientStream.close(); } catch (IOException e) { e.printStackTrace(); } } } } } } public void closeSystemDialogs(String reason) { final ViewRoot viewRoot = mViewRoot.get(); if (viewRoot != null) { viewRoot.dispatchCloseSystemDialogs(reason); } } public void dispatchWallpaperOffsets(float x, float y, float xStep, float yStep, boolean sync) { if (sync) { try { sWindowSession.wallpaperOffsetsComplete(asBinder()); } catch (RemoteException e) { } } } public void dispatchWallpaperCommand(String action, int x, int y, int z, Bundle extras, boolean sync) { if (sync) { try { sWindowSession.wallpaperCommandComplete(asBinder(), null); } catch (RemoteException e) { } } } }
写道
private final class Session extends IWindowSession.Stub implements IBinder.DeathRecipient { final IInputMethodClient mClient; final IInputContext mInputContext; final int mUid; final int mPid; final String mStringName; SurfaceSession mSurfaceSession; int mNumWindow = 0; boolean mClientDead = false; public Session(IInputMethodClient client, IInputContext inputContext) { mClient = client; mInputContext = inputContext; mUid = Binder.getCallingUid(); mPid = Binder.getCallingPid(); StringBuilder sb = new StringBuilder(); sb.append("Session{"); sb.append(Integer.toHexString(System.identityHashCode(this))); sb.append(" uid "); sb.append(mUid); sb.append("}"); mStringName = sb.toString(); synchronized (mWindowMap) { if (mInputMethodManager == null && mHaveInputMethods) { IBinder b = ServiceManager.getService( Context.INPUT_METHOD_SERVICE); mInputMethodManager = IInputMethodManager.Stub.asInterface(b); } } long ident = Binder.clearCallingIdentity(); try { // Note: it is safe to call in to the input method manager // here because we are not holding our lock. if (mInputMethodManager != null) { mInputMethodManager.addClient(client, inputContext, mUid, mPid); } else { client.setUsingInputMethod(false); } client.asBinder().linkToDeath(this, 0); } catch (RemoteException e) { // The caller has died, so we can just forget about this. try { if (mInputMethodManager != null) { mInputMethodManager.removeClient(client); } } catch (RemoteException ee) { } } finally { Binder.restoreCallingIdentity(ident); } } @Override public boolean onTransact(int code, Parcel data, Parcel reply, int flags) throws RemoteException { try { return super.onTransact(code, data, reply, flags); } catch (RuntimeException e) { // Log all 'real' exceptions thrown to the caller if (!(e instanceof SecurityException)) { Slog.e(TAG, "Window Session Crash", e); } throw e; } } public void binderDied() { // Note: it is safe to call in to the input method manager // here because we are not holding our lock. try { if (mInputMethodManager != null) { mInputMethodManager.removeClient(mClient); } } catch (RemoteException e) { } synchronized(mWindowMap) { mClient.asBinder().unlinkToDeath(this, 0); mClientDead = true; killSessionLocked(); } } public int add(IWindow window, WindowManager.LayoutParams attrs, int viewVisibility, Rect outContentInsets, InputChannel outInputChannel) { return addWindow(this, window, attrs, viewVisibility, outContentInsets, outInputChannel); } public int addWithoutInputChannel(IWindow window, WindowManager.LayoutParams attrs, int viewVisibility, Rect outContentInsets) { return addWindow(this, window, attrs, viewVisibility, outContentInsets, null); } public void remove(IWindow window) { removeWindow(this, window); } public int relayout(IWindow window, WindowManager.LayoutParams attrs, int requestedWidth, int requestedHeight, int viewFlags, boolean insetsPending, Rect outFrame, Rect outContentInsets, Rect outVisibleInsets, Configuration outConfig, Surface outSurface) { //Log.d(TAG, ">>>>>> ENTERED relayout from " + Binder.getCallingPid()); int res = relayoutWindow(this, window, attrs, requestedWidth, requestedHeight, viewFlags, insetsPending, outFrame, outContentInsets, outVisibleInsets, outConfig, outSurface); //Log.d(TAG, "<<<<<< EXITING relayout to " + Binder.getCallingPid()); return res; } public void setTransparentRegion(IWindow window, Region region) { setTransparentRegionWindow(this, window, region); } public void setInsets(IWindow window, int touchableInsets, Rect contentInsets, Rect visibleInsets) { setInsetsWindow(this, window, touchableInsets, contentInsets, visibleInsets); } public void getDisplayFrame(IWindow window, Rect outDisplayFrame) { getWindowDisplayFrame(this, window, outDisplayFrame); } public void finishDrawing(IWindow window) { if (localLOGV) Slog.v( TAG, "IWindow finishDrawing called for " + window); finishDrawingWindow(this, window); } public void setInTouchMode(boolean mode) { synchronized(mWindowMap) { mInTouchMode = mode; } } public boolean getInTouchMode() { synchronized(mWindowMap) { return mInTouchMode; } } public boolean performHapticFeedback(IWindow window, int effectId, boolean always) { synchronized(mWindowMap) { long ident = Binder.clearCallingIdentity(); try { return mPolicy.performHapticFeedbackLw( windowForClientLocked(this, window, true), effectId, always); } finally { Binder.restoreCallingIdentity(ident); } } } public void setWallpaperPosition(IBinder window, float x, float y, float xStep, float yStep) { synchronized(mWindowMap) { long ident = Binder.clearCallingIdentity(); try { setWindowWallpaperPositionLocked( windowForClientLocked(this, window, true), x, y, xStep, yStep); } finally { Binder.restoreCallingIdentity(ident); } } } public void wallpaperOffsetsComplete(IBinder window) { WindowManagerService.this.wallpaperOffsetsComplete(window); } public Bundle sendWallpaperCommand(IBinder window, String action, int x, int y, int z, Bundle extras, boolean sync) { synchronized(mWindowMap) { long ident = Binder.clearCallingIdentity(); try { return sendWindowWallpaperCommandLocked( windowForClientLocked(this, window, true), action, x, y, z, extras, sync); } finally { Binder.restoreCallingIdentity(ident); } } } public void wallpaperCommandComplete(IBinder window, Bundle result) { WindowManagerService.this.wallpaperCommandComplete(window, result); } void windowAddedLocked() { if (mSurfaceSession == null) { if (localLOGV) Slog.v( TAG, "First window added to " + this + ", creating SurfaceSession"); mSurfaceSession = new SurfaceSession(); if (SHOW_TRANSACTIONS) Slog.i( TAG, " NEW SURFACE SESSION " + mSurfaceSession); mSessions.add(this); } mNumWindow++; } void windowRemovedLocked() { mNumWindow--; killSessionLocked(); } void killSessionLocked() { if (mNumWindow <= 0 && mClientDead) { mSessions.remove(this); if (mSurfaceSession != null) { if (localLOGV) Slog.v( TAG, "Last window removed from " + this + ", destroying " + mSurfaceSession); if (SHOW_TRANSACTIONS) Slog.i( TAG, " KILL SURFACE SESSION " + mSurfaceSession); try { mSurfaceSession.kill(); } catch (Exception e) { Slog.w(TAG, "Exception thrown when killing surface session " + mSurfaceSession + " in session " + this + ": " + e.toString()); } mSurfaceSession = null; } } } void dump(PrintWriter pw, String prefix) { pw.print(prefix); pw.print("mNumWindow="); pw.print(mNumWindow); pw.print(" mClientDead="); pw.print(mClientDead); pw.print(" mSurfaceSession="); pw.println(mSurfaceSession); } @Override public String toString() { return mStringName; } }
发表评论
-
ANativeWindow是个什么东西
2012-12-28 23:18 12615公司经常组织一些培训,培训的都是些奇技淫巧。什么设计模 ... -
Android自定义组件
2011-11-22 22:15 963http://developer.android.com/gu ... -
Android输入输出机制之来龙去脉之前生后世
2011-11-20 14:58 13658密码太多记不了,怎么办? http://a.app.qq ... -
Android输入输出机制之来龙去脉
2011-11-20 12:35 3758openInputChannelPair( 阅读本 ... -
Anroid基础建设之View,Window,Activity
2011-11-16 22:15 17741.PhoneWindow DecorView存在于P ... -
Android之linux之基础建设之窗口系统
2011-11-16 00:49 1282活动窗口(Active),焦点窗口(Focus)和前景 ... -
Android基础建设之View全注释
2011-11-16 00:19 3package android.view; impo ... -
Android游戏框架之基础之AA碰撞系统
2011-11-11 23:38 1666AA 碰撞体 就是将所有的物体设置为矩形框进行碰撞计算。下面是 ... -
Android游戏框架解读之总体结构
2011-11-11 01:08 1432Android游戏开发的框架图无偿奉上。
相关推荐
我建议您逐步阅读所有内容,但是如果您没有耐心,请转到“演示版postMessage 该插件使用Window.postMessage()方法( )在应用程序和kibana iframe之间进行连接var iframe = document.getElementById('Iframe');...
IWindow接口:定义所有窗口,并且Window实现了该接口 Module类:模块基类 PopModule类:弹出型环境类,继承Module PopWindow类:弹出型窗口,继承Window Window类:窗口基类 WindowEvent类:窗口事件类 Windows...
W api对象的Typescript接口和类型 纱 yarn add @web-lite/api-types --dev npm npm install @web-lite/api-types --save-dev 打字稿 import IWindow from '@web-lite/api-types' ; const W = ( window as IWindow )...
在这个项目中,我创建了一个抽象层,它提供了接口,属性和自动接口查询的概念。 假设的例子: int frame = videoPlayer[ &IPlaybackControl::CurrentFrame ]; videoPlayer[ &IPlaybackControl::Start ](); video...
做过BREW开发的都知道,不论是用IWINDOW还是StateMachine,都是应用的C语言,而且编译器也是采用的C编译器,而对于具有优良思想的面向对象的C++语言却应用的不多。