Merge "Adding more diags for WellbeingModel" into sc-dev

This commit is contained in:
TreeHugger Robot
2021-05-28 02:12:42 +00:00
committed by Android (Google) Code Review

View File

@@ -319,12 +319,17 @@ public final class WellbeingModel extends BgObjectWithLooper {
@WorkerThread
private void updateActionsWithRetry(int retryCount, @Nullable String packageName) {
if (DEBUG || mIsInTest) {
Log.i(TAG,
"updateActionsWithRetry(); retryCount: " + retryCount + ", package: "
+ packageName);
}
String[] packageNames = TextUtils.isEmpty(packageName)
? mContext.getSystemService(LauncherApps.class)
? mContext.getSystemService(LauncherApps.class)
.getActivityList(null, Process.myUserHandle()).stream()
.map(li -> li.getApplicationInfo().packageName).distinct()
.toArray(String[]::new)
: new String[] { packageName };
: new String[]{packageName};
mWorkerHandler.removeCallbacksAndMessages(packageName);
if (updateActions(packageNames)) {
@@ -335,12 +340,16 @@ public final class WellbeingModel extends BgObjectWithLooper {
return;
}
mWorkerHandler.postDelayed(
() -> updateActionsWithRetry(retryCount + 1, packageName),
() -> {
if (DEBUG || mIsInTest) Log.i(TAG, "Retrying; attempt " + (retryCount + 1));
updateActionsWithRetry(retryCount + 1, packageName);
},
packageName, RETRY_TIMES_MS[retryCount]);
}
@WorkerThread
private void updateAllPackages() {
if (DEBUG || mIsInTest) Log.i(TAG, "updateAllPackages");
updateActionsWithRetry(0, null);
}