Use new doccentric flags and attributes in Sharing
Put the new doccentric flags and attributes into use. And make their first application the Share widget. Sharing now creates a new task which is destroyed once the share action has completed. Fixes bug 14463859. Change-Id: I34c4c79775ef44d65e1967be5601997a2d46b210
This commit is contained in:
@@ -276,6 +276,8 @@ public class ShareActionProvider extends ActionProvider {
|
||||
* @see Intent#ACTION_SEND_MULTIPLE
|
||||
*/
|
||||
public void setShareIntent(Intent shareIntent) {
|
||||
shareIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_DOCUMENT |
|
||||
Intent.FLAG_ACTIVITY_AUTO_REMOVE_FROM_RECENTS);
|
||||
ActivityChooserModel dataModel = ActivityChooserModel.get(mContext,
|
||||
mShareHistoryFileName);
|
||||
dataModel.setIntent(shareIntent);
|
||||
@@ -292,7 +294,8 @@ public class ShareActionProvider extends ActionProvider {
|
||||
final int itemId = item.getItemId();
|
||||
Intent launchIntent = dataModel.chooseActivity(itemId);
|
||||
if (launchIntent != null) {
|
||||
launchIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
|
||||
launchIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_DOCUMENT |
|
||||
Intent.FLAG_ACTIVITY_AUTO_REMOVE_FROM_RECENTS);
|
||||
mContext.startActivity(launchIntent);
|
||||
}
|
||||
return true;
|
||||
@@ -308,7 +311,7 @@ public class ShareActionProvider extends ActionProvider {
|
||||
return;
|
||||
}
|
||||
if (mOnChooseActivityListener == null) {
|
||||
mOnChooseActivityListener = new ShareAcitivityChooserModelPolicy();
|
||||
mOnChooseActivityListener = new ShareActivityChooserModelPolicy();
|
||||
}
|
||||
ActivityChooserModel dataModel = ActivityChooserModel.get(mContext, mShareHistoryFileName);
|
||||
dataModel.setOnChooseActivityListener(mOnChooseActivityListener);
|
||||
@@ -317,7 +320,7 @@ public class ShareActionProvider extends ActionProvider {
|
||||
/**
|
||||
* Policy that delegates to the {@link OnShareTargetSelectedListener}, if such.
|
||||
*/
|
||||
private class ShareAcitivityChooserModelPolicy implements OnChooseActivityListener {
|
||||
private class ShareActivityChooserModelPolicy implements OnChooseActivityListener {
|
||||
@Override
|
||||
public boolean onChooseActivity(ActivityChooserModel host, Intent intent) {
|
||||
if (mOnShareTargetSelectedListener != null) {
|
||||
|
||||
@@ -17,7 +17,6 @@
|
||||
package com.android.server.am;
|
||||
|
||||
import android.os.Trace;
|
||||
import com.android.internal.R.styleable;
|
||||
import com.android.internal.app.ResolverActivity;
|
||||
import com.android.server.AttributeCache;
|
||||
import com.android.server.am.ActivityStack.ActivityState;
|
||||
@@ -480,7 +479,7 @@ final class ActivityRecord {
|
||||
void setTask(TaskRecord newTask, ThumbnailHolder newThumbHolder, boolean isRoot) {
|
||||
if (task != null && task.removeActivity(this)) {
|
||||
if (task != newTask) {
|
||||
task.stack.removeTask(task, false);
|
||||
task.stack.removeTask(task);
|
||||
} else {
|
||||
Slog.d(TAG, "!!! REMOVE THIS LOG !!! setTask: nearly removed stack=" +
|
||||
(newTask == null ? null : newTask.stack));
|
||||
|
||||
@@ -36,8 +36,6 @@ import static com.android.server.am.ActivityStackSupervisor.DEBUG_SAVED_STATE;
|
||||
import static com.android.server.am.ActivityStackSupervisor.DEBUG_STATES;
|
||||
import static com.android.server.am.ActivityStackSupervisor.HOME_STACK_ID;
|
||||
|
||||
import static com.android.server.am.ActivityStackSupervisor.ActivityContainer.CONTAINER_STATE_HAS_SURFACE;
|
||||
|
||||
import android.service.voice.IVoiceInteractionSession;
|
||||
import com.android.internal.app.IVoiceInteractor;
|
||||
import com.android.internal.os.BatteryStatsImpl;
|
||||
@@ -2841,7 +2839,7 @@ final class ActivityStack {
|
||||
if (mStackSupervisor.isFrontStack(this) && task == topTask() && task.mOnTopOfHome) {
|
||||
mStackSupervisor.moveHomeToTop();
|
||||
}
|
||||
removeTask(task, false);
|
||||
removeTask(task);
|
||||
}
|
||||
cleanUpActivityServicesLocked(r);
|
||||
r.removeUriPermissionsLocked();
|
||||
@@ -3717,7 +3715,7 @@ final class ActivityStack {
|
||||
return starting;
|
||||
}
|
||||
|
||||
void removeTask(TaskRecord task, boolean moving) {
|
||||
void removeTask(TaskRecord task) {
|
||||
mStackSupervisor.endLockTaskModeIfTaskEnding(task);
|
||||
mWindowManager.removeTask(task.taskId);
|
||||
final ActivityRecord r = mResumedActivity;
|
||||
@@ -3731,14 +3729,20 @@ final class ActivityStack {
|
||||
mTaskHistory.get(taskNdx + 1).mOnTopOfHome = true;
|
||||
}
|
||||
mTaskHistory.remove(task);
|
||||
if (!moving && task.voiceSession != null) {
|
||||
// This task was a voice interaction, so it should not remain on the
|
||||
// recent tasks list.
|
||||
try {
|
||||
task.voiceSession.taskFinished(task.intent, task.taskId);
|
||||
} catch (RemoteException e) {
|
||||
|
||||
if (task.mActivities.isEmpty()) {
|
||||
final boolean isVoiceSession = task.voiceSession != null;
|
||||
if (isVoiceSession) {
|
||||
try {
|
||||
task.voiceSession.taskFinished(task.intent, task.taskId);
|
||||
} catch (RemoteException e) {
|
||||
}
|
||||
}
|
||||
if (task.autoRemoveFromRecents() || isVoiceSession) {
|
||||
// Task creator asked to remove this when done, or this task was a voice
|
||||
// interaction, so it should not remain on the recent tasks list.
|
||||
mService.mRecentTasks.remove(task);
|
||||
}
|
||||
mService.mRecentTasks.remove(task);
|
||||
}
|
||||
|
||||
if (mTaskHistory.isEmpty()) {
|
||||
|
||||
@@ -1471,6 +1471,17 @@ public final class ActivityStackSupervisor implements DisplayListener {
|
||||
}
|
||||
}
|
||||
|
||||
switch (r.info.documentLaunchMode) {
|
||||
case ActivityInfo.DOCUMENT_LAUNCH_NONE:
|
||||
break;
|
||||
case ActivityInfo.DOCUMENT_LAUNCH_ALWAYS:
|
||||
intent.addFlags(
|
||||
Intent.FLAG_ACTIVITY_NEW_DOCUMENT | Intent.FLAG_ACTIVITY_MULTIPLE_TASK);
|
||||
break;
|
||||
case ActivityInfo.DOCUMENT_LAUNCH_INTO_EXISTING:
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_DOCUMENT);
|
||||
break;
|
||||
}
|
||||
final boolean newDocument = intent.isDocument();
|
||||
if (sourceRecord == null) {
|
||||
// This activity is not being started from another... in this
|
||||
@@ -2237,7 +2248,7 @@ public final class ActivityStackSupervisor implements DisplayListener {
|
||||
Slog.w(TAG, "moveTaskToStack: no stack for id=" + stackId);
|
||||
return;
|
||||
}
|
||||
task.stack.removeTask(task, true);
|
||||
task.stack.removeTask(task);
|
||||
stack.addTask(task, toTop, true);
|
||||
mWindowManager.addTask(taskId, stackId, toTop);
|
||||
resumeTopActivitiesLocked();
|
||||
|
||||
@@ -139,6 +139,9 @@ final class TaskRecord extends ThumbnailHolder {
|
||||
|
||||
userId = UserHandle.getUserId(info.applicationInfo.uid);
|
||||
creatorUid = info.applicationInfo.uid;
|
||||
if ((info.flags & ActivityInfo.FLAG_AUTO_REMOVE_FROM_RECENTS) != 0) {
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_AUTO_REMOVE_FROM_RECENTS);
|
||||
}
|
||||
}
|
||||
|
||||
void disposeThumbnail() {
|
||||
@@ -246,6 +249,11 @@ final class TaskRecord extends ThumbnailHolder {
|
||||
return mActivities.size() == 0;
|
||||
}
|
||||
|
||||
boolean autoRemoveFromRecents() {
|
||||
return intent != null &&
|
||||
(intent.getFlags() & Intent.FLAG_ACTIVITY_AUTO_REMOVE_FROM_RECENTS) != 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Completely remove all activities associated with an existing
|
||||
* task starting at a specified index.
|
||||
|
||||
Reference in New Issue
Block a user