Skip to content

Commit 678e213

Browse files
author
android-build-team Robot
committed
Snap for 6542686 from 7f35707 to rvc-release
Change-Id: Id4d5eafbfac86414fe2dc3a8e45812efac9428bb
2 parents 6ac14ea + 7f35707 commit 678e213

154 files changed

Lines changed: 11970 additions & 16465 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

apex/jobscheduler/service/java/com/android/server/usage/AppStandbyController.java

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -447,6 +447,8 @@ public void onBootPhase(int phase) {
447447
userFileExists = mAppIdleHistory.userFileExists(UserHandle.USER_SYSTEM);
448448
}
449449

450+
loadHeadlessSystemAppCache();
451+
450452
if (mPendingInitializeDefaults || !userFileExists) {
451453
initializeDefaultsForSystemApps(UserHandle.USER_SYSTEM);
452454
}
@@ -1670,6 +1672,8 @@ public void onReceive(Context context, Intent intent) {
16701672
clearCarrierPrivilegedApps();
16711673
// ACTION_PACKAGE_ADDED is called even for system app downgrades.
16721674
evaluateSystemAppException(pkgName, userId);
1675+
mHandler.obtainMessage(MSG_CHECK_PACKAGE_IDLE_STATE, userId, -1, pkgName)
1676+
.sendToTarget();
16731677
}
16741678
if ((Intent.ACTION_PACKAGE_REMOVED.equals(action) ||
16751679
Intent.ACTION_PACKAGE_ADDED.equals(action))) {
@@ -1684,7 +1688,7 @@ public void onReceive(Context context, Intent intent) {
16841688

16851689
private void evaluateSystemAppException(String packageName, int userId) {
16861690
if (!mSystemServicesReady) {
1687-
// The app will be evaluated in initializeDefaultsForSystemApps() when possible.
1691+
// The app will be evaluated in when services are ready.
16881692
return;
16891693
}
16901694
try {
@@ -1710,6 +1714,7 @@ private void evaluateSystemAppException(@Nullable PackageInfo pkgInfo) {
17101714
}
17111715
}
17121716

1717+
/** Call on a system version update to temporarily reset system app buckets. */
17131718
@Override
17141719
public void initializeDefaultsForSystemApps(int userId) {
17151720
if (!mSystemServicesReady) {
@@ -1721,7 +1726,7 @@ public void initializeDefaultsForSystemApps(int userId) {
17211726
+ "appIdleEnabled=" + mAppIdleEnabled);
17221727
final long elapsedRealtime = mInjector.elapsedRealtime();
17231728
List<PackageInfo> packages = mPackageManager.getInstalledPackagesAsUser(
1724-
PackageManager.GET_ACTIVITIES | PackageManager.MATCH_DISABLED_COMPONENTS,
1729+
PackageManager.MATCH_DISABLED_COMPONENTS,
17251730
userId);
17261731
final int packageCount = packages.size();
17271732
synchronized (mAppIdleLock) {
@@ -1734,15 +1739,25 @@ public void initializeDefaultsForSystemApps(int userId) {
17341739
mAppIdleHistory.reportUsage(packageName, userId, STANDBY_BUCKET_ACTIVE,
17351740
REASON_SUB_USAGE_SYSTEM_UPDATE, 0,
17361741
elapsedRealtime + mSystemUpdateUsageTimeoutMillis);
1737-
1738-
evaluateSystemAppException(pi);
17391742
}
17401743
}
17411744
// Immediately persist defaults to disk
17421745
mAppIdleHistory.writeAppIdleTimes(userId);
17431746
}
17441747
}
17451748

1749+
/** Call on a system update to temporarily reset system app buckets. */
1750+
private void loadHeadlessSystemAppCache() {
1751+
Slog.d(TAG, "Loading headless system app cache. appIdleEnabled=" + mAppIdleEnabled);
1752+
final List<PackageInfo> packages = mPackageManager.getInstalledPackagesAsUser(
1753+
PackageManager.GET_ACTIVITIES | PackageManager.MATCH_DISABLED_COMPONENTS,
1754+
UserHandle.USER_SYSTEM);
1755+
final int packageCount = packages.size();
1756+
for (int i = 0; i < packageCount; i++) {
1757+
evaluateSystemAppException(packages.get(i));
1758+
}
1759+
}
1760+
17461761
@Override
17471762
public void postReportContentProviderUsage(String name, String packageName, int userId) {
17481763
SomeArgs args = SomeArgs.obtain();
@@ -1835,6 +1850,14 @@ public void dumpState(String[] args, PrintWriter pw) {
18351850
pw.print("mScreenThresholds="); pw.println(Arrays.toString(mAppStandbyScreenThresholds));
18361851
pw.print("mElapsedThresholds="); pw.println(Arrays.toString(mAppStandbyElapsedThresholds));
18371852
pw.println();
1853+
1854+
pw.println("mHeadlessSystemApps=[");
1855+
for (int i = mHeadlessSystemApps.size() - 1; i >= 0; --i) {
1856+
pw.print(mHeadlessSystemApps.keyAt(i));
1857+
pw.println(",");
1858+
}
1859+
pw.println("]");
1860+
pw.println();
18381861
}
18391862

18401863
/**

apex/media/framework/java/android/media/MediaParser.java

Lines changed: 70 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@
5555
import com.google.android.exoplayer2.extractor.wav.WavExtractor;
5656
import com.google.android.exoplayer2.upstream.DataReader;
5757
import com.google.android.exoplayer2.util.ParsableByteArray;
58+
import com.google.android.exoplayer2.util.TimestampAdjuster;
5859
import com.google.android.exoplayer2.util.Util;
5960
import com.google.android.exoplayer2.video.ColorInfo;
6061

@@ -759,7 +760,6 @@ private ParsingException(ParserException cause) {
759760
*/
760761
public static final String PARAMETER_IN_BAND_CRYPTO_INFO =
761762
"android.media.mediaparser.inBandCryptoInfo";
762-
763763
/**
764764
* Sets whether supplemental data should be included as part of the sample data. {@code boolean}
765765
* expected. Default value is {@code false}. See {@link #SAMPLE_FLAG_HAS_SUPPLEMENTAL_DATA} for
@@ -769,6 +769,31 @@ private ParsingException(ParserException cause) {
769769
*/
770770
public static final String PARAMETER_INCLUDE_SUPPLEMENTAL_DATA =
771771
"android.media.mediaparser.includeSupplementalData";
772+
/**
773+
* Sets whether sample timestamps may start from non-zero offsets. {@code boolean} expected.
774+
* Default value is {@code false}.
775+
*
776+
* <p>When set to true, sample timestamps will not be offset to start from zero, and the media
777+
* provided timestamps will be used instead. For example, transport stream sample timestamps
778+
* will not be converted to a zero-based timebase.
779+
*
780+
* @hide
781+
*/
782+
public static final String PARAMETER_IGNORE_TIMESTAMP_OFFSET =
783+
"android.media.mediaparser.ignoreTimestampOffset";
784+
/**
785+
* Sets whether each track type should be eagerly exposed. {@code boolean} expected. Default
786+
* value is {@code false}.
787+
*
788+
* <p>When set to true, each track type will be eagerly exposed through a call to {@link
789+
* OutputConsumer#onTrackDataFound} containing a single-value {@link MediaFormat}. The key for
790+
* the track type is {@code "track-type-string"}, and the possible values are {@code "video"},
791+
* {@code "audio"}, {@code "text"}, {@code "metadata"}, and {@code "unknown"}.
792+
*
793+
* @hide
794+
*/
795+
public static final String PARAMETER_EAGERLY_EXPOSE_TRACKTYPE =
796+
"android.media.mediaparser.eagerlyExposeTrackType";
772797

773798
// Private constants.
774799

@@ -930,6 +955,8 @@ public static List<String> getParserNames(@NonNull MediaFormat mediaFormat) {
930955
@Nullable private final Constructor<DrmInitData.SchemeInitData> mSchemeInitDataConstructor;
931956
private boolean mInBandCryptoInfo;
932957
private boolean mIncludeSupplementalData;
958+
private boolean mIgnoreTimestampOffset;
959+
private boolean mEagerlyExposeTrackType;
933960
private String mParserName;
934961
private Extractor mExtractor;
935962
private ExtractorInput mExtractorInput;
@@ -983,6 +1010,12 @@ public MediaParser setParameter(
9831010
if (PARAMETER_INCLUDE_SUPPLEMENTAL_DATA.equals(parameterName)) {
9841011
mIncludeSupplementalData = (boolean) value;
9851012
}
1013+
if (PARAMETER_IGNORE_TIMESTAMP_OFFSET.equals(parameterName)) {
1014+
mIgnoreTimestampOffset = (boolean) value;
1015+
}
1016+
if (PARAMETER_EAGERLY_EXPOSE_TRACKTYPE.equals(parameterName)) {
1017+
mEagerlyExposeTrackType = (boolean) value;
1018+
}
9861019
mParserParameters.put(parameterName, value);
9871020
return this;
9881021
}
@@ -1159,6 +1192,10 @@ private void removePendingSeek() {
11591192

11601193
private Extractor createExtractor(String parserName) {
11611194
int flags = 0;
1195+
TimestampAdjuster timestampAdjuster = null;
1196+
if (mIgnoreTimestampOffset) {
1197+
timestampAdjuster = new TimestampAdjuster(TimestampAdjuster.DO_NOT_OFFSET);
1198+
}
11621199
switch (parserName) {
11631200
case PARSER_NAME_MATROSKA:
11641201
flags =
@@ -1180,7 +1217,7 @@ private Extractor createExtractor(String parserName) {
11801217
? FragmentedMp4Extractor
11811218
.FLAG_WORKAROUND_EVERY_VIDEO_FRAME_IS_SYNC_FRAME
11821219
: 0;
1183-
return new FragmentedMp4Extractor(flags);
1220+
return new FragmentedMp4Extractor(flags, timestampAdjuster);
11841221
case PARSER_NAME_MP4:
11851222
flags |=
11861223
getBooleanParameter(PARAMETER_MP4_IGNORE_EDIT_LISTS)
@@ -1238,7 +1275,12 @@ private Extractor createExtractor(String parserName) {
12381275
: TS_MODE_HLS.equals(tsMode)
12391276
? TsExtractor.MODE_HLS
12401277
: TsExtractor.MODE_MULTI_PMT;
1241-
return new TsExtractor(hlsMode, flags);
1278+
return new TsExtractor(
1279+
hlsMode,
1280+
timestampAdjuster != null
1281+
? timestampAdjuster
1282+
: new TimestampAdjuster(/* firstSampleTimestampUs= */ 0),
1283+
new DefaultTsPayloadReaderFactory(flags));
12421284
case PARSER_NAME_FLV:
12431285
return new FlvExtractor();
12441286
case PARSER_NAME_OGG:
@@ -1340,8 +1382,15 @@ private ExtractorOutputAdapter() {
13401382
public TrackOutput track(int id, int type) {
13411383
TrackOutput trackOutput = mTrackOutputAdapters.get(id);
13421384
if (trackOutput == null) {
1343-
trackOutput = new TrackOutputAdapter(mTrackOutputAdapters.size());
1385+
int trackIndex = mTrackOutputAdapters.size();
1386+
trackOutput = new TrackOutputAdapter(trackIndex);
13441387
mTrackOutputAdapters.put(id, trackOutput);
1388+
if (mEagerlyExposeTrackType) {
1389+
MediaFormat mediaFormat = new MediaFormat();
1390+
mediaFormat.setString("track-type-string", toTypeString(type));
1391+
mOutputConsumer.onTrackDataFound(
1392+
trackIndex, new TrackData(mediaFormat, /* drmInitData= */ null));
1393+
}
13451394
}
13461395
return trackOutput;
13471396
}
@@ -1662,6 +1711,21 @@ private static MediaFormat toMediaFormat(Format format) {
16621711
return result;
16631712
}
16641713

1714+
private static String toTypeString(int type) {
1715+
switch (type) {
1716+
case C.TRACK_TYPE_VIDEO:
1717+
return "video";
1718+
case C.TRACK_TYPE_AUDIO:
1719+
return "audio";
1720+
case C.TRACK_TYPE_TEXT:
1721+
return "text";
1722+
case C.TRACK_TYPE_METADATA:
1723+
return "metadata";
1724+
default:
1725+
return "unknown";
1726+
}
1727+
}
1728+
16651729
private static void setPcmEncoding(Format format, MediaFormat result) {
16661730
int exoPcmEncoding = format.pcmEncoding;
16671731
setOptionalMediaFormatInt(result, "exo-pcm-encoding", format.pcmEncoding);
@@ -1800,6 +1864,8 @@ private static Constructor<DrmInitData.SchemeInitData> getSchemeInitDataConstruc
18001864
expectedTypeByParameterName.put(PARAMETER_TS_ENABLE_HDMV_DTS_AUDIO_STREAMS, Boolean.class);
18011865
expectedTypeByParameterName.put(PARAMETER_IN_BAND_CRYPTO_INFO, Boolean.class);
18021866
expectedTypeByParameterName.put(PARAMETER_INCLUDE_SUPPLEMENTAL_DATA, Boolean.class);
1867+
expectedTypeByParameterName.put(PARAMETER_IGNORE_TIMESTAMP_OFFSET, Boolean.class);
1868+
expectedTypeByParameterName.put(PARAMETER_EAGERLY_EXPOSE_TRACKTYPE, Boolean.class);
18031869
EXPECTED_TYPE_BY_PARAMETER_NAME = Collections.unmodifiableMap(expectedTypeByParameterName);
18041870
}
18051871
}

apex/permission/TEST_MAPPING

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"presubmit" : [
3+
{
4+
"name" : "PermissionApexTests"
5+
}
6+
]
7+
}

apex/permission/tests/Android.bp

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
// Copyright (C) 2020 The Android Open Source Project
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
android_test {
16+
name: "PermissionApexTests",
17+
sdk_version: "test_current",
18+
srcs: [
19+
"java/**/*.kt",
20+
],
21+
static_libs: [
22+
"service-permission",
23+
"androidx.test.rules",
24+
"androidx.test.ext.junit",
25+
"androidx.test.ext.truth",
26+
"mockito-target-extended-minus-junit4",
27+
],
28+
jni_libs: [
29+
"libdexmakerjvmtiagent",
30+
"libstaticjvmtiagent",
31+
],
32+
compile_multilib: "both",
33+
test_suites: [
34+
"general-tests",
35+
"mts",
36+
],
37+
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
3+
<!--
4+
~ Copyright (C) 2020 The Android Open Source Project
5+
~
6+
~ Licensed under the Apache License, Version 2.0 (the "License");
7+
~ you may not use this file except in compliance with the License.
8+
~ You may obtain a copy of the License at
9+
~
10+
~ http://www.apache.org/licenses/LICENSE-2.0
11+
~
12+
~ Unless required by applicable law or agreed to in writing, software
13+
~ distributed under the License is distributed on an "AS IS" BASIS,
14+
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
~ See the License for the specific language governing permissions and
16+
~ limitations under the License.
17+
-->
18+
19+
<manifest
20+
xmlns:android="http://schemas.android.com/apk/res/android"
21+
package="com.android.permission.test">
22+
23+
<!-- The application has to be debuggable for static mocking to work. -->
24+
<application android:debuggable="true">
25+
<uses-library android:name="android.test.runner" />
26+
</application>
27+
28+
<instrumentation
29+
android:name="androidx.test.runner.AndroidJUnitRunner"
30+
android:targetPackage="com.android.permission.test"
31+
android:label="Permission APEX Tests" />
32+
</manifest>

0 commit comments

Comments
 (0)