summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Ravenwood.bp1
-rw-r--r--core/java/android/content/ClipData.java10
-rw-r--r--core/java/android/content/ClipDescription.java1
-rw-r--r--core/java/android/content/ComponentName.java1
-rw-r--r--core/java/android/content/ContentUris.java1
-rw-r--r--core/java/android/content/ContentValues.java1
-rw-r--r--core/java/android/content/Intent.java10
-rw-r--r--core/java/android/content/IntentFilter.java1
-rw-r--r--core/java/android/content/UriMatcher.java1
-rw-r--r--ravenwood/framework-minus-apex-ravenwood-policies.txt12
-rw-r--r--ravenwood/ravenwood-annotation-allowed-classes.txt10
-rw-r--r--tools/hoststubgen/hoststubgen/helper-framework-runtime-src/framework/com/android/hoststubgen/nativesubstitution/Parcel_host.java6
12 files changed, 54 insertions, 1 deletions
diff --git a/Ravenwood.bp b/Ravenwood.bp
index 2f6709090093..b497871aee85 100644
--- a/Ravenwood.bp
+++ b/Ravenwood.bp
@@ -82,6 +82,7 @@ android_ravenwood_libgroup {
"junit",
"truth",
"ravenwood-junit",
+ "android.test.mock",
],
}
diff --git a/core/java/android/content/ClipData.java b/core/java/android/content/ClipData.java
index 0bc459a19e7d..67759f4aa76d 100644
--- a/core/java/android/content/ClipData.java
+++ b/core/java/android/content/ClipData.java
@@ -163,6 +163,7 @@ import java.util.List;
* into an editor), then {@link Item#coerceToText(Context)} will ask the content
* provider for the clip URI as text and successfully paste the entire note.
*/
+@android.ravenwood.annotation.RavenwoodKeepWholeClass
public class ClipData implements Parcelable {
static final String[] MIMETYPES_TEXT_PLAIN = new String[] {
ClipDescription.MIMETYPE_TEXT_PLAIN };
@@ -387,6 +388,7 @@ public class ClipData implements Parcelable {
* @return Returns the item's textual representation.
*/
//BEGIN_INCLUDE(coerceToText)
+ @android.ravenwood.annotation.RavenwoodThrow
public CharSequence coerceToText(Context context) {
// If this Item has an explicit textual value, simply return that.
CharSequence text = getText();
@@ -470,6 +472,7 @@ public class ClipData implements Parcelable {
* and other things can be retrieved.
* @return Returns the item's textual representation.
*/
+ @android.ravenwood.annotation.RavenwoodThrow
public CharSequence coerceToStyledText(Context context) {
CharSequence text = getText();
if (text instanceof Spanned) {
@@ -520,6 +523,7 @@ public class ClipData implements Parcelable {
* and other things can be retrieved.
* @return Returns the item's representation as HTML text.
*/
+ @android.ravenwood.annotation.RavenwoodThrow
public String coerceToHtmlText(Context context) {
// If the item has an explicit HTML value, simply return that.
String htmlText = getHtmlText();
@@ -540,6 +544,7 @@ public class ClipData implements Parcelable {
return text != null ? text.toString() : null;
}
+ @android.ravenwood.annotation.RavenwoodThrow
private CharSequence coerceToHtmlOrStyledText(Context context, boolean styled) {
// If this Item has a URI value, try using that.
if (mUri != null) {
@@ -1030,6 +1035,7 @@ public class ClipData implements Parcelable {
*
* @hide
*/
+ @android.ravenwood.annotation.RavenwoodThrow
public void prepareToLeaveProcess(boolean leavingPackage) {
// Assume that callers are going to be granting permissions
prepareToLeaveProcess(leavingPackage, Intent.FLAG_GRANT_READ_URI_PERMISSION);
@@ -1040,6 +1046,7 @@ public class ClipData implements Parcelable {
*
* @hide
*/
+ @android.ravenwood.annotation.RavenwoodThrow
public void prepareToLeaveProcess(boolean leavingPackage, int intentFlags) {
final int size = mItems.size();
for (int i = 0; i < size; i++) {
@@ -1060,6 +1067,7 @@ public class ClipData implements Parcelable {
}
/** {@hide} */
+ @android.ravenwood.annotation.RavenwoodThrow
public void prepareToEnterProcess(AttributionSource source) {
final int size = mItems.size();
for (int i = 0; i < size; i++) {
@@ -1073,6 +1081,7 @@ public class ClipData implements Parcelable {
}
/** @hide */
+ @android.ravenwood.annotation.RavenwoodThrow
public void fixUris(int contentUserHint) {
final int size = mItems.size();
for (int i = 0; i < size; i++) {
@@ -1090,6 +1099,7 @@ public class ClipData implements Parcelable {
* Only fixing the data field of the intents
* @hide
*/
+ @android.ravenwood.annotation.RavenwoodThrow
public void fixUrisLight(int contentUserHint) {
final int size = mItems.size();
for (int i = 0; i < size; i++) {
diff --git a/core/java/android/content/ClipDescription.java b/core/java/android/content/ClipDescription.java
index de2ba44ca393..5953890ad85f 100644
--- a/core/java/android/content/ClipDescription.java
+++ b/core/java/android/content/ClipDescription.java
@@ -48,6 +48,7 @@ import java.util.Map;
* developer guide.</p>
* </div>
*/
+@android.ravenwood.annotation.RavenwoodKeepWholeClass
public class ClipDescription implements Parcelable {
/**
* The MIME type for a clip holding plain text.
diff --git a/core/java/android/content/ComponentName.java b/core/java/android/content/ComponentName.java
index f12e971afb1f..a6a6bccbb4b5 100644
--- a/core/java/android/content/ComponentName.java
+++ b/core/java/android/content/ComponentName.java
@@ -37,6 +37,7 @@ import java.io.PrintWriter;
* name inside of that package.
*
*/
+@android.ravenwood.annotation.RavenwoodKeepWholeClass
public final class ComponentName implements Parcelable, Cloneable, Comparable<ComponentName> {
private final String mPackage;
private final String mClass;
diff --git a/core/java/android/content/ContentUris.java b/core/java/android/content/ContentUris.java
index 767d3f668313..093faff654ec 100644
--- a/core/java/android/content/ContentUris.java
+++ b/core/java/android/content/ContentUris.java
@@ -70,6 +70,7 @@ import java.util.List;
*</dl>
*
*/
+@android.ravenwood.annotation.RavenwoodKeepWholeClass
public class ContentUris {
/**
diff --git a/core/java/android/content/ContentValues.java b/core/java/android/content/ContentValues.java
index 02a5ba13f2aa..bde2f3e9a707 100644
--- a/core/java/android/content/ContentValues.java
+++ b/core/java/android/content/ContentValues.java
@@ -35,6 +35,7 @@ import java.util.Set;
* This class is used to store a set of values that the {@link ContentResolver}
* can process.
*/
+@android.ravenwood.annotation.RavenwoodKeepWholeClass
public final class ContentValues implements Parcelable {
public static final String TAG = "ContentValues";
diff --git a/core/java/android/content/Intent.java b/core/java/android/content/Intent.java
index 6b39f266a802..665ba1119550 100644
--- a/core/java/android/content/Intent.java
+++ b/core/java/android/content/Intent.java
@@ -660,6 +660,7 @@ import java.util.TimeZone;
* {@link #setFlags} and {@link #addFlags}. See {@link #setFlags} for a list
* of all possible flags.
*/
+@android.ravenwood.annotation.RavenwoodKeepWholeClass
public class Intent implements Parcelable, Cloneable {
private static final String TAG = "Intent";
@@ -12180,6 +12181,7 @@ public class Intent implements Parcelable, Cloneable {
*
* @hide
*/
+ @android.ravenwood.annotation.RavenwoodThrow
@UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553)
public void prepareToLeaveProcess(Context context) {
final boolean leavingPackage;
@@ -12201,6 +12203,7 @@ public class Intent implements Parcelable, Cloneable {
*
* @hide
*/
+ @android.ravenwood.annotation.RavenwoodThrow
public void prepareToLeaveProcess(boolean leavingPackage) {
setAllowFds(false);
@@ -12296,6 +12299,7 @@ public class Intent implements Parcelable, Cloneable {
/**
* @hide
*/
+ @android.ravenwood.annotation.RavenwoodThrow
public void prepareToEnterProcess(boolean fromProtectedComponent, AttributionSource source) {
if (fromProtectedComponent) {
prepareToEnterProcess(LOCAL_FLAG_FROM_PROTECTED_COMPONENT, source);
@@ -12307,6 +12311,7 @@ public class Intent implements Parcelable, Cloneable {
/**
* @hide
*/
+ @android.ravenwood.annotation.RavenwoodThrow
public void prepareToEnterProcess(int localFlags, AttributionSource source) {
// We just entered destination process, so we should be able to read all
// parcelables inside.
@@ -12378,6 +12383,7 @@ public class Intent implements Parcelable, Cloneable {
/**
* @hide
*/
+ @android.ravenwood.annotation.RavenwoodThrow
public void fixUris(int contentUserHint) {
Uri data = getData();
if (data != null) {
@@ -12417,6 +12423,7 @@ public class Intent implements Parcelable, Cloneable {
* @return Whether any contents were migrated.
* @hide
*/
+ @android.ravenwood.annotation.RavenwoodThrow
public boolean migrateExtraStreamToClipData() {
return migrateExtraStreamToClipData(AppGlobals.getInitialApplication());
}
@@ -12430,6 +12437,7 @@ public class Intent implements Parcelable, Cloneable {
* @return Whether any contents were migrated.
* @hide
*/
+ @android.ravenwood.annotation.RavenwoodThrow
public boolean migrateExtraStreamToClipData(Context context) {
// Refuse to touch if extras already parcelled
if (mExtras != null && mExtras.isParcelled()) return false;
@@ -12545,6 +12553,7 @@ public class Intent implements Parcelable, Cloneable {
return false;
}
+ @android.ravenwood.annotation.RavenwoodThrow
private Uri maybeConvertFileToContentUri(Context context, Uri uri) {
if (ContentResolver.SCHEME_FILE.equals(uri.getScheme())
&& context.getApplicationInfo().targetSdkVersion < Build.VERSION_CODES.R) {
@@ -12598,6 +12607,7 @@ public class Intent implements Parcelable, Cloneable {
// TODO(b/299109198): Refactor into the {@link SdkSandboxManagerLocal}
/** @hide */
+ @android.ravenwood.annotation.RavenwoodThrow
public boolean isSandboxActivity(@NonNull Context context) {
if (mAction != null && mAction.equals(ACTION_START_SANDBOXED_ACTIVITY)) {
return true;
diff --git a/core/java/android/content/IntentFilter.java b/core/java/android/content/IntentFilter.java
index f946754bd9a1..ad3acd713c6b 100644
--- a/core/java/android/content/IntentFilter.java
+++ b/core/java/android/content/IntentFilter.java
@@ -152,6 +152,7 @@ import java.util.function.Predicate;
* that unlike the action, an IntentFilter with no categories
* will only match an Intent that does not have any categories.
*/
+@android.ravenwood.annotation.RavenwoodKeepWholeClass
public class IntentFilter implements Parcelable {
private static final String TAG = "IntentFilter";
diff --git a/core/java/android/content/UriMatcher.java b/core/java/android/content/UriMatcher.java
index 7fa48f0e9a78..4422ade7ec0a 100644
--- a/core/java/android/content/UriMatcher.java
+++ b/core/java/android/content/UriMatcher.java
@@ -119,6 +119,7 @@ instead of:
}
</pre>
*/
+@android.ravenwood.annotation.RavenwoodKeepWholeClass
public class UriMatcher
{
public static final int NO_MATCH = -1;
diff --git a/ravenwood/framework-minus-apex-ravenwood-policies.txt b/ravenwood/framework-minus-apex-ravenwood-policies.txt
index 3e54c7a06288..aa2d470d7d9c 100644
--- a/ravenwood/framework-minus-apex-ravenwood-policies.txt
+++ b/ravenwood/framework-minus-apex-ravenwood-policies.txt
@@ -121,3 +121,15 @@ class com.android.modules.utils.FastDataOutput stubclass
class com.android.modules.utils.ModifiedUtf8 stubclass
class com.android.modules.utils.TypedXmlPullParser stubclass
class com.android.modules.utils.TypedXmlSerializer stubclass
+
+# Uri
+class android.net.Uri stubclass
+class android.net.UriCodec stubclass
+
+# Context: just enough to support wrapper, no further functionality
+class android.content.Context stub
+ method <init> ()V stub
+
+# Text
+class android.text.TextUtils stub
+ method isEmpty (Ljava/lang/CharSequence;)Z stub
diff --git a/ravenwood/ravenwood-annotation-allowed-classes.txt b/ravenwood/ravenwood-annotation-allowed-classes.txt
index 1ac6bf0a7c4d..0290bbe64439 100644
--- a/ravenwood/ravenwood-annotation-allowed-classes.txt
+++ b/ravenwood/ravenwood-annotation-allowed-classes.txt
@@ -10,3 +10,13 @@ android.os.IBinder
android.os.Process
android.os.SystemClock
android.os.UserHandle
+
+android.content.ClipData
+android.content.ClipData$Item
+android.content.ClipDescription
+android.content.ComponentName
+android.content.ContentUris
+android.content.ContentValues
+android.content.Intent
+android.content.IntentFilter
+android.content.UriMatcher
diff --git a/tools/hoststubgen/hoststubgen/helper-framework-runtime-src/framework/com/android/hoststubgen/nativesubstitution/Parcel_host.java b/tools/hoststubgen/hoststubgen/helper-framework-runtime-src/framework/com/android/hoststubgen/nativesubstitution/Parcel_host.java
index 12c7841556fc..4a3a79803b65 100644
--- a/tools/hoststubgen/hoststubgen/helper-framework-runtime-src/framework/com/android/hoststubgen/nativesubstitution/Parcel_host.java
+++ b/tools/hoststubgen/hoststubgen/helper-framework-runtime-src/framework/com/android/hoststubgen/nativesubstitution/Parcel_host.java
@@ -286,11 +286,15 @@ public class Parcel_host {
}
public static byte[] nativeReadBlob(long nativePtr) {
+ var p = getInstance(nativePtr);
+ if (p.mSize - p.mPos < 4) {
+ // Match native impl that returns "null" when not enough data
+ return null;
+ }
final var size = nativeReadInt(nativePtr);
if (size == -1) {
return null;
}
- var p = getInstance(nativePtr);
try {
p.ensureDataAvailable(align4(size));
} catch (Exception e) {