Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 5522d654 authored by Oleg Blinnikov's avatar Oleg Blinnikov Committed by Android (Google) Code Review
Browse files

Merge changes I28d7f1d9,Iea5090e4 into main

* changes:
  Critical temperature error notification
  External display management on temperature changes
parents 75dd2c79 2e089f27
Loading
Loading
Loading
Loading
+29 −0
Original line number Diff line number Diff line
<!--
Copyright (C) 2023 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.
-->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
        android:width="24dp"
        android:height="24dp"
        android:viewportWidth="16"
        android:viewportHeight="16">
  <group>
    <clip-path
        android:pathData="M0,0h16v16h-16z"/>
    <path
        android:fillColor="#FFFFFFFF"
        android:fillType="evenOdd"
        android:pathData="M8.9,7.1V5.75H12.5V7.1H8.9ZM8.9,4.4V3.05L14.3,3.05V4.4L8.9,4.4ZM5.3,14.3C4.3,14.3 3.45,13.95 2.75,13.25C2.05,12.55 1.7,11.7 1.7,10.7C1.7,10.075 1.837,9.5 2.112,8.975C2.4,8.45 2.787,8.031 3.275,7.719L3.275,3.725C3.275,3.162 3.469,2.688 3.856,2.3C4.256,1.9 4.738,1.7 5.3,1.7C5.863,1.7 6.338,1.9 6.725,2.3C7.125,2.688 7.325,3.162 7.325,3.725V7.719C7.813,8.031 8.194,8.45 8.469,8.975C8.756,9.5 8.9,10.075 8.9,10.7C8.9,11.7 8.55,12.55 7.85,13.25C7.15,13.95 6.3,14.3 5.3,14.3ZM3.05,10.7L7.55,10.7C7.55,10.387 7.481,10.094 7.344,9.819C7.219,9.531 7.031,9.281 6.781,9.069L5.975,8.45L5.975,3.725C5.975,3.537 5.906,3.381 5.769,3.256C5.644,3.119 5.488,3.05 5.3,3.05C5.113,3.05 4.95,3.119 4.813,3.256C4.688,3.381 4.625,3.537 4.625,3.725L4.625,8.45L3.838,9.069C3.588,9.294 3.394,9.55 3.256,9.837C3.119,10.125 3.05,10.413 3.05,10.7Z" />
  </group>
</vector>
+3 −5
Original line number Diff line number Diff line
@@ -16,12 +16,10 @@ Copyright (C) 2023 The Android Open Source Project
<vector xmlns:android="http://schemas.android.com/apk/res/android"
        android:width="24dp"
        android:height="24dp"
        android:viewportWidth="20"
        android:viewportHeight="20">
        android:viewportWidth="16"
        android:viewportHeight="16">
    <path
        android:pathData="M15.333,5.333V4.667C15.333,4.3 15.033,4 14.667,4L13.333,4C12.967,4 12.667,4.3 12.667,4.667V5.333H12V8C12,8.367 12.3,8.667 12.667,8.667H13.333L13.333,13.333C13.333,14.067 12.733,14.667 12,14.667C11.267,14.667 10.667,14.067 10.667,13.333L10.667,11.333V6.667C10.667,5.193 9.473,4 8,4C6.527,4 5.333,5.193 5.333,6.667L5.333,11.333H4.667C4.3,11.333 4,11.633 4,12L4,14.667H4.667V15.333C4.667,15.7 4.967,16 5.333,16H6.667C7.033,16 7.333,15.7 7.333,15.333V14.667H8L8,12C8,11.633 7.7,11.333 7.333,11.333H6.667L6.667,6.667C6.667,5.933 7.267,5.333 8,5.333C8.733,5.333 9.333,5.933 9.333,6.667V11.333L9.333,13.333C9.333,14.807 10.527,16 12,16C13.473,16 14.667,14.807 14.667,13.333L14.667,8.667H15.333C15.7,8.667 16,8.367 16,8V5.333H15.333Z"
        android:pathData="M13.333,3.333V2.667C13.333,2.3 13.033,2 12.667,2L11.333,2C10.967,2 10.667,2.3 10.667,2.667V3.333H10V6C10,6.367 10.3,6.667 10.667,6.667H11.333L11.333,11.333C11.333,12.067 10.733,12.667 10,12.667C9.267,12.667 8.667,12.067 8.667,11.333L8.667,9.333V4.667C8.667,3.193 7.473,2 6,2C4.527,2 3.333,3.193 3.333,4.667L3.333,9.333H2.667C2.3,9.333 2,9.633 2,10L2,12.667H2.667V13.333C2.667,13.7 2.967,14 3.333,14H4.667C5.033,14 5.333,13.7 5.333,13.333V12.667H6L6,10C6,9.633 5.7,9.333 5.333,9.333H4.667L4.667,4.667C4.667,3.933 5.267,3.333 6,3.333C6.733,3.333 7.333,3.933 7.333,4.667L7.333,9.333L7.333,11.333C7.333,12.807 8.527,14 10,14C11.473,14 12.667,12.807 12.667,11.333L12.667,6.667H13.333C13.7,6.667 14,6.367 14,6V3.333H13.333Z"
        android:fillColor="#FFFFFFFF"
        android:fillType="evenOdd"/>
