Merge "Fix the issue "Turn on work profile?" dialog not displayed for work profile deep shortcuts when disabled." into ub-launcher3-rvc-dev

This commit is contained in:
TreeHugger Robot
2020-04-09 18:48:19 +00:00
committed by Android (Google) Code Review
2 changed files with 9 additions and 8 deletions
+2 -1
View File
@@ -235,7 +235,8 @@ public class LauncherModel extends LauncherApps.Callback implements InstallSessi
// we need to run the state change task again.
if (Intent.ACTION_MANAGED_PROFILE_UNAVAILABLE.equals(action) ||
Intent.ACTION_MANAGED_PROFILE_UNLOCKED.equals(action)) {
enqueueModelUpdateTask(new UserLockStateChangedTask(user));
enqueueModelUpdateTask(new UserLockStateChangedTask(
user, Intent.ACTION_MANAGED_PROFILE_UNLOCKED.equals(action)));
}
}
} else if (IS_STUDIO_BUILD && ACTION_FORCE_ROLOAD.equals(action)) {
@@ -20,7 +20,6 @@ import static com.android.launcher3.ItemInfoWithIcon.FLAG_DISABLED_LOCKED_USER;
import android.content.Context;
import android.content.pm.ShortcutInfo;
import android.os.UserHandle;
import android.os.UserManager;
import com.android.launcher3.ItemInfo;
import com.android.launcher3.LauncherAppState;
@@ -43,18 +42,19 @@ import java.util.Iterator;
public class UserLockStateChangedTask extends BaseModelUpdateTask {
private final UserHandle mUser;
private boolean mIsUserUnlocked;
public UserLockStateChangedTask(UserHandle user) {
public UserLockStateChangedTask(UserHandle user, boolean isUserUnlocked) {
mUser = user;
mIsUserUnlocked = isUserUnlocked;
}
@Override
public void execute(LauncherAppState app, BgDataModel dataModel, AllAppsList apps) {
Context context = app.getContext();
boolean isUserUnlocked = context.getSystemService(UserManager.class).isUserUnlocked(mUser);
HashMap<ShortcutKey, ShortcutInfo> pinnedShortcuts = new HashMap<>();
if (isUserUnlocked) {
if (mIsUserUnlocked) {
QueryResult shortcuts = new ShortcutRequest(context, mUser)
.query(ShortcutRequest.PINNED);
if (shortcuts.wasSuccess()) {
@@ -65,7 +65,7 @@ public class UserLockStateChangedTask extends BaseModelUpdateTask {
// Shortcut manager can fail due to some race condition when the lock state
// changes too frequently. For the purpose of the update,
// consider it as still locked.
isUserUnlocked = false;
mIsUserUnlocked = false;
}
}
@@ -77,7 +77,7 @@ public class UserLockStateChangedTask extends BaseModelUpdateTask {
if (itemInfo.itemType == LauncherSettings.Favorites.ITEM_TYPE_DEEP_SHORTCUT
&& mUser.equals(itemInfo.user)) {
WorkspaceItemInfo si = (WorkspaceItemInfo) itemInfo;
if (isUserUnlocked) {
if (mIsUserUnlocked) {
ShortcutKey key = ShortcutKey.fromItemInfo(si);
ShortcutInfo shortcut = pinnedShortcuts.get(key);
// We couldn't verify the shortcut during loader. If its no longer available
@@ -108,7 +108,7 @@ public class UserLockStateChangedTask extends BaseModelUpdateTask {
}
}
if (isUserUnlocked) {
if (mIsUserUnlocked) {
dataModel.updateDeepShortcutCounts(
null, mUser,
new ShortcutRequest(context, mUser).query(ShortcutRequest.ALL));