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