@@ -3566,7 +3566,7 @@ private final int startActivityUncheckedLocked(HistoryRecord r,
35663566 if (DEBUG_TASKS) Log.v(TAG, "Starting new activity " + r
35673567 + " in new task " + r.task);
35683568 newTask = true;
3569- addRecentTask (r.task);
3569+ addRecentTaskLocked (r.task);
35703570
35713571 } else if (sourceRecord != null) {
35723572 if (!addingToTask &&
@@ -3855,7 +3855,7 @@ public final int startActivityInPackage(int uid,
38553855 }
38563856 }
38573857
3858- private final void addRecentTask (TaskRecord task) {
3858+ private final void addRecentTaskLocked (TaskRecord task) {
38593859 // Remove any existing entries that are the same kind of task.
38603860 int N = mRecentTasks.size();
38613861 for (int i=0; i<N; i++) {
@@ -4931,9 +4931,11 @@ public boolean clearApplicationUserData(final String packageName,
49314931 Intent intent = new Intent(Intent.ACTION_PACKAGE_DATA_CLEARED,
49324932 Uri.fromParts("package", packageName, null));
49334933 intent.putExtra(Intent.EXTRA_UID, pkgUid);
4934- broadcastIntentLocked(null, null, intent,
4935- null, null, 0, null, null, null,
4936- false, false, MY_PID, Process.SYSTEM_UID);
4934+ synchronized (this) {
4935+ broadcastIntentLocked(null, null, intent,
4936+ null, null, 0, null, null, null,
4937+ false, false, MY_PID, Process.SYSTEM_UID);
4938+ }
49374939 } catch (RemoteException e) {
49384940 }
49394941 } finally {
@@ -5668,7 +5670,9 @@ final void finishBooting() {
56685670 ArrayList<ProcessRecord> procs =
56695671 new ArrayList<ProcessRecord>(mProcessesOnHold);
56705672 for (int ip=0; ip<NP; ip++) {
5671- this.startProcessLocked(procs.get(ip), "on-hold", null);
5673+ synchronized (this) {
5674+ this.startProcessLocked(procs.get(ip), "on-hold", null);
5675+ }
56725676 }
56735677 }
56745678 if (mFactoryTest != SystemServer.FACTORY_TEST_LOW_LEVEL) {
@@ -6887,7 +6891,7 @@ private final HistoryRecord resetTaskIfNeededLocked(HistoryRecord taskTop,
68876891 taskTopI = -1;
68886892 }
68896893 replyChainEnd = -1;
6890- addRecentTask (target.task);
6894+ addRecentTaskLocked (target.task);
68916895 } else if (forceReset || finishOnTaskLaunch
68926896 || clearWhenTaskReset) {
68936897 // If the activity should just be removed -- either
@@ -7109,7 +7113,7 @@ private final void moveTaskToFrontLocked(TaskRecord tr, HistoryRecord reason) {
71097113 moved.add(0, r);
71107114 top--;
71117115 if (first) {
7112- addRecentTask (r.task);
7116+ addRecentTaskLocked (r.task);
71137117 first = false;
71147118 }
71157119 }
@@ -7134,11 +7138,11 @@ private final void moveTaskToFrontLocked(TaskRecord tr, HistoryRecord reason) {
71347138 mWindowManager.validateAppTokens(mHistory);
71357139 }
71367140
7137- finishTaskMove (task);
7141+ finishTaskMoveLocked (task);
71387142 EventLog.writeEvent(LOG_TASK_TO_FRONT, task);
71397143 }
71407144
7141- private final void finishTaskMove (int task) {
7145+ private final void finishTaskMoveLocked (int task) {
71427146 resumeTopActivityLocked(null);
71437147 }
71447148
@@ -7256,7 +7260,7 @@ private final boolean moveTaskToBackLocked(int task, HistoryRecord reason) {
72567260 mWindowManager.validateAppTokens(mHistory);
72577261 }
72587262
7259- finishTaskMove (task);
7263+ finishTaskMoveLocked (task);
72607264 return true;
72617265 }
72627266
@@ -7879,9 +7883,14 @@ public final void publishContentProviders(IApplicationThread caller,
78797883 }
78807884
78817885 public static final void installSystemProviders() {
7882- ProcessRecord app = mSelf.mProcessNames.get("system", Process.SYSTEM_UID);
7883- List providers = mSelf.generateApplicationProvidersLocked(app);
7884- mSystemThread.installSystemProviders(providers);
7886+ List providers = null;
7887+ synchronized (mSelf) {
7888+ ProcessRecord app = mSelf.mProcessNames.get("system", Process.SYSTEM_UID);
7889+ providers = mSelf.generateApplicationProvidersLocked(app);
7890+ }
7891+ if (providers != null) {
7892+ mSystemThread.installSystemProviders(providers);
7893+ }
78857894 }
78867895
78877896 // =========================================================
@@ -8156,11 +8165,15 @@ public void setActivityController(IActivityController controller) {
81568165 }
81578166
81588167 public void registerActivityWatcher(IActivityWatcher watcher) {
8159- mWatchers.register(watcher);
8168+ synchronized (this) {
8169+ mWatchers.register(watcher);
8170+ }
81608171 }
81618172
81628173 public void unregisterActivityWatcher(IActivityWatcher watcher) {
8163- mWatchers.unregister(watcher);
8174+ synchronized (this) {
8175+ mWatchers.unregister(watcher);
8176+ }
81648177 }
81658178
81668179 public final void enterSafeMode() {
@@ -11564,7 +11577,7 @@ public void unbindBackupAgent(ApplicationInfo appInfo) {
1156411577 // BROADCASTS
1156511578 // =========================================================
1156611579
11567- private final List getStickies (String action, IntentFilter filter,
11580+ private final List getStickiesLocked (String action, IntentFilter filter,
1156811581 List cur) {
1156911582 final ContentResolver resolver = mContext.getContentResolver();
1157011583 final ArrayList<Intent> list = mStickyBroadcasts.get(action);
@@ -11616,10 +11629,10 @@ public Intent registerReceiver(IApplicationThread caller,
1161611629 if (actions != null) {
1161711630 while (actions.hasNext()) {
1161811631 String action = (String)actions.next();
11619- allSticky = getStickies (action, filter, allSticky);
11632+ allSticky = getStickiesLocked (action, filter, allSticky);
1162011633 }
1162111634 } else {
11622- allSticky = getStickies (null, filter, allSticky);
11635+ allSticky = getStickiesLocked (null, filter, allSticky);
1162311636 }
1162411637
1162511638 // The first sticky in the list is returned directly back to
@@ -13357,7 +13370,7 @@ final void performAppGcLocked(ProcessRecord app) {
1335713370 /**
1335813371 * Returns true if things are idle enough to perform GCs.
1335913372 */
13360- private final boolean canGcNow () {
13373+ private final boolean canGcNowLocked () {
1336113374 return mParallelBroadcasts.size() == 0
1336213375 && mOrderedBroadcasts.size() == 0
1336313376 && (mSleeping || (mResumedActivity != null &&
@@ -13373,7 +13386,7 @@ final void performAppGcsLocked() {
1337313386 if (N <= 0) {
1337413387 return;
1337513388 }
13376- if (canGcNow ()) {
13389+ if (canGcNowLocked ()) {
1337713390 while (mProcessesToGc.size() > 0) {
1337813391 ProcessRecord proc = mProcessesToGc.remove(0);
1337913392 if (proc.curRawAdj > VISIBLE_APP_ADJ || proc.reportLowMemory) {
@@ -13401,7 +13414,7 @@ final void performAppGcsLocked() {
1340113414 * If all looks good, perform GCs on all processes waiting for them.
1340213415 */
1340313416 final void performAppGcsIfAppropriateLocked() {
13404- if (canGcNow ()) {
13417+ if (canGcNowLocked ()) {
1340513418 performAppGcsLocked();
1340613419 return;
1340713420 }
0 commit comments