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

Commit 3748d0e3 authored by Justin Chung's avatar Justin Chung
Browse files

Do not generate WTF for the SearchManager query

1. getSystemService() can generate WTF error, if service is not available
   from the device. But since search service is not available from the
   watch device, the query to the service should not print the WTF.
2. Still WTF was reported from the phone side too, due to the race of
   init order. To handle this, make PhoneWindowManager to not to call
   getSystemService for SearchService from init, but call in on demand.

Bug: 297928943
Test: Manual test from SearchManager non-available device
Change-Id: I7e3f7060f436aac28da8442773ca957c2e4cc172
parent 6182bc4a
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -1647,6 +1647,12 @@ public final class SystemServiceRegistry {
                case Context.VIRTUALIZATION_SERVICE:
                case Context.VIRTUAL_DEVICE_SERVICE:
                    return null;
                case Context.SEARCH_SERVICE:
                    // Wear device does not support SEARCH_SERVICE so we do not print WTF here
                    PackageManager manager = ctx.getPackageManager();
                    if (manager != null && manager.hasSystemFeature(PackageManager.FEATURE_WATCH)) {
                        return null;
                    }
            }
            Slog.wtf(TAG, "Manager wrapper not available: " + name);
            return null;
+3 −4
Original line number Diff line number Diff line
@@ -438,7 +438,6 @@ public class PhoneWindowManager implements WindowManagerPolicy {
    boolean mPreloadedRecentApps;
    final Object mServiceAcquireLock = new Object();
    Vibrator mVibrator; // Vibrator for giving feedback of orientation changes
    SearchManager mSearchManager;
    AccessibilityManager mAccessibilityManager;
    AccessibilityManagerInternal mAccessibilityManagerInternal;
    BurnInProtectionHelper mBurnInProtectionHelper;
@@ -2217,7 +2216,6 @@ public class PhoneWindowManager implements WindowManagerPolicy {
        mPowerManagerInternal = LocalServices.getService(PowerManagerInternal.class);
        mAppOpsManager = mContext.getSystemService(AppOpsManager.class);
        mSensorPrivacyManager = mContext.getSystemService(SensorPrivacyManager.class);
        mSearchManager = mContext.getSystemService(SearchManager.class);
        mDisplayManager = mContext.getSystemService(DisplayManager.class);
        mDisplayManagerInternal = LocalServices.getService(DisplayManagerInternal.class);
        mUserManagerInternal = LocalServices.getService(UserManagerInternal.class);
@@ -4009,8 +4007,9 @@ public class PhoneWindowManager implements WindowManagerPolicy {
        args.putLong(Intent.EXTRA_TIME, eventTime);
        args.putInt(AssistUtils.INVOCATION_TYPE_KEY, invocationType);

        if (mSearchManager != null) {
            mSearchManager.launchAssist(args);
        SearchManager searchManager = mContext.getSystemService(SearchManager.class);
        if (searchManager != null) {
            searchManager.launchAssist(args);
        } else {
            // Fallback to status bar if search manager doesn't exist (e.g. on wear).
            StatusBarManagerInternal statusBar = getStatusBarManagerInternal();
+1 −1
Original line number Diff line number Diff line
@@ -447,7 +447,7 @@ class TestPhoneWindowManager {
    }

    void overrideSearchManager(SearchManager searchManager) {
        mPhoneWindowManager.mSearchManager = searchManager;
        doReturn(searchManager).when(mContext).getSystemService(eq(SearchManager.class));
    }

    void assumeResolveActivityNotNull() {