Loading src/com/android/launcher3/LauncherAppState.java +4 −1 Original line number Diff line number Diff line Loading @@ -16,6 +16,8 @@ package com.android.launcher3; import static android.app.admin.DevicePolicyManager.ACTION_DEVICE_POLICY_RESOURCE_UPDATED; import static com.android.launcher3.Utilities.getDevicePrefs; import static com.android.launcher3.config.FeatureFlags.ENABLE_THEMED_ICONS; import static com.android.launcher3.util.Executors.MODEL_EXECUTOR; Loading Loading @@ -97,7 +99,8 @@ public class LauncherAppState implements SafeCloseable { modelChangeReceiver.register(mContext, Intent.ACTION_LOCALE_CHANGED, Intent.ACTION_MANAGED_PROFILE_AVAILABLE, Intent.ACTION_MANAGED_PROFILE_UNAVAILABLE, Intent.ACTION_MANAGED_PROFILE_UNLOCKED); Intent.ACTION_MANAGED_PROFILE_UNLOCKED, ACTION_DEVICE_POLICY_RESOURCE_UPDATED); if (FeatureFlags.IS_STUDIO_BUILD) { modelChangeReceiver.register(mContext, Context.RECEIVER_EXPORTED, ACTION_FORCE_ROLOAD); } Loading src/com/android/launcher3/LauncherModel.java +5 −0 Original line number Diff line number Diff line Loading @@ -16,6 +16,8 @@ package com.android.launcher3; import static android.app.admin.DevicePolicyManager.ACTION_DEVICE_POLICY_RESOURCE_UPDATED; import static com.android.launcher3.LauncherAppState.ACTION_FORCE_ROLOAD; import static com.android.launcher3.config.FeatureFlags.IS_STUDIO_BUILD; import static com.android.launcher3.util.Executors.MAIN_EXECUTOR; Loading Loading @@ -51,6 +53,7 @@ import com.android.launcher3.model.ModelWriter; import com.android.launcher3.model.PackageIncrementalDownloadUpdatedTask; import com.android.launcher3.model.PackageInstallStateChangedTask; import com.android.launcher3.model.PackageUpdatedTask; import com.android.launcher3.model.ReloadStringCacheTask; import com.android.launcher3.model.ShortcutsChangedTask; import com.android.launcher3.model.UserLockStateChangedTask; import com.android.launcher3.model.data.AppInfo; Loading Loading @@ -278,6 +281,8 @@ public class LauncherModel extends LauncherApps.Callback implements InstallSessi user, Intent.ACTION_MANAGED_PROFILE_UNLOCKED.equals(action))); } } } else if (ACTION_DEVICE_POLICY_RESOURCE_UPDATED.equals(action)) { enqueueModelUpdateTask(new ReloadStringCacheTask(mModelDelegate)); } else if (IS_STUDIO_BUILD && ACTION_FORCE_ROLOAD.equals(action)) { for (Callbacks cb : getCallbacks()) { if (cb instanceof Launcher) { Loading src/com/android/launcher3/folder/FolderNameProvider.java +19 −2 Original line number Diff line number Diff line Loading @@ -15,6 +15,8 @@ */ package com.android.launcher3.folder; import android.annotation.SuppressLint; import android.app.admin.DevicePolicyManager; import android.content.ComponentName; import android.content.Context; import android.os.Process; Loading @@ -22,11 +24,15 @@ import android.os.UserHandle; import android.text.TextUtils; import android.util.Log; import androidx.annotation.WorkerThread; import com.android.launcher3.LauncherAppState; import com.android.launcher3.R; import com.android.launcher3.Utilities; import com.android.launcher3.model.AllAppsList; import com.android.launcher3.model.BaseModelUpdateTask; import com.android.launcher3.model.BgDataModel; import com.android.launcher3.model.StringCache; import com.android.launcher3.model.data.AppInfo; import com.android.launcher3.model.data.FolderInfo; import com.android.launcher3.model.data.WorkspaceItemInfo; Loading Loading @@ -94,6 +100,7 @@ public class FolderNameProvider implements ResourceBasedOverride { /** * Generate and rank the suggested Folder names. */ @WorkerThread public void getSuggestedFolderName(Context context, ArrayList<WorkspaceItemInfo> workspaceItemInfos, FolderNameInfos nameInfos) { Loading @@ -107,8 +114,7 @@ public class FolderNameProvider implements ResourceBasedOverride { Set<UserHandle> users = workspaceItemInfos.stream().map(w -> w.user) .collect(Collectors.toSet()); if (users.size() == 1 && !users.contains(Process.myUserHandle())) { String workFolderName = context.getString(R.string.work_folder_name); setAsLastSuggestion(nameInfos, workFolderName); setAsLastSuggestion(nameInfos, getWorkFolderName(context)); } // If all the icons are from same package (e.g., main icon, shortcut, shortcut) Loading @@ -130,6 +136,17 @@ public class FolderNameProvider implements ResourceBasedOverride { } } @WorkerThread @SuppressLint("NewApi") private String getWorkFolderName(Context context) { if (!Utilities.ATLEAST_T) { return context.getString(R.string.work_folder_name); } return context.getSystemService(DevicePolicyManager.class).getResources() .getString(StringCache.WORK_FOLDER_NAME, () -> context.getString(R.string.work_folder_name)); } private Optional<AppInfo> getAppInfoByPackageName(String packageName) { if (mAppInfos == null || mAppInfos.isEmpty()) { return Optional.empty(); Loading src/com/android/launcher3/model/ReloadStringCacheTask.java 0 → 100644 +39 −0 Original line number Diff line number Diff line /* * 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 com.android.launcher3.LauncherAppState; /** * Handles updates due to changes in Device Policy Management resources triggered by * {@link android.app.admin.DevicePolicyManager#ACTION_DEVICE_POLICY_RESOURCE_UPDATED}. */ public class ReloadStringCacheTask extends BaseModelUpdateTask { private ModelDelegate mModelDelegate; public ReloadStringCacheTask(ModelDelegate modelDelegate) { mModelDelegate = modelDelegate; } @Override public void execute(LauncherAppState app, BgDataModel dataModel, AllAppsList appsList) { synchronized (dataModel) { mModelDelegate.loadStringCache(dataModel.stringCache); StringCache cloneSC = dataModel.stringCache.clone(); scheduleCallbackTask(c -> c.bindStringCache(cloneSC)); } } } src/com/android/launcher3/model/StringCache.java +5 −5 Original line number Diff line number Diff line Loading @@ -34,6 +34,11 @@ public class StringCache { private static final String PREFIX = "Launcher."; /** * Work folder name. */ public static final String WORK_FOLDER_NAME = PREFIX + "WORK_FOLDER_NAME"; /** * User on-boarding title for work profile apps. */ Loading Loading @@ -90,11 +95,6 @@ public class StringCache { private static final String ALL_APPS_PERSONAL_TAB_ACCESSIBILITY = PREFIX + "ALL_APPS_PERSONAL_TAB_ACCESSIBILITY"; /** * Work folder name. */ private static final String WORK_FOLDER_NAME = PREFIX + "WORK_FOLDER_NAME"; /** * Label on widget tab to indicate work app widgets. */ Loading Loading
src/com/android/launcher3/LauncherAppState.java +4 −1 Original line number Diff line number Diff line Loading @@ -16,6 +16,8 @@ package com.android.launcher3; import static android.app.admin.DevicePolicyManager.ACTION_DEVICE_POLICY_RESOURCE_UPDATED; import static com.android.launcher3.Utilities.getDevicePrefs; import static com.android.launcher3.config.FeatureFlags.ENABLE_THEMED_ICONS; import static com.android.launcher3.util.Executors.MODEL_EXECUTOR; Loading Loading @@ -97,7 +99,8 @@ public class LauncherAppState implements SafeCloseable { modelChangeReceiver.register(mContext, Intent.ACTION_LOCALE_CHANGED, Intent.ACTION_MANAGED_PROFILE_AVAILABLE, Intent.ACTION_MANAGED_PROFILE_UNAVAILABLE, Intent.ACTION_MANAGED_PROFILE_UNLOCKED); Intent.ACTION_MANAGED_PROFILE_UNLOCKED, ACTION_DEVICE_POLICY_RESOURCE_UPDATED); if (FeatureFlags.IS_STUDIO_BUILD) { modelChangeReceiver.register(mContext, Context.RECEIVER_EXPORTED, ACTION_FORCE_ROLOAD); } Loading
src/com/android/launcher3/LauncherModel.java +5 −0 Original line number Diff line number Diff line Loading @@ -16,6 +16,8 @@ package com.android.launcher3; import static android.app.admin.DevicePolicyManager.ACTION_DEVICE_POLICY_RESOURCE_UPDATED; import static com.android.launcher3.LauncherAppState.ACTION_FORCE_ROLOAD; import static com.android.launcher3.config.FeatureFlags.IS_STUDIO_BUILD; import static com.android.launcher3.util.Executors.MAIN_EXECUTOR; Loading Loading @@ -51,6 +53,7 @@ import com.android.launcher3.model.ModelWriter; import com.android.launcher3.model.PackageIncrementalDownloadUpdatedTask; import com.android.launcher3.model.PackageInstallStateChangedTask; import com.android.launcher3.model.PackageUpdatedTask; import com.android.launcher3.model.ReloadStringCacheTask; import com.android.launcher3.model.ShortcutsChangedTask; import com.android.launcher3.model.UserLockStateChangedTask; import com.android.launcher3.model.data.AppInfo; Loading Loading @@ -278,6 +281,8 @@ public class LauncherModel extends LauncherApps.Callback implements InstallSessi user, Intent.ACTION_MANAGED_PROFILE_UNLOCKED.equals(action))); } } } else if (ACTION_DEVICE_POLICY_RESOURCE_UPDATED.equals(action)) { enqueueModelUpdateTask(new ReloadStringCacheTask(mModelDelegate)); } else if (IS_STUDIO_BUILD && ACTION_FORCE_ROLOAD.equals(action)) { for (Callbacks cb : getCallbacks()) { if (cb instanceof Launcher) { Loading
src/com/android/launcher3/folder/FolderNameProvider.java +19 −2 Original line number Diff line number Diff line Loading @@ -15,6 +15,8 @@ */ package com.android.launcher3.folder; import android.annotation.SuppressLint; import android.app.admin.DevicePolicyManager; import android.content.ComponentName; import android.content.Context; import android.os.Process; Loading @@ -22,11 +24,15 @@ import android.os.UserHandle; import android.text.TextUtils; import android.util.Log; import androidx.annotation.WorkerThread; import com.android.launcher3.LauncherAppState; import com.android.launcher3.R; import com.android.launcher3.Utilities; import com.android.launcher3.model.AllAppsList; import com.android.launcher3.model.BaseModelUpdateTask; import com.android.launcher3.model.BgDataModel; import com.android.launcher3.model.StringCache; import com.android.launcher3.model.data.AppInfo; import com.android.launcher3.model.data.FolderInfo; import com.android.launcher3.model.data.WorkspaceItemInfo; Loading Loading @@ -94,6 +100,7 @@ public class FolderNameProvider implements ResourceBasedOverride { /** * Generate and rank the suggested Folder names. */ @WorkerThread public void getSuggestedFolderName(Context context, ArrayList<WorkspaceItemInfo> workspaceItemInfos, FolderNameInfos nameInfos) { Loading @@ -107,8 +114,7 @@ public class FolderNameProvider implements ResourceBasedOverride { Set<UserHandle> users = workspaceItemInfos.stream().map(w -> w.user) .collect(Collectors.toSet()); if (users.size() == 1 && !users.contains(Process.myUserHandle())) { String workFolderName = context.getString(R.string.work_folder_name); setAsLastSuggestion(nameInfos, workFolderName); setAsLastSuggestion(nameInfos, getWorkFolderName(context)); } // If all the icons are from same package (e.g., main icon, shortcut, shortcut) Loading @@ -130,6 +136,17 @@ public class FolderNameProvider implements ResourceBasedOverride { } } @WorkerThread @SuppressLint("NewApi") private String getWorkFolderName(Context context) { if (!Utilities.ATLEAST_T) { return context.getString(R.string.work_folder_name); } return context.getSystemService(DevicePolicyManager.class).getResources() .getString(StringCache.WORK_FOLDER_NAME, () -> context.getString(R.string.work_folder_name)); } private Optional<AppInfo> getAppInfoByPackageName(String packageName) { if (mAppInfos == null || mAppInfos.isEmpty()) { return Optional.empty(); Loading
src/com/android/launcher3/model/ReloadStringCacheTask.java 0 → 100644 +39 −0 Original line number Diff line number Diff line /* * 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 com.android.launcher3.LauncherAppState; /** * Handles updates due to changes in Device Policy Management resources triggered by * {@link android.app.admin.DevicePolicyManager#ACTION_DEVICE_POLICY_RESOURCE_UPDATED}. */ public class ReloadStringCacheTask extends BaseModelUpdateTask { private ModelDelegate mModelDelegate; public ReloadStringCacheTask(ModelDelegate modelDelegate) { mModelDelegate = modelDelegate; } @Override public void execute(LauncherAppState app, BgDataModel dataModel, AllAppsList appsList) { synchronized (dataModel) { mModelDelegate.loadStringCache(dataModel.stringCache); StringCache cloneSC = dataModel.stringCache.clone(); scheduleCallbackTask(c -> c.bindStringCache(cloneSC)); } } }
src/com/android/launcher3/model/StringCache.java +5 −5 Original line number Diff line number Diff line Loading @@ -34,6 +34,11 @@ public class StringCache { private static final String PREFIX = "Launcher."; /** * Work folder name. */ public static final String WORK_FOLDER_NAME = PREFIX + "WORK_FOLDER_NAME"; /** * User on-boarding title for work profile apps. */ Loading Loading @@ -90,11 +95,6 @@ public class StringCache { private static final String ALL_APPS_PERSONAL_TAB_ACCESSIBILITY = PREFIX + "ALL_APPS_PERSONAL_TAB_ACCESSIBILITY"; /** * Work folder name. */ private static final String WORK_FOLDER_NAME = PREFIX + "WORK_FOLDER_NAME"; /** * Label on widget tab to indicate work app widgets. */ Loading