19.1: Initial bringup

TODO:
- manifest
- devices
- a few small patches to rebase

Signed-off-by: Tad <tad@spotco.us>
This commit is contained in:
Tad 2022-04-04 21:48:14 -04:00
parent b464106cc5
commit 1705545d22
109 changed files with 9579 additions and 7 deletions

View file

@ -0,0 +1,32 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Dmitry Muhomor <muhomor.dmitry@gmail.com>
Date: Tue, 14 Dec 2021 21:10:51 +0200
Subject: [PATCH] don't throw SecurityException when INTERNET permission is
revoked
---
ojluni/src/main/java/java/net/Inet6AddressImpl.java | 11 +----------
1 file changed, 1 insertion(+), 10 deletions(-)
diff --git a/ojluni/src/main/java/java/net/Inet6AddressImpl.java b/ojluni/src/main/java/java/net/Inet6AddressImpl.java
index 84bcf17edae..fda9674e08e 100644
--- a/ojluni/src/main/java/java/net/Inet6AddressImpl.java
+++ b/ojluni/src/main/java/java/net/Inet6AddressImpl.java
@@ -141,16 +141,7 @@ class Inet6AddressImpl implements InetAddressImpl {
addressCache.put(host, netId, addresses);
return addresses;
} catch (GaiException gaiException) {
- // If the failure appears to have been a lack of INTERNET permission, throw a clear
- // SecurityException to aid in debugging this common mistake.
- // http://code.google.com/p/android/issues/detail?id=15722
- if (gaiException.getCause() instanceof ErrnoException) {
- int errno = ((ErrnoException) gaiException.getCause()).errno;
- if (errno == EACCES || errno == EPERM) {
- throw new SecurityException("Permission denied (missing INTERNET permission?)", gaiException);
- }
- }
- // Otherwise, throw an UnknownHostException.
+ // Throw an UnknownHostException.
String detailMessage = "Unable to resolve host \"" + host + "\": " + Libcore.os.gai_strerror(gaiException.error);
addressCache.putUnknownHost(host, netId, detailMessage);
throw gaiException.rethrowAsUnknownHostException(detailMessage);

View file

@ -0,0 +1,199 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Daniel Micay <danielmicay@gmail.com>
Date: Sun, 10 Oct 2021 18:47:54 -0400
Subject: [PATCH] constify JNINativeMethod tables
---
luni/src/main/native/android_system_OsConstants.cpp | 2 +-
luni/src/main/native/java_lang_StringToReal.cpp | 2 +-
luni/src/main/native/java_lang_invoke_MethodHandle.cpp | 2 +-
luni/src/main/native/java_lang_invoke_VarHandle.cpp | 2 +-
luni/src/main/native/libcore_icu_ICU.cpp | 2 +-
luni/src/main/native/libcore_io_AsynchronousCloseMonitor.cpp | 2 +-
luni/src/main/native/libcore_io_Linux.cpp | 2 +-
luni/src/main/native/libcore_io_Memory.cpp | 2 +-
luni/src/main/native/libcore_math_NativeBN.cpp | 2 +-
.../src/main/native/libcore_util_NativeAllocationRegistry.cpp | 2 +-
luni/src/main/native/org_apache_harmony_xml_ExpatParser.cpp | 4 ++--
luni/src/main/native/sun_misc_Unsafe.cpp | 2 +-
ojluni/src/main/native/Character.cpp | 2 +-
13 files changed, 14 insertions(+), 14 deletions(-)
diff --git a/luni/src/main/native/android_system_OsConstants.cpp b/luni/src/main/native/android_system_OsConstants.cpp
index 50e3c104666..8ad66d2742b 100644
--- a/luni/src/main/native/android_system_OsConstants.cpp
+++ b/luni/src/main/native/android_system_OsConstants.cpp
@@ -722,7 +722,7 @@ static void OsConstants_initConstants(JNIEnv* env, jclass c) {
initConstant(env, c, "_SC_XOPEN_XCU_VERSION", _SC_XOPEN_XCU_VERSION);
}
-static JNINativeMethod gMethods[] = {
+static const JNINativeMethod gMethods[] = {
NATIVE_METHOD(OsConstants, initConstants, "()V"),
};
void register_android_system_OsConstants(JNIEnv* env) {
diff --git a/luni/src/main/native/java_lang_StringToReal.cpp b/luni/src/main/native/java_lang_StringToReal.cpp
index 7a492856394..edd71fad700 100644
--- a/luni/src/main/native/java_lang_StringToReal.cpp
+++ b/luni/src/main/native/java_lang_StringToReal.cpp
@@ -892,7 +892,7 @@ static jdouble StringToReal_parseDblImpl(JNIEnv* env, jclass, jstring s, jint e)
return createDouble(env, str.c_str(), e);
}
-static JNINativeMethod gMethods[] = {
+static const JNINativeMethod gMethods[] = {
NATIVE_METHOD(StringToReal, parseFltImpl, "(Ljava/lang/String;I)F"),
NATIVE_METHOD(StringToReal, parseDblImpl, "(Ljava/lang/String;I)D"),
};
diff --git a/luni/src/main/native/java_lang_invoke_MethodHandle.cpp b/luni/src/main/native/java_lang_invoke_MethodHandle.cpp
index 0441d4552dc..3335c6de9ac 100644
--- a/luni/src/main/native/java_lang_invoke_MethodHandle.cpp
+++ b/luni/src/main/native/java_lang_invoke_MethodHandle.cpp
@@ -29,7 +29,7 @@ static jobject MethodHandle_invoke(JNIEnv* env, jobject, jobjectArray) {
return nullptr;
}
-static JNINativeMethod gMethods[] = {
+static const JNINativeMethod gMethods[] = {
NATIVE_METHOD(MethodHandle, invokeExact, "([Ljava/lang/Object;)Ljava/lang/Object;"),
NATIVE_METHOD(MethodHandle, invoke, "([Ljava/lang/Object;)Ljava/lang/Object;"),
};
diff --git a/luni/src/main/native/java_lang_invoke_VarHandle.cpp b/luni/src/main/native/java_lang_invoke_VarHandle.cpp
index e1cc1c7f8b5..9f5215a5204 100644
--- a/luni/src/main/native/java_lang_invoke_VarHandle.cpp
+++ b/luni/src/main/native/java_lang_invoke_VarHandle.cpp
@@ -210,7 +210,7 @@ static jboolean VarHandle_weakCompareAndSetRelease(JNIEnv* env, jobject, jobject
return JNI_FALSE;
}
-static JNINativeMethod gMethods[] = {
+static const JNINativeMethod gMethods[] = {
NATIVE_METHOD(VarHandle, compareAndExchange, "([Ljava/lang/Object;)Ljava/lang/Object;"),
NATIVE_METHOD(VarHandle, compareAndExchangeAcquire, "([Ljava/lang/Object;)Ljava/lang/Object;"),
NATIVE_METHOD(VarHandle, compareAndExchangeRelease, "([Ljava/lang/Object;)Ljava/lang/Object;"),
diff --git a/luni/src/main/native/libcore_icu_ICU.cpp b/luni/src/main/native/libcore_icu_ICU.cpp
index f9401d1edb7..1531ad1ca59 100644
--- a/luni/src/main/native/libcore_icu_ICU.cpp
+++ b/luni/src/main/native/libcore_icu_ICU.cpp
@@ -112,7 +112,7 @@ static jstring ICU_getUnicodeVersion(JNIEnv* env, jclass) {
return versionString(env, unicodeVersion);
}
-static JNINativeMethod gMethods[] = {
+static const JNINativeMethod gMethods[] = {
NATIVE_METHOD(ICU, getAvailableLocalesNative, "()[Ljava/lang/String;"),
NATIVE_METHOD(ICU, getCldrVersion, "()Ljava/lang/String;"),
NATIVE_METHOD(ICU, getDefaultLocale, "()Ljava/lang/String;"),
diff --git a/luni/src/main/native/libcore_io_AsynchronousCloseMonitor.cpp b/luni/src/main/native/libcore_io_AsynchronousCloseMonitor.cpp
index e99edd6c4f9..61b75bcd358 100644
--- a/luni/src/main/native/libcore_io_AsynchronousCloseMonitor.cpp
+++ b/luni/src/main/native/libcore_io_AsynchronousCloseMonitor.cpp
@@ -26,7 +26,7 @@ static void AsynchronousCloseMonitor_signalBlockedThreads(JNIEnv* env, jclass, j
AsynchronousCloseMonitor::signalBlockedThreads(fd);
}
-static JNINativeMethod gMethods[] = {
+static const JNINativeMethod gMethods[] = {
NATIVE_METHOD(AsynchronousCloseMonitor, signalBlockedThreads, "(Ljava/io/FileDescriptor;)V"),
};
void register_libcore_io_AsynchronousCloseMonitor(JNIEnv* env) {
diff --git a/luni/src/main/native/libcore_io_Linux.cpp b/luni/src/main/native/libcore_io_Linux.cpp
index d7b6c22aa57..996085b1423 100755
--- a/luni/src/main/native/libcore_io_Linux.cpp
+++ b/luni/src/main/native/libcore_io_Linux.cpp
@@ -2741,7 +2741,7 @@ static jint Linux_writev(JNIEnv* env, jobject, jobject javaFd, jobjectArray buff
#define NATIVE_METHOD_OVERLOAD(className, functionName, signature, variant) \
{ #functionName, signature, reinterpret_cast<void*>(className ## _ ## functionName ## variant) }
-static JNINativeMethod gMethods[] = {
+static const JNINativeMethod gMethods[] = {
NATIVE_METHOD(Linux, accept, "(Ljava/io/FileDescriptor;Ljava/net/SocketAddress;)Ljava/io/FileDescriptor;"),
NATIVE_METHOD(Linux, access, "(Ljava/lang/String;I)Z"),
NATIVE_METHOD(Linux, android_fdsan_exchange_owner_tag, "(Ljava/io/FileDescriptor;JJ)V"),
diff --git a/luni/src/main/native/libcore_io_Memory.cpp b/luni/src/main/native/libcore_io_Memory.cpp
index b8a88450006..7dec85dab80 100644
--- a/luni/src/main/native/libcore_io_Memory.cpp
+++ b/luni/src/main/native/libcore_io_Memory.cpp
@@ -290,7 +290,7 @@ static void Memory_unsafeBulkPut(JNIEnv* env, jclass, jbyteArray dstArray, jint
env->ReleasePrimitiveArrayCritical(srcArray, srcBytes, 0);
}
-static JNINativeMethod gMethods[] = {
+static const JNINativeMethod gMethods[] = {
NATIVE_METHOD(Memory, memmove, "(Ljava/lang/Object;ILjava/lang/Object;IJ)V"),
FAST_NATIVE_METHOD(Memory, peekByte, "(J)B"),
NATIVE_METHOD(Memory, peekByteArray, "(J[BII)V"),
diff --git a/luni/src/main/native/libcore_math_NativeBN.cpp b/luni/src/main/native/libcore_math_NativeBN.cpp
index dc4b947358b..c6af376f6bc 100644
--- a/luni/src/main/native/libcore_math_NativeBN.cpp
+++ b/luni/src/main/native/libcore_math_NativeBN.cpp
@@ -164,7 +164,7 @@ static void NativeBN_BN_mod_exp(JNIEnv* env, jclass, jlong r, jlong a, jlong p,
}
}
-static JNINativeMethod gMethods[] = {
+static const JNINativeMethod gMethods[] = {
NATIVE_METHOD(NativeBN, BN_div, "(JJJJ)V"),
NATIVE_METHOD(NativeBN, BN_free, "(J)V"),
NATIVE_METHOD(NativeBN, BN_mod_exp, "(JJJJ)V"),
diff --git a/luni/src/main/native/libcore_util_NativeAllocationRegistry.cpp b/luni/src/main/native/libcore_util_NativeAllocationRegistry.cpp
index ded578a9580..faaa5c7a7c4 100644
--- a/luni/src/main/native/libcore_util_NativeAllocationRegistry.cpp
+++ b/luni/src/main/native/libcore_util_NativeAllocationRegistry.cpp
@@ -29,7 +29,7 @@ static void NativeAllocationRegistry_applyFreeFunction(JNIEnv*,
nativeFreeFunction(nativePtr);
}
-static JNINativeMethod gMethods[] = {
+static const JNINativeMethod gMethods[] = {
NATIVE_METHOD(NativeAllocationRegistry, applyFreeFunction, "(JJ)V"),
};
diff --git a/luni/src/main/native/org_apache_harmony_xml_ExpatParser.cpp b/luni/src/main/native/org_apache_harmony_xml_ExpatParser.cpp
index fdabcf71591..62a2cd37b76 100644
--- a/luni/src/main/native/org_apache_harmony_xml_ExpatParser.cpp
+++ b/luni/src/main/native/org_apache_harmony_xml_ExpatParser.cpp
@@ -1366,7 +1366,7 @@ static void ExpatParser_staticInitialize(JNIEnv* env, jobject classObject, jstri
emptyString = reinterpret_cast<jstring>(env->NewGlobalRef(empty));
}
-static JNINativeMethod parserMethods[] = {
+static const JNINativeMethod parserMethods[] = {
NATIVE_METHOD(ExpatParser, appendString, "(JLjava/lang/String;Z)V"),
NATIVE_METHOD(ExpatParser, appendBytes, "(J[BII)V"),
NATIVE_METHOD(ExpatParser, appendChars, "(J[CII)V"),
@@ -1380,7 +1380,7 @@ static JNINativeMethod parserMethods[] = {
NATIVE_METHOD(ExpatParser, staticInitialize, "(Ljava/lang/String;)V"),
};
-static JNINativeMethod attributeMethods[] = {
+static const JNINativeMethod attributeMethods[] = {
NATIVE_METHOD(ExpatAttributes, freeAttributes, "(J)V"),
NATIVE_METHOD(ExpatAttributes, getIndexForQName, "(JLjava/lang/String;)I"),
NATIVE_METHOD(ExpatAttributes, getIndex, "(JLjava/lang/String;Ljava/lang/String;)I"),
diff --git a/luni/src/main/native/sun_misc_Unsafe.cpp b/luni/src/main/native/sun_misc_Unsafe.cpp
index 49848a2db2b..87b2feac807 100644
--- a/luni/src/main/native/sun_misc_Unsafe.cpp
+++ b/luni/src/main/native/sun_misc_Unsafe.cpp
@@ -23,7 +23,7 @@ static jobject Unsafe_allocateInstance(JNIEnv* env, jclass, jclass c) {
return env->AllocObject(c);
}
-static JNINativeMethod gMethods[] = {
+static const JNINativeMethod gMethods[] = {
NATIVE_METHOD(Unsafe, allocateInstance, "(Ljava/lang/Class;)Ljava/lang/Object;"),
};
void register_sun_misc_Unsafe(JNIEnv* env) {
diff --git a/ojluni/src/main/native/Character.cpp b/ojluni/src/main/native/Character.cpp
index 3e27c674d2f..719190c81ae 100644
--- a/ojluni/src/main/native/Character.cpp
+++ b/ojluni/src/main/native/Character.cpp
@@ -158,7 +158,7 @@ Character_getNameImpl(JNIEnv* env, jclass, jint codePoint) {
return (U_FAILURE(status) || byteCount == 0) ? NULL : env->NewStringUTF(buf);
}
-static JNINativeMethod gMethods[] = {
+static const JNINativeMethod gMethods[] = {
FAST_NATIVE_METHOD(Character, digitImpl, "(II)I"),
FAST_NATIVE_METHOD(Character, getDirectionalityImpl, "(I)B"),
NATIVE_METHOD(Character, getNameImpl, "(I)Ljava/lang/String;"),

View file

@ -0,0 +1,112 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Daniel Micay <danielmicay@gmail.com>
Date: Wed, 11 Sep 2019 06:46:38 -0400
Subject: [PATCH] add parameter for avoiding full preload with exec
---
api/module-lib-current.txt | 2 ++
.../main/java/dalvik/system/ZygoteHooks.java | 26 +++++++++++++++++--
.../api/legacy_platform/current.txt | 2 ++
.../api/stable_platform/current.txt | 2 ++
4 files changed, 30 insertions(+), 2 deletions(-)
diff --git a/api/module-lib-current.txt b/api/module-lib-current.txt
index 15741a78057..e554dd77cb8 100644
--- a/api/module-lib-current.txt
+++ b/api/module-lib-current.txt
@@ -366,7 +366,9 @@ package dalvik.system {
public final class ZygoteHooks {
method public static void gcAndFinalize();
method public static boolean isIndefiniteThreadSuspensionSafe();
+ method public static void onBeginPreload(boolean);
method public static void onBeginPreload();
+ method public static void onEndPreload(boolean);
method public static void onEndPreload();
method public static void postForkChild(int, boolean, boolean, String);
method public static void postForkCommon();
diff --git a/dalvik/src/main/java/dalvik/system/ZygoteHooks.java b/dalvik/src/main/java/dalvik/system/ZygoteHooks.java
index a17a2574f7b..763511d2187 100644
--- a/dalvik/src/main/java/dalvik/system/ZygoteHooks.java
+++ b/dalvik/src/main/java/dalvik/system/ZygoteHooks.java
@@ -62,7 +62,7 @@ public final class ZygoteHooks {
*/
@SystemApi(client = MODULE_LIBRARIES)
@libcore.api.CorePlatformApi(status = libcore.api.CorePlatformApi.Status.STABLE)
- public static void onBeginPreload() {
+ public static void onBeginPreload(boolean fullPreload) {
com.android.i18n.system.ZygoteHooks.onBeginPreload();
ICU.initializeCacheInZygote();
@@ -81,6 +81,17 @@ public final class ZygoteHooks {
}
}
+ /**
+ * Called when the zygote begins preloading classes and data.
+ *
+ * @hide
+ */
+ @SystemApi(client = MODULE_LIBRARIES)
+ @libcore.api.CorePlatformApi(status = libcore.api.CorePlatformApi.Status.STABLE)
+ public static void onBeginPreload() {
+ onBeginPreload(true);
+ }
+
/**
* Called when the zygote has completed preloading classes and data.
*
@@ -88,7 +99,7 @@ public final class ZygoteHooks {
*/
@SystemApi(client = MODULE_LIBRARIES)
@libcore.api.CorePlatformApi(status = libcore.api.CorePlatformApi.Status.STABLE)
- public static void onEndPreload() {
+ public static void onEndPreload(boolean fullPreload) {
com.android.i18n.system.ZygoteHooks.onEndPreload();
// Clone standard descriptors as originals closed / rebound during zygote post fork.
@@ -97,6 +108,17 @@ public final class ZygoteHooks {
FileDescriptor.err.cloneForFork();
}
+ /**
+ * Called when the zygote has completed preloading classes and data.
+ *
+ * @hide
+ */
+ @SystemApi(client = MODULE_LIBRARIES)
+ @libcore.api.CorePlatformApi(status = libcore.api.CorePlatformApi.Status.STABLE)
+ public static void onEndPreload() {
+ onEndPreload(true);
+ }
+
/**
* Runs several special GCs to try to clean up a few generations of
* softly- and final-reachable objects, along with any other garbage.
diff --git a/mmodules/core_platform_api/api/legacy_platform/current.txt b/mmodules/core_platform_api/api/legacy_platform/current.txt
index 15741a78057..e554dd77cb8 100644
--- a/mmodules/core_platform_api/api/legacy_platform/current.txt
+++ b/mmodules/core_platform_api/api/legacy_platform/current.txt
@@ -366,7 +366,9 @@ package dalvik.system {
public final class ZygoteHooks {
method public static void gcAndFinalize();
method public static boolean isIndefiniteThreadSuspensionSafe();
+ method public static void onBeginPreload(boolean);
method public static void onBeginPreload();
+ method public static void onEndPreload(boolean);
method public static void onEndPreload();
method public static void postForkChild(int, boolean, boolean, String);
method public static void postForkCommon();
diff --git a/mmodules/core_platform_api/api/stable_platform/current.txt b/mmodules/core_platform_api/api/stable_platform/current.txt
index 15741a78057..e554dd77cb8 100644
--- a/mmodules/core_platform_api/api/stable_platform/current.txt
+++ b/mmodules/core_platform_api/api/stable_platform/current.txt
@@ -366,7 +366,9 @@ package dalvik.system {
public final class ZygoteHooks {
method public static void gcAndFinalize();
method public static boolean isIndefiniteThreadSuspensionSafe();
+ method public static void onBeginPreload(boolean);
method public static void onBeginPreload();
+ method public static void onEndPreload(boolean);
method public static void onEndPreload();
method public static void postForkChild(int, boolean, boolean, String);
method public static void postForkCommon();

View file

@ -0,0 +1,38 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Daniel Micay <danielmicay@gmail.com>
Date: Thu, 14 Oct 2021 17:00:10 -0400
Subject: [PATCH] disable ICU cache pinning for exec spawning
---
dalvik/src/main/java/dalvik/system/ZygoteHooks.java | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/dalvik/src/main/java/dalvik/system/ZygoteHooks.java b/dalvik/src/main/java/dalvik/system/ZygoteHooks.java
index 763511d2187..179c19ac8d5 100644
--- a/dalvik/src/main/java/dalvik/system/ZygoteHooks.java
+++ b/dalvik/src/main/java/dalvik/system/ZygoteHooks.java
@@ -63,9 +63,11 @@ public final class ZygoteHooks {
@SystemApi(client = MODULE_LIBRARIES)
@libcore.api.CorePlatformApi(status = libcore.api.CorePlatformApi.Status.STABLE)
public static void onBeginPreload(boolean fullPreload) {
- com.android.i18n.system.ZygoteHooks.onBeginPreload();
+ if (fullPreload) {
+ com.android.i18n.system.ZygoteHooks.onBeginPreload();
- ICU.initializeCacheInZygote();
+ ICU.initializeCacheInZygote();
+ }
// Look up JaCoCo on the boot classpath, if it exists. This will be used later for enabling
// memory-mapped Java coverage.
@@ -100,7 +102,9 @@ public final class ZygoteHooks {
@SystemApi(client = MODULE_LIBRARIES)
@libcore.api.CorePlatformApi(status = libcore.api.CorePlatformApi.Status.STABLE)
public static void onEndPreload(boolean fullPreload) {
- com.android.i18n.system.ZygoteHooks.onEndPreload();
+ if (fullPreload) {
+ com.android.i18n.system.ZygoteHooks.onEndPreload();
+ }
// Clone standard descriptors as originals closed / rebound during zygote post fork.
FileDescriptor.in.cloneForFork();