Search in sources :

Example 36 with INSTALL

use of com.android.launcher3.popup.SystemShortcut.INSTALL in project android_packages_apps_Launcher3 by AOSPA.

the class LauncherModelHelper method initializeData.

/**
 * Initializes mock data for the test.
 */
public void initializeData(String resourceName) throws Exception {
    BgDataModel bgDataModel = getBgDataModel();
    AllAppsList allAppsList = getAllAppsList();
    MODEL_EXECUTOR.submit(() -> {
        // Copy apk from resources to a local file and install from there.
        Resources resources = testContext().getResources();
        int resId = resources.getIdentifier(resourceName, "raw", testContext().getPackageName());
        try (BufferedReader reader = new BufferedReader(new InputStreamReader(resources.openRawResource(resId)))) {
            String line;
            HashMap<String, Class> classMap = new HashMap<>();
            while ((line = reader.readLine()) != null) {
                line = line.trim();
                if (line.startsWith("#") || line.isEmpty()) {
                    continue;
                }
                String[] commands = line.split(" ");
                switch(commands[0]) {
                    case "classMap":
                        classMap.put(commands[1], Class.forName(commands[2]));
                        break;
                    case "bgItem":
                        bgDataModel.addItem(sandboxContext, (ItemInfo) initItem(classMap.get(commands[1]), commands, 2), false);
                        break;
                    case "allApps":
                        allAppsList.add((AppInfo) initItem(AppInfo.class, commands, 1), null);
                        break;
                }
            }
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }).get();
}
Also used : InputStreamReader(java.io.InputStreamReader) HashMap(java.util.HashMap) ItemInfo(com.android.launcher3.model.data.ItemInfo) BgDataModel(com.android.launcher3.model.BgDataModel) AllAppsList(com.android.launcher3.model.AllAppsList) BufferedReader(java.io.BufferedReader) Resources(android.content.res.Resources) FileNotFoundException(java.io.FileNotFoundException) ExecutionException(java.util.concurrent.ExecutionException) AppInfo(com.android.launcher3.model.data.AppInfo)

Aggregations

ItemInfo (com.android.launcher3.model.data.ItemInfo)15 HashSet (java.util.HashSet)14 HashMap (java.util.HashMap)13 BitmapInfo (com.android.launcher3.icons.BitmapInfo)12 LauncherIcons (com.android.launcher3.icons.LauncherIcons)12 LauncherAppWidgetInfo (com.android.launcher3.model.data.LauncherAppWidgetInfo)12 WorkspaceItemInfo (com.android.launcher3.model.data.WorkspaceItemInfo)12 ComponentName (android.content.ComponentName)9 Launcher (com.android.launcher3.Launcher)9 AppInfo (com.android.launcher3.model.data.AppInfo)9 Context (android.content.Context)7 ShortcutInfo (android.content.pm.ShortcutInfo)7 IconCache (com.android.launcher3.icons.IconCache)7 FlagOp (com.android.launcher3.util.FlagOp)7 ItemInfoMatcher (com.android.launcher3.util.ItemInfoMatcher)7 PackageUserKey (com.android.launcher3.util.PackageUserKey)7 SafeCloseable (com.android.launcher3.util.SafeCloseable)7 ArrayList (java.util.ArrayList)7 ApplicationInfo (android.content.pm.ApplicationInfo)6 LauncherApps (android.content.pm.LauncherApps)6