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

Commit 89db0c17 authored by Sunny Goyal's avatar Sunny Goyal
Browse files

Converting BaseIconCache to kotlin

This makes it easier to define default parameters for various methods

Bug: 366237794
Flag: EXEMPT refactor
Test: Presubmit
Change-Id: If8f657f5a034f70b0af9a5c04601bb565204f3e6
parent 7c3c32d9
Loading
Loading
Loading
Loading
+0 −781

File deleted.

Preview size limit exceeded, changes collapsed.

+673 −0

File added.

Preview size limit exceeded, changes collapsed.

+8 −9
Original line number Diff line number Diff line
@@ -23,7 +23,6 @@ import android.os.SystemClock
import android.os.UserHandle
import android.util.ArrayMap
import android.util.Log
import com.android.launcher3.icons.cache.BaseIconCache.IconDB
import com.android.launcher3.util.ComponentKey
import com.android.launcher3.util.SQLiteCacheHelper
import java.util.ArrayDeque
@@ -107,19 +106,19 @@ class IconCacheUpdateHandler(
            cacheDb
                .query(
                    arrayOf(
                        IconDB.COLUMN_ROWID,
                        IconDB.COLUMN_COMPONENT,
                        IconDB.COLUMN_FRESHNESS_ID,
                        BaseIconCache.COLUMN_ROWID,
                        BaseIconCache.COLUMN_COMPONENT,
                        BaseIconCache.COLUMN_FRESHNESS_ID,
                    ),
                    "${IconDB.COLUMN_USER} = ? ",
                    "${BaseIconCache.COLUMN_USER} = ? ",
                    arrayOf(userSerial.toString()),
                )
                .use { c ->
                    var ignorePackages = packagesToIgnore[user] ?: emptySet()

                    val indexComponent = c.getColumnIndex(IconDB.COLUMN_COMPONENT)
                    val indexFreshnessId = c.getColumnIndex(IconDB.COLUMN_FRESHNESS_ID)
                    val rowIndex = c.getColumnIndex(IconDB.COLUMN_ROWID)
                    val indexComponent = c.getColumnIndex(BaseIconCache.COLUMN_COMPONENT)
                    val indexFreshnessId = c.getColumnIndex(BaseIconCache.COLUMN_FRESHNESS_ID)
                    val rowIndex = c.getColumnIndex(BaseIconCache.COLUMN_ROWID)

                    while (c.moveToNext()) {
                        val rowId = c.getInt(rowIndex)
@@ -232,7 +231,7 @@ class IconCacheUpdateHandler(
        // Commit all deletes
        if (itemsToDelete.isNotEmpty()) {
            val r = itemsToDelete.joinToString { it.rowId.toString() }
            cacheDb.delete("${IconDB.COLUMN_ROWID} IN ($r)", null)
            cacheDb.delete("${BaseIconCache.COLUMN_ROWID} IN ($r)", null)
            Log.d(TAG, "Deleting obsolete entries, count=" + itemsToDelete.size)
        }
    }
+2 −2
Original line number Diff line number Diff line
@@ -66,7 +66,7 @@ public class SimpleIconCache extends BaseIconCache {
    }

    @Override
    protected long getSerialNumberForUser(@NonNull UserHandle user) {
    public long getSerialNumberForUser(@NonNull UserHandle user) {
        synchronized (mUserSerialMap) {
            int index = mUserSerialMap.indexOfKey(user.getIdentifier());
            if (index >= 0) {
@@ -92,7 +92,7 @@ public class SimpleIconCache extends BaseIconCache {
    @NonNull
    @Override
    public BaseIconFactory getIconFactory() {
        return IconFactory.obtain(mContext);
        return IconFactory.obtain(context);
    }

    public static SimpleIconCache getIconCache(Context context) {