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

Commit 678e2134 authored by android-build-team Robot's avatar android-build-team Robot
Browse files

Snap for 6542686 from 7f357072 to rvc-release

Change-Id: Id4d5eafbfac86414fe2dc3a8e45812efac9428bb
parents 6ac14ea9 7f357072
Loading
Loading
Loading
Loading
+27 −4
Original line number Diff line number Diff line
@@ -447,6 +447,8 @@ public class AppStandbyController implements AppStandbyInternal {
                userFileExists = mAppIdleHistory.userFileExists(UserHandle.USER_SYSTEM);
            }

            loadHeadlessSystemAppCache();

            if (mPendingInitializeDefaults || !userFileExists) {
                initializeDefaultsForSystemApps(UserHandle.USER_SYSTEM);
            }
@@ -1670,6 +1672,8 @@ public class AppStandbyController implements AppStandbyInternal {
                clearCarrierPrivilegedApps();
                // ACTION_PACKAGE_ADDED is called even for system app downgrades.
                evaluateSystemAppException(pkgName, userId);
                mHandler.obtainMessage(MSG_CHECK_PACKAGE_IDLE_STATE, userId, -1, pkgName)
                    .sendToTarget();
            }
            if ((Intent.ACTION_PACKAGE_REMOVED.equals(action) ||
                    Intent.ACTION_PACKAGE_ADDED.equals(action))) {
@@ -1684,7 +1688,7 @@ public class AppStandbyController implements AppStandbyInternal {

    private void evaluateSystemAppException(String packageName, int userId) {
        if (!mSystemServicesReady) {
            // The app will be evaluated in initializeDefaultsForSystemApps() when possible.
            // The app will be evaluated in when services are ready.
            return;
        }
        try {
@@ -1710,6 +1714,7 @@ public class AppStandbyController implements AppStandbyInternal {
        }
    }

    /** Call on a system version update to temporarily reset system app buckets. */
    @Override
    public void initializeDefaultsForSystemApps(int userId) {
        if (!mSystemServicesReady) {
@@ -1721,7 +1726,7 @@ public class AppStandbyController implements AppStandbyInternal {
                + "appIdleEnabled=" + mAppIdleEnabled);
        final long elapsedRealtime = mInjector.elapsedRealtime();
        List<PackageInfo> packages = mPackageManager.getInstalledPackagesAsUser(
                PackageManager.GET_ACTIVITIES | PackageManager.MATCH_DISABLED_COMPONENTS,
                PackageManager.MATCH_DISABLED_COMPONENTS,
                userId);
        final int packageCount = packages.size();
        synchronized (mAppIdleLock) {
@@ -1734,8 +1739,6 @@ public class AppStandbyController implements AppStandbyInternal {
                    mAppIdleHistory.reportUsage(packageName, userId, STANDBY_BUCKET_ACTIVE,
                            REASON_SUB_USAGE_SYSTEM_UPDATE, 0,
                            elapsedRealtime + mSystemUpdateUsageTimeoutMillis);

                    evaluateSystemAppException(pi);
                }
            }
            // Immediately persist defaults to disk
@@ -1743,6 +1746,18 @@ public class AppStandbyController implements AppStandbyInternal {
        }
    }

    /** Call on a system update to temporarily reset system app buckets. */
    private void loadHeadlessSystemAppCache() {
        Slog.d(TAG, "Loading headless system app cache. appIdleEnabled=" + mAppIdleEnabled);
        final List<PackageInfo> packages = mPackageManager.getInstalledPackagesAsUser(
                PackageManager.GET_ACTIVITIES | PackageManager.MATCH_DISABLED_COMPONENTS,
                UserHandle.USER_SYSTEM);
        final int packageCount = packages.size();
        for (int i = 0; i < packageCount; i++) {
            evaluateSystemAppException(packages.get(i));
        }
    }

    @Override
    public void postReportContentProviderUsage(String name, String packageName, int userId) {
        SomeArgs args = SomeArgs.obtain();
@@ -1835,6 +1850,14 @@ public class AppStandbyController implements AppStandbyInternal {
        pw.print("mScreenThresholds="); pw.println(Arrays.toString(mAppStandbyScreenThresholds));
        pw.print("mElapsedThresholds="); pw.println(Arrays.toString(mAppStandbyElapsedThresholds));
        pw.println();

        pw.println("mHeadlessSystemApps=[");
        for (int i = mHeadlessSystemApps.size() - 1; i >= 0; --i) {
            pw.print(mHeadlessSystemApps.keyAt(i));
            pw.println(",");
        }
        pw.println("]");
        pw.println();
    }

    /**
+70 −4
Original line number Diff line number Diff line
@@ -55,6 +55,7 @@ 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.util.ParsableByteArray;
import com.google.android.exoplayer2.util.TimestampAdjuster;
import com.google.android.exoplayer2.util.Util;
import com.google.android.exoplayer2.video.ColorInfo;

@@ -759,7 +760,6 @@ public final class MediaParser {
     */
    public static final String PARAMETER_IN_BAND_CRYPTO_INFO =
            "android.media.mediaparser.inBandCryptoInfo";

    /**
     * Sets whether supplemental data should be included as part of the sample data. {@code boolean}
     * expected. Default value is {@code false}. See {@link #SAMPLE_FLAG_HAS_SUPPLEMENTAL_DATA} for
@@ -769,6 +769,31 @@ public final class MediaParser {
     */
    public static final String PARAMETER_INCLUDE_SUPPLEMENTAL_DATA =
            "android.media.mediaparser.includeSupplementalData";
    /**
     * Sets whether sample timestamps may start from non-zero offsets. {@code boolean} expected.
     * Default value is {@code false}.
     *
     * <p>When set to true, sample timestamps will not be offset to start from zero, and the media
     * provided timestamps will be used instead. For example, transport stream sample timestamps
     * will not be converted to a zero-based timebase.
     *
     * @hide
     */
    public static final String PARAMETER_IGNORE_TIMESTAMP_OFFSET =
            "android.media.mediaparser.ignoreTimestampOffset";
    /**
     * Sets whether each track type should be eagerly exposed. {@code boolean} expected. Default
     * value is {@code false}.
     *
     * <p>When set to true, each track type will be eagerly exposed through a call to {@link
     * OutputConsumer#onTrackDataFound} containing a single-value {@link MediaFormat}. The key for
     * the track type is {@code "track-type-string"}, and the possible values are {@code "video"},
     * {@code "audio"}, {@code "text"}, {@code "metadata"}, and {@code "unknown"}.
     *
     * @hide
     */
    public static final String PARAMETER_EAGERLY_EXPOSE_TRACKTYPE =
            "android.media.mediaparser.eagerlyExposeTrackType";

    // Private constants.

@@ -930,6 +955,8 @@ public final class MediaParser {
    @Nullable private final Constructor<DrmInitData.SchemeInitData> mSchemeInitDataConstructor;
    private boolean mInBandCryptoInfo;
    private boolean mIncludeSupplementalData;
    private boolean mIgnoreTimestampOffset;
    private boolean mEagerlyExposeTrackType;
    private String mParserName;
    private Extractor mExtractor;
    private ExtractorInput mExtractorInput;
@@ -983,6 +1010,12 @@ public final class MediaParser {
        if (PARAMETER_INCLUDE_SUPPLEMENTAL_DATA.equals(parameterName)) {
            mIncludeSupplementalData = (boolean) value;
        }
        if (PARAMETER_IGNORE_TIMESTAMP_OFFSET.equals(parameterName)) {
            mIgnoreTimestampOffset = (boolean) value;
        }
        if (PARAMETER_EAGERLY_EXPOSE_TRACKTYPE.equals(parameterName)) {
            mEagerlyExposeTrackType = (boolean) value;
        }
        mParserParameters.put(parameterName, value);
        return this;
    }
@@ -1159,6 +1192,10 @@ public final class MediaParser {

    private Extractor createExtractor(String parserName) {
        int flags = 0;
        TimestampAdjuster timestampAdjuster = null;
        if (mIgnoreTimestampOffset) {
            timestampAdjuster = new TimestampAdjuster(TimestampAdjuster.DO_NOT_OFFSET);
        }
        switch (parserName) {
            case PARSER_NAME_MATROSKA:
                flags =
@@ -1180,7 +1217,7 @@ public final class MediaParser {
                                ? FragmentedMp4Extractor
                                        .FLAG_WORKAROUND_EVERY_VIDEO_FRAME_IS_SYNC_FRAME
                                : 0;
                return new FragmentedMp4Extractor(flags);
                return new FragmentedMp4Extractor(flags, timestampAdjuster);
            case PARSER_NAME_MP4:
                flags |=
                        getBooleanParameter(PARAMETER_MP4_IGNORE_EDIT_LISTS)
@@ -1238,7 +1275,12 @@ public final class MediaParser {
                                : TS_MODE_HLS.equals(tsMode)
                                        ? TsExtractor.MODE_HLS
                                        : TsExtractor.MODE_MULTI_PMT;
                return new TsExtractor(hlsMode, flags);
                return new TsExtractor(
                        hlsMode,
                        timestampAdjuster != null
                                ? timestampAdjuster
                                : new TimestampAdjuster(/* firstSampleTimestampUs= */ 0),
                        new DefaultTsPayloadReaderFactory(flags));
            case PARSER_NAME_FLV:
                return new FlvExtractor();
            case PARSER_NAME_OGG:
@@ -1340,8 +1382,15 @@ public final class MediaParser {
        public TrackOutput track(int id, int type) {
            TrackOutput trackOutput = mTrackOutputAdapters.get(id);
            if (trackOutput == null) {
                trackOutput = new TrackOutputAdapter(mTrackOutputAdapters.size());
                int trackIndex = mTrackOutputAdapters.size();
                trackOutput = new TrackOutputAdapter(trackIndex);
                mTrackOutputAdapters.put(id, trackOutput);
                if (mEagerlyExposeTrackType) {
                    MediaFormat mediaFormat = new MediaFormat();
                    mediaFormat.setString("track-type-string", toTypeString(type));
                    mOutputConsumer.onTrackDataFound(
                            trackIndex, new TrackData(mediaFormat, /* drmInitData= */ null));
                }
            }
            return trackOutput;
        }
@@ -1662,6 +1711,21 @@ public final class MediaParser {
        return result;
    }

    private static String toTypeString(int type) {
        switch (type) {
            case C.TRACK_TYPE_VIDEO:
                return "video";
            case C.TRACK_TYPE_AUDIO:
                return "audio";
            case C.TRACK_TYPE_TEXT:
                return "text";
            case C.TRACK_TYPE_METADATA:
                return "metadata";
            default:
                return "unknown";
        }
    }

    private static void setPcmEncoding(Format format, MediaFormat result) {
        int exoPcmEncoding = format.pcmEncoding;
        setOptionalMediaFormatInt(result, "exo-pcm-encoding", format.pcmEncoding);
@@ -1800,6 +1864,8 @@ public final class MediaParser {
        expectedTypeByParameterName.put(PARAMETER_TS_ENABLE_HDMV_DTS_AUDIO_STREAMS, Boolean.class);
        expectedTypeByParameterName.put(PARAMETER_IN_BAND_CRYPTO_INFO, Boolean.class);
        expectedTypeByParameterName.put(PARAMETER_INCLUDE_SUPPLEMENTAL_DATA, Boolean.class);
        expectedTypeByParameterName.put(PARAMETER_IGNORE_TIMESTAMP_OFFSET, Boolean.class);
        expectedTypeByParameterName.put(PARAMETER_EAGERLY_EXPOSE_TRACKTYPE, Boolean.class);
        EXPECTED_TYPE_BY_PARAMETER_NAME = Collections.unmodifiableMap(expectedTypeByParameterName);
    }
}
+7 −0
Original line number Diff line number Diff line
{
  "presubmit" : [
    {
      "name" : "PermissionApexTests"
    }
  ]
}
+37 −0
Original line number Diff line number Diff line
// 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.

android_test {
    name: "PermissionApexTests",
    sdk_version: "test_current",
    srcs: [
        "java/**/*.kt",
    ],
    static_libs: [
        "service-permission",
        "androidx.test.rules",
        "androidx.test.ext.junit",
        "androidx.test.ext.truth",
        "mockito-target-extended-minus-junit4",
    ],
    jni_libs: [
        "libdexmakerjvmtiagent",
        "libstaticjvmtiagent",
    ],
    compile_multilib: "both",
    test_suites: [
        "general-tests",
        "mts",
    ],
}
+32 −0
Original line number Diff line number Diff line
<?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.
  -->

<manifest
    xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.android.permission.test">

    <!-- The application has to be debuggable for static mocking to work. -->
    <application android:debuggable="true">
        <uses-library android:name="android.test.runner" />
    </application>

    <instrumentation
        android:name="androidx.test.runner.AndroidJUnitRunner"
        android:targetPackage="com.android.permission.test"
        android:label="Permission APEX Tests" />
</manifest>
Loading