Merge "Bump up OOM priority of bound VrListenerService." into oc-mr1-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
71acf7074f
@@ -44,6 +44,7 @@ public class ManagedApplicationService {
|
|||||||
private final int mClientLabel;
|
private final int mClientLabel;
|
||||||
private final String mSettingsAction;
|
private final String mSettingsAction;
|
||||||
private final BinderChecker mChecker;
|
private final BinderChecker mChecker;
|
||||||
|
private final boolean mIsImportant;
|
||||||
|
|
||||||
private final DeathRecipient mDeathRecipient = new DeathRecipient() {
|
private final DeathRecipient mDeathRecipient = new DeathRecipient() {
|
||||||
@Override
|
@Override
|
||||||
@@ -64,13 +65,14 @@ public class ManagedApplicationService {
|
|||||||
|
|
||||||
private ManagedApplicationService(final Context context, final ComponentName component,
|
private ManagedApplicationService(final Context context, final ComponentName component,
|
||||||
final int userId, int clientLabel, String settingsAction,
|
final int userId, int clientLabel, String settingsAction,
|
||||||
BinderChecker binderChecker) {
|
BinderChecker binderChecker, boolean isImportant) {
|
||||||
mContext = context;
|
mContext = context;
|
||||||
mComponent = component;
|
mComponent = component;
|
||||||
mUserId = userId;
|
mUserId = userId;
|
||||||
mClientLabel = clientLabel;
|
mClientLabel = clientLabel;
|
||||||
mSettingsAction = settingsAction;
|
mSettingsAction = settingsAction;
|
||||||
mChecker = binderChecker;
|
mChecker = binderChecker;
|
||||||
|
mIsImportant = isImportant;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -99,13 +101,15 @@ public class ManagedApplicationService {
|
|||||||
* @param settingsAction an action that can be used to open the Settings UI to enable/disable
|
* @param settingsAction an action that can be used to open the Settings UI to enable/disable
|
||||||
* binding to these services.
|
* binding to these services.
|
||||||
* @param binderChecker an interface used to validate the returned binder object.
|
* @param binderChecker an interface used to validate the returned binder object.
|
||||||
|
* @param isImportant bind the user service with BIND_IMPORTANT.
|
||||||
* @return a ManagedApplicationService instance.
|
* @return a ManagedApplicationService instance.
|
||||||
*/
|
*/
|
||||||
public static ManagedApplicationService build(@NonNull final Context context,
|
public static ManagedApplicationService build(@NonNull final Context context,
|
||||||
@NonNull final ComponentName component, final int userId, @NonNull int clientLabel,
|
@NonNull final ComponentName component, final int userId, @NonNull int clientLabel,
|
||||||
@NonNull String settingsAction, @NonNull BinderChecker binderChecker) {
|
@NonNull String settingsAction, @NonNull BinderChecker binderChecker,
|
||||||
|
boolean isImportant) {
|
||||||
return new ManagedApplicationService(context, component, userId, clientLabel,
|
return new ManagedApplicationService(context, component, userId, clientLabel,
|
||||||
settingsAction, binderChecker);
|
settingsAction, binderChecker, isImportant);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -248,9 +252,12 @@ public class ManagedApplicationService {
|
|||||||
|
|
||||||
mPendingConnection = serviceConnection;
|
mPendingConnection = serviceConnection;
|
||||||
|
|
||||||
|
int flags = Context.BIND_AUTO_CREATE | Context.BIND_FOREGROUND_SERVICE;
|
||||||
|
if (mIsImportant) {
|
||||||
|
flags |= Context.BIND_IMPORTANT;
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
if (!mContext.bindServiceAsUser(intent, serviceConnection,
|
if (!mContext.bindServiceAsUser(intent, serviceConnection, flags,
|
||||||
Context.BIND_AUTO_CREATE | Context.BIND_FOREGROUND_SERVICE,
|
|
||||||
new UserHandle(mUserId))) {
|
new UserHandle(mUserId))) {
|
||||||
Slog.w(TAG, "Unable to bind service: " + intent);
|
Slog.w(TAG, "Unable to bind service: " + intent);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1026,7 +1026,7 @@ public class VrManagerService extends SystemService implements EnabledComponentC
|
|||||||
@NonNull ComponentName component, int userId) {
|
@NonNull ComponentName component, int userId) {
|
||||||
return ManagedApplicationService.build(context, component, userId,
|
return ManagedApplicationService.build(context, component, userId,
|
||||||
R.string.vr_listener_binding_label, Settings.ACTION_VR_LISTENER_SETTINGS,
|
R.string.vr_listener_binding_label, Settings.ACTION_VR_LISTENER_SETTINGS,
|
||||||
sBinderChecker);
|
sBinderChecker, /*isImportant*/true);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user