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
This commit is contained in:
parent
21a567428d
commit
fe7fd1d489
|
@ -74,6 +74,12 @@ public class AppSuggestManagerService extends SystemService {
|
||||||
Slog.i(TAG, "Bound to to suggest provider");
|
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!");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -141,5 +141,13 @@ public final class CMContextConstants {
|
||||||
*/
|
*/
|
||||||
@SdkConstant(SdkConstant.SdkConstantType.FEATURE)
|
@SdkConstant(SdkConstant.SdkConstantType.FEATURE)
|
||||||
public static final String PROFILES = "org.cyanogenmod.profiles";
|
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";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -63,10 +63,18 @@ public class AppSuggestManager {
|
||||||
return sInstance;
|
return sInstance;
|
||||||
}
|
}
|
||||||
|
|
||||||
context = context.getApplicationContext() != null ? context.getApplicationContext() : context;
|
context = context.getApplicationContext() != null ?
|
||||||
|
context.getApplicationContext() : context;
|
||||||
|
|
||||||
sInstance = new AppSuggestManager(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;
|
return sInstance;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue