Fix location settings crash when work profile is disabled

Bug: 27402597
Change-Id: Iab5f999b67e9f81977142648f90cf31acb8b5f69
This commit is contained in:
Ricky Wai
2016-03-11 09:06:02 +00:00
parent ff99bae744
commit 3bd4771ccb

View File

@@ -16,6 +16,7 @@
package com.android.settings.location; package com.android.settings.location;
import android.app.ActivityManager;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.content.pm.ApplicationInfo; import android.content.pm.ApplicationInfo;
@@ -474,6 +475,15 @@ class SettingsInjector {
* preference when the service replies. * preference when the service replies.
*/ */
public void startService() { public void startService() {
final ActivityManager am = (ActivityManager)
mContext.getSystemService(Context.ACTIVITY_SERVICE);
if (!am.isUserRunning(setting.mUserHandle.getIdentifier())) {
if (Log.isLoggable(TAG, Log.VERBOSE)) {
Log.v(TAG, "Cannot start service as user "
+ setting.mUserHandle.getIdentifier() + " is not running");
}
return;
}
Handler handler = new Handler() { Handler handler = new Handler() {
@Override @Override
public void handleMessage(Message msg) { public void handleMessage(Message msg) {