Skip to content

Commit e23ae14

Browse files
krutonAndroid Git Automerger
authored andcommitted
am fa74f7e: am bba948d: Merge "Delay AccountManagerService initialization" into jb-dev
* commit 'fa74f7e04fcad1258a1b85515547dba0466086d8': Delay AccountManagerService initialization
2 parents 4fcaa38 + fa74f7e commit e23ae14

File tree

5 files changed

+34
-7
lines changed

5 files changed

+34
-7
lines changed

core/java/android/accounts/AccountManagerService.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -220,8 +220,6 @@ public AccountManagerService(Context context, PackageManager packageManager,
220220

221221
sThis.set(this);
222222

223-
UserAccounts accounts = initUser(0);
224-
225223
IntentFilter intentFilter = new IntentFilter();
226224
intentFilter.addAction(Intent.ACTION_PACKAGE_REMOVED);
227225
intentFilter.addDataScheme("package");
@@ -242,6 +240,11 @@ public void onReceive(Context context, Intent intent) {
242240
}, userFilter);
243241
}
244242

243+
public void systemReady() {
244+
mAuthenticatorCache.generateServicesMap();
245+
initUser(0);
246+
}
247+
245248
private UserAccounts initUser(int userId) {
246249
synchronized (mUsers) {
247250
UserAccounts accounts = mUsers.get(userId);

core/java/android/accounts/IAccountAuthenticatorCache.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,4 +60,9 @@ RegisteredServicesCache.ServiceInfo<AuthenticatorDescription> getServiceInfo(
6060
*/
6161
void setListener(RegisteredServicesCacheListener<AuthenticatorDescription> listener,
6262
Handler handler);
63+
64+
/**
65+
* Refreshes the authenticator cache.
66+
*/
67+
void generateServicesMap();
6368
}

core/java/android/content/ContentService.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,9 @@ public boolean onTransact(int code, Parcel data, Parcel reply, int flags)
132132
/*package*/ ContentService(Context context, boolean factoryTest) {
133133
mContext = context;
134134
mFactoryTest = factoryTest;
135+
}
136+
137+
public void systemReady() {
135138
getSyncManager();
136139
}
137140

@@ -524,7 +527,7 @@ public void removeStatusChangeListener(ISyncStatusObserver callback) {
524527
}
525528
}
526529

527-
public static IContentService main(Context context, boolean factoryTest) {
530+
public static ContentService main(Context context, boolean factoryTest) {
528531
ContentService service = new ContentService(context, factoryTest);
529532
ServiceManager.addService(ContentResolver.CONTENT_SERVICE_NAME, service);
530533
return service;

core/java/android/content/pm/RegisteredServicesCache.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ private boolean inSystemImage(int callerUid) {
251251
return false;
252252
}
253253

254-
void generateServicesMap() {
254+
public void generateServicesMap() {
255255
PackageManager pm = mContext.getPackageManager();
256256
ArrayList<ServiceInfo<V>> serviceInfos = new ArrayList<ServiceInfo<V>>();
257257
List<ResolveInfo> resolveInfos = pm.queryIntentServices(new Intent(mInterfaceName),

services/java/com/android/server/SystemServer.java

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,8 @@ public void run() {
114114
: Integer.parseInt(factoryTestStr);
115115
final boolean headless = "1".equals(SystemProperties.get("ro.config.headless", "0"));
116116

117+
AccountManagerService accountManager = null;
118+
ContentService contentService = null;
117119
LightsService lights = null;
118120
PowerManagerService power = null;
119121
DisplayManagerService display = null;
@@ -195,14 +197,14 @@ public void run() {
195197
// The AccountManager must come before the ContentService
196198
try {
197199
Slog.i(TAG, "Account Manager");
198-
ServiceManager.addService(Context.ACCOUNT_SERVICE,
199-
new AccountManagerService(context));
200+
accountManager = new AccountManagerService(context);
201+
ServiceManager.addService(Context.ACCOUNT_SERVICE, accountManager);
200202
} catch (Throwable e) {
201203
Slog.e(TAG, "Failure starting Account Manager", e);
202204
}
203205

204206
Slog.i(TAG, "Content Manager");
205-
ContentService.main(context,
207+
contentService = ContentService.main(context,
206208
factoryTest == SystemServer.FACTORY_TEST_LOW_LEVEL);
207209

208210
Slog.i(TAG, "System Content Providers");
@@ -456,6 +458,20 @@ public void run() {
456458
mountService.waitForAsecScan();
457459
}
458460

461+
try {
462+
if (accountManager != null)
463+
accountManager.systemReady();
464+
} catch (Throwable e) {
465+
reportWtf("making Account Manager Service ready", e);
466+
}
467+
468+
try {
469+
if (contentService != null)
470+
contentService.systemReady();
471+
} catch (Throwable e) {
472+
reportWtf("making Content Service ready", e);
473+
}
474+
459475
try {
460476
Slog.i(TAG, "Notification Manager");
461477
notification = new NotificationManagerService(context, statusBar, lights);

0 commit comments

Comments
 (0)