How is the NotificationShadeWindowView added to WindowManager?

CentralSurfacesImpl  is a CoreStartable .

com.android.systemui.statusbar.phone.CentralSurfacesImpl#start()

com.android.systemui.statusbar.phone.CentralSurfacesImpl#createAndAddWindows()

com.android.systemui.shade.NotificationShadeWindowControllerImpl#attach()

super_notification_shade.xml:

<?xml version="1.0" encoding="utf-8"?>
<!--
**
** Copyright 2020, The Android Open Source Project
**
** Licensed under the Apache License, Version 2.0 (the "License");
** you may not use this file except in compliance with the License.
** You may obtain a copy of the License at
**
**     http://www.apache.org/licenses/LICENSE-2.0
**
** Unless required by applicable law or agreed to in writing, software
** distributed under the License is distributed on an "AS IS" BASIS,
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
** See the License for the specific language governing permissions and
** limitations under the License.
*/
-->

<!-- This is the notification shade window. -->
<com.android.systemui.shade.NotificationShadeWindowView
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:sysui="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fitsSystemWindows="true">

    <com.android.systemui.statusbar.BackDropView
        android:id="@+id/backdrop"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:visibility="gone"
        sysui:ignoreRightInset="true"
    >
        <ImageView android:id="@+id/backdrop_back"
                   android:layout_width="match_parent"
                   android:scaleType="centerCrop"
                   android:layout_height="match_parent" />
        <ImageView android:id="@+id/backdrop_front"
                   android:layout_width="match_parent"
                   android:layout_height="match_parent"
                   android:scaleType="centerCrop"
                   android:visibility="invisible" />
    </com.android.systemui.statusbar.BackDropView>

    <com.android.systemui.scrim.ScrimView
        android:id="@+id/scrim_behind"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:importantForAccessibility="no"
        sysui:ignoreRightInset="true"
    />

    <com.android.systemui.scrim.ScrimView
        android:id="@+id/scrim_notifications"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:importantForAccessibility="no"
        sysui:ignoreRightInset="true"
    />

    <com.android.systemui.statusbar.LightRevealScrim
        android:id="@+id/light_reveal_scrim"
        android:layout_width="match_parent"
        android:layout_height="match_parent" />

    <include layout="@layout/status_bar_expanded"
             android:layout_width="match_parent"
             android:layout_height="match_parent"
             android:visibility="invisible" />

    <include layout="@layout/brightness_mirror_container" />

    <com.android.systemui.scrim.ScrimView
        android:id="@+id/scrim_in_front"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:importantForAccessibility="no"
        sysui:ignoreRightInset="true"
    />

    <!-- Keyguard messages -->
    <LinearLayout
        android:id="@+id/keyguard_message_area_container"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical"
        android:layout_marginTop="@dimen/status_bar_height"
        android:layout_gravity="top|center_horizontal"
        android:gravity="center_horizontal">
        <com.android.keyguard.AuthKeyguardMessageArea
            android:id="@+id/keyguard_message_area"
            style="@style/Keyguard.TextView"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginTop="@dimen/keyguard_lock_padding"
            android:gravity="center"
            android:singleLine="true"
            android:ellipsize="marquee"
            android:focusable="true" />
    </LinearLayout>

    <FrameLayout android:id="@+id/keyguard_bouncer_container"
        android:paddingTop="@dimen/status_bar_height"
        android:layout_height="match_parent"
        android:layout_width="match_parent"
        android:layout_weight="1"
        android:background="@android:color/transparent"
        android:visibility="invisible"
        android:clipChildren="false"
        android:clipToPadding="false" />

    <com.android.systemui.biometrics.AuthRippleView
        android:id="@+id/auth_ripple"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:importantForAccessibility="no"
        sysui:ignoreRightInset="true"
    />
</com.android.systemui.shade.NotificationShadeWindowView>
  • 3
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
通过 WindowManager 添加 GLSurfaceView 的基本步骤如下: 1. 在 Service 中创建一个 GLSurfaceView 对象,并将其添加到 WindowManager 中: ```java // 创建 GLSurfaceView 对象 GLSurfaceView glSurfaceView = new GLSurfaceView(this); // 将 GLSurfaceView 添加到 WindowManagerWindowManager.LayoutParams params = new WindowManager.LayoutParams( WindowManager.LayoutParams.MATCH_PARENT, WindowManager.LayoutParams.MATCH_PARENT, WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY, // 需要添加 SYSTEM_ALERT_WINDOW 权限 WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE | WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE, PixelFormat.TRANSLUCENT); WindowManager windowManager = (WindowManager) getSystemService(WINDOW_SERVICE); windowManager.addView(glSurfaceView, params); ``` 其中,`TYPE_APPLICATION_OVERLAY` 是在 Android 8.0 及以上版本中可用的一种窗口类型,用于在应用程序之上显示窗口。需要添加 `SYSTEM_ALERT_WINDOW` 权限才能使用该窗口类型。 2. 实现 GLSurfaceView.Renderer 接口,并在其中实现必要的渲染逻辑: ```java class MyRenderer implements GLSurfaceView.Renderer { @Override public void onSurfaceCreated(GL10 gl, EGLConfig config) { // 执行必要的初始化操作 } @Override public void onSurfaceChanged(GL10 gl, int width, int height) { // 处理窗口尺寸变化事件 } @Override public void onDrawFrame(GL10 gl) { // 执行渲染操作 } } // 设置 Renderer glSurfaceView.setRenderer(new MyRenderer()); ``` 在实现 GLSurfaceView.Renderer 接口时,你需要实现 `onSurfaceCreated`、`onSurfaceChanged` 和 `onDrawFrame` 三个方法,分别用于初始化、处理窗口尺寸变化和渲染操作。 3. 在 Service 的 onDestroy 方法中,移除 GLSurfaceView: ```java @Override public void onDestroy() { super.onDestroy(); windowManager.removeView(glSurfaceView); } ``` 以上就是通过 WindowManager 添加 GLSurfaceView 的基本步骤。需要注意的是,添加 GLSurfaceView 后,你需要自己管理 EGL 上下文和表面,以确保正确的渲染和显示。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值