diff --git a/cm/lib/main/java/org/cyanogenmod/platform/internal/CMTelephonyManagerService.java b/cm/lib/main/java/org/cyanogenmod/platform/internal/CMTelephonyManagerService.java index 739722e..35e5395 100644 --- a/cm/lib/main/java/org/cyanogenmod/platform/internal/CMTelephonyManagerService.java +++ b/cm/lib/main/java/org/cyanogenmod/platform/internal/CMTelephonyManagerService.java @@ -186,8 +186,13 @@ public class CMTelephonyManagerService extends SystemService { if (localLOGD) { Log.d(TAG, "CM telephony manager service start: " + this); } - publishBinderService(CMContextConstants.CM_TELEPHONY_MANAGER_SERVICE, mService); - + if (mContext.getPackageManager().hasSystemFeature( + CMContextConstants.Features.TELEPHONY)) { + publishBinderService(CMContextConstants.CM_TELEPHONY_MANAGER_SERVICE, mService); + } else { + Log.wtf(TAG, "CM telephony service started by system server but feature xml not" + + " declared. Not publishing binder service!"); + } mTelephonyManager = (TelephonyManager) mContext.getSystemService(Context.TELEPHONY_SERVICE); } diff --git a/src/java/cyanogenmod/app/CMContextConstants.java b/src/java/cyanogenmod/app/CMContextConstants.java index 8cfa04b..e82c60b 100644 --- a/src/java/cyanogenmod/app/CMContextConstants.java +++ b/src/java/cyanogenmod/app/CMContextConstants.java @@ -149,5 +149,13 @@ public final class CMContextConstants { */ @SdkConstant(SdkConstant.SdkConstantType.FEATURE) public static final String APP_SUGGEST = "org.cyanogenmod.appsuggest"; + + /** + * Feature for {@link PackageManager#getSystemAvailableFeatures} and + * {@link PackageManager#hasSystemFeature}: The device includes the cm telephony service + * utilized by the cmsdk. + */ + @SdkConstant(SdkConstant.SdkConstantType.FEATURE) + public static final String TELEPHONY = "org.cyanogenmod.telephony"; } } diff --git a/src/java/cyanogenmod/app/CMTelephonyManager.java b/src/java/cyanogenmod/app/CMTelephonyManager.java index 35466c9..4285f44 100644 --- a/src/java/cyanogenmod/app/CMTelephonyManager.java +++ b/src/java/cyanogenmod/app/CMTelephonyManager.java @@ -26,6 +26,8 @@ import android.util.Slog; import java.util.List; +import cyanogenmod.app.CMContextConstants; + /** * The CMTelephonyManager allows you to view and manage the phone state and * the data connection, with multiple SIMs support. @@ -55,6 +57,13 @@ public class CMTelephonyManager { mContext = context; } sService = getService(); + + if (context.getPackageManager().hasSystemFeature(CMContextConstants.Features.TELEPHONY) + && sService == null) { + throw new RuntimeException("Unable to get CMTelephonyManagerService. " + + "The service either crashed, was not started, or the interface has been " + + "called to early in SystemServer init"); + } } /**