add HUN logging to view binding
Bug: 198359689 Test: HeadsUpViewBinderTest Change-Id: I54f4c4c307b7844c69dc45ad2b4fdb5bc5c2b5ad
This commit is contained in:
@@ -50,15 +50,17 @@ public class HeadsUpViewBinder {
|
||||
private final NotificationMessagingUtil mNotificationMessagingUtil;
|
||||
private final Map<NotificationEntry, CancellationSignal> mOngoingBindCallbacks =
|
||||
new ArrayMap<>();
|
||||
private final HeadsUpViewBinderLogger mLogger;
|
||||
|
||||
private NotificationPresenter mNotificationPresenter;
|
||||
|
||||
@Inject
|
||||
HeadsUpViewBinder(
|
||||
NotificationMessagingUtil notificationMessagingUtil,
|
||||
RowContentBindStage bindStage) {
|
||||
RowContentBindStage bindStage, HeadsUpViewBinderLogger logger) {
|
||||
mNotificationMessagingUtil = notificationMessagingUtil;
|
||||
mStage = bindStage;
|
||||
mLogger = logger;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -81,12 +83,14 @@ public class HeadsUpViewBinder {
|
||||
params.setUseIncreasedHeadsUpHeight(useIncreasedHeadsUp);
|
||||
params.requireContentViews(FLAG_CONTENT_VIEW_HEADS_UP);
|
||||
CancellationSignal signal = mStage.requestRebind(entry, en -> {
|
||||
mLogger.entryBoundSuccessfully(entry.getKey());
|
||||
en.getRow().setUsesIncreasedHeadsUpHeight(params.useIncreasedHeadsUpHeight());
|
||||
if (callback != null) {
|
||||
callback.onBindFinished(en);
|
||||
}
|
||||
});
|
||||
abortBindCallback(entry);
|
||||
mLogger.startBindingHun(entry.getKey());
|
||||
mOngoingBindCallbacks.put(entry, signal);
|
||||
}
|
||||
|
||||
@@ -97,6 +101,7 @@ public class HeadsUpViewBinder {
|
||||
public void abortBindCallback(NotificationEntry entry) {
|
||||
CancellationSignal ongoingBindCallback = mOngoingBindCallbacks.remove(entry);
|
||||
if (ongoingBindCallback != null) {
|
||||
mLogger.currentOngoingBindingAborted(entry.getKey());
|
||||
ongoingBindCallback.cancel();
|
||||
}
|
||||
}
|
||||
@@ -107,6 +112,7 @@ public class HeadsUpViewBinder {
|
||||
public void unbindHeadsUpView(NotificationEntry entry) {
|
||||
abortBindCallback(entry);
|
||||
mStage.getStageParams(entry).markContentViewsFreeable(FLAG_CONTENT_VIEW_HEADS_UP);
|
||||
mStage.requestRebind(entry, null);
|
||||
mLogger.entryContentViewMarkedFreeable(entry.getKey());
|
||||
mStage.requestRebind(entry, e -> mLogger.entryUnbound(e.getKey()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,49 @@
|
||||
package com.android.systemui.statusbar.notification.interruption
|
||||
|
||||
import com.android.systemui.log.LogBuffer
|
||||
import com.android.systemui.log.LogLevel.INFO
|
||||
import com.android.systemui.log.dagger.NotificationHeadsUpLog
|
||||
import javax.inject.Inject
|
||||
|
||||
class HeadsUpViewBinderLogger @Inject constructor(@NotificationHeadsUpLog val buffer: LogBuffer) {
|
||||
fun startBindingHun(key: String) {
|
||||
buffer.log(TAG, INFO, {
|
||||
str1 = key
|
||||
}, {
|
||||
"start binding heads up entry $str1 "
|
||||
})
|
||||
}
|
||||
|
||||
fun currentOngoingBindingAborted(key: String) {
|
||||
buffer.log(TAG, INFO, {
|
||||
str1 = key
|
||||
}, {
|
||||
"aborted potential ongoing heads up entry binding $str1 "
|
||||
})
|
||||
}
|
||||
|
||||
fun entryBoundSuccessfully(key: String) {
|
||||
buffer.log(TAG, INFO, {
|
||||
str1 = key
|
||||
}, {
|
||||
"heads up entry bound successfully $str1 "
|
||||
})
|
||||
}
|
||||
|
||||
fun entryUnbound(key: String) {
|
||||
buffer.log(TAG, INFO, {
|
||||
str1 = key
|
||||
}, {
|
||||
"heads up entry unbound successfully $str1 "
|
||||
})
|
||||
}
|
||||
|
||||
fun entryContentViewMarkedFreeable(key: String) {
|
||||
buffer.log(TAG, INFO, {
|
||||
str1 = key
|
||||
}, {
|
||||
"start unbinding heads up entry $str1 "
|
||||
})
|
||||
}
|
||||
}
|
||||
const val TAG = "HeadsUpViewBinder"
|
||||
@@ -0,0 +1,89 @@
|
||||
/*
|
||||
* Copyright (C) 2022 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.android.systemui.statusbar.notification.interruption;
|
||||
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.ArgumentMatchers.eq;
|
||||
import static org.mockito.Mockito.times;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import android.testing.AndroidTestingRunner;
|
||||
|
||||
import androidx.core.os.CancellationSignal;
|
||||
import androidx.test.filters.SmallTest;
|
||||
|
||||
import com.android.internal.util.NotificationMessagingUtil;
|
||||
import com.android.systemui.SysuiTestCase;
|
||||
import com.android.systemui.statusbar.notification.collection.NotificationEntry;
|
||||
import com.android.systemui.statusbar.notification.row.ExpandableNotificationRow;
|
||||
import com.android.systemui.statusbar.notification.row.NotifBindPipeline;
|
||||
import com.android.systemui.statusbar.notification.row.RowContentBindParams;
|
||||
import com.android.systemui.statusbar.notification.row.RowContentBindStage;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.MockitoAnnotations;
|
||||
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
|
||||
@RunWith(AndroidTestingRunner.class)
|
||||
@SmallTest
|
||||
public class HeadsUpViewBinderTest extends SysuiTestCase {
|
||||
private HeadsUpViewBinder mViewBinder;
|
||||
@Mock private NotificationMessagingUtil mNotificationMessagingUtil;
|
||||
@Mock private RowContentBindStage mBindStage;
|
||||
@Mock private HeadsUpViewBinderLogger mLogger;
|
||||
@Mock private NotificationEntry mEntry;
|
||||
@Mock private ExpandableNotificationRow mRow;
|
||||
|
||||
@Before
|
||||
public void setup() {
|
||||
MockitoAnnotations.initMocks(this);
|
||||
mViewBinder = new HeadsUpViewBinder(mNotificationMessagingUtil, mBindStage, mLogger);
|
||||
when(mEntry.getKey()).thenReturn("key");
|
||||
when(mEntry.getRow()).thenReturn(mRow);
|
||||
when(mBindStage.getStageParams(eq(mEntry))).thenReturn(new RowContentBindParams());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testLoggingWorks() {
|
||||
AtomicReference<NotifBindPipeline.BindCallback> callback = new AtomicReference<>();
|
||||
when(mBindStage.requestRebind(any(), any())).then(i -> {
|
||||
callback.set(i.getArgument(1));
|
||||
return new CancellationSignal();
|
||||
});
|
||||
|
||||
mViewBinder.bindHeadsUpView(mEntry, null);
|
||||
verify(mLogger, times(1)).startBindingHun(eq("key"));
|
||||
verify(mLogger, times(0)).entryBoundSuccessfully(eq("key"));
|
||||
verify(mLogger, times(0)).currentOngoingBindingAborted(eq("key"));
|
||||
|
||||
callback.get().onBindFinished(mEntry);
|
||||
|
||||
verify(mLogger, times(1)).entryBoundSuccessfully(eq("key"));
|
||||
mViewBinder.bindHeadsUpView(mEntry, null);
|
||||
|
||||
callback.get().onBindFinished(mEntry);
|
||||
|
||||
verify(mLogger, times(2)).startBindingHun(eq("key"));
|
||||
verify(mLogger, times(2)).entryBoundSuccessfully(eq("key"));
|
||||
verify(mLogger, times(1)).currentOngoingBindingAborted(eq("key"));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user