Merge "Catch SecurityException thrown from job binding" into qt-dev
am: b15ce5ac96
Change-Id: I373c3f71ad72720bd27993779e7ccb3b94af9032
This commit is contained in:
@@ -247,10 +247,20 @@ public final class JobServiceContext implements ServiceConnection {
|
|||||||
mVerb = VERB_BINDING;
|
mVerb = VERB_BINDING;
|
||||||
scheduleOpTimeOutLocked();
|
scheduleOpTimeOutLocked();
|
||||||
final Intent intent = new Intent().setComponent(job.getServiceComponent());
|
final Intent intent = new Intent().setComponent(job.getServiceComponent());
|
||||||
boolean binding = mContext.bindServiceAsUser(intent, this,
|
boolean binding = false;
|
||||||
Context.BIND_AUTO_CREATE | Context.BIND_NOT_FOREGROUND
|
try {
|
||||||
| Context.BIND_NOT_VISIBLE | Context.BIND_ADJUST_BELOW_PERCEPTIBLE,
|
binding = mContext.bindServiceAsUser(intent, this,
|
||||||
new UserHandle(job.getUserId()));
|
Context.BIND_AUTO_CREATE | Context.BIND_NOT_FOREGROUND
|
||||||
|
| Context.BIND_NOT_VISIBLE | Context.BIND_ADJUST_BELOW_PERCEPTIBLE,
|
||||||
|
new UserHandle(job.getUserId()));
|
||||||
|
} catch (SecurityException e) {
|
||||||
|
// Some permission policy, for example INTERACT_ACROSS_USERS and
|
||||||
|
// android:singleUser, can result in a SecurityException being thrown from
|
||||||
|
// bindServiceAsUser(). If this happens, catch it and fail gracefully.
|
||||||
|
Slog.w(TAG, "Job service " + job.getServiceComponent().getShortClassName()
|
||||||
|
+ " cannot be executed: " + e.getMessage());
|
||||||
|
binding = false;
|
||||||
|
}
|
||||||
if (!binding) {
|
if (!binding) {
|
||||||
if (DEBUG) {
|
if (DEBUG) {
|
||||||
Slog.d(TAG, job.getServiceComponent().getShortClassName() + " unavailable.");
|
Slog.d(TAG, job.getServiceComponent().getShortClassName() + " unavailable.");
|
||||||
|
|||||||
Reference in New Issue
Block a user