Merge "Support apps sharing file:// URIs with the camera API" into rvc-dev am: efbc3f2d5e am: d371efcfb2
Original change: undetermined Change-Id: Ie50c75f157b29fd2376faa2cc9510b64b3a57432
This commit is contained in:
@@ -5568,7 +5568,7 @@ public class Activity extends ContextThemeWrapper
|
||||
options = transferSpringboardActivityOptions(options);
|
||||
String resolvedType = null;
|
||||
if (fillInIntent != null) {
|
||||
fillInIntent.migrateExtraStreamToClipData();
|
||||
fillInIntent.migrateExtraStreamToClipData(this);
|
||||
fillInIntent.prepareToLeaveProcess(this);
|
||||
resolvedType = fillInIntent.resolveTypeIfNeeded(getContentResolver());
|
||||
}
|
||||
@@ -5823,7 +5823,7 @@ public class Activity extends ContextThemeWrapper
|
||||
if (referrer != null) {
|
||||
intent.putExtra(Intent.EXTRA_REFERRER, referrer);
|
||||
}
|
||||
intent.migrateExtraStreamToClipData();
|
||||
intent.migrateExtraStreamToClipData(this);
|
||||
intent.prepareToLeaveProcess(this);
|
||||
result = ActivityTaskManager.getService()
|
||||
.startActivity(mMainThread.getApplicationThread(), getBasePackageName(),
|
||||
@@ -5894,7 +5894,7 @@ public class Activity extends ContextThemeWrapper
|
||||
@Nullable Bundle options) {
|
||||
if (mParent == null) {
|
||||
try {
|
||||
intent.migrateExtraStreamToClipData();
|
||||
intent.migrateExtraStreamToClipData(this);
|
||||
intent.prepareToLeaveProcess(this);
|
||||
return ActivityTaskManager.getService()
|
||||
.startNextMatchingActivity(mToken, intent, options);
|
||||
|
||||
@@ -1087,7 +1087,7 @@ class ContextImpl extends Context {
|
||||
try {
|
||||
String resolvedType = null;
|
||||
if (fillInIntent != null) {
|
||||
fillInIntent.migrateExtraStreamToClipData();
|
||||
fillInIntent.migrateExtraStreamToClipData(this);
|
||||
fillInIntent.prepareToLeaveProcess(this);
|
||||
resolvedType = fillInIntent.resolveTypeIfNeeded(getContentResolver());
|
||||
}
|
||||
|
||||
@@ -1718,7 +1718,7 @@ public class Instrumentation {
|
||||
}
|
||||
}
|
||||
try {
|
||||
intent.migrateExtraStreamToClipData();
|
||||
intent.migrateExtraStreamToClipData(who);
|
||||
intent.prepareToLeaveProcess(who);
|
||||
int result = ActivityTaskManager.getService().startActivity(whoThread,
|
||||
who.getBasePackageName(), who.getAttributionTag(), intent,
|
||||
@@ -1788,7 +1788,7 @@ public class Instrumentation {
|
||||
try {
|
||||
String[] resolvedTypes = new String[intents.length];
|
||||
for (int i=0; i<intents.length; i++) {
|
||||
intents[i].migrateExtraStreamToClipData();
|
||||
intents[i].migrateExtraStreamToClipData(who);
|
||||
intents[i].prepareToLeaveProcess(who);
|
||||
resolvedTypes[i] = intents[i].resolveTypeIfNeeded(who.getContentResolver());
|
||||
}
|
||||
@@ -1857,7 +1857,7 @@ public class Instrumentation {
|
||||
}
|
||||
}
|
||||
try {
|
||||
intent.migrateExtraStreamToClipData();
|
||||
intent.migrateExtraStreamToClipData(who);
|
||||
intent.prepareToLeaveProcess(who);
|
||||
int result = ActivityTaskManager.getService().startActivity(whoThread,
|
||||
who.getBasePackageName(), who.getAttributionTag(), intent,
|
||||
@@ -1924,7 +1924,7 @@ public class Instrumentation {
|
||||
}
|
||||
}
|
||||
try {
|
||||
intent.migrateExtraStreamToClipData();
|
||||
intent.migrateExtraStreamToClipData(who);
|
||||
intent.prepareToLeaveProcess(who);
|
||||
int result = ActivityTaskManager.getService().startActivityAsUser(whoThread,
|
||||
who.getBasePackageName(), who.getAttributionTag(), intent,
|
||||
@@ -1970,7 +1970,7 @@ public class Instrumentation {
|
||||
}
|
||||
}
|
||||
try {
|
||||
intent.migrateExtraStreamToClipData();
|
||||
intent.migrateExtraStreamToClipData(who);
|
||||
intent.prepareToLeaveProcess(who);
|
||||
int result = ActivityTaskManager.getService()
|
||||
.startActivityAsCaller(whoThread, who.getBasePackageName(), intent,
|
||||
@@ -2017,7 +2017,7 @@ public class Instrumentation {
|
||||
}
|
||||
}
|
||||
try {
|
||||
intent.migrateExtraStreamToClipData();
|
||||
intent.migrateExtraStreamToClipData(who);
|
||||
intent.prepareToLeaveProcess(who);
|
||||
int result = appTask.startActivity(whoThread.asBinder(), who.getBasePackageName(),
|
||||
who.getAttributionTag(), intent,
|
||||
|
||||
@@ -351,7 +351,7 @@ public final class PendingIntent implements Parcelable {
|
||||
String resolvedType = intent != null ? intent.resolveTypeIfNeeded(
|
||||
context.getContentResolver()) : null;
|
||||
try {
|
||||
intent.migrateExtraStreamToClipData();
|
||||
intent.migrateExtraStreamToClipData(context);
|
||||
intent.prepareToLeaveProcess(context);
|
||||
IIntentSender target =
|
||||
ActivityManager.getService().getIntentSenderWithFeature(
|
||||
@@ -377,7 +377,7 @@ public final class PendingIntent implements Parcelable {
|
||||
String resolvedType = intent != null ? intent.resolveTypeIfNeeded(
|
||||
context.getContentResolver()) : null;
|
||||
try {
|
||||
intent.migrateExtraStreamToClipData();
|
||||
intent.migrateExtraStreamToClipData(context);
|
||||
intent.prepareToLeaveProcess(context);
|
||||
IIntentSender target =
|
||||
ActivityManager.getService().getIntentSenderWithFeature(
|
||||
@@ -491,7 +491,7 @@ public final class PendingIntent implements Parcelable {
|
||||
String packageName = context.getPackageName();
|
||||
String[] resolvedTypes = new String[intents.length];
|
||||
for (int i=0; i<intents.length; i++) {
|
||||
intents[i].migrateExtraStreamToClipData();
|
||||
intents[i].migrateExtraStreamToClipData(context);
|
||||
intents[i].prepareToLeaveProcess(context);
|
||||
resolvedTypes[i] = intents[i].resolveTypeIfNeeded(context.getContentResolver());
|
||||
}
|
||||
@@ -517,7 +517,7 @@ public final class PendingIntent implements Parcelable {
|
||||
String packageName = context.getPackageName();
|
||||
String[] resolvedTypes = new String[intents.length];
|
||||
for (int i=0; i<intents.length; i++) {
|
||||
intents[i].migrateExtraStreamToClipData();
|
||||
intents[i].migrateExtraStreamToClipData(context);
|
||||
intents[i].prepareToLeaveProcess(context);
|
||||
resolvedTypes[i] = intents[i].resolveTypeIfNeeded(context.getContentResolver());
|
||||
}
|
||||
|
||||
@@ -11272,6 +11272,19 @@ public class Intent implements Parcelable, Cloneable {
|
||||
* @hide
|
||||
*/
|
||||
public boolean migrateExtraStreamToClipData() {
|
||||
return migrateExtraStreamToClipData(AppGlobals.getInitialApplication());
|
||||
}
|
||||
|
||||
/**
|
||||
* Migrate any {@link #EXTRA_STREAM} in {@link #ACTION_SEND} and
|
||||
* {@link #ACTION_SEND_MULTIPLE} to {@link ClipData}. Also inspects nested
|
||||
* intents in {@link #ACTION_CHOOSER}.
|
||||
*
|
||||
* @param context app context
|
||||
* @return Whether any contents were migrated.
|
||||
* @hide
|
||||
*/
|
||||
public boolean migrateExtraStreamToClipData(Context context) {
|
||||
// Refuse to touch if extras already parcelled
|
||||
if (mExtras != null && mExtras.isParcelled()) return false;
|
||||
|
||||
@@ -11289,7 +11302,7 @@ public class Intent implements Parcelable, Cloneable {
|
||||
try {
|
||||
final Intent intent = getParcelableExtra(EXTRA_INTENT);
|
||||
if (intent != null) {
|
||||
migrated |= intent.migrateExtraStreamToClipData();
|
||||
migrated |= intent.migrateExtraStreamToClipData(context);
|
||||
}
|
||||
} catch (ClassCastException e) {
|
||||
}
|
||||
@@ -11299,7 +11312,7 @@ public class Intent implements Parcelable, Cloneable {
|
||||
for (int i = 0; i < intents.length; i++) {
|
||||
final Intent intent = (Intent) intents[i];
|
||||
if (intent != null) {
|
||||
migrated |= intent.migrateExtraStreamToClipData();
|
||||
migrated |= intent.migrateExtraStreamToClipData(context);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -11362,13 +11375,17 @@ public class Intent implements Parcelable, Cloneable {
|
||||
} catch (ClassCastException e) {
|
||||
}
|
||||
} else if (isImageCaptureIntent()) {
|
||||
final Uri output;
|
||||
Uri output;
|
||||
try {
|
||||
output = getParcelableExtra(MediaStore.EXTRA_OUTPUT);
|
||||
} catch (ClassCastException e) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (output != null) {
|
||||
output = maybeConvertFileToContentUri(context, output);
|
||||
putExtra(MediaStore.EXTRA_OUTPUT, output);
|
||||
|
||||
setClipData(ClipData.newRawUri("", output));
|
||||
addFlags(FLAG_GRANT_WRITE_URI_PERMISSION|FLAG_GRANT_READ_URI_PERMISSION);
|
||||
return true;
|
||||
@@ -11378,6 +11395,23 @@ public class Intent implements Parcelable, Cloneable {
|
||||
return false;
|
||||
}
|
||||
|
||||
private Uri maybeConvertFileToContentUri(Context context, Uri uri) {
|
||||
if (ContentResolver.SCHEME_FILE.equals(uri.getScheme())
|
||||
&& context.getApplicationInfo().targetSdkVersion < Build.VERSION_CODES.R) {
|
||||
File file = new File(uri.getPath());
|
||||
try {
|
||||
if (!file.exists()) file.createNewFile();
|
||||
uri = MediaStore.scanFile(context.getContentResolver(), new File(uri.getPath()));
|
||||
if (uri != null) {
|
||||
return uri;
|
||||
}
|
||||
} catch (IOException e) {
|
||||
Log.e(TAG, "Ignoring failure to create file " + file, e);
|
||||
}
|
||||
}
|
||||
return uri;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert the dock state to a human readable format.
|
||||
* @hide
|
||||
|
||||
@@ -1311,7 +1311,7 @@ public class VoiceInteractionSession implements KeyEvent.Callback, ComponentCall
|
||||
throw new IllegalStateException("Can't call before onCreate()");
|
||||
}
|
||||
try {
|
||||
intent.migrateExtraStreamToClipData();
|
||||
intent.migrateExtraStreamToClipData(mContext);
|
||||
intent.prepareToLeaveProcess(mContext);
|
||||
int res = mSystemService.startVoiceActivity(mToken, intent,
|
||||
intent.resolveType(mContext.getContentResolver()),
|
||||
@@ -1340,7 +1340,7 @@ public class VoiceInteractionSession implements KeyEvent.Callback, ComponentCall
|
||||
throw new IllegalStateException("Can't call before onCreate()");
|
||||
}
|
||||
try {
|
||||
intent.migrateExtraStreamToClipData();
|
||||
intent.migrateExtraStreamToClipData(mContext);
|
||||
intent.prepareToLeaveProcess(mContext);
|
||||
int res = mSystemService.startAssistantActivity(mToken, intent,
|
||||
intent.resolveType(mContext.getContentResolver()),
|
||||
|
||||
Reference in New Issue
Block a user