diff options
author | Adnan Begovic <adnan@cyngn.com> | 2016-03-24 17:25:13 -0700 |
---|---|---|
committer | Adnan Begovic <adnan@cyngn.com> | 2016-03-24 17:25:13 -0700 |
commit | fe7fd1d489108d8278dd1a4a0e8d2b3bc0617cd3 (patch) | |
tree | 4af4cfcd7f883ec8424b75fcaaf5e7c9d8abd0f9 | |
parent | 21a567428db79f97d2178a8dec7cf1825b7ecff6 (diff) | |
download | vendor_cmsdk-fe7fd1d489108d8278dd1a4a0e8d2b3bc0617cd3.zip vendor_cmsdk-fe7fd1d489108d8278dd1a4a0e8d2b3bc0617cd3.tar.gz vendor_cmsdk-fe7fd1d489108d8278dd1a4a0e8d2b3bc0617cd3.tar.bz2 |
cmsdk: Mandate app suggest feature xml's for service implementation.
The feature xml plays two roles:
1) To allow sdk interface (constructor) to throw when system
service is unavailable. This allows for clearer platform
development debugging.
2) To allow for simpler disambiguation of what services to
instrument in a modular environment.
Change-Id: Icda71efc084cf91bd358dba24eee4704179be90e
TICKET: CYNGNOS-2290
3 files changed, 24 insertions, 2 deletions
diff --git a/cm/lib/main/java/org/cyanogenmod/platform/internal/AppSuggestManagerService.java b/cm/lib/main/java/org/cyanogenmod/platform/internal/AppSuggestManagerService.java index 0673211..b954dfa 100644 --- a/cm/lib/main/java/org/cyanogenmod/platform/internal/AppSuggestManagerService.java +++ b/cm/lib/main/java/org/cyanogenmod/platform/internal/AppSuggestManagerService.java @@ -74,6 +74,12 @@ public class AppSuggestManagerService extends SystemService { Slog.i(TAG, "Bound to to suggest provider"); } - publishBinderService(CMContextConstants.CM_APP_SUGGEST_SERVICE, mService); + if (mContext.getPackageManager().hasSystemFeature( + CMContextConstants.Features.APP_SUGGEST)) { + publishBinderService(CMContextConstants.CM_APP_SUGGEST_SERVICE, mService); + } else { + Log.wtf(TAG, "CM hardware service started by system server but feature xml not" + + " declared. Not publishing binder service!"); + } } } diff --git a/src/java/cyanogenmod/app/CMContextConstants.java b/src/java/cyanogenmod/app/CMContextConstants.java index 622732d..8cfa04b 100644 --- a/src/java/cyanogenmod/app/CMContextConstants.java +++ b/src/java/cyanogenmod/app/CMContextConstants.java @@ -141,5 +141,13 @@ public final class CMContextConstants { */ @SdkConstant(SdkConstant.SdkConstantType.FEATURE) public static final String PROFILES = "org.cyanogenmod.profiles"; + + /** + * Feature for {@link PackageManager#getSystemAvailableFeatures} and + * {@link PackageManager#hasSystemFeature}: The device includes the cm app suggest service + * utilized by the cmsdk. + */ + @SdkConstant(SdkConstant.SdkConstantType.FEATURE) + public static final String APP_SUGGEST = "org.cyanogenmod.appsuggest"; } } diff --git a/src/java/cyanogenmod/app/suggest/AppSuggestManager.java b/src/java/cyanogenmod/app/suggest/AppSuggestManager.java index 7bc034c..0eb55d4 100644 --- a/src/java/cyanogenmod/app/suggest/AppSuggestManager.java +++ b/src/java/cyanogenmod/app/suggest/AppSuggestManager.java @@ -63,10 +63,18 @@ public class AppSuggestManager { return sInstance; } - context = context.getApplicationContext() != null ? context.getApplicationContext() : context; + context = context.getApplicationContext() != null ? + context.getApplicationContext() : context; sInstance = new AppSuggestManager(context); + if (context.getPackageManager().hasSystemFeature(CMContextConstants.Features.APP_SUGGEST) + && sImpl == null) { + throw new RuntimeException("Unable to get AppSuggestManagerService. " + + "The service either crashed, was not started, or the interface has been" + + " called to early in SystemServer init"); + } + return sInstance; } |