Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Unverified Commit 0de4290f authored by Kevin F. Haggerty's avatar Kevin F. Haggerty
Browse files

Merge tag 'android-11.0.0_r34' into staging/lineage-18.1_merge-android-11.0.0_r34

Android 11.0.0 release 34

* tag 'android-11.0.0_r34':
  Revert "Only allow BROWSABLE && DEFAULT Intents to be always opened"
  Fix legacy APIs when VPN switches to suspended underlying network.
  Backport test coverage from aosp/1547496.
  Backport some helpers in ConnectivityServiceTest.
  Test for bugs with suspended VPN underlying networks.
  Add a test for getDefaultNetworkCapabilitiesForUser.
  Improve testing of CONNECTIVITY_ACTION broadcasts.
  Test passing an underlying network array with null network in it.
  Make testVpnNetworkActive more deterministic.
  Make MockVpn more realistic and easier to use.
  Increase test coverage for VPN info sent to NetworkStatsService.
  Simplify MockVpn.
  Test a VPN with an underlying network that does not yet exist.
  Get ApplicationInfo using usr id
  [DO NOT MERGE] Close screenshot process on user switched
  RESTRICT AUTOMERGE Allow CDM to hide overlays
  RESTRICT AUTOMERGE Prevent non-system overlays from showing over CDM UI
  Fix thread safety issue on clearing cache
  [SettingsProvider] extend font size scale range
  [RESTRICT AUTOMERGE] Fix potential out of bounds writes in LogEvent.
  Only update native InputApplicationHandle once
  Only allow BROWSABLE && DEFAULT Intents to be always opened
  DO NOT MERGE: Do not inject mock location to chipset
  Check mode/boost index before accessing cached support value

Change-Id: I4cfee8d810d011847bd4835b4922f878e4a5bae2
parents 5960e54c 719eec38
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -334,6 +334,7 @@ void StatsPullerManager::OnAlarmFired(int64_t elapsedTimeNs) {
}

