gpt4 book ai didi

android - App Standby Buckets - "Never"bucket有什么限制(bucket 50)

转载 作者:行者123 更新时间:2023-12-04 08:27:59 26 4
gpt4 key购买 nike

Android documentation提到操作系统对以下每个存储桶的应用程序施加的限制:“Activity ”、“工作集”、“频繁”和“稀有”。
唯一documentation我发现“从不”存储桶(从未启动的应用程序在其中启动的存储桶)提到:

In addition, there's a special never bucket for apps that have been installed but have never been run. The system imposes severe restrictions on these apps.


有谁知道操作系统对“从不”存储桶中的应用程序施加了哪些限制? (桶50)

最佳答案

首先对我的回答做一点免责声明:
我的回答基于 AOSP 代码,可能会因版本或制造商而异。
此外,我们或许可以推断制造商对其行为方式有发言权:

Every manufacturer can set their own criteria for how non-active appsare assigned to buckets. You should not try to influence which bucketyour app is assigned to. Instead, focus on making sure your appbehaves well in whatever bucket it might be in. Your app can find outwhat bucket it's currently in by calling the new methodUsageStatsManager.getAppStandbyBucket().


作业将无法运行(带或不带充电器)
如果您查看 QuotaController,它是实现作业存储桶限制的地方:
框架/base/apex/jobscheduler/service/java/com/android/server/job/controllers/QuotaController.java
您会看到 NEVER_INDEX 只是关闭了工作可用性,并且不会隐式地将其自身升级/升级到更好的存储桶,除非某些事情会显式更改存储桶(例如,启动 Activity )。
这也适用于连接充电器时,如 isWithinQuotaLocked() 所示:
if (standbyBucket == NEVER_INDEX) return false;

// Quota constraint is not enforced while charging.
if (mChargeTracker.isCharging()) {
// Restricted jobs require additional constraints when charging, so don't immediately
// mark quota as free when charging.
if (standbyBucket != RESTRICTED_INDEX) {
return true;
}
警报不会运行(带或不带充电器)
看看AlarmManagerService:
frameworks/base/services/core/java/com/android/server/AlarmManagerService.java
在那里,您可以看到在连接/断开充电器时调用了 reorderAlarmsBasedOnStandbyBuckets()。
它根据配额对警报重新排序,对于存储桶,它从不为 0。
private final int[] DEFAULT_APP_STANDBY_QUOTAS = {
720, // Active
10, // Working
2, // Frequent
1, // Rare
0 // Never
};
代码将其推迟一天,直到它变为 0 以上:
      if (quotaForBucket <= 0) {
// Just keep deferring for a day till the quota changes
minElapsed = mInjector.getElapsedRealtime() + MILLIS_IN_DAY;
}
网络无法在后台工作
因为没有可用的作业和警报,所以没有可以使用网络的端点。
只有当前台服务/Activity 将备用存储桶更改为 Activity 状态时,它才会开始工作,如文档中所述:

An app is in the active bucket if the user is currently using the appor very recently used the app. For example: • The app has launched anactivity • The app is running a foreground service • The app has async adapter associated with a content provider used by a foregroundapp • The user clicks on a notification from the app

关于android - App Standby Buckets - "Never"bucket有什么限制(bucket 50),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65171129/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com