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

Commit a86cce68 authored by Yeabkal Wubshit's avatar Yeabkal Wubshit
Browse files

Do not start SelectionToolbarManagerService for Wear

The logic to get the SelectionToolbarManager API class has also been
updated to ensure that no call to Context.getSystemService made for
SelectionToolbarManager does not cause crashes.

Bug: 407778313
Flag: EXEMPT minor change, removing service not used on Wear
Test: presubmit, and tests (see CL topic)
Change-Id: Ice836d1ca3908ffe284fd98c886e4bcf89560614
parent 72544d2f
Loading
Loading
Loading
Loading
+18 −2
Original line number Diff line number Diff line
@@ -453,8 +453,24 @@ public final class SystemServiceRegistry {
                    @Override
                    public SelectionToolbarManager createService(ContextImpl ctx)
                            throws ServiceNotFoundException {
                        IBinder b = ServiceManager.getServiceOrThrow(
                                Context.SELECTION_TOOLBAR_SERVICE);
                        final PackageManager pm = ctx.getPackageManager();
                        final boolean serviceRequired =
                                !pm.hasSystemFeature(PackageManager.FEATURE_WATCH)
                                && !pm.hasSystemFeature(PackageManager.FEATURE_LEANBACK);
                        // If the service is required on the device, use `getServiceOrThrow`, which
                        // will throw an Exception if the service is missing.
                        // If the service is not required on the device, use `getService`. This
                        // method simply returns `null` if the service is absent. Avoiding the
                        // Exception is critical for such devices, because the Exception may cause
                        // process crashes, and we do not want that given that the service is not
                        // mandatory.
                        IBinder b = serviceRequired
                                ? ServiceManager.getServiceOrThrow(
                                        Context.SELECTION_TOOLBAR_SERVICE)
                                : ServiceManager.getService(Context.SELECTION_TOOLBAR_SERVICE);
                        if (b == null) {
                            return null;
                        }
                        return new SelectionToolbarManager(
                                ISelectionToolbarManager.Stub.asInterface(b));
                    }});
+1 −1
Original line number Diff line number Diff line
@@ -3016,7 +3016,7 @@ public final class SystemServer implements Dumpable {
        mSystemServiceManager.startService(ClipboardService.class);
        t.traceEnd();

        if (!isTv) {
        if (!isTv && !isWatch) {
            // Selection toolbar service
            t.traceBegin("StartSelectionToolbarManagerService");
            mSystemServiceManager.startService(SelectionToolbarManagerService.class);