Fixed
Status Update
Comments
su...@google.com <su...@google.com>
su...@google.com <su...@google.com> #2
Trying to reproduce this on my 4.2.2 (v17) Nexus 4. Added this drawable:
<transition xmlns:android="http://schemas.android.com/apk/res/android " >
<item android:drawable="@drawable/test_drawable_blue"/>
<item android:drawable="@drawable/test_drawable_green"/>
</transition>
where blue/green drawables look like this:
<shape
xmlns:android="http://schemas.android.com/apk/res/android "
android:shape="rectangle">
<size
android:width="@dimen/drawable_large_size"
android:height="@dimen/drawable_small_size" />
<solid
android:color="@color/test_blue" />
</shape>
Then added this test:
@Test
public void testMutateTransitionDrawable() {
Drawable drawable = ResourcesCompat.getDrawable(mResources,
R.drawable.test_transition_drawable, null);
assertTrue(drawable instanceof TransitionDrawable);
Drawable mutated = drawable.mutate();
assertTrue(drawable instanceof TransitionDrawable);
assertTrue(mutated instanceof TransitionDrawable);
}
It passes on the device. Going to also try on other earlier devices a bit later in the day once they are charged.
<transition xmlns:android="
<item android:drawable="@drawable/test_drawable_blue"/>
<item android:drawable="@drawable/test_drawable_green"/>
</transition>
where blue/green drawables look like this:
<shape
xmlns:android="
android:shape="rectangle">
<size
android:width="@dimen/drawable_large_size"
android:height="@dimen/drawable_small_size" />
<solid
android:color="@color/test_blue" />
</shape>
Then added this test:
@Test
public void testMutateTransitionDrawable() {
Drawable drawable = ResourcesCompat.getDrawable(mResources,
R.drawable.test_transition_drawable, null);
assertTrue(drawable instanceof TransitionDrawable);
Drawable mutated = drawable.mutate();
assertTrue(drawable instanceof TransitionDrawable);
assertTrue(mutated instanceof TransitionDrawable);
}
It passes on the device. Going to also try on other earlier devices a bit later in the day once they are charged.
su...@google.com <su...@google.com> #3
Also not reproducible on Galaxy Nexus running 4.0.1 (v14), 4.0.4 (v15) and 4.2.2 (v17)
kl...@google.com <kl...@google.com> #4
su...@google.com <su...@google.com> #5
Is there any update on this?
gy...@google.com <gy...@google.com>
ap...@google.com <ap...@google.com> #6
Project: platform/frameworks/support
Branch: androidx-main
commit ccc903ffe73241ef16b77f1303469e4908b2aa96
Author: Gyumin Sim <gyumin@google.com>
Date: Tue Aug 17 21:54:37 2021
Don't start MediaSessionService as foreground for ACTION_STOP
Bug: 148011394
Relnote: Fixed ANR when dismissing media notification
Test: Manually tested with integration testapp
Change-Id: Ifdcc20bba122c235cd977a5049ce84cecc2f55b1
M media2/media2-session/src/main/java/androidx/media2/session/MediaNotificationHandler.java
https://android-review.googlesource.com/1797988
Branch: androidx-main
commit ccc903ffe73241ef16b77f1303469e4908b2aa96
Author: Gyumin Sim <gyumin@google.com>
Date: Tue Aug 17 21:54:37 2021
Don't start MediaSessionService as foreground for ACTION_STOP
Bug: 148011394
Relnote: Fixed ANR when dismissing media notification
Test: Manually tested with integration testapp
Change-Id: Ifdcc20bba122c235cd977a5049ce84cecc2f55b1
M media2/media2-session/src/main/java/androidx/media2/session/MediaNotificationHandler.java
Description
When I dismiss the default notification created by MediaNotificationHandler, I get the following ANR:
Context.startForegroundService() did not then call Service.startForeground()
As far as I can tell the problem is that notification is created with a PendingIntent#getForegroundService() for delete intent, so after I dismiss the notification the service is started again as a foreground, but since the command is ACTION_STOP, nothing happens afterwards and we get the ANR.
If I understood correctly, the ACTION_PAUSE is handled correctly, so that its pending intent will start a regular service instead of a foreground one.
MediaNotificationHandler#206
if (Build.VERSION.SDK_INT >= 26 && action != ACTION_PAUSE) {
return PendingIntent.getForegroundService(
mServiceInstance, keyCode /* requestCode */, intent, 0 /* flags */);
} else {
return PendingIntent.getService(
mServiceInstance, keyCode /* requestCode */, intent, 0 /* flags */);
}
So I guess we should do the same for ACTION_STOP.