</vector>

+2 −0
Original line number Diff line number Diff line
@@ -6297,6 +6297,8 @@ ul.</string>
    <string name="connected_display_unavailable_notification_title">Can\'t mirror to display</string>
    <!-- Content of connected display unavailable notification. [CHAR LIMIT=NONE] -->
    <string name="connected_display_unavailable_notification_content">Use a different cable and try again</string>
    <!-- Content of connected display unavailable due to thermals notification. [CHAR LIMIT=NONE] -->
    <string name="connected_display_thermally_unavailable_notification_content">Your device is too warm and can\'t mirror to the display until it cools down</string>

    <!-- Title of cable don't support displays notifications. [CHAR LIMIT=NONE] -->
    <string name="connected_display_cable_dont_support_displays_notification_title">Cable may not support displays</string>
+2 −0
Original line number Diff line number Diff line
@@ -2006,6 +2006,7 @@
  <java-symbol type="drawable" name="vpn_connected" />
  <java-symbol type="drawable" name="vpn_disconnected" />
  <java-symbol type="drawable" name="usb_cable_unknown_issue" />
  <java-symbol type="drawable" name="ic_thermostat_notification" />
  <java-symbol type="id" name="ask_checkbox" />
  <java-symbol type="id" name="compat_checkbox" />
  <java-symbol type="id" name="original_app_icon" />
@@ -5085,6 +5086,7 @@
  <java-symbol type="array" name="device_state_notification_power_save_contents"/>
  <java-symbol type="string" name="connected_display_unavailable_notification_title"/>
  <java-symbol type="string" name="connected_display_unavailable_notification_content"/>
  <java-symbol type="string" name="connected_display_thermally_unavailable_notification_content"/>
  <java-symbol type="string" name="connected_display_cable_dont_support_displays_notification_title"/>
  <java-symbol type="string" name="connected_display_cable_dont_support_displays_notification_content"/>
  <java-symbol type="string" name="concurrent_display_notification_name"/>
+86 −25
Original line number Diff line number Diff line
@@ -102,11 +102,11 @@ import android.media.projection.IMediaProjection;
import android.media.projection.IMediaProjectionManager;
import android.net.Uri;
import android.os.Binder;
import android.os.Build;
import android.os.Handler;
import android.os.HandlerExecutor;
import android.os.IBinder;
import android.os.IBinder.DeathRecipient;
import android.os.IThermalService;
import android.os.Looper;
import android.os.Message;
import android.os.PowerManager;
@@ -241,9 +241,6 @@ public final class DisplayManagerService extends SystemService {

    private static final String PROP_DEFAULT_DISPLAY_TOP_INSET = "persist.sys.displayinset.top";

    @VisibleForTesting
    static final String ENABLE_ON_CONNECT =
            "persist.sys.display.enable_on_connect.external";
    private static final long WAIT_FOR_DEFAULT_DISPLAY_TIMEOUT = 10000;
    // This value needs to be in sync with the threshold
    // in RefreshRateConfigs::getFrameRateDivisor.
@@ -266,6 +263,7 @@ public final class DisplayManagerService extends SystemService {
    private final DisplayManagerHandler mHandler;
    private final Handler mUiHandler;
    private final DisplayModeDirector mDisplayModeDirector;
    private final ExternalDisplayPolicy mExternalDisplayPolicy;
    private WindowManagerInternal mWindowManagerInternal;
    private InputManagerInternal mInputManagerInternal;
    private ActivityManagerInternal mActivityManagerInternal;
@@ -598,6 +596,7 @@ public final class DisplayManagerService extends SystemService {
        mConfigParameterProvider = new DeviceConfigParameterProvider(DeviceConfigInterface.REAL);
        mExtraDisplayLoggingPackageName = DisplayProperties.debug_vri_package().orElse(null);
        mExtraDisplayEventLogging = !TextUtils.isEmpty(mExtraDisplayLoggingPackageName);
        mExternalDisplayPolicy = new ExternalDisplayPolicy(new ExternalDisplayPolicyInjector());
    }

    public void setupSchedulerPolicies() {
@@ -667,6 +666,7 @@ public final class DisplayManagerService extends SystemService {
            mDisplayModeDirector.onBootCompleted();
            mLogicalDisplayMapper.onBootCompleted();
            mDisplayNotificationManager.onBootCompleted();
            mExternalDisplayPolicy.onBootCompleted();
        }
    }

@@ -1947,17 +1947,12 @@ public final class DisplayManagerService extends SystemService {
        }

        setupLogicalDisplay(display);
        // TODO(b/292196201) Remove when the display can be disabled before DPC is created.
        if (display.getDisplayInfoLocked().type == Display.TYPE_EXTERNAL) {
            if ((Build.IS_ENG || Build.IS_USERDEBUG)
                    && SystemProperties.getBoolean(ENABLE_ON_CONNECT, false)) {
                Slog.w(TAG, "External display is enabled by default, bypassing user consent.");
            } else {
                display.setEnabledLocked(false);
            }
        }

        if (ExternalDisplayPolicy.isExternalDisplay(display)) {
            mExternalDisplayPolicy.handleExternalDisplayConnectedLocked(display);
        } else {
            sendDisplayEventLocked(display, DisplayManagerGlobal.EVENT_DISPLAY_CONNECTED);
        }

        updateLogicalDisplayState(display);
    }
@@ -3248,7 +3243,14 @@ public final class DisplayManagerService extends SystemService {

    void enableConnectedDisplay(int displayId, boolean enabled) {
        synchronized (mSyncRoot) {
            mLogicalDisplayMapper.setDisplayEnabledLocked(displayId, enabled);
            final var logicalDisplay = mLogicalDisplayMapper.getDisplayLocked(displayId);
            if (logicalDisplay == null) {
                Slog.w(TAG, "enableConnectedDisplay: Can not find displayId=" + displayId);
            } else if (ExternalDisplayPolicy.isExternalDisplay(logicalDisplay)) {
                mExternalDisplayPolicy.setExternalDisplayEnabledLocked(logicalDisplay, enabled);
            } else {
                mLogicalDisplayMapper.setDisplayEnabledLocked(logicalDisplay, enabled);
            }
        }
    }

@@ -4470,22 +4472,12 @@ public final class DisplayManagerService extends SystemService {
        @EnforcePermission(MANAGE_DISPLAYS)
        public void enableConnectedDisplay(int displayId) {
            enableConnectedDisplay_enforcePermission();
            if (!mFlags.isConnectedDisplayManagementEnabled()) {
                Slog.w(TAG, "External display management is not enabled on your device: "
                                    + "cannot enable display.");
                return;
            }
            DisplayManagerService.this.enableConnectedDisplay(displayId, true);
        }

        @EnforcePermission(MANAGE_DISPLAYS)
        public void disableConnectedDisplay(int displayId) {
            disableConnectedDisplay_enforcePermission();
            if (!mFlags.isConnectedDisplayManagementEnabled()) {
                Slog.w(TAG, "External display management is not enabled on your device: "
                                    + "cannot disable display.");
                return;
            }
            DisplayManagerService.this.enableConnectedDisplay(displayId, false);
        }
    }
@@ -5043,4 +5035,73 @@ public final class DisplayManagerService extends SystemService {
         */
        long uptimeMillis();
    }

    /**
     * Implements necessary functionality for {@link ExternalDisplayPolicy}
     */
    private class ExternalDisplayPolicyInjector implements ExternalDisplayPolicy.Injector {
        /**
         * Sends event for the display.
         */
        @Override
        public void sendExternalDisplayEventLocked(@NonNull final LogicalDisplay display,
                @DisplayEvent int event) {
            sendDisplayEventLocked(display, event);
        }

        /**
         * Gets thermal service
         */
        @Override
        @Nullable
        public IThermalService getThermalService() {
            return IThermalService.Stub.asInterface(ServiceManager.getService(
                    Context.THERMAL_SERVICE));
        }

        /**
         * @return display manager flags.
         */
        @Override
        @NonNull
        public DisplayManagerFlags getFlags() {
            return mFlags;
        }

        /**
         * @return Logical display mapper.
         */
        @Override
        @NonNull
        public LogicalDisplayMapper getLogicalDisplayMapper() {
            return mLogicalDisplayMapper;
        }

        /**
         * @return Sync root, for synchronization on this object across display manager.
         */
        @Override
        @NonNull
        public SyncRoot getSyncRoot() {
            return mSyncRoot;
        }

        /**
         * Notification manager for display manager
         */
        @Override
        @NonNull
        public DisplayNotificationManager getDisplayNotificationManager() {
            return mDisplayNotificationManager;
        }

        /**
         * Handler to use for notification sending to avoid requiring POST_NOTIFICATION permission.
         */
        @Override
        @NonNull
        public Handler getHandler() {
            return mHandler;
        }
    }
}
Loading