Merge change 23704 into eclair

* changes:
  Fiddle system boot ordering.
This commit is contained in:
Android (Google) Code Review
2009-09-02 17:55:35 -07:00
6 changed files with 99 additions and 73 deletions

View File

@@ -941,13 +941,6 @@ public abstract class ActivityManagerNative extends Binder implements IActivityM
return true; return true;
} }
case SYSTEM_READY_TRANSACTION: {
data.enforceInterface(IActivityManager.descriptor);
systemReady();
reply.writeNoException();
return true;
}
case HANDLE_APPLICATION_ERROR_TRANSACTION: { case HANDLE_APPLICATION_ERROR_TRANSACTION: {
data.enforceInterface(IActivityManager.descriptor); data.enforceInterface(IActivityManager.descriptor);
IBinder app = data.readStrongBinder(); IBinder app = data.readStrongBinder();
@@ -2248,16 +2241,6 @@ class ActivityManagerProxy implements IActivityManager
data.recycle(); data.recycle();
reply.recycle(); reply.recycle();
} }
public void systemReady() throws RemoteException
{
Parcel data = Parcel.obtain();
Parcel reply = Parcel.obtain();
data.writeInterfaceToken(IActivityManager.descriptor);
mRemote.transact(SYSTEM_READY_TRANSACTION, data, reply, 0);
reply.readException();
data.recycle();
reply.recycle();
}
public boolean testIsSystemReady() public boolean testIsSystemReady()
{ {
/* this base class version is never called */ /* this base class version is never called */

View File

@@ -233,7 +233,6 @@ public interface IActivityManager extends IInterface {
// Special low-level communication with activity manager. // Special low-level communication with activity manager.
public void startRunning(String pkg, String cls, String action, public void startRunning(String pkg, String cls, String action,
String data) throws RemoteException; String data) throws RemoteException;
public void systemReady() throws RemoteException;
// Returns 1 if the user wants to debug. // Returns 1 if the user wants to debug.
public int handleApplicationError(IBinder app, public int handleApplicationError(IBinder app,
int flags, /* 1 == can debug */ int flags, /* 1 == can debug */
@@ -368,7 +367,7 @@ public interface IActivityManager extends IInterface {
int PUBLISH_CONTENT_PROVIDERS_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+29; int PUBLISH_CONTENT_PROVIDERS_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+29;
int SET_PERSISTENT_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+30; int SET_PERSISTENT_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+30;
int FINISH_SUB_ACTIVITY_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+31; int FINISH_SUB_ACTIVITY_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+31;
int SYSTEM_READY_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+32;
int START_SERVICE_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+33; int START_SERVICE_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+33;
int STOP_SERVICE_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+34; int STOP_SERVICE_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+34;
int BIND_SERVICE_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+35; int BIND_SERVICE_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+35;

View File

@@ -2035,6 +2035,7 @@ class SyncManager implements OnAccountsUpdatedListener {
private void sendSyncStateIntent() { private void sendSyncStateIntent() {
Intent syncStateIntent = new Intent(Intent.ACTION_SYNC_STATE_CHANGED); Intent syncStateIntent = new Intent(Intent.ACTION_SYNC_STATE_CHANGED);
syncStateIntent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT);
syncStateIntent.putExtra("active", mNeedSyncActiveNotification); syncStateIntent.putExtra("active", mNeedSyncActiveNotification);
syncStateIntent.putExtra("failing", mNeedSyncErrorNotification); syncStateIntent.putExtra("failing", mNeedSyncErrorNotification);
mContext.sendBroadcast(syncStateIntent); mContext.sendBroadcast(syncStateIntent);

View File

@@ -179,6 +179,11 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
final HashMap<IBinder, ClientState> mClients final HashMap<IBinder, ClientState> mClients
= new HashMap<IBinder, ClientState>(); = new HashMap<IBinder, ClientState>();
/**
* Set once the system is ready to run third party code.
*/
boolean mSystemReady;
/** /**
* Id of the currently selected input method. * Id of the currently selected input method.
*/ */
@@ -508,6 +513,12 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
} }
public void systemReady() { public void systemReady() {
synchronized (mMethodMap) {
if (!mSystemReady) {
mSystemReady = true;
startInputInnerLocked();
}
}
} }
public List<InputMethodInfo> getInputMethodList() { public List<InputMethodInfo> getInputMethodList() {
@@ -727,6 +738,20 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
} }
} }
return startInputInnerLocked();
}
InputBindResult startInputInnerLocked() {
if (mCurMethodId == null) {
return mNoBinding;
}
if (!mSystemReady) {
// If the system is not yet ready, we shouldn't be running third
// party code.
return new InputBindResult(null, mCurId, mCurSeq);
}
InputMethodInfo info = mMethodMap.get(mCurMethodId); InputMethodInfo info = mMethodMap.get(mCurMethodId);
if (info == null) { if (info == null) {
throw new IllegalArgumentException("Unknown id: " + mCurMethodId); throw new IllegalArgumentException("Unknown id: " + mCurMethodId);

View File

@@ -92,22 +92,22 @@ class ServerThread extends Thread {
// Critical services... // Critical services...
try { try {
Log.i(TAG, "Starting Entropy Service."); Log.i(TAG, "Entropy Service");
ServiceManager.addService("entropy", new EntropyService()); ServiceManager.addService("entropy", new EntropyService());
Log.i(TAG, "Starting Power Manager."); Log.i(TAG, "Power Manager");
power = new PowerManagerService(); power = new PowerManagerService();
ServiceManager.addService(Context.POWER_SERVICE, power); ServiceManager.addService(Context.POWER_SERVICE, power);
Log.i(TAG, "Starting Activity Manager."); Log.i(TAG, "Activity Manager");
context = ActivityManagerService.main(factoryTest); context = ActivityManagerService.main(factoryTest);
Log.i(TAG, "Starting telephony registry"); Log.i(TAG, "Telephony Registry");
ServiceManager.addService("telephony.registry", new TelephonyRegistry(context)); ServiceManager.addService("telephony.registry", new TelephonyRegistry(context));
AttributeCache.init(context); AttributeCache.init(context);
Log.i(TAG, "Starting Package Manager."); Log.i(TAG, "Package Manager");
pm = PackageManagerService.main(context, pm = PackageManagerService.main(context,
factoryTest != SystemServer.FACTORY_TEST_OFF); factoryTest != SystemServer.FACTORY_TEST_OFF);
@@ -116,25 +116,25 @@ class ServerThread extends Thread {
mContentResolver = context.getContentResolver(); mContentResolver = context.getContentResolver();
try { try {
Log.i(TAG, "Starting Account Manager."); Log.i(TAG, "Account Manager");
ServiceManager.addService(Context.ACCOUNT_SERVICE, ServiceManager.addService(Context.ACCOUNT_SERVICE,
new AccountManagerService(context)); new AccountManagerService(context));
} catch (Throwable e) { } catch (Throwable e) {
Log.e(TAG, "Failure starting Account Manager", e); Log.e(TAG, "Failure starting Account Manager", e);
} }
Log.i(TAG, "Starting Content Manager."); Log.i(TAG, "Content Manager");
ContentService.main(context, ContentService.main(context,
factoryTest == SystemServer.FACTORY_TEST_LOW_LEVEL); factoryTest == SystemServer.FACTORY_TEST_LOW_LEVEL);
Log.i(TAG, "Starting System Content Providers."); Log.i(TAG, "System Content Providers");
ActivityManagerService.installSystemProviders(); ActivityManagerService.installSystemProviders();
Log.i(TAG, "Starting Battery Service."); Log.i(TAG, "Battery Service");
battery = new BatteryService(context); battery = new BatteryService(context);
ServiceManager.addService("battery", battery); ServiceManager.addService("battery", battery);
Log.i(TAG, "Starting Hardware Service."); Log.i(TAG, "Hardware Service");
hardware = new HardwareService(context); hardware = new HardwareService(context);
ServiceManager.addService("hardware", hardware); ServiceManager.addService("hardware", hardware);
@@ -142,18 +142,19 @@ class ServerThread extends Thread {
// hardware service, content providers and the battery service. // hardware service, content providers and the battery service.
power.init(context, hardware, ActivityManagerService.getDefault(), battery); power.init(context, hardware, ActivityManagerService.getDefault(), battery);
Log.i(TAG, "Starting Alarm Manager."); Log.i(TAG, "Alarm Manager");
AlarmManagerService alarm = new AlarmManagerService(context); AlarmManagerService alarm = new AlarmManagerService(context);
ServiceManager.addService(Context.ALARM_SERVICE, alarm); ServiceManager.addService(Context.ALARM_SERVICE, alarm);
Log.i(TAG, "Init Watchdog");
Watchdog.getInstance().init(context, battery, power, alarm, Watchdog.getInstance().init(context, battery, power, alarm,
ActivityManagerService.self()); ActivityManagerService.self());
// Sensor Service is needed by Window Manager, so this goes first // Sensor Service is needed by Window Manager, so this goes first
Log.i(TAG, "Starting Sensor Service."); Log.i(TAG, "Sensor Service");
ServiceManager.addService(Context.SENSOR_SERVICE, new SensorService(context)); ServiceManager.addService(Context.SENSOR_SERVICE, new SensorService(context));
Log.i(TAG, "Starting Window Manager."); Log.i(TAG, "Window Manager");
wm = WindowManagerService.main(context, power, wm = WindowManagerService.main(context, power,
factoryTest != SystemServer.FACTORY_TEST_LOW_LEVEL); factoryTest != SystemServer.FACTORY_TEST_LOW_LEVEL);
ServiceManager.addService(Context.WINDOW_SERVICE, wm); ServiceManager.addService(Context.WINDOW_SERVICE, wm);
@@ -171,7 +172,7 @@ class ServerThread extends Thread {
Log.i(TAG, "Registering null Bluetooth Service (factory test)"); Log.i(TAG, "Registering null Bluetooth Service (factory test)");
ServiceManager.addService(Context.BLUETOOTH_SERVICE, null); ServiceManager.addService(Context.BLUETOOTH_SERVICE, null);
} else { } else {
Log.i(TAG, "Starting Bluetooth Service."); Log.i(TAG, "Bluetooth Service");
bluetooth = new BluetoothService(context); bluetooth = new BluetoothService(context);
ServiceManager.addService(Context.BLUETOOTH_SERVICE, bluetooth); ServiceManager.addService(Context.BLUETOOTH_SERVICE, bluetooth);
bluetooth.initAfterRegistration(); bluetooth.initAfterRegistration();
@@ -198,7 +199,7 @@ class ServerThread extends Thread {
if (factoryTest != SystemServer.FACTORY_TEST_LOW_LEVEL) { if (factoryTest != SystemServer.FACTORY_TEST_LOW_LEVEL) {
try { try {
Log.i(TAG, "Starting Status Bar Service."); Log.i(TAG, "Status Bar");
statusBar = new StatusBarService(context); statusBar = new StatusBarService(context);
ServiceManager.addService("statusbar", statusBar); ServiceManager.addService("statusbar", statusBar);
} catch (Throwable e) { } catch (Throwable e) {
@@ -206,14 +207,14 @@ class ServerThread extends Thread {
} }
try { try {
Log.i(TAG, "Starting Clipboard Service."); Log.i(TAG, "Clipboard Service");
ServiceManager.addService("clipboard", new ClipboardService(context)); ServiceManager.addService("clipboard", new ClipboardService(context));
} catch (Throwable e) { } catch (Throwable e) {
Log.e(TAG, "Failure starting Clipboard Service", e); Log.e(TAG, "Failure starting Clipboard Service", e);
} }
try { try {
Log.i(TAG, "Starting Input Method Service."); Log.i(TAG, "Input Method Service");
imm = new InputMethodManagerService(context, statusBar); imm = new InputMethodManagerService(context, statusBar);
ServiceManager.addService(Context.INPUT_METHOD_SERVICE, imm); ServiceManager.addService(Context.INPUT_METHOD_SERVICE, imm);
} catch (Throwable e) { } catch (Throwable e) {
@@ -221,14 +222,14 @@ class ServerThread extends Thread {
} }
try { try {
Log.i(TAG, "Starting NetStat Service."); Log.i(TAG, "NetStat Service");
ServiceManager.addService("netstat", new NetStatService(context)); ServiceManager.addService("netstat", new NetStatService(context));
} catch (Throwable e) { } catch (Throwable e) {
Log.e(TAG, "Failure starting NetStat Service", e); Log.e(TAG, "Failure starting NetStat Service", e);
} }
try { try {
Log.i(TAG, "Starting Connectivity Service."); Log.i(TAG, "Connectivity Service");
connectivity = ConnectivityService.getInstance(context); connectivity = ConnectivityService.getInstance(context);
ServiceManager.addService(Context.CONNECTIVITY_SERVICE, connectivity); ServiceManager.addService(Context.CONNECTIVITY_SERVICE, connectivity);
} catch (Throwable e) { } catch (Throwable e) {
@@ -236,7 +237,7 @@ class ServerThread extends Thread {
} }
try { try {
Log.i(TAG, "Starting Accessibility Manager."); Log.i(TAG, "Accessibility Manager");
ServiceManager.addService(Context.ACCESSIBILITY_SERVICE, ServiceManager.addService(Context.ACCESSIBILITY_SERVICE,
new AccessibilityManagerService(context)); new AccessibilityManagerService(context));
} catch (Throwable e) { } catch (Throwable e) {
@@ -244,7 +245,7 @@ class ServerThread extends Thread {
} }
try { try {
Log.i(TAG, "Starting Notification Manager."); Log.i(TAG, "Notification Manager");
notification = new NotificationManagerService(context, statusBar, hardware); notification = new NotificationManagerService(context, statusBar, hardware);
ServiceManager.addService(Context.NOTIFICATION_SERVICE, notification); ServiceManager.addService(Context.NOTIFICATION_SERVICE, notification);
} catch (Throwable e) { } catch (Throwable e) {
@@ -253,14 +254,14 @@ class ServerThread extends Thread {
try { try {
// MountService must start after NotificationManagerService // MountService must start after NotificationManagerService
Log.i(TAG, "Starting Mount Service."); Log.i(TAG, "Mount Service");
ServiceManager.addService("mount", new MountService(context)); ServiceManager.addService("mount", new MountService(context));
} catch (Throwable e) { } catch (Throwable e) {
Log.e(TAG, "Failure starting Mount Service", e); Log.e(TAG, "Failure starting Mount Service", e);
} }
try { try {
Log.i(TAG, "Starting DeviceStorageMonitor service"); Log.i(TAG, "Device Storage Monitor");
ServiceManager.addService(DeviceStorageMonitorService.SERVICE, ServiceManager.addService(DeviceStorageMonitorService.SERVICE,
new DeviceStorageMonitorService(context)); new DeviceStorageMonitorService(context));
} catch (Throwable e) { } catch (Throwable e) {
@@ -268,14 +269,14 @@ class ServerThread extends Thread {
} }
try { try {
Log.i(TAG, "Starting Location Manager."); Log.i(TAG, "Location Manager");
ServiceManager.addService(Context.LOCATION_SERVICE, new LocationManagerService(context)); ServiceManager.addService(Context.LOCATION_SERVICE, new LocationManagerService(context));
} catch (Throwable e) { } catch (Throwable e) {
Log.e(TAG, "Failure starting Location Manager", e); Log.e(TAG, "Failure starting Location Manager", e);
} }
try { try {
Log.i(TAG, "Starting Search Service."); Log.i(TAG, "Search Service");
ServiceManager.addService( Context.SEARCH_SERVICE, new SearchManagerService(context) ); ServiceManager.addService( Context.SEARCH_SERVICE, new SearchManagerService(context) );
} catch (Throwable e) { } catch (Throwable e) {
Log.e(TAG, "Failure starting Search Service", e); Log.e(TAG, "Failure starting Search Service", e);
@@ -287,7 +288,7 @@ class ServerThread extends Thread {
} }
try { try {
Log.i(TAG, "Starting Checkin Service."); Log.i(TAG, "Checkin Service");
Intent intent = new Intent().setComponent(new ComponentName( Intent intent = new Intent().setComponent(new ComponentName(
"com.google.android.server.checkin", "com.google.android.server.checkin",
"com.google.android.server.checkin.CheckinService")); "com.google.android.server.checkin.CheckinService"));
@@ -300,7 +301,7 @@ class ServerThread extends Thread {
} }
try { try {
Log.i(TAG, "Starting Wallpaper Service"); Log.i(TAG, "Wallpaper Service");
wallpaper = new WallpaperManagerService(context); wallpaper = new WallpaperManagerService(context);
ServiceManager.addService(Context.WALLPAPER_SERVICE, wallpaper); ServiceManager.addService(Context.WALLPAPER_SERVICE, wallpaper);
} catch (Throwable e) { } catch (Throwable e) {
@@ -308,14 +309,14 @@ class ServerThread extends Thread {
} }
try { try {
Log.i(TAG, "Starting Audio Service"); Log.i(TAG, "Audio Service");
ServiceManager.addService(Context.AUDIO_SERVICE, new AudioService(context)); ServiceManager.addService(Context.AUDIO_SERVICE, new AudioService(context));
} catch (Throwable e) { } catch (Throwable e) {
Log.e(TAG, "Failure starting Audio Service", e); Log.e(TAG, "Failure starting Audio Service", e);
} }
try { try {
Log.i(TAG, "Starting HeadsetObserver"); Log.i(TAG, "Headset Observer");
// Listen for wired headset changes // Listen for wired headset changes
headset = new HeadsetObserver(context); headset = new HeadsetObserver(context);
} catch (Throwable e) { } catch (Throwable e) {
@@ -323,7 +324,7 @@ class ServerThread extends Thread {
} }
try { try {
Log.i(TAG, "Starting DockObserver"); Log.i(TAG, "Dock Observer");
// Listen for dock station changes // Listen for dock station changes
dock = new DockObserver(context); dock = new DockObserver(context);
} catch (Throwable e) { } catch (Throwable e) {
@@ -331,14 +332,14 @@ class ServerThread extends Thread {
} }
try { try {
Log.i(TAG, "Starting Backup Service"); Log.i(TAG, "Backup Service");
ServiceManager.addService(Context.BACKUP_SERVICE, new BackupManagerService(context)); ServiceManager.addService(Context.BACKUP_SERVICE, new BackupManagerService(context));
} catch (Throwable e) { } catch (Throwable e) {
Log.e(TAG, "Failure starting Backup Service", e); Log.e(TAG, "Failure starting Backup Service", e);
} }
try { try {
Log.i(TAG, "Starting AppWidget Service"); Log.i(TAG, "AppWidget Service");
appWidget = new AppWidgetService(context); appWidget = new AppWidgetService(context);
ServiceManager.addService(Context.APPWIDGET_SERVICE, appWidget); ServiceManager.addService(Context.APPWIDGET_SERVICE, appWidget);
} catch (Throwable e) { } catch (Throwable e) {
@@ -361,7 +362,7 @@ class ServerThread extends Thread {
false, new AdbSettingsObserver()); false, new AdbSettingsObserver());
// It is now time to start up the app processes... // It is now time to start up the app processes...
boolean safeMode = wm.detectSafeMode(); final boolean safeMode = wm.detectSafeMode();
if (notification != null) { if (notification != null) {
notification.systemReady(); notification.systemReady();
@@ -370,31 +371,45 @@ class ServerThread extends Thread {
if (statusBar != null) { if (statusBar != null) {
statusBar.systemReady(); statusBar.systemReady();
} }
if (imm != null) {
imm.systemReady();
}
wm.systemReady(); wm.systemReady();
power.systemReady(); power.systemReady();
try { try {
pm.systemReady(); pm.systemReady();
} catch (RemoteException e) { } catch (RemoteException e) {
} }
if (appWidget != null) {
appWidget.systemReady(safeMode);
}
// After making the following code, third party code may be running... // These are needed to propagate to the runnable below.
try { final BatteryService batteryF = battery;
ActivityManagerNative.getDefault().systemReady(); final ConnectivityService connectivityF = connectivity;
} catch (RemoteException e) { final DockObserver dockF = dock;
} final AppWidgetService appWidgetF = appWidget;
final WallpaperManagerService wallpaperF = wallpaper;
if (wallpaper != null) wallpaper.systemReady(); final InputMethodManagerService immF = imm;
if (battery != null) battery.systemReady();
if (connectivity != null) connectivity.systemReady(); // We now tell the activity manager it is okay to run third party
if (dock != null) dock.systemReady(); // code. It will call back into us once it has gotten to the state
Watchdog.getInstance().start(); // where third party code can really run (but before it has actually
// started launching the initial applications), for us to complete our
// initialization.
((ActivityManagerService)ActivityManagerNative.getDefault())
.systemReady(new Runnable() {
public void run() {
Log.i(TAG, "Making services ready");
if (batteryF != null) batteryF.systemReady();
if (connectivityF != null) connectivityF.systemReady();
if (dockF != null) dockF.systemReady();
Watchdog.getInstance().start();
// It is now okay to let the various system services start their
// third party code...
if (appWidgetF != null) appWidgetF.systemReady(safeMode);
if (wallpaperF != null) wallpaperF.systemReady();
if (immF != null) immF.systemReady();
}
});
Looper.loop(); Looper.loop();
Log.d(TAG, "System ServerThread is exiting!"); Log.d(TAG, "System ServerThread is exiting!");
} }

View File

@@ -8188,7 +8188,7 @@ public final class ActivityManagerService extends ActivityManagerNative implemen
} }
} }
systemReady(); systemReady(null);
} }
private void retrieveSettings() { private void retrieveSettings() {
@@ -8218,7 +8218,7 @@ public final class ActivityManagerService extends ActivityManagerNative implemen
return mSystemReady; return mSystemReady;
} }
public void systemReady() { public void systemReady(final Runnable goingCallback) {
// In the simulator, startRunning will never have been called, which // In the simulator, startRunning will never have been called, which
// normally sets a few crucial variables. Do it here instead. // normally sets a few crucial variables. Do it here instead.
if (!Process.supportsProcesses()) { if (!Process.supportsProcesses()) {
@@ -8228,6 +8228,7 @@ public final class ActivityManagerService extends ActivityManagerNative implemen
synchronized(this) { synchronized(this) {
if (mSystemReady) { if (mSystemReady) {
if (goingCallback != null) goingCallback.run();
return; return;
} }
@@ -8263,7 +8264,7 @@ public final class ActivityManagerService extends ActivityManagerNative implemen
synchronized (ActivityManagerService.this) { synchronized (ActivityManagerService.this) {
mDidUpdate = true; mDidUpdate = true;
} }
systemReady(); systemReady(goingCallback);
} }
}; };
} }
@@ -8310,7 +8311,7 @@ public final class ActivityManagerService extends ActivityManagerNative implemen
} }
} }
if (Config.LOGD) Log.d(TAG, "Start running!"); Log.i(TAG, "System now ready");
EventLog.writeEvent(LOG_BOOT_PROGRESS_AMS_READY, EventLog.writeEvent(LOG_BOOT_PROGRESS_AMS_READY,
SystemClock.uptimeMillis()); SystemClock.uptimeMillis());
@@ -8352,6 +8353,8 @@ public final class ActivityManagerService extends ActivityManagerNative implemen
retrieveSettings(); retrieveSettings();
if (goingCallback != null) goingCallback.run();
synchronized (this) { synchronized (this) {
if (mFactoryTest != SystemServer.FACTORY_TEST_LOW_LEVEL) { if (mFactoryTest != SystemServer.FACTORY_TEST_LOW_LEVEL) {
try { try {