int StatsPullerManager::ForceClearPullerCache() {
    std::lock_guard<std::mutex> _l(mLock);
    int totalCleared = 0;
    for (const auto& pulledAtom : kAllPullAtomInfo) {
        totalCleared += pulledAtom.second->ForceClearCache();
@@ -342,6 +343,7 @@ int StatsPullerManager::ForceClearPullerCache() {
}

int StatsPullerManager::ClearPullerCacheIfNecessary(int64_t timestampNs) {
    std::lock_guard<std::mutex> _l(mLock);
    int totalCleared = 0;
    for (const auto& pulledAtom : kAllPullAtomInfo) {
        totalCleared += pulledAtom.second->ClearCacheIfNecessary(timestampNs);
+23 −4
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@

#include <android-base/stringprintf.h>
#include <android/binder_ibinder.h>
#include <log/log.h>
#include <private/android_filesystem_config.h>

#include "annotations.h"
@@ -216,13 +217,18 @@ void LogEvent::parseAttributionChain(int32_t* pos, int32_t depth, bool* last,
        last[2] = true;
        parseString(pos, /*depth=*/2, last, /*numAnnotations=*/0);
    }
    // Check if at least one node was successfully parsed.
    if (mValues.size() - 1 > firstUidInChainIndex) {

    if (mValues.size() - 1 > INT8_MAX) {
        mValid = false;
    } else if (mValues.size() - 1 > firstUidInChainIndex) {
        // At least one node was successfully parsed.
        mAttributionChainStartIndex = static_cast<int8_t>(firstUidInChainIndex);
        mAttributionChainEndIndex = static_cast<int8_t>(mValues.size() - 1);
    }

    if (mValid) {
        parseAnnotations(numAnnotations, firstUidInChainIndex);
    }

    pos[1] = pos[2] = 1;
    last[1] = last[2] = false;
@@ -234,7 +240,8 @@ bool LogEvent::checkPreviousValueType(Type expected) {
}

void LogEvent::parseIsUidAnnotation(uint8_t annotationType) {
    if (mValues.empty() || !checkPreviousValueType(INT) || annotationType != BOOL_TYPE) {
    if (mValues.empty() || mValues.size() - 1 > INT8_MAX || !checkPreviousValueType(INT)
            || annotationType != BOOL_TYPE) {
        mValid = false;
        return;
    }
@@ -270,6 +277,12 @@ void LogEvent::parsePrimaryFieldFirstUidAnnotation(uint8_t annotationType,
        return;
    }

    if (static_cast<int>(mValues.size() - 1) < firstUidInChainIndex) { // AttributionChain is empty.
        mValid = false;
        android_errorWriteLog(0x534e4554, "174485572");
        return;
    }

    const bool primaryField = readNextValue<uint8_t>();
    mValues[firstUidInChainIndex].mAnnotations.setPrimaryField(primaryField);
}
@@ -280,6 +293,12 @@ void LogEvent::parseExclusiveStateAnnotation(uint8_t annotationType) {
        return;
    }

    if (mValues.size() - 1 > INT8_MAX) {
        android_errorWriteLog(0x534e4554, "174488848");
        mValid = false;
        return;
    }

    const bool exclusiveState = readNextValue<uint8_t>();
    mExclusiveStateFieldIndex = static_cast<int8_t>(mValues.size() - 1);
    mValues[getExclusiveStateFieldIndex()].mAnnotations.setExclusiveState(exclusiveState);
+110 −0
Original line number Diff line number Diff line
@@ -363,6 +363,116 @@ TEST(LogEventTest, TestResetStateAnnotation) {
    EXPECT_EQ(event.getResetState(), resetState);
}

TEST(LogEventTest, TestExclusiveStateAnnotationAfterTooManyFields) {
    AStatsEvent* event = AStatsEvent_obtain();
    AStatsEvent_setAtomId(event, 100);

    const unsigned int numAttributionNodes = 64;

    uint32_t uids[numAttributionNodes];
    const char* tags[numAttributionNodes];

    for (unsigned int i = 1; i <= numAttributionNodes; i++) {
        uids[i-1] = i;
        tags[i-1] = std::to_string(i).c_str();
    }

    AStatsEvent_writeAttributionChain(event, uids, tags, numAttributionNodes);
    AStatsEvent_writeInt32(event, 1);
    AStatsEvent_addBoolAnnotation(event, ANNOTATION_ID_EXCLUSIVE_STATE, true);

    AStatsEvent_build(event);

    size_t size;
    uint8_t* buf = AStatsEvent_getBuffer(event, &size);

    LogEvent logEvent(/*uid=*/1000, /*pid=*/1001);
    EXPECT_FALSE(logEvent.parseBuffer(buf, size));
    EXPECT_EQ(-1, logEvent.getExclusiveStateFieldIndex());

    AStatsEvent_release(event);
}

TEST(LogEventTest, TestUidAnnotationAfterTooManyFields) {
    AStatsEvent* event = AStatsEvent_obtain();
    AStatsEvent_setAtomId(event, 100);

    const unsigned int numAttributionNodes = 64;

    uint32_t uids[numAttributionNodes];
    const char* tags[numAttributionNodes];

    for (unsigned int i = 1; i <= numAttributionNodes; i++) {
        uids[i-1] = i;
        tags[i-1] = std::to_string(i).c_str();
    }

    AStatsEvent_writeAttributionChain(event, uids, tags, numAttributionNodes);
    AStatsEvent_writeInt32(event, 1);
    AStatsEvent_addBoolAnnotation(event, ANNOTATION_ID_IS_UID, true);

    AStatsEvent_build(event);

    size_t size;
    uint8_t* buf = AStatsEvent_getBuffer(event, &size);

    LogEvent logEvent(/*uid=*/1000, /*pid=*/1001);
    EXPECT_FALSE(logEvent.parseBuffer(buf, size));
    EXPECT_EQ(-1, logEvent.getUidFieldIndex());

    AStatsEvent_release(event);
}

TEST(LogEventTest, TestAttributionChainEndIndexAfterTooManyFields) {
    AStatsEvent* event = AStatsEvent_obtain();
    AStatsEvent_setAtomId(event, 100);

    const unsigned int numAttributionNodes = 65;

    uint32_t uids[numAttributionNodes];
    const char* tags[numAttributionNodes];

    for (unsigned int i = 1; i <= numAttributionNodes; i++) {
        uids[i-1] = i;
        tags[i-1] = std::to_string(i).c_str();
    }

    AStatsEvent_writeAttributionChain(event, uids, tags, numAttributionNodes);

    AStatsEvent_build(event);

    size_t size;
    uint8_t* buf = AStatsEvent_getBuffer(event, &size);

    LogEvent logEvent(/*uid=*/1000, /*pid=*/1001);
    EXPECT_FALSE(logEvent.parseBuffer(buf, size));
    EXPECT_FALSE(logEvent.hasAttributionChain());

    AStatsEvent_release(event);
}

TEST(LogEventTest, TestEmptyAttributionChainWithPrimaryFieldFirstUidAnnotation) {
    AStatsEvent* event = AStatsEvent_obtain();
    AStatsEvent_setAtomId(event, 100);

    uint32_t uids[] = {};
    const char* tags[] = {};

    AStatsEvent_writeInt32(event, 10);
    AStatsEvent_writeAttributionChain(event, uids, tags, 0);
    AStatsEvent_addBoolAnnotation(event, ANNOTATION_ID_PRIMARY_FIELD_FIRST_UID, true);

    AStatsEvent_build(event);

    size_t size;
    uint8_t* buf = AStatsEvent_getBuffer(event, &size);

    LogEvent logEvent(/*uid=*/1000, /*pid=*/1001);
    EXPECT_FALSE(logEvent.parseBuffer(buf, size));

    AStatsEvent_release(event);
}

}  // namespace statsd
}  // namespace os
}  // namespace android
+6 −6
Original line number Diff line number Diff line
@@ -7623,8 +7623,8 @@ public class AppOpsManager {
                } else if (collectionMode == COLLECT_SYNC
                        // Only collect app-ops when the proxy is trusted
                        && (mContext.checkPermission(Manifest.permission.UPDATE_APP_OPS_STATS, -1,
                        myUid) == PackageManager.PERMISSION_GRANTED
                        || isTrustedVoiceServiceProxy(mContext, mContext.getOpPackageName(), op))) {
                        myUid) == PackageManager.PERMISSION_GRANTED || isTrustedVoiceServiceProxy(
                        mContext, mContext.getOpPackageName(), op, mContext.getUserId()))) {
                    collectNotedOpSync(op, proxiedAttributionTag);
                }
            }
@@ -7642,7 +7642,7 @@ public class AppOpsManager {
     * @hide
     */
    public static boolean isTrustedVoiceServiceProxy(Context context, String packageName,
            int code) {
            int code, int userId) {
        // This is a workaround for R QPR, new API change is not allowed. We only allow the current
        // voice recognizer is also the voice interactor to noteproxy op.
        if (code != OP_RECORD_AUDIO) {
@@ -7654,7 +7654,7 @@ public class AppOpsManager {
        final String voiceRecognitionServicePackageName =
                getComponentPackageNameFromString(voiceRecognitionComponent);
        return (Objects.equals(packageName, voiceRecognitionServicePackageName))
                && isPackagePreInstalled(context, packageName);
                && isPackagePreInstalled(context, packageName, userId);
    }

    private static String getComponentPackageNameFromString(String from) {
@@ -7662,10 +7662,10 @@ public class AppOpsManager {
        return componentName != null ? componentName.getPackageName() : "";
    }

    private static boolean isPackagePreInstalled(Context context, String packageName) {
    private static boolean isPackagePreInstalled(Context context, String packageName, int userId) {
        try {
            final PackageManager pm = context.getPackageManager();
            final ApplicationInfo info = pm.getApplicationInfo(packageName, 0);
            final ApplicationInfo info = pm.getApplicationInfoAsUser(packageName, 0, userId);
            return ((info.flags & ApplicationInfo.FLAG_SYSTEM) != 0);
        } catch (PackageManager.NameNotFoundException e) {
            return false;
+7 −3
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@

package android.view;

import android.annotation.NonNull;
import android.os.IBinder;

/**
@@ -31,17 +32,20 @@ public final class InputApplicationHandle {
    private long ptr;

    // Application name.
    public String name;
    public final @NonNull String name;

    // Dispatching timeout.
    public long dispatchingTimeoutNanos;
    public final long dispatchingTimeoutNanos;

    public final IBinder token;

    private native void nativeDispose();

    public InputApplicationHandle(IBinder token) {
    public InputApplicationHandle(@NonNull IBinder token, @NonNull String name,
            long dispatchingTimeoutNanos) {
        this.token = token;
        this.name = name;
        this.dispatchingTimeoutNanos = dispatchingTimeoutNanos;
    }

    public InputApplicationHandle(InputApplicationHandle handle) {
Loading