remove status bar icon logs
partial revert of Ife5ce988 Bug: 122451213 Test: runtest systemui Change-Id: I026217ea8e95ba0805b05e62a5d527c8c3a1d9ce
This commit is contained in:
@@ -40,7 +40,6 @@ import android.util.TypedValue;
|
||||
import android.view.ContextThemeWrapper;
|
||||
import android.view.Gravity;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
@@ -56,7 +55,6 @@ import com.android.systemui.statusbar.policy.BatteryController;
|
||||
import com.android.systemui.statusbar.policy.BatteryController.BatteryStateChangeCallback;
|
||||
import com.android.systemui.statusbar.policy.ConfigurationController;
|
||||
import com.android.systemui.statusbar.policy.ConfigurationController.ConfigurationListener;
|
||||
import com.android.systemui.statusbar.policy.IconLogger;
|
||||
import com.android.systemui.tuner.TunerService;
|
||||
import com.android.systemui.tuner.TunerService.Tunable;
|
||||
import com.android.systemui.util.Utils.DisableStateTracker;
|
||||
@@ -276,9 +274,6 @@ public class BatteryMeterView extends LinearLayout implements
|
||||
public void onTuningChanged(String key, String newValue) {
|
||||
if (StatusBarIconController.ICON_BLACKLIST.equals(key)) {
|
||||
ArraySet<String> icons = StatusBarIconController.getIconBlacklist(newValue);
|
||||
boolean hidden = icons.contains(mSlotBattery);
|
||||
Dependency.get(IconLogger.class).onIconVisibility(mSlotBattery, !hidden);
|
||||
setVisibility(hidden ? View.GONE : View.VISIBLE);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -86,7 +86,6 @@ import com.android.systemui.statusbar.policy.DeviceProvisionedController;
|
||||
import com.android.systemui.statusbar.policy.ExtensionController;
|
||||
import com.android.systemui.statusbar.policy.FlashlightController;
|
||||
import com.android.systemui.statusbar.policy.HotspotController;
|
||||
import com.android.systemui.statusbar.policy.IconLogger;
|
||||
import com.android.systemui.statusbar.policy.KeyguardMonitor;
|
||||
import com.android.systemui.statusbar.policy.LocationController;
|
||||
import com.android.systemui.statusbar.policy.NetworkController;
|
||||
@@ -217,7 +216,6 @@ public class Dependency extends SystemUI {
|
||||
@Inject Lazy<LeakDetector> mLeakDetector;
|
||||
@Inject Lazy<LeakReporter> mLeakReporter;
|
||||
@Inject Lazy<GarbageMonitor> mGarbageMonitor;
|
||||
@Inject Lazy<IconLogger> mIconLogger;
|
||||
@Inject Lazy<TunerService> mTunerService;
|
||||
@Inject Lazy<StatusBarWindowController> mStatusBarWindowController;
|
||||
@Inject Lazy<DarkIconDispatcher> mDarkIconDispatcher;
|
||||
@@ -392,8 +390,6 @@ public class Dependency extends SystemUI {
|
||||
|
||||
mProviders.put(PowerUI.WarningsUI.class, mWarningsUI::get);
|
||||
|
||||
mProviders.put(IconLogger.class, mIconLogger::get);
|
||||
|
||||
mProviders.put(LightBarController.class, mLightBarController::get);
|
||||
|
||||
mProviders.put(IWindowManager.class, mIWindowManager::get);
|
||||
|
||||
@@ -46,8 +46,6 @@ import com.android.systemui.statusbar.policy.FlashlightController;
|
||||
import com.android.systemui.statusbar.policy.FlashlightControllerImpl;
|
||||
import com.android.systemui.statusbar.policy.HotspotController;
|
||||
import com.android.systemui.statusbar.policy.HotspotControllerImpl;
|
||||
import com.android.systemui.statusbar.policy.IconLogger;
|
||||
import com.android.systemui.statusbar.policy.IconLoggerImpl;
|
||||
import com.android.systemui.statusbar.policy.KeyguardMonitor;
|
||||
import com.android.systemui.statusbar.policy.KeyguardMonitorImpl;
|
||||
import com.android.systemui.statusbar.policy.LocationController;
|
||||
@@ -130,11 +128,6 @@ public abstract class DependencyBinder {
|
||||
public abstract NotificationRemoteInputManager.Callback provideNotificationRemoteInputManager(
|
||||
StatusBarRemoteInputCallback callbackImpl);
|
||||
|
||||
/**
|
||||
*/
|
||||
@Binds
|
||||
public abstract IconLogger provideIconLogger(IconLoggerImpl loggerImpl);
|
||||
|
||||
/**
|
||||
*/
|
||||
@Binds
|
||||
|
||||
@@ -36,7 +36,6 @@ import com.android.systemui.statusbar.phone.StatusBarSignalPolicy.MobileIconStat
|
||||
import com.android.systemui.statusbar.phone.StatusBarSignalPolicy.WifiIconState;
|
||||
import com.android.systemui.statusbar.policy.ConfigurationController;
|
||||
import com.android.systemui.statusbar.policy.ConfigurationController.ConfigurationListener;
|
||||
import com.android.systemui.statusbar.policy.IconLogger;
|
||||
import com.android.systemui.tuner.TunerService;
|
||||
import com.android.systemui.tuner.TunerService.Tunable;
|
||||
|
||||
@@ -61,7 +60,6 @@ public class StatusBarIconControllerImpl extends StatusBarIconList implements Tu
|
||||
|
||||
private final ArrayList<IconManager> mIconGroups = new ArrayList<>();
|
||||
private final ArraySet<String> mIconBlacklist = new ArraySet<>();
|
||||
private final IconLogger mIconLogger = Dependency.get(IconLogger.class);
|
||||
|
||||
// Points to light or dark context depending on the... context?
|
||||
private Context mContext;
|
||||
@@ -147,7 +145,6 @@ public class StatusBarIconControllerImpl extends StatusBarIconList implements Tu
|
||||
int viewIndex = getViewIndex(index, holder.getTag());
|
||||
boolean blocked = mIconBlacklist.contains(slot);
|
||||
|
||||
mIconLogger.onIconVisibility(getSlotName(index), holder.isVisible());
|
||||
mIconGroups.forEach(l -> l.onIconAdded(viewIndex, slot, blocked, holder));
|
||||
}
|
||||
|
||||
@@ -281,8 +278,6 @@ public class StatusBarIconControllerImpl extends StatusBarIconList implements Tu
|
||||
return;
|
||||
}
|
||||
|
||||
mIconLogger.onIconHidden(slotName);
|
||||
|
||||
int slotIndex = getSlotIndex(slotName);
|
||||
List<StatusBarIconHolder> iconsToRemove = slot.getHolderListInViewOrder();
|
||||
for (StatusBarIconHolder holder : iconsToRemove) {
|
||||
@@ -297,7 +292,6 @@ public class StatusBarIconControllerImpl extends StatusBarIconList implements Tu
|
||||
if (getIcon(index, tag) == null) {
|
||||
return;
|
||||
}
|
||||
mIconLogger.onIconHidden(getSlotName(index));
|
||||
super.removeIcon(index, tag);
|
||||
int viewIndex = getViewIndex(index, 0);
|
||||
mIconGroups.forEach(l -> l.onRemoveIcon(viewIndex));
|
||||
@@ -305,7 +299,6 @@ public class StatusBarIconControllerImpl extends StatusBarIconList implements Tu
|
||||
|
||||
private void handleSet(int index, StatusBarIconHolder holder) {
|
||||
int viewIndex = getViewIndex(index, holder.getTag());
|
||||
mIconLogger.onIconVisibility(getSlotName(index), holder.isVisible());
|
||||
mIconGroups.forEach(l -> l.onSetIconHolder(viewIndex, holder));
|
||||
}
|
||||
|
||||
|
||||
@@ -274,7 +274,6 @@ public class Clock extends TextView implements DemoMode, Tunable, CommandQueue.C
|
||||
|
||||
private void updateClockVisibility() {
|
||||
boolean visible = shouldBeVisible();
|
||||
Dependency.get(IconLogger.class).onIconVisibility("clock", visible);
|
||||
int visibility = visible ? View.VISIBLE : View.GONE;
|
||||
super.setVisibility(visibility);
|
||||
}
|
||||
|
||||
@@ -1,29 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2017 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.policy;
|
||||
|
||||
public interface IconLogger {
|
||||
|
||||
void onIconShown(String tag);
|
||||
void onIconHidden(String tag);
|
||||
|
||||
default void onIconVisibility(String tag, boolean visible) {
|
||||
if (visible) {
|
||||
onIconShown(tag);
|
||||
} else {
|
||||
onIconHidden(tag);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,115 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2017 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.policy;
|
||||
|
||||
import static com.android.internal.logging.nano.MetricsProto.MetricsEvent.FIELD_NUM_STATUS_ICONS;
|
||||
import static com.android.internal.logging.nano.MetricsProto.MetricsEvent.FIELD_STATUS_ICONS;
|
||||
import static com.android.internal.logging.nano.MetricsProto.MetricsEvent.STATUS_BAR_ICONS_CHANGED;
|
||||
import static com.android.internal.logging.nano.MetricsProto.MetricsEvent.TYPE_ACTION;
|
||||
import static com.android.systemui.Dependency.BG_LOOPER_NAME;
|
||||
|
||||
import android.content.Context;
|
||||
import android.metrics.LogMaker;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import android.util.ArraySet;
|
||||
|
||||
import androidx.annotation.VisibleForTesting;
|
||||
|
||||
import com.android.internal.logging.MetricsLogger;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Named;
|
||||
|
||||
public class IconLoggerImpl implements IconLogger {
|
||||
|
||||
// Minimum ms between log statements.
|
||||
// NonFinalForTesting
|
||||
@VisibleForTesting
|
||||
protected static long MIN_LOG_INTERVAL = 1000;
|
||||
|
||||
private final Context mContext;
|
||||
private final Handler mHandler;
|
||||
private final MetricsLogger mLogger;
|
||||
private final ArraySet<String> mIcons = new ArraySet<>();
|
||||
private final List<String> mIconIndex;
|
||||
private long mLastLog = System.currentTimeMillis();
|
||||
|
||||
@Inject
|
||||
public IconLoggerImpl(Context context, @Named(BG_LOOPER_NAME) Looper bgLooper,
|
||||
MetricsLogger logger) {
|
||||
mContext = context;
|
||||
mHandler = new Handler(bgLooper);
|
||||
mLogger = logger;
|
||||
String[] icons = mContext.getResources().getStringArray(
|
||||
com.android.internal.R.array.config_statusBarIcons);
|
||||
mIconIndex = Arrays.asList(icons);
|
||||
doLog();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onIconShown(String tag) {
|
||||
synchronized (mIcons) {
|
||||
if (mIcons.contains(tag)) return;
|
||||
mIcons.add(tag);
|
||||
}
|
||||
if (!mHandler.hasCallbacks(mLog)) {
|
||||
mHandler.postDelayed(mLog, MIN_LOG_INTERVAL);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onIconHidden(String tag) {
|
||||
synchronized (mIcons) {
|
||||
if (!mIcons.contains(tag)) return;
|
||||
mIcons.remove(tag);
|
||||
}
|
||||
if (!mHandler.hasCallbacks(mLog)) {
|
||||
mHandler.postDelayed(mLog, MIN_LOG_INTERVAL);
|
||||
}
|
||||
}
|
||||
|
||||
private void doLog() {
|
||||
long time = System.currentTimeMillis();
|
||||
long timeSinceLastLog = time - mLastLog;
|
||||
mLastLog = time;
|
||||
|
||||
ArraySet<String> icons;
|
||||
synchronized (mIcons) {
|
||||
icons = new ArraySet<>(mIcons);
|
||||
}
|
||||
mLogger.write(new LogMaker(STATUS_BAR_ICONS_CHANGED)
|
||||
.setType(TYPE_ACTION)
|
||||
.setLatency(timeSinceLastLog)
|
||||
.addTaggedData(FIELD_NUM_STATUS_ICONS, icons.size())
|
||||
.addTaggedData(FIELD_STATUS_ICONS, getBitField(icons)));
|
||||
}
|
||||
|
||||
private int getBitField(ArraySet<String> icons) {
|
||||
int iconsVisible = 0;
|
||||
for (String icon : icons) {
|
||||
int index = mIconIndex.indexOf(icon);
|
||||
if (index >= 0) {
|
||||
iconsVisible |= (1 << index);
|
||||
}
|
||||
}
|
||||
return iconsVisible;
|
||||
}
|
||||
|
||||
private final Runnable mLog = this::doLog;
|
||||
}
|
||||
@@ -1,177 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2017 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.policy;
|
||||
|
||||
import static com.android.internal.logging.nano.MetricsProto.MetricsEvent.FIELD_NUM_STATUS_ICONS;
|
||||
import static com.android.internal.logging.nano.MetricsProto.MetricsEvent.FIELD_STATUS_ICONS;
|
||||
import static com.android.internal.logging.nano.MetricsProto.MetricsEvent
|
||||
.RESERVED_FOR_LOGBUILDER_LATENCY_MILLIS;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.ArgumentMatchers.argThat;
|
||||
import static org.mockito.Mockito.clearInvocations;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.never;
|
||||
import static org.mockito.Mockito.times;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import static java.lang.Thread.sleep;
|
||||
|
||||
import android.metrics.LogMaker;
|
||||
import android.support.test.filters.SmallTest;
|
||||
import android.testing.AndroidTestingRunner;
|
||||
import android.testing.TestableLooper;
|
||||
import android.testing.TestableLooper.MessageHandler;
|
||||
import android.testing.TestableLooper.RunWithLooper;
|
||||
import android.util.Log;
|
||||
|
||||
import com.android.internal.logging.MetricsLogger;
|
||||
import com.android.systemui.SysuiTestCase;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.ArgumentMatcher;
|
||||
|
||||
@RunWith(AndroidTestingRunner.class)
|
||||
@RunWithLooper
|
||||
@SmallTest
|
||||
public class IconLoggerImplTest extends SysuiTestCase {
|
||||
|
||||
private MetricsLogger mMetricsLogger;
|
||||
private IconLoggerImpl mIconLogger;
|
||||
private TestableLooper mTestableLooper;
|
||||
private MessageHandler mMessageHandler;
|
||||
|
||||
@Before
|
||||
public void setup() {
|
||||
IconLoggerImpl.MIN_LOG_INTERVAL = 5; // Low interval for testing
|
||||
mMetricsLogger = mock(MetricsLogger.class);
|
||||
mTestableLooper = TestableLooper.get(this);
|
||||
mMessageHandler = mock(MessageHandler.class);
|
||||
mTestableLooper.setMessageHandler(mMessageHandler);
|
||||
String[] iconArray = new String[] {
|
||||
"test_icon_1",
|
||||
"test_icon_2",
|
||||
};
|
||||
mContext.getOrCreateTestableResources().addOverride(
|
||||
com.android.internal.R.array.config_statusBarIcons, iconArray);
|
||||
mIconLogger = new IconLoggerImpl(mContext, mTestableLooper.getLooper(), mMetricsLogger);
|
||||
when(mMessageHandler.onMessageHandled(any())).thenReturn(true);
|
||||
clearInvocations(mMetricsLogger);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIconShown() throws InterruptedException {
|
||||
// Should only get one message, for the same icon shown twice.
|
||||
mIconLogger.onIconShown("test_icon_2");
|
||||
mIconLogger.onIconShown("test_icon_2");
|
||||
|
||||
// There should be some delay before execute.
|
||||
mTestableLooper.processAllMessages();
|
||||
verify(mMessageHandler, never()).onMessageHandled(any());
|
||||
|
||||
sleep(10);
|
||||
mTestableLooper.processAllMessages();
|
||||
verify(mMessageHandler, times(1)).onMessageHandled(any());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIconHidden() throws InterruptedException {
|
||||
// Add the icon so that it can be removed.
|
||||
mIconLogger.onIconShown("test_icon_2");
|
||||
sleep(10);
|
||||
mTestableLooper.processAllMessages();
|
||||
clearInvocations(mMessageHandler);
|
||||
|
||||
// Should only get one message, for the same icon shown twice.
|
||||
mIconLogger.onIconHidden("test_icon_2");
|
||||
mIconLogger.onIconHidden("test_icon_2");
|
||||
|
||||
// There should be some delay before execute.
|
||||
mTestableLooper.processAllMessages();
|
||||
verify(mMessageHandler, never()).onMessageHandled(any());
|
||||
|
||||
sleep(10);
|
||||
mTestableLooper.processAllMessages();
|
||||
verify(mMessageHandler, times(1)).onMessageHandled(any());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testLog() throws InterruptedException {
|
||||
mIconLogger.onIconShown("test_icon_2");
|
||||
sleep(10);
|
||||
mTestableLooper.processAllMessages();
|
||||
|
||||
verify(mMetricsLogger).write(argThat(maker -> {
|
||||
if (IconLoggerImpl.MIN_LOG_INTERVAL >
|
||||
(long) maker.getTaggedData(RESERVED_FOR_LOGBUILDER_LATENCY_MILLIS)) {
|
||||
Log.e("IconLoggerImplTest", "Invalid latency "
|
||||
+ maker.getTaggedData(RESERVED_FOR_LOGBUILDER_LATENCY_MILLIS));
|
||||
return false;
|
||||
}
|
||||
if (1 != (int) maker.getTaggedData(FIELD_NUM_STATUS_ICONS)) {
|
||||
Log.e("IconLoggerImplTest", "Invalid icon count "
|
||||
+ maker.getTaggedData(FIELD_NUM_STATUS_ICONS));
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBitField() throws InterruptedException {
|
||||
mIconLogger.onIconShown("test_icon_2");
|
||||
sleep(10);
|
||||
mTestableLooper.processAllMessages();
|
||||
|
||||
verify(mMetricsLogger).write(argThat(maker -> {
|
||||
if ((1 << 1) != (int) maker.getTaggedData(FIELD_STATUS_ICONS)) {
|
||||
Log.e("IconLoggerImplTest", "Invalid bitfield " + Integer.toHexString(
|
||||
(Integer) maker.getTaggedData(FIELD_NUM_STATUS_ICONS)));
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}));
|
||||
|
||||
mIconLogger.onIconShown("test_icon_1");
|
||||
sleep(10);
|
||||
mTestableLooper.processAllMessages();
|
||||
|
||||
verify(mMetricsLogger).write(argThat(maker -> {
|
||||
if ((1 << 1 | 1 << 0) != (int) maker.getTaggedData(FIELD_STATUS_ICONS)) {
|
||||
Log.e("IconLoggerImplTest", "Invalid bitfield " + Integer.toHexString(
|
||||
(Integer) maker.getTaggedData(FIELD_NUM_STATUS_ICONS)));
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}));
|
||||
|
||||
mIconLogger.onIconHidden("test_icon_2");
|
||||
sleep(10);
|
||||
mTestableLooper.processAllMessages();
|
||||
|
||||
verify(mMetricsLogger).write(argThat(maker -> {
|
||||
if ((1 << 0) != (int) maker.getTaggedData(FIELD_STATUS_ICONS)) {
|
||||
Log.e("IconLoggerImplTest", "Invalid bitfield " + Integer.toHexString(
|
||||
(Integer) maker.getTaggedData(FIELD_STATUS_ICONS)));
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user