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

Commit 02c163f4 authored by android-build-team Robot's avatar android-build-team Robot
Browse files

Snap for 6485046 from 58e04685 to mainline-release

Change-Id: Ia6efb4e19871a9feba68abf9590ea61bf618d012
parents 5c6b5627 58e04685
Loading
Loading
Loading
Loading
+169 −12
Original line number Diff line number Diff line
@@ -65,6 +65,7 @@ import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import java.nio.ByteBuffer;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.LinkedHashMap;
@@ -709,6 +710,35 @@ public final class MediaParser {
     */
    public static final String PARAMETER_TS_ENABLE_HDMV_DTS_AUDIO_STREAMS =
            "android.media.mediaparser.ts.enableHdmvDtsAudioStreams";
    /**
     * Sets whether encryption data should be sent in-band with the sample data, as per {@link
     * OutputConsumer#onSampleDataFound}. {@code boolean} expected. Default value is {@code false}.
     *
     * <p>If this parameter is set, encrypted samples' data will be prefixed with the encryption
     * information bytes. The format for in-band encryption information is:
     *
     * <ul>
     *   <li>(1 byte) {@code encryption_signal_byte}: Most significant bit signals whether the
     *       encryption data contains subsample encryption data. The remaining bits contain {@code
     *       initialization_vector_size}.
     *   <li>({@code initialization_vector_size} bytes) Initialization vector.
     *   <li>If subsample encryption data is present, as per {@code encryption_signal_byte}, the
     *       encryption data also contains:
     *       <ul>
     *         <li>(2 bytes) {@code subsample_encryption_data_length}.
     *         <li>({@code subsample_encryption_data_length * 6} bytes) Subsample encryption data
     *             (repeated {@code subsample_encryption_data_length} times):
     *             <ul>
     *               <li>(2 bytes) Size of a clear section in sample.
     *               <li>(4 bytes) Size of an encryption section in sample.
     *             </ul>
     *       </ul>
     * </ul>
     *
     * @hide
     */
    public static final String PARAMETER_IN_BAND_CRYPTO_INFO =
            "android.media.mediaparser.inBandCryptoInfo";

    // Private constants.

@@ -718,6 +748,21 @@ public final class MediaParser {
    private static final String TS_MODE_SINGLE_PMT = "single_pmt";
    private static final String TS_MODE_MULTI_PMT = "multi_pmt";
    private static final String TS_MODE_HLS = "hls";
    private static final int BYTES_PER_SUBSAMPLE_ENCRYPTION_ENTRY = 6;

    @IntDef(
            value = {
                STATE_READING_SIGNAL_BYTE,
                STATE_READING_INIT_VECTOR,
                STATE_READING_SUBSAMPLE_ENCRYPTION_SIZE,
                STATE_READING_SUBSAMPLE_ENCRYPTION_DATA
            })
    private @interface EncryptionDataReadState {}

    private static final int STATE_READING_SIGNAL_BYTE = 0;
    private static final int STATE_READING_INIT_VECTOR = 1;
    private static final int STATE_READING_SUBSAMPLE_ENCRYPTION_SIZE = 2;
    private static final int STATE_READING_SUBSAMPLE_ENCRYPTION_DATA = 3;

    // Instance creation methods.

@@ -853,6 +898,7 @@ public final class MediaParser {
    private final DataReaderAdapter mScratchDataReaderAdapter;
    private final ParsableByteArrayAdapter mScratchParsableByteArrayAdapter;
    @Nullable private final Constructor<DrmInitData.SchemeInitData> mSchemeInitDataConstructor;
    private boolean mInBandCryptoInfo;
    private String mParserName;
    private Extractor mExtractor;
    private ExtractorInput mExtractorInput;
@@ -900,6 +946,9 @@ public final class MediaParser {
                && !TS_MODE_MULTI_PMT.equals(value)) {
            throw new IllegalArgumentException(PARAMETER_TS_MODE + " does not accept: " + value);
        }
        if (PARAMETER_IN_BAND_CRYPTO_INFO.equals(parameterName)) {
            mInBandCryptoInfo = (boolean) value;
        }
        mParserParameters.put(parameterName, value);
        return this;
    }
@@ -1274,9 +1323,23 @@ public final class MediaParser {
    private class TrackOutputAdapter implements TrackOutput {

        private final int mTrackIndex;
        private final CryptoInfo mCryptoInfo;

        @EncryptionDataReadState private int mEncryptionDataReadState;
        private int mEncryptionDataSizeToSubtractFromSampleDataSize;
        private int mEncryptionVectorSize;
        private boolean mHasSubsampleEncryptionData;
        private CryptoInfo.Pattern mEncryptionPattern;

        private TrackOutputAdapter(int trackIndex) {
            mTrackIndex = trackIndex;
            mCryptoInfo = new CryptoInfo();
            mCryptoInfo.iv = new byte[16]; // Size documented in CryptoInfo.
            mCryptoInfo.numBytesOfClearData = new int[0];
            mCryptoInfo.numBytesOfEncryptedData = new int[0];
            mEncryptionDataReadState = STATE_READING_SIGNAL_BYTE;
            mEncryptionPattern =
                    new CryptoInfo.Pattern(/* blocksToEncrypt= */ 0, /* blocksToSkip= */ 0);
        }

        @Override
@@ -1303,6 +1366,98 @@ public final class MediaParser {
        @Override
        public void sampleData(
                ParsableByteArray data, int length, @SampleDataPart int sampleDataPart) {
            if (sampleDataPart == SAMPLE_DATA_PART_ENCRYPTION && !mInBandCryptoInfo) {
                while (length > 0) {
                    switch (mEncryptionDataReadState) {
                        case STATE_READING_SIGNAL_BYTE:
                            int encryptionSignalByte = data.readUnsignedByte();
                            length--;
                            mHasSubsampleEncryptionData = ((encryptionSignalByte >> 7) & 1) != 0;
                            mEncryptionVectorSize = encryptionSignalByte & 0x7F;
                            mEncryptionDataSizeToSubtractFromSampleDataSize =
                                    mEncryptionVectorSize + 1; // Signal byte.
                            mEncryptionDataReadState = STATE_READING_INIT_VECTOR;
                            break;
                        case STATE_READING_INIT_VECTOR:
                            Arrays.fill(mCryptoInfo.iv, (byte) 0); // Ensure 0-padding.
                            data.readBytes(mCryptoInfo.iv, /* offset= */ 0, mEncryptionVectorSize);
                            length -= mEncryptionVectorSize;
                            if (mHasSubsampleEncryptionData) {
                                mEncryptionDataReadState = STATE_READING_SUBSAMPLE_ENCRYPTION_SIZE;
                            } else {
                                mCryptoInfo.numSubSamples = 0;
                                mEncryptionDataReadState = STATE_READING_SIGNAL_BYTE;
                            }
                            break;
                        case STATE_READING_SUBSAMPLE_ENCRYPTION_SIZE:
                            int numSubSamples = data.readUnsignedShort();
                            mCryptoInfo.numSubSamples = numSubSamples;
                            if (mCryptoInfo.numBytesOfClearData.length < numSubSamples) {
                                mCryptoInfo.numBytesOfClearData = new int[numSubSamples];
                                mCryptoInfo.numBytesOfEncryptedData = new int[numSubSamples];
                            }
                            length -= 2;
                            mEncryptionDataSizeToSubtractFromSampleDataSize +=
                                    2 + numSubSamples * BYTES_PER_SUBSAMPLE_ENCRYPTION_ENTRY;
                            mEncryptionDataReadState = STATE_READING_SUBSAMPLE_ENCRYPTION_DATA;
                            break;
                        case STATE_READING_SUBSAMPLE_ENCRYPTION_DATA:
                            for (int i = 0; i < mCryptoInfo.numSubSamples; i++) {
                                mCryptoInfo.numBytesOfClearData[i] = data.readUnsignedShort();
                                mCryptoInfo.numBytesOfEncryptedData[i] = data.readInt();
                            }
                            length -=
                                    mCryptoInfo.numSubSamples
                                            * BYTES_PER_SUBSAMPLE_ENCRYPTION_ENTRY;
                            mEncryptionDataReadState = STATE_READING_SIGNAL_BYTE;
                            if (length != 0) {
                                throw new IllegalStateException();
                            }
                            break;
                        default:
                            // Never happens.
                            throw new IllegalStateException();
                    }
                }
            } else {
                outputSampleData(data, length);
            }
        }

        @Override
        public void sampleMetadata(
                long timeUs, int flags, int size, int offset, @Nullable CryptoData cryptoData) {
            mOutputConsumer.onSampleCompleted(
                    mTrackIndex,
                    timeUs,
                    getMediaParserFlags(flags),
                    size - mEncryptionDataSizeToSubtractFromSampleDataSize,
                    offset,
                    getPopulatedCryptoInfo(cryptoData));
            mEncryptionDataReadState = STATE_READING_SIGNAL_BYTE;
            mEncryptionDataSizeToSubtractFromSampleDataSize = 0;
        }

        @Nullable
        private CryptoInfo getPopulatedCryptoInfo(@Nullable CryptoData cryptoData) {
            if (cryptoData == null) {
                // The sample is not encrypted.
                return null;
            }
            mCryptoInfo.key = cryptoData.encryptionKey;
            // ExoPlayer modes match MediaCodec modes.
            mCryptoInfo.mode = cryptoData.cryptoMode;
            if (cryptoData.clearBlocks != 0) {
                // Content is pattern-encrypted.
                mCryptoInfo.setPattern(mEncryptionPattern);
                mEncryptionPattern.set(cryptoData.encryptedBlocks, cryptoData.clearBlocks);
            } else {
                mCryptoInfo.setPattern(null);
            }
            return mCryptoInfo;
        }

        private void outputSampleData(ParsableByteArray data, int length) {
            mScratchParsableByteArrayAdapter.resetWithByteArray(data, length);
            try {
                mOutputConsumer.onSampleDataFound(mTrackIndex, mScratchParsableByteArrayAdapter);
@@ -1311,13 +1466,6 @@ public final class MediaParser {
                throw new RuntimeException(e);
            }
        }

        @Override
        public void sampleMetadata(
                long timeUs, int flags, int size, int offset, CryptoData encryptionData) {
            mOutputConsumer.onSampleCompleted(
                    mTrackIndex, timeUs, flags, size, offset, toCryptoInfo(encryptionData));
        }
    }

    private static final class DataReaderAdapter implements InputReader {
@@ -1519,11 +1667,6 @@ public final class MediaParser {
        }
    }

    private static CryptoInfo toCryptoInfo(TrackOutput.CryptoData encryptionData) {
        // TODO: Implement.
        return null;
    }

    /** Returns a new {@link SeekPoint} equivalent to the given {@code exoPlayerSeekPoint}. */
    private static SeekPoint toSeekPoint(
            com.google.android.exoplayer2.extractor.SeekPoint exoPlayerSeekPoint) {
@@ -1543,6 +1686,19 @@ public final class MediaParser {
        }
    }

    private static int getMediaParserFlags(int flags) {
        @SampleFlags int result = 0;
        result |= (flags & C.BUFFER_FLAG_ENCRYPTED) != 0 ? SAMPLE_FLAG_ENCRYPTED : 0;
        result |= (flags & C.BUFFER_FLAG_KEY_FRAME) != 0 ? SAMPLE_FLAG_KEY_FRAME : 0;
        result |= (flags & C.BUFFER_FLAG_DECODE_ONLY) != 0 ? SAMPLE_FLAG_DECODE_ONLY : 0;
        result |=
                (flags & C.BUFFER_FLAG_HAS_SUPPLEMENTAL_DATA) != 0
                        ? SAMPLE_FLAG_HAS_SUPPLEMENTAL_DATA
                        : 0;
        result |= (flags & C.BUFFER_FLAG_LAST_SAMPLE) != 0 ? SAMPLE_FLAG_LAST_SAMPLE : 0;
        return result;
    }

    @Nullable
    private static Constructor<DrmInitData.SchemeInitData> getSchemeInitDataConstructor() {
        // TODO: Use constructor statically when available.
@@ -1598,6 +1754,7 @@ public final class MediaParser {
        expectedTypeByParameterName.put(PARAMETER_TS_IGNORE_SPLICE_INFO_STREAM, Boolean.class);
        expectedTypeByParameterName.put(PARAMETER_TS_DETECT_ACCESS_UNITS, Boolean.class);
        expectedTypeByParameterName.put(PARAMETER_TS_ENABLE_HDMV_DTS_AUDIO_STREAMS, Boolean.class);
        expectedTypeByParameterName.put(PARAMETER_IN_BAND_CRYPTO_INFO, Boolean.class);
        EXPECTED_TYPE_BY_PARAMETER_NAME = Collections.unmodifiableMap(expectedTypeByParameterName);
    }
}
+1 −1
Original line number Diff line number Diff line
@@ -1306,7 +1306,7 @@ status_t BootAnimation::TimeCheckThread::readyToRun() {
    if (mSystemWd < 0) {
        close(mInotifyFd);
        mInotifyFd = -1;
        SLOGE("Could not add watch for %s", SYSTEM_DATA_DIR_PATH);
        SLOGE("Could not add watch for %s: %s", SYSTEM_DATA_DIR_PATH, strerror(errno));
        return NO_INIT;
    }

+146 −2
Original line number Diff line number Diff line
@@ -429,6 +429,16 @@ message Atom {
        AccessibilityServiceReported accessibility_service_reported = 267 [(module) = "settings"];
        DocsUIDragAndDropReported docs_ui_drag_and_drop_reported = 268 [(module) = "docsui"];
        AppUsageEventOccurred app_usage_event_occurred = 269 [(module) = "framework"];
        AutoRevokeNotificationClicked auto_revoke_notification_clicked =
            270 [(module) = "permissioncontroller"];
        AutoRevokeFragmentAppViewed auto_revoke_fragment_app_viewed =
            271 [(module) = "permissioncontroller"];
        AutoRevokedAppInteraction auto_revoked_app_interaction =
            272 [(module) = "permissioncontroller", (module) = "settings"];
        AppPermissionGroupsFragmentAutoRevokeAction
            app_permission_groups_fragment_auto_revoke_action =
            273 [(module) = "permissioncontroller"];
        EvsUsageStatsReported evs_usage_stats_reported = 274 [(module) = "evs"];
        SdkExtensionStatus sdk_extension_status = 354;

        // StatsdStats tracks platform atoms with ids upto 500.
@@ -8210,7 +8220,8 @@ message AppPermissionFragmentViewed {
}

/**
* Information about a AppPermissionsFragment viewed by user
* Information about a AppPermissionGroupsFragment viewed by user. Fragment has been renamed, but
* the log retains the old fragment name.
*/
message AppPermissionsFragmentViewed {
    // id which identifies single session of user interacting with permission controller
@@ -8238,7 +8249,6 @@ message AppPermissionsFragmentViewed {
    }
    optional Category category = 6;
}

/**
* Information about a PermissionAppsFragment viewed by user.
* Logged from ui/handheld/PermissionAppsFragment.java
@@ -8270,6 +8280,99 @@ message PermissionAppsFragmentViewed {
    optional Category category = 6;
}

/**
* Log that the Auto Revoke notification has been clicked
* Logged from ui/ManagePermissionsActivity
*/
message AutoRevokeNotificationClicked {
    // id which identifies single session of user interacting with permission controller
    optional int64 session_id = 1;
}

/**
* Log that an app has been displayed on the auto revoke page, and lists one permission that was
* auto revoked for it.
* Logged from ui/handheld/AutoRevokeFragment
*/
message AutoRevokeFragmentAppViewed {
    // id which identifies single session of user interacting with permission controller
    optional int64 session_id = 1;

    // UID of package for which permissions are viewed
    optional int32 uid = 2 [(is_uid) = true];

    // Name of package for which permissions are viewed
    optional string package_name = 3;

    // The name of a permission group that has been revoked
    optional string permission_group_name = 4;

    // The age of the app- more than three months old, or more than six months
    enum Age {
        UNDEFINED = 0;
        NEWER_BUCKET = 1;
        OLDER_BUCKET = 2;
    }

    // How long the app has been unused. Currently, newer bucket is 3 months, older is 6 months
    optional Age age = 5;
}

/**
* Log that the user has interacted with an app on the auto revoke fragment
* Logged from ui/handheld/AutoRevokeFragment
*/
message AutoRevokedAppInteraction {
    // id which identifies single session of user interacting with permission controller
    optional int64 session_id = 1;

    // UID of package for which permissions are viewed
    optional int32 uid = 2 [(is_uid) = true];

    // Name of package for which permissions are viewed
    optional string package_name = 3;

    enum Action {
        UNDEFINED = 0;
        REMOVE = 1;
        OPEN = 2;
        APP_INFO = 3;
        PERMISSIONS = 4;
        REMOVE_IN_SETTINGS = 5;
        OPEN_IN_SETTINGS = 6;
    }

    // The action the user took to interact with the app
    optional Action action = 4;
}

/**
* Log that the AppPermissionGroupsFragment has been interacted with for the possible purposes of
* auto revoke, or that the auto revoke switch has been changed
* Logged from ui/handheld/AppPermissionGroupsFragment
 */
message AppPermissionGroupsFragmentAutoRevokeAction {
    // id which identifies single session of user interacting with permission controller
    optional int64 session_id = 1;

    // UID of package for which permissions are viewed
    optional int32 uid = 2 [(is_uid) = true];

    // Name of package for which permissions are viewed
    optional string package_name = 3;

    enum Action {
        UNDEFINED = 0;
        OPENED_FOR_AUTO_REVOKE = 1;
        OPENED_FROM_INTENT = 2;
        SWITCH_ENABLED = 3;
        SWITCH_DISABLED = 4;
    }

    // The action the user took to interact with the fragment
    optional Action action = 4;
}

/**
 * Logs when there is a smart selection related event.
 * See frameworks/base/core/java/android/view/textclassifier/TextClassifierEvent.java
@@ -9545,3 +9648,44 @@ message AppUsageEventOccurred {
    }
    optional EventType event_type = 4;
}

/*
 * Quality metrics logged when EVS cameras are active.
 *
 * Logged from:
 *  packages/services/Car/evs/manager/1.1/Enumerator.cpp
 */
message EvsUsageStatsReported {

    // Camera identifier to distinguish the source camera device.  This is not
    // globally unique and therefore cannot be used to identify the user and/or
    // the device.
    optional int32 device_id = 1;

    // Peak number of clients during the service
    optional int32 peak_num_clients = 2;

    // Number of erroneous events during the service
    optional int32 num_errors = 3;

    // Round trip latency of the very first frame
    optional int64 first_latency_millis = 4;

    // Average frame round trip latency
    optional float avg_latency_millis = 5;

    // Peak frame round trip latency
    optional int64 peak_latency_millis = 6;

    // Total number of frames received
    optional int64 total_frames = 7;

    // Number of frames ignored
    optional int64 ignored_frames = 8;

    // Number of dropped frames to synchronize camera devices
    optional int64 dropped_frames_to_sync = 9;

    // The duration of the service
    optional int64 duration_millis = 10;
}
+1 −1
Original line number Diff line number Diff line
@@ -6420,7 +6420,7 @@ public final class ActivityThread extends ClientTransactionHandler {
        // Allow binder tracing, and application-generated systrace messages if we're profileable.
        boolean isAppProfileable = data.appInfo.isProfileableByShell();
        Trace.setAppTracingAllowed(isAppProfileable);
        if (isAppProfileable && data.enableBinderTracking) {
        if ((isAppProfileable || Build.IS_DEBUGGABLE) && data.enableBinderTracking) {
            Binder.enableTracing();
        }

+3 −2
Original line number Diff line number Diff line
@@ -90,6 +90,7 @@ import android.widget.FrameLayout;
import android.widget.ImageButton;
import android.widget.LinearLayout;
import android.widget.TextView;
import android.window.WindowMetricsHelper;

import com.android.internal.annotations.GuardedBy;
import com.android.internal.inputmethod.IInputContentUriToken;
@@ -1438,8 +1439,8 @@ public class InputMethodService extends AbstractInputMethodService {
     */
    public int getMaxWidth() {
        final WindowManager windowManager = getSystemService(WindowManager.class);
        final Rect windowBounds = windowManager.getCurrentWindowMetrics().getBounds();
        return windowBounds.width();
        return WindowMetricsHelper.getBoundsExcludingNavigationBarAndCutout(
                windowManager.getCurrentWindowMetrics()).width();
    }
    
    /**
Loading