#####笔记##### Android P新特性---应用待机群组( 三 )


2.关于Alarm
闹钟根据以上列表对每个组群的应用脑中进行延后调整:
private final long[] DEFAULT_APP_STANDBY_DELAYS = {0,// Active6 * 60_000,// Working30 * 60_000,// Frequent2 * 60 * 60_000,// Rare10 * 24 * 60 * 60_000// Never};
在设置闹钟时对应用所属的组群进行检查:
->
->cked
->
private boolean adjustDeliveryTimeBasedOnStandbyBucketLocked(Alarm alarm) {...final int standbyBucket = mUsageStatsManagerInternal.getAppStandbyBucket(sourcePackage, sourceUserId, SystemClock.elapsedRealtime());...if (lastElapsed > 0) {final long minElapsed = lastElapsed + getMinDelayForBucketLocked(standbyBucket);...}
3.关于
注册的监听器,根据上报的应用状态更新UID网络访问权限(待深入):
private class AppIdleStateChangeListenerextends UsageStatsManagerInternal.AppIdleStateChangeListener {@Overridepublic void onAppIdleStateChanged(String packageName, int userId, boolean idle, int bucket,int reason) {try {final int uid = mContext.getPackageManager().getPackageUidAsUser(packageName,PackageManager.MATCH_UNINSTALLED_PACKAGES, userId);synchronized (mUidRulesFirstLock) {mLogger.appIdleStateChanged(uid, idle);updateRuleForAppIdleUL(uid);//更新UID状态updateRulesForPowerRestrictionsUL(uid);}} catch (NameNotFoundException nnfe) {}}
void updateRuleForAppIdleUL(int uid) {if (!isUidValidForBlacklistRules(uid)) return;if (Trace.isTagEnabled(Trace.TRACE_TAG_NETWORK)) {Trace.traceBegin(Trace.TRACE_TAG_NETWORK, "updateRuleForAppIdleUL: " + uid );}try {int appId = UserHandle.getAppId(uid);if (!mPowerSaveTempWhitelistAppIds.get(appId) && isUidIdle(uid)&& !isUidForegroundOnRestrictPowerUL(uid)) {//根据组群setUidFirewallRule(FIREWALL_CHAIN_STANDBY, uid, FIREWALL_RULE_DENY);} else {setUidFirewallRule(FIREWALL_CHAIN_STANDBY, uid, FIREWALL_RULE_DEFAULT);}} finally {Trace.traceEnd(Trace.TRACE_TAG_NETWORK);}}
4.FCM限制
国内无法使用FCM服务 。
一堆订单BUG,,溜了