Files
Lawnchair/src/com/android/launcher3/model/CacheDataUpdatedTask.java
T
Hyunyoung Song 0a4a4d920e Revert "Merging from ub-launcher3-rvc-qpr-dev @ build 6690853"
Revert "Merging from ub-launcher3-rvc-qpr-dev @ build 6690853"

Revert "Merging from ub-launcher3-rvc-qpr-dev @ build 6690853"

Revert submission 12190253-merge_ub-launcher3-rvc-qpr-dev_6690853

Reason for revert: Build ID picked from ub-launcher3-master and not ub-launcher3-rvc-qpr-dev

Reverted Changes:
I9e658ece0:Merging from ub-launcher3-rvc-qpr-dev @ build 6690...
I2a47fe180:Merging from ub-launcher3-rvc-qpr-dev @ build 6690...
Ie86b0a2e0:Merging from ub-launcher3-rvc-qpr-dev @ build 6690...
Id3ca76da6:Merging from ub-launcher3-rvc-qpr-dev @ build 6690...
Ib6a63da0f:Merging from ub-launcher3-rvc-qpr-dev @ build 6690...
Bug: 162366734


Change-Id: Ie81853a34c9a48d5b3fd922c65483a9ff639e0ce
Merged-In: Ibff46b3ef7ff89accb459db323f31179adb4ef21
2020-07-28 23:43:43 +00:00

85 lines
2.9 KiB
Java

/*
* Copyright (C) 2016 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.android.launcher3.model;
import android.content.ComponentName;
import android.os.UserHandle;
import com.android.launcher3.LauncherAppState;
import com.android.launcher3.LauncherSettings;
import com.android.launcher3.icons.IconCache;
import com.android.launcher3.model.data.ItemInfo;
import com.android.launcher3.model.data.WorkspaceItemInfo;
import java.util.ArrayList;
import java.util.HashSet;
/**
* Handles changes due to cache updates.
*/
public class CacheDataUpdatedTask extends BaseModelUpdateTask {
public static final int OP_CACHE_UPDATE = 1;
public static final int OP_SESSION_UPDATE = 2;
private final int mOp;
private final UserHandle mUser;
private final HashSet<String> mPackages;
public CacheDataUpdatedTask(int op, UserHandle user, HashSet<String> packages) {
mOp = op;
mUser = user;
mPackages = packages;
}
@Override
public void execute(LauncherAppState app, BgDataModel dataModel, AllAppsList apps) {
IconCache iconCache = app.getIconCache();
ArrayList<WorkspaceItemInfo> updatedShortcuts = new ArrayList<>();
synchronized (dataModel) {
for (ItemInfo info : dataModel.itemsIdMap) {
if (info instanceof WorkspaceItemInfo && mUser.equals(info.user)) {
WorkspaceItemInfo si = (WorkspaceItemInfo) info;
ComponentName cn = si.getTargetComponent();
if (si.itemType == LauncherSettings.Favorites.ITEM_TYPE_APPLICATION
&& isValidShortcut(si) && cn != null
&& mPackages.contains(cn.getPackageName())) {
iconCache.getTitleAndIcon(si, si.usingLowResIcon());
updatedShortcuts.add(si);
}
}
}
apps.updateIconsAndLabels(mPackages, mUser);
}
bindUpdatedWorkspaceItems(updatedShortcuts);
bindApplicationsIfNeeded();
}
public boolean isValidShortcut(WorkspaceItemInfo si) {
switch (mOp) {
case OP_CACHE_UPDATE:
return true;
case OP_SESSION_UPDATE:
return si.hasPromiseIconUi();
default:
return false;
}
}
}