When launching ChooserActivity from lockscreen, we will start it
in stopped state because lockscreen is still showing, meaning that
the activity goes through start -> resume -> pause -> stop
immediately after it was launched, and will be later resumed once
Keyguard actually goes away.
However, ResolverActivity finished itself in onStop. We add a
private extra to change this behavior for sharing bugreports.
Test: Take bugreport, double tap on it on lockscreen
Test: com.android.shell.BugreportReceiverTest$1
Bug:
33009364
Change-Id: I973b2c71587950499b7c88b16af9cf1387795e17
public class ChooserActivity extends ResolverActivity {
private static final String TAG = "ChooserActivity";
+ /**
+ * Boolean extra to change the following behavior: Normally, ChooserActivity finishes itself
+ * in onStop when launched in a new task. If this extra is set to true, we do not finish
+ * ourselves when onStop gets called.
+ */
+ public static final String EXTRA_PRIVATE_RETAIN_IN_ON_STOP
+ = "com.android.internal.app.ChooserActivity.EXTRA_PRIVATE_RETAIN_IN_ON_STOP";
+
private static final boolean DEBUG = false;
private static final int QUERY_TARGET_SERVICE_LIMIT = 5;
}
mPinnedSharedPrefs = getPinnedSharedPrefs(this);
+ setRetainInOnStop(intent.getBooleanExtra(EXTRA_PRIVATE_RETAIN_IN_ON_STOP, false));
super.onCreate(savedInstanceState, target, title, defaultTitleRes, initialIntents,
null, false);
private Runnable mPostListReadyRunnable;
private boolean mRegistered;
+
+ /** See {@link #setRetainInOnStop}. */
+ private boolean mRetainInOnStop;
+
private final PackageMonitor mPackageMonitor = new PackageMonitor() {
@Override public void onSomePackagesChanged() {
mAdapter.handlePackagesChanged();
}
final Intent intent = getIntent();
if ((intent.getFlags() & FLAG_ACTIVITY_NEW_TASK) != 0 && !isVoiceInteraction()
- && !mResolvingHome) {
+ && !mResolvingHome && !mRetainInOnStop) {
// This resolver is in the unusual situation where it has been
// launched at the top of a new task. We don't let it be added
// to the recent tasks shown to the user, and we need to make sure
}
/**
+ * If {@code retainInOnStop} is set to true, we will not finish ourselves when onStop gets
+ * called and we are launched in a new task.
+ */
+ protected void setRetainInOnStop(boolean retainInOnStop) {
+ mRetainInOnStop = retainInOnStop;
+ }
+
+ /**
* Check a simple match for the component of two ResolveInfos.
*/
static boolean resolveInfoMatch(ResolveInfo lhs, ResolveInfo rhs) {
import libcore.io.Streams;
import com.android.internal.annotations.VisibleForTesting;
+import com.android.internal.app.ChooserActivity;
import com.android.internal.logging.MetricsLogger;
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
import com.android.internal.util.FastPrintWriter;
}
static void sendShareIntent(Context context, Intent intent) {
- context.startActivity(Intent.createChooser(intent,
- context.getResources().getText(R.string.bugreport_intent_chooser_title)));
+ final Intent chooserIntent = Intent.createChooser(intent,
+ context.getResources().getText(R.string.bugreport_intent_chooser_title));
+
+ // Since we may be launched behind lockscreen, make sure that ChooserActivity doesn't finish
+ // itself in onStop.
+ chooserIntent.putExtra(ChooserActivity.EXTRA_PRIVATE_RETAIN_IN_ON_STOP, true);
+ context.startActivity(chooserIntent);
}
/**