Merge "Launch home activity in home stack if coming from ResolverActivity" into nyc-dev

This commit is contained in:
TreeHugger Robot
2016-05-02 16:21:40 +00:00
committed by Android (Google) Code Review
2 changed files with 34 additions and 18 deletions

View File

@@ -592,7 +592,7 @@ final class ActivityRecord {
ActivityRecord _resultTo, String _resultWho, int _reqCode, ActivityRecord _resultTo, String _resultWho, int _reqCode,
boolean _componentSpecified, boolean _rootVoiceInteraction, boolean _componentSpecified, boolean _rootVoiceInteraction,
ActivityStackSupervisor supervisor, ActivityStackSupervisor supervisor,
ActivityContainer container, ActivityOptions options) { ActivityContainer container, ActivityOptions options, ActivityRecord sourceRecord) {
service = _service; service = _service;
appToken = new Token(this, service); appToken = new Token(this, service);
info = aInfo; info = aInfo;
@@ -705,21 +705,7 @@ final class ActivityRecord {
noDisplay = ent != null && ent.array.getBoolean( noDisplay = ent != null && ent.array.getBoolean(
com.android.internal.R.styleable.Window_windowNoDisplay, false); com.android.internal.R.styleable.Window_windowNoDisplay, false);
if ((!_componentSpecified || _launchedFromUid == Process.myUid() setActivityType(_componentSpecified, _launchedFromUid, _intent, sourceRecord);
|| _launchedFromUid == 0) &&
Intent.ACTION_MAIN.equals(_intent.getAction()) &&
_intent.hasCategory(Intent.CATEGORY_HOME) &&
_intent.getCategories().size() == 1 &&
_intent.getData() == null &&
_intent.getType() == null &&
!isResolverActivity()) {
// This sure looks like a home activity!
mActivityType = HOME_ACTIVITY_TYPE;
} else if (realActivity.getClassName().contains(RECENTS_PACKAGE_NAME)) {
mActivityType = RECENTS_ACTIVITY_TYPE;
} else {
mActivityType = APPLICATION_ACTIVITY_TYPE;
}
immersive = (aInfo.flags & ActivityInfo.FLAG_IMMERSIVE) != 0; immersive = (aInfo.flags & ActivityInfo.FLAG_IMMERSIVE) != 0;
@@ -740,6 +726,36 @@ final class ActivityRecord {
} }
} }
private boolean isHomeIntent(Intent intent) {
return Intent.ACTION_MAIN.equals(intent.getAction())
&& intent.hasCategory(Intent.CATEGORY_HOME)
&& intent.getCategories().size() == 1
&& intent.getData() == null
&& intent.getType() == null;
}
private boolean canLaunchHomeActivity(int uid, ActivityRecord sourceRecord) {
if (uid == Process.myUid() || uid == 0) {
// System process can launch home activity.
return true;
}
// Resolver activity can launch home activity.
return sourceRecord != null && sourceRecord.isResolverActivity();
}
private void setActivityType(boolean componentSpecified,
int launchedFromUid, Intent intent, ActivityRecord sourceRecord) {
if ((!componentSpecified || canLaunchHomeActivity(launchedFromUid, sourceRecord))
&& isHomeIntent(intent) && !isResolverActivity()) {
// This sure looks like a home activity!
mActivityType = HOME_ACTIVITY_TYPE;
} else if (realActivity.getClassName().contains(RECENTS_PACKAGE_NAME)) {
mActivityType = RECENTS_ACTIVITY_TYPE;
} else {
mActivityType = APPLICATION_ACTIVITY_TYPE;
}
}
void setTask(TaskRecord newTask, TaskRecord taskToAffiliateWith) { void setTask(TaskRecord newTask, TaskRecord taskToAffiliateWith) {
if (task != null && task.removeActivity(this) && task != newTask && task.stack != null) { if (task != null && task.removeActivity(this) && task != newTask && task.stack != null) {
task.stack.removeTask(task, "setTask"); task.stack.removeTask(task, "setTask");
@@ -1473,7 +1489,7 @@ final class ActivityRecord {
} }
final ActivityRecord r = new ActivityRecord(service, /*caller*/null, launchedFromUid, final ActivityRecord r = new ActivityRecord(service, /*caller*/null, launchedFromUid,
launchedFromPackage, intent, resolvedType, aInfo, service.getConfiguration(), launchedFromPackage, intent, resolvedType, aInfo, service.getConfiguration(),
null, null, 0, componentSpecified, false, stackSupervisor, null, null); null, null, 0, componentSpecified, false, stackSupervisor, null, null, null);
r.persistentState = persistentState; r.persistentState = persistentState;
r.taskDescription = taskDescription; r.taskDescription = taskDescription;

View File

@@ -492,7 +492,7 @@ class ActivityStarter {
ActivityRecord r = new ActivityRecord(mService, callerApp, callingUid, callingPackage, ActivityRecord r = new ActivityRecord(mService, callerApp, callingUid, callingPackage,
intent, resolvedType, aInfo, mService.mConfiguration, resultRecord, resultWho, intent, resolvedType, aInfo, mService.mConfiguration, resultRecord, resultWho,
requestCode, componentSpecified, voiceSession != null, mSupervisor, container, requestCode, componentSpecified, voiceSession != null, mSupervisor, container,
options); options, sourceRecord);
if (outActivity != null) { if (outActivity != null) {
outActivity[0] = r; outActivity[0] = r;
} }