diff options
author | Steve Kondik <steve@cyngn.com> | 2016-07-28 02:48:59 -0700 |
---|---|---|
committer | Steve Kondik <shade@chemlab.org> | 2016-08-01 12:19:11 -0700 |
commit | 7bf7c4b72effd90cdd9492dc2b1e522c8331bd3b (patch) | |
tree | 2189affecfd93040fab550b33a1520e40a045904 | |
parent | fa227b12edac73a33cd82afd1bc16a3ff3e7a36b (diff) | |
download | vendor_cmsdk-7bf7c4b72effd90cdd9492dc2b1e522c8331bd3b.zip vendor_cmsdk-7bf7c4b72effd90cdd9492dc2b1e522c8331bd3b.tar.gz vendor_cmsdk-7bf7c4b72effd90cdd9492dc2b1e522c8331bd3b.tar.bz2 |
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
3 files changed, 32 insertions, 2 deletions
diff --git a/cm/lib/main/java/org/cyanogenmod/platform/internal/CMSystemServer.java b/cm/lib/main/java/org/cyanogenmod/platform/internal/CMSystemServer.java index 0e0b9b5..aa82428 100644 --- a/cm/lib/main/java/org/cyanogenmod/platform/internal/CMSystemServer.java +++ b/cm/lib/main/java/org/cyanogenmod/platform/internal/CMSystemServer.java @@ -17,6 +17,7 @@ package org.cyanogenmod.platform.internal; import android.content.Context; +import android.os.SystemProperties; import android.util.Slog; import com.android.server.LocalServices; import com.android.server.SystemServiceManager; @@ -33,11 +34,21 @@ public class CMSystemServer { private Context mSystemContext; private CMSystemServiceHelper mSystemServiceHelper; + private static final String ENCRYPTING_STATE = "trigger_restart_min_framework"; + private static final String ENCRYPTED_STATE = "1"; + public CMSystemServer(Context systemContext) { mSystemContext = systemContext; 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 */ @@ -64,8 +75,13 @@ public class CMSystemServer { CMSystemService cmSystemService = mSystemServiceHelper.getServiceFor(service); if (context.getPackageManager().hasSystemFeature( cmSystemService.getFeatureDeclaration())) { - Slog.i(TAG, "Starting service " + service); - ssm.startService(cmSystemService.getClass()); + if (coreAppsOnly() && !cmSystemService.isCoreService()) { + Slog.d(TAG, "Not starting " + service + + " - only parsing core apps"); + } else { + Slog.i(TAG, "Starting service " + service); + ssm.startService(cmSystemService.getClass()); + } } else { Slog.i(TAG, "Not starting service " + service + " due to feature not declared on device"); diff --git a/cm/lib/main/java/org/cyanogenmod/platform/internal/CMSystemService.java b/cm/lib/main/java/org/cyanogenmod/platform/internal/CMSystemService.java index 85a306d..2316ec2 100644 --- a/cm/lib/main/java/org/cyanogenmod/platform/internal/CMSystemService.java +++ b/cm/lib/main/java/org/cyanogenmod/platform/internal/CMSystemService.java @@ -25,4 +25,13 @@ public abstract class CMSystemService extends SystemService { } public abstract String getFeatureDeclaration(); + + + /** + * Override and return true if the service should be started + * before the device is decrypted. + */ + public boolean isCoreService() { + return true; + } } diff --git a/cm/lib/main/java/org/cyanogenmod/platform/internal/display/LiveDisplayService.java b/cm/lib/main/java/org/cyanogenmod/platform/internal/display/LiveDisplayService.java index 129983b..7fe5656 100644 --- a/cm/lib/main/java/org/cyanogenmod/platform/internal/display/LiveDisplayService.java +++ b/cm/lib/main/java/org/cyanogenmod/platform/internal/display/LiveDisplayService.java @@ -151,6 +151,11 @@ public class LiveDisplayService extends CMSystemService { } @Override + public boolean isCoreService() { + return false; + } + + @Override public void onStart() { publishBinderService(CMContextConstants.CM_LIVEDISPLAY_SERVICE, mBinder); } |