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

Commit 02351afb authored by android-build-team Robot's avatar android-build-team Robot
Browse files

Snap for 5546586 from 0f0a12cc to qt-release

Change-Id: Iec13f74127dde2be0c4fd6563419b8762f2ecd02
parents 90e25c71 0f0a12cc
Loading
Loading
Loading
Loading
+0 −1
Original line number Diff line number Diff line
@@ -725,7 +725,6 @@ package android.content.pm {
    field public static final int FLAG_PERMISSION_USER_SET = 1; // 0x1
    field public static final int MATCH_FACTORY_ONLY = 2097152; // 0x200000
    field public static final int MATCH_KNOWN_PACKAGES = 4202496; // 0x402000
    field public static boolean RESTRICTED_PERMISSIONS_ENABLED;
    field public static final String SYSTEM_SHARED_LIBRARY_SERVICES = "android.ext.services";
    field public static final String SYSTEM_SHARED_LIBRARY_SHARED = "android.ext.shared";
  }
+0 −14
Original line number Diff line number Diff line
@@ -60,12 +60,6 @@ cc_binary {
        "libservices",
        "libutils",
        "libprotobuf-cpp-lite",
        "libcrypto",
        "libkeystore_aidl",
        "libkeystore_binder",
        "libkeystore_parcelables",
        "android.hardware.keymaster@4.0",
        "libkeymaster4support",
    ],

    static_libs: [
@@ -119,8 +113,6 @@ cc_test {
        "src/incidentd_util.cpp",
        "src/proto_util.cpp",
        "src/report_directory.cpp",
        "src/cipher/IncidentKeyStore.cpp",
        "src/cipher/ProtoEncryption.cpp",
        "src/**/*.proto",
    ],

@@ -142,12 +134,6 @@ cc_test {
        "libprotoutil",
        "libservices",
        "libutils",
        "libcrypto",
        "libkeystore_aidl",
        "libkeystore_binder",
        "libkeystore_parcelables",
        "android.hardware.keymaster@4.0",
        "libkeymaster4support",
    ],

    target: {
+0 −6
Original line number Diff line number Diff line
@@ -28,8 +28,6 @@ namespace incidentd {
using namespace android::os;
using std::strstream;

static const bool kEncryptionEnabled = false;

uint64_t encode_field_id(const Privacy* p) { return (uint64_t)p->type << 32 | p->field_id; }

string Privacy::toString() const {
@@ -52,10 +50,6 @@ const Privacy* lookup(const Privacy* p, uint32_t fieldId) {
    return NULL;
}

bool sectionEncryption(int section_id) {
    return kEncryptionEnabled ? (section_id == 3025) /*restricted image section*/ : false;
}

static bool isAllowed(const uint8_t policy, const uint8_t check) {
    switch (check) {
        case PRIVACY_POLICY_LOCAL:
+0 −3
Original line number Diff line number Diff line
@@ -90,9 +90,6 @@ private:
    uint8_t mPolicy;
};

// TODO: Add privacy flag in incident.proto and auto generate it inside Privacy.
bool sectionEncryption(int section_id);

/**
 * If a privacy policy is other than the defined values, update it to a real one.
 */
+21 −65
Original line number Diff line number Diff line
@@ -16,20 +16,19 @@
#define DEBUG false
#include "Log.h"

#include "incidentd_util.h"
#include "PrivacyFilter.h"
#include "proto_util.h"

#include "incidentd_util.h"
#include "proto_util.h"
#include "Section.h"

#include <android-base/file.h>
#include <android/util/ProtoFileReader.h>
#include <android/util/protobuf.h>
#include <android/util/ProtoFileReader.h>
#include <log/log.h>

#include "cipher/IncidentKeyStore.h"
#include "cipher/ProtoEncryption.h"

namespace android {
namespace os {
namespace incidentd {
@@ -146,8 +145,6 @@ public:
     */
    status_t writeData(int fd);

    sp<ProtoReader> getData() { return mData; }

private:
    /**
     * The global set of field --> required privacy level mapping.
@@ -259,47 +256,8 @@ void PrivacyFilter::addFd(const sp<FilterFd>& output) {
    mOutputs.push_back(output);
}

static void write_section_to_file(int sectionId, FieldStripper& fieldStripper, sp<FilterFd> output,
                                  bool encryptIfNeeded) {
    status_t err;

    if (sectionEncryption(sectionId) && encryptIfNeeded) {
        ProtoEncryptor encryptor(fieldStripper.getData());
        size_t encryptedSize = encryptor.encrypt();

        if (encryptedSize <= 0) {
            output->onWriteError(BAD_VALUE);
            return;
        }
        err = write_section_header(output->getFd(), sectionId, encryptedSize);
        VLOG("Encrypted: write section header size %lu", (unsigned long)encryptedSize);

        encryptor.flush(output->getFd());

        if (err != NO_ERROR) {
            output->onWriteError(err);
            return;
        }
    } else {
        err = write_section_header(output->getFd(), sectionId, fieldStripper.dataSize());
        VLOG("No encryption: write section header size %lu",
             (unsigned long)fieldStripper.dataSize());

        if (err != NO_ERROR) {
            output->onWriteError(err);
            return;
        }

        err = fieldStripper.writeData(output->getFd());
        if (err != NO_ERROR) {
            output->onWriteError(err);
            return;
        }
    }
}

status_t PrivacyFilter::writeData(const FdBuffer& buffer, uint8_t bufferLevel, size_t* maxSize,
                                  bool encryptIfNeeded) {
status_t PrivacyFilter::writeData(const FdBuffer& buffer, uint8_t bufferLevel,
        size_t* maxSize) {
    status_t err;

    if (maxSize != NULL) {
@@ -330,7 +288,17 @@ status_t PrivacyFilter::writeData(const FdBuffer& buffer, uint8_t bufferLevel, s
        // Write the resultant buffer to the fd, along with the header.
        ssize_t dataSize = fieldStripper.dataSize();
        if (dataSize > 0) {
            write_section_to_file(mSectionId, fieldStripper, output, encryptIfNeeded);
            err = write_section_header(output->getFd(), mSectionId, dataSize);
            if (err != NO_ERROR) {
                output->onWriteError(err);
                continue;
            }

            err = fieldStripper.writeData(output->getFd());
            if (err != NO_ERROR) {
                output->onWriteError(err);
                continue;
            }
        }

        if (maxSize != NULL) {
@@ -382,18 +350,8 @@ status_t filter_and_write_report(int to, int from, uint8_t bufferLevel,

            // Read this section from the reader into an FdBuffer
            size_t sectionSize = reader->readRawVarint();

            FdBuffer sectionData;

            // Write data to FdBuffer, if the section was encrypted, decrypt first.
            if (sectionEncryption(fieldId)) {
                VLOG("sectionSize %lu", (unsigned long)sectionSize);
                ProtoDecryptor decryptor(reader, sectionSize);
                err = decryptor.decryptAndFlush(&sectionData);
            } else {
            err = sectionData.write(reader, sectionSize);
            }

            if (err != NO_ERROR) {
                ALOGW("filter_and_write_report FdBuffer.write failed (this shouldn't happen): %s",
                        strerror(-err));
@@ -401,8 +359,7 @@ status_t filter_and_write_report(int to, int from, uint8_t bufferLevel,
            }

            // Do the filter and write.
            err = filter.writeData(sectionData, bufferLevel, nullptr,
                                   false /* do not encrypt again*/);
            err = filter.writeData(sectionData, bufferLevel, nullptr);
            if (err != NO_ERROR) {
                ALOGW("filter_and_write_report filter.writeData had an error: %s", strerror(-err));
                return err;
@@ -411,7 +368,6 @@ status_t filter_and_write_report(int to, int from, uint8_t bufferLevel,
            // We don't need this field.  Incident does not have any direct children
            // other than sections.  So just skip them.
            write_field_or_skip(NULL, reader, fieldTag, true);
            VLOG("Skip this.... section %d", fieldId);
        }
    }

Loading