Merge "Track interfaces and roaming changed event history"
diff --git a/apct-tests/perftests/core/src/android/libcore/regression/CharsetUtf8PerfTest.java b/apct-tests/perftests/core/src/android/libcore/regression/CharsetUtf8PerfTest.java
index f31e9c1..b753006 100644
--- a/apct-tests/perftests/core/src/android/libcore/regression/CharsetUtf8PerfTest.java
+++ b/apct-tests/perftests/core/src/android/libcore/regression/CharsetUtf8PerfTest.java
@@ -37,9 +37,7 @@
public class CharsetUtf8PerfTest {
@Rule public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter();
- private final int mNoOfBytes = 0x100; // 4MB
-
- private void makeUnicodeRange(int startingCodePoint, int endingCodePoint, int repeated) {
+ private void makeUnicodeRange(int startingCodePoint, int endingCodePoint) {
StringBuilder builder = new StringBuilder();
for (int codePoint = startingCodePoint; codePoint <= endingCodePoint; codePoint++) {
if (codePoint < Character.MIN_SURROGATE || codePoint > Character.MAX_SURROGATE) {
@@ -48,35 +46,30 @@
}
String str = builder.toString();
- StringBuilder builder2 = new StringBuilder();
BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
while (state.keepRunning()) {
- for (int i = 0; i < repeated; i++) {
- builder2.append(str);
- }
+ StringBuilder builder2 = new StringBuilder();
+ builder2.append(str);
}
}
@Test
public void time_ascii() {
- makeUnicodeRange(0, 0x7f, mNoOfBytes / 0x80);
+ makeUnicodeRange(0, 0x7f);
}
@Test
public void time_bmp2() {
- makeUnicodeRange(0x0080, 0x07ff, mNoOfBytes / 2 / 0x780);
+ makeUnicodeRange(0x0080, 0x07ff);
}
@Test
public void time_bmp3() {
- makeUnicodeRange(
- 0x0800,
- 0xffff,
- mNoOfBytes / 3 / 0xf000 /* 0x10000 - 0x0800 - no of surrogate code points */);
+ makeUnicodeRange(0x0800, 0xffff);
}
@Test
public void time_supplementary() {
- makeUnicodeRange(0x10000, 0x10ffff, mNoOfBytes / 4 / 0x100000);
+ makeUnicodeRange(0x10000, 0x10ffff);
}
}
diff --git a/apct-tests/perftests/core/src/com/android/internal/util/FastDataPerfTest.java b/apct-tests/perftests/core/src/com/android/internal/util/FastDataPerfTest.java
index 2700fff..76656bd 100644
--- a/apct-tests/perftests/core/src/com/android/internal/util/FastDataPerfTest.java
+++ b/apct-tests/perftests/core/src/com/android/internal/util/FastDataPerfTest.java
@@ -52,21 +52,45 @@
while (state.keepRunning()) {
os.reset();
final BufferedOutputStream bos = new BufferedOutputStream(os, BUFFER_SIZE);
- final DataOutput out = new DataOutputStream(bos);
- doWrite(out);
- bos.flush();
+ final DataOutputStream out = new DataOutputStream(bos);
+ try {
+ doWrite(out);
+ out.flush();
+ } finally {
+ out.close();
+ }
}
}
@Test
- public void timeWrite_Local() throws IOException {
+ public void timeWrite_LocalUsing4ByteSequences() throws IOException {
final ByteArrayOutputStream os = new ByteArrayOutputStream(OUTPUT_SIZE);
final BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
while (state.keepRunning()) {
os.reset();
- final FastDataOutput out = new FastDataOutput(os, BUFFER_SIZE);
- doWrite(out);
- out.flush();
+ final FastDataOutput out = FastDataOutput.obtainUsing4ByteSequences(os);
+ try {
+ doWrite(out);
+ out.flush();
+ } finally {
+ out.release();
+ }
+ }
+ }
+
+ @Test
+ public void timeWrite_LocalUsing3ByteSequences() throws IOException {
+ final ByteArrayOutputStream os = new ByteArrayOutputStream(OUTPUT_SIZE);
+ final BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
+ while (state.keepRunning()) {
+ os.reset();
+ final FastDataOutput out = FastDataOutput.obtainUsing3ByteSequences(os);
+ try {
+ doWrite(out);
+ out.flush();
+ } finally {
+ out.release();
+ }
}
}
@@ -77,19 +101,42 @@
while (state.keepRunning()) {
is.reset();
final BufferedInputStream bis = new BufferedInputStream(is, BUFFER_SIZE);
- final DataInput in = new DataInputStream(bis);
- doRead(in);
+ final DataInputStream in = new DataInputStream(bis);
+ try {
+ doRead(in);
+ } finally {
+ in.close();
+ }
}
}
@Test
- public void timeRead_Local() throws Exception {
+ public void timeRead_LocalUsing4ByteSequences() throws Exception {
final ByteArrayInputStream is = new ByteArrayInputStream(doWrite());
final BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
while (state.keepRunning()) {
is.reset();
- final DataInput in = new FastDataInput(is, BUFFER_SIZE);
- doRead(in);
+ final FastDataInput in = FastDataInput.obtainUsing4ByteSequences(is);
+ try {
+ doRead(in);
+ } finally {
+ in.release();
+ }
+ }
+ }
+
+ @Test
+ public void timeRead_LocalUsing3ByteSequences() throws Exception {
+ final ByteArrayInputStream is = new ByteArrayInputStream(doWrite());
+ final BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
+ while (state.keepRunning()) {
+ is.reset();
+ final FastDataInput in = FastDataInput.obtainUsing3ByteSequences(is);
+ try {
+ doRead(in);
+ } finally {
+ in.release();
+ }
}
}
diff --git a/apex/jobscheduler/service/java/com/android/server/alarm/AlarmManagerService.java b/apex/jobscheduler/service/java/com/android/server/alarm/AlarmManagerService.java
index c9b33aa..c063158 100644
--- a/apex/jobscheduler/service/java/com/android/server/alarm/AlarmManagerService.java
+++ b/apex/jobscheduler/service/java/com/android/server/alarm/AlarmManagerService.java
@@ -2523,7 +2523,11 @@
changeDisabled = true;
needsPermission = false;
lowerQuota = allowWhileIdle;
- idleOptions = allowWhileIdle ? mOptsWithFgs.toBundle() : null;
+ idleOptions = (allowWhileIdle || (alarmClock != null))
+ // This avoids exceptions on existing alarms when the app upgrades to
+ // target S. Note that FGS from pre-S apps isn't restricted anyway.
+ ? mOptsWithFgs.toBundle()
+ : null;
}
if (needsPermission && !hasScheduleExactAlarmInternal(callingPackage, callingUid)) {
if (!isExemptFromExactAlarmPermission(callingUid)) {
diff --git a/cmds/incidentd/src/IncidentService.cpp b/cmds/incidentd/src/IncidentService.cpp
index 13bf197..30a525c 100644
--- a/cmds/incidentd/src/IncidentService.cpp
+++ b/cmds/incidentd/src/IncidentService.cpp
@@ -47,10 +47,16 @@
#define DEFAULT_REFACTORY_PERIOD_MS (24 * 60 * 60 * 1000) // 1 Day
// Skip these sections (for dumpstate only)
-// Skip logs (1100 - 1108) and traces (1200 - 1202) because they are already in the bug report.
+// Skip logs (1100 - 1108), traces (1200 - 1202), dumpsys (3000 - 3024, 3027 - 3056, 4000 - 4001)
+// because they are already in the bug report.
#define SKIPPED_DUMPSTATE_SECTIONS { \
1100, 1101, 1102, 1103, 1104, 1105, 1106, 1107, 1108, /* Logs */ \
- 1200, 1201, 1202, /* Native, hal, java traces */ }
+ 1200, 1201, 1202, /* Native, hal, java traces */ \
+ 3000, 3001, 3002, 3003, 3004, 3005, 3006, 3007, 3008, 3009, 3010, 3011, 3012, 3013, \
+ 3014, 3015, 3016, 3017, 3018, 3019, 3020, 3021, 3022, 3023, 3024, 3027, 3028, 3029, \
+ 3030, 3031, 3032, 3033, 3034, 3035, 3036, 3037, 3038, 3039, 3040, 3041, 3042, 3043, \
+ 3044, 3045, 3046, 3047, 3048, 3049, 3050, 3051, 3052, 3053, 3054, 3055, 3056, 4000, \
+ 4001, /* Dumpsys */ }
namespace android {
namespace os {
diff --git a/cmds/telecom/src/com/android/commands/telecom/Telecom.java b/cmds/telecom/src/com/android/commands/telecom/Telecom.java
index 8b9ab4c..d464e26 100644
--- a/cmds/telecom/src/com/android/commands/telecom/Telecom.java
+++ b/cmds/telecom/src/com/android/commands/telecom/Telecom.java
@@ -73,6 +73,8 @@
private static final String COMMAND_GET_DEFAULT_DIALER = "get-default-dialer";
private static final String COMMAND_STOP_BLOCK_SUPPRESSION = "stop-block-suppression";
private static final String COMMAND_CLEANUP_STUCK_CALLS = "cleanup-stuck-calls";
+ private static final String COMMAND_CLEANUP_ORPHAN_PHONE_ACCOUNTS =
+ "cleanup-orphan-phone-accounts";
private static final String COMMAND_RESET_CAR_MODE = "reset-car-mode";
/**
@@ -131,6 +133,9 @@
+ " provider after a call to emergency services.\n"
+ "usage: telecom cleanup-stuck-calls: Clear any disconnected calls that have"
+ " gotten wedged in Telecom.\n"
+ + "usage: telecom cleanup-orphan-phone-accounts: remove any phone accounts that"
+ + " no longer have a valid UserHandle or accounts that no longer belongs to an"
+ + " installed package.\n"
+ "usage: telecom set-emer-phone-account-filter <PACKAGE>\n"
+ "\n"
+ "telecom set-phone-account-enabled: Enables the given phone account, if it has"
@@ -235,6 +240,9 @@
case COMMAND_CLEANUP_STUCK_CALLS:
runCleanupStuckCalls();
break;
+ case COMMAND_CLEANUP_ORPHAN_PHONE_ACCOUNTS:
+ runCleanupOrphanPhoneAccounts();
+ break;
case COMMAND_RESET_CAR_MODE:
runResetCarMode();
break;
@@ -373,6 +381,11 @@
mTelecomService.cleanupStuckCalls();
}
+ private void runCleanupOrphanPhoneAccounts() throws RemoteException {
+ System.out.println("Success - cleaned up " + mTelecomService.cleanupOrphanPhoneAccounts()
+ + " phone accounts.");
+ }
+
private void runResetCarMode() throws RemoteException {
mTelecomService.resetCarMode();
}
diff --git a/core/api/current.txt b/core/api/current.txt
index dc19496..e513bba 100644
--- a/core/api/current.txt
+++ b/core/api/current.txt
@@ -29758,7 +29758,7 @@
method @Deprecated public static void changeDebugPort(int);
method public static void dumpHprofData(String) throws java.io.IOException;
method public static boolean dumpService(String, java.io.FileDescriptor, String[]);
- method public static void enableEmulatorTraceOutput();
+ method @Deprecated public static void enableEmulatorTraceOutput();
method public static int getBinderDeathObjectCount();
method public static int getBinderLocalObjectCount();
method public static int getBinderProxyObjectCount();
diff --git a/core/java/android/os/Debug.java b/core/java/android/os/Debug.java
index b4930fa..399f11b 100644
--- a/core/java/android/os/Debug.java
+++ b/core/java/android/os/Debug.java
@@ -1155,6 +1155,8 @@
* consequences.
*
* To temporarily enable tracing, use {@link #startNativeTracing()}.
+ *
+ * @deprecated Please use other tracing method in this class.
*/
public static void enableEmulatorTraceOutput() {
Log.w(TAG, "Unimplemented");
diff --git a/core/java/android/util/CharsetUtils.java b/core/java/android/util/CharsetUtils.java
index fa14667..3b08c3b 100644
--- a/core/java/android/util/CharsetUtils.java
+++ b/core/java/android/util/CharsetUtils.java
@@ -26,6 +26,12 @@
* <p>
* These methods purposefully accept only non-movable byte array addresses to
* avoid extra JNI overhead.
+ * <p>
+ * Callers are cautioned that there is a long-standing ART bug that emits
+ * non-standard 4-byte sequences, as described by {@code kUtfUse4ByteSequence}
+ * in {@code art/runtime/jni/jni_internal.cc}. If precise modified UTF-8
+ * encoding is required, use {@link com.android.internal.util.ModifiedUtf8}
+ * instead.
*
* @hide
*/
@@ -33,6 +39,12 @@
/**
* Attempt to encode the given string as modified UTF-8 into the destination
* byte array without making any new allocations.
+ * <p>
+ * Callers are cautioned that there is a long-standing ART bug that emits
+ * non-standard 4-byte sequences, as described by
+ * {@code kUtfUse4ByteSequence} in {@code art/runtime/jni/jni_internal.cc}.
+ * If precise modified UTF-8 encoding is required, use
+ * {@link com.android.internal.util.ModifiedUtf8} instead.
*
* @param src string value to be encoded
* @param dest destination byte array to encode into
@@ -50,6 +62,12 @@
/**
* Attempt to encode the given string as modified UTF-8 into the destination
* byte array without making any new allocations.
+ * <p>
+ * Callers are cautioned that there is a long-standing ART bug that emits
+ * non-standard 4-byte sequences, as described by
+ * {@code kUtfUse4ByteSequence} in {@code art/runtime/jni/jni_internal.cc}.
+ * If precise modified UTF-8 encoding is required, use
+ * {@link com.android.internal.util.ModifiedUtf8} instead.
*
* @param src string value to be encoded
* @param srcLen exact length of string to be encoded
@@ -66,6 +84,12 @@
/**
* Attempt to decode a modified UTF-8 string from the source byte array.
+ * <p>
+ * Callers are cautioned that there is a long-standing ART bug that emits
+ * non-standard 4-byte sequences, as described by
+ * {@code kUtfUse4ByteSequence} in {@code art/runtime/jni/jni_internal.cc}.
+ * If precise modified UTF-8 encoding is required, use
+ * {@link com.android.internal.util.ModifiedUtf8} instead.
*
* @param src source byte array to decode from
* @param srcOff offset into source where decoding should begin
diff --git a/core/java/android/util/Log.java b/core/java/android/util/Log.java
index b5fe4f5..f1e91d0 100644
--- a/core/java/android/util/Log.java
+++ b/core/java/android/util/Log.java
@@ -66,6 +66,10 @@
* <p>When calling the log methods that take a Throwable parameter,
* if any of the throwables in the cause chain is an <code>UnknownHostException</code>,
* then the stack trace is not logged.
+ *
+ * <p>Note: The return value from the logging functions in this class may vary between Android
+ * releases due to changes in the logging implementation. For the methods that return an integer,
+ * a positive value may be considered as a successful invocation.
*/
public final class Log {
/** @hide */
@@ -134,6 +138,7 @@
* @param tag Used to identify the source of a log message. It usually identifies
* the class or activity where the log call occurs.
* @param msg The message you would like logged.
+ * @return A positive value if the message was loggable (see {@link #isLoggable}).
*/
public static int v(@Nullable String tag, @NonNull String msg) {
return println_native(LOG_ID_MAIN, VERBOSE, tag, msg);
@@ -144,7 +149,8 @@
* @param tag Used to identify the source of a log message. It usually identifies
* the class or activity where the log call occurs.
* @param msg The message you would like logged.
- * @param tr An exception to log
+ * @param tr An exception to log.
+ * @return A positive value if the message was loggable (see {@link #isLoggable}).
*/
public static int v(@Nullable String tag, @Nullable String msg, @Nullable Throwable tr) {
return printlns(LOG_ID_MAIN, VERBOSE, tag, msg, tr);
@@ -155,6 +161,7 @@
* @param tag Used to identify the source of a log message. It usually identifies
* the class or activity where the log call occurs.
* @param msg The message you would like logged.
+ * @return A positive value if the message was loggable (see {@link #isLoggable}).
*/
public static int d(@Nullable String tag, @NonNull String msg) {
return println_native(LOG_ID_MAIN, DEBUG, tag, msg);
@@ -165,7 +172,8 @@
* @param tag Used to identify the source of a log message. It usually identifies
* the class or activity where the log call occurs.
* @param msg The message you would like logged.
- * @param tr An exception to log
+ * @param tr An exception to log.
+ * @return A positive value if the message was loggable (see {@link #isLoggable}).
*/
public static int d(@Nullable String tag, @Nullable String msg, @Nullable Throwable tr) {
return printlns(LOG_ID_MAIN, DEBUG, tag, msg, tr);
@@ -176,6 +184,7 @@
* @param tag Used to identify the source of a log message. It usually identifies
* the class or activity where the log call occurs.
* @param msg The message you would like logged.
+ * @return A positive value if the message was loggable (see {@link #isLoggable}).
*/
public static int i(@Nullable String tag, @NonNull String msg) {
return println_native(LOG_ID_MAIN, INFO, tag, msg);
@@ -186,7 +195,7 @@
* @param tag Used to identify the source of a log message. It usually identifies
* the class or activity where the log call occurs.
* @param msg The message you would like logged.
- * @param tr An exception to log
+ * @param tr An exception to log.
*/
public static int i(@Nullable String tag, @Nullable String msg, @Nullable Throwable tr) {
return printlns(LOG_ID_MAIN, INFO, tag, msg, tr);
@@ -197,6 +206,7 @@
* @param tag Used to identify the source of a log message. It usually identifies
* the class or activity where the log call occurs.
* @param msg The message you would like logged.
+ * @return A positive value if the message was loggable (see {@link #isLoggable}).
*/
public static int w(@Nullable String tag, @NonNull String msg) {
return println_native(LOG_ID_MAIN, WARN, tag, msg);
@@ -207,7 +217,8 @@
* @param tag Used to identify the source of a log message. It usually identifies
* the class or activity where the log call occurs.
* @param msg The message you would like logged.
- * @param tr An exception to log
+ * @param tr An exception to log.
+ * @return A positive value if the message was loggable (see {@link #isLoggable}).
*/
public static int w(@Nullable String tag, @Nullable String msg, @Nullable Throwable tr) {
return printlns(LOG_ID_MAIN, WARN, tag, msg, tr);
@@ -239,7 +250,8 @@
* Send a {@link #WARN} log message and log the exception.
* @param tag Used to identify the source of a log message. It usually identifies
* the class or activity where the log call occurs.
- * @param tr An exception to log
+ * @param tr An exception to log.
+ * @return A positive value if the message was loggable (see {@link #isLoggable}).
*/
public static int w(@Nullable String tag, @Nullable Throwable tr) {
return printlns(LOG_ID_MAIN, WARN, tag, "", tr);
@@ -250,6 +262,7 @@
* @param tag Used to identify the source of a log message. It usually identifies
* the class or activity where the log call occurs.
* @param msg The message you would like logged.
+ * @return A positive value if the message was loggable (see {@link #isLoggable}).
*/
public static int e(@Nullable String tag, @NonNull String msg) {
return println_native(LOG_ID_MAIN, ERROR, tag, msg);
@@ -260,7 +273,8 @@
* @param tag Used to identify the source of a log message. It usually identifies
* the class or activity where the log call occurs.
* @param msg The message you would like logged.
- * @param tr An exception to log
+ * @param tr An exception to log.
+ * @return A positive value if the message was loggable (see {@link #isLoggable}).
*/
public static int e(@Nullable String tag, @Nullable String msg, @Nullable Throwable tr) {
return printlns(LOG_ID_MAIN, ERROR, tag, msg, tr);
@@ -274,6 +288,7 @@
* immediately with an error dialog.
* @param tag Used to identify the source of a log message.
* @param msg The message you would like logged.
+ * @return A positive value if the message was loggable (see {@link #isLoggable}).
*/
public static int wtf(@Nullable String tag, @Nullable String msg) {
return wtf(LOG_ID_MAIN, tag, msg, null, false, false);
@@ -293,6 +308,7 @@
* Similar to {@link #wtf(String, String)}, with an exception to log.
* @param tag Used to identify the source of a log message.
* @param tr An exception to log.
+ * @return A positive value if the message was loggable (see {@link #isLoggable}).
*/
public static int wtf(@Nullable String tag, @NonNull Throwable tr) {
return wtf(LOG_ID_MAIN, tag, tr.getMessage(), tr, false, false);
@@ -304,6 +320,7 @@
* @param tag Used to identify the source of a log message.
* @param msg The message you would like logged.
* @param tr An exception to log. May be null.
+ * @return A positive value if the message was loggable (see {@link #isLoggable}).
*/
public static int wtf(@Nullable String tag, @Nullable String msg, @Nullable Throwable tr) {
return wtf(LOG_ID_MAIN, tag, msg, tr, false, false);
@@ -348,7 +365,7 @@
* <p>If any of the throwables in the cause chain is an <code>UnknownHostException</code>,
* this returns an empty string.
- * @param tr An exception to log
+ * @param tr An exception to log.
*/
@NonNull
public static String getStackTraceString(@Nullable Throwable tr) {
@@ -379,7 +396,7 @@
* @param tag Used to identify the source of a log message. It usually identifies
* the class or activity where the log call occurs.
* @param msg The message you would like logged.
- * @return The number of bytes written.
+ * @return A positive value if the message was loggable (see {@link #isLoggable}).
*/
public static int println(@Level int priority, @Nullable String tag, @NonNull String msg) {
return println_native(LOG_ID_MAIN, priority, tag, msg);
@@ -391,7 +408,16 @@
/** @hide */ public static final int LOG_ID_SYSTEM = 3;
/** @hide */ public static final int LOG_ID_CRASH = 4;
- /** @hide */
+ /**
+ * Low-level logging call.
+ * @param bufID The buffer ID to receive the message.
+ * @param priority The priority of the message.
+ * @param tag Used to identify the source of a log message. It usually identifies
+ * the class or activity where the log call occurs.
+ * @param msg The message you would like logged.
+ * @return A positive value if the message was loggable (see {@link #isLoggable}).
+ * @hide
+ */
@UnsupportedAppUsage
public static native int println_native(int bufID, int priority, String tag, String msg);
@@ -407,6 +433,7 @@
* @param tag Used to identify the source of a log message. It usually identifies
* the class or activity where the log call occurs.
* @param message The message you would like logged.
+ * @return A positive value if the message was loggable (see {@link #isLoggable}).
* @hide
*/
@SystemApi(client = SystemApi.Client.MODULE_LIBRARIES)
@@ -425,6 +452,7 @@
* Helper function for long messages. Uses the LineBreakBufferedWriter to break
* up long messages and stacktraces along newlines, but tries to write in large
* chunks. This is to avoid truncation.
+ * @return A positive value if the message was loggable (see {@link #isLoggable}).
* @hide
*/
public static int printlns(int bufID, int priority, @Nullable String tag, @NonNull String msg,
diff --git a/core/java/android/util/TEST_MAPPING b/core/java/android/util/TEST_MAPPING
new file mode 100644
index 0000000..0ae1c15
--- /dev/null
+++ b/core/java/android/util/TEST_MAPPING
@@ -0,0 +1,28 @@
+{
+ "presubmit": [
+ {
+ "name": "FrameworksCoreTests",
+ "options": [
+ {
+ "include-filter": "android.util.CharsetUtilsTest"
+ },
+ {
+ "include-filter": "com.android.internal.util.FastDataTest"
+ }
+ ],
+ "file_patterns": ["CharsetUtils|FastData"]
+ },
+ {
+ "name": "FrameworksCoreTests",
+ "options": [
+ {
+ "include-filter": "android.util.XmlTest"
+ },
+ {
+ "include-filter": "android.util.BinaryXmlTest"
+ }
+ ],
+ "file_patterns": ["Xml"]
+ }
+ ]
+}
diff --git a/core/java/android/view/View.java b/core/java/android/view/View.java
index ffa577a..271d7ba 100644
--- a/core/java/android/view/View.java
+++ b/core/java/android/view/View.java
@@ -12810,6 +12810,10 @@
/**
* Set if view is a heading for a section of content for accessibility purposes.
+ * <p>
+ * Users of some accessibility services can choose to navigate between headings
+ * instead of between paragraphs, words, etc. Apps that provide headings on
+ * sections of text can help the text navigation experience.
*
* @param isHeading {@code true} if the view is a heading, {@code false} otherwise.
*
diff --git a/core/java/com/android/internal/util/BinaryXmlPullParser.java b/core/java/com/android/internal/util/BinaryXmlPullParser.java
index 57552f3..d3abac9 100644
--- a/core/java/com/android/internal/util/BinaryXmlPullParser.java
+++ b/core/java/com/android/internal/util/BinaryXmlPullParser.java
@@ -73,12 +73,6 @@
* </ul>
*/
public final class BinaryXmlPullParser implements TypedXmlPullParser {
- /**
- * Default buffer size, which matches {@code FastXmlSerializer}. This should
- * be kept in sync with {@link BinaryXmlPullParser}.
- */
- private static final int BUFFER_SIZE = 32_768;
-
private FastDataInput mIn;
private int mCurrentToken = START_DOCUMENT;
@@ -100,7 +94,12 @@
throw new UnsupportedOperationException();
}
- mIn = new FastDataInput(is, BUFFER_SIZE);
+ if (mIn != null) {
+ mIn.release();
+ mIn = null;
+ }
+
+ mIn = FastDataInput.obtainUsing4ByteSequences(is);
mCurrentToken = START_DOCUMENT;
mCurrentDepth = 0;
diff --git a/core/java/com/android/internal/util/BinaryXmlSerializer.java b/core/java/com/android/internal/util/BinaryXmlSerializer.java
index 9df4bdb..485430a 100644
--- a/core/java/com/android/internal/util/BinaryXmlSerializer.java
+++ b/core/java/com/android/internal/util/BinaryXmlSerializer.java
@@ -91,12 +91,6 @@
static final int TYPE_BOOLEAN_TRUE = 12 << 4;
static final int TYPE_BOOLEAN_FALSE = 13 << 4;
- /**
- * Default buffer size, which matches {@code FastXmlSerializer}. This should
- * be kept in sync with {@link BinaryXmlPullParser}.
- */
- private static final int BUFFER_SIZE = 32_768;
-
private FastDataOutput mOut;
/**
@@ -124,7 +118,7 @@
throw new UnsupportedOperationException();
}
- mOut = new FastDataOutput(os, BUFFER_SIZE);
+ mOut = FastDataOutput.obtainUsing4ByteSequences(os);
mOut.write(PROTOCOL_MAGIC_VERSION_0);
mTagCount = 0;
@@ -138,7 +132,9 @@
@Override
public void flush() throws IOException {
- mOut.flush();
+ if (mOut != null) {
+ mOut.flush();
+ }
}
@Override
@@ -157,6 +153,9 @@
public void endDocument() throws IOException {
mOut.writeByte(END_DOCUMENT | TYPE_NULL);
flush();
+
+ mOut.release();
+ mOut = null;
}
@Override
diff --git a/core/java/com/android/internal/util/FastDataInput.java b/core/java/com/android/internal/util/FastDataInput.java
index f8d241b..5117034 100644
--- a/core/java/com/android/internal/util/FastDataInput.java
+++ b/core/java/com/android/internal/util/FastDataInput.java
@@ -30,6 +30,7 @@
import java.io.InputStream;
import java.util.Arrays;
import java.util.Objects;
+import java.util.concurrent.atomic.AtomicReference;
/**
* Optimized implementation of {@link DataInput} which buffers data in memory
@@ -41,13 +42,18 @@
public class FastDataInput implements DataInput, Closeable {
private static final int MAX_UNSIGNED_SHORT = 65_535;
+ private static final int DEFAULT_BUFFER_SIZE = 32_768;
+
+ private static AtomicReference<FastDataInput> sInCache = new AtomicReference<>();
+
private final VMRuntime mRuntime;
- private final InputStream mIn;
private final byte[] mBuffer;
private final long mBufferPtr;
private final int mBufferCap;
+ private final boolean mUse4ByteSequence;
+ private InputStream mIn;
private int mBufferPos;
private int mBufferLim;
@@ -57,7 +63,18 @@
private int mStringRefCount = 0;
private String[] mStringRefs = new String[32];
+ /**
+ * @deprecated callers must specify {@code use4ByteSequence} so they make a
+ * clear choice about working around a long-standing ART bug, as
+ * described by the {@code kUtfUse4ByteSequence} comments in
+ * {@code art/runtime/jni/jni_internal.cc}.
+ */
+ @Deprecated
public FastDataInput(@NonNull InputStream in, int bufferSize) {
+ this(in, bufferSize, true /* use4ByteSequence */);
+ }
+
+ public FastDataInput(@NonNull InputStream in, int bufferSize, boolean use4ByteSequence) {
mRuntime = VMRuntime.getRuntime();
mIn = Objects.requireNonNull(in);
if (bufferSize < 8) {
@@ -67,6 +84,64 @@
mBuffer = (byte[]) mRuntime.newNonMovableArray(byte.class, bufferSize);
mBufferPtr = mRuntime.addressOf(mBuffer);
mBufferCap = mBuffer.length;
+ mUse4ByteSequence = use4ByteSequence;
+ }
+
+ /**
+ * Obtain a {@link FastDataInput} configured with the given
+ * {@link InputStream} and which encodes large code-points using 3-byte
+ * sequences.
+ * <p>
+ * This <em>is</em> compatible with the {@link DataInput} API contract,
+ * which specifies that large code-points must be encoded with 3-byte
+ * sequences.
+ */
+ public static FastDataInput obtainUsing3ByteSequences(@NonNull InputStream in) {
+ return new FastDataInput(in, DEFAULT_BUFFER_SIZE, false /* use4ByteSequence */);
+ }
+
+ /**
+ * Obtain a {@link FastDataInput} configured with the given
+ * {@link InputStream} and which decodes large code-points using 4-byte
+ * sequences.
+ * <p>
+ * This <em>is not</em> compatible with the {@link DataInput} API contract,
+ * which specifies that large code-points must be encoded with 3-byte
+ * sequences.
+ */
+ public static FastDataInput obtainUsing4ByteSequences(@NonNull InputStream in) {
+ FastDataInput instance = sInCache.getAndSet(null);
+ if (instance != null) {
+ instance.setInput(in);
+ return instance;
+ }
+ return new FastDataInput(in, DEFAULT_BUFFER_SIZE, true /* use4ByteSequence */);
+ }
+
+ /**
+ * Release a {@link FastDataInput} to potentially be recycled. You must not
+ * interact with the object after releasing it.
+ */
+ public void release() {
+ mIn = null;
+ mBufferPos = 0;
+ mBufferLim = 0;
+ mStringRefCount = 0;
+
+ if (mBufferCap == DEFAULT_BUFFER_SIZE && mUse4ByteSequence) {
+ // Try to return to the cache.
+ sInCache.compareAndSet(null, this);
+ }
+ }
+
+ /**
+ * Re-initializes the object for the new input.
+ */
+ private void setInput(@NonNull InputStream in) {
+ mIn = Objects.requireNonNull(in);
+ mBufferPos = 0;
+ mBufferLim = 0;
+ mStringRefCount = 0;
}
private void fill(int need) throws IOException {
@@ -90,6 +165,7 @@
@Override
public void close() throws IOException {
mIn.close();
+ release();
}
@Override
@@ -126,6 +202,14 @@
@Override
public String readUTF() throws IOException {
+ if (mUse4ByteSequence) {
+ return readUTFUsing4ByteSequences();
+ } else {
+ return readUTFUsing3ByteSequences();
+ }
+ }
+
+ private String readUTFUsing4ByteSequences() throws IOException {
// Attempt to read directly from buffer space if there's enough room,
// otherwise fall back to chunking into place
final int len = readUnsignedShort();
@@ -141,6 +225,22 @@
}
}
+ private String readUTFUsing3ByteSequences() throws IOException {
+ // Attempt to read directly from buffer space if there's enough room,
+ // otherwise fall back to chunking into place
+ final int len = readUnsignedShort();
+ if (mBufferCap > len) {
+ if (mBufferLim - mBufferPos < len) fill(len);
+ final String res = ModifiedUtf8.decode(mBuffer, new char[len], mBufferPos, len);
+ mBufferPos += len;
+ return res;
+ } else {
+ final byte[] tmp = (byte[]) mRuntime.newNonMovableArray(byte.class, len + 1);
+ readFully(tmp, 0, len);
+ return ModifiedUtf8.decode(tmp, new char[len], 0, len);
+ }
+ }
+
/**
* Read a {@link String} value with the additional signal that the given
* value is a candidate for being canonicalized, similar to
diff --git a/core/java/com/android/internal/util/FastDataOutput.java b/core/java/com/android/internal/util/FastDataOutput.java
index cf5b296..c9e8f8f 100644
--- a/core/java/com/android/internal/util/FastDataOutput.java
+++ b/core/java/com/android/internal/util/FastDataOutput.java
@@ -30,6 +30,7 @@
import java.io.OutputStream;
import java.util.HashMap;
import java.util.Objects;
+import java.util.concurrent.atomic.AtomicReference;
/**
* Optimized implementation of {@link DataOutput} which buffers data in memory
@@ -41,23 +42,38 @@
public class FastDataOutput implements DataOutput, Flushable, Closeable {
private static final int MAX_UNSIGNED_SHORT = 65_535;
+ private static final int DEFAULT_BUFFER_SIZE = 32_768;
+
+ private static AtomicReference<FastDataOutput> sOutCache = new AtomicReference<>();
+
private final VMRuntime mRuntime;
- private final OutputStream mOut;
private final byte[] mBuffer;
private final long mBufferPtr;
private final int mBufferCap;
+ private final boolean mUse4ByteSequence;
+ private OutputStream mOut;
private int mBufferPos;
/**
* Values that have been "interned" by {@link #writeInternedUTF(String)}.
*/
- private HashMap<String, Short> mStringRefs = new HashMap<>();
+ private final HashMap<String, Short> mStringRefs = new HashMap<>();
+ /**
+ * @deprecated callers must specify {@code use4ByteSequence} so they make a
+ * clear choice about working around a long-standing ART bug, as
+ * described by the {@code kUtfUse4ByteSequence} comments in
+ * {@code art/runtime/jni/jni_internal.cc}.
+ */
+ @Deprecated
public FastDataOutput(@NonNull OutputStream out, int bufferSize) {
+ this(out, bufferSize, true /* use4ByteSequence */);
+ }
+
+ public FastDataOutput(@NonNull OutputStream out, int bufferSize, boolean use4ByteSequence) {
mRuntime = VMRuntime.getRuntime();
- mOut = Objects.requireNonNull(out);
if (bufferSize < 8) {
throw new IllegalArgumentException();
}
@@ -65,6 +81,68 @@
mBuffer = (byte[]) mRuntime.newNonMovableArray(byte.class, bufferSize);
mBufferPtr = mRuntime.addressOf(mBuffer);
mBufferCap = mBuffer.length;
+ mUse4ByteSequence = use4ByteSequence;
+
+ setOutput(out);
+ }
+
+ /**
+ * Obtain a {@link FastDataOutput} configured with the given
+ * {@link OutputStream} and which encodes large code-points using 3-byte
+ * sequences.
+ * <p>
+ * This <em>is</em> compatible with the {@link DataOutput} API contract,
+ * which specifies that large code-points must be encoded with 3-byte
+ * sequences.
+ */
+ public static FastDataOutput obtainUsing3ByteSequences(@NonNull OutputStream out) {
+ return new FastDataOutput(out, DEFAULT_BUFFER_SIZE, false /* use4ByteSequence */);
+ }
+
+ /**
+ * Obtain a {@link FastDataOutput} configured with the given
+ * {@link OutputStream} and which encodes large code-points using 4-byte
+ * sequences.
+ * <p>
+ * This <em>is not</em> compatible with the {@link DataOutput} API contract,
+ * which specifies that large code-points must be encoded with 3-byte
+ * sequences.
+ */
+ public static FastDataOutput obtainUsing4ByteSequences(@NonNull OutputStream out) {
+ FastDataOutput instance = sOutCache.getAndSet(null);
+ if (instance != null) {
+ instance.setOutput(out);
+ return instance;
+ }
+ return new FastDataOutput(out, DEFAULT_BUFFER_SIZE, true /* use4ByteSequence */);
+ }
+
+ /**
+ * Release a {@link FastDataOutput} to potentially be recycled. You must not
+ * interact with the object after releasing it.
+ */
+ public void release() {
+ if (mBufferPos > 0) {
+ throw new IllegalStateException("Lingering data, call flush() before releasing.");
+ }
+
+ mOut = null;
+ mBufferPos = 0;
+ mStringRefs.clear();
+
+ if (mBufferCap == DEFAULT_BUFFER_SIZE && mUse4ByteSequence) {
+ // Try to return to the cache.
+ sOutCache.compareAndSet(null, this);
+ }
+ }
+
+ /**
+ * Re-initializes the object for the new output.
+ */
+ private void setOutput(@NonNull OutputStream out) {
+ mOut = Objects.requireNonNull(out);
+ mBufferPos = 0;
+ mStringRefs.clear();
}
private void drain() throws IOException {
@@ -83,6 +161,7 @@
@Override
public void close() throws IOException {
mOut.close();
+ release();
}
@Override
@@ -109,6 +188,14 @@
@Override
public void writeUTF(String s) throws IOException {
+ if (mUse4ByteSequence) {
+ writeUTFUsing4ByteSequences(s);
+ } else {
+ writeUTFUsing3ByteSequences(s);
+ }
+ }
+
+ private void writeUTFUsing4ByteSequences(String s) throws IOException {
// Attempt to write directly to buffer space if there's enough room,
// otherwise fall back to chunking into place
if (mBufferCap - mBufferPos < 2 + s.length()) drain();
@@ -136,6 +223,27 @@
}
}
+ private void writeUTFUsing3ByteSequences(String s) throws IOException {
+ final int len = (int) ModifiedUtf8.countBytes(s, false);
+ if (len > MAX_UNSIGNED_SHORT) {
+ throw new IOException("Modified UTF-8 length too large: " + len);
+ }
+
+ // Attempt to write directly to buffer space if there's enough room,
+ // otherwise fall back to chunking into place
+ if (mBufferCap >= 2 + len) {
+ if (mBufferCap - mBufferPos < 2 + len) drain();
+ writeShort(len);
+ ModifiedUtf8.encode(mBuffer, mBufferPos, s);
+ mBufferPos += len;
+ } else {
+ final byte[] tmp = (byte[]) mRuntime.newNonMovableArray(byte.class, len + 1);
+ ModifiedUtf8.encode(tmp, 0, s);
+ writeShort(len);
+ write(tmp, 0, len);
+ }
+ }
+
/**
* Write a {@link String} value with the additional signal that the given
* value is a candidate for being canonicalized, similar to
diff --git a/core/java/com/android/internal/util/ModifiedUtf8.java b/core/java/com/android/internal/util/ModifiedUtf8.java
new file mode 100644
index 0000000..a144c00
--- /dev/null
+++ b/core/java/com/android/internal/util/ModifiedUtf8.java
@@ -0,0 +1,110 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.internal.util;
+
+import java.io.UTFDataFormatException;
+
+public class ModifiedUtf8 {
+ /**
+ * Decodes a byte array containing <i>modified UTF-8</i> bytes into a string.
+ *
+ * <p>Note that although this method decodes the (supposedly impossible) zero byte to U+0000,
+ * that's what the RI does too.
+ */
+ public static String decode(byte[] in, char[] out, int offset, int utfSize)
+ throws UTFDataFormatException {
+ int count = 0, s = 0, a;
+ while (count < utfSize) {
+ if ((out[s] = (char) in[offset + count++]) < '\u0080') {
+ s++;
+ } else if (((a = out[s]) & 0xe0) == 0xc0) {
+ if (count >= utfSize) {
+ throw new UTFDataFormatException("bad second byte at " + count);
+ }
+ int b = in[offset + count++];
+ if ((b & 0xC0) != 0x80) {
+ throw new UTFDataFormatException("bad second byte at " + (count - 1));
+ }
+ out[s++] = (char) (((a & 0x1F) << 6) | (b & 0x3F));
+ } else if ((a & 0xf0) == 0xe0) {
+ if (count + 1 >= utfSize) {
+ throw new UTFDataFormatException("bad third byte at " + (count + 1));
+ }
+ int b = in[offset + count++];
+ int c = in[offset + count++];
+ if (((b & 0xC0) != 0x80) || ((c & 0xC0) != 0x80)) {
+ throw new UTFDataFormatException("bad second or third byte at " + (count - 2));
+ }
+ out[s++] = (char) (((a & 0x0F) << 12) | ((b & 0x3F) << 6) | (c & 0x3F));
+ } else {
+ throw new UTFDataFormatException("bad byte at " + (count - 1));
+ }
+ }
+ return new String(out, 0, s);
+ }
+
+ /**
+ * Returns the number of bytes the modified UTF-8 representation of 's' would take. Note
+ * that this is just the space for the bytes representing the characters, not the length
+ * which precedes those bytes, because different callers represent the length differently,
+ * as two, four, or even eight bytes. If {@code shortLength} is true, we'll throw an
+ * exception if the string is too long for its length to be represented by a short.
+ */
+ public static long countBytes(String s, boolean shortLength) throws UTFDataFormatException {
+ long result = 0;
+ final int length = s.length();
+ for (int i = 0; i < length; ++i) {
+ char ch = s.charAt(i);
+ if (ch != 0 && ch <= 127) { // U+0000 uses two bytes.
+ ++result;
+ } else if (ch <= 2047) {
+ result += 2;
+ } else {
+ result += 3;
+ }
+ if (shortLength && result > 65535) {
+ throw new UTFDataFormatException("String more than 65535 UTF bytes long");
+ }
+ }
+ return result;
+ }
+
+ /**
+ * Encodes the <i>modified UTF-8</i> bytes corresponding to string {@code s} into the
+ * byte array {@code dst}, starting at the given {@code offset}.
+ */
+ public static void encode(byte[] dst, int offset, String s) {
+ final int length = s.length();
+ for (int i = 0; i < length; i++) {
+ char ch = s.charAt(i);
+ if (ch != 0 && ch <= 127) { // U+0000 uses two bytes.
+ dst[offset++] = (byte) ch;
+ } else if (ch <= 2047) {
+ dst[offset++] = (byte) (0xc0 | (0x1f & (ch >> 6)));
+ dst[offset++] = (byte) (0x80 | (0x3f & ch));
+ } else {
+ dst[offset++] = (byte) (0xe0 | (0x0f & (ch >> 12)));
+ dst[offset++] = (byte) (0x80 | (0x3f & (ch >> 6)));
+ dst[offset++] = (byte) (0x80 | (0x3f & ch));
+ }
+ }
+ }
+
+ private ModifiedUtf8() {
+ }
+}
diff --git a/core/java/com/android/internal/util/TEST_MAPPING b/core/java/com/android/internal/util/TEST_MAPPING
index 5881c51..41d59bb 100644
--- a/core/java/com/android/internal/util/TEST_MAPPING
+++ b/core/java/com/android/internal/util/TEST_MAPPING
@@ -1,7 +1,20 @@
{
"presubmit": [
{
- "name": "ScreenshotHelperTests"
+ "name": "ScreenshotHelperTests",
+ "file_patterns": ["ScreenshotHelper"]
+ },
+ {
+ "name": "FrameworksCoreTests",
+ "options": [
+ {
+ "include-filter": "android.util.XmlTest"
+ },
+ {
+ "include-filter": "android.util.BinaryXmlTest"
+ }
+ ],
+ "file_patterns": ["Xml"]
}
]
-}
\ No newline at end of file
+}
diff --git a/core/jni/Android.bp b/core/jni/Android.bp
index 682dbc31..a60368b 100644
--- a/core/jni/Android.bp
+++ b/core/jni/Android.bp
@@ -50,6 +50,7 @@
"android_util_XmlBlock.cpp",
"android_util_jar_StrictJarFile.cpp",
"com_android_internal_util_VirtualRefBasePtr.cpp",
+ "core_jni_helpers.cpp",
":deviceproductinfoconstants_aidl",
],
diff --git a/core/jni/OWNERS b/core/jni/OWNERS
index 361988c..5915808 100644
--- a/core/jni/OWNERS
+++ b/core/jni/OWNERS
@@ -44,6 +44,7 @@
per-file EphemeralStorage* = file:platform/system/libhwbinder:/OWNERS
per-file *Zygote* = file:/ZYGOTE_OWNERS
+per-file core_jni_helpers.* = file:/ZYGOTE_OWNERS
per-file fd_utils.* = file:/ZYGOTE_OWNERS
per-file Android.bp = file:platform/build/soong:/OWNERS
per-file android_animation_* = file:/core/java/android/animation/OWNERS
diff --git a/core/jni/TEST_MAPPING b/core/jni/TEST_MAPPING
new file mode 100644
index 0000000..004c30e
--- /dev/null
+++ b/core/jni/TEST_MAPPING
@@ -0,0 +1,16 @@
+{
+ "presubmit": [
+ {
+ "name": "FrameworksCoreTests",
+ "options": [
+ {
+ "include-filter": "android.util.CharsetUtilsTest"
+ },
+ {
+ "include-filter": "com.android.internal.util.FastDataTest"
+ }
+ ],
+ "file_patterns": ["CharsetUtils|FastData"]
+ }
+ ]
+}
diff --git a/core/jni/android_hardware_SensorManager.cpp b/core/jni/android_hardware_SensorManager.cpp
index d0504fb..af0800a 100644
--- a/core/jni/android_hardware_SensorManager.cpp
+++ b/core/jni/android_hardware_SensorManager.cpp
@@ -332,7 +332,7 @@
virtual int handleEvent(int fd, int events, void* data) {
JNIEnv* env = AndroidRuntime::getJNIEnv();
sp<SensorEventQueue> q = reinterpret_cast<SensorEventQueue *>(data);
- ScopedLocalRef<jobject> receiverObj(env, jniGetReferent(env, mReceiverWeakGlobal));
+ ScopedLocalRef<jobject> receiverObj(env, GetReferent(env, mReceiverWeakGlobal));
ssize_t n;
ASensorEvent buffer[16];
diff --git a/core/jni/android_view_DisplayEventReceiver.cpp b/core/jni/android_view_DisplayEventReceiver.cpp
index ce772cf..c9d8ac0 100644
--- a/core/jni/android_view_DisplayEventReceiver.cpp
+++ b/core/jni/android_view_DisplayEventReceiver.cpp
@@ -102,7 +102,7 @@
uint32_t count, VsyncEventData vsyncEventData) {
JNIEnv* env = AndroidRuntime::getJNIEnv();
- ScopedLocalRef<jobject> receiverObj(env, jniGetReferent(env, mReceiverWeakGlobal));
+ ScopedLocalRef<jobject> receiverObj(env, GetReferent(env, mReceiverWeakGlobal));
if (receiverObj.get()) {
ALOGV("receiver %p ~ Invoking vsync handler.", this);
env->CallVoidMethod(receiverObj.get(), gDisplayEventReceiverClassInfo.dispatchVsync,
@@ -118,7 +118,7 @@
bool connected) {
JNIEnv* env = AndroidRuntime::getJNIEnv();
- ScopedLocalRef<jobject> receiverObj(env, jniGetReferent(env, mReceiverWeakGlobal));
+ ScopedLocalRef<jobject> receiverObj(env, GetReferent(env, mReceiverWeakGlobal));
if (receiverObj.get()) {
ALOGV("receiver %p ~ Invoking hotplug handler.", this);
env->CallVoidMethod(receiverObj.get(), gDisplayEventReceiverClassInfo.dispatchHotplug,
@@ -133,7 +133,7 @@
int32_t modeId, nsecs_t) {
JNIEnv* env = AndroidRuntime::getJNIEnv();
- ScopedLocalRef<jobject> receiverObj(env, jniGetReferent(env, mReceiverWeakGlobal));
+ ScopedLocalRef<jobject> receiverObj(env, GetReferent(env, mReceiverWeakGlobal));
if (receiverObj.get()) {
ALOGV("receiver %p ~ Invoking mode changed handler.", this);
env->CallVoidMethod(receiverObj.get(), gDisplayEventReceiverClassInfo.dispatchModeChanged,
@@ -148,7 +148,7 @@
nsecs_t timestamp, PhysicalDisplayId displayId, std::vector<FrameRateOverride> overrides) {
JNIEnv* env = AndroidRuntime::getJNIEnv();
- ScopedLocalRef<jobject> receiverObj(env, jniGetReferent(env, mReceiverWeakGlobal));
+ ScopedLocalRef<jobject> receiverObj(env, GetReferent(env, mReceiverWeakGlobal));
if (receiverObj.get()) {
ALOGV("receiver %p ~ Invoking FrameRateOverride handler.", this);
const auto frameRateOverrideClass =
diff --git a/core/jni/android_view_InputEventReceiver.cpp b/core/jni/android_view_InputEventReceiver.cpp
index 7d0f60a..9f2fd71 100644
--- a/core/jni/android_view_InputEventReceiver.cpp
+++ b/core/jni/android_view_InputEventReceiver.cpp
@@ -328,7 +328,7 @@
if (!skipCallbacks && !mBatchedInputEventPending && mInputConsumer.hasPendingBatch()) {
// There is a pending batch. Come back later.
if (!receiverObj.get()) {
- receiverObj.reset(jniGetReferent(env, mReceiverWeakGlobal));
+ receiverObj.reset(GetReferent(env, mReceiverWeakGlobal));
if (!receiverObj.get()) {
ALOGW("channel '%s' ~ Receiver object was finalized "
"without being disposed.",
@@ -357,7 +357,7 @@
if (!skipCallbacks) {
if (!receiverObj.get()) {
- receiverObj.reset(jniGetReferent(env, mReceiverWeakGlobal));
+ receiverObj.reset(GetReferent(env, mReceiverWeakGlobal));
if (!receiverObj.get()) {
ALOGW("channel '%s' ~ Receiver object was finalized "
"without being disposed.", getInputChannelName().c_str());
diff --git a/core/jni/android_view_InputEventSender.cpp b/core/jni/android_view_InputEventSender.cpp
index 16366a4..7ce54af 100644
--- a/core/jni/android_view_InputEventSender.cpp
+++ b/core/jni/android_view_InputEventSender.cpp
@@ -202,7 +202,7 @@
ALOGD("channel '%s' ~ Receiving finished signals.", getInputChannelName().c_str());
}
- ScopedLocalRef<jobject> senderObj(env, jniGetReferent(env, mSenderWeakGlobal));
+ ScopedLocalRef<jobject> senderObj(env, GetReferent(env, mSenderWeakGlobal));
if (!senderObj.get()) {
ALOGW("channel '%s' ~ Sender object was finalized without being disposed.",
getInputChannelName().c_str());
diff --git a/core/jni/android_view_InputQueue.cpp b/core/jni/android_view_InputQueue.cpp
index 70a9be7..244b895 100644
--- a/core/jni/android_view_InputQueue.cpp
+++ b/core/jni/android_view_InputQueue.cpp
@@ -135,7 +135,7 @@
switch(message.what) {
case MSG_FINISH_INPUT:
JNIEnv* env = AndroidRuntime::getJNIEnv();
- ScopedLocalRef<jobject> inputQueueObj(env, jniGetReferent(env, mInputQueueWeakGlobal));
+ ScopedLocalRef<jobject> inputQueueObj(env, GetReferent(env, mInputQueueWeakGlobal));
if (!inputQueueObj.get()) {
ALOGW("InputQueue was finalized without being disposed");
return;
diff --git a/core/jni/com_android_internal_content_NativeLibraryHelper.cpp b/core/jni/com_android_internal_content_NativeLibraryHelper.cpp
index ef6fd7d..be82879 100644
--- a/core/jni/com_android_internal_content_NativeLibraryHelper.cpp
+++ b/core/jni/com_android_internal_content_NativeLibraryHelper.cpp
@@ -36,7 +36,6 @@
#include <inttypes.h>
#include <sys/stat.h>
#include <sys/types.h>
-#include <linux/fs.h>
#include <memory>
@@ -254,16 +253,6 @@
return INSTALL_FAILED_CONTAINER_ERROR;
}
- // If a filesystem like f2fs supports per-file compression, set the compression bit before data
- // writes
- unsigned int flags;
- if (ioctl(fd, FS_IOC_GETFLAGS, &flags) == -1) {
- ALOGE("Failed to call FS_IOC_GETFLAGS on %s: %s\n", localTmpFileName, strerror(errno));
- } else if ((flags & FS_COMPR_FL) == 0) {
- flags |= FS_COMPR_FL;
- ioctl(fd, FS_IOC_SETFLAGS, &flags);
- }
-
if (!zipFile->uncompressEntry(zipEntry, fd)) {
ALOGE("Failed uncompressing %s to %s\n", fileName, localTmpFileName);
close(fd);
diff --git a/core/jni/core_jni_helpers.cpp b/core/jni/core_jni_helpers.cpp
new file mode 100644
index 0000000..b65053b
--- /dev/null
+++ b/core/jni/core_jni_helpers.cpp
@@ -0,0 +1,35 @@
+/*
+ * Copyright (C) 2022 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "core_jni_helpers.h"
+
+namespace android {
+
+namespace {
+
+jmethodID gGetReferent = nullptr;
+
+} // namespace
+
+jobject GetReferent(JNIEnv* env, jobject ref) {
+ if (gGetReferent == nullptr) {
+ jclass clazz = FindClassOrDie(env, "java/lang/ref/Reference");
+ gGetReferent = GetMethodIDOrDie(env, clazz, "get", "()Ljava/lang/Object;");
+ }
+ return env->CallObjectMethod(ref, gGetReferent);
+}
+
+} // namespace android
\ No newline at end of file
diff --git a/core/jni/core_jni_helpers.h b/core/jni/core_jni_helpers.h
index 5268049..b85a425 100644
--- a/core/jni/core_jni_helpers.h
+++ b/core/jni/core_jni_helpers.h
@@ -90,11 +90,10 @@
return res;
}
-static inline jobject jniGetReferent(JNIEnv* env, jobject ref) {
- jclass cls = FindClassOrDie(env, "java/lang/ref/Reference");
- jmethodID get = GetMethodIDOrDie(env, cls, "get", "()Ljava/lang/Object;");
- return env->CallObjectMethod(ref, get);
-}
+/**
+ * Returns the result of invoking java.lang.ref.Reference.get() on a Reference object.
+ */
+jobject GetReferent(JNIEnv* env, jobject ref);
/**
* Read the specified field from jobject, and convert to std::string.
diff --git a/core/tests/coretests/src/android/net/NetworkPolicyTest.kt b/core/tests/coretests/src/android/net/NetworkPolicyTest.kt
index 6360a2d..3ab7fa9 100644
--- a/core/tests/coretests/src/android/net/NetworkPolicyTest.kt
+++ b/core/tests/coretests/src/android/net/NetworkPolicyTest.kt
@@ -22,7 +22,6 @@
import android.net.NetworkTemplate.MATCH_ETHERNET
import android.net.NetworkTemplate.MATCH_MOBILE
import android.net.NetworkTemplate.MATCH_WIFI
-import android.text.format.Time.TIMEZONE_UTC
import androidx.test.runner.AndroidJUnit4
import org.junit.Test
import org.junit.runner.RunWith
@@ -57,7 +56,7 @@
}
private fun createTestPolicyForTemplate(template: NetworkTemplate): NetworkPolicy {
- return NetworkPolicy(template, NetworkPolicy.buildRule(5, ZoneId.of(TIMEZONE_UTC)),
+ return NetworkPolicy(template, NetworkPolicy.buildRule(5, ZoneId.of("UTC")),
NetworkPolicy.WARNING_DISABLED, NetworkPolicy.LIMIT_DISABLED,
NetworkPolicy.SNOOZE_NEVER, NetworkPolicy.SNOOZE_NEVER, NetworkPolicy.SNOOZE_NEVER,
/*metered*/ false, /*inferred*/ true)
diff --git a/core/tests/coretests/src/android/util/XmlTest.java b/core/tests/coretests/src/android/util/XmlTest.java
index 4e10ea9..1cd4d13 100644
--- a/core/tests/coretests/src/android/util/XmlTest.java
+++ b/core/tests/coretests/src/android/util/XmlTest.java
@@ -224,7 +224,7 @@
doVerifyRead(in);
}
- private static final String TEST_STRING = "com.example";
+ private static final String TEST_STRING = "com☃example😀typical☃package😀name";
private static final String TEST_STRING_EMPTY = "";
private static final byte[] TEST_BYTES = new byte[] { 0, 1, 2, 3, 4, 3, 2, 1, 0 };
private static final byte[] TEST_BYTES_EMPTY = new byte[0];
diff --git a/core/tests/coretests/src/com/android/internal/util/FastDataTest.java b/core/tests/coretests/src/com/android/internal/util/FastDataTest.java
index 81fb39f..04dfd6e 100644
--- a/core/tests/coretests/src/com/android/internal/util/FastDataTest.java
+++ b/core/tests/coretests/src/com/android/internal/util/FastDataTest.java
@@ -23,10 +23,13 @@
import android.annotation.NonNull;
import android.util.ExceptionUtils;
-import androidx.test.ext.junit.runners.AndroidJUnit4;
+import libcore.util.HexEncoding;
+import org.junit.Assume;
import org.junit.Test;
import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+import org.junit.runners.Parameterized.Parameters;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
@@ -38,22 +41,34 @@
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.util.Arrays;
+import java.util.Collection;
import java.util.function.Consumer;
-@RunWith(AndroidJUnit4.class)
+@RunWith(Parameterized.class)
public class FastDataTest {
+ private final boolean use4ByteSequence;
+
private static final String TEST_SHORT_STRING = "a";
- private static final String TEST_LONG_STRING = "com☃example☃typical☃package☃name";
+ private static final String TEST_LONG_STRING = "com☃example😀typical☃package😀name";
private static final byte[] TEST_BYTES = TEST_LONG_STRING.getBytes(StandardCharsets.UTF_16LE);
+ @Parameters(name = "use4ByteSequence={0}")
+ public static Collection<Object[]> data() {
+ return Arrays.asList(new Object[][] { {true}, {false} });
+ }
+
+ public FastDataTest(boolean use4ByteSequence) {
+ this.use4ByteSequence = use4ByteSequence;
+ }
+
@Test
public void testEndOfFile_Int() throws Exception {
try (FastDataInput in = new FastDataInput(new ByteArrayInputStream(
- new byte[] { 1 }), 1000)) {
+ new byte[] { 1 }), 1000, use4ByteSequence)) {
assertThrows(EOFException.class, () -> in.readInt());
}
try (FastDataInput in = new FastDataInput(new ByteArrayInputStream(
- new byte[] { 1, 1, 1, 1 }), 1000)) {
+ new byte[] { 1, 1, 1, 1 }), 1000, use4ByteSequence)) {
assertEquals(1, in.readByte());
assertThrows(EOFException.class, () -> in.readInt());
}
@@ -62,11 +77,11 @@
@Test
public void testEndOfFile_String() throws Exception {
try (FastDataInput in = new FastDataInput(new ByteArrayInputStream(
- new byte[] { 1 }), 1000)) {
+ new byte[] { 1 }), 1000, use4ByteSequence)) {
assertThrows(EOFException.class, () -> in.readUTF());
}
try (FastDataInput in = new FastDataInput(new ByteArrayInputStream(
- new byte[] { 1, 1, 1, 1 }), 1000)) {
+ new byte[] { 1, 1, 1, 1 }), 1000, use4ByteSequence)) {
assertThrows(EOFException.class, () -> in.readUTF());
}
}
@@ -74,12 +89,12 @@
@Test
public void testEndOfFile_Bytes_Small() throws Exception {
try (FastDataInput in = new FastDataInput(new ByteArrayInputStream(
- new byte[] { 1, 1, 1, 1 }), 1000)) {
+ new byte[] { 1, 1, 1, 1 }), 1000, use4ByteSequence)) {
final byte[] tmp = new byte[10];
assertThrows(EOFException.class, () -> in.readFully(tmp));
}
try (FastDataInput in = new FastDataInput(new ByteArrayInputStream(
- new byte[] { 1, 1, 1, 1 }), 1000)) {
+ new byte[] { 1, 1, 1, 1 }), 1000, use4ByteSequence)) {
final byte[] tmp = new byte[10_000];
assertThrows(EOFException.class, () -> in.readFully(tmp));
}
@@ -88,7 +103,8 @@
@Test
public void testUTF_Bounds() throws Exception {
final char[] buf = new char[65_534];
- try (FastDataOutput out = new FastDataOutput(new ByteArrayOutputStream(), BOUNCE_SIZE)) {
+ try (FastDataOutput out = new FastDataOutput(new ByteArrayOutputStream(),
+ BOUNCE_SIZE, use4ByteSequence)) {
// Writing simple string will fit fine
Arrays.fill(buf, '!');
final String simple = new String(buf);
@@ -100,11 +116,15 @@
final String complex = new String(buf);
assertThrows(IOException.class, () -> out.writeUTF(complex));
assertThrows(IOException.class, () -> out.writeInternedUTF(complex));
+
+ out.flush();
}
}
@Test
public void testTranscode() throws Exception {
+ Assume.assumeFalse(use4ByteSequence);
+
// Verify that upstream data can be read by fast
{
final ByteArrayOutputStream outStream = new ByteArrayOutputStream();
@@ -113,20 +133,22 @@
out.flush();
final FastDataInput in = new FastDataInput(
- new ByteArrayInputStream(outStream.toByteArray()), BOUNCE_SIZE);
- doTransodeRead(in);
+ new ByteArrayInputStream(outStream.toByteArray()),
+ BOUNCE_SIZE, use4ByteSequence);
+ doTranscodeRead(in);
}
// Verify that fast data can be read by upstream
{
final ByteArrayOutputStream outStream = new ByteArrayOutputStream();
- final FastDataOutput out = new FastDataOutput(outStream, BOUNCE_SIZE);
+ final FastDataOutput out = new FastDataOutput(outStream,
+ BOUNCE_SIZE, use4ByteSequence);
doTranscodeWrite(out);
out.flush();
final DataInputStream in = new DataInputStream(
new ByteArrayInputStream(outStream.toByteArray()));
- doTransodeRead(in);
+ doTranscodeRead(in);
}
}
@@ -144,7 +166,7 @@
out.writeDouble(32d);
}
- private static void doTransodeRead(DataInput in) throws IOException {
+ private static void doTranscodeRead(DataInput in) throws IOException {
assertEquals(true, in.readBoolean());
assertEquals(false, in.readBoolean());
assertEquals(1, in.readByte());
@@ -225,10 +247,12 @@
doBounce((out) -> {
out.writeUTF("");
out.writeUTF("☃");
+ out.writeUTF("😀");
out.writeUTF("example");
}, (in) -> {
assertEquals("", in.readUTF());
assertEquals("☃", in.readUTF());
+ assertEquals("😀", in.readUTF());
assertEquals("example", in.readUTF());
});
}
@@ -263,6 +287,35 @@
}, 1);
}
+ /**
+ * Verify that we encode every valid code-point identically to RI when
+ * running in 3-byte mode.
+ */
+ @Test
+ public void testBounce_UTF_Exhaustive() throws Exception {
+ Assume.assumeFalse(use4ByteSequence);
+
+ final ByteArrayOutputStream slowStream = new ByteArrayOutputStream();
+ final DataOutput slowData = new DataOutputStream(slowStream);
+
+ final ByteArrayOutputStream fastStream = new ByteArrayOutputStream();
+ final FastDataOutput fastData = FastDataOutput.obtainUsing3ByteSequences(fastStream);
+
+ for (int cp = Character.MIN_CODE_POINT; cp < Character.MAX_CODE_POINT; cp++) {
+ if (Character.isValidCodePoint(cp)) {
+ final String cpString = new String(Character.toChars(cp));
+ slowStream.reset();
+ slowData.writeUTF(cpString);
+ fastStream.reset();
+ fastData.writeUTF(cpString);
+ fastData.flush();
+ assertEquals("Bad encoding for code-point " + Integer.toHexString(cp),
+ HexEncoding.encodeToString(slowStream.toByteArray()),
+ HexEncoding.encodeToString(fastStream.toByteArray()));
+ }
+ }
+ }
+
@Test
public void testBounce_InternedUTF() throws Exception {
doBounce((out) -> {
@@ -355,22 +408,24 @@
* Verify that some common data can be written and read back, effectively
* "bouncing" it through a serialized representation.
*/
- private static void doBounce(@NonNull ThrowingConsumer<FastDataOutput> out,
+ private void doBounce(@NonNull ThrowingConsumer<FastDataOutput> out,
@NonNull ThrowingConsumer<FastDataInput> in) throws Exception {
doBounce(out, in, BOUNCE_REPEAT);
}
- private static void doBounce(@NonNull ThrowingConsumer<FastDataOutput> out,
+ private void doBounce(@NonNull ThrowingConsumer<FastDataOutput> out,
@NonNull ThrowingConsumer<FastDataInput> in, int count) throws Exception {
final ByteArrayOutputStream outStream = new ByteArrayOutputStream();
- final FastDataOutput outData = new FastDataOutput(outStream, BOUNCE_SIZE);
+ final FastDataOutput outData = new FastDataOutput(outStream,
+ BOUNCE_SIZE, use4ByteSequence);
for (int i = 0; i < count; i++) {
out.accept(outData);
}
outData.flush();
final ByteArrayInputStream inStream = new ByteArrayInputStream(outStream.toByteArray());
- final FastDataInput inData = new FastDataInput(inStream, BOUNCE_SIZE);
+ final FastDataInput inData = new FastDataInput(inStream,
+ BOUNCE_SIZE, use4ByteSequence);
for (int i = 0; i < count; i++) {
in.accept(inData);
}
diff --git a/data/etc/Android.bp b/data/etc/Android.bp
index dc07758..08ff452 100644
--- a/data/etc/Android.bp
+++ b/data/etc/Android.bp
@@ -71,14 +71,6 @@
}
prebuilt_etc {
- name: "privapp_whitelist_com.android.cellbroadcastreceiver",
- system_ext_specific: true,
- sub_dir: "permissions",
- src: "com.android.cellbroadcastreceiver.xml",
- filename_from_src: true,
-}
-
-prebuilt_etc {
name: "privapp_whitelist_com.android.contacts",
product_specific: true,
sub_dir: "permissions",
diff --git a/data/etc/com.android.cellbroadcastreceiver.xml b/data/etc/com.android.cellbroadcastreceiver.xml
deleted file mode 100644
index 01a28a8..0000000
--- a/data/etc/com.android.cellbroadcastreceiver.xml
+++ /dev/null
@@ -1,28 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
- ~ Copyright (C) 2020 The Android Open Source Project
- ~
- ~ Licensed under the Apache License, Version 2.0 (the "License");
- ~ you may not use this file except in compliance with the License.
- ~ You may obtain a copy of the License at
- ~
- ~ http://www.apache.org/licenses/LICENSE-2.0
- ~
- ~ Unless required by applicable law or agreed to in writing, software
- ~ distributed under the License is distributed on an "AS IS" BASIS,
- ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- ~ See the License for the specific language governing permissions and
- ~ limitations under the License
- -->
-<permissions>
- <privapp-permissions package="com.android.cellbroadcastreceiver">
- <permission name="android.permission.BROADCAST_CLOSE_SYSTEM_DIALOGS"/>
- <permission name="android.permission.INTERACT_ACROSS_USERS"/>
- <permission name="android.permission.MANAGE_USERS"/>
- <permission name="android.permission.MODIFY_PHONE_STATE"/>
- <permission name="android.permission.MODIFY_CELL_BROADCASTS"/>
- <permission name="android.permission.READ_PRIVILEGED_PHONE_STATE"/>
- <permission name="android.permission.RECEIVE_EMERGENCY_BROADCAST"/>
- <permission name="android.permission.START_ACTIVITIES_FROM_BACKGROUND"/>
- </privapp-permissions>
-</permissions>
diff --git a/data/etc/privapp-permissions-platform.xml b/data/etc/privapp-permissions-platform.xml
index fdc6e81..e345c8d 100644
--- a/data/etc/privapp-permissions-platform.xml
+++ b/data/etc/privapp-permissions-platform.xml
@@ -38,23 +38,6 @@
<permission name="android.permission.CRYPT_KEEPER"/>
</privapp-permissions>
- <privapp-permissions package="com.android.cellbroadcastreceiver.module">
- <permission name="android.permission.BROADCAST_CLOSE_SYSTEM_DIALOGS"/>
- <permission name="android.permission.INTERACT_ACROSS_USERS"/>
- <permission name="android.permission.MANAGE_USERS"/>
- <permission name="android.permission.MODIFY_PHONE_STATE"/>
- <permission name="android.permission.MODIFY_CELL_BROADCASTS"/>
- <permission name="android.permission.READ_PRIVILEGED_PHONE_STATE"/>
- <permission name="android.permission.RECEIVE_EMERGENCY_BROADCAST"/>
- <permission name="android.permission.START_ACTIVITIES_FROM_BACKGROUND"/>
- </privapp-permissions>
-
- <privapp-permissions package="com.android.cellbroadcastservice">
- <permission name="android.permission.MODIFY_PHONE_STATE"/>
- <permission name="android.permission.READ_PRIVILEGED_PHONE_STATE"/>
- <permission name="android.permission.RECEIVE_EMERGENCY_BROADCAST"/>
- </privapp-permissions>
-
<privapp-permissions package="com.android.externalstorage">
<permission name="android.permission.MOUNT_UNMOUNT_FILESYSTEMS"/>
<permission name="android.permission.WRITE_MEDIA_STORAGE"/>
diff --git a/graphics/java/android/graphics/Bitmap.java b/graphics/java/android/graphics/Bitmap.java
index 055e5ad..ad089b6 100644
--- a/graphics/java/android/graphics/Bitmap.java
+++ b/graphics/java/android/graphics/Bitmap.java
@@ -519,7 +519,7 @@
ARGB_8888 (5),
/**
- * Each pixels is stored on 8 bytes. Each channel (RGB and alpha
+ * Each pixel is stored on 8 bytes. Each channel (RGB and alpha
* for translucency) is stored as a
* {@link android.util.Half half-precision floating point value}.
*
diff --git a/identity/java/android/security/identity/Util.java b/identity/java/android/security/identity/Util.java
index e56bd51..789ff06 100644
--- a/identity/java/android/security/identity/Util.java
+++ b/identity/java/android/security/identity/Util.java
@@ -20,12 +20,12 @@
import java.io.ByteArrayOutputStream;
import java.io.IOException;
+import java.math.BigInteger;
import java.security.InvalidKeyException;
import java.security.NoSuchAlgorithmException;
import java.security.PublicKey;
import java.security.interfaces.ECPublicKey;
import java.security.spec.ECPoint;
-import java.util.Collection;
import javax.crypto.Mac;
import javax.crypto.spec.SecretKeySpec;
@@ -36,15 +36,6 @@
public class Util {
private static final String TAG = "Util";
- static int[] integerCollectionToArray(Collection<Integer> collection) {
- int[] result = new int[collection.size()];
- int n = 0;
- for (int item : collection) {
- result[n++] = item;
- }
- return result;
- }
-
static byte[] stripLeadingZeroes(byte[] value) {
int n = 0;
while (n < value.length && value[n] == 0) {
@@ -61,15 +52,47 @@
static byte[] publicKeyEncodeUncompressedForm(PublicKey publicKey) {
ECPoint w = ((ECPublicKey) publicKey).getW();
- // X and Y are always positive so for interop we remove any leading zeroes
- // inserted by the BigInteger encoder.
- byte[] x = stripLeadingZeroes(w.getAffineX().toByteArray());
- byte[] y = stripLeadingZeroes(w.getAffineY().toByteArray());
+ BigInteger x = w.getAffineX();
+ BigInteger y = w.getAffineY();
+ if (x.compareTo(BigInteger.ZERO) < 0) {
+ throw new RuntimeException("X is negative");
+ }
+ if (y.compareTo(BigInteger.ZERO) < 0) {
+ throw new RuntimeException("Y is negative");
+ }
try {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
baos.write(0x04);
- baos.write(x);
- baos.write(y);
+
+ // Each coordinate may be encoded in 33*, 32, or fewer bytes.
+ //
+ // * : it can be 33 bytes because toByteArray() guarantees "The array will contain the
+ // minimum number of bytes required to represent this BigInteger, including at
+ // least one sign bit, which is (ceil((this.bitLength() + 1)/8))" which means that
+ // the MSB is always 0x00. This is taken care of by calling calling
+ // stripLeadingZeroes().
+ //
+ // We need the encoding to be exactly 32 bytes since according to RFC 5480 section 2.2
+ // and SEC 1: Elliptic Curve Cryptography section 2.3.3 the encoding is 0x04 | X | Y
+ // where X and Y are encoded in exactly 32 byte, big endian integer values each.
+ //
+ byte[] xBytes = stripLeadingZeroes(x.toByteArray());
+ if (xBytes.length > 32) {
+ throw new RuntimeException("xBytes is " + xBytes.length + " which is unexpected");
+ }
+ for (int n = 0; n < 32 - xBytes.length; n++) {
+ baos.write(0x00);
+ }
+ baos.write(xBytes);
+
+ byte[] yBytes = stripLeadingZeroes(y.toByteArray());
+ if (yBytes.length > 32) {
+ throw new RuntimeException("yBytes is " + yBytes.length + " which is unexpected");
+ }
+ for (int n = 0; n < 32 - yBytes.length; n++) {
+ baos.write(0x00);
+ }
+ baos.write(yBytes);
return baos.toByteArray();
} catch (IOException e) {
throw new RuntimeException("Unexpected IOException", e);
diff --git a/libs/WindowManager/OWNERS b/libs/WindowManager/OWNERS
index 780e4c1..2c61df9 100644
--- a/libs/WindowManager/OWNERS
+++ b/libs/WindowManager/OWNERS
@@ -1,6 +1,3 @@
set noparent
include /services/core/java/com/android/server/wm/OWNERS
-
-# Give submodule owners in shell resource approval
-per-file Shell/res*/*/*.xml = hwwang@google.com, lbill@google.com, madym@google.com
diff --git a/libs/WindowManager/Shell/OWNERS b/libs/WindowManager/Shell/OWNERS
new file mode 100644
index 0000000..4b12590
--- /dev/null
+++ b/libs/WindowManager/Shell/OWNERS
@@ -0,0 +1,4 @@
+xutan@google.com
+
+# Give submodule owners in shell resource approval
+per-file res*/*/*.xml = hwwang@google.com, lbill@google.com, madym@google.com
diff --git a/libs/incident/libincident.map.txt b/libs/incident/libincident.map.txt
index f157763..f75ccea 100644
--- a/libs/incident/libincident.map.txt
+++ b/libs/incident/libincident.map.txt
@@ -1,15 +1,15 @@
LIBINCIDENT {
global:
- AIncidentReportArgs_init; # apex # introduced=30
- AIncidentReportArgs_clone; # apex # introduced=30
- AIncidentReportArgs_delete; # apex # introduced=30
- AIncidentReportArgs_setAll; # apex # introduced=30
- AIncidentReportArgs_setPrivacyPolicy; # apex # introduced=30
- AIncidentReportArgs_addSection; # apex # introduced=30
- AIncidentReportArgs_setReceiverPackage; # apex # introduced=30
- AIncidentReportArgs_setReceiverClass; # apex # introduced=30
- AIncidentReportArgs_addHeader; # apex # introduced=30
- AIncidentReportArgs_takeReport; # apex # introduced=30
+ AIncidentReportArgs_init; # systemapi # introduced=30
+ AIncidentReportArgs_clone; # systemapi # introduced=30
+ AIncidentReportArgs_delete; # systemapi # introduced=30
+ AIncidentReportArgs_setAll; # systemapi # introduced=30
+ AIncidentReportArgs_setPrivacyPolicy; # systemapi # introduced=30
+ AIncidentReportArgs_addSection; # systemapi # introduced=30
+ AIncidentReportArgs_setReceiverPackage; # systemapi # introduced=30
+ AIncidentReportArgs_setReceiverClass; # systemapi # introduced=30
+ AIncidentReportArgs_addHeader; # systemapi # introduced=30
+ AIncidentReportArgs_takeReport; # systemapi # introduced=30
local:
*;
};
diff --git a/packages/BackupEncryption/test/robolectric/src/com/android/server/backup/encryption/tasks/EncryptedBackupTaskTest.java b/packages/BackupEncryption/test/robolectric/src/com/android/server/backup/encryption/tasks/EncryptedBackupTaskTest.java
index f6914ef..23d6e34 100644
--- a/packages/BackupEncryption/test/robolectric/src/com/android/server/backup/encryption/tasks/EncryptedBackupTaskTest.java
+++ b/packages/BackupEncryption/test/robolectric/src/com/android/server/backup/encryption/tasks/EncryptedBackupTaskTest.java
@@ -22,8 +22,8 @@
import static com.google.common.truth.Truth.assertThat;
-import static org.mockito.ArgumentMatchers.any;
-import static org.mockito.Matchers.eq;
+import static org.mockito.Mockito.any;
+import static org.mockito.Mockito.eq;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
diff --git a/packages/BackupEncryption/test/robolectric/src/com/android/server/backup/encryption/tasks/EncryptedFullBackupTaskTest.java b/packages/BackupEncryption/test/robolectric/src/com/android/server/backup/encryption/tasks/EncryptedFullBackupTaskTest.java
index 096b2da..bfc5d0d 100644
--- a/packages/BackupEncryption/test/robolectric/src/com/android/server/backup/encryption/tasks/EncryptedFullBackupTaskTest.java
+++ b/packages/BackupEncryption/test/robolectric/src/com/android/server/backup/encryption/tasks/EncryptedFullBackupTaskTest.java
@@ -18,9 +18,9 @@
import static com.google.common.truth.Truth.assertThat;
-import static org.mockito.ArgumentMatchers.any;
-import static org.mockito.Matchers.eq;
+import static org.mockito.Mockito.any;
import static org.mockito.Mockito.doAnswer;
+import static org.mockito.Mockito.eq;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import static org.testng.Assert.assertThrows;
diff --git a/packages/BackupEncryption/test/robolectric/src/com/android/server/backup/encryption/tasks/EncryptedKvBackupTaskTest.java b/packages/BackupEncryption/test/robolectric/src/com/android/server/backup/encryption/tasks/EncryptedKvBackupTaskTest.java
index fa4fef5..222b882 100644
--- a/packages/BackupEncryption/test/robolectric/src/com/android/server/backup/encryption/tasks/EncryptedKvBackupTaskTest.java
+++ b/packages/BackupEncryption/test/robolectric/src/com/android/server/backup/encryption/tasks/EncryptedKvBackupTaskTest.java
@@ -19,8 +19,8 @@
import static com.google.common.truth.Truth.assertThat;
import static com.google.common.truth.Truth.assertWithMessage;
-import static org.mockito.ArgumentMatchers.any;
-import static org.mockito.Matchers.eq;
+import static org.mockito.Mockito.any;
+import static org.mockito.Mockito.eq;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import static org.testng.Assert.assertFalse;
@@ -41,13 +41,6 @@
import com.android.server.backup.encryption.protos.nano.WrappedKeyProto;
import com.android.server.backup.testing.CryptoTestUtils;
-import java.io.IOException;
-import java.util.Arrays;
-import java.util.Map;
-import java.util.Map.Entry;
-
-import javax.crypto.SecretKey;
-
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
@@ -59,6 +52,14 @@
import org.mockito.MockitoAnnotations;
import org.robolectric.RobolectricTestRunner;
+import java.io.IOException;
+import java.util.Arrays;
+import java.util.Map;
+import java.util.Map.Entry;
+
+import javax.crypto.SecretKey;
+
+
@RunWith(RobolectricTestRunner.class)
public class EncryptedKvBackupTaskTest {
private static final boolean INCREMENTAL = true;
diff --git a/packages/SettingsLib/tests/robotests/src/com/android/settingslib/applications/ApplicationsStateRoboTest.java b/packages/SettingsLib/tests/robotests/src/com/android/settingslib/applications/ApplicationsStateRoboTest.java
index 5efce4d..30bbc2a 100644
--- a/packages/SettingsLib/tests/robotests/src/com/android/settingslib/applications/ApplicationsStateRoboTest.java
+++ b/packages/SettingsLib/tests/robotests/src/com/android/settingslib/applications/ApplicationsStateRoboTest.java
@@ -21,9 +21,10 @@
import static com.google.common.truth.Truth.assertThat;
import static org.mockito.ArgumentMatchers.eq;
-import static org.mockito.Matchers.any;
-import static org.mockito.Matchers.anyInt;
-import static org.mockito.Matchers.anyString;
+import static org.mockito.Mockito.any;
+import static org.mockito.Mockito.anyInt;
+import static org.mockito.Mockito.anyLong;
+import static org.mockito.Mockito.anyString;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.spy;
diff --git a/packages/SettingsLib/tests/robotests/src/com/android/settingslib/net/DataUsageUtilsTest.java b/packages/SettingsLib/tests/robotests/src/com/android/settingslib/net/DataUsageUtilsTest.java
index 95f7ef4..508dffc 100644
--- a/packages/SettingsLib/tests/robotests/src/com/android/settingslib/net/DataUsageUtilsTest.java
+++ b/packages/SettingsLib/tests/robotests/src/com/android/settingslib/net/DataUsageUtilsTest.java
@@ -18,7 +18,7 @@
import static com.google.common.truth.Truth.assertThat;
-import static org.mockito.Matchers.anyInt;
+import static org.mockito.Mockito.anyInt;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.when;
diff --git a/packages/SettingsLib/tests/robotests/src/com/android/settingslib/users/EditUserInfoControllerTest.java b/packages/SettingsLib/tests/robotests/src/com/android/settingslib/users/EditUserInfoControllerTest.java
index d6c8816..c190d07 100644
--- a/packages/SettingsLib/tests/robotests/src/com/android/settingslib/users/EditUserInfoControllerTest.java
+++ b/packages/SettingsLib/tests/robotests/src/com/android/settingslib/users/EditUserInfoControllerTest.java
@@ -22,7 +22,7 @@
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.verifyZeroInteractions;
+import static org.mockito.Mockito.verifyNoInteractions;
import static org.mockito.Mockito.when;
import android.app.Activity;
@@ -141,7 +141,7 @@
dialog.show();
dialog.cancel();
- verifyZeroInteractions(successCallback);
+ verifyNoInteractions(successCallback);
verify(cancelCallback, times(1))
.run();
}
@@ -157,7 +157,7 @@
dialog.show();
dialog.getButton(Dialog.BUTTON_NEGATIVE).performClick();
- verifyZeroInteractions(successCallback);
+ verifyNoInteractions(successCallback);
verify(cancelCallback, times(1))
.run();
}
@@ -178,7 +178,7 @@
verify(successCallback, times(1))
.accept("test", oldUserIcon);
- verifyZeroInteractions(cancelCallback);
+ verifyNoInteractions(cancelCallback);
}
@Test
@@ -196,7 +196,7 @@
verify(successCallback, times(1))
.accept("test", null);
- verifyZeroInteractions(cancelCallback);
+ verifyNoInteractions(cancelCallback);
}
@Test
@@ -217,7 +217,7 @@
verify(successCallback, times(1))
.accept(expectedNewName, mCurrentIcon);
- verifyZeroInteractions(cancelCallback);
+ verifyNoInteractions(cancelCallback);
}
@Test
@@ -236,7 +236,7 @@
verify(successCallback, times(1))
.accept("test", newPhoto);
- verifyZeroInteractions(cancelCallback);
+ verifyNoInteractions(cancelCallback);
}
@Test
@@ -255,7 +255,7 @@
verify(successCallback, times(1))
.accept("test", newPhoto);
- verifyZeroInteractions(cancelCallback);
+ verifyNoInteractions(cancelCallback);
}
@Test
diff --git a/packages/SettingsLib/tests/robotests/src/com/android/settingslib/widget/UpdatableListPreferenceDialogFragmentTest.java b/packages/SettingsLib/tests/robotests/src/com/android/settingslib/widget/UpdatableListPreferenceDialogFragmentTest.java
index 0b3495d..ca0aa0d 100644
--- a/packages/SettingsLib/tests/robotests/src/com/android/settingslib/widget/UpdatableListPreferenceDialogFragmentTest.java
+++ b/packages/SettingsLib/tests/robotests/src/com/android/settingslib/widget/UpdatableListPreferenceDialogFragmentTest.java
@@ -56,7 +56,7 @@
mUpdatableListPrefDlgFragment = spy(UpdatableListPreferenceDialogFragment
.newInstance(KEY, MetricsProto.MetricsEvent.DIALOG_SWITCH_A2DP_DEVICES));
- mEntries = spy(new ArrayList<>());
+ mEntries = new ArrayList<>();
mUpdatableListPrefDlgFragment.setEntries(mEntries);
mUpdatableListPrefDlgFragment
.setMetricsCategory(mUpdatableListPrefDlgFragment.getArguments());
diff --git a/rs/OWNERS b/rs/OWNERS
index 61853d3..fd03660 100644
--- a/rs/OWNERS
+++ b/rs/OWNERS
@@ -1,5 +1,2 @@
-butlermichael@google.com
-dgross@google.com
-jeanluc@google.com
-miaowang@google.com
-yangni@google.com
+# Bug component: 43047
+include platform/frameworks/rs:/RS_OWNERS # RenderScript team
diff --git a/sax/tests/saxtests/src/android/sax/SafeSaxTest.java b/sax/tests/saxtests/src/android/sax/SafeSaxTest.java
index e8cf2f7..a68fc9a 100644
--- a/sax/tests/saxtests/src/android/sax/SafeSaxTest.java
+++ b/sax/tests/saxtests/src/android/sax/SafeSaxTest.java
@@ -26,7 +26,6 @@
import android.test.AndroidTestCase;
import android.test.suitebuilder.annotation.LargeTest;
import android.test.suitebuilder.annotation.SmallTest;
-import android.text.format.Time;
import android.util.Log;
import android.util.Xml;
import com.android.internal.util.XmlUtils;
@@ -39,6 +38,7 @@
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
+import java.time.Instant;
import com.android.frameworks.saxtests.R;
@@ -225,8 +225,7 @@
.setEndTextElementListener(new EndTextElementListener() {
public void end(String body) {
// TODO(tomtaylor): programmatically get the timezone
- video.dateAdded = new Time(Time.TIMEZONE_UTC);
- video.dateAdded.parse3339(body);
+ video.dateAdded = Instant.parse(body);
}
});
@@ -472,8 +471,7 @@
if (uri.equals(ATOM_NAMESPACE)) {
if (localName.equals("published")) {
// TODO(tomtaylor): programmatically get the timezone
- video.dateAdded = new Time(Time.TIMEZONE_UTC);
- video.dateAdded.parse3339(takeText());
+ video.dateAdded = Instant.parse(takeText());
return;
}
@@ -532,7 +530,7 @@
public float rating; // ranges from 0.0 to 5.0
public Boolean triedToLoadThumbnail;
public String authorName;
- public Time dateAdded;
+ public Instant dateAdded;
public String category;
public String tags;
public String description;
diff --git a/services/core/java/com/android/server/StorageManagerService.java b/services/core/java/com/android/server/StorageManagerService.java
index 16c4880..0f67033 100644
--- a/services/core/java/com/android/server/StorageManagerService.java
+++ b/services/core/java/com/android/server/StorageManagerService.java
@@ -357,6 +357,8 @@
private static final boolean DEFAULT_CHARGING_REQUIRED = true;
// Minimum GC interval sleep time in ms
private static final int DEFAULT_MIN_GC_SLEEPTIME = 10000;
+ // Target dirty segment ratio to aim to
+ private static final int DEFAULT_TARGET_DIRTY_RATIO = 80;
private volatile int mLifetimePercentThreshold;
private volatile int mMinSegmentsThreshold;
@@ -365,6 +367,7 @@
private volatile float mLowBatteryLevel;
private volatile boolean mChargingRequired;
private volatile int mMinGCSleepTime;
+ private volatile int mTargetDirtyRatio;
private volatile boolean mNeedGC;
private volatile boolean mPassedLifetimeThresh;
@@ -2617,6 +2620,8 @@
"charging_required", DEFAULT_CHARGING_REQUIRED);
mMinGCSleepTime = DeviceConfig.getInt(DeviceConfig.NAMESPACE_STORAGE_NATIVE_BOOT,
"min_gc_sleeptime", DEFAULT_MIN_GC_SLEEPTIME);
+ mTargetDirtyRatio = DeviceConfig.getInt(DeviceConfig.NAMESPACE_STORAGE_NATIVE_BOOT,
+ "target_dirty_ratio", DEFAULT_TARGET_DIRTY_RATIO);
// If we use the smart idle maintenance, we need to turn off GC in the traditional idle
// maintenance to avoid the conflict
@@ -2757,10 +2762,11 @@
", dirty reclaim rate: " + mDirtyReclaimRate +
", segment reclaim weight: " + mSegmentReclaimWeight +
", period(min): " + sSmartIdleMaintPeriod +
- ", min gc sleep time(ms): " + mMinGCSleepTime);
+ ", min gc sleep time(ms): " + mMinGCSleepTime +
+ ", target dirty ratio: " + mTargetDirtyRatio);
mVold.setGCUrgentPace(avgWriteAmount, mMinSegmentsThreshold, mDirtyReclaimRate,
mSegmentReclaimWeight, sSmartIdleMaintPeriod,
- mMinGCSleepTime);
+ mMinGCSleepTime, mTargetDirtyRatio);
} else {
Slog.i(TAG, "Skipping smart idle maintenance - block based checkpoint in progress");
}
diff --git a/services/core/java/com/android/server/TelephonyRegistry.java b/services/core/java/com/android/server/TelephonyRegistry.java
index 481b53c..c751e1ed 100644
--- a/services/core/java/com/android/server/TelephonyRegistry.java
+++ b/services/core/java/com/android/server/TelephonyRegistry.java
@@ -2357,9 +2357,8 @@
return;
}
- if (VDBG) {
- log("notifyActiveDataSubIdChanged: activeDataSubId=" + activeDataSubId);
- }
+ log("notifyActiveDataSubIdChanged: activeDataSubId=" + activeDataSubId);
+ mLocalLog.log("notifyActiveDataSubIdChanged: activeDataSubId=" + activeDataSubId);
mActiveDataSubId = activeDataSubId;
synchronized (mRecords) {
diff --git a/services/core/java/com/android/server/audio/AudioDeviceBroker.java b/services/core/java/com/android/server/audio/AudioDeviceBroker.java
index 6ce7b1a..e03f3c11 100644
--- a/services/core/java/com/android/server/audio/AudioDeviceBroker.java
+++ b/services/core/java/com/android/server/audio/AudioDeviceBroker.java
@@ -642,6 +642,9 @@
audioDevice = AudioSystem.DEVICE_IN_BLE_HEADSET;
}
break;
+ case BluetoothProfile.LE_AUDIO_BROADCAST:
+ audioDevice = AudioSystem.DEVICE_OUT_BLE_BROADCAST;
+ break;
default: throw new IllegalArgumentException("Invalid profile " + d.mInfo.getProfile());
}
return new BtDeviceInfo(d, device, state, audioDevice, codec);
diff --git a/services/core/java/com/android/server/audio/AudioDeviceInventory.java b/services/core/java/com/android/server/audio/AudioDeviceInventory.java
index a3c6f0a..282714a 100644
--- a/services/core/java/com/android/server/audio/AudioDeviceInventory.java
+++ b/services/core/java/com/android/server/audio/AudioDeviceInventory.java
@@ -363,6 +363,7 @@
}
break;
case BluetoothProfile.LE_AUDIO:
+ case BluetoothProfile.LE_AUDIO_BROADCAST:
if (switchToUnavailable) {
makeLeAudioDeviceUnavailable(address, btInfo.mAudioSystemDevice);
} else if (switchToAvailable) {
@@ -814,7 +815,10 @@
disconnectHearingAid();
break;
case BluetoothProfile.LE_AUDIO:
- disconnectLeAudio();
+ disconnectLeAudioUnicast();
+ break;
+ case BluetoothProfile.LE_AUDIO_BROADCAST:
+ disconnectLeAudioBroadcast();
break;
default:
// Not a valid profile to disconnect
@@ -824,28 +828,39 @@
}
}
- /*package*/ void disconnectLeAudio() {
+ /*package*/ void disconnectLeAudio(int device) {
+ if (device != AudioSystem.DEVICE_OUT_BLE_HEADSET ||
+ device != AudioSystem.DEVICE_OUT_BLE_BROADCAST) {
+ Log.e(TAG, "disconnectLeAudio: Can't disconnect not LE Audio device " + device);
+ return;
+ }
+
synchronized (mDevicesLock) {
final ArraySet<String> toRemove = new ArraySet<>();
- // Disconnect ALL DEVICE_OUT_BLE_HEADSET devices
+ // Disconnect ALL DEVICE_OUT_BLE_HEADSET or DEVICE_OUT_BLE_BROADCAST devices
mConnectedDevices.values().forEach(deviceInfo -> {
- if (deviceInfo.mDeviceType == AudioSystem.DEVICE_OUT_BLE_HEADSET) {
+ if (deviceInfo.mDeviceType == device) {
toRemove.add(deviceInfo.mDeviceAddress);
}
});
new MediaMetrics.Item(mMetricsId + "disconnectLeAudio")
.record();
if (toRemove.size() > 0) {
- final int delay = checkSendBecomingNoisyIntentInt(
- AudioSystem.DEVICE_OUT_BLE_HEADSET, 0, AudioSystem.DEVICE_NONE);
toRemove.stream().forEach(deviceAddress ->
- makeLeAudioDeviceUnavailable(deviceAddress,
- AudioSystem.DEVICE_OUT_BLE_HEADSET)
+ makeLeAudioDeviceUnavailable(deviceAddress, device)
);
}
}
}
+ /*package*/ void disconnectLeAudioUnicast() {
+ disconnectLeAudio(AudioSystem.DEVICE_OUT_BLE_HEADSET);
+ }
+
+ /*package*/ void disconnectLeAudioBroadcast() {
+ disconnectLeAudio(AudioSystem.DEVICE_OUT_BLE_BROADCAST);
+ }
+
// must be called before removing the device from mConnectedDevices
// musicDevice argument is used when not AudioSystem.DEVICE_NONE instead of querying
// from AudioSystem
@@ -875,7 +890,9 @@
int delay;
synchronized (mDevicesLock) {
if (!info.mSupprNoisy
- && ((info.mProfile == BluetoothProfile.LE_AUDIO && info.mIsLeOutput)
+ && (((info.mProfile == BluetoothProfile.LE_AUDIO
+ || info.mProfile == BluetoothProfile.LE_AUDIO_BROADCAST)
+ && info.mIsLeOutput)
|| info.mProfile == BluetoothProfile.HEARING_AID
|| info.mProfile == BluetoothProfile.A2DP)) {
@AudioService.ConnectionState int asState =
@@ -1110,8 +1127,7 @@
return;
}
- final int leAudioVolIndex = mDeviceBroker.getVssVolumeForDevice(streamType,
- AudioSystem.DEVICE_OUT_BLE_HEADSET);
+ final int leAudioVolIndex = mDeviceBroker.getVssVolumeForDevice(streamType, device);
final int maxIndex = mDeviceBroker.getMaxVssVolumeForStream(streamType);
mDeviceBroker.postSetLeAudioVolumeIndex(leAudioVolIndex, maxIndex, streamType);
mDeviceBroker.postApplyVolumeOnDevice(streamType, device, "makeLeAudioDeviceAvailable");
@@ -1163,6 +1179,7 @@
BECOMING_NOISY_INTENT_DEVICES_SET.add(AudioSystem.DEVICE_OUT_LINE);
BECOMING_NOISY_INTENT_DEVICES_SET.add(AudioSystem.DEVICE_OUT_HEARING_AID);
BECOMING_NOISY_INTENT_DEVICES_SET.add(AudioSystem.DEVICE_OUT_BLE_HEADSET);
+ BECOMING_NOISY_INTENT_DEVICES_SET.add(AudioSystem.DEVICE_OUT_BLE_BROADCAST);
BECOMING_NOISY_INTENT_DEVICES_SET.addAll(AudioSystem.DEVICE_OUT_ALL_A2DP_SET);
BECOMING_NOISY_INTENT_DEVICES_SET.addAll(AudioSystem.DEVICE_OUT_ALL_USB_SET);
BECOMING_NOISY_INTENT_DEVICES_SET.addAll(AudioSystem.DEVICE_OUT_ALL_BLE_SET);
diff --git a/services/core/java/com/android/server/audio/AudioService.java b/services/core/java/com/android/server/audio/AudioService.java
index 1cc0443..490f844 100644
--- a/services/core/java/com/android/server/audio/AudioService.java
+++ b/services/core/java/com/android/server/audio/AudioService.java
@@ -2998,7 +2998,8 @@
mDeviceBroker.postSetAvrcpAbsoluteVolumeIndex(newIndex / 10);
}
- if (device == AudioSystem.DEVICE_OUT_BLE_HEADSET
+ if ((device == AudioSystem.DEVICE_OUT_BLE_HEADSET
+ || device == AudioSystem.DEVICE_OUT_BLE_BROADCAST)
&& streamType == getBluetoothContextualVolumeStream()
&& (flags & AudioManager.FLAG_BLUETOOTH_ABS_VOLUME) == 0) {
if (DEBUG_VOL) {
@@ -3644,7 +3645,8 @@
mDeviceBroker.postSetAvrcpAbsoluteVolumeIndex(index / 10);
}
- if (device == AudioSystem.DEVICE_OUT_BLE_HEADSET
+ if ((device == AudioSystem.DEVICE_OUT_BLE_HEADSET
+ || device == AudioSystem.DEVICE_OUT_BLE_BROADCAST)
&& streamType == getBluetoothContextualVolumeStream()
&& (flags & AudioManager.FLAG_BLUETOOTH_ABS_VOLUME) == 0) {
if (DEBUG_VOL) {
@@ -6336,6 +6338,7 @@
BluetoothProfile.A2DP,
BluetoothProfile.A2DP_SINK,
BluetoothProfile.LE_AUDIO,
+ BluetoothProfile.LE_AUDIO_BROADCAST,
})
@Retention(RetentionPolicy.SOURCE)
public @interface BtProfile {}
@@ -6357,6 +6360,7 @@
final int profile = info.getProfile();
if (profile != BluetoothProfile.A2DP && profile != BluetoothProfile.A2DP_SINK
&& profile != BluetoothProfile.LE_AUDIO
+ && profile != BluetoothProfile.LE_AUDIO_BROADCAST
&& profile != BluetoothProfile.HEARING_AID) {
throw new IllegalArgumentException("Illegal BluetoothProfile profile for device "
+ previousDevice + " -> " + newDevice + ". Got: " + profile);
diff --git a/services/core/java/com/android/server/connectivity/Vpn.java b/services/core/java/com/android/server/connectivity/Vpn.java
index c3fc8e0..774fe5b 100644
--- a/services/core/java/com/android/server/connectivity/Vpn.java
+++ b/services/core/java/com/android/server/connectivity/Vpn.java
@@ -1095,7 +1095,7 @@
// Except for Settings and VpnDialogs, the caller should be matched one of oldPackage or
// newPackage. Otherwise, non VPN owner might get the VPN always-on status of the VPN owner.
// See b/191382886.
- if (mContext.checkCallingOrSelfPermission(CONTROL_VPN) != PERMISSION_GRANTED) {
+ if (!hasControlVpnPermission()) {
if (oldPackage != null) {
verifyCallingUidAndPackage(oldPackage);
}
@@ -2045,6 +2045,10 @@
"Unauthorized Caller");
}
+ private boolean hasControlVpnPermission() {
+ return mContext.checkCallingOrSelfPermission(CONTROL_VPN) == PERMISSION_GRANTED;
+ }
+
private class Connection implements ServiceConnection {
private IBinder mService;
@@ -3337,7 +3341,7 @@
// TODO(b/230548427): Remove SDK check once VPN related stuff are
// decoupled from ConnectivityServiceTest.
- if (SdkLevel.isAtLeastT() && category != null) {
+ if (SdkLevel.isAtLeastT() && category != null && isVpnApp(mPackage)) {
sendEventToVpnManagerApp(category, errorClass, errorCode,
getPackage(), mSessionKey, makeVpnProfileStateLocked(),
mActiveNetwork,
@@ -3846,8 +3850,10 @@
Binder.restoreCallingIdentity(token);
}
- // TODO: if package has CONTROL_VPN, grant the ACTIVATE_PLATFORM_VPN appop.
- // This mirrors the prepareAndAuthorize that is used by VpnService.
+ // If package has CONTROL_VPN, grant the ACTIVATE_PLATFORM_VPN appop.
+ if (hasControlVpnPermission()) {
+ setPackageAuthorization(packageName, VpnManager.TYPE_VPN_PLATFORM);
+ }
// Return whether the app is already pre-consented
return isVpnProfilePreConsented(mContext, packageName);
diff --git a/services/core/java/com/android/server/media/MediaSessionRecord.java b/services/core/java/com/android/server/media/MediaSessionRecord.java
index b482d18..c502e16 100644
--- a/services/core/java/com/android/server/media/MediaSessionRecord.java
+++ b/services/core/java/com/android/server/media/MediaSessionRecord.java
@@ -61,8 +61,8 @@
import java.util.Arrays;
import java.util.Collection;
import java.util.List;
-import java.util.concurrent.CopyOnWriteArrayList;
import java.util.NoSuchElementException;
+import java.util.concurrent.CopyOnWriteArrayList;
/**
* This is the system implementation of a Session. Apps will interact with the
@@ -1159,6 +1159,9 @@
public void sendCommand(String packageName, int pid, int uid, String command, Bundle args,
ResultReceiver cb) {
try {
+ final String reason = TAG + ":" + command;
+ mService.tempAllowlistTargetPkgIfPossible(getUid(), getPackageName(),
+ pid, uid, packageName, reason);
mCb.onCommand(packageName, pid, uid, command, args, cb);
} catch (RemoteException e) {
Log.e(TAG, "Remote failure in sendCommand.", e);
@@ -1168,6 +1171,9 @@
public void sendCustomAction(String packageName, int pid, int uid, String action,
Bundle args) {
try {
+ final String reason = TAG + ":custom-" + action;
+ mService.tempAllowlistTargetPkgIfPossible(getUid(), getPackageName(),
+ pid, uid, packageName, reason);
mCb.onCustomAction(packageName, pid, uid, action, args);
} catch (RemoteException e) {
Log.e(TAG, "Remote failure in sendCustomAction.", e);
@@ -1176,6 +1182,9 @@
public void prepare(String packageName, int pid, int uid) {
try {
+ final String reason = TAG + ":prepare";
+ mService.tempAllowlistTargetPkgIfPossible(getUid(), getPackageName(),
+ pid, uid, packageName, reason);
mCb.onPrepare(packageName, pid, uid);
} catch (RemoteException e) {
Log.e(TAG, "Remote failure in prepare.", e);
@@ -1185,6 +1194,9 @@
public void prepareFromMediaId(String packageName, int pid, int uid, String mediaId,
Bundle extras) {
try {
+ final String reason = TAG + ":prepareFromMediaId";
+ mService.tempAllowlistTargetPkgIfPossible(getUid(), getPackageName(),
+ pid, uid, packageName, reason);
mCb.onPrepareFromMediaId(packageName, pid, uid, mediaId, extras);
} catch (RemoteException e) {
Log.e(TAG, "Remote failure in prepareFromMediaId.", e);
@@ -1194,6 +1206,9 @@
public void prepareFromSearch(String packageName, int pid, int uid, String query,
Bundle extras) {
try {
+ final String reason = TAG + ":prepareFromSearch";
+ mService.tempAllowlistTargetPkgIfPossible(getUid(), getPackageName(),
+ pid, uid, packageName, reason);
mCb.onPrepareFromSearch(packageName, pid, uid, query, extras);
} catch (RemoteException e) {
Log.e(TAG, "Remote failure in prepareFromSearch.", e);
@@ -1202,6 +1217,9 @@
public void prepareFromUri(String packageName, int pid, int uid, Uri uri, Bundle extras) {
try {
+ final String reason = TAG + ":prepareFromUri";
+ mService.tempAllowlistTargetPkgIfPossible(getUid(), getPackageName(),
+ pid, uid, packageName, reason);
mCb.onPrepareFromUri(packageName, pid, uid, uri, extras);
} catch (RemoteException e) {
Log.e(TAG, "Remote failure in prepareFromUri.", e);
@@ -1210,6 +1228,9 @@
public void play(String packageName, int pid, int uid) {
try {
+ final String reason = TAG + ":play";
+ mService.tempAllowlistTargetPkgIfPossible(getUid(), getPackageName(),
+ pid, uid, packageName, reason);
mCb.onPlay(packageName, pid, uid);
} catch (RemoteException e) {
Log.e(TAG, "Remote failure in play.", e);
@@ -1219,6 +1240,9 @@
public void playFromMediaId(String packageName, int pid, int uid, String mediaId,
Bundle extras) {
try {
+ final String reason = TAG + ":playFromMediaId";
+ mService.tempAllowlistTargetPkgIfPossible(getUid(), getPackageName(),
+ pid, uid, packageName, reason);
mCb.onPlayFromMediaId(packageName, pid, uid, mediaId, extras);
} catch (RemoteException e) {
Log.e(TAG, "Remote failure in playFromMediaId.", e);
@@ -1228,6 +1252,9 @@
public void playFromSearch(String packageName, int pid, int uid, String query,
Bundle extras) {
try {
+ final String reason = TAG + ":playFromSearch";
+ mService.tempAllowlistTargetPkgIfPossible(getUid(), getPackageName(),
+ pid, uid, packageName, reason);
mCb.onPlayFromSearch(packageName, pid, uid, query, extras);
} catch (RemoteException e) {
Log.e(TAG, "Remote failure in playFromSearch.", e);
@@ -1236,6 +1263,9 @@
public void playFromUri(String packageName, int pid, int uid, Uri uri, Bundle extras) {
try {
+ final String reason = TAG + ":playFromUri";
+ mService.tempAllowlistTargetPkgIfPossible(getUid(), getPackageName(),
+ pid, uid, packageName, reason);
mCb.onPlayFromUri(packageName, pid, uid, uri, extras);
} catch (RemoteException e) {
Log.e(TAG, "Remote failure in playFromUri.", e);
@@ -1244,6 +1274,9 @@
public void skipToTrack(String packageName, int pid, int uid, long id) {
try {
+ final String reason = TAG + ":skipToTrack";
+ mService.tempAllowlistTargetPkgIfPossible(getUid(), getPackageName(),
+ pid, uid, packageName, reason);
mCb.onSkipToTrack(packageName, pid, uid, id);
} catch (RemoteException e) {
Log.e(TAG, "Remote failure in skipToTrack", e);
@@ -1252,6 +1285,9 @@
public void pause(String packageName, int pid, int uid) {
try {
+ final String reason = TAG + ":pause";
+ mService.tempAllowlistTargetPkgIfPossible(getUid(), getPackageName(),
+ pid, uid, packageName, reason);
mCb.onPause(packageName, pid, uid);
} catch (RemoteException e) {
Log.e(TAG, "Remote failure in pause.", e);
@@ -1260,6 +1296,9 @@
public void stop(String packageName, int pid, int uid) {
try {
+ final String reason = TAG + ":stop";
+ mService.tempAllowlistTargetPkgIfPossible(getUid(), getPackageName(),
+ pid, uid, packageName, reason);
mCb.onStop(packageName, pid, uid);
} catch (RemoteException e) {
Log.e(TAG, "Remote failure in stop.", e);
@@ -1268,6 +1307,9 @@
public void next(String packageName, int pid, int uid) {
try {
+ final String reason = TAG + ":next";
+ mService.tempAllowlistTargetPkgIfPossible(getUid(), getPackageName(),
+ pid, uid, packageName, reason);
mCb.onNext(packageName, pid, uid);
} catch (RemoteException e) {
Log.e(TAG, "Remote failure in next.", e);
@@ -1276,6 +1318,9 @@
public void previous(String packageName, int pid, int uid) {
try {
+ final String reason = TAG + ":previous";
+ mService.tempAllowlistTargetPkgIfPossible(getUid(), getPackageName(),
+ pid, uid, packageName, reason);
mCb.onPrevious(packageName, pid, uid);
} catch (RemoteException e) {
Log.e(TAG, "Remote failure in previous.", e);
@@ -1284,6 +1329,9 @@
public void fastForward(String packageName, int pid, int uid) {
try {
+ final String reason = TAG + ":fastForward";
+ mService.tempAllowlistTargetPkgIfPossible(getUid(), getPackageName(),
+ pid, uid, packageName, reason);
mCb.onFastForward(packageName, pid, uid);
} catch (RemoteException e) {
Log.e(TAG, "Remote failure in fastForward.", e);
@@ -1292,6 +1340,9 @@
public void rewind(String packageName, int pid, int uid) {
try {
+ final String reason = TAG + ":rewind";
+ mService.tempAllowlistTargetPkgIfPossible(getUid(), getPackageName(),
+ pid, uid, packageName, reason);
mCb.onRewind(packageName, pid, uid);
} catch (RemoteException e) {
Log.e(TAG, "Remote failure in rewind.", e);
@@ -1300,6 +1351,9 @@
public void seekTo(String packageName, int pid, int uid, long pos) {
try {
+ final String reason = TAG + ":seekTo";
+ mService.tempAllowlistTargetPkgIfPossible(getUid(), getPackageName(),
+ pid, uid, packageName, reason);
mCb.onSeekTo(packageName, pid, uid, pos);
} catch (RemoteException e) {
Log.e(TAG, "Remote failure in seekTo.", e);
@@ -1308,6 +1362,9 @@
public void rate(String packageName, int pid, int uid, Rating rating) {
try {
+ final String reason = TAG + ":rate";
+ mService.tempAllowlistTargetPkgIfPossible(getUid(), getPackageName(),
+ pid, uid, packageName, reason);
mCb.onRate(packageName, pid, uid, rating);
} catch (RemoteException e) {
Log.e(TAG, "Remote failure in rate.", e);
@@ -1316,6 +1373,9 @@
public void setPlaybackSpeed(String packageName, int pid, int uid, float speed) {
try {
+ final String reason = TAG + ":setPlaybackSpeed";
+ mService.tempAllowlistTargetPkgIfPossible(getUid(), getPackageName(),
+ pid, uid, packageName, reason);
mCb.onSetPlaybackSpeed(packageName, pid, uid, speed);
} catch (RemoteException e) {
Log.e(TAG, "Remote failure in setPlaybackSpeed.", e);
@@ -1325,6 +1385,9 @@
public void adjustVolume(String packageName, int pid, int uid, boolean asSystemService,
int direction) {
try {
+ final String reason = TAG + ":adjustVolume";
+ mService.tempAllowlistTargetPkgIfPossible(getUid(), getPackageName(),
+ pid, uid, packageName, reason);
if (asSystemService) {
mCb.onAdjustVolume(mContext.getPackageName(), Process.myPid(),
Process.SYSTEM_UID, direction);
@@ -1338,6 +1401,9 @@
public void setVolumeTo(String packageName, int pid, int uid, int value) {
try {
+ final String reason = TAG + ":setVolumeTo";
+ mService.tempAllowlistTargetPkgIfPossible(getUid(), getPackageName(),
+ pid, uid, packageName, reason);
mCb.onSetVolumeTo(packageName, pid, uid, value);
} catch (RemoteException e) {
Log.e(TAG, "Remote failure in setVolumeTo.", e);
diff --git a/services/core/java/com/android/server/media/MediaSessionService.java b/services/core/java/com/android/server/media/MediaSessionService.java
index 29a5469..65d9f99 100644
--- a/services/core/java/com/android/server/media/MediaSessionService.java
+++ b/services/core/java/com/android/server/media/MediaSessionService.java
@@ -40,6 +40,7 @@
import android.content.Intent;
import android.content.IntentFilter;
import android.content.pm.PackageManager;
+import android.content.pm.PackageManagerInternal;
import android.media.AudioManager;
import android.media.AudioPlaybackConfiguration;
import android.media.AudioSystem;
@@ -85,6 +86,7 @@
import com.android.internal.R;
import com.android.internal.annotations.GuardedBy;
import com.android.server.LocalManagerRegistry;
+import com.android.server.LocalServices;
import com.android.server.SystemService;
import com.android.server.Watchdog;
import com.android.server.Watchdog.Monitor;
@@ -538,14 +540,19 @@
if (TextUtils.isEmpty(packageName)) {
throw new IllegalArgumentException("packageName may not be empty");
}
- String[] packages = mContext.getPackageManager().getPackagesForUid(uid);
- final int packageCount = packages.length;
- for (int i = 0; i < packageCount; i++) {
- if (packageName.equals(packages[i])) {
- return;
- }
+ if (uid == Process.ROOT_UID || uid == Process.SHELL_UID) {
+ // If the caller is shell, then trust the packageName given and allow it
+ // to proceed.
+ return;
}
- throw new IllegalArgumentException("packageName is not owned by the calling process");
+ final PackageManagerInternal packageManagerInternal =
+ LocalServices.getService(PackageManagerInternal.class);
+ final int actualUid = packageManagerInternal.getPackageUid(
+ packageName, 0 /* flags */, UserHandle.getUserId(uid));
+ if (!UserHandle.isSameApp(uid, actualUid)) {
+ throw new IllegalArgumentException("packageName does not belong to the calling uid; "
+ + "pkg=" + packageName + ", uid=" + uid);
+ }
}
void tempAllowlistTargetPkgIfPossible(int targetUid, String targetPackage,
diff --git a/services/core/java/com/android/server/notification/NotificationManagerService.java b/services/core/java/com/android/server/notification/NotificationManagerService.java
index f836a6c..b7fc38d 100755
--- a/services/core/java/com/android/server/notification/NotificationManagerService.java
+++ b/services/core/java/com/android/server/notification/NotificationManagerService.java
@@ -9404,10 +9404,16 @@
* given NAS is bound in.
*/
private boolean isInteractionVisibleToListener(ManagedServiceInfo info, int userId) {
- boolean isAssistantService = mAssistants.isServiceTokenValidLocked(info.service);
+ boolean isAssistantService = isServiceTokenValid(info.service);
return !isAssistantService || info.isSameUser(userId);
}
+ private boolean isServiceTokenValid(IInterface service) {
+ synchronized (mNotificationLock) {
+ return mAssistants.isServiceTokenValidLocked(service);
+ }
+ }
+
private boolean isPackageSuspendedForUser(String pkg, int uid) {
final long identity = Binder.clearCallingIdentity();
int userId = UserHandle.getUserId(uid);
@@ -10652,7 +10658,7 @@
BackgroundThread.getHandler().post(() -> {
if (info.isSystem
|| hasCompanionDevice(info)
- || mAssistants.isServiceTokenValidLocked(info.service)) {
+ || isServiceTokenValid(info.service)) {
notifyNotificationChannelChanged(
info, pkg, user, channel, modificationType);
}
diff --git a/services/net/Android.bp b/services/net/Android.bp
index 804ccc5..3d40f64 100644
--- a/services/net/Android.bp
+++ b/services/net/Android.bp
@@ -18,7 +18,6 @@
name: "services.net",
defaults: ["platform_service_defaults"],
srcs: [
- ":net-module-utils-srcs",
":services.net-sources",
],
static_libs: [
diff --git a/services/robotests/backup/src/com/android/server/backup/keyvalue/KeyValueBackupTaskTest.java b/services/robotests/backup/src/com/android/server/backup/keyvalue/KeyValueBackupTaskTest.java
index 7d17109..edcf357 100644
--- a/services/robotests/backup/src/com/android/server/backup/keyvalue/KeyValueBackupTaskTest.java
+++ b/services/robotests/backup/src/com/android/server/backup/keyvalue/KeyValueBackupTaskTest.java
@@ -43,23 +43,23 @@
import static com.google.common.truth.Truth.assertThat;
import static com.google.common.truth.Truth.assertWithMessage;
-import static org.mockito.ArgumentMatchers.any;
-import static org.mockito.ArgumentMatchers.anyInt;
-import static org.mockito.ArgumentMatchers.anyLong;
-import static org.mockito.ArgumentMatchers.argThat;
-import static org.mockito.ArgumentMatchers.eq;
-import static org.mockito.ArgumentMatchers.intThat;
+import static org.mockito.Mockito.any;
+import static org.mockito.Mockito.anyInt;
+import static org.mockito.Mockito.anyLong;
+import static org.mockito.Mockito.argThat;
import static org.mockito.Mockito.doAnswer;
import static org.mockito.Mockito.doNothing;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.doThrow;
+import static org.mockito.Mockito.eq;
import static org.mockito.Mockito.inOrder;
+import static org.mockito.Mockito.intThat;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.reset;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.verifyZeroInteractions;
+import static org.mockito.Mockito.verifyNoInteractions;
import static org.mockito.Mockito.when;
import static org.robolectric.Shadows.shadowOf;
import static org.robolectric.shadow.api.Shadow.extract;
@@ -2185,7 +2185,7 @@
task.waitCancel();
reset(transportMock.transport);
taskFinished.block();
- verifyZeroInteractions(transportMock.transport);
+ verifyNoInteractions(transportMock.transport);
}
@Test
diff --git a/services/tests/PackageManagerServiceTests/appenumeration/Android.bp b/services/tests/PackageManagerServiceTests/appenumeration/Android.bp
index 479ef8e..c3cce96 100644
--- a/services/tests/PackageManagerServiceTests/appenumeration/Android.bp
+++ b/services/tests/PackageManagerServiceTests/appenumeration/Android.bp
@@ -33,4 +33,5 @@
],
platform_apis: true,
test_suites: ["device-tests"],
+ data: [":AppEnumerationSyncProviderTestApp"],
}
diff --git a/services/tests/PackageManagerServiceTests/appenumeration/AndroidTest.xml b/services/tests/PackageManagerServiceTests/appenumeration/AndroidTest.xml
index 6f168a3..5bcf2e3 100644
--- a/services/tests/PackageManagerServiceTests/appenumeration/AndroidTest.xml
+++ b/services/tests/PackageManagerServiceTests/appenumeration/AndroidTest.xml
@@ -30,7 +30,7 @@
</target_preparer>
<!-- Load additional APKs onto device -->
- <target_preparer class="com.android.compatibility.common.tradefed.targetprep.FilePusher">
+ <target_preparer class="com.android.tradefed.targetprep.PushFilePreparer">
<option name="push" value="AppEnumerationSyncProviderTestApp.apk->/data/local/tmp/appenumerationtests/AppEnumerationSyncProviderTestApp.apk" />
</target_preparer>
diff --git a/services/tests/mockingservicestests/src/com/android/server/alarm/AlarmManagerServiceTest.java b/services/tests/mockingservicestests/src/com/android/server/alarm/AlarmManagerServiceTest.java
index 32d9247..01ca494 100644
--- a/services/tests/mockingservicestests/src/com/android/server/alarm/AlarmManagerServiceTest.java
+++ b/services/tests/mockingservicestests/src/com/android/server/alarm/AlarmManagerServiceTest.java
@@ -2204,10 +2204,15 @@
mBinder.set(TEST_CALLING_PACKAGE, RTC_WAKEUP, 1234, WINDOW_EXACT, 0, 0,
alarmPi, null, null, null, alarmClock);
+ final ArgumentCaptor<Bundle> bundleCaptor = ArgumentCaptor.forClass(Bundle.class);
verify(mService).setImpl(eq(RTC_WAKEUP), eq(1234L), eq(WINDOW_EXACT), eq(0L),
eq(alarmPi), isNull(), isNull(), eq(FLAG_STANDALONE | FLAG_WAKE_FROM_IDLE),
- isNull(), eq(alarmClock), eq(TEST_CALLING_UID), eq(TEST_CALLING_PACKAGE), isNull(),
- eq(EXACT_ALLOW_REASON_COMPAT));
+ isNull(), eq(alarmClock), eq(TEST_CALLING_UID), eq(TEST_CALLING_PACKAGE),
+ bundleCaptor.capture(), eq(EXACT_ALLOW_REASON_COMPAT));
+
+ final BroadcastOptions idleOptions = new BroadcastOptions(bundleCaptor.getValue());
+ final int type = idleOptions.getTemporaryAppAllowlistType();
+ assertEquals(TEMPORARY_ALLOWLIST_TYPE_FOREGROUND_SERVICE_ALLOWED, type);
}
@Test
diff --git a/telecomm/java/com/android/internal/telecom/ITelecomService.aidl b/telecomm/java/com/android/internal/telecom/ITelecomService.aidl
index 23b5787..7a69fe5 100644
--- a/telecomm/java/com/android/internal/telecom/ITelecomService.aidl
+++ b/telecomm/java/com/android/internal/telecom/ITelecomService.aidl
@@ -340,6 +340,8 @@
void cleanupStuckCalls();
+ int cleanupOrphanPhoneAccounts();
+
void resetCarMode();
void setTestDefaultCallRedirectionApp(String packageName);
diff --git a/telephony/common/android/telephony/LocationAccessPolicy.java b/telephony/common/android/telephony/LocationAccessPolicy.java
index 9dfb0cc..d4b6c91 100644
--- a/telephony/common/android/telephony/LocationAccessPolicy.java
+++ b/telephony/common/android/telephony/LocationAccessPolicy.java
@@ -316,9 +316,11 @@
return LocationPermissionResult.ALLOWED;
}
- // Check the system-wide requirements. If the location main switch is off or
- // the app's profile isn't in foreground, return a soft denial.
- if (!checkSystemLocationAccess(context, query.callingUid, query.callingPid)) {
+ // Check the system-wide requirements. If the location main switch is off and the caller is
+ // not in the allowlist of apps that always have loation access or the app's profile
+ // isn't in the foreground, return a soft denial.
+ if (!checkSystemLocationAccess(context, query.callingUid, query.callingPid,
+ query.callingPackage)) {
return LocationPermissionResult.DENIED_SOFT;
}
@@ -344,15 +346,16 @@
return LocationPermissionResult.ALLOWED;
}
-
private static boolean checkManifestPermission(Context context, int pid, int uid,
String permissionToCheck) {
return context.checkPermission(permissionToCheck, pid, uid)
== PackageManager.PERMISSION_GRANTED;
}
- private static boolean checkSystemLocationAccess(@NonNull Context context, int uid, int pid) {
- if (!isLocationModeEnabled(context, UserHandle.getUserHandleForUid(uid).getIdentifier())) {
+ private static boolean checkSystemLocationAccess(@NonNull Context context, int uid, int pid,
+ @NonNull String callingPackage) {
+ if (!isLocationModeEnabled(context, UserHandle.getUserHandleForUid(uid).getIdentifier())
+ && !isLocationBypassAllowed(context, callingPackage)) {
if (DBG) Log.w(TAG, "Location disabled, failed, (" + uid + ")");
return false;
}
@@ -373,6 +376,16 @@
return locationManager.isLocationEnabledForUser(UserHandle.of(userId));
}
+ private static boolean isLocationBypassAllowed(@NonNull Context context,
+ @NonNull String callingPackage) {
+ for (String bypassPackage : getLocationBypassPackages(context)) {
+ if (callingPackage.equals(bypassPackage)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
/**
* @return An array of packages that are always allowed to access location.
*/
diff --git a/telephony/java/android/telephony/CellSignalStrengthNr.java b/telephony/java/android/telephony/CellSignalStrengthNr.java
index 417fd49..a22e43e 100644
--- a/telephony/java/android/telephony/CellSignalStrengthNr.java
+++ b/telephony/java/android/telephony/CellSignalStrengthNr.java
@@ -49,7 +49,7 @@
private static final String TAG = "CellSignalStrengthNr";
// Lifted from Default carrier configs and max range of SSRSRP
- // Boundaries: [-140 dB, -44 dB]
+ // Boundaries: [-156 dB, -31 dB]
private int[] mSsRsrpThresholds = new int[] {
-110, /* SIGNAL_STRENGTH_POOR */
-90, /* SIGNAL_STRENGTH_MODERATE */
@@ -173,14 +173,14 @@
*/
public CellSignalStrengthNr(int csiRsrp, int csiRsrq, int csiSinr, int csiCqiTableIndex,
List<Byte> csiCqiReport, int ssRsrp, int ssRsrq, int ssSinr) {
- mCsiRsrp = inRangeOrUnavailable(csiRsrp, -140, -44);
+ mCsiRsrp = inRangeOrUnavailable(csiRsrp, -156, -31);
mCsiRsrq = inRangeOrUnavailable(csiRsrq, -20, -3);
mCsiSinr = inRangeOrUnavailable(csiSinr, -23, 23);
mCsiCqiTableIndex = inRangeOrUnavailable(csiCqiTableIndex, 1, 3);
mCsiCqiReport = csiCqiReport.stream()
- .map(cqi -> new Integer(inRangeOrUnavailable(Byte.toUnsignedInt(cqi), 0, 15)))
+ .map(cqi -> inRangeOrUnavailable(Byte.toUnsignedInt(cqi), 0, 15))
.collect(Collectors.toList());
- mSsRsrp = inRangeOrUnavailable(ssRsrp, -140, -44);
+ mSsRsrp = inRangeOrUnavailable(ssRsrp, -156, -31);
mSsRsrq = inRangeOrUnavailable(ssRsrq, -43, 20);
mSsSinr = inRangeOrUnavailable(ssSinr, -23, 40);
updateLevel(null, null);
@@ -212,8 +212,8 @@
}
/**
- * Reference: 3GPP TS 38.215.
- * Range: -140 dBm to -44 dBm.
+ * Reference: 3GPP TS 38.133 10.1.6.1.
+ * Range: -156 dBm to -31 dBm.
* @return SS reference signal received power, {@link CellInfo#UNAVAILABLE} means unreported
* value.
*/
@@ -242,8 +242,8 @@
}
/**
- * Reference: 3GPP TS 38.215.
- * Range: -140 dBm to -44 dBm.
+ * Reference: 3GPP TS 38.133 10.1.6.1.
+ * Range: -156 dBm to -31 dBm.
* @return CSI reference signal received power, {@link CellInfo#UNAVAILABLE} means unreported
* value.
*/
diff --git a/telephony/java/android/telephony/SubscriptionManager.java b/telephony/java/android/telephony/SubscriptionManager.java
index d2858ec..f254980 100644
--- a/telephony/java/android/telephony/SubscriptionManager.java
+++ b/telephony/java/android/telephony/SubscriptionManager.java
@@ -3040,8 +3040,9 @@
* @param callback Callback will be triggered once it succeeds or failed.
* Pass null if don't care about the result.
*
+ * @throws IllegalStateException when subscription manager service is not available.
+ * @throws SecurityException when clients do not have MODIFY_PHONE_STATE permission.
* @hide
- *
*/
@SystemApi
@RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE)
@@ -3051,7 +3052,9 @@
if (VDBG) logd("[setPreferredDataSubscriptionId]+ subId:" + subId);
try {
ISub iSub = TelephonyManager.getSubscriptionService();
- if (iSub == null) return;
+ if (iSub == null) {
+ throw new IllegalStateException("subscription manager service is null.");
+ }
ISetOpportunisticDataCallback callbackStub = new ISetOpportunisticDataCallback.Stub() {
@Override
@@ -3071,7 +3074,8 @@
};
iSub.setPreferredDataSubscriptionId(subId, needValidation, callbackStub);
} catch (RemoteException ex) {
- // ignore it
+ loge("setPreferredDataSubscriptionId RemoteException=" + ex);
+ ex.rethrowFromSystemServer();
}
}
diff --git a/telephony/java/android/telephony/data/ApnSetting.java b/telephony/java/android/telephony/data/ApnSetting.java
index a710e38..7fc8871 100644
--- a/telephony/java/android/telephony/data/ApnSetting.java
+++ b/telephony/java/android/telephony/data/ApnSetting.java
@@ -1134,10 +1134,7 @@
return false;
}
// DEFAULT can handle HIPRI.
- if (hasApnType(type)) {
- return true;
- }
- return false;
+ return hasApnType(type);
}
// Check whether the types of two APN same (even only one type of each APN is same).