cmsdk: Allow services to conditionally start before decryption
* Essentially everything in CMSDK should remain silent when we are being prompted to enter a passcode for decrypting the device. Unfortunately, simply shutting off CMSDK entirely will cause crashes everywhere. We need to be somewhat selective about it. * Motivation for this was LiveDisplay kicking into night mode before decrypted due to location services failing. Change-Id: I4d745debb2894776258343e8696ce5144f094404
This commit is contained in:
parent
fa227b12ed
commit
7bf7c4b72e
@ -17,6 +17,7 @@
|
|||||||
package org.cyanogenmod.platform.internal;
|
package org.cyanogenmod.platform.internal;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.os.SystemProperties;
|
||||||
import android.util.Slog;
|
import android.util.Slog;
|
||||||
import com.android.server.LocalServices;
|
import com.android.server.LocalServices;
|
||||||
import com.android.server.SystemServiceManager;
|
import com.android.server.SystemServiceManager;
|
||||||
@ -33,11 +34,21 @@ public class CMSystemServer {
|
|||||||
private Context mSystemContext;
|
private Context mSystemContext;
|
||||||
private CMSystemServiceHelper mSystemServiceHelper;
|
private CMSystemServiceHelper mSystemServiceHelper;
|
||||||
|
|
||||||
|
private static final String ENCRYPTING_STATE = "trigger_restart_min_framework";
|
||||||
|
private static final String ENCRYPTED_STATE = "1";
|
||||||
|
|
||||||
public CMSystemServer(Context systemContext) {
|
public CMSystemServer(Context systemContext) {
|
||||||
mSystemContext = systemContext;
|
mSystemContext = systemContext;
|
||||||
mSystemServiceHelper = new CMSystemServiceHelper(mSystemContext);
|
mSystemServiceHelper = new CMSystemServiceHelper(mSystemContext);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static boolean coreAppsOnly() {
|
||||||
|
// Only run "core" apps+services if we're encrypting the device.
|
||||||
|
final String cryptState = SystemProperties.get("vold.decrypt");
|
||||||
|
return ENCRYPTING_STATE.equals(cryptState) ||
|
||||||
|
ENCRYPTED_STATE.equals(cryptState);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Invoked via reflection by the SystemServer
|
* Invoked via reflection by the SystemServer
|
||||||
*/
|
*/
|
||||||
@ -64,8 +75,13 @@ public class CMSystemServer {
|
|||||||
CMSystemService cmSystemService = mSystemServiceHelper.getServiceFor(service);
|
CMSystemService cmSystemService = mSystemServiceHelper.getServiceFor(service);
|
||||||
if (context.getPackageManager().hasSystemFeature(
|
if (context.getPackageManager().hasSystemFeature(
|
||||||
cmSystemService.getFeatureDeclaration())) {
|
cmSystemService.getFeatureDeclaration())) {
|
||||||
|
if (coreAppsOnly() && !cmSystemService.isCoreService()) {
|
||||||
|
Slog.d(TAG, "Not starting " + service +
|
||||||
|
" - only parsing core apps");
|
||||||
|
} else {
|
||||||
Slog.i(TAG, "Starting service " + service);
|
Slog.i(TAG, "Starting service " + service);
|
||||||
ssm.startService(cmSystemService.getClass());
|
ssm.startService(cmSystemService.getClass());
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
Slog.i(TAG, "Not starting service " + service +
|
Slog.i(TAG, "Not starting service " + service +
|
||||||
" due to feature not declared on device");
|
" due to feature not declared on device");
|
||||||
|
@ -25,4 +25,13 @@ public abstract class CMSystemService extends SystemService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public abstract String getFeatureDeclaration();
|
public abstract String getFeatureDeclaration();
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Override and return true if the service should be started
|
||||||
|
* before the device is decrypted.
|
||||||
|
*/
|
||||||
|
public boolean isCoreService() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -150,6 +150,11 @@ public class LiveDisplayService extends CMSystemService {
|
|||||||
return CMContextConstants.Features.LIVEDISPLAY;
|
return CMContextConstants.Features.LIVEDISPLAY;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isCoreService() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onStart() {
|
public void onStart() {
|
||||||
publishBinderService(CMContextConstants.CM_LIVEDISPLAY_SERVICE, mBinder);
|
publishBinderService(CMContextConstants.CM_LIVEDISPLAY_SERVICE, mBinder);
|
||||||
|
Loading…
Reference in New Issue
Block a user