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

Commit 674b1cfc authored by Guliz Tuncay's avatar Guliz Tuncay
Browse files

Track update count of TSMS#mSpellCheckerMap

TextServicesManagerService#buildSpellCheckerMapLocked() is known be
one of the biggest contributors to CPU and I/O bandwidth consumed
by TextServicesManagerService (TSMS). To check when it gets called
and to see how a CL would affect its call count, it would be useful
if we can easily get the call count of that method.

With this CL, how many times TSMS#mSpellCheckerMap was rebuilt will be
included in the dumpsys.

Bug: 64449660
Test: adb shell dumpsys textservices | grep "mSpellCheckerMapUpdateCount="
      to make sure the count is increasing with each switch between
      users.
Change-Id: Ia1f50c756c332b3329b6e28e8edb7673cf9124f2
parent 443d9cac
Loading
Loading
Loading
Loading
+6 −1
Original line number Diff line number Diff line
@@ -89,6 +89,8 @@ public class TextServicesManagerService extends ITextServicesManager.Stub {
    @NonNull
    private final UserManager mUserManager;
    private final Object mLock = new Object();
    @GuardedBy("mLock")
    private int mSpellCheckerMapUpdateCount = 0;

    public static final class Lifecycle extends SystemService {
        private TextServicesManagerService mService;
@@ -242,11 +244,12 @@ public class TextServicesManagerService extends ITextServicesManager.Stub {
        }
    }

    private static void buildSpellCheckerMapLocked(Context context,
    private void buildSpellCheckerMapLocked(Context context,
            ArrayList<SpellCheckerInfo> list, HashMap<String, SpellCheckerInfo> map,
            @UserIdInt int userId) {
        list.clear();
        map.clear();
        mSpellCheckerMapUpdateCount++;
        final PackageManager pm = context.getPackageManager();
        // Note: We do not specify PackageManager.MATCH_ENCRYPTION_* flags here because the default
        // behavior of PackageManager is exactly what we want.  It by default picks up appropriate
@@ -690,6 +693,8 @@ public class TextServicesManagerService extends ITextServicesManager.Stub {

        synchronized (mLock) {
            pw.println("Current Text Services Manager state:");
            pw.println("  Spell Checkers: mSpellCheckerMapUpdateCount="
                    + mSpellCheckerMapUpdateCount);
            pw.println("  Spell Checkers:");
            int spellCheckerIndex = 0;
            for (final SpellCheckerInfo info : mSpellCheckerMap.values()) {