Android14 WMS-窗口添加流程(二)-Server端

上一篇文章講到了Client端窗口添加流程,本文接著上文往下講,講一下Server端的窗口添加流程。

1. WindowManagerService#grantInputChannel

? ? ? ? 由grantInputChannel我們可以看到,Client端傳入了session對象, 發起者Uid-callingUid,發起者pid-callingPid, 要顯示屏幕的displayId, 要顯示的圖層surface,用于返回到客戶端窗口,讓WMS使用它來通知客戶端的IWindow對象window,窗口的flags, 窗口的privateFlags,窗口的inputFeatures以及窗口類型,windowToken,以及InputChannel,用戶應用端和WMS端雙方互相通信的通路已經鋪好了。

    /**
將 InputChannel 分配給 SurfaceControl,并將其配置為根據其屏幕上的幾何圖形接收觸摸輸入。
由 WindowlessWindowManager 用于啟用 SurfaceControl 嵌入視圖的輸入。*/void grantInputChannel(Session session, int callingUid, int callingPid,int displayId, SurfaceControl surface, IWindow window, IBinder hostInputToken,int flags, int privateFlags, int inputFeatures, int type, IBinder windowToken,IBinder focusGrantToken, String inputHandleName, InputChannel outInputChannel) {final int sanitizedType = sanitizeWindowType(session, displayId, windowToken, type);final InputApplicationHandle applicationHandle;final String name;final InputChannel clientChannel;synchronized (mGlobalLock) {
//EmbeddedWindowController是用于跟蹤嵌入式窗口。
// 如果嵌入的窗口沒有收到輸入,則窗口管理器不會跟蹤它。但是,如果他們確實收到輸入,我們會跟蹤調用 PID 以歸咎于正確的應用和主機窗口以發送 pointerDownOutsideFocus。EmbeddedWindowController.EmbeddedWindow win =new EmbeddedWindowController.EmbeddedWindow(session, this, window,mInputToWindowMap.get(hostInputToken), callingUid, callingPid,sanitizedType, displayId, focusGrantToken, inputHandleName,(flags & FLAG_NOT_FOCUSABLE) == 0);
//client輸入通道確認clientChannel = win.openInputChannel();
//增加一個新的嵌入窗口mEmbeddedWindowController.add(clientChannel.getToken(), win);applicationHandle = win.getApplicationHandle();name = win.toString();}
//updateInputChannelupdateInputChannel(clientChannel.getToken(), callingUid, callingPid, displayId, surface, name, applicationHandle, flags, privateFlags, inputFeatures, sanitizedType, null /* region */, window);clientChannel.copyTo(outInputChannel);}

這里有個很重要的IWindow,官方介紹是API back to a client window that the Window Manager uses to inform it of?interesting things happening. 也就是說是是用于WMS回調客戶端的,當窗口有一些改變時,WMS及時調用客戶端接口,讓客戶端窗口立即更新。

IWindow.aidl - OpenGrok cross reference for /frameworks/base/core/java/android/view/IWindow.aidl

/*** API back to a client window that the Window Manager uses to inform it of* interesting things happening.** {@hide}*/
oneway interface IWindow {/*** ===== NOTICE =====* The first method must remain the first method. Scripts* and tools rely on their transaction number to work properly.*//*** Invoked by the view server to tell a window to execute the specified* command. Any response from the receiver must be sent through the* specified file descriptor.*/void executeCommand(String command, String parameters, in ParcelFileDescriptor descriptor);void resized(in ClientWindowFrames frames, boolean reportDraw,in MergedConfiguration newMergedConfiguration, in InsetsState insetsState,boolean forceLayout, boolean alwaysConsumeSystemBars, int displayId,int syncSeqId, boolean dragResizing);/*** Called when this window retrieved control over a specified set of insets sources.*/void insetsControlChanged(in InsetsState insetsState, in InsetsSourceControl[] activeControls);/*** Called when a set of insets source window should be shown by policy.** @param types internal insets types (WindowInsets.Type.InsetsType) to show* @param fromIme true if this request originated from IME (InputMethodService).* @param statsToken the token tracking the current IME show request or {@code null} otherwise.*/void showInsets(int types, boolean fromIme, in @nullable ImeTracker.Token statsToken);/*** Called when a set of insets source window should be hidden by policy.** @param types internal insets types (WindowInsets.Type.InsetsType) to hide* @param fromIme true if this request originated from IME (InputMethodService).* @param statsToken the token tracking the current IME hide request or {@code null} otherwise.*/void hideInsets(int types, boolean fromIme, in @nullable ImeTracker.Token statsToken);void moved(int newX, int newY);void dispatchAppVisibility(boolean visible);void dispatchGetNewSurface();void closeSystemDialogs(String reason);/*** Called for wallpaper windows when their offsets or zoom level change.*/void dispatchWallpaperOffsets(float x, float y, float xStep, float yStep, float zoom, boolean sync);void dispatchWallpaperCommand(String action, int x, int y,int z, in Bundle extras, boolean sync);/*** Drag/drop events*/void dispatchDragEvent(in DragEvent event);/*** Pointer icon events*/void updatePointerIcon(float x, float y);/*** Called for non-application windows when the enter animation has completed.*/void dispatchWindowShown();/*** Called when Keyboard Shortcuts are requested for the window.*/void requestAppKeyboardShortcuts(IResultReceiver receiver, int deviceId);/*** Called when Scroll Capture support is requested for a window.** @param callbacks to receive responses*/void requestScrollCapture(in IScrollCaptureResponseListener callbacks);
}

IWindow是怎么賦值并一步步傳入WMS端的呢,由下面代碼可以看出,它是在ViewRootImpl中進行賦值的


//定義
?    final W mWindow;
...public ViewRootImpl(@UiContext Context context, Display display, IWindowSession session, WindowLayout windowLayout) {...mWindow = new W(this);... }W如下static class W extends IWindow.Stub {private final WeakReference<ViewRootImpl> mViewAncestor;private final IWindowSession mWindowSession;W(ViewRootImpl viewAncestor) {mViewAncestor = new WeakReference<ViewRootImpl>(viewAncestor);mWindowSession = viewAncestor.mWindowSession;}
...public void setView(View view, WindowManager.LayoutParams attrs, View panelParentView, int userId) {
//此時將mWindow傳入res = mWindowSession.addToDisplayAsUser(mWindow, mWindowAttributes,getHostVisibility(), mDisplay.getDisplayId(), userId,mInsetsController.getRequestedVisibleTypes(), inputChannel, mTempInsets, mTempControls, attachedFrame, compatScale);
?

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/bicheng/18376.shtml
繁體地址,請注明出處:http://hk.pswp.cn/bicheng/18376.shtml
英文地址,請注明出處:http://en.pswp.cn/bicheng/18376.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

X.509數字證書

在國密標準文件《GMT 0015-2012 基于SM2密碼算法的數字證書格式》里有對X.509數字證書格式的詳細描述。 數字證書的定義 由國家認可的&#xff0c;具有權威性、可信性和公正性的第三方證書認證機構&#xff08;CA&#xff09;進行數字簽名的一個可信的數字化文件。 數字證書…

YOLOv10代碼詳細介紹(附錄訓練教程和權重)

前言 YOLOv10 是清華大學研究人員在 UltralyticsPython 清華大學的研究人員在 YOLOv10軟件包的基礎上&#xff0c;引入了一種新的實時目標檢測方法&#xff0c;解決了YOLO 以前版本在后處理和模型架構方面的不足。通過消除非最大抑制&#xff08;NMS&#xff09;和優化各種模型…

【幾何角度】感知機

本質&#xff1a;將n維空間中的一些點線性投影到一維&#xff0c;在一維軸上找一個閾值對這些點進行二分類。 程序&#xff1a; import numpy as npclass Perceptron:def __init__(self, learning_rate0.01, n_iterations1000):self.learning_rate learning_rateself.n_itera…

【Python基礎】一文搞懂:Python 中 “requirements.txt“ 文件生成和使用

文章目錄 1 引言2 什么是 requirements.txt&#xff1f;3 如何生成 requirements.txt&#xff1f;3.1 方法一&#xff1a;使用 pip freeze3.2 方法二&#xff1a;使用 pipreqs 3.3 使用 pip freeze 和 pipreqs 的對比4 如何使用 requirements.txt&#xff1f;4.1 安裝依賴4.2 更…

[從零開發JS應用] 如何在VScode中配置Javascript環境,常見的調試方法有哪些?

一、安裝VSCode和Node.js 記錄環境配置&#xff1a;本文配置的環境主要針對單獨JS文件的斷點調試&#xff0c;主要是為了調試LeetCode里面的代碼。 首先在官網下載對應的版本&#xff1a;https://nodejs.org/en/ 開始安裝&#xff0c;可以自定義選擇安裝路徑。 這里選擇Add Pa…

【親測,安卓版】快速將網頁網址打包成安卓app,一鍵將網頁打包成app,免安裝純綠色版本,快速將網頁網址打包成安卓apk

背景&#xff1a;部分客戶需求將自己網站打包成app&#xff0c;供用戶在瀏覽器安裝使用、 網頁網址快速生成app 準備材料操作流程第一步&#xff1a;打開HBuilder X新建項目第二步創建Wap2App項目第三步修改App圖標第四步發布app第五步查看apk 準備材料 1.需要打包的網頁 2.ap…

在網頁開發中,前后端如何更好地協同工作?

在網頁開發中&#xff0c;前后端如何更好地協同工作是非常關鍵的&#xff0c;以下是一些方法和技巧可以幫助前后端更好地協同工作&#xff1a; 1.明確需求和規范&#xff1a;前后端應該共同討論和明確項目的需求和規范&#xff0c;包括功能、界面、數據格式等。確保雙方對項目…

頁面加載不出來,報錯[@umijs/runtime] load component failed

問題描述 頁面加載不出來數據&#xff0c;一直在旋轉&#xff0c;控制臺輸出內容如下&#xff1a; 原因分析&#xff1a; 之前頁面是沒有問題的&#xff0c;在寫當前頁面突然出現頁面加載不出來&#xff0c;控制臺報錯&#xff0c;主要是頁面引入了這行代碼報錯 import { …

MX Component基礎使用(多點位讀取,多點位寫入)

步驟&#xff0c;先連接PLC&#xff0c;然后在填入對應的點位 D10 然后去讀取。 using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Linq;using System.Text;using System.Threading.Tasks;us…

邊緣計算網關的主要功能有哪些?天拓四方

隨著物聯網&#xff08;IoT&#xff09;的快速發展和普及&#xff0c;邊緣計算網關已經成為了數據處理和傳輸的重要樞紐。作為一種集成數據采集、協議轉換、數據處理、數據聚合和遠程控制等多種功能的設備&#xff0c;邊緣計算網關在降低網絡延遲、提高數據處理效率以及減輕云數…

民國漫畫雜志《時代漫畫》第13期.PDF

時代漫畫13.PDF: https://url03.ctfile.com/f/1779803-1247458360-14efab?p9586 (訪問密碼: 9586) 《時代漫畫》的雜志在1934年誕生了&#xff0c;截止1937年6月戰爭來臨被迫停刊共發行了39期。 ps:資源來源網絡&#xff01;

數組的定義、順序存儲及特殊矩陣的存儲

目錄 一、數組的定義 1.1概念 1.2抽象數據類型定義 二、數組的順序存儲 2.1一維數組元素的存儲位置 2.2二維數組元素的存儲位置 2.3三維數組元素的存儲位置 三、特殊矩陣的壓縮存儲 3.1相關概念 3.2對稱矩陣 3.3三角矩陣 3.4對角矩陣&#xff08;帶狀矩陣&#xff0…

【機器學習300問】102、什么是混淆矩陣?

一、混淆矩陣的定義 混淆矩陣是一種用于評估分類模型性能的評估指標。當模型對數據進行預測并將數據分配到預定義的類別時&#xff0c;混淆矩陣提供了一種直觀的方式來總結這些預測與數據實際類別之間的對應關系。具體來說&#xff0c;它是一個表格。 二、分類模型性能評估一級…

私域用戶畫像分析

為什么做私域要分析用戶畫像&#xff1f; 1、更好地了解用戶需求&#xff1a;通過分析用戶畫像&#xff0c;可以深入了解用戶的需求、偏好、行為等特征&#xff0c;從而更好地滿足他們的需求。 2、個性化營銷&#xff1a;根據用戶畫像&#xff0c;可以為用戶提供個性化的營銷…

js setTimeout、setInterval、promise、async await執行順序梳理

基礎知識 async: 關鍵字用于標記一個函數為異步函數&#xff0c;該函數中有一個或多個promise對象&#xff0c;需要等待執行完成后才會繼續執行。 await:關鍵字&#xff0c;用于等待一個promise對象執行完&#xff0c;并返回其中的值&#xff0c;只能在async函數內部使用。可…

云服務器平臺AutoDL--基本介紹與使用感受

因為課程作業需要復現DreamBooth&#xff0c;找了幾個教程之后&#xff0c;發現了AutoDL這個好東西&#xff0c;蕪湖~ 相關概念 以下回答來自于ChatGPT。 云計算平臺&#xff1a;云服務器平臺是提供按需計算資源和服務的在線平臺&#xff0c;通常包括存儲、處理能力、數據庫、…

搜維爾科技:使用Haption Virtuose 6D 力反饋通過機器人和虛擬現實完成遠程操作項目

使用Haption Virtuose 6D 力反饋通過機器人和虛擬現實完成遠程操作項目 搜維爾科技&#xff1a;使用Haption Virtuose 6D 力反饋通過機器人和虛擬現實完成遠程操作項目

【Python設計模式06】代理模式

代理模式&#xff08;Proxy Pattern&#xff09;是一種結構型設計模式&#xff0c;它通過創建代理對象來控制對另一個對象的訪問。代理模式可以用于延遲實例化、控制訪問權限、記錄日志等。代理模式的核心思想是為其他對象提供一種代理&#xff0c;以控制對這個對象的訪問。 代…

System32文件夾千萬不能刪除,看完這篇你就知道為什么了

序言 C:\Windows\System32目錄是Windows操作系統的關鍵部分,重要的系統文件存儲在該目錄中。網上的一些惡作劇者可能會告訴你刪除它,但你不應該嘗試去操作,如果你嘗試的話,我們會告訴你會發生什么。 什么是System32文件夾 位于C:\Windows\System32的System32文件夾是所有…

Python深度學習:【模型系列】Transformer面試靈魂20問

1. transformer簡介 Transformer模型是一種基于自注意力機制的神經網絡架構,主要用于處理序列數據,如自然語言處理任務。它由Google在2017年提出,并在“Attention is All You Need”這篇論文中首次公開。Transformer模型的核心思想是利用自注意力機制來捕捉序列中的依賴關系…