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

Commit b463def0 authored by Jared Duke's avatar Jared Duke
Browse files

Remove PropertyInvalidatedCache.onTrimMemory

This method was only called for TRIM_MEMORY_COMPLETE, a signal that is
now deprecated and no longer issued. Remove the callsite and method for
now.

A follow-up effort may explore more targetted trimming and clearing for
caches that could have larger footprints than current ones.

Bug: 354774702
Test: m + presubmit
Flag: EXEMPT refactor
Change-Id: Iebe70537bfde5fe0480a38a3dbdc4a1e9296a6a8
parent 3e7db78c
Loading
Loading
Loading
Loading
+0 −3
Original line number Original line Diff line number Diff line
@@ -7066,9 +7066,6 @@ public final class ActivityThread extends ClientTransactionHandler
                    && level >= ComponentCallbacks2.TRIM_MEMORY_BACKGROUND) {
                    && level >= ComponentCallbacks2.TRIM_MEMORY_BACKGROUND) {
                return;
                return;
            }
            }
            if (level >= ComponentCallbacks2.TRIM_MEMORY_COMPLETE) {
                PropertyInvalidatedCache.onTrimMemory();
            }


            final ArrayList<ComponentCallbacks2> callbacks =
            final ArrayList<ComponentCallbacks2> callbacks =
                    collectComponentCallbacks(true /* includeUiContexts */);
                    collectComponentCallbacks(true /* includeUiContexts */);
+0 −14
Original line number Original line Diff line number Diff line
@@ -1617,18 +1617,4 @@ public class PropertyInvalidatedCache<Query, Result> {
            Log.e(TAG, "Failed to dump PropertyInvalidatedCache instances");
            Log.e(TAG, "Failed to dump PropertyInvalidatedCache instances");
        }
        }
    }
    }

    /**
     * Trim memory by clearing all the caches.
     * @hide
     */
    public static void onTrimMemory() {
        ArrayList<PropertyInvalidatedCache> activeCaches;
        synchronized (sGlobalLock) {
            activeCaches = getActiveCaches();
        }
        for (int i = 0; i < activeCaches.size(); i++) {
            activeCaches.get(i).clear();
        }
    }
}
}
+0 −16
Original line number Original line Diff line number Diff line
@@ -375,20 +375,4 @@ public class PropertyInvalidatedCacheTests {
            PropertyInvalidatedCache.MODULE_BLUETOOTH, "getState");
            PropertyInvalidatedCache.MODULE_BLUETOOTH, "getState");
        assertEquals(n1, "cache_key.bluetooth.get_state");
        assertEquals(n1, "cache_key.bluetooth.get_state");
    }
    }

    @Test
    public void testOnTrimMemory() {
        TestCache cache = new TestCache(MODULE, "trimMemoryTest");
        // The cache is not active until it has been invalidated once.
        cache.invalidateCache();
        // Populate the cache with six entries.
        for (int i = 0; i < 6; i++) {
            cache.query(i);
        }
        // The maximum number of entries in TestCache is 4, so even though six entries were
        // created, only four are retained.
        assertEquals(4, cache.size());
        PropertyInvalidatedCache.onTrimMemory();
        assertEquals(0, cache.size());
    }
}
}