Loading services/core/java/com/android/server/DockObserver.java +15 −2 Original line number Diff line number Diff line Loading @@ -79,6 +79,8 @@ final class DockObserver extends SystemService { private final List<ExtconStateConfig> mExtconStateConfigs; private DeviceProvisionedObserver mDeviceProvisionedObserver; private final DockObserverLocalService mDockObserverLocalService; static final class ExtconStateProvider { private final Map<String, String> mState; Loading Loading @@ -193,13 +195,21 @@ final class DockObserver extends SystemService { } else { Slog.i(TAG, "No extcon dock device found in this kernel."); } mDockObserverLocalService = new DockObserverLocalService(); LocalServices.addService(DockObserverInternal.class, mDockObserverLocalService); } public class DockObserverLocalService extends DockObserverInternal { @Override public int getActualDockState() { return mActualDockState; } } @Override public void onStart() { publishBinderService(TAG, new BinderService()); // Logs dock state after setDockStateFromProviderLocked sets mReportedDockState FrameworkStatsLog.write(FrameworkStatsLog.DOCK_STATE_CHANGED, mReportedDockState); } @Override Loading Loading @@ -230,6 +240,9 @@ final class DockObserver extends SystemService { private void setDockStateLocked(int newState) { if (newState != mReportedDockState) { mReportedDockState = newState; // Here is the place mReportedDockState is updated. Logs dock state for // mReportedDockState here so we can report the dock state. FrameworkStatsLog.write(FrameworkStatsLog.DOCK_STATE_CHANGED, mReportedDockState); if (mSystemReady) { // Wake up immediately when docked or undocked unless prohibited from doing so. if (allowWakeFromDock()) { Loading services/core/java/com/android/server/DockObserverInternal.java 0 → 100644 +25 −0 Original line number Diff line number Diff line /* * Copyright (C) 2025 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. */ package com.android.server; /** * @hide Only for use within the system server. */ public abstract class DockObserverInternal { /** Retrieve the current dock state from DockObserver. */ public abstract int getActualDockState(); } services/core/java/com/android/server/policy/PhoneWindowManager.java +10 −6 Original line number Diff line number Diff line Loading @@ -239,6 +239,7 @@ import com.android.internal.policy.TransitionAnimation; import com.android.internal.statusbar.IStatusBarService; import com.android.internal.widget.LockPatternUtils; import com.android.server.AccessibilityManagerInternal; import com.android.server.DockObserverInternal; import com.android.server.ExtconStateObserver; import com.android.server.ExtconUEventObserver; import com.android.server.GestureLauncherService; Loading Loading @@ -473,6 +474,7 @@ public class PhoneWindowManager implements WindowManagerPolicy { DisplayManager mDisplayManager; DisplayManagerInternal mDisplayManagerInternal; UserManagerInternal mUserManagerInternal; DockObserverInternal mDockObserverInternal; private WallpaperManagerInternal mWallpaperManagerInternal; Loading Loading @@ -2452,12 +2454,7 @@ public class PhoneWindowManager implements WindowManagerPolicy { filter.addAction(UiModeManager.ACTION_ENTER_DESK_MODE); filter.addAction(UiModeManager.ACTION_EXIT_DESK_MODE); filter.addAction(Intent.ACTION_DOCK_EVENT); Intent intent = mContext.registerReceiver(mDockReceiver, filter); if (intent != null) { // Retrieve current sticky dock event broadcast. mDefaultDisplayPolicy.setDockMode(intent.getIntExtra(Intent.EXTRA_DOCK_STATE, Intent.EXTRA_DOCK_STATE_UNDOCKED)); } mContext.registerReceiver(mDockReceiver, filter); // register for multiuser-relevant broadcasts filter = new IntentFilter(Intent.ACTION_USER_SWITCHED); Loading Loading @@ -6756,6 +6753,13 @@ public class PhoneWindowManager implements WindowManagerPolicy { mVrManagerInternal.addPersistentVrModeStateListener(mPersistentVrModeListener); } mDockObserverInternal = LocalServices.getService(DockObserverInternal.class); if (mDockObserverInternal != null) { // Get initial state from DockObserverInternal, DockObserver starts after WM. int dockMode = mDockObserverInternal.getActualDockState(); mDefaultDisplayPolicy.setDockMode(dockMode); } readCameraLensCoverState(); updateUiMode(); mDefaultDisplayRotation.updateOrientationListener(); Loading Loading
services/core/java/com/android/server/DockObserver.java +15 −2 Original line number Diff line number Diff line Loading @@ -79,6 +79,8 @@ final class DockObserver extends SystemService { private final List<ExtconStateConfig> mExtconStateConfigs; private DeviceProvisionedObserver mDeviceProvisionedObserver; private final DockObserverLocalService mDockObserverLocalService; static final class ExtconStateProvider { private final Map<String, String> mState; Loading Loading @@ -193,13 +195,21 @@ final class DockObserver extends SystemService { } else { Slog.i(TAG, "No extcon dock device found in this kernel."); } mDockObserverLocalService = new DockObserverLocalService(); LocalServices.addService(DockObserverInternal.class, mDockObserverLocalService); } public class DockObserverLocalService extends DockObserverInternal { @Override public int getActualDockState() { return mActualDockState; } } @Override public void onStart() { publishBinderService(TAG, new BinderService()); // Logs dock state after setDockStateFromProviderLocked sets mReportedDockState FrameworkStatsLog.write(FrameworkStatsLog.DOCK_STATE_CHANGED, mReportedDockState); } @Override Loading Loading @@ -230,6 +240,9 @@ final class DockObserver extends SystemService { private void setDockStateLocked(int newState) { if (newState != mReportedDockState) { mReportedDockState = newState; // Here is the place mReportedDockState is updated. Logs dock state for // mReportedDockState here so we can report the dock state. FrameworkStatsLog.write(FrameworkStatsLog.DOCK_STATE_CHANGED, mReportedDockState); if (mSystemReady) { // Wake up immediately when docked or undocked unless prohibited from doing so. if (allowWakeFromDock()) { Loading
services/core/java/com/android/server/DockObserverInternal.java 0 → 100644 +25 −0 Original line number Diff line number Diff line /* * Copyright (C) 2025 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. */ package com.android.server; /** * @hide Only for use within the system server. */ public abstract class DockObserverInternal { /** Retrieve the current dock state from DockObserver. */ public abstract int getActualDockState(); }
services/core/java/com/android/server/policy/PhoneWindowManager.java +10 −6 Original line number Diff line number Diff line Loading @@ -239,6 +239,7 @@ import com.android.internal.policy.TransitionAnimation; import com.android.internal.statusbar.IStatusBarService; import com.android.internal.widget.LockPatternUtils; import com.android.server.AccessibilityManagerInternal; import com.android.server.DockObserverInternal; import com.android.server.ExtconStateObserver; import com.android.server.ExtconUEventObserver; import com.android.server.GestureLauncherService; Loading Loading @@ -473,6 +474,7 @@ public class PhoneWindowManager implements WindowManagerPolicy { DisplayManager mDisplayManager; DisplayManagerInternal mDisplayManagerInternal; UserManagerInternal mUserManagerInternal; DockObserverInternal mDockObserverInternal; private WallpaperManagerInternal mWallpaperManagerInternal; Loading Loading @@ -2452,12 +2454,7 @@ public class PhoneWindowManager implements WindowManagerPolicy { filter.addAction(UiModeManager.ACTION_ENTER_DESK_MODE); filter.addAction(UiModeManager.ACTION_EXIT_DESK_MODE); filter.addAction(Intent.ACTION_DOCK_EVENT); Intent intent = mContext.registerReceiver(mDockReceiver, filter); if (intent != null) { // Retrieve current sticky dock event broadcast. mDefaultDisplayPolicy.setDockMode(intent.getIntExtra(Intent.EXTRA_DOCK_STATE, Intent.EXTRA_DOCK_STATE_UNDOCKED)); } mContext.registerReceiver(mDockReceiver, filter); // register for multiuser-relevant broadcasts filter = new IntentFilter(Intent.ACTION_USER_SWITCHED); Loading Loading @@ -6756,6 +6753,13 @@ public class PhoneWindowManager implements WindowManagerPolicy { mVrManagerInternal.addPersistentVrModeStateListener(mPersistentVrModeListener); } mDockObserverInternal = LocalServices.getService(DockObserverInternal.class); if (mDockObserverInternal != null) { // Get initial state from DockObserverInternal, DockObserver starts after WM. int dockMode = mDockObserverInternal.getActualDockState(); mDefaultDisplayPolicy.setDockMode(dockMode); } readCameraLensCoverState(); updateUiMode(); mDefaultDisplayRotation.updateOrientationListener(); Loading