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

Commit e20bf9f5 authored by Felipe Leme's avatar Felipe Leme
Browse files

Improved generics on AbstractMasterSystemService / AbstractPerUserSystemService.

Bug: 117779333
Test: atest CtsAutoFillServiceTestCases

Change-Id: I777fbe44aa395372eba3c97a1c18c2de4c771dd4
parent fd21b518
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -89,7 +89,7 @@ import java.util.Objects;
 * {@link AutofillManagerServiceImpl} itself.
 */
public final class AutofillManagerService
        extends AbstractMasterSystemService<AutofillManagerServiceImpl> {
        extends AbstractMasterSystemService<AutofillManagerService, AutofillManagerServiceImpl> {

    private static final String TAG = "AutofillManagerService";

+1 −1
Original line number Diff line number Diff line
@@ -86,7 +86,7 @@ import java.util.Random;
 *
 */
final class AutofillManagerServiceImpl
        extends AbstractPerUserSystemService<AutofillManagerServiceImpl> {
        extends AbstractPerUserSystemService<AutofillManagerServiceImpl, AutofillManagerService> {

    private static final String TAG = "AutofillManagerServiceImpl";
    private static final int MAX_SESSION_ID_CREATE_TRIES = 2048;
+3 −2
Original line number Diff line number Diff line
@@ -62,13 +62,14 @@ import java.util.List;
 * <p>See {@code com.android.server.autofill.AutofillManagerService} for a concrete
 * (no pun intended) example of how to use it.
 *
 * @param <M> "master" service class.
 * @param <S> "real" service class.
 *
 * @hide
 */
// TODO(b/117779333): improve javadoc above instead of using Autofill as an example
public abstract class AbstractMasterSystemService<S extends AbstractPerUserSystemService<S>>
        extends SystemService {
public abstract class AbstractMasterSystemService<M extends AbstractMasterSystemService<M, S>,
        S extends AbstractPerUserSystemService<S, M>> extends SystemService {

    /**
     * Log tag
+7 −5
Original line number Diff line number Diff line
@@ -41,17 +41,19 @@ import java.io.PrintWriter;
 * Companion for {@link AbstractMasterSystemService}, it's the base class for the "real" service
 * implementation.
 *
 * @param <S> itself
 * @param <M> "master" service class.
 * @param <S> "real" service class.
 *
 * @hide
 */
public abstract class AbstractPerUserSystemService<S extends AbstractPerUserSystemService<S>> {
public abstract class AbstractPerUserSystemService<S extends AbstractPerUserSystemService<S, M>,
        M extends AbstractMasterSystemService<M, S>> {

    protected final @UserIdInt int mUserId;
    protected final Object mLock;
    protected final String mTag = getClass().getSimpleName();

    protected final AbstractMasterSystemService<S> mMaster;
    protected final M mMaster;

    /**
     * Whether service was disabled for user due to {@link UserManager} restrictions.
@@ -68,8 +70,8 @@ public abstract class AbstractPerUserSystemService<S extends AbstractPerUserSyst
    @GuardedBy("mLock")
    private ServiceInfo mServiceInfo;

    protected AbstractPerUserSystemService(@NonNull AbstractMasterSystemService<S> master,
            @NonNull Object lock, @UserIdInt int userId) {
    protected AbstractPerUserSystemService(@NonNull M master, @NonNull Object lock,
            @UserIdInt int userId) {
        mMaster = master;
        mLock = lock;
        mUserId = userId;
+2 −2
Original line number Diff line number Diff line
@@ -46,8 +46,8 @@ import java.util.List;
 * <p>The data collected by this service can be analyzed and combined with other sources to provide
 * contextual data in other areas of the system such as Autofill.
 */
public final class IntelligenceManagerService
        extends AbstractMasterSystemService<IntelligencePerUserService> {
public final class IntelligenceManagerService extends
        AbstractMasterSystemService<IntelligenceManagerService, IntelligencePerUserService> {

    private static final String TAG = "IntelligenceManagerService";

Loading