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

Commit 1de95f97 authored by android-build-team Robot's avatar android-build-team Robot
Browse files

Snap for 6399349 from d1f82dd3 to mainline-release

Change-Id: Iab1e25b6719b5aeec2027b7e86413e42fc65ce9e
parents 00fc23e2 d1f82dd3
Loading
Loading
Loading
Loading
+20 −32
Original line number Diff line number Diff line
@@ -51,6 +51,7 @@ import com.google.android.exoplayer2.extractor.ts.DefaultTsPayloadReaderFactory;
import com.google.android.exoplayer2.extractor.ts.PsExtractor;
import com.google.android.exoplayer2.extractor.ts.TsExtractor;
import com.google.android.exoplayer2.extractor.wav.WavExtractor;
import com.google.android.exoplayer2.upstream.DataReader;
import com.google.android.exoplayer2.upstream.DataSource;
import com.google.android.exoplayer2.upstream.DataSpec;
import com.google.android.exoplayer2.upstream.TransferListener;
@@ -60,7 +61,6 @@ import com.google.android.exoplayer2.video.ColorInfo;

import java.io.EOFException;
import java.io.IOException;
import java.io.InterruptedIOException;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.nio.ByteBuffer;
@@ -848,9 +848,9 @@ public final class MediaParser {
    private final String[] mParserNamesPool;
    private final PositionHolder mPositionHolder;
    private final InputReadingDataSource mDataSource;
    private final ExtractorInputAdapter mScratchExtractorInputAdapter;
    private final DataReaderAdapter mScratchDataReaderAdapter;
    private final ParsableByteArrayAdapter mScratchParsableByteArrayAdapter;
    private String mExtractorName;
    private String mParserName;
    private Extractor mExtractor;
    private ExtractorInput mExtractorInput;
    private long mPendingSeekPosition;
@@ -924,7 +924,7 @@ public final class MediaParser {
    @NonNull
    @ParserName
    public String getParserName() {
        return mExtractorName;
        return mParserName;
    }

    /**
@@ -958,25 +958,21 @@ public final class MediaParser {

        // TODO: Apply parameters when creating extractor instances.
        if (mExtractor == null) {
            if (!mExtractorName.equals(PARSER_NAME_UNKNOWN)) {
                mExtractor = EXTRACTOR_FACTORIES_BY_NAME.get(mExtractorName).createInstance();
            if (!mParserName.equals(PARSER_NAME_UNKNOWN)) {
                mExtractor = createExtractor(mParserName);
                mExtractor.init(new ExtractorOutputAdapter());
            } else {
                for (String parserName : mParserNamesPool) {
                    Extractor extractor = createExtractor(parserName);
                    try {
                        if (extractor.sniff(mExtractorInput)) {
                            mExtractorName = parserName;
                            mParserName = parserName;
                            mExtractor = extractor;
                            mExtractor.init(new ExtractorOutputAdapter());
                            break;
                        }
                    } catch (EOFException e) {
                        // Do nothing.
                    } catch (InterruptedException e) {
                        // TODO: Remove this exception replacement once we update the ExoPlayer
                        // version.
                        throw new InterruptedIOException();
                    } finally {
                        mExtractorInput.resetPeekPosition();
                    }
@@ -999,9 +995,6 @@ public final class MediaParser {
            result = mExtractor.read(mExtractorInput, mPositionHolder);
        } catch (ParserException e) {
            throw new ParsingException(e);
        } catch (InterruptedException e) {
            // TODO: Remove this exception replacement once we update the ExoPlayer version.
            throw new InterruptedIOException();
        }
        if (result == Extractor.RESULT_END_OF_INPUT) {
            return false;
@@ -1051,11 +1044,11 @@ public final class MediaParser {
        mParserParameters = new HashMap<>();
        mOutputConsumer = outputConsumer;
        mParserNamesPool = parserNamesPool;
        mExtractorName = sniff ? PARSER_NAME_UNKNOWN : parserNamesPool[0];
        mParserName = sniff ? PARSER_NAME_UNKNOWN : parserNamesPool[0];
        mPositionHolder = new PositionHolder();
        mDataSource = new InputReadingDataSource();
        removePendingSeek();
        mScratchExtractorInputAdapter = new ExtractorInputAdapter();
        mScratchDataReaderAdapter = new DataReaderAdapter();
        mScratchParsableByteArrayAdapter = new ParsableByteArrayAdapter();
    }

@@ -1097,7 +1090,7 @@ public final class MediaParser {
                        getBooleanParameter(PARAMETER_MP4_IGNORE_EDIT_LISTS)
                                ? Mp4Extractor.FLAG_WORKAROUND_IGNORE_EDIT_LISTS
                                : 0;
                return new Mp4Extractor();
                return new Mp4Extractor(flags);
            case PARSER_NAME_MP3:
                flags |=
                        getBooleanParameter(PARAMETER_MP3_DISABLE_ID3)
@@ -1270,12 +1263,12 @@ public final class MediaParser {
        }

        @Override
        public int sampleData(ExtractorInput input, int length, boolean allowEndOfInput)
        public int sampleData(DataReader input, int length, boolean allowEndOfInput)
                throws IOException {
            mScratchExtractorInputAdapter.setExtractorInput(input, length);
            long positionBeforeReading = mScratchExtractorInputAdapter.getPosition();
            mOutputConsumer.onSampleDataFound(mTrackIndex, mScratchExtractorInputAdapter);
            return (int) (mScratchExtractorInputAdapter.getPosition() - positionBeforeReading);
            mScratchDataReaderAdapter.setDataReader(input, length);
            long positionBeforeReading = mScratchDataReaderAdapter.getPosition();
            mOutputConsumer.onSampleDataFound(mTrackIndex, mScratchDataReaderAdapter);
            return (int) (mScratchDataReaderAdapter.getPosition() - positionBeforeReading);
        }

        @Override
@@ -1297,14 +1290,14 @@ public final class MediaParser {
        }
    }

    private static final class ExtractorInputAdapter implements InputReader {
    private static final class DataReaderAdapter implements InputReader {

        private ExtractorInput mExtractorInput;
        private DataReader mDataReader;
        private int mCurrentPosition;
        private long mLength;

        public void setExtractorInput(ExtractorInput extractorInput, long length) {
            mExtractorInput = extractorInput;
        public void setDataReader(DataReader dataReader, long length) {
            mDataReader = dataReader;
            mCurrentPosition = 0;
            mLength = length;
        }
@@ -1314,12 +1307,7 @@ public final class MediaParser {
        @Override
        public int read(byte[] buffer, int offset, int readLength) throws IOException {
            int readBytes = 0;
            try {
                readBytes = mExtractorInput.read(buffer, offset, readLength);
            } catch (InterruptedException e) {
                // TODO: Remove this exception replacement once we update the ExoPlayer version.
                throw new InterruptedIOException();
            }
            readBytes = mDataReader.read(buffer, offset, readLength);
            mCurrentPosition += readBytes;
            return readBytes;
        }
+2 −0
Original line number Diff line number Diff line
@@ -104,6 +104,7 @@ cc_defaults {
        "src/subscriber/IncidentdReporter.cpp",
        "src/subscriber/SubscriberReporter.cpp",
        "src/uid_data.proto",
        "src/utils/NamedLatch.cpp",
    ],

    local_include_dirs: [
@@ -361,6 +362,7 @@ cc_test {
        "tests/StatsService_test.cpp",
        "tests/storage/StorageManager_test.cpp",
        "tests/UidMap_test.cpp",
        "tests/utils/NamedLatch_test.cpp",
    ],

    static_libs: [
+12 −4
Original line number Diff line number Diff line
@@ -118,8 +118,9 @@ StatsService::StatsService(const sp<Looper>& handlerLooper, shared_ptr<LogEventQ
                  }
              })),
      mEventQueue(queue),
      mStatsCompanionServiceDeathRecipient(AIBinder_DeathRecipient_new(
              StatsService::statsCompanionServiceDied)) {
      mBootCompleteLatch({kBootCompleteTag, kUidMapReceivedTag, kAllPullersRegisteredTag}),
      mStatsCompanionServiceDeathRecipient(
              AIBinder_DeathRecipient_new(StatsService::statsCompanionServiceDied)) {
    mUidMap = UidMap::getInstance();
    mPullerManager = new StatsPullerManager();
    StatsPuller::SetUidMap(mUidMap);
@@ -164,6 +165,12 @@ StatsService::StatsService(const sp<Looper>& handlerLooper, shared_ptr<LogEventQ
        std::thread pushedEventThread([this] { readLogs(); });
        pushedEventThread.detach();
    }

    std::thread bootCompletedThread([this] {
        mBootCompleteLatch.wait();
        VLOG("In the boot completed thread");
    });
    bootCompletedThread.detach();
}

StatsService::~StatsService() {
@@ -939,6 +946,7 @@ Status StatsService::informAllUidData(const ScopedFileDescriptor& fd) {
                       packageNames,
                       installers);

    mBootCompleteLatch.countDown(kUidMapReceivedTag);
    VLOG("StatsService::informAllUidData UidData proto parsed successfully.");
    return Status::ok();
}
@@ -1058,7 +1066,7 @@ Status StatsService::bootCompleted() {
    ENFORCE_UID(AID_SYSTEM);

    VLOG("StatsService::bootCompleted was called");

    mBootCompleteLatch.countDown(kBootCompleteTag);
    return Status::ok();
}

@@ -1227,7 +1235,7 @@ Status StatsService::allPullersFromBootRegistered() {
    ENFORCE_UID(AID_SYSTEM);

    VLOG("StatsService::allPullersFromBootRegistered was called");

    mBootCompleteLatch.countDown(kAllPullersRegisteredTag);
    return Status::ok();
}

+13 −7
Original line number Diff line number Diff line
@@ -17,7 +17,14 @@
#ifndef STATS_SERVICE_H
#define STATS_SERVICE_H

#include <aidl/android/os/BnStatsd.h>
#include <aidl/android/os/IPendingIntentRef.h>
#include <aidl/android/os/IPullAtomCallback.h>
#include <gtest/gtest_prod.h>
#include <utils/Looper.h>

#include <mutex>

#include "StatsLogProcessor.h"
#include "anomaly/AlarmMonitor.h"
#include "config/ConfigManager.h"
@@ -26,13 +33,7 @@
#include "packages/UidMap.h"
#include "shell/ShellSubscriber.h"
#include "statscompanion_util.h"

#include <aidl/android/os/BnStatsd.h>
#include <aidl/android/os/IPendingIntentRef.h>
#include <aidl/android/os/IPullAtomCallback.h>
#include <utils/Looper.h>

#include <mutex>
#include "utils/NamedLatch.h"

using namespace android;
using namespace android::os;
@@ -385,6 +386,11 @@ private:
    mutable mutex mShellSubscriberMutex;
    std::shared_ptr<LogEventQueue> mEventQueue;

    NamedLatch mBootCompleteLatch;
    static const inline string kBootCompleteTag = "BOOT_COMPLETE";
    static const inline string kUidMapReceivedTag = "UID_MAP";
    static const inline string kAllPullersRegisteredTag = "PULLERS_REGISTERED";

    ScopedAIBinder_DeathRecipient mStatsCompanionServiceDeathRecipient;

    FRIEND_TEST(StatsLogProcessorTest, TestActivationsPersistAcrossSystemServerRestart);
+81 −0
Original line number Diff line number Diff line
@@ -421,6 +421,8 @@ message Atom {
        TvSettingsUIInteracted tvsettings_ui_interacted = 261 [(module) = "tv_settings"];
        LauncherStaticLayout launcher_snapshot = 262 [(module) = "sysui"];
        PackageInstallerV2Reported package_installer_v2_reported = 263 [(module) = "framework"];
        UserLifecycleJourneyReported user_lifecycle_journey_reported = 264 [(module) = "framework"];
        UserLifecycleEventOccurred user_lifecycle_event_occurred = 265 [(module) = "framework"];
        SdkExtensionStatus sdk_extension_status = 354;
    }

@@ -9357,3 +9359,82 @@ message SettingSnapshot {
    // Android user index. 0 for primary user, 10, 11 for secondary or profile user
    optional int32 user_id = 7;
}

/**
 * An event logged to indicate that a user journey is about to be performed. This atom includes
 * relevant information about the users involved in the journey. A UserLifecycleEventOccurred event
 * will immediately follow this atom which will describe the event(s) and its state.
 *
 * Logged from:
 *   frameworks/base/services/core/java/com/android/server/am/UserController.java
 *   frameworks/base/services/core/java/com/android/server/pm/UserManagerService.java
 */
message UserLifecycleJourneyReported {
    // An identifier to track a chain of user lifecycle events occurring (referenced in the
    // UserLifecycleEventOccurred atom)
    optional int64 session_id = 1;

    // Indicates what type of user journey this session is related to
    enum Journey {
        UNKNOWN = 0; // Undefined user lifecycle journey
        USER_SWITCH_UI = 1; // A user switch journey where a UI is shown
        USER_SWITCH_FG = 2; // A user switch journey without a UI shown
        USER_START = 3; // A user start journey
        USER_CREATE = 4; // A user creation journey
    }
    optional Journey journey = 2;
    // Which user the journey is originating from - could be -1 for certain phases (eg USER_CREATE)
    // This integer is a UserIdInt (eg 0 for the system user, 10 for secondary/guest)
    optional int32 origin_user = 3;
    // Which user the journey is targeting
    // This integer is a UserIdInt (eg 0 for the system user, 10 for secondary/guest)
    optional int32 target_user = 4;

    // What is the user type of the target user
    // These should be in sync with USER_TYPE_* flags defined in UserManager.java
    enum UserType {
        TYPE_UNKNOWN = 0;
        FULL_SYSTEM = 1;
        FULL_SECONDARY = 2;
        FULL_GUEST = 3;
        FULL_DEMO = 4;
        FULL_RESTRICTED = 5;
        PROFILE_MANAGED = 6;
        SYSTEM_HEADLESS = 7;
    }
    optional UserType user_type = 5;
    // What are the flags attached to the target user
    optional int32 user_flags = 6;
}

/**
 * An event logged when a specific user lifecycle event is performed. These events should be
 * correlated with a UserLifecycleJourneyReported atom via the session_id.
 * Note: journeys can span over multiple events, hence some events may share a single session id.
 *
 * Logged from:
 *   frameworks/base/services/core/java/com/android/server/am/UserController.java
 *   frameworks/base/services/core/java/com/android/server/pm/UserManagerService.java
 */
message UserLifecycleEventOccurred {
    // An id which links back to user details (reported in the UserLifecycleJourneyReported atom)
    optional int64 session_id = 1;
    // The target user for this event (same as target_user in the UserLifecycleJourneyReported atom)
    // This integer is a UserIdInt (eg 0 for the system user, 10 for secondary/guest)
    optional int32 user_id = 2;

    enum Event {
        UNKNOWN = 0; // Indicates that the associated user journey timed-out or resulted in an error
        SWITCH_USER = 1; // Indicates that this is a user switch event
        START_USER = 2; // Indicates that this is a user start event
        CREATE_USER = 3; // Indicates that this is a user create event
    }
    optional Event event = 3;

    enum State {
        NONE = 0; // Indicates the associated event has no start/end defined
        BEGIN = 1;
        FINISH = 2;
    }
    optional State state = 4; // Represents the state of an event (beginning/ending)
}
Loading