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

Commit 7f794c42 authored by Reema Bajwa's avatar Reema Bajwa
Browse files

Fix cancellation on the provider side

This change makes the aidl interface for CredentialProviderService
oneway as per the guidance for transactions going out of system service.

Test: built & deployed locally
Bug: 270439131

Change-Id: I70a30fe0f1073e418f8046f7e40d58e3bd3e2c0f
parent 0126a404
Loading
Loading
Loading
Loading
+19 −6
Original line number Diff line number Diff line
@@ -231,12 +231,18 @@ public abstract class CredentialProviderService extends Service {
    }

    private final ICredentialProviderService mInterface = new ICredentialProviderService.Stub() {
        public ICancellationSignal onBeginGetCredential(BeginGetCredentialRequest request,
        @Override
        public void onBeginGetCredential(BeginGetCredentialRequest request,
                IBeginGetCredentialCallback callback) {
            Objects.requireNonNull(request);
            Objects.requireNonNull(callback);

            ICancellationSignal transport = CancellationSignal.createTransport();
            try {
                callback.onCancellable(transport);
            } catch (RemoteException e) {
                e.rethrowFromSystemServer();
            }

            mHandler.sendMessage(obtainMessage(
                    CredentialProviderService::onBeginGetCredential,
@@ -267,7 +273,6 @@ public abstract class CredentialProviderService extends Service {
                        }
                    }
            ));
            return transport;
        }
        private void enforceRemoteEntryPermission() {
            String permission =
@@ -280,12 +285,17 @@ public abstract class CredentialProviderService extends Service {
        }

        @Override
        public ICancellationSignal onBeginCreateCredential(BeginCreateCredentialRequest request,
        public void onBeginCreateCredential(BeginCreateCredentialRequest request,
                IBeginCreateCredentialCallback callback) {
            Objects.requireNonNull(request);
            Objects.requireNonNull(callback);

            ICancellationSignal transport = CancellationSignal.createTransport();
            try {
                callback.onCancellable(transport);
            } catch (RemoteException e) {
                e.rethrowFromSystemServer();
            }

            mHandler.sendMessage(obtainMessage(
                    CredentialProviderService::onBeginCreateCredential,
@@ -316,16 +326,20 @@ public abstract class CredentialProviderService extends Service {
                        }
                    }
            ));
            return transport;
        }

        @Override
        public ICancellationSignal onClearCredentialState(ClearCredentialStateRequest request,
        public void onClearCredentialState(ClearCredentialStateRequest request,
                IClearCredentialStateCallback callback) {
            Objects.requireNonNull(request);
            Objects.requireNonNull(callback);

            ICancellationSignal transport = CancellationSignal.createTransport();
            try {
                callback.onCancellable(transport);
            } catch (RemoteException e) {
                e.rethrowFromSystemServer();
            }

            mHandler.sendMessage(obtainMessage(
                    CredentialProviderService::onClearCredentialState,
@@ -350,7 +364,6 @@ public abstract class CredentialProviderService extends Service {
                        }
                    }
            ));
            return transport;
        }
    };

+2 −0
Original line number Diff line number Diff line
package android.service.credentials;

import android.service.credentials.BeginCreateCredentialResponse;
import android.os.ICancellationSignal;

/**
 * Interface from the system to a credential provider service.
@@ -10,4 +11,5 @@ import android.service.credentials.BeginCreateCredentialResponse;
oneway interface IBeginCreateCredentialCallback {
    void onSuccess(in BeginCreateCredentialResponse request);
    void onFailure(String errorType, in CharSequence message);
    void onCancellable(in ICancellationSignal cancellation);
}
 No newline at end of file
+3 −0
Original line number Diff line number Diff line
package android.service.credentials;

import android.service.credentials.BeginGetCredentialResponse;
import android.os.ICancellationSignal;


/**
 * Interface from the system to a credential provider service.
@@ -10,4 +12,5 @@ import android.service.credentials.BeginGetCredentialResponse;
oneway interface IBeginGetCredentialCallback {
    void onSuccess(in BeginGetCredentialResponse response);
    void onFailure(String errorType, in CharSequence message);
    void onCancellable(in ICancellationSignal cancellation);
}
 No newline at end of file
+7 −3
Original line number Diff line number Diff line
@@ -16,12 +16,16 @@

package android.service.credentials;

import android.os.ICancellationSignal;


/**
 * Callback for onClearCredentialState request.
 *
 * @hide
 */
interface IClearCredentialStateCallback {
    oneway void onSuccess();
    oneway void onFailure(String errorType, CharSequence message);
oneway interface IClearCredentialStateCallback {
    void onSuccess();
    void onFailure(String errorType, CharSequence message);
    void onCancellable(in ICancellationSignal cancellation);
}
 No newline at end of file
+4 −4
Original line number Diff line number Diff line
@@ -30,8 +30,8 @@ import android.os.ICancellationSignal;
 *
 * @hide
 */
interface ICredentialProviderService {
    ICancellationSignal onBeginGetCredential(in BeginGetCredentialRequest request, in IBeginGetCredentialCallback callback);
    ICancellationSignal onBeginCreateCredential(in BeginCreateCredentialRequest request, in IBeginCreateCredentialCallback callback);
    ICancellationSignal onClearCredentialState(in ClearCredentialStateRequest request, in IClearCredentialStateCallback callback);
oneway interface ICredentialProviderService {
    void onBeginGetCredential(in BeginGetCredentialRequest request, in IBeginGetCredentialCallback callback);
    void onBeginCreateCredential(in BeginCreateCredentialRequest request, in IBeginCreateCredentialCallback callback);
    void onClearCredentialState(in ClearCredentialStateRequest request, in IClearCredentialStateCallback callback);
}
Loading