把Android中setSurface部分的源码发给我
时间: 2024-02-20 07:01:59 浏览: 19
好的,以下是Android中setSurface方法的部分源码:
```java
/**
* This is called by the WindowManager with the new Surface that is being
* used to display this window. For non-embedded applications it will always
* be the same as the Surface passed to create().
*
* @param surface The Surface being used to display this window.
*/
public void onWindowAttributesChanged(WindowManager.LayoutParams attrs) {
synchronized (mWindowManagerLock) {
final int fl = attrs.flags;
if ((fl&WindowManager.LayoutParams.FLAG_SHOW_WALLPAPER) != 0) {
if (!mShowWallpaper) {
mShowWallpaper = true;
if (mLastSurface != null) {
try {
mSession.setWallpaperPosition(mWindow, mLastSurface.getWidth(),
mLastSurface.getHeight(), mLastSurfaceLayer);
} catch (RemoteException e) {
}
updateSurface(false, false);
}
}
} else if ((fl&WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD) != 0) {
if (!mDismissKeyguardOnNextSurfaceUpdate) {
mDismissKeyguardOnNextSurfaceUpdate = true;
updateSurface(false, false);
}
} else {
mShowWallpaper = false;
}
if (mSurfaceHolder != null) {
mSurfaceHolder.setFlags(
(attrs.flags&WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON)
| (attrs.flags&WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON),
WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON
| WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON);
}
}
}
```
注意,这里只展示了部分源码,如果您需要完整的源码,建议到Android源码仓库中查看。