Loading apex/Android.bp +54 −0 Original line number Diff line number Diff line Loading @@ -63,6 +63,60 @@ mainline_service_stubs_args = "--hide-annotation android.annotation.Hide " + "--hide InternalClasses " // com.android.* classes are okay in this interface // Defaults for mainline module provided java_sdk_library instances. java_defaults { name: "framework-module-defaults", // Additional annotations used for compiling both the implementation and the // stubs libraries. libs: ["framework-annotations-lib"], // Enable api lint. This will eventually become the default for java_sdk_library // but it cannot yet be turned on because some usages have not been cleaned up. // TODO(b/156126315) - Remove when no longer needed. api_lint: { enabled: true, }, // The API scope specific properties. public: { enabled: true, sdk_version: "module_current", }, system: { enabled: true, sdk_version: "module_current", }, module_lib: { enabled: true, sdk_version: "module_current", }, // The stub libraries must be visible to frameworks/base so they can be combined // into API specific libraries. stubs_library_visibility: [ "//frameworks/base", // Framework ], // Set the visibility of the modules creating the stubs source. stubs_source_visibility: [ // Ignore any visibility rules specified on the java_sdk_library when // setting the visibility of the stubs source modules. "//visibility:override", // Currently, the stub source is not required for anything other than building // the stubs library so is private to avoid misuse. "//visibility:private", ], // Collates API usages from each module for further analysis. plugins: ["java_api_finder"], // Mainline modules should only rely on 'module_lib' APIs provided by other modules // and the non updatable parts of the platform. sdk_version: "module_current", } stubs_defaults { name: "framework-module-stubs-defaults-publicapi", args: mainline_framework_stubs_args, Loading apex/jobscheduler/service/java/com/android/server/usage/AppIdleHistory.java +8 −2 Original line number Diff line number Diff line Loading @@ -79,6 +79,12 @@ public class AppIdleHistory { private static final int STANDBY_BUCKET_UNKNOWN = -1; /** * The bucket beyond which apps are considered idle. Any apps in this bucket or lower are * considered idle while those in higher buckets are not considered idle. */ static final int IDLE_BUCKET_CUTOFF = STANDBY_BUCKET_RARE; @VisibleForTesting static final String APP_IDLE_FILENAME = "app_idle_stats.xml"; private static final String TAG_PACKAGES = "packages"; Loading Loading @@ -350,7 +356,7 @@ public class AppIdleHistory { ArrayMap<String, AppUsageHistory> userHistory = getUserHistory(userId); AppUsageHistory appUsageHistory = getPackageHistory(userHistory, packageName, elapsedRealtime, true); return appUsageHistory.currentBucket >= STANDBY_BUCKET_RARE; return appUsageHistory.currentBucket >= IDLE_BUCKET_CUTOFF; } public AppUsageHistory getAppUsageHistory(String packageName, int userId, Loading Loading @@ -487,7 +493,7 @@ public class AppIdleHistory { final int newBucket; final int reason; if (idle) { newBucket = STANDBY_BUCKET_RARE; newBucket = IDLE_BUCKET_CUTOFF; reason = REASON_MAIN_FORCED_BY_USER; } else { newBucket = STANDBY_BUCKET_ACTIVE; Loading apex/jobscheduler/service/java/com/android/server/usage/AppStandbyController.java +99 −22 Original line number Diff line number Diff line Loading @@ -54,6 +54,7 @@ import static com.android.server.SystemService.PHASE_BOOT_COMPLETED; import static com.android.server.SystemService.PHASE_SYSTEM_SERVICES_READY; import android.annotation.NonNull; import android.annotation.Nullable; import android.annotation.UserIdInt; import android.app.ActivityManager; import android.app.AppGlobals; Loading Loading @@ -92,6 +93,7 @@ import android.os.SystemClock; import android.os.UserHandle; import android.provider.Settings.Global; import android.telephony.TelephonyManager; import android.util.ArrayMap; import android.util.ArraySet; import android.util.KeyValueListParser; import android.util.Slog; Loading Loading @@ -227,6 +229,13 @@ public class AppStandbyController implements AppStandbyInternal { @GuardedBy("mActiveAdminApps") private final SparseArray<Set<String>> mActiveAdminApps = new SparseArray<>(); /** * Set of system apps that are headless (don't have any declared activities, enabled or * disabled). Presence in this map indicates that the app is a headless system app. */ @GuardedBy("mAppIdleLock") private final ArrayMap<String, Boolean> mHeadlessSystemApps = new ArrayMap<>(); private final CountDownLatch mAdminDataAvailableLatch = new CountDownLatch(1); // Messages for the handler Loading Loading @@ -667,20 +676,22 @@ public class AppStandbyController implements AppStandbyInternal { return; } } final boolean isSpecial = isAppSpecial(packageName, final int minBucket = getAppMinBucket(packageName, UserHandle.getAppId(uid), userId); if (DEBUG) { Slog.d(TAG, " Checking idle state for " + packageName + " special=" + isSpecial); Slog.d(TAG, " Checking idle state for " + packageName + " minBucket=" + minBucket); } if (isSpecial) { if (minBucket <= STANDBY_BUCKET_ACTIVE) { // No extra processing needed for ACTIVE or higher since apps can't drop into lower // buckets. synchronized (mAppIdleLock) { mAppIdleHistory.setAppStandbyBucket(packageName, userId, elapsedRealtime, STANDBY_BUCKET_EXEMPTED, REASON_MAIN_DEFAULT); minBucket, REASON_MAIN_DEFAULT); } maybeInformListeners(packageName, userId, elapsedRealtime, STANDBY_BUCKET_EXEMPTED, REASON_MAIN_DEFAULT, false); minBucket, REASON_MAIN_DEFAULT, false); } else { synchronized (mAppIdleLock) { final AppIdleHistory.AppUsageHistory app = Loading Loading @@ -761,6 +772,14 @@ public class AppStandbyController implements AppStandbyInternal { Slog.d(TAG, "Bringing up from RESTRICTED to RARE due to off switch"); } } if (newBucket > minBucket) { newBucket = minBucket; // Leave the reason alone. if (DEBUG) { Slog.d(TAG, "Bringing up from " + newBucket + " to " + minBucket + " due to min bucketing"); } } if (DEBUG) { Slog.d(TAG, " Old bucket=" + oldBucket + ", newBucket=" + newBucket); Loading Loading @@ -1027,20 +1046,35 @@ public class AppStandbyController implements AppStandbyInternal { return isAppIdleFiltered(packageName, getAppId(packageName), userId, elapsedRealtime); } private boolean isAppSpecial(String packageName, int appId, int userId) { if (packageName == null) return false; @StandbyBuckets private int getAppMinBucket(String packageName, int userId) { try { final int uid = mPackageManager.getPackageUidAsUser(packageName, userId); return getAppMinBucket(packageName, UserHandle.getAppId(uid), userId); } catch (PackageManager.NameNotFoundException e) { // Not a valid package for this user, nothing to do return STANDBY_BUCKET_NEVER; } } /** * Return the lowest bucket this app should ever enter. */ @StandbyBuckets private int getAppMinBucket(String packageName, int appId, int userId) { if (packageName == null) return STANDBY_BUCKET_NEVER; // If not enabled at all, of course nobody is ever idle. if (!mAppIdleEnabled) { return true; return STANDBY_BUCKET_EXEMPTED; } if (appId < Process.FIRST_APPLICATION_UID) { // System uids never go idle. return true; return STANDBY_BUCKET_EXEMPTED; } if (packageName.equals("android")) { // Nor does the framework (which should be redundant with the above, but for MR1 we will // retain this for safety). return true; return STANDBY_BUCKET_EXEMPTED; } if (mSystemServicesReady) { try { Loading @@ -1048,42 +1082,51 @@ public class AppStandbyController implements AppStandbyInternal { // for idle mode, because app idle (aka app standby) is really not as big an issue // for controlling who participates vs. doze mode. if (mInjector.isNonIdleWhitelisted(packageName)) { return true; return STANDBY_BUCKET_EXEMPTED; } } catch (RemoteException re) { throw re.rethrowFromSystemServer(); } if (isActiveDeviceAdmin(packageName, userId)) { return true; return STANDBY_BUCKET_EXEMPTED; } if (isActiveNetworkScorer(packageName)) { return true; return STANDBY_BUCKET_EXEMPTED; } if (mAppWidgetManager != null && mInjector.isBoundWidgetPackage(mAppWidgetManager, packageName, userId)) { return true; // TODO: consider lowering to ACTIVE return STANDBY_BUCKET_EXEMPTED; } if (isDeviceProvisioningPackage(packageName)) { return true; return STANDBY_BUCKET_EXEMPTED; } } // Check this last, as it can be the most expensive check if (isCarrierApp(packageName)) { return true; return STANDBY_BUCKET_EXEMPTED; } return false; if (isHeadlessSystemApp(packageName)) { return STANDBY_BUCKET_ACTIVE; } return STANDBY_BUCKET_NEVER; } private boolean isHeadlessSystemApp(String packageName) { return mHeadlessSystemApps.containsKey(packageName); } @Override public boolean isAppIdleFiltered(String packageName, int appId, int userId, long elapsedRealtime) { if (isAppSpecial(packageName, appId, userId)) { if (getAppMinBucket(packageName, appId, userId) < AppIdleHistory.IDLE_BUCKET_CUTOFF) { return false; } else { synchronized (mAppIdleLock) { Loading Loading @@ -1423,6 +1466,8 @@ public class AppStandbyController implements AppStandbyInternal { } } // Make sure we don't put the app in a lower bucket than it's supposed to be in. newBucket = Math.min(newBucket, getAppMinBucket(packageName, userId)); mAppIdleHistory.setAppStandbyBucket(packageName, userId, elapsedRealtime, newBucket, reason, resetTimeout); } Loading Loading @@ -1617,14 +1662,16 @@ public class AppStandbyController implements AppStandbyInternal { @Override public void onReceive(Context context, Intent intent) { final String action = intent.getAction(); final String pkgName = intent.getData().getSchemeSpecificPart(); final int userId = getSendingUserId(); if (Intent.ACTION_PACKAGE_ADDED.equals(action) || Intent.ACTION_PACKAGE_CHANGED.equals(action)) { clearCarrierPrivilegedApps(); // ACTION_PACKAGE_ADDED is called even for system app downgrades. evaluateSystemAppException(pkgName, userId); } if ((Intent.ACTION_PACKAGE_REMOVED.equals(action) || Intent.ACTION_PACKAGE_ADDED.equals(action))) { final String pkgName = intent.getData().getSchemeSpecificPart(); final int userId = getSendingUserId(); if (intent.getBooleanExtra(Intent.EXTRA_REPLACING, false)) { maybeUnrestrictBuggyApp(pkgName, userId); } else { Loading @@ -1634,6 +1681,34 @@ public class AppStandbyController implements AppStandbyInternal { } } private void evaluateSystemAppException(String packageName, int userId) { if (!mSystemServicesReady) { // The app will be evaluated in initializeDefaultsForSystemApps() when possible. return; } try { PackageInfo pi = mPackageManager.getPackageInfoAsUser(packageName, PackageManager.GET_ACTIVITIES | PackageManager.MATCH_DISABLED_COMPONENTS, userId); evaluateSystemAppException(pi); } catch (PackageManager.NameNotFoundException e) { mHeadlessSystemApps.remove(packageName); } } private void evaluateSystemAppException(@Nullable PackageInfo pkgInfo) { if (pkgInfo.applicationInfo != null && pkgInfo.applicationInfo.isSystemApp()) { synchronized (mAppIdleLock) { if (pkgInfo.activities == null || pkgInfo.activities.length == 0) { // Headless system app. mHeadlessSystemApps.put(pkgInfo.packageName, true); } else { mHeadlessSystemApps.remove(pkgInfo.packageName); } } } } @Override public void initializeDefaultsForSystemApps(int userId) { if (!mSystemServicesReady) { Loading @@ -1645,7 +1720,7 @@ public class AppStandbyController implements AppStandbyInternal { + "appIdleEnabled=" + mAppIdleEnabled); final long elapsedRealtime = mInjector.elapsedRealtime(); List<PackageInfo> packages = mPackageManager.getInstalledPackagesAsUser( PackageManager.MATCH_DISABLED_COMPONENTS, PackageManager.GET_ACTIVITIES | PackageManager.MATCH_DISABLED_COMPONENTS, userId); final int packageCount = packages.size(); synchronized (mAppIdleLock) { Loading @@ -1658,6 +1733,8 @@ 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 Loading apex/media/framework/java/android/media/MediaParser.java +49 −4 Original line number Diff line number Diff line Loading @@ -21,6 +21,7 @@ import android.annotation.NonNull; import android.annotation.Nullable; import android.annotation.StringDef; import android.media.MediaCodec.CryptoInfo; import android.os.Build; import android.text.TextUtils; import android.util.Log; import android.util.Pair; Loading Loading @@ -467,7 +468,24 @@ public final class MediaParser { public @interface SampleFlags {} /** Indicates that the sample holds a synchronization sample. */ public static final int SAMPLE_FLAG_KEY_FRAME = MediaCodec.BUFFER_FLAG_KEY_FRAME; /** Indicates that the sample has supplemental data. */ /** * Indicates that the sample has supplemental data. * * <p>Samples will not have this flag set unless the {@code * "android.media.mediaparser.includeSupplementalData"} parameter is set to {@code true} via * {@link #setParameter}. * * <p>Samples with supplemental data have the following sample data format: * * <ul> * <li>If the {@code "android.media.mediaparser.inBandCryptoInfo"} parameter is set, all * encryption information. * <li>(4 bytes) {@code sample_data_size}: The size of the actual sample data, not including * supplemental data or encryption information. * <li>({@code sample_data_size} bytes): The media sample data. * <li>(remaining bytes) The supplemental data. * </ul> */ public static final int SAMPLE_FLAG_HAS_SUPPLEMENTAL_DATA = 1 << 28; /** Indicates that the sample is known to contain the last media sample of the stream. */ public static final int SAMPLE_FLAG_LAST_SAMPLE = 1 << 29; Loading Loading @@ -578,7 +596,9 @@ public final class MediaParser { PARAMETER_TS_IGNORE_AVC_STREAM, PARAMETER_TS_IGNORE_SPLICE_INFO_STREAM, PARAMETER_TS_DETECT_ACCESS_UNITS, PARAMETER_TS_ENABLE_HDMV_DTS_AUDIO_STREAMS PARAMETER_TS_ENABLE_HDMV_DTS_AUDIO_STREAMS, PARAMETER_IN_BAND_CRYPTO_INFO, PARAMETER_INCLUDE_SUPPLEMENTAL_DATA }) public @interface ParameterName {} Loading Loading @@ -740,6 +760,16 @@ 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 * information about the sample data format. * * @hide */ public static final String PARAMETER_INCLUDE_SUPPLEMENTAL_DATA = "android.media.mediaparser.includeSupplementalData"; // Private constants. private static final String TAG = "MediaParser"; Loading Loading @@ -899,6 +929,7 @@ public final class MediaParser { private final ParsableByteArrayAdapter mScratchParsableByteArrayAdapter; @Nullable private final Constructor<DrmInitData.SchemeInitData> mSchemeInitDataConstructor; private boolean mInBandCryptoInfo; private boolean mIncludeSupplementalData; private String mParserName; private Extractor mExtractor; private ExtractorInput mExtractorInput; Loading Loading @@ -949,6 +980,9 @@ public final class MediaParser { if (PARAMETER_IN_BAND_CRYPTO_INFO.equals(parameterName)) { mInBandCryptoInfo = (boolean) value; } if (PARAMETER_INCLUDE_SUPPLEMENTAL_DATA.equals(parameterName)) { mIncludeSupplementalData = (boolean) value; } mParserParameters.put(parameterName, value); return this; } Loading Loading @@ -1099,6 +1133,9 @@ public final class MediaParser { // Private methods. private MediaParser(OutputConsumer outputConsumer, boolean sniff, String... parserNamesPool) { if (Build.VERSION.SDK_INT < Build.VERSION_CODES.R) { throw new UnsupportedOperationException("Android version must be R or greater."); } mParserParameters = new HashMap<>(); mOutputConsumer = outputConsumer; mParserNamesPool = parserNamesPool; Loading Loading @@ -1330,6 +1367,7 @@ public final class MediaParser { private int mEncryptionVectorSize; private boolean mHasSubsampleEncryptionData; private CryptoInfo.Pattern mEncryptionPattern; private int mSkippedSupplementalDataBytes; private TrackOutputAdapter(int trackIndex) { mTrackIndex = trackIndex; Loading Loading @@ -1419,6 +1457,10 @@ public final class MediaParser { throw new IllegalStateException(); } } } else if (sampleDataPart == SAMPLE_DATA_PART_SUPPLEMENTAL && !mIncludeSupplementalData) { mSkippedSupplementalDataBytes += length; data.skipBytes(length); } else { outputSampleData(data, length); } Loading @@ -1427,6 +1469,8 @@ public final class MediaParser { @Override public void sampleMetadata( long timeUs, int flags, int size, int offset, @Nullable CryptoData cryptoData) { size -= mSkippedSupplementalDataBytes; mSkippedSupplementalDataBytes = 0; mOutputConsumer.onSampleCompleted( mTrackIndex, timeUs, Loading Loading @@ -1686,13 +1730,13 @@ public final class MediaParser { } } private static int getMediaParserFlags(int flags) { private 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 (flags & C.BUFFER_FLAG_HAS_SUPPLEMENTAL_DATA) != 0 && mIncludeSupplementalData ? SAMPLE_FLAG_HAS_SUPPLEMENTAL_DATA : 0; result |= (flags & C.BUFFER_FLAG_LAST_SAMPLE) != 0 ? SAMPLE_FLAG_LAST_SAMPLE : 0; Loading Loading @@ -1755,6 +1799,7 @@ public final class MediaParser { 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); expectedTypeByParameterName.put(PARAMETER_INCLUDE_SUPPLEMENTAL_DATA, Boolean.class); EXPECTED_TYPE_BY_PARAMETER_NAME = Collections.unmodifiableMap(expectedTypeByParameterName); } } apex/sdkextensions/Android.bp +1 −1 Original line number Diff line number Diff line Loading @@ -39,7 +39,7 @@ apex_defaults { sdk { name: "sdkextensions-sdk", java_header_libs: [ "framework-sdkextensions-stubs-systemapi" ], java_sdk_libs: [ "framework-sdkextensions" ], } apex_key { Loading Loading
apex/Android.bp +54 −0 Original line number Diff line number Diff line Loading @@ -63,6 +63,60 @@ mainline_service_stubs_args = "--hide-annotation android.annotation.Hide " + "--hide InternalClasses " // com.android.* classes are okay in this interface // Defaults for mainline module provided java_sdk_library instances. java_defaults { name: "framework-module-defaults", // Additional annotations used for compiling both the implementation and the // stubs libraries. libs: ["framework-annotations-lib"], // Enable api lint. This will eventually become the default for java_sdk_library // but it cannot yet be turned on because some usages have not been cleaned up. // TODO(b/156126315) - Remove when no longer needed. api_lint: { enabled: true, }, // The API scope specific properties. public: { enabled: true, sdk_version: "module_current", }, system: { enabled: true, sdk_version: "module_current", }, module_lib: { enabled: true, sdk_version: "module_current", }, // The stub libraries must be visible to frameworks/base so they can be combined // into API specific libraries. stubs_library_visibility: [ "//frameworks/base", // Framework ], // Set the visibility of the modules creating the stubs source. stubs_source_visibility: [ // Ignore any visibility rules specified on the java_sdk_library when // setting the visibility of the stubs source modules. "//visibility:override", // Currently, the stub source is not required for anything other than building // the stubs library so is private to avoid misuse. "//visibility:private", ], // Collates API usages from each module for further analysis. plugins: ["java_api_finder"], // Mainline modules should only rely on 'module_lib' APIs provided by other modules // and the non updatable parts of the platform. sdk_version: "module_current", } stubs_defaults { name: "framework-module-stubs-defaults-publicapi", args: mainline_framework_stubs_args, Loading
apex/jobscheduler/service/java/com/android/server/usage/AppIdleHistory.java +8 −2 Original line number Diff line number Diff line Loading @@ -79,6 +79,12 @@ public class AppIdleHistory { private static final int STANDBY_BUCKET_UNKNOWN = -1; /** * The bucket beyond which apps are considered idle. Any apps in this bucket or lower are * considered idle while those in higher buckets are not considered idle. */ static final int IDLE_BUCKET_CUTOFF = STANDBY_BUCKET_RARE; @VisibleForTesting static final String APP_IDLE_FILENAME = "app_idle_stats.xml"; private static final String TAG_PACKAGES = "packages"; Loading Loading @@ -350,7 +356,7 @@ public class AppIdleHistory { ArrayMap<String, AppUsageHistory> userHistory = getUserHistory(userId); AppUsageHistory appUsageHistory = getPackageHistory(userHistory, packageName, elapsedRealtime, true); return appUsageHistory.currentBucket >= STANDBY_BUCKET_RARE; return appUsageHistory.currentBucket >= IDLE_BUCKET_CUTOFF; } public AppUsageHistory getAppUsageHistory(String packageName, int userId, Loading Loading @@ -487,7 +493,7 @@ public class AppIdleHistory { final int newBucket; final int reason; if (idle) { newBucket = STANDBY_BUCKET_RARE; newBucket = IDLE_BUCKET_CUTOFF; reason = REASON_MAIN_FORCED_BY_USER; } else { newBucket = STANDBY_BUCKET_ACTIVE; Loading
apex/jobscheduler/service/java/com/android/server/usage/AppStandbyController.java +99 −22 Original line number Diff line number Diff line Loading @@ -54,6 +54,7 @@ import static com.android.server.SystemService.PHASE_BOOT_COMPLETED; import static com.android.server.SystemService.PHASE_SYSTEM_SERVICES_READY; import android.annotation.NonNull; import android.annotation.Nullable; import android.annotation.UserIdInt; import android.app.ActivityManager; import android.app.AppGlobals; Loading Loading @@ -92,6 +93,7 @@ import android.os.SystemClock; import android.os.UserHandle; import android.provider.Settings.Global; import android.telephony.TelephonyManager; import android.util.ArrayMap; import android.util.ArraySet; import android.util.KeyValueListParser; import android.util.Slog; Loading Loading @@ -227,6 +229,13 @@ public class AppStandbyController implements AppStandbyInternal { @GuardedBy("mActiveAdminApps") private final SparseArray<Set<String>> mActiveAdminApps = new SparseArray<>(); /** * Set of system apps that are headless (don't have any declared activities, enabled or * disabled). Presence in this map indicates that the app is a headless system app. */ @GuardedBy("mAppIdleLock") private final ArrayMap<String, Boolean> mHeadlessSystemApps = new ArrayMap<>(); private final CountDownLatch mAdminDataAvailableLatch = new CountDownLatch(1); // Messages for the handler Loading Loading @@ -667,20 +676,22 @@ public class AppStandbyController implements AppStandbyInternal { return; } } final boolean isSpecial = isAppSpecial(packageName, final int minBucket = getAppMinBucket(packageName, UserHandle.getAppId(uid), userId); if (DEBUG) { Slog.d(TAG, " Checking idle state for " + packageName + " special=" + isSpecial); Slog.d(TAG, " Checking idle state for " + packageName + " minBucket=" + minBucket); } if (isSpecial) { if (minBucket <= STANDBY_BUCKET_ACTIVE) { // No extra processing needed for ACTIVE or higher since apps can't drop into lower // buckets. synchronized (mAppIdleLock) { mAppIdleHistory.setAppStandbyBucket(packageName, userId, elapsedRealtime, STANDBY_BUCKET_EXEMPTED, REASON_MAIN_DEFAULT); minBucket, REASON_MAIN_DEFAULT); } maybeInformListeners(packageName, userId, elapsedRealtime, STANDBY_BUCKET_EXEMPTED, REASON_MAIN_DEFAULT, false); minBucket, REASON_MAIN_DEFAULT, false); } else { synchronized (mAppIdleLock) { final AppIdleHistory.AppUsageHistory app = Loading Loading @@ -761,6 +772,14 @@ public class AppStandbyController implements AppStandbyInternal { Slog.d(TAG, "Bringing up from RESTRICTED to RARE due to off switch"); } } if (newBucket > minBucket) { newBucket = minBucket; // Leave the reason alone. if (DEBUG) { Slog.d(TAG, "Bringing up from " + newBucket + " to " + minBucket + " due to min bucketing"); } } if (DEBUG) { Slog.d(TAG, " Old bucket=" + oldBucket + ", newBucket=" + newBucket); Loading Loading @@ -1027,20 +1046,35 @@ public class AppStandbyController implements AppStandbyInternal { return isAppIdleFiltered(packageName, getAppId(packageName), userId, elapsedRealtime); } private boolean isAppSpecial(String packageName, int appId, int userId) { if (packageName == null) return false; @StandbyBuckets private int getAppMinBucket(String packageName, int userId) { try { final int uid = mPackageManager.getPackageUidAsUser(packageName, userId); return getAppMinBucket(packageName, UserHandle.getAppId(uid), userId); } catch (PackageManager.NameNotFoundException e) { // Not a valid package for this user, nothing to do return STANDBY_BUCKET_NEVER; } } /** * Return the lowest bucket this app should ever enter. */ @StandbyBuckets private int getAppMinBucket(String packageName, int appId, int userId) { if (packageName == null) return STANDBY_BUCKET_NEVER; // If not enabled at all, of course nobody is ever idle. if (!mAppIdleEnabled) { return true; return STANDBY_BUCKET_EXEMPTED; } if (appId < Process.FIRST_APPLICATION_UID) { // System uids never go idle. return true; return STANDBY_BUCKET_EXEMPTED; } if (packageName.equals("android")) { // Nor does the framework (which should be redundant with the above, but for MR1 we will // retain this for safety). return true; return STANDBY_BUCKET_EXEMPTED; } if (mSystemServicesReady) { try { Loading @@ -1048,42 +1082,51 @@ public class AppStandbyController implements AppStandbyInternal { // for idle mode, because app idle (aka app standby) is really not as big an issue // for controlling who participates vs. doze mode. if (mInjector.isNonIdleWhitelisted(packageName)) { return true; return STANDBY_BUCKET_EXEMPTED; } } catch (RemoteException re) { throw re.rethrowFromSystemServer(); } if (isActiveDeviceAdmin(packageName, userId)) { return true; return STANDBY_BUCKET_EXEMPTED; } if (isActiveNetworkScorer(packageName)) { return true; return STANDBY_BUCKET_EXEMPTED; } if (mAppWidgetManager != null && mInjector.isBoundWidgetPackage(mAppWidgetManager, packageName, userId)) { return true; // TODO: consider lowering to ACTIVE return STANDBY_BUCKET_EXEMPTED; } if (isDeviceProvisioningPackage(packageName)) { return true; return STANDBY_BUCKET_EXEMPTED; } } // Check this last, as it can be the most expensive check if (isCarrierApp(packageName)) { return true; return STANDBY_BUCKET_EXEMPTED; } return false; if (isHeadlessSystemApp(packageName)) { return STANDBY_BUCKET_ACTIVE; } return STANDBY_BUCKET_NEVER; } private boolean isHeadlessSystemApp(String packageName) { return mHeadlessSystemApps.containsKey(packageName); } @Override public boolean isAppIdleFiltered(String packageName, int appId, int userId, long elapsedRealtime) { if (isAppSpecial(packageName, appId, userId)) { if (getAppMinBucket(packageName, appId, userId) < AppIdleHistory.IDLE_BUCKET_CUTOFF) { return false; } else { synchronized (mAppIdleLock) { Loading Loading @@ -1423,6 +1466,8 @@ public class AppStandbyController implements AppStandbyInternal { } } // Make sure we don't put the app in a lower bucket than it's supposed to be in. newBucket = Math.min(newBucket, getAppMinBucket(packageName, userId)); mAppIdleHistory.setAppStandbyBucket(packageName, userId, elapsedRealtime, newBucket, reason, resetTimeout); } Loading Loading @@ -1617,14 +1662,16 @@ public class AppStandbyController implements AppStandbyInternal { @Override public void onReceive(Context context, Intent intent) { final String action = intent.getAction(); final String pkgName = intent.getData().getSchemeSpecificPart(); final int userId = getSendingUserId(); if (Intent.ACTION_PACKAGE_ADDED.equals(action) || Intent.ACTION_PACKAGE_CHANGED.equals(action)) { clearCarrierPrivilegedApps(); // ACTION_PACKAGE_ADDED is called even for system app downgrades. evaluateSystemAppException(pkgName, userId); } if ((Intent.ACTION_PACKAGE_REMOVED.equals(action) || Intent.ACTION_PACKAGE_ADDED.equals(action))) { final String pkgName = intent.getData().getSchemeSpecificPart(); final int userId = getSendingUserId(); if (intent.getBooleanExtra(Intent.EXTRA_REPLACING, false)) { maybeUnrestrictBuggyApp(pkgName, userId); } else { Loading @@ -1634,6 +1681,34 @@ public class AppStandbyController implements AppStandbyInternal { } } private void evaluateSystemAppException(String packageName, int userId) { if (!mSystemServicesReady) { // The app will be evaluated in initializeDefaultsForSystemApps() when possible. return; } try { PackageInfo pi = mPackageManager.getPackageInfoAsUser(packageName, PackageManager.GET_ACTIVITIES | PackageManager.MATCH_DISABLED_COMPONENTS, userId); evaluateSystemAppException(pi); } catch (PackageManager.NameNotFoundException e) { mHeadlessSystemApps.remove(packageName); } } private void evaluateSystemAppException(@Nullable PackageInfo pkgInfo) { if (pkgInfo.applicationInfo != null && pkgInfo.applicationInfo.isSystemApp()) { synchronized (mAppIdleLock) { if (pkgInfo.activities == null || pkgInfo.activities.length == 0) { // Headless system app. mHeadlessSystemApps.put(pkgInfo.packageName, true); } else { mHeadlessSystemApps.remove(pkgInfo.packageName); } } } } @Override public void initializeDefaultsForSystemApps(int userId) { if (!mSystemServicesReady) { Loading @@ -1645,7 +1720,7 @@ public class AppStandbyController implements AppStandbyInternal { + "appIdleEnabled=" + mAppIdleEnabled); final long elapsedRealtime = mInjector.elapsedRealtime(); List<PackageInfo> packages = mPackageManager.getInstalledPackagesAsUser( PackageManager.MATCH_DISABLED_COMPONENTS, PackageManager.GET_ACTIVITIES | PackageManager.MATCH_DISABLED_COMPONENTS, userId); final int packageCount = packages.size(); synchronized (mAppIdleLock) { Loading @@ -1658,6 +1733,8 @@ 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 Loading
apex/media/framework/java/android/media/MediaParser.java +49 −4 Original line number Diff line number Diff line Loading @@ -21,6 +21,7 @@ import android.annotation.NonNull; import android.annotation.Nullable; import android.annotation.StringDef; import android.media.MediaCodec.CryptoInfo; import android.os.Build; import android.text.TextUtils; import android.util.Log; import android.util.Pair; Loading Loading @@ -467,7 +468,24 @@ public final class MediaParser { public @interface SampleFlags {} /** Indicates that the sample holds a synchronization sample. */ public static final int SAMPLE_FLAG_KEY_FRAME = MediaCodec.BUFFER_FLAG_KEY_FRAME; /** Indicates that the sample has supplemental data. */ /** * Indicates that the sample has supplemental data. * * <p>Samples will not have this flag set unless the {@code * "android.media.mediaparser.includeSupplementalData"} parameter is set to {@code true} via * {@link #setParameter}. * * <p>Samples with supplemental data have the following sample data format: * * <ul> * <li>If the {@code "android.media.mediaparser.inBandCryptoInfo"} parameter is set, all * encryption information. * <li>(4 bytes) {@code sample_data_size}: The size of the actual sample data, not including * supplemental data or encryption information. * <li>({@code sample_data_size} bytes): The media sample data. * <li>(remaining bytes) The supplemental data. * </ul> */ public static final int SAMPLE_FLAG_HAS_SUPPLEMENTAL_DATA = 1 << 28; /** Indicates that the sample is known to contain the last media sample of the stream. */ public static final int SAMPLE_FLAG_LAST_SAMPLE = 1 << 29; Loading Loading @@ -578,7 +596,9 @@ public final class MediaParser { PARAMETER_TS_IGNORE_AVC_STREAM, PARAMETER_TS_IGNORE_SPLICE_INFO_STREAM, PARAMETER_TS_DETECT_ACCESS_UNITS, PARAMETER_TS_ENABLE_HDMV_DTS_AUDIO_STREAMS PARAMETER_TS_ENABLE_HDMV_DTS_AUDIO_STREAMS, PARAMETER_IN_BAND_CRYPTO_INFO, PARAMETER_INCLUDE_SUPPLEMENTAL_DATA }) public @interface ParameterName {} Loading Loading @@ -740,6 +760,16 @@ 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 * information about the sample data format. * * @hide */ public static final String PARAMETER_INCLUDE_SUPPLEMENTAL_DATA = "android.media.mediaparser.includeSupplementalData"; // Private constants. private static final String TAG = "MediaParser"; Loading Loading @@ -899,6 +929,7 @@ public final class MediaParser { private final ParsableByteArrayAdapter mScratchParsableByteArrayAdapter; @Nullable private final Constructor<DrmInitData.SchemeInitData> mSchemeInitDataConstructor; private boolean mInBandCryptoInfo; private boolean mIncludeSupplementalData; private String mParserName; private Extractor mExtractor; private ExtractorInput mExtractorInput; Loading Loading @@ -949,6 +980,9 @@ public final class MediaParser { if (PARAMETER_IN_BAND_CRYPTO_INFO.equals(parameterName)) { mInBandCryptoInfo = (boolean) value; } if (PARAMETER_INCLUDE_SUPPLEMENTAL_DATA.equals(parameterName)) { mIncludeSupplementalData = (boolean) value; } mParserParameters.put(parameterName, value); return this; } Loading Loading @@ -1099,6 +1133,9 @@ public final class MediaParser { // Private methods. private MediaParser(OutputConsumer outputConsumer, boolean sniff, String... parserNamesPool) { if (Build.VERSION.SDK_INT < Build.VERSION_CODES.R) { throw new UnsupportedOperationException("Android version must be R or greater."); } mParserParameters = new HashMap<>(); mOutputConsumer = outputConsumer; mParserNamesPool = parserNamesPool; Loading Loading @@ -1330,6 +1367,7 @@ public final class MediaParser { private int mEncryptionVectorSize; private boolean mHasSubsampleEncryptionData; private CryptoInfo.Pattern mEncryptionPattern; private int mSkippedSupplementalDataBytes; private TrackOutputAdapter(int trackIndex) { mTrackIndex = trackIndex; Loading Loading @@ -1419,6 +1457,10 @@ public final class MediaParser { throw new IllegalStateException(); } } } else if (sampleDataPart == SAMPLE_DATA_PART_SUPPLEMENTAL && !mIncludeSupplementalData) { mSkippedSupplementalDataBytes += length; data.skipBytes(length); } else { outputSampleData(data, length); } Loading @@ -1427,6 +1469,8 @@ public final class MediaParser { @Override public void sampleMetadata( long timeUs, int flags, int size, int offset, @Nullable CryptoData cryptoData) { size -= mSkippedSupplementalDataBytes; mSkippedSupplementalDataBytes = 0; mOutputConsumer.onSampleCompleted( mTrackIndex, timeUs, Loading Loading @@ -1686,13 +1730,13 @@ public final class MediaParser { } } private static int getMediaParserFlags(int flags) { private 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 (flags & C.BUFFER_FLAG_HAS_SUPPLEMENTAL_DATA) != 0 && mIncludeSupplementalData ? SAMPLE_FLAG_HAS_SUPPLEMENTAL_DATA : 0; result |= (flags & C.BUFFER_FLAG_LAST_SAMPLE) != 0 ? SAMPLE_FLAG_LAST_SAMPLE : 0; Loading Loading @@ -1755,6 +1799,7 @@ public final class MediaParser { 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); expectedTypeByParameterName.put(PARAMETER_INCLUDE_SUPPLEMENTAL_DATA, Boolean.class); EXPECTED_TYPE_BY_PARAMETER_NAME = Collections.unmodifiableMap(expectedTypeByParameterName); } }
apex/sdkextensions/Android.bp +1 −1 Original line number Diff line number Diff line Loading @@ -39,7 +39,7 @@ apex_defaults { sdk { name: "sdkextensions-sdk", java_header_libs: [ "framework-sdkextensions-stubs-systemapi" ], java_sdk_libs: [ "framework-sdkextensions" ], } apex_key { Loading