cmsdk: Mandate cm sb 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. TICKET: CYNGNOS-2289 Change-Id: Ice0ae7c45aecbb34e0ea667128b040906c46d7e7
This commit is contained in:
parent
1bf0cf2ff8
commit
cdf85adde1
@ -83,6 +83,12 @@ public class CMStatusBarManagerService extends SystemService {
|
||||
|
||||
@Override
|
||||
public void onStart() {
|
||||
if (!mContext.getPackageManager().hasSystemFeature(
|
||||
CMContextConstants.Features.STATUSBAR)) {
|
||||
Log.wtf(TAG, "CM statusbar service started by system server but feature xml not" +
|
||||
" declared. Not publishing binder service!");
|
||||
return;
|
||||
}
|
||||
Log.d(TAG, "registerCMStatusBar cmstatusbar: " + this);
|
||||
mCustomTileListeners = new CustomTileListeners();
|
||||
publishBinderService(CMContextConstants.CM_STATUS_BAR_SERVICE, mService);
|
||||
|
@ -125,5 +125,13 @@ public final class CMContextConstants {
|
||||
*/
|
||||
@SdkConstant(SdkConstant.SdkConstantType.FEATURE)
|
||||
public static final String HARDWARE_ABSTRACTION = "org.cyanogenmod.hardware";
|
||||
|
||||
/**
|
||||
* Feature for {@link PackageManager#getSystemAvailableFeatures} and
|
||||
* {@link PackageManager#hasSystemFeature}: The device includes the cm status bar service
|
||||
* utilzed by the cmsdk.
|
||||
*/
|
||||
@SdkConstant(SdkConstant.SdkConstantType.FEATURE)
|
||||
public static final String STATUSBAR = "org.cyanogenmod.statusbar";
|
||||
}
|
||||
}
|
||||
|
@ -65,6 +65,13 @@ public class CMStatusBarManager {
|
||||
mContext = context;
|
||||
}
|
||||
sService = getService();
|
||||
|
||||
if (context.getPackageManager().hasSystemFeature(
|
||||
cyanogenmod.app.CMContextConstants.Features.STATUSBAR) && sService == null) {
|
||||
throw new RuntimeException("Unable to get CMStatusBarService. The service either" +
|
||||
" crashed, was not started, or the interface has been called to early in" +
|
||||
" SystemServer init");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -19,6 +19,7 @@ package org.cyanogenmod.tests.customtiles.unit;
|
||||
import android.test.AndroidTestCase;
|
||||
import android.test.suitebuilder.annotation.SmallTest;
|
||||
|
||||
import cyanogenmod.app.CMContextConstants;
|
||||
import cyanogenmod.app.CMStatusBarManager;
|
||||
import cyanogenmod.app.ICMStatusBarManager;
|
||||
|
||||
@ -31,6 +32,9 @@ public class CMStatusBarManagerTest extends AndroidTestCase {
|
||||
@Override
|
||||
protected void setUp() throws Exception {
|
||||
super.setUp();
|
||||
// Only run this if we support cm status bar service
|
||||
org.junit.Assume.assumeTrue(mContext.getPackageManager().hasSystemFeature(
|
||||
CMContextConstants.Features.STATUSBAR));
|
||||
mCMStatusBarManager = CMStatusBarManager.getInstance(mContext);
|
||||
}
|
||||
|
||||
|
@ -24,6 +24,7 @@ import android.net.Uri;
|
||||
import android.test.AndroidTestCase;
|
||||
import android.test.suitebuilder.annotation.MediumTest;
|
||||
import android.test.suitebuilder.annotation.SmallTest;
|
||||
import cyanogenmod.app.CMContextConstants;
|
||||
import cyanogenmod.app.CustomTile;
|
||||
import org.cyanogenmod.tests.R;
|
||||
import org.cyanogenmod.tests.customtiles.CMStatusBarTest;
|
||||
@ -39,6 +40,9 @@ public class CustomTileBuilderTest extends AndroidTestCase {
|
||||
@Override
|
||||
protected void setUp() throws Exception {
|
||||
super.setUp();
|
||||
// Only run this if we support cm status bar service
|
||||
org.junit.Assume.assumeTrue(mContext.getPackageManager().hasSystemFeature(
|
||||
CMContextConstants.Features.STATUSBAR));
|
||||
}
|
||||
|
||||
@SmallTest
|
||||
|
@ -25,6 +25,7 @@ import android.test.AndroidTestCase;
|
||||
import android.test.suitebuilder.annotation.MediumTest;
|
||||
import android.test.suitebuilder.annotation.SmallTest;
|
||||
import android.widget.RemoteViews;
|
||||
import cyanogenmod.app.CMContextConstants;
|
||||
import cyanogenmod.app.CustomTile;
|
||||
|
||||
import org.cyanogenmod.tests.R;
|
||||
@ -39,6 +40,9 @@ public class CustomTileTest extends AndroidTestCase {
|
||||
@Override
|
||||
protected void setUp() throws Exception {
|
||||
super.setUp();
|
||||
// Only run this if we support cm status bar service
|
||||
org.junit.Assume.assumeTrue(mContext.getPackageManager().hasSystemFeature(
|
||||
CMContextConstants.Features.STATUSBAR));
|
||||
}
|
||||
|
||||
@SmallTest
|
||||
|
@ -25,6 +25,7 @@ import android.os.UserHandle;
|
||||
import android.test.AndroidTestCase;
|
||||
import android.test.suitebuilder.annotation.MediumTest;
|
||||
import android.test.suitebuilder.annotation.SmallTest;
|
||||
import cyanogenmod.app.CMContextConstants;
|
||||
import cyanogenmod.app.CustomTile;
|
||||
import cyanogenmod.app.StatusBarPanelCustomTile;
|
||||
import org.cyanogenmod.tests.R;
|
||||
@ -39,6 +40,9 @@ public class StatusBarPanelCustomTileTest extends AndroidTestCase {
|
||||
@Override
|
||||
protected void setUp() throws Exception {
|
||||
super.setUp();
|
||||
// Only run this if we support cm status bar service
|
||||
org.junit.Assume.assumeTrue(mContext.getPackageManager().hasSystemFeature(
|
||||
CMContextConstants.Features.STATUSBAR));
|
||||
}
|
||||
|
||||
@SmallTest
|
||||
|
Loading…
Reference in New Issue
Block a user