Loading core/java/com/android/internal/os/BinderDeathDispatcher.java +1 −5 Original line number Diff line number Diff line Loading @@ -63,10 +63,6 @@ public class BinderDeathDispatcher<T extends IInterface> { @Override public void binderDied() { } @Override public void binderDied(IBinder who) { final ArraySet<DeathRecipient> copy; synchronized (mLock) { copy = mRecipients; Loading @@ -81,7 +77,7 @@ public class BinderDeathDispatcher<T extends IInterface> { // Let's call it without holding the lock. final int size = copy.size(); for (int i = 0; i < size; i++) { copy.valueAt(i).binderDied(who); copy.valueAt(i).binderDied(); } } } Loading core/java/com/android/internal/os/TEST_MAPPING +0 −10 Original line number Diff line number Diff line { "presubmit": [ { "file_patterns": [ "BinderDeathDispatcher\\.java" ], "name": "FrameworksCoreTests", "options": [ { "include-filter": "com.android.internal.os.BinderDeathDispatcherTest" }, { "exclude-annotation": "com.android.internal.os.SkipPresubmit" } ] }, { "name": "FrameworksCoreTests", "options": [ Loading core/tests/coretests/src/com/android/internal/os/BinderDeathDispatcherTest.java +19 −43 Original line number Diff line number Diff line Loading @@ -17,7 +17,6 @@ package com.android.internal.os; import static com.google.common.truth.Truth.assertThat; import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.reset; import static org.mockito.Mockito.times; Loading @@ -32,14 +31,14 @@ import android.os.RemoteException; import android.os.ResultReceiver; import android.os.ShellCallback; import androidx.test.filters.SmallTest; import androidx.test.runner.AndroidJUnit4; import org.junit.Test; import org.junit.runner.RunWith; import java.io.FileDescriptor; import androidx.test.filters.SmallTest; import androidx.test.runner.AndroidJUnit4; @SmallTest @RunWith(AndroidJUnit4.class) public class BinderDeathDispatcherTest { Loading Loading @@ -121,7 +120,7 @@ public class BinderDeathDispatcherTest { public void die() { isAlive = false; if (mRecipient != null) { mRecipient.binderDied(this); mRecipient.binderDied(); } mRecipient = null; } Loading Loading @@ -228,33 +227,33 @@ public class BinderDeathDispatcherTest { // Kill the targets. t1.die(); verify(r1, times(1)).binderDied(t1); verify(r2, times(1)).binderDied(t1); verify(r3, times(1)).binderDied(t1); verify(r4, times(0)).binderDied(any()); verify(r5, times(0)).binderDied(any()); verify(r1, times(1)).binderDied(); verify(r2, times(1)).binderDied(); verify(r3, times(1)).binderDied(); verify(r4, times(0)).binderDied(); verify(r5, times(0)).binderDied(); assertThat(d.getTargetsForTest().size()).isEqualTo(2); reset(r1, r2, r3, r4, r5); t2.die(); verify(r1, times(1)).binderDied(t2); verify(r2, times(0)).binderDied(any()); verify(r3, times(0)).binderDied(any()); verify(r4, times(0)).binderDied(any()); verify(r5, times(0)).binderDied(any()); verify(r1, times(1)).binderDied(); verify(r2, times(0)).binderDied(); verify(r3, times(0)).binderDied(); verify(r4, times(0)).binderDied(); verify(r5, times(0)).binderDied(); assertThat(d.getTargetsForTest().size()).isEqualTo(1); reset(r1, r2, r3, r4, r5); t3.die(); verify(r1, times(0)).binderDied(any()); verify(r2, times(0)).binderDied(any()); verify(r3, times(1)).binderDied(t3); verify(r4, times(0)).binderDied(any()); verify(r5, times(1)).binderDied(t3); verify(r1, times(0)).binderDied(); verify(r2, times(0)).binderDied(); verify(r3, times(1)).binderDied(); verify(r4, times(0)).binderDied(); verify(r5, times(1)).binderDied(); assertThat(d.getTargetsForTest().size()).isEqualTo(0); Loading @@ -263,27 +262,4 @@ public class BinderDeathDispatcherTest { assertThat(d.getTargetsForTest().size()).isEqualTo(0); } @Test public void duplicateRegistrations() { BinderDeathDispatcher<MyTarget> d = new BinderDeathDispatcher<>(); MyTarget t1 = new MyTarget(); DeathRecipient r1 = mock(DeathRecipient.class); DeathRecipient r2 = mock(DeathRecipient.class); for (int i = 0; i < 5; i++) { assertThat(d.linkToDeath(t1, r1)).isEqualTo(1); } assertThat(d.linkToDeath(t1, r2)).isEqualTo(2); t1.die(); verify(r1, times(1)).binderDied(t1); verify(r2, times(1)).binderDied(t1); d.unlinkToDeath(t1, r1); d.unlinkToDeath(t1, r2); assertThat(d.getTargetsForTest()).isEmpty(); } } services/core/java/com/android/server/AlarmManagerService.java +3 −9 Original line number Diff line number Diff line Loading @@ -91,7 +91,6 @@ import android.util.proto.ProtoOutputStream; import com.android.internal.annotations.GuardedBy; import com.android.internal.annotations.VisibleForTesting; import com.android.internal.os.BinderDeathDispatcher; import com.android.internal.util.ArrayUtils; import com.android.internal.util.DumpUtils; import com.android.internal.util.FrameworkStatsLog; Loading Loading @@ -177,8 +176,6 @@ class AlarmManagerService extends SystemService { .addFlags(Intent.FLAG_RECEIVER_REPLACE_PENDING | Intent.FLAG_RECEIVER_INCLUDE_BACKGROUND); private static final BinderDeathDispatcher<IAlarmListener> sListenerDeathDispatcher = new BinderDeathDispatcher<>(); final LocalLog mLog = new LocalLog(TAG); AppOpsManager mAppOps; Loading Loading @@ -1704,8 +1701,9 @@ class AlarmManagerService extends SystemService { } if (directReceiver != null) { if (sListenerDeathDispatcher.linkToDeath(directReceiver, mListenerDeathRecipient) <= 0) { try { directReceiver.asBinder().linkToDeath(mListenerDeathRecipient, 0); } catch (RemoteException e) { Slog.w(TAG, "Dropping unreachable alarm listener " + listenerTag); return; } Loading Loading @@ -2466,10 +2464,6 @@ class AlarmManagerService extends SystemService { pw.println("]"); pw.println(); pw.println("Listener death dispatcher state:"); sListenerDeathDispatcher.dump(pw, " "); pw.println(); if (mLog.dump(pw, " Recent problems", " ")) { pw.println(); } Loading Loading
core/java/com/android/internal/os/BinderDeathDispatcher.java +1 −5 Original line number Diff line number Diff line Loading @@ -63,10 +63,6 @@ public class BinderDeathDispatcher<T extends IInterface> { @Override public void binderDied() { } @Override public void binderDied(IBinder who) { final ArraySet<DeathRecipient> copy; synchronized (mLock) { copy = mRecipients; Loading @@ -81,7 +77,7 @@ public class BinderDeathDispatcher<T extends IInterface> { // Let's call it without holding the lock. final int size = copy.size(); for (int i = 0; i < size; i++) { copy.valueAt(i).binderDied(who); copy.valueAt(i).binderDied(); } } } Loading
core/java/com/android/internal/os/TEST_MAPPING +0 −10 Original line number Diff line number Diff line { "presubmit": [ { "file_patterns": [ "BinderDeathDispatcher\\.java" ], "name": "FrameworksCoreTests", "options": [ { "include-filter": "com.android.internal.os.BinderDeathDispatcherTest" }, { "exclude-annotation": "com.android.internal.os.SkipPresubmit" } ] }, { "name": "FrameworksCoreTests", "options": [ Loading
core/tests/coretests/src/com/android/internal/os/BinderDeathDispatcherTest.java +19 −43 Original line number Diff line number Diff line Loading @@ -17,7 +17,6 @@ package com.android.internal.os; import static com.google.common.truth.Truth.assertThat; import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.reset; import static org.mockito.Mockito.times; Loading @@ -32,14 +31,14 @@ import android.os.RemoteException; import android.os.ResultReceiver; import android.os.ShellCallback; import androidx.test.filters.SmallTest; import androidx.test.runner.AndroidJUnit4; import org.junit.Test; import org.junit.runner.RunWith; import java.io.FileDescriptor; import androidx.test.filters.SmallTest; import androidx.test.runner.AndroidJUnit4; @SmallTest @RunWith(AndroidJUnit4.class) public class BinderDeathDispatcherTest { Loading Loading @@ -121,7 +120,7 @@ public class BinderDeathDispatcherTest { public void die() { isAlive = false; if (mRecipient != null) { mRecipient.binderDied(this); mRecipient.binderDied(); } mRecipient = null; } Loading Loading @@ -228,33 +227,33 @@ public class BinderDeathDispatcherTest { // Kill the targets. t1.die(); verify(r1, times(1)).binderDied(t1); verify(r2, times(1)).binderDied(t1); verify(r3, times(1)).binderDied(t1); verify(r4, times(0)).binderDied(any()); verify(r5, times(0)).binderDied(any()); verify(r1, times(1)).binderDied(); verify(r2, times(1)).binderDied(); verify(r3, times(1)).binderDied(); verify(r4, times(0)).binderDied(); verify(r5, times(0)).binderDied(); assertThat(d.getTargetsForTest().size()).isEqualTo(2); reset(r1, r2, r3, r4, r5); t2.die(); verify(r1, times(1)).binderDied(t2); verify(r2, times(0)).binderDied(any()); verify(r3, times(0)).binderDied(any()); verify(r4, times(0)).binderDied(any()); verify(r5, times(0)).binderDied(any()); verify(r1, times(1)).binderDied(); verify(r2, times(0)).binderDied(); verify(r3, times(0)).binderDied(); verify(r4, times(0)).binderDied(); verify(r5, times(0)).binderDied(); assertThat(d.getTargetsForTest().size()).isEqualTo(1); reset(r1, r2, r3, r4, r5); t3.die(); verify(r1, times(0)).binderDied(any()); verify(r2, times(0)).binderDied(any()); verify(r3, times(1)).binderDied(t3); verify(r4, times(0)).binderDied(any()); verify(r5, times(1)).binderDied(t3); verify(r1, times(0)).binderDied(); verify(r2, times(0)).binderDied(); verify(r3, times(1)).binderDied(); verify(r4, times(0)).binderDied(); verify(r5, times(1)).binderDied(); assertThat(d.getTargetsForTest().size()).isEqualTo(0); Loading @@ -263,27 +262,4 @@ public class BinderDeathDispatcherTest { assertThat(d.getTargetsForTest().size()).isEqualTo(0); } @Test public void duplicateRegistrations() { BinderDeathDispatcher<MyTarget> d = new BinderDeathDispatcher<>(); MyTarget t1 = new MyTarget(); DeathRecipient r1 = mock(DeathRecipient.class); DeathRecipient r2 = mock(DeathRecipient.class); for (int i = 0; i < 5; i++) { assertThat(d.linkToDeath(t1, r1)).isEqualTo(1); } assertThat(d.linkToDeath(t1, r2)).isEqualTo(2); t1.die(); verify(r1, times(1)).binderDied(t1); verify(r2, times(1)).binderDied(t1); d.unlinkToDeath(t1, r1); d.unlinkToDeath(t1, r2); assertThat(d.getTargetsForTest()).isEmpty(); } }
services/core/java/com/android/server/AlarmManagerService.java +3 −9 Original line number Diff line number Diff line Loading @@ -91,7 +91,6 @@ import android.util.proto.ProtoOutputStream; import com.android.internal.annotations.GuardedBy; import com.android.internal.annotations.VisibleForTesting; import com.android.internal.os.BinderDeathDispatcher; import com.android.internal.util.ArrayUtils; import com.android.internal.util.DumpUtils; import com.android.internal.util.FrameworkStatsLog; Loading Loading @@ -177,8 +176,6 @@ class AlarmManagerService extends SystemService { .addFlags(Intent.FLAG_RECEIVER_REPLACE_PENDING | Intent.FLAG_RECEIVER_INCLUDE_BACKGROUND); private static final BinderDeathDispatcher<IAlarmListener> sListenerDeathDispatcher = new BinderDeathDispatcher<>(); final LocalLog mLog = new LocalLog(TAG); AppOpsManager mAppOps; Loading Loading @@ -1704,8 +1701,9 @@ class AlarmManagerService extends SystemService { } if (directReceiver != null) { if (sListenerDeathDispatcher.linkToDeath(directReceiver, mListenerDeathRecipient) <= 0) { try { directReceiver.asBinder().linkToDeath(mListenerDeathRecipient, 0); } catch (RemoteException e) { Slog.w(TAG, "Dropping unreachable alarm listener " + listenerTag); return; } Loading Loading @@ -2466,10 +2464,6 @@ class AlarmManagerService extends SystemService { pw.println("]"); pw.println(); pw.println("Listener death dispatcher state:"); sListenerDeathDispatcher.dump(pw, " "); pw.println(); if (mLog.dump(pw, " Recent problems", " ")) { pw.println(); } Loading