Merge "Don't require post-execution state for onActivityResult" into pi-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
5007c67a70
@@ -759,6 +759,7 @@ public class Activity extends ContextThemeWrapper
|
||||
private static final int LOG_AM_ON_STOP_CALLED = 30049;
|
||||
private static final int LOG_AM_ON_RESTART_CALLED = 30058;
|
||||
private static final int LOG_AM_ON_DESTROY_CALLED = 30060;
|
||||
private static final int LOG_AM_ON_ACTIVITY_RESULT_CALLED = 30062;
|
||||
|
||||
private static class ManagedDialog {
|
||||
Dialog mDialog;
|
||||
@@ -7438,8 +7439,8 @@ public class Activity extends ContextThemeWrapper
|
||||
}
|
||||
}
|
||||
|
||||
void dispatchActivityResult(String who, int requestCode,
|
||||
int resultCode, Intent data) {
|
||||
void dispatchActivityResult(String who, int requestCode, int resultCode, Intent data,
|
||||
String reason) {
|
||||
if (false) Log.v(
|
||||
TAG, "Dispatching result: who=" + who + ", reqCode=" + requestCode
|
||||
+ ", resCode=" + resultCode + ", data=" + data);
|
||||
@@ -7475,6 +7476,7 @@ public class Activity extends ContextThemeWrapper
|
||||
frag.onActivityResult(requestCode, resultCode, data);
|
||||
}
|
||||
}
|
||||
writeEventLog(LOG_AM_ON_ACTIVITY_RESULT_CALLED, reason);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -16,11 +16,11 @@
|
||||
|
||||
package android.app;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
/**
|
||||
* A screen that contains and runs multiple embedded activities.
|
||||
*
|
||||
@@ -109,7 +109,7 @@ public class ActivityGroup extends Activity {
|
||||
|
||||
@Override
|
||||
void dispatchActivityResult(String who, int requestCode, int resultCode,
|
||||
Intent data) {
|
||||
Intent data, String reason) {
|
||||
if (who != null) {
|
||||
Activity act = mLocalActivityManager.getActivity(who);
|
||||
/*
|
||||
@@ -123,7 +123,7 @@ public class ActivityGroup extends Activity {
|
||||
return;
|
||||
}
|
||||
}
|
||||
super.dispatchActivityResult(who, requestCode, resultCode, data);
|
||||
super.dispatchActivityResult(who, requestCode, resultCode, data, reason);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -3730,7 +3730,7 @@ public final class ActivityThread extends ClientTransactionHandler {
|
||||
r.pendingIntents = null;
|
||||
}
|
||||
if (r.pendingResults != null) {
|
||||
deliverResults(r, r.pendingResults);
|
||||
deliverResults(r, r.pendingResults, reason);
|
||||
r.pendingResults = null;
|
||||
}
|
||||
r.activity.performResume(r.startsNotResumed, reason);
|
||||
@@ -4299,7 +4299,7 @@ public final class ActivityThread extends ClientTransactionHandler {
|
||||
WindowManagerGlobal.getInstance().reportNewConfiguration(mConfiguration);
|
||||
}
|
||||
|
||||
private void deliverResults(ActivityClientRecord r, List<ResultInfo> results) {
|
||||
private void deliverResults(ActivityClientRecord r, List<ResultInfo> results, String reason) {
|
||||
final int N = results.size();
|
||||
for (int i=0; i<N; i++) {
|
||||
ResultInfo ri = results.get(i);
|
||||
@@ -4311,7 +4311,7 @@ public final class ActivityThread extends ClientTransactionHandler {
|
||||
if (DEBUG_RESULTS) Slog.v(TAG,
|
||||
"Delivering result to activity " + r + " : " + ri);
|
||||
r.activity.dispatchActivityResult(ri.mResultWho,
|
||||
ri.mRequestCode, ri.mResultCode, ri.mData);
|
||||
ri.mRequestCode, ri.mResultCode, ri.mData, reason);
|
||||
} catch (Exception e) {
|
||||
if (!mInstrumentation.onException(r.activity, e)) {
|
||||
throw new RuntimeException(
|
||||
@@ -4324,7 +4324,7 @@ public final class ActivityThread extends ClientTransactionHandler {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleSendResult(IBinder token, List<ResultInfo> results) {
|
||||
public void handleSendResult(IBinder token, List<ResultInfo> results, String reason) {
|
||||
ActivityClientRecord r = mActivities.get(token);
|
||||
if (DEBUG_RESULTS) Slog.v(TAG, "Handling send result to " + r);
|
||||
if (r != null) {
|
||||
@@ -4359,9 +4359,9 @@ public final class ActivityThread extends ClientTransactionHandler {
|
||||
}
|
||||
}
|
||||
checkAndBlockForNetworkAccess();
|
||||
deliverResults(r, results);
|
||||
deliverResults(r, results, reason);
|
||||
if (resumed) {
|
||||
r.activity.performResume(false, "handleSendResult");
|
||||
r.activity.performResume(false, reason);
|
||||
r.activity.mTemporaryPause = false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -121,7 +121,7 @@ public abstract class ClientTransactionHandler {
|
||||
Configuration overrideConfig, int displayId);
|
||||
|
||||
/** Deliver result from another activity. */
|
||||
public abstract void handleSendResult(IBinder token, List<ResultInfo> results);
|
||||
public abstract void handleSendResult(IBinder token, List<ResultInfo> results, String reason);
|
||||
|
||||
/** Deliver multi-window mode change notification. */
|
||||
public abstract void handleMultiWindowModeChanged(IBinder token, boolean isInMultiWindowMode,
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
|
||||
package android.app.servertransaction;
|
||||
|
||||
import static android.app.servertransaction.ActivityLifecycleItem.ON_RESUME;
|
||||
import static android.os.Trace.TRACE_TAG_ACTIVITY_MANAGER;
|
||||
|
||||
import android.app.ClientTransactionHandler;
|
||||
@@ -37,16 +36,17 @@ public class ActivityResultItem extends ClientTransactionItem {
|
||||
|
||||
private List<ResultInfo> mResultInfoList;
|
||||
|
||||
/* TODO(b/78294732)
|
||||
@Override
|
||||
public int getPostExecutionState() {
|
||||
return ON_RESUME;
|
||||
}
|
||||
}*/
|
||||
|
||||
@Override
|
||||
public void execute(ClientTransactionHandler client, IBinder token,
|
||||
PendingTransactionActions pendingActions) {
|
||||
Trace.traceBegin(TRACE_TAG_ACTIVITY_MANAGER, "activityDeliverResult");
|
||||
client.handleSendResult(token, mResultInfoList);
|
||||
client.handleSendResult(token, mResultInfoList, "ACTIVITY_RESULT");
|
||||
Trace.traceEnd(TRACE_TAG_ACTIVITY_MANAGER);
|
||||
}
|
||||
|
||||
|
||||
@@ -40,7 +40,10 @@ import static org.mockito.Mockito.when;
|
||||
|
||||
import android.app.ActivityThread.ActivityClientRecord;
|
||||
import android.app.ClientTransactionHandler;
|
||||
import android.app.servertransaction.ActivityLifecycleItem.LifecycleState;
|
||||
import android.os.IBinder;
|
||||
import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
import android.platform.test.annotations.Presubmit;
|
||||
import android.support.test.filters.SmallTest;
|
||||
import android.support.test.runner.AndroidJUnit4;
|
||||
@@ -50,7 +53,6 @@ import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.InOrder;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
@@ -231,12 +233,12 @@ public class TransactionExecutorTests {
|
||||
|
||||
@Test
|
||||
public void testActivityResultRequiredStateResolution() {
|
||||
ActivityResultItem activityResultItem = ActivityResultItem.obtain(new ArrayList<>());
|
||||
PostExecItem postExecItem = new PostExecItem(ON_RESUME);
|
||||
|
||||
IBinder token = mock(IBinder.class);
|
||||
ClientTransaction transaction = ClientTransaction.obtain(null /* client */,
|
||||
token /* activityToken */);
|
||||
transaction.addCallback(activityResultItem);
|
||||
transaction.addCallback(postExecItem);
|
||||
|
||||
// Verify resolution that should get to onPause
|
||||
mClientRecord.setState(ON_RESUME);
|
||||
@@ -395,4 +397,54 @@ public class TransactionExecutorTests {
|
||||
return mExecutorHelper.getLifecyclePath(mClientRecord.getLifecycleState(), finish,
|
||||
true /* excludeLastState */).toArray();
|
||||
}
|
||||
|
||||
/** A transaction item that requires some specific post-execution state. */
|
||||
private static class PostExecItem extends StubItem {
|
||||
|
||||
@LifecycleState
|
||||
private int mPostExecutionState;
|
||||
|
||||
PostExecItem(@LifecycleState int state) {
|
||||
mPostExecutionState = state;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPostExecutionState() {
|
||||
return mPostExecutionState;
|
||||
}
|
||||
}
|
||||
|
||||
/** Stub implementation of a transaction item that works as a base class for items in tests. */
|
||||
private static class StubItem extends ClientTransactionItem {
|
||||
|
||||
private StubItem() {
|
||||
}
|
||||
|
||||
private StubItem(Parcel in) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(ClientTransactionHandler client, IBinder token,
|
||||
PendingTransactionActions pendingActions) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void recycle() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToParcel(Parcel dest, int flags) {
|
||||
}
|
||||
|
||||
public static final Parcelable.Creator<StubItem> CREATOR =
|
||||
new Parcelable.Creator<StubItem>() {
|
||||
public StubItem createFromParcel(Parcel in) {
|
||||
return new StubItem(in);
|
||||
}
|
||||
|
||||
public StubItem[] newArray(int size) {
|
||||
return new StubItem[size];
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -134,6 +134,8 @@ option java_package com.android.server.am
|
||||
30059 am_on_start_called (User|1|5),(Component Name|3),(Reason|3)
|
||||
# The activity's onDestroy has been called.
|
||||
30060 am_on_destroy_called (User|1|5),(Component Name|3),(Reason|3)
|
||||
# The activity's onActivityResult has been called.
|
||||
30062 am_on_activity_result_called (User|1|5),(Component Name|3),(Reason|3)
|
||||
|
||||
# The task is being removed from its parent stack
|
||||
30061 am_remove_task (Task ID|1|5), (Stack ID|1|5)
|
||||
Reference in New Issue
Block a user