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

Commit 661e08f2 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Fixed how temporary remote services are set."

parents 59a7bc04 18a9a4a7
Loading
Loading
Loading
Loading
+15 −4
Original line number Diff line number Diff line
@@ -274,10 +274,14 @@ public abstract class AbstractMasterSystemService<M extends AbstractMasterSystem
        }

        synchronized (mLock) {
            final S service = getServiceForUserLocked(userId);
            if (service != null) {
                service.setTemporaryServiceLocked(componentName, durationMs);
            final S oldService = peekServiceForUserLocked(userId);
            if (oldService != null) {
                oldService.removeSelfFromCacheLocked();
            }
            mServiceNameResolver.setTemporaryService(userId, componentName, durationMs);

            // Must update the service on cache so its initialization code is triggered
            updateCachedServiceLocked(userId);
        }
    }

@@ -500,6 +504,7 @@ public abstract class AbstractMasterSystemService<M extends AbstractMasterSystem
    protected void dumpLocked(@NonNull String prefix, @NonNull PrintWriter pw) {
        boolean realDebug = debug;
        boolean realVerbose = verbose;
        final String prefix2 = "    ";

        try {
            // Temporarily turn on full logging;
@@ -510,6 +515,13 @@ public abstract class AbstractMasterSystemService<M extends AbstractMasterSystem
            if (mServiceNameResolver != null) {
                pw.print(prefix); pw.print("Name resolver: ");
                mServiceNameResolver.dumpShort(pw); pw.println();
                final UserManager um = getContext().getSystemService(UserManager.class);
                final List<UserInfo> users = um.getUsers();
                for (int i = 0; i < users.size(); i++) {
                    final int userId = users.get(i).id;
                    pw.print(prefix2); pw.print(userId); pw.print(": ");
                    mServiceNameResolver.dumpShort(pw, userId); pw.println();
                }
            }
            pw.print(prefix); pw.print("Disabled users: "); pw.println(mDisabledUsers);
            pw.print(prefix); pw.print("Allow instant service: "); pw.println(mAllowInstantService);
@@ -522,7 +534,6 @@ public abstract class AbstractMasterSystemService<M extends AbstractMasterSystem
                pw.println("none");
            } else {
                pw.println(size);
                final String prefix2 = "    ";
                for (int i = 0; i < size; i++) {
                    pw.print(prefix); pw.print("Service at "); pw.print(i); pw.println(": ");
                    final S service = mServicesCache.valueAt(i);
+1 −12
Original line number Diff line number Diff line
@@ -214,7 +214,7 @@ public abstract class AbstractPerUserSystemService<S extends AbstractPerUserSyst

    /**
     * Gets the current name of the service, which is either the default service or the
     *  {@link #setTemporaryServiceLocked(String, int) temporary one}.
     *  {@link AbstractMasterSystemService#setTemporaryService(int, String, int) temporary one}.
     */
    protected final @Nullable String getComponentNameLocked() {
        return mMaster.mServiceNameResolver.getServiceName(mUserId);
@@ -227,17 +227,6 @@ public abstract class AbstractPerUserSystemService<S extends AbstractPerUserSyst
        return mMaster.mServiceNameResolver.isTemporary(mUserId);
    }

    /**
     * Temporary sets the service implementation.
     *
     * @param componentName name of the new component
     * @param durationMs how long the change will be valid (the service will be automatically reset
     * to the default component after this timeout expires).
     */
    protected final void setTemporaryServiceLocked(@NonNull String componentName, int durationMs) {
        mMaster.mServiceNameResolver.setTemporaryService(mUserId, componentName, durationMs);
    }

    /**
     * Resets the temporary service implementation to the default component.
     */
+1 −1
Original line number Diff line number Diff line
@@ -159,7 +159,7 @@ public final class FrameworkResourcesServiceNameResolver implements ServiceNameR

    @Override
    public String toString() {
        return "FrameworkResourcesServiceNamer: temps=" + mTemporaryServiceNames;
        return "FrameworkResourcesServiceNamer[temps=" + mTemporaryServiceNames + "]";
    }

    // TODO(b/117779333): support proto
+5 −0
Original line number Diff line number Diff line
@@ -56,4 +56,9 @@ public final class SecureSettingsServiceNameResolver implements ServiceNameResol
    public void dumpShort(@NonNull PrintWriter pw, @UserIdInt int userId) {
        pw.print("defaultService="); pw.print(getDefaultServiceName(userId));
    }

    @Override
    public String toString() {
        return "SecureSettingsServiceNameResolver[" + mProperty + "]";
    }
}