summaryrefslogtreecommitdiffstats
path: root/services/java
diff options
context:
space:
mode:
Diffstat (limited to 'services/java')
-rw-r--r--services/java/com/android/server/SystemServer.java87
1 files changed, 86 insertions, 1 deletions
diff --git a/services/java/com/android/server/SystemServer.java b/services/java/com/android/server/SystemServer.java
index 08816b9..aa8026b 100644
--- a/services/java/com/android/server/SystemServer.java
+++ b/services/java/com/android/server/SystemServer.java
@@ -25,9 +25,11 @@ import android.content.ComponentName;
import android.content.ContentResolver;
import android.content.Context;
import android.content.Intent;
+import android.content.pm.IPackageManager;
import android.content.pm.PackageManager;
import android.content.res.Configuration;
import android.content.res.Resources.Theme;
+import android.database.ContentObserver;
import android.os.Build;
import android.os.Environment;
import android.os.FactoryTest;
@@ -61,6 +63,7 @@ import com.android.server.display.DisplayManagerService;
import com.android.server.dreams.DreamManagerService;
import com.android.server.fingerprint.FingerprintService;
import com.android.server.hdmi.HdmiControlService;
+import com.android.server.gesture.GestureService;
import com.android.server.input.InputManagerService;
import com.android.server.job.JobSchedulerService;
import com.android.server.lights.LightsService;
@@ -92,6 +95,7 @@ import com.android.server.wallpaper.WallpaperManagerService;
import com.android.server.webkit.WebViewUpdateService;
import com.android.server.wm.WindowManagerService;
+import cyanogenmod.providers.CMSettings;
import dalvik.system.VMRuntime;
import java.io.File;
@@ -173,6 +177,19 @@ public final class SystemServer {
mFactoryTestMode = FactoryTest.getMode();
}
+ private class AdbPortObserver extends ContentObserver {
+ public AdbPortObserver() {
+ super(null);
+ }
+ @Override
+ public void onChange(boolean selfChange) {
+ int adbPort = CMSettings.Secure.getInt(mContentResolver,
+ CMSettings.Secure.ADB_PORT, 0);
+ // setting this will control whether ADB runs on TCP/IP or USB
+ SystemProperties.set("adb.network.port", Integer.toString(adbPort));
+ }
+ }
+
private void run() {
// If a device's clock is before 1970 (before 0), a lot of
// APIs crash dealing with negative numbers, notably
@@ -438,6 +455,8 @@ public final class SystemServer {
boolean disableNetwork = SystemProperties.getBoolean("config.disable_network", false);
boolean disableNetworkTime = SystemProperties.getBoolean("config.disable_networktime", false);
boolean isEmulator = SystemProperties.get("ro.kernel.qemu").equals("1");
+ String[] externalServices = context.getResources()
+ .getStringArray(com.android.internal.R.array.config_externalCMServices);
try {
Slog.i(TAG, "Reading configuration...");
@@ -499,7 +518,7 @@ public final class SystemServer {
Slog.i(TAG, "Window Manager");
wm = WindowManagerService.main(context, inputManager,
mFactoryTestMode != FactoryTest.FACTORY_TEST_LOW_LEVEL,
- !mFirstBoot, mOnlyCore);
+ true, mOnlyCore);
ServiceManager.addService(Context.WINDOW_SERVICE, wm);
ServiceManager.addService(Context.INPUT_SERVICE, inputManager);
@@ -542,6 +561,7 @@ public final class SystemServer {
LockSettingsService lockSettings = null;
AssetAtlasService atlas = null;
MediaRouterService mediaRouter = null;
+ GestureService gestureService = null;
// Bring up services needed for UI.
if (mFactoryTestMode != FactoryTest.FACTORY_TEST_LOW_LEVEL) {
@@ -952,6 +972,17 @@ public final class SystemServer {
new GraphicsStatsService(context));
}
+ if (context.getResources().getBoolean(
+ com.android.internal.R.bool.config_enableGestureService)) {
+ try {
+ Slog.i(TAG, "Gesture Sensor Service");
+ gestureService = new GestureService(context, inputManager);
+ ServiceManager.addService("gesture", gestureService);
+ } catch (Throwable e) {
+ Slog.e(TAG, "Failure starting Gesture Sensor Service", e);
+ }
+ }
+
if (mPackageManager.hasSystemFeature(PackageManager.FEATURE_PRINTING)) {
mSystemServiceManager.startService(PRINT_MANAGER_SERVICE_CLASS);
}
@@ -997,6 +1028,15 @@ public final class SystemServer {
mSystemServiceManager.startService(MediaProjectionManagerService.class);
}
+ // make sure the ADB_ENABLED setting value matches the secure property value
+ CMSettings.Secure.putInt(mContentResolver, CMSettings.Secure.ADB_PORT,
+ Integer.parseInt(SystemProperties.get("service.adb.tcp.port", "-1")));
+
+ // register observer to listen for settings changes
+ mContentResolver.registerContentObserver(
+ CMSettings.Secure.getUriFor(CMSettings.Secure.ADB_PORT),
+ false, new AdbPortObserver());
+
// Before things start rolling, be sure we have decided whether
// we are in safe mode.
final boolean safeMode = wm.detectSafeMode();
@@ -1012,6 +1052,15 @@ public final class SystemServer {
// MMS service broker
mmsService = mSystemServiceManager.startService(MmsServiceBroker.class);
+ for (String service : externalServices) {
+ try {
+ Slog.i(TAG, service);
+ mSystemServiceManager.startService(service);
+ } catch (Throwable e) {
+ reportWtf("starting " + service , e);
+ }
+ }
+
// It is now time to start up the app processes...
try {
@@ -1078,6 +1127,14 @@ public final class SystemServer {
reportWtf("making Display Manager Service ready", e);
}
+ if (gestureService != null) {
+ try {
+ gestureService.systemReady();
+ } catch (Throwable e) {
+ reportWtf("making Gesture Sensor Service ready", e);
+ }
+ }
+
// These are needed to propagate to the runnable below.
final NetworkManagementService networkManagementF = networkManagement;
final NetworkStatsService networkStatsF = networkStats;
@@ -1120,6 +1177,15 @@ public final class SystemServer {
Slog.i(TAG, "WebViewFactory preparation");
WebViewFactory.prepareWebViewInSystemServer();
+ // Start Nfc before SystemUi to ensure NfcTile and other apps gets a
+ // valid NfcAdapter from NfcManager
+ try {
+ startNfcService(context);
+ } catch (Throwable e) {
+ // Don't crash. Nfc is an optional service. Just annotate that isn't ready
+ Slog.e(TAG, "Nfc service didn't start. Nfc will not be available.", e);
+ }
+
try {
startSystemUi(context);
} catch (Throwable e) {
@@ -1238,4 +1304,23 @@ public final class SystemServer {
//Slog.d(TAG, "Starting service: " + intent);
context.startServiceAsUser(intent, UserHandle.OWNER);
}
+
+ static final void startNfcService(Context context) {
+ IPackageManager pm = ActivityThread.getPackageManager();
+ if (pm == null) {
+ Slog.w(TAG, "Cannot get package manager, assuming no NFC feature");
+ return;
+ }
+ try {
+ if (pm.hasSystemFeature(PackageManager.FEATURE_NFC)) {
+ Intent intent = new Intent();
+ intent.setComponent(new ComponentName("com.android.nfc",
+ "com.android.nfc.NfcBootstrapService"));
+ context.startServiceAsUser(intent, UserHandle.OWNER);
+ }
+ } catch (RemoteException e) {
+ Slog.w(TAG, "Package manager query failed, assuming no NFC feature", e);
+ return;
+ }
+ }
}