Skip to content

Commit 1da49e4

Browse files
author
The Android Open Source Project
committed
merge from open-source master
Change-Id: I23af6296f0867bea2a2da72d4eb3dda93025b1ac
2 parents 7243c04 + 239750f commit 1da49e4

File tree

2 files changed

+66
-24
lines changed

2 files changed

+66
-24
lines changed

services/java/com/android/server/am/ActivityManagerService.java

Lines changed: 35 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -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
}

telephony/java/com/android/internal/telephony/SMSDispatcher.java

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,12 @@ public abstract class SMSDispatcher extends Handler {
109109
/** Stop the sending */
110110
static final protected int EVENT_STOP_SENDING = 10;
111111

112+
/** Memory status reporting is acknowledged by RIL */
113+
static final protected int EVENT_REPORT_MEMORY_STATUS_DONE = 11;
114+
115+
/** Radio is ON */
116+
static final protected int EVENT_RADIO_ON = 12;
117+
112118
protected Phone mPhone;
113119
protected Context mContext;
114120
protected ContentResolver mResolver;
@@ -152,6 +158,7 @@ public abstract class SMSDispatcher extends Handler {
152158
private SmsMessageBase.SubmitPduBase mSubmitPduBase;
153159

154160
protected boolean mStorageAvailable = true;
161+
protected boolean mReportMemoryStatusPending = false;
155162

156163
protected static int getNextConcatenatedRef() {
157164
sConcatenatedRef += 1;
@@ -235,6 +242,7 @@ protected SMSDispatcher(PhoneBase phone) {
235242
mCm.setOnNewSMS(this, EVENT_NEW_SMS, null);
236243
mCm.setOnSmsStatus(this, EVENT_NEW_SMS_STATUS_REPORT, null);
237244
mCm.setOnIccSmsFull(this, EVENT_ICC_FULL, null);
245+
mCm.registerForOn(this, EVENT_RADIO_ON, null);
238246

239247
// Don't always start message ref at 0.
240248
sConcatenatedRef = new Random().nextInt(256);
@@ -253,6 +261,7 @@ public void dispose() {
253261
mCm.unSetOnNewSMS(this);
254262
mCm.unSetOnSmsStatus(this);
255263
mCm.unSetOnIccSmsFull(this);
264+
mCm.unregisterForOn(this);
256265
}
257266

258267
protected void finalize() {
@@ -370,6 +379,26 @@ public void handleMessage(Message msg) {
370379
removeMessages(EVENT_ALERT_TIMEOUT, msg.obj);
371380
}
372381
break;
382+
383+
case EVENT_REPORT_MEMORY_STATUS_DONE:
384+
ar = (AsyncResult)msg.obj;
385+
if (ar.exception != null) {
386+
mReportMemoryStatusPending = true;
387+
Log.v(TAG, "Memory status report to modem pending : mStorageAvailable = "
388+
+ mStorageAvailable);
389+
} else {
390+
mReportMemoryStatusPending = false;
391+
}
392+
break;
393+
394+
case EVENT_RADIO_ON:
395+
if (mReportMemoryStatusPending) {
396+
Log.v(TAG, "Sending pending memory status report : mStorageAvailable = "
397+
+ mStorageAvailable);
398+
mCm.reportSmsMemoryStatus(mStorageAvailable,
399+
obtainMessage(EVENT_REPORT_MEMORY_STATUS_DONE));
400+
}
401+
break;
373402
}
374403
}
375404

@@ -940,10 +969,10 @@ public void onClick(DialogInterface dialog, int which) {
940969
public void onReceive(Context context, Intent intent) {
941970
if (intent.getAction().equals(Intent.ACTION_DEVICE_STORAGE_LOW)) {
942971
mStorageAvailable = false;
943-
mCm.reportSmsMemoryStatus(false, null);
972+
mCm.reportSmsMemoryStatus(false, obtainMessage(EVENT_REPORT_MEMORY_STATUS_DONE));
944973
} else if (intent.getAction().equals(Intent.ACTION_DEVICE_STORAGE_OK)) {
945974
mStorageAvailable = true;
946-
mCm.reportSmsMemoryStatus(true, null);
975+
mCm.reportSmsMemoryStatus(true, obtainMessage(EVENT_REPORT_MEMORY_STATUS_DONE));
947976
} else {
948977
// Assume the intent is one of the SMS receive intents that
949978
// was sent as an ordered broadcast. Check result and ACK.

0 commit comments

Comments
 (0)