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

Commit 2f288432 authored by Felipe Leme's avatar Felipe Leme
Browse files

Fixed Content Capture workflow when service package is updated.

The workflow already handles the case where the service dies and the framework re-establishes
the binder connection, but that didn't work when it died because the package was being updated.

This CL fixes this scenario by gracefully pausing the existing sessions before the package is
updated, then resuming them afterwards.

Test: manual verification
Test: atest CtsContentCaptureServiceTestCases # sanity check minus flakiness

Bug: 126266412
Fixes: 129072171

Change-Id: Ibc6b723c7bc08b4f920436f365d6006bc8fac7b6
parent c9a92abc
Loading
Loading
Loading
Loading
+0 −1
Original line number Diff line number Diff line
@@ -367,7 +367,6 @@ public abstract class ContentCaptureService extends Service {
            stateFlags = initialState;
        } else {
            stateFlags |= ContentCaptureSession.STATE_DISABLED;

        }
        setClientState(clientReceiver, stateFlags, mClientInterface.asBinder());
    }
+8 −1
Original line number Diff line number Diff line
@@ -134,12 +134,19 @@ public abstract class ContentCaptureSession implements AutoCloseable {
     */
    public static final int STATE_SERVICE_DIED = 0x400;

    /**
     * Session is disabled because the service package is being udpated.
     *
     * @hide
     */
    public static final int STATE_SERVICE_UPDATING = 0x800;

    /**
     * Session is enabled, after the service died and came back to live.
     *
     * @hide
     */
    public static final int STATE_SERVICE_RESURRECTED = 0x800;
    public static final int STATE_SERVICE_RESURRECTED = 0x1000;

    private static final int INITIAL_CHILDREN_CAPACITY = 5;

+2 −1
Original line number Diff line number Diff line
@@ -230,7 +230,8 @@ public final class MainContentCaptureSession extends ContentCaptureSession {

    /**
     * Callback from {@code system_server} after call to
     * {@link IContentCaptureManager#startSession(IBinder, ComponentName, String, int, IBinder)}
     * {@link IContentCaptureManager#startSession(IBinder, ComponentName, String, int,
     * IResultReceiver)}.
     *
     * @param resultCode session state
     * @param binder handle to {@code IContentCaptureDirectManager}
+5 −1
Original line number Diff line number Diff line
@@ -481,7 +481,11 @@ public abstract class AbstractRemoteService<S extends AbstractRemoteService<S, I

    @Override
    public String toString() {
        return getClass().getSimpleName() + "[" + mComponentName + "]";
        return getClass().getSimpleName() + "[" + mComponentName
                + " " + System.identityHashCode(this)
                + (mService != null ? " (bound)" : " (unbound)")
                + (mDestroyed ? " (destroyed)" : "")
                + "]";
    }

    /**
+16 −0
Original line number Diff line number Diff line
@@ -166,6 +166,22 @@ public final class ContentCaptureManagerService extends
        service.destroyLocked();
    }

    @Override // from AbstractMasterSystemService
    protected void onServicePackageUpdatingLocked(int userId) {
        final ContentCapturePerUserService service = getServiceForUserLocked(userId);
        if (service != null) {
            service.onPackageUpdatingLocked();
        }
    }

    @Override // from AbstractMasterSystemService
    protected void onServicePackageUpdatedLocked(@UserIdInt int userId) {
        final ContentCapturePerUserService service = getServiceForUserLocked(userId);
        if (service != null) {
            service.onPackageUpdatedLocked();
        }
    }

    @Override // from AbstractMasterSystemService
    protected void enforceCallingPermissionForManagement() {
        getContext().enforceCallingPermission(MANAGE_CONTENT_CAPTURE, mTag);
Loading