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

Commit a6a152e7 authored by Yohei Yukawa's avatar Yohei Yukawa
Browse files

Switch to SystemService lifecycle in TSMS.

Like we did this for InputMethodManagerService [1],
TextServicesManagerService (TSMS) needs to be recognized by
SystemServiceManager with SystemService lifecycle mechanism so that we
can receive SystemService#onUnlockUser() event, which is necessary to
make TSMS encryption-aware.

As a preparation, with this CL we only does mechcanical migration to
SystemService lifecycle mechanism in TSMS.  Hence no user-visible
behavior change should occur.

  [1]: Ic17667df60b30e5355b61a3601ad27a000cab3a3
       1e33dc8f

Bug: 27456430
Change-Id: Ib3cc799d384f259b4fa3f5295f2da198df015eb8
parent 77dd59fc
Loading
Loading
Loading
Loading
+28 −3
Original line number Original line Diff line number Diff line
@@ -83,11 +83,36 @@ public class TextServicesManagerService extends ITextServicesManager.Stub {
            new HashMap<String, SpellCheckerBindGroup>();
            new HashMap<String, SpellCheckerBindGroup>();
    private final TextServicesSettings mSettings;
    private final TextServicesSettings mSettings;


    public void systemRunning() {
    public static final class Lifecycle extends SystemService {
        private TextServicesManagerService mService;

        public Lifecycle(Context context) {
            super(context);
            mService = new TextServicesManagerService(context);
        }

        @Override
        public void onStart() {
            publishBinderService(Context.TEXT_SERVICES_MANAGER_SERVICE, mService);
        }

        @Override
        public void onBootPhase(int phase) {
            // Called on the system server's main looper thread.
            // TODO: Dispatch this to a worker thread as needed.
            if (phase == SystemService.PHASE_ACTIVITY_MANAGER_READY) {
                mService.systemRunning();
            }
        }
    }

    void systemRunning() {
        synchronized (mSpellCheckerMap) {
            if (!mSystemReady) {
            if (!mSystemReady) {
                mSystemReady = true;
                mSystemReady = true;
            }
            }
        }
        }
    }


    public TextServicesManagerService(Context context) {
    public TextServicesManagerService(Context context) {
        mSystemReady = false;
        mSystemReady = false;
+1 −16
Original line number Original line Diff line number Diff line
@@ -635,7 +635,6 @@ public final class SystemServer {
        WallpaperManagerService wallpaper = null;
        WallpaperManagerService wallpaper = null;
        LocationManagerService location = null;
        LocationManagerService location = null;
        CountryDetectorService countryDetector = null;
        CountryDetectorService countryDetector = null;
        TextServicesManagerService tsms = null;
        ILockSettings lockSettings = null;
        ILockSettings lockSettings = null;
        AssetAtlasService atlas = null;
        AssetAtlasService atlas = null;
        MediaRouterService mediaRouter = null;
        MediaRouterService mediaRouter = null;
@@ -762,14 +761,7 @@ public final class SystemServer {
            }
            }


            if (!disableNonCoreServices) {
            if (!disableNonCoreServices) {
                traceBeginAndSlog("StartTextServicesManagerService");
                mSystemServiceManager.startService(TextServicesManagerService.Lifecycle.class);
                try {
                    tsms = new TextServicesManagerService(context);
                    ServiceManager.addService(Context.TEXT_SERVICES_MANAGER_SERVICE, tsms);
                } catch (Throwable e) {
                    reportWtf("starting Text Service Manager Service", e);
                }
                Trace.traceEnd(Trace.TRACE_TAG_SYSTEM_SERVER);
            }
            }


            if (!disableNetwork) {
            if (!disableNetwork) {
@@ -1256,7 +1248,6 @@ public final class SystemServer {
        final CountryDetectorService countryDetectorF = countryDetector;
        final CountryDetectorService countryDetectorF = countryDetector;
        final NetworkTimeUpdateService networkTimeUpdaterF = networkTimeUpdater;
        final NetworkTimeUpdateService networkTimeUpdaterF = networkTimeUpdater;
        final CommonTimeManagementService commonTimeMgmtServiceF = commonTimeMgmtService;
        final CommonTimeManagementService commonTimeMgmtServiceF = commonTimeMgmtService;
        final TextServicesManagerService textServiceManagerServiceF = tsms;
        final StatusBarManagerService statusBarF = statusBar;
        final StatusBarManagerService statusBarF = statusBar;
        final AssetAtlasService atlasF = atlas;
        final AssetAtlasService atlasF = atlas;
        final InputManagerService inputManagerF = inputManager;
        final InputManagerService inputManagerF = inputManager;
@@ -1371,12 +1362,6 @@ public final class SystemServer {
                } catch (Throwable e) {
                } catch (Throwable e) {
                    reportWtf("Notifying CommonTimeManagementService running", e);
                    reportWtf("Notifying CommonTimeManagementService running", e);
                }
                }
                try {
                    if (textServiceManagerServiceF != null)
                        textServiceManagerServiceF.systemRunning();
                } catch (Throwable e) {
                    reportWtf("Notifying TextServicesManagerService running", e);
                }
                try {
                try {
                    if (atlasF != null) atlasF.systemRunning();
                    if (atlasF != null) atlasF.systemRunning();
                } catch (Throwable e) {
                } catch (Throwable e) {