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

Commit c55b854b authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Check if the wallpaper service exists before use."

parents 7495af74 674a4a0f
Loading
Loading
Loading
Loading
+16 −11
Original line number Original line Diff line number Diff line
@@ -905,16 +905,14 @@ public class WallpaperManagerService extends IWallpaperManager.Stub
            return;
            return;
        }
        }
        if (supportsMultiDisplay(systemConnection)
        if (supportsMultiDisplay(systemConnection)
                && fallbackConnection.getConnectedEngineSize() != 0) {
                && fallbackConnection.mDisplayConnector.size() != 0) {
            fallbackConnection.forEachDisplayConnector(
            fallbackConnection.forEachDisplayConnector(connector -> {
                    WallpaperConnection.DisplayConnector::disconnectLocked);
                if (connector.mEngine != null) {
                    connector.disconnectLocked();
                }
            });
            fallbackConnection.mDisplayConnector.clear();
            fallbackConnection.mDisplayConnector.clear();
        } else {
        } else {
            // TODO(b/121181553) Handle wallpaper service disconnect case.
            if (fallbackConnection.mService == null) {
                Slog.w(TAG, "There is no fallback wallpaper service");
                return;
            }
            fallbackConnection.appendConnectorWithCondition(display ->
            fallbackConnection.appendConnectorWithCondition(display ->
                    fallbackConnection.isUsableDisplay(display)
                    fallbackConnection.isUsableDisplay(display)
                            && display.getDisplayId() != DEFAULT_DISPLAY
                            && display.getDisplayId() != DEFAULT_DISPLAY
@@ -965,6 +963,10 @@ public class WallpaperManagerService extends IWallpaperManager.Stub
            }
            }


            void connectLocked(WallpaperConnection connection, WallpaperData wallpaper) {
            void connectLocked(WallpaperConnection connection, WallpaperData wallpaper) {
                if (connection.mService == null) {
                    Slog.w(TAG, "WallpaperService is not connected yet");
                    return;
                }
                if (DEBUG) Slog.v(TAG, "Adding window token: " + mToken);
                if (DEBUG) Slog.v(TAG, "Adding window token: " + mToken);
                try {
                try {
                    mIWindowManager.addWindowToken(mToken, TYPE_WALLPAPER, mDisplayId);
                    mIWindowManager.addWindowToken(mToken, TYPE_WALLPAPER, mDisplayId);
@@ -980,7 +982,7 @@ public class WallpaperManagerService extends IWallpaperManager.Stub
                            wpdData.mPadding, mDisplayId);
                            wpdData.mPadding, mDisplayId);
                } catch (RemoteException e) {
                } catch (RemoteException e) {
                    Slog.w(TAG, "Failed attaching wallpaper on display", e);
                    Slog.w(TAG, "Failed attaching wallpaper on display", e);
                    if (mLastWallpaper != null && !mLastWallpaper.wallpaperUpdating
                    if (wallpaper != null && !wallpaper.wallpaperUpdating
                            && connection.getConnectedEngineSize() == 0) {
                            && connection.getConnectedEngineSize() == 0) {
                        bindWallpaperComponentLocked(null /* componentName */, false /* force */,
                        bindWallpaperComponentLocked(null /* componentName */, false /* force */,
                                false /* fromUser */, wallpaper, null /* reply */);
                                false /* fromUser */, wallpaper, null /* reply */);
@@ -1067,11 +1069,14 @@ public class WallpaperManagerService extends IWallpaperManager.Stub
            for (Display display : displays) {
            for (Display display : displays) {
                if (tester.test(display)) {
                if (tester.test(display)) {
                    final int displayId = display.getDisplayId();
                    final int displayId = display.getDisplayId();
                    final DisplayConnector connector = mDisplayConnector.get(displayId);
                    if (connector == null) {
                        mDisplayConnector.append(displayId,
                        mDisplayConnector.append(displayId,
                                new DisplayConnector(displayId));
                                new DisplayConnector(displayId));
                    }
                    }
                }
                }
            }
            }
        }


        private boolean isUsableDisplay(Display display) {
        private boolean isUsableDisplay(Display display) {
            return display != null &&  display.hasAccess(mClientUid)
            return display != null &&  display.hasAccess(mClientUid)