Adding more diags for WellbeingModel

Test: presubmit
Bug: 189139513
Change-Id: Ic52ef42d2cd0a3f19f55aee048911526dd8c732f
This commit is contained in:
vadimt
2021-05-24 16:42:07 -07:00
parent 4717bae7dc
commit 6fad078a31

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);
}