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

Commit e22dfb8c authored by Shashwat Razdan's avatar Shashwat Razdan Committed by Automerger Merge Worker
Browse files

Merge "Revert "Adding multiple provider support in AbstractMasterSystem...""...

Merge "Revert "Adding multiple provider support in AbstractMasterSystem..."" into tm-dev am: 68688e2e

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/17060491

Change-Id: I372bc2c10add443e1e0c42863b8026a8c82eb093
parents 945e459d 68688e2e
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -4130,9 +4130,9 @@
          This service must be trusted, as it can be activated without explicit consent of the user.
          If no service with the specified name exists on the device, cloudsearch will be disabled.
          Example: "com.android.intelligence/.CloudSearchService"
          config_defaultCloudSearchServices is for the multiple provider case.
          config_defaultCloudSearchService is for the single provider case.
    -->
    <string-array name="config_defaultCloudSearchServices"></string-array>
    <string name="config_defaultCloudSearchService" translatable="false"></string>

    <!-- The package name for the system's translation service.
     This service must be trusted, as it can be activated without explicit consent of the user.
+1 −1
Original line number Diff line number Diff line
@@ -3677,7 +3677,7 @@
  <java-symbol type="string" name="notification_channel_network_status" />
  <java-symbol type="string" name="notification_channel_network_alerts" />
  <java-symbol type="string" name="notification_channel_network_available" />
  <java-symbol type="array" name="config_defaultCloudSearchServices" />
  <java-symbol type="string" name="config_defaultCloudSearchService" />
  <java-symbol type="string" name="notification_channel_vpn" />
  <java-symbol type="string" name="notification_channel_device_admin" />
  <java-symbol type="string" name="notification_channel_alerts" />
+13 −44
Original line number Diff line number Diff line
@@ -43,8 +43,6 @@ import com.android.server.infra.FrameworkResourcesServiceNameResolver;
import com.android.server.wm.ActivityTaskManagerInternal;

import java.io.FileDescriptor;
import java.util.ArrayList;
import java.util.List;
import java.util.function.Consumer;

/**
@@ -64,7 +62,7 @@ public class CloudSearchManagerService extends

    public CloudSearchManagerService(Context context) {
        super(context, new FrameworkResourcesServiceNameResolver(context,
                        R.array.config_defaultCloudSearchServices, true), null,
                        R.string.config_defaultCloudSearchService), null,
                PACKAGE_UPDATE_POLICY_NO_REFRESH | PACKAGE_RESTART_POLICY_NO_REFRESH);
        mActivityTaskManagerInternal = LocalServices.getService(ActivityTaskManagerInternal.class);
        mContext = context;
@@ -72,25 +70,7 @@ public class CloudSearchManagerService extends

    @Override
    protected CloudSearchPerUserService newServiceLocked(int resolvedUserId, boolean disabled) {
        return new CloudSearchPerUserService(this, mLock, resolvedUserId, "");
    }

    @Override
    protected List<CloudSearchPerUserService> newServiceListLocked(int resolvedUserId,
            boolean disabled, String[] serviceNames) {
        if (serviceNames == null) {
            return new ArrayList<>();
        }
        List<CloudSearchPerUserService> serviceList =
                new ArrayList<>(serviceNames.length);
        for (int i = 0; i < serviceNames.length; i++) {
            if (serviceNames[i] == null) {
                continue;
            }
            serviceList.add(new CloudSearchPerUserService(this, mLock, resolvedUserId,
                    serviceNames[i]));
        }
        return serviceList;
        return new CloudSearchPerUserService(this, mLock, resolvedUserId);
    }

    @Override
@@ -131,28 +111,19 @@ public class CloudSearchManagerService extends
                @NonNull ICloudSearchManagerCallback callBack) {
            searchRequest.setCallerPackageName(
                    mContext.getPackageManager().getNameForUid(Binder.getCallingUid()));
            runForUser("search", (service) -> {
                synchronized (service.mLock) {
                    service.onSearchLocked(searchRequest, callBack);
                }
            });
            runForUserLocked("search", searchRequest.getRequestId(), (service) ->
                    service.onSearchLocked(searchRequest, callBack));
        }

        @Override
        public void returnResults(IBinder token, String requestId, SearchResponse response) {
            runForUser("returnResults", (service) -> {
                synchronized (service.mLock) {
                    service.onReturnResultsLocked(token, requestId, response);
                }
            });
            runForUserLocked("returnResults", requestId, (service) ->
                    service.onReturnResultsLocked(token, requestId, response));
        }

        public void destroy(@NonNull SearchRequest searchRequest) {
            runForUser("destroyCloudSearchSession", (service) -> {
                synchronized (service.mLock) {
                    service.onDestroyLocked(searchRequest.getRequestId());
                }
            });
            runForUserLocked("destroyCloudSearchSession", searchRequest.getRequestId(),
                    (service) -> service.onDestroyLocked(searchRequest.getRequestId()));
        }

        public void onShellCommand(@Nullable FileDescriptor in, @Nullable FileDescriptor out,
@@ -163,7 +134,8 @@ public class CloudSearchManagerService extends
                    .exec(this, in, out, err, args, callback, resultReceiver);
        }

        private void runForUser(@NonNull final String func,
        private void runForUserLocked(@NonNull final String func,
                @NonNull final String  requestId,
                @NonNull final Consumer<CloudSearchPerUserService> c) {
            ActivityManagerInternal am = LocalServices.getService(ActivityManagerInternal.class);
            final int userId = am.handleIncomingUser(Binder.getCallingPid(), Binder.getCallingUid(),
@@ -171,7 +143,7 @@ public class CloudSearchManagerService extends
                    null, null);

            if (DEBUG) {
                Slog.d(TAG, "runForUser:" + func + " from pid=" + Binder.getCallingPid()
                Slog.d(TAG, "runForUserLocked:" + func + " from pid=" + Binder.getCallingPid()
                        + ", uid=" + Binder.getCallingUid());
            }
            Context ctx = getContext();
@@ -188,11 +160,8 @@ public class CloudSearchManagerService extends
            final long origId = Binder.clearCallingIdentity();
            try {
                synchronized (mLock) {
                    final List<CloudSearchPerUserService> services =
                            getServiceListForUserLocked(userId);
                    for (int i = 0; i < services.size(); i++) {
                        c.accept(services.get(i));
                    }
                    final CloudSearchPerUserService service = getServiceForUserLocked(userId);
                    c.accept(service);
                }
            } finally {
                Binder.restoreCallingIdentity(origId);
+1 −6
Original line number Diff line number Diff line
@@ -54,12 +54,7 @@ public class CloudSearchManagerServiceShellCommand extends ShellCommand {
                            return 0;
                        }
                        final int duration = Integer.parseInt(getNextArgRequired());
                        String[] services = serviceName.split(";");
                        if (services.length == 0) {
                            return 0;
                        } else {
                            mService.setTemporaryServices(userId, services, duration);
                        }
                        mService.setTemporaryService(userId, serviceName, duration);
                        pw.println("CloudSearchService temporarily set to " + serviceName
                                + " for " + duration + "ms");
                        break;
+4 −20
Original line number Diff line number Diff line
@@ -49,8 +49,6 @@ public class CloudSearchPerUserService extends
    @GuardedBy("mLock")
    private final CircularQueue<String, CloudSearchCallbackInfo> mCallbackQueue =
            new CircularQueue<>(QUEUE_SIZE);
    private final String mServiceName;
    private final ComponentName mRemoteComponentName;
    @Nullable
    @GuardedBy("mLock")
    private RemoteCloudSearchService mRemoteService;
@@ -62,10 +60,8 @@ public class CloudSearchPerUserService extends
    private boolean mZombie;

    protected CloudSearchPerUserService(CloudSearchManagerService master,
            Object lock, int userId, String serviceName) {
            Object lock, int userId) {
        super(master, lock, userId);
        mServiceName = serviceName;
        mRemoteComponentName = ComponentName.unflattenFromString(mServiceName);
    }

    @Override // from PerUserSystemService
@@ -112,7 +108,7 @@ public class CloudSearchPerUserService extends
                ? searchRequest.getSearchConstraints().getString(
                SearchRequest.CONSTRAINT_SEARCH_PROVIDER_FILTER) : "";

        String remoteServicePackageName = mRemoteComponentName.getPackageName();
        String remoteServicePackageName = getServiceComponentName().getPackageName();
        // By default, all providers are marked as wanted.
        boolean wantedProvider = true;
        if (filterList.length() > 0) {
@@ -154,19 +150,11 @@ public class CloudSearchPerUserService extends
    /**
     * Used to return results back to the clients.
     */
    @GuardedBy("mLock")
    public void onReturnResultsLocked(@NonNull IBinder token,
            @NonNull String requestId,
            @NonNull SearchResponse response) {
        if (mRemoteService == null) {
            return;
        }
        ICloudSearchService serviceInterface = mRemoteService.getServiceInterface();
        if (serviceInterface == null || token != serviceInterface.asBinder()) {
            return;
        }
        if (mCallbackQueue.containsKey(requestId)) {
            response.setSource(mServiceName);
            response.setSource(mRemoteService.getComponentName().getPackageName());
            final CloudSearchCallbackInfo sessionInfo = mCallbackQueue.getElement(requestId);
            try {
                if (response.getStatusCode() == SearchResponse.SEARCH_STATUS_OK) {
@@ -175,10 +163,6 @@ public class CloudSearchPerUserService extends
                    sessionInfo.mCallback.onSearchFailed(response);
                }
            } catch (RemoteException e) {
                if (mMaster.debug) {
                    Slog.e(TAG, "Exception in posting results");
                    e.printStackTrace();
                }
                onDestroyLocked(requestId);
            }
        }
@@ -313,7 +297,7 @@ public class CloudSearchPerUserService extends
    @Nullable
    private RemoteCloudSearchService getRemoteServiceLocked() {
        if (mRemoteService == null) {
            final String serviceName = getComponentNameForMultipleLocked(mServiceName);
            final String serviceName = getComponentNameLocked();
            if (serviceName == null) {
                if (mMaster.verbose) {
                    Slog.v(TAG, "getRemoteServiceLocked(): not set");
Loading