Merge "Fix issue #5263361: Browser instance not created in application picker"

This commit is contained in:
Dianne Hackborn
2011-09-08 10:38:42 -07:00
committed by Android (Google) Code Review
8 changed files with 126 additions and 89 deletions

View File

@@ -1254,6 +1254,12 @@ public class ActivityManager {
*/
public ComponentName importanceReasonComponent;
/**
* When {@link importanceReasonPid} is non-0, this is the importance
* of the other pid. @hide
*/
public int importanceReasonImportance;
public RunningAppProcessInfo() {
importance = IMPORTANCE_FOREGROUND;
importanceReasonCode = REASON_UNKNOWN;
@@ -1280,6 +1286,7 @@ public class ActivityManager {
dest.writeInt(importanceReasonCode);
dest.writeInt(importanceReasonPid);
ComponentName.writeToParcel(importanceReasonComponent, dest);
dest.writeInt(importanceReasonImportance);
}
public void readFromParcel(Parcel source) {
@@ -1293,6 +1300,7 @@ public class ActivityManager {
importanceReasonCode = source.readInt();
importanceReasonPid = source.readInt();
importanceReasonComponent = ComponentName.readFromParcel(source);
importanceReasonImportance = source.readInt();
}
public static final Creator<RunningAppProcessInfo> CREATOR =

View File

@@ -239,6 +239,9 @@ public abstract class Context {
* methods of activities and other components are called. Note that you
* <em>must</em> be sure to use {@link #unregisterComponentCallbacks} when
* appropriate in the future; this will not be removed for you.
*
* @param callback The interface to call. This can be either a
* {@link ComponentCallbacks} or {@link ComponentCallbacks2} interface.
*/
public void registerComponentCallbacks(ComponentCallbacks callback) {
getApplicationContext().registerComponentCallbacks(callback);

View File

@@ -58,9 +58,20 @@ public class ResolverActivity extends AlertActivity implements
private TextView mClearDefaultHint;
private PackageManager mPm;
private Intent makeMyIntent() {
Intent intent = new Intent(getIntent());
// The resolver activity is set to be hidden from recent tasks.
// we don't want this attribute to be propagated to the next activity
// being launched. Note that if the original Intent also had this
// flag set, we are now losing it. That should be a very rare case
// and we can live with this.
intent.setFlags(intent.getFlags()&~Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
return intent;
}
@Override
protected void onCreate(Bundle savedInstanceState) {
onCreate(savedInstanceState, new Intent(getIntent()),
onCreate(savedInstanceState, makeMyIntent(),
getResources().getText(com.android.internal.R.string.whichApplication),
null, null, true);
}

View File

@@ -1499,19 +1499,23 @@
android:theme="@style/Theme.Holo.Dialog"
android:label="@string/heavy_weight_switcher_title"
android:finishOnCloseSystemDialogs="true"
android:excludeFromRecents="true">
android:excludeFromRecents="true"
android:process=":ui">
</activity>
<activity android:name="com.android.internal.app.PlatLogoActivity"
android:theme="@style/Theme.Wallpaper.NoTitleBar.Fullscreen">
android:theme="@style/Theme.Wallpaper.NoTitleBar.Fullscreen"
android:process=":ui">
</activity>
<activity android:name="com.android.internal.app.DisableCarModeActivity"
android:theme="@style/Theme.NoDisplay"
android:excludeFromRecents="true">
android:excludeFromRecents="true"
android:process=":ui">
</activity>
<activity android:name="com.android.internal.app.RingtonePickerActivity"
android:theme="@style/Theme.Holo.Dialog.Alert"
android:excludeFromRecents="true"
android:multiprocess="true">
android:multiprocess="true"
android:process=":ui">
<intent-filter>
<action android:name="android.intent.action.RINGTONE_PICKER" />
<category android:name="android.intent.category.DEFAULT" />
@@ -1522,18 +1526,21 @@
android:excludeFromRecents="true"
android:exported="true"
android:theme="@android:style/Theme.Holo.Dialog"
android:label="@string/choose_account_label">
android:label="@string/choose_account_label"
android:process=":ui">
</activity>
<activity android:name="android.accounts.GrantCredentialsPermissionActivity"
android:excludeFromRecents="true"
android:exported="true"
android:theme="@android:style/Theme.Holo.DialogWhenLarge">
android:theme="@android:style/Theme.Holo.DialogWhenLarge"
android:process=":ui">
</activity>
<activity android:name="android.content.SyncActivityTooManyDeletes"
android:theme="@android:style/Theme.Holo.Dialog"
android:label="@string/sync_too_many_deletes">
android:label="@string/sync_too_many_deletes"
android:process=":ui">
</activity>
<activity android:name="com.android.server.ShutdownActivity"
@@ -1551,7 +1558,8 @@
<activity android:name="com.android.internal.app.NetInitiatedActivity"
android:theme="@style/Theme.Holo.Dialog.Alert"
android:excludeFromRecents="true">
android:excludeFromRecents="true"
android:process=":ui">
</activity>
<receiver android:name="com.android.server.BootReceiver" >

View File

@@ -106,6 +106,7 @@ import android.os.SystemClock;
import android.os.SystemProperties;
import android.provider.Settings;
import android.util.EventLog;
import android.util.Pair;
import android.util.Slog;
import android.util.Log;
import android.util.PrintWriterPrinter;
@@ -5004,7 +5005,13 @@ public final class ActivityManagerService extends ActivityManagerNative
maxNum < N ? maxNum : N);
for (int i=0; i<N && maxNum > 0; i++) {
TaskRecord tr = mRecentTasks.get(i);
if (((flags&ActivityManager.RECENT_WITH_EXCLUDED) != 0)
// Return the entry if desired by the caller. We always return
// the first entry, because callers always expect this to be the
// forground app. We may filter others if the caller has
// not supplied RECENT_WITH_EXCLUDED and there is some reason
// we should exclude the entry.
if (i == 0
|| ((flags&ActivityManager.RECENT_WITH_EXCLUDED) != 0)
|| (tr.intent == null)
|| ((tr.intent.getFlags()
&Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS) == 0)) {
@@ -7546,7 +7553,33 @@ public final class ActivityManagerService extends ActivityManagerNative
return errList;
}
static int oomAdjToImportance(int adj, ActivityManager.RunningAppProcessInfo currApp) {
if (adj >= ProcessList.EMPTY_APP_ADJ) {
return ActivityManager.RunningAppProcessInfo.IMPORTANCE_EMPTY;
} else if (adj >= ProcessList.HIDDEN_APP_MIN_ADJ) {
if (currApp != null) {
currApp.lru = adj - ProcessList.HIDDEN_APP_MIN_ADJ + 1;
}
return ActivityManager.RunningAppProcessInfo.IMPORTANCE_BACKGROUND;
} else if (adj >= ProcessList.HOME_APP_ADJ) {
if (currApp != null) {
currApp.lru = 0;
}
return ActivityManager.RunningAppProcessInfo.IMPORTANCE_BACKGROUND;
} else if (adj >= ProcessList.SECONDARY_SERVER_ADJ) {
return ActivityManager.RunningAppProcessInfo.IMPORTANCE_SERVICE;
} else if (adj >= ProcessList.HEAVY_WEIGHT_APP_ADJ) {
return ActivityManager.RunningAppProcessInfo.IMPORTANCE_CANT_SAVE_STATE;
} else if (adj >= ProcessList.PERCEPTIBLE_APP_ADJ) {
return ActivityManager.RunningAppProcessInfo.IMPORTANCE_PERCEPTIBLE;
} else if (adj >= ProcessList.VISIBLE_APP_ADJ) {
return ActivityManager.RunningAppProcessInfo.IMPORTANCE_VISIBLE;
} else {
return ActivityManager.RunningAppProcessInfo.IMPORTANCE_FOREGROUND;
}
}
public List<ActivityManager.RunningAppProcessInfo> getRunningAppProcesses() {
// Lazy instantiation of list
List<ActivityManager.RunningAppProcessInfo> runList = null;
@@ -7567,28 +7600,12 @@ public final class ActivityManagerService extends ActivityManagerNative
currApp.flags |= ActivityManager.RunningAppProcessInfo.FLAG_PERSISTENT;
}
int adj = app.curAdj;
if (adj >= ProcessList.EMPTY_APP_ADJ) {
currApp.importance = ActivityManager.RunningAppProcessInfo.IMPORTANCE_EMPTY;
} else if (adj >= ProcessList.HIDDEN_APP_MIN_ADJ) {
currApp.importance = ActivityManager.RunningAppProcessInfo.IMPORTANCE_BACKGROUND;
currApp.lru = adj - ProcessList.HIDDEN_APP_MIN_ADJ + 1;
} else if (adj >= ProcessList.HOME_APP_ADJ) {
currApp.importance = ActivityManager.RunningAppProcessInfo.IMPORTANCE_BACKGROUND;
currApp.lru = 0;
} else if (adj >= ProcessList.SECONDARY_SERVER_ADJ) {
currApp.importance = ActivityManager.RunningAppProcessInfo.IMPORTANCE_SERVICE;
} else if (adj >= ProcessList.HEAVY_WEIGHT_APP_ADJ) {
currApp.importance = ActivityManager.RunningAppProcessInfo.IMPORTANCE_CANT_SAVE_STATE;
} else if (adj >= ProcessList.PERCEPTIBLE_APP_ADJ) {
currApp.importance = ActivityManager.RunningAppProcessInfo.IMPORTANCE_PERCEPTIBLE;
} else if (adj >= ProcessList.VISIBLE_APP_ADJ) {
currApp.importance = ActivityManager.RunningAppProcessInfo.IMPORTANCE_VISIBLE;
} else {
currApp.importance = ActivityManager.RunningAppProcessInfo.IMPORTANCE_FOREGROUND;
}
currApp.importance = oomAdjToImportance(adj, currApp);
currApp.importanceReasonCode = app.adjTypeCode;
if (app.adjSource instanceof ProcessRecord) {
currApp.importanceReasonPid = ((ProcessRecord)app.adjSource).pid;
currApp.importanceReasonImportance = oomAdjToImportance(
app.adjSourceOom, null);
} else if (app.adjSource instanceof ActivityRecord) {
ActivityRecord r = (ActivityRecord)app.adjSource;
if (r.app != null) currApp.importanceReasonPid = r.app.pid;
@@ -7891,7 +7908,7 @@ public final class ActivityManagerService extends ActivityManagerNative
if (mLruProcesses.size() > 0) {
if (needSep) pw.println(" ");
needSep = true;
pw.println(" Process LRU list (most recent first):");
pw.println(" Process LRU list (sorted by oom_adj):");
dumpProcessOomList(pw, this, mLruProcesses, " ",
"Proc", "PERS", false);
needSep = true;
@@ -8069,29 +8086,6 @@ public final class ActivityManagerService extends ActivityManagerNative
boolean needSep = false;
if (mLruProcesses.size() > 0) {
ArrayList<ProcessRecord> procs = new ArrayList<ProcessRecord>(mLruProcesses);
Comparator<ProcessRecord> comparator = new Comparator<ProcessRecord>() {
@Override
public int compare(ProcessRecord object1, ProcessRecord object2) {
if (object1.setAdj != object2.setAdj) {
return object1.setAdj > object2.setAdj ? -1 : 1;
}
if (object1.setSchedGroup != object2.setSchedGroup) {
return object1.setSchedGroup > object2.setSchedGroup ? -1 : 1;
}
if (object1.keeping != object2.keeping) {
return object1.keeping ? -1 : 1;
}
if (object1.pid != object2.pid) {
return object1.pid > object2.pid ? -1 : 1;
}
return 0;
}
};
Collections.sort(procs, comparator);
if (needSep) pw.println(" ");
needSep = true;
pw.println(" OOM levels:");
@@ -8110,7 +8104,7 @@ public final class ActivityManagerService extends ActivityManagerNative
if (needSep) pw.println(" ");
needSep = true;
pw.println(" Process OOM control:");
dumpProcessOomList(pw, this, procs, " ",
dumpProcessOomList(pw, this, mLruProcesses, " ",
"Proc", "PERS", true);
needSep = true;
}
@@ -8859,10 +8853,33 @@ public final class ActivityManagerService extends ActivityManagerNative
}
private static final void dumpProcessOomList(PrintWriter pw,
ActivityManagerService service, List<ProcessRecord> list,
ActivityManagerService service, List<ProcessRecord> origList,
String prefix, String normalLabel, String persistentLabel,
boolean inclDetails) {
ArrayList<Pair<ProcessRecord, Integer>> list
= new ArrayList<Pair<ProcessRecord, Integer>>(origList.size());
for (int i=0; i<origList.size(); i++) {
list.add(new Pair<ProcessRecord, Integer>(origList.get(i), i));
}
Comparator<Pair<ProcessRecord, Integer>> comparator
= new Comparator<Pair<ProcessRecord, Integer>>() {
@Override
public int compare(Pair<ProcessRecord, Integer> object1,
Pair<ProcessRecord, Integer> object2) {
if (object1.first.setAdj != object2.first.setAdj) {
return object1.first.setAdj > object2.first.setAdj ? -1 : 1;
}
if (object1.second.intValue() != object2.second.intValue()) {
return object1.second.intValue() > object2.second.intValue() ? -1 : 1;
}
return 0;
}
};
Collections.sort(list, comparator);
final long curRealtime = SystemClock.elapsedRealtime();
final long realtimeSince = curRealtime - service.mLastPowerCheckRealtime;
final long curUptime = SystemClock.uptimeMillis();
@@ -8870,7 +8887,7 @@ public final class ActivityManagerService extends ActivityManagerNative
final int N = list.size()-1;
for (int i=N; i>=0; i--) {
ProcessRecord r = list.get(i);
ProcessRecord r = list.get(i).first;
String oomAdj;
if (r.setAdj >= ProcessList.EMPTY_APP_ADJ) {
oomAdj = buildOomTag("empty", null, r.setAdj, ProcessList.EMPTY_APP_ADJ);
@@ -8919,7 +8936,7 @@ public final class ActivityManagerService extends ActivityManagerNative
}
pw.println(String.format("%s%s #%2d: adj=%s/%s%s trm=%2d %s (%s)",
prefix, (r.persistent ? persistentLabel : normalLabel),
N-i, oomAdj, schedGroup, foreground, r.trimMemoryLevel,
N-list.get(i).second, oomAdj, schedGroup, foreground, r.trimMemoryLevel,
r.toShortString(), r.adjType));
if (r.adjSource != null || r.adjTarget != null) {
pw.print(prefix);
@@ -13118,6 +13135,7 @@ public final class ActivityManagerService extends ActivityManagerNative
app.adjTypeCode = ActivityManager.RunningAppProcessInfo
.REASON_SERVICE_IN_USE;
app.adjSource = cr.binding.client;
app.adjSourceOom = clientAdj;
app.adjTarget = s.name;
}
if ((cr.flags&Context.BIND_NOT_FOREGROUND) == 0) {
@@ -13140,6 +13158,7 @@ public final class ActivityManagerService extends ActivityManagerNative
app.adjTypeCode = ActivityManager.RunningAppProcessInfo
.REASON_SERVICE_IN_USE;
app.adjSource = a;
app.adjSourceOom = adj;
app.adjTarget = s.name;
}
}
@@ -13201,6 +13220,7 @@ public final class ActivityManagerService extends ActivityManagerNative
app.adjTypeCode = ActivityManager.RunningAppProcessInfo
.REASON_PROVIDER_IN_USE;
app.adjSource = client;
app.adjSourceOom = clientAdj;
app.adjTarget = cpr.name;
}
if (client.curSchedGroup == Process.THREAD_GROUP_DEFAULT) {
@@ -13511,16 +13531,21 @@ public final class ActivityManagerService extends ActivityManagerNative
computeOomAdjLocked(app, hiddenAdj, TOP_APP, false);
if (app.curRawAdj != app.setRawAdj) {
if (app.curRawAdj > ProcessList.FOREGROUND_APP_ADJ
&& app.setRawAdj <= ProcessList.FOREGROUND_APP_ADJ) {
// If this app is transitioning from foreground to
// non-foreground, have it do a gc.
scheduleAppGcLocked(app);
} else if (app.curRawAdj >= ProcessList.HIDDEN_APP_MIN_ADJ
&& app.setRawAdj < ProcessList.HIDDEN_APP_MIN_ADJ) {
// Likewise do a gc when an app is moving in to the
// background (such as a service stopping).
scheduleAppGcLocked(app);
if (false) {
// Removing for now. Forcing GCs is not so useful anymore
// with Dalvik, and the new memory level hint facility is
// better for what we need to do these days.
if (app.curRawAdj > ProcessList.FOREGROUND_APP_ADJ
&& app.setRawAdj <= ProcessList.FOREGROUND_APP_ADJ) {
// If this app is transitioning from foreground to
// non-foreground, have it do a gc.
scheduleAppGcLocked(app);
} else if (app.curRawAdj >= ProcessList.HIDDEN_APP_MIN_ADJ
&& app.setRawAdj < ProcessList.HIDDEN_APP_MIN_ADJ) {
// Likewise do a gc when an app is moving in to the
// background (such as a service stopping).
scheduleAppGcLocked(app);
}
}
if (wasKeeping && !app.keeping) {

View File

@@ -1151,6 +1151,7 @@ final class ActivityStack {
try {
mService.mWindowManager.setAppVisibility(r, true);
r.sleeping = false;
r.app.pendingUiClean = true;
r.app.thread.scheduleWindowVisibility(r, true);
r.stopFreezingScreenLocked(false);
} catch (Exception e) {
@@ -1497,6 +1498,7 @@ final class ActivityStack {
next.sleeping = false;
showAskCompatModeDialogLocked(next);
next.app.pendingUiClean = true;
next.app.thread.scheduleResumeActivity(next,
mService.isNextTransitionForward());

View File

@@ -99,6 +99,7 @@ class ProcessRecord {
String adjType; // Debugging: primary thing impacting oom_adj.
int adjTypeCode; // Debugging: adj code to report to app.
Object adjSource; // Debugging: option dependent object.
int adjSourceOom; // Debugging: oom_adj of adjSource's process.
Object adjTarget; // Debugging: target component impacting oom_adj.
// contains HistoryRecord objects

View File

@@ -5824,27 +5824,6 @@ public class WindowManagerService extends IWindowManager.Stub
config.compatScreenHeightDp = (int)(config.screenHeightDp / mCompatibleScreenScale);
config.compatSmallestScreenWidthDp = computeCompatSmallestWidth(rotated, dm, dw, dh);
// We need to determine the smallest width that will occur under normal
// operation. To this, start with the base screen size and compute the
// width under the different possible rotations. We need to un-rotate
// the current screen dimensions before doing this.
int unrotDw, unrotDh;
if (rotated) {
unrotDw = dh;
unrotDh = dw;
} else {
unrotDw = dw;
unrotDh = dh;
}
config.smallestScreenWidthDp = reduceConfigWidthSize(unrotDw,
Surface.ROTATION_0, dm.density, unrotDw);
config.smallestScreenWidthDp = reduceConfigWidthSize(config.smallestScreenWidthDp,
Surface.ROTATION_90, dm.density, unrotDh);
config.smallestScreenWidthDp = reduceConfigWidthSize(config.smallestScreenWidthDp,
Surface.ROTATION_180, dm.density, unrotDw);
config.smallestScreenWidthDp = reduceConfigWidthSize(config.smallestScreenWidthDp,
Surface.ROTATION_270, dm.density, unrotDh);
// Compute the screen layout size class.
int screenLayout;
int longSize = dw;