Merge "Avoid sending messages of destroyed Engine" into udc-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
359c0a200f
@@ -868,6 +868,11 @@ public abstract class WallpaperService extends Service {
|
|||||||
* This will trigger a {@link #onComputeColors()} call.
|
* This will trigger a {@link #onComputeColors()} call.
|
||||||
*/
|
*/
|
||||||
public void notifyColorsChanged() {
|
public void notifyColorsChanged() {
|
||||||
|
if (mDestroyed) {
|
||||||
|
Log.i(TAG, "Ignoring notifyColorsChanged(), Engine has already been destroyed.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
final long now = mClockFunction.get();
|
final long now = mClockFunction.get();
|
||||||
if (now - mLastColorInvalidation < NOTIFY_COLORS_RATE_LIMIT_MS) {
|
if (now - mLastColorInvalidation < NOTIFY_COLORS_RATE_LIMIT_MS) {
|
||||||
Log.w(TAG, "This call has been deferred. You should only call "
|
Log.w(TAG, "This call has been deferred. You should only call "
|
||||||
@@ -2226,7 +2231,11 @@ public abstract class WallpaperService extends Service {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void detach() {
|
/**
|
||||||
|
* @hide
|
||||||
|
*/
|
||||||
|
@VisibleForTesting
|
||||||
|
public void detach() {
|
||||||
if (mDestroyed) {
|
if (mDestroyed) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -2442,6 +2451,14 @@ public abstract class WallpaperService extends Service {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void reportShown() {
|
public void reportShown() {
|
||||||
|
if (mEngine == null) {
|
||||||
|
Log.i(TAG, "Can't report null engine as shown.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (mEngine.mDestroyed) {
|
||||||
|
Log.i(TAG, "Engine was destroyed before we could draw.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (!mShownReported) {
|
if (!mShownReported) {
|
||||||
mShownReported = true;
|
mShownReported = true;
|
||||||
Trace.beginSection("WPMS.mConnection.engineShown");
|
Trace.beginSection("WPMS.mConnection.engineShown");
|
||||||
|
|||||||
4
tests/Internal/src/android/service/wallpaper/OWNERS
Normal file
4
tests/Internal/src/android/service/wallpaper/OWNERS
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
dupin@google.com
|
||||||
|
santie@google.com
|
||||||
|
pomini@google.com
|
||||||
|
poultney@google.com
|
||||||
@@ -85,4 +85,17 @@ public class WallpaperServiceTest {
|
|||||||
assertEquals("onAmbientModeChanged should have been called", 2, zoomChangedCount[0]);
|
assertEquals("onAmbientModeChanged should have been called", 2, zoomChangedCount[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testNotifyColorsOfDestroyedEngine_doesntCrash() {
|
||||||
|
WallpaperService service = new WallpaperService() {
|
||||||
|
@Override
|
||||||
|
public Engine onCreateEngine() {
|
||||||
|
return new Engine();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
WallpaperService.Engine engine = service.onCreateEngine();
|
||||||
|
engine.detach();
|
||||||
|
|
||||||
|
engine.notifyColorsChanged();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user