Merge remote-tracking branch 'origin/release' into dev

# Conflicts:
#	app/src/main/java/com/gh/gamecenter/catalog/CatalogFragment.kt
#	app/src/main/java/com/gh/gamecenter/catalog/SubCatalogFragment.kt
This commit is contained in:
juntao
2021-02-27 10:58:57 +08:00
10 changed files with 81 additions and 58 deletions

View File

@ -490,10 +490,15 @@ public class DownloadManager implements DownloadStatusListener {
* @param packageName 包名
* @return null表示下载列表中不存在该任务否则返回下载任务
*/
@Nullable
public DownloadEntity getDownloadEntityByPackageName(String packageName) {
if (mDownloadDao == null) return null;
for (DownloadEntity downloadEntity : mDownloadDao.getAll()) {
List<DownloadEntity> downloadList = mDownloadDao.getAll();
if (downloadList == null) return null;
for (DownloadEntity downloadEntity : downloadList) {
if (packageName.equals(downloadEntity.getPackageName())) {
return downloadEntity;
}
@ -762,7 +767,16 @@ public class DownloadManager implements DownloadStatusListener {
serviceIntent.putExtra(DownloadService.KEY_SERVICE_ACTION, DownloadService.START_FOREGROUND);
mContext.startForegroundService(serviceIntent);
} else {
mContext.startService(serviceIntent);
/*
* sentry上报oppo手机无法启动服务原因OPPO手机自动熄屏一段时间后会启用系统自带的电量优化管理禁止一切自启动的APP用户设置的自启动白名单除外所以在服务启动的地方进行try/catch防止崩溃
* https://sentry.ghzs.com/organizations/lightgame/issues/10707/?project=22&query=is%3Aunresolved+assigned%3Ame&statsPeriod=14d
* https://stackoverflow.com/questions/38764497/security-exception-unable-to-start-service-user-0-is-restricted
*/
ExtensionsKt.tryWithDefaultCatch(() -> {
mContext.startService(serviceIntent);
return null;
});
}
}