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

Commit 442b805d authored by Yeabkal Wubshit's avatar Yeabkal Wubshit
Browse files

Avoid system app crashes for absent TEXT_SERVICES_MANAGER_SERVICE in Wear

Wear intentionally removes the TEXT_SERVICES_MANAGER_SERVICE, so an absence of that service should not throw an exception for any app in Wear. See http://ag/q/topic:%22wear_TextServicesManagerService%22 for details.

Bug: 335456104
Bug: 366125318
Test: manual
Flag: android.server.remove_text_service
Change-Id: If17cb7fe36024f2e03cf4dd3843e99b06036cd00
parent c99762b2
Loading
Loading
Loading
Loading
+11 −0
Original line number Diff line number Diff line
@@ -593,6 +593,11 @@ public final class SystemServiceRegistry {
            @Override
            public TextServicesManager createService(ContextImpl ctx)
                    throws ServiceNotFoundException {
                 if (ctx.getPackageManager().hasSystemFeature(PackageManager.FEATURE_WATCH)
                        && ServiceManager.getService(Context.TEXT_SERVICES_MANAGER_SERVICE) == null
                        && android.server.Flags.removeTextService()) {
                    return null;
                }
                return TextServicesManager.createInstance(ctx);
            }});

@@ -1887,6 +1892,12 @@ public final class SystemServiceRegistry {
                        return null;
                    }
                    break;
                case Context.TEXT_SERVICES_MANAGER_SERVICE:
                    if (android.server.Flags.removeTextService()
                            && hasSystemFeatureOpportunistic(ctx, PackageManager.FEATURE_WATCH)) {
                        return null;
                    }
                    break;
            }
            Slog.wtf(TAG, "Manager wrapper not available: " + name);
            return null;