Merge "Improved generics on AbstractMasterSystemService / AbstractPerUserSystemService."

This commit is contained in:
TreeHugger Robot
2018-11-19 21:31:53 +00:00
committed by Android (Google) Code Review
6 changed files with 16 additions and 12 deletions

View File

@@ -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";

View File

@@ -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;

View File

@@ -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

View File

@@ -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;

View File

@@ -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";

View File

@@ -42,7 +42,8 @@ import java.util.List;
* Per-user instance of {@link IntelligenceManagerService}.
*/
final class IntelligencePerUserService
extends AbstractPerUserSystemService<IntelligencePerUserService> {
extends AbstractPerUserSystemService<IntelligencePerUserService,
IntelligenceManagerService> {
private static final String TAG = "IntelligencePerUserService";