Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit f0ba8b7c authored by Sunny Goyal's avatar Sunny Goyal
Browse files

Moving various runnables in LauncherModel to individual tasks

> Adding tests for some of the runnable

Change-Id: I1a315d38878857df3371f0e69d622a41fc3b081a
parent 0d547bfd
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -45,6 +45,7 @@ android {

        androidTest {
            java.srcDirs = ['tests/src']
            res.srcDirs = ['tests/res']
            manifest.srcFile "tests/AndroidManifest.xml"
        }

@@ -65,6 +66,9 @@ dependencies {
    compile 'com.google.protobuf.nano:protobuf-javanano:3.0.0-alpha-2'

    testCompile 'junit:junit:4.12'
    androidTestCompile "org.mockito:mockito-core:1.+"
    androidTestCompile 'com.google.dexmaker:dexmaker:1.2'
    androidTestCompile 'com.google.dexmaker:dexmaker-mockito:1.2'
    androidTestCompile 'com.android.support.test:runner:0.5'
    androidTestCompile 'com.android.support.test.uiautomator:uiautomator-v18:2.1.2'
    androidTestCompile 'com.android.support:support-annotations:23.2.0'
+6 −9
Original line number Diff line number Diff line
@@ -155,10 +155,9 @@ public class AllAppsList {
            // to the removed list.
            for (int i = data.size() - 1; i >= 0; i--) {
                final AppInfo applicationInfo = data.get(i);
                final ComponentName component = applicationInfo.intent.getComponent();
                if (user.equals(applicationInfo.user)
                        && packageName.equals(component.getPackageName())) {
                    if (!findActivity(matches, component)) {
                        && packageName.equals(applicationInfo.componentName.getPackageName())) {
                    if (!findActivity(matches, applicationInfo.componentName)) {
                        removed.add(applicationInfo);
                        data.remove(i);
                    }
@@ -182,11 +181,10 @@ public class AllAppsList {
            // Remove all data for this package.
            for (int i = data.size() - 1; i >= 0; i--) {
                final AppInfo applicationInfo = data.get(i);
                final ComponentName component = applicationInfo.intent.getComponent();
                if (user.equals(applicationInfo.user)
                        && packageName.equals(component.getPackageName())) {
                        && packageName.equals(applicationInfo.componentName.getPackageName())) {
                    removed.add(applicationInfo);
                    mIconCache.remove(component, user);
                    mIconCache.remove(applicationInfo.componentName, user);
                    data.remove(i);
                }
            }
@@ -238,9 +236,8 @@ public class AllAppsList {
    private AppInfo findApplicationInfoLocked(String packageName, UserHandleCompat user,
            String className) {
        for (AppInfo info: data) {
            final ComponentName component = info.intent.getComponent();
            if (user.equals(info.user) && packageName.equals(component.getPackageName())
                    && className.equals(component.getClassName())) {
            if (user.equals(info.user) && packageName.equals(info.componentName.getPackageName())
                    && className.equals(info.componentName.getClassName())) {
                return info;
            }
        }
+2 −2
Original line number Diff line number Diff line
@@ -79,7 +79,7 @@ public class IconCache {

    @Thunk static final Object ICON_UPDATE_TOKEN = new Object();

    @Thunk static class CacheEntry {
    public static class CacheEntry {
        public Bitmap icon;
        public CharSequence title = "";
        public CharSequence contentDescription = "";
@@ -544,7 +544,7 @@ public class IconCache {
     * Retrieves the entry from the cache. If the entry is not present, it creates a new entry.
     * This method is not thread safe, it must be called from a synchronized method.
     */
    private CacheEntry cacheLocked(ComponentName componentName, LauncherActivityInfoCompat info,
    protected CacheEntry cacheLocked(ComponentName componentName, LauncherActivityInfoCompat info,
            UserHandleCompat user, boolean usePackageIcon, boolean useLowResIcon) {
        ComponentKey cacheKey = new ComponentKey(componentName, user);
        CacheEntry entry = mCache.get(cacheKey);
+1 −1
Original line number Diff line number Diff line
@@ -241,7 +241,7 @@ public class InstallShortcutReceiver extends BroadcastReceiver {
            // Add the new apps to the model and bind them
            if (!addShortcuts.isEmpty()) {
                LauncherAppState app = LauncherAppState.getInstance();
                app.getModel().addAndBindAddedWorkspaceItems(context, addShortcuts);
                app.getModel().addAndBindAddedWorkspaceItems(addShortcuts);
            }
        }
    }
+8 −3
Original line number Diff line number Diff line
@@ -84,12 +84,12 @@ public class LauncherAppWidgetInfo extends ItemInfo {
    /**
     * Indicates the restore status of the widget.
     */
    int restoreStatus;
    public int restoreStatus;

    /**
     * Indicates the installation progress of the widget provider
     */
    int installProgress = -1;
    public int installProgress = -1;

    /**
     * Optional extras sent during widget bind. See {@link #FLAG_DIRECT_CONFIG}.
@@ -98,7 +98,7 @@ public class LauncherAppWidgetInfo extends ItemInfo {

    private boolean mHasNotifiedInitialWidgetSizeChanged;

    LauncherAppWidgetInfo(int appWidgetId, ComponentName providerName) {
    public LauncherAppWidgetInfo(int appWidgetId, ComponentName providerName) {
        if (appWidgetId == CUSTOM_WIDGET_ID) {
            itemType = LauncherSettings.Favorites.ITEM_TYPE_CUSTOM_APPWIDGET;
        } else {
@@ -117,6 +117,11 @@ public class LauncherAppWidgetInfo extends ItemInfo {
        restoreStatus = RESTORE_COMPLETED;
    }

    /** Used for testing **/
    public LauncherAppWidgetInfo() {
        itemType = LauncherSettings.Favorites.ITEM_TYPE_APPWIDGET;
    }

    public boolean isCustomWidget() {
        return appWidgetId == CUSTOM_WIDGET_ID;
    }
Loading