This repository was archived by the owner on Feb 25, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6k
Call Shell::NotifyLowMemoryWarning on Android Trim and LowMemory events #18979
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
48a1245
fix build
dnfield 5411470
Dart_NotifyLowMemory on memory pressure in Android
dnfield 1a93d54
Merge remote-tracking branch 'upstream/master' into android_mem
dnfield 5ad39c8
review and format
dnfield 8ade3ed
Update DartExecutorTest.java
dnfield File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,6 @@ | ||
| package io.flutter.embedding.android; | ||
|
|
||
| import static android.content.ComponentCallbacks2.TRIM_MEMORY_RUNNING_LOW; | ||
| import static android.content.ComponentCallbacks2.*; | ||
| import static org.junit.Assert.assertEquals; | ||
| import static org.junit.Assert.assertNull; | ||
| import static org.mockito.Matchers.any; | ||
|
|
@@ -442,7 +442,7 @@ public void itForwardsOnUserLeaveHintToFlutterEngine() { | |
| } | ||
|
|
||
| @Test | ||
| public void itSendsMessageOverSystemChannelWhenToldToTrimMemory() { | ||
| public void itNotifiesDartExecutorAndSendsMessageOverSystemChannelWhenToldToTrimMemory() { | ||
| // Create the real object that we're testing. | ||
| FlutterActivityAndFragmentDelegate delegate = new FlutterActivityAndFragmentDelegate(mockHost); | ||
|
|
||
|
|
@@ -451,14 +451,21 @@ public void itSendsMessageOverSystemChannelWhenToldToTrimMemory() { | |
| delegate.onAttach(RuntimeEnvironment.application); | ||
|
|
||
| // Emulate the host and call the method that we expect to be forwarded. | ||
| delegate.onTrimMemory(TRIM_MEMORY_RUNNING_MODERATE); | ||
| delegate.onTrimMemory(TRIM_MEMORY_RUNNING_LOW); | ||
| delegate.onTrimMemory(TRIM_MEMORY_RUNNING_CRITICAL); | ||
| delegate.onTrimMemory(TRIM_MEMORY_BACKGROUND); | ||
| delegate.onTrimMemory(TRIM_MEMORY_COMPLETE); | ||
| delegate.onTrimMemory(TRIM_MEMORY_MODERATE); | ||
| delegate.onTrimMemory(TRIM_MEMORY_UI_HIDDEN); | ||
|
|
||
| // Verify that the call was forwarded to the engine. | ||
| verify(mockFlutterEngine.getDartExecutor(), times(7)).notifyLowMemoryWarning(); | ||
| verify(mockFlutterEngine.getSystemChannel(), times(1)).sendMemoryPressureWarning(); | ||
| } | ||
|
|
||
| @Test | ||
| public void itSendsMessageOverSystemChannelWhenInformedOfLowMemory() { | ||
| public void itNotifiesDartExecutorAndSendsMessageOverSystemChannelWhenInformedOfLowMemory() { | ||
| // Create the real object that we're testing. | ||
| FlutterActivityAndFragmentDelegate delegate = new FlutterActivityAndFragmentDelegate(mockHost); | ||
|
|
||
|
|
@@ -470,6 +477,7 @@ public void itSendsMessageOverSystemChannelWhenInformedOfLowMemory() { | |
| delegate.onLowMemory(); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ditto
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done |
||
|
|
||
| // Verify that the call was forwarded to the engine. | ||
| verify(mockFlutterEngine.getDartExecutor(), times(1)).notifyLowMemoryWarning(); | ||
| verify(mockFlutterEngine.getSystemChannel(), times(1)).sendMemoryPressureWarning(); | ||
| } | ||
|
|
||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: you should change the test name now
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done