Merge "Add hidden API startActivityForResultAsUser" into oc-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
bb14fb9acb
@@ -4521,12 +4521,20 @@ public class Activity extends ContextThemeWrapper
|
||||
*/
|
||||
public void startActivityForResultAsUser(Intent intent, int requestCode,
|
||||
@Nullable Bundle options, UserHandle user) {
|
||||
startActivityForResultAsUser(intent, mEmbeddedID, requestCode, options, user);
|
||||
}
|
||||
|
||||
/**
|
||||
* @hide Implement to provide correct calling token.
|
||||
*/
|
||||
public void startActivityForResultAsUser(Intent intent, String resultWho, int requestCode,
|
||||
@Nullable Bundle options, UserHandle user) {
|
||||
if (mParent != null) {
|
||||
throw new RuntimeException("Can't be called from a child");
|
||||
}
|
||||
options = transferSpringboardActivityOptions(options);
|
||||
Instrumentation.ActivityResult ar = mInstrumentation.execStartActivity(
|
||||
this, mMainThread.getApplicationThread(), mToken, this, intent, requestCode,
|
||||
this, mMainThread.getApplicationThread(), mToken, resultWho, intent, requestCode,
|
||||
options, user);
|
||||
if (ar != null) {
|
||||
mMainThread.sendActivityResult(
|
||||
@@ -4563,7 +4571,7 @@ public class Activity extends ContextThemeWrapper
|
||||
options = transferSpringboardActivityOptions(options);
|
||||
Instrumentation.ActivityResult ar =
|
||||
mInstrumentation.execStartActivity(
|
||||
this, mMainThread.getApplicationThread(), mToken, this,
|
||||
this, mMainThread.getApplicationThread(), mToken, mEmbeddedID,
|
||||
intent, -1, options, user);
|
||||
if (ar != null) {
|
||||
mMainThread.sendActivityResult(
|
||||
@@ -5089,6 +5097,15 @@ public class Activity extends ContextThemeWrapper
|
||||
startActivityForResult(fragment.mWho, intent, requestCode, options);
|
||||
}
|
||||
|
||||
/**
|
||||
* @hide
|
||||
*/
|
||||
public void startActivityAsUserFromFragment(@NonNull Fragment fragment,
|
||||
@RequiresPermission Intent intent, int requestCode, @Nullable Bundle options,
|
||||
UserHandle user) {
|
||||
startActivityForResultAsUser(intent, fragment.mWho, requestCode, options, user);
|
||||
}
|
||||
|
||||
/**
|
||||
* @hide
|
||||
*/
|
||||
@@ -7462,6 +7479,14 @@ public class Activity extends ContextThemeWrapper
|
||||
Activity.this.startActivityFromFragment(fragment, intent, requestCode, options);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStartActivityAsUserFromFragment(
|
||||
Fragment fragment, Intent intent, int requestCode, Bundle options,
|
||||
UserHandle user) {
|
||||
Activity.this.startActivityAsUserFromFragment(
|
||||
fragment, intent, requestCode, options, user);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStartIntentSenderFromFragment(Fragment fragment, IntentSender intent,
|
||||
int requestCode, @Nullable Intent fillInIntent, int flagsMask, int flagsValues,
|
||||
|
||||
@@ -34,6 +34,7 @@ import android.os.Bundle;
|
||||
import android.os.Looper;
|
||||
import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
import android.os.UserHandle;
|
||||
import android.transition.Transition;
|
||||
import android.transition.TransitionInflater;
|
||||
import android.transition.TransitionSet;
|
||||
@@ -1187,6 +1188,19 @@ public class Fragment implements ComponentCallbacks2, OnCreateContextMenuListene
|
||||
mHost.onStartActivityFromFragment(this, intent, requestCode, options);
|
||||
}
|
||||
|
||||
/**
|
||||
* @hide
|
||||
* Call {@link Activity#startActivityForResultAsUser(Intent, int, UserHandle)} from the
|
||||
* fragment's containing Activity.
|
||||
*/
|
||||
public void startActivityForResultAsUser(
|
||||
Intent intent, int requestCode, Bundle options, UserHandle user) {
|
||||
if (mHost == null) {
|
||||
throw new IllegalStateException("Fragment " + this + " not attached to Activity");
|
||||
}
|
||||
mHost.onStartActivityAsUserFromFragment(this, intent, requestCode, options, user);
|
||||
}
|
||||
|
||||
/**
|
||||
* Call {@link Activity#startIntentSenderForResult(IntentSender, int, Intent, int, int, int,
|
||||
* Bundle)} from the fragment's containing Activity.
|
||||
|
||||
@@ -23,6 +23,7 @@ import android.content.Intent;
|
||||
import android.content.IntentSender;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.UserHandle;
|
||||
import android.util.ArrayMap;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
@@ -145,6 +146,20 @@ public abstract class FragmentHostCallback<E> extends FragmentContainer {
|
||||
mContext.startActivity(intent);
|
||||
}
|
||||
|
||||
/**
|
||||
* @hide
|
||||
* Starts a new {@link Activity} from the given fragment.
|
||||
* See {@link Activity#startActivityForResult(Intent, int)}.
|
||||
*/
|
||||
public void onStartActivityAsUserFromFragment(Fragment fragment, Intent intent, int requestCode,
|
||||
Bundle options, UserHandle userHandle) {
|
||||
if (requestCode != -1) {
|
||||
throw new IllegalStateException(
|
||||
"Starting activity with a requestCode requires a FragmentActivity host");
|
||||
}
|
||||
mContext.startActivityAsUser(intent, userHandle);
|
||||
}
|
||||
|
||||
/**
|
||||
* Starts a new {@link IntentSender} from the given fragment.
|
||||
* See {@link Activity#startIntentSender(IntentSender, Intent, int, int, int, Bundle)}.
|
||||
|
||||
@@ -1779,7 +1779,7 @@ public class Instrumentation {
|
||||
* {@hide}
|
||||
*/
|
||||
public ActivityResult execStartActivity(
|
||||
Context who, IBinder contextThread, IBinder token, Activity target,
|
||||
Context who, IBinder contextThread, IBinder token, String resultWho,
|
||||
Intent intent, int requestCode, Bundle options, UserHandle user) {
|
||||
IApplicationThread whoThread = (IApplicationThread) contextThread;
|
||||
if (mActivityMonitors != null) {
|
||||
@@ -1810,7 +1810,7 @@ public class Instrumentation {
|
||||
int result = ActivityManager.getService()
|
||||
.startActivityAsUser(whoThread, who.getBasePackageName(), intent,
|
||||
intent.resolveTypeIfNeeded(who.getContentResolver()),
|
||||
token, target != null ? target.mEmbeddedID : null,
|
||||
token, resultWho,
|
||||
requestCode, 0, null, options, user.getIdentifier());
|
||||
checkStartActivityResult(result, intent);
|
||||
} catch (RemoteException e) {
|
||||
|
||||
Reference in New Issue
Block a user