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

Commit 34a676bd authored by John Reck's avatar John Reck
Browse files

Register to receive onTrimMemory callbacks

 Bug: 5269460

Change-Id: Ic2429af1ba0b6e86157f6ba16d420d10c17920e5
parent faa42dbe
Loading
Loading
Loading
Loading
+35 −0
Original line number Diff line number Diff line
@@ -383,6 +383,39 @@ public class WebView extends AbsoluteLayout
        }
    }

    private static class OnTrimMemoryListener implements ComponentCallbacks2 {
        private static OnTrimMemoryListener sInstance = null;

        static void init(Context c) {
            if (sInstance == null) {
                sInstance = new OnTrimMemoryListener(c.getApplicationContext());
            }
        }

        private OnTrimMemoryListener(Context c) {
            c.registerComponentCallbacks(this);
        }

        @Override
        public void onConfigurationChanged(Configuration newConfig) {
            // Ignore
        }

        @Override
        public void onLowMemory() {
            // Ignore
        }

        @Override
        public void onTrimMemory(int level) {
            if (DebugFlags.WEB_VIEW) {
                Log.d("WebView", "onTrimMemory: " + level);
            }
            WebView.nativeOnTrimMemory(level);
        }

    }

    // A final CallbackProxy shared by WebViewCore and BrowserFrame.
    private final CallbackProxy mCallbackProxy;

@@ -1195,6 +1228,8 @@ public class WebView extends AbsoluteLayout
    }

    private void init() {
        OnTrimMemoryListener.init(getContext());

        setWillNotDraw(false);
        setFocusable(true);
        setFocusableInTouchMode(true);