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

Commit 0382496d authored by Harshit Mahajan's avatar Harshit Mahajan
Browse files

Updating intent to use system services only.

ExplicitHealthCheckController is filtering the system services libraries by setting the package name.
We could simply pass the MATCH_SYSTEM_ONLY flag instead.
This way we could stop depending on
`getServicesSystemSharedLibraryPackageName` hidden API.

Bug: 338468233
Test: verified that ExplicitHealthCheckServiceImpl is connected
Flag: android.crashrecovery.flags.refactor_crashrecovery
Change-Id: Ie602aefd1280022fc6965ad31e4d872c33904dd9
parent 254a519d
Loading
Loading
Loading
Loading
+27 −15
Original line number Diff line number Diff line
@@ -15,6 +15,7 @@
 */

package com.android.server;
import static android.crashrecovery.flags.Flags.refactorCrashrecovery;
import static android.service.watchdog.ExplicitHealthCheckService.EXTRA_HEALTH_CHECK_PASSED_PACKAGE;
import static android.service.watchdog.ExplicitHealthCheckService.EXTRA_REQUESTED_PACKAGES;
import static android.service.watchdog.ExplicitHealthCheckService.EXTRA_SUPPORTED_PACKAGES;
@@ -41,7 +42,6 @@ import android.util.ArraySet;
import android.util.Slog;

import com.android.internal.annotations.GuardedBy;
import com.android.internal.util.Preconditions;

import java.util.Collection;
import java.util.Collections;
@@ -363,6 +363,17 @@ class ExplicitHealthCheckController {
    @GuardedBy("mLock")
    @Nullable
    private ServiceInfo getServiceInfoLocked() {
        if (refactorCrashrecovery()) {
            final Intent intent = new Intent(ExplicitHealthCheckService.SERVICE_INTERFACE);
            final ResolveInfo resolveInfo = mContext.getPackageManager().resolveService(intent,
                    PackageManager.GET_SERVICES | PackageManager.GET_META_DATA
                            |  PackageManager.MATCH_SYSTEM_ONLY);
            if (resolveInfo == null || resolveInfo.serviceInfo == null) {
                Slog.w(TAG, "No valid components found.");
                return null;
            }
            return resolveInfo.serviceInfo;
        } else {
            final String packageName =
                    mContext.getPackageManager().getServicesSystemSharedLibraryPackageName();
            if (packageName == null) {
@@ -380,6 +391,7 @@ class ExplicitHealthCheckController {
            }
            return resolveInfo.serviceInfo;
        }
    }

    @GuardedBy("mLock")
    @Nullable