Fix process source propagation for binder calls stats settings so that

it is correctly reported in the pushed atom BinderLatencyReported.

Bug: 180584913
Test: unit test
Change-Id: Ifbdd96c73276546fb2a05213f71e1de088e1fe1e
This commit is contained in:
Siim Sammul
2021-06-22 17:11:45 +01:00
parent bd661f629e
commit f64b4c5dc9
3 changed files with 40 additions and 4 deletions

View File

@@ -1190,15 +1190,12 @@ public class BinderCallsStats implements BinderInternal.Observer {
private final Context mContext;
private final KeyValueListParser mParser = new KeyValueListParser(',');
private final BinderCallsStats mBinderCallsStats;
private final int mProcessSource;
public SettingsObserver(Context context, BinderCallsStats binderCallsStats,
int processSource) {
public SettingsObserver(Context context, BinderCallsStats binderCallsStats) {
super(BackgroundThread.getHandler());
mContext = context;
context.getContentResolver().registerContentObserver(mUri, false, this);
mBinderCallsStats = binderCallsStats;
mProcessSource = processSource;
// Always kick once to ensure that we match current state
onChange();
}

View File

@@ -370,4 +370,9 @@ public class BinderLatencyObserver {
public Runnable getStatsdPushRunnable() {
return mLatencyObserverRunnable;
}
@VisibleForTesting
public int getProcessSource() {
return mProcessSource;
}
}

View File

@@ -974,6 +974,40 @@ public class BinderCallsStatsTest {
assertEquals(true, bcs.getCollectLatencyData());
}
@Test
public void testProcessSource() {
BinderCallsStats defaultCallsStats = new BinderCallsStats(
new BinderCallsStats.Injector());
BinderCallsStats systemServerCallsStats = new BinderCallsStats(
new BinderCallsStats.Injector(),
com.android.internal.os.BinderLatencyProto.Dims.SYSTEM_SERVER);
BinderCallsStats telephonyCallsStats = new BinderCallsStats(
new BinderCallsStats.Injector(),
com.android.internal.os.BinderLatencyProto.Dims.TELEPHONY);
BinderCallsStats bluetoothCallsStats = new BinderCallsStats(
new BinderCallsStats.Injector(),
com.android.internal.os.BinderLatencyProto.Dims.BLUETOOTH);
assertEquals(
com.android.internal.os.BinderLatencyProto.Dims.SYSTEM_SERVER,
defaultCallsStats.getLatencyObserver().getProcessSource());
assertEquals(
com.android.internal.os.BinderLatencyProto.Dims.SYSTEM_SERVER,
systemServerCallsStats.getLatencyObserver().getProcessSource());
assertEquals(
com.android.internal.os.BinderLatencyProto.Dims.TELEPHONY,
telephonyCallsStats.getLatencyObserver().getProcessSource());
assertEquals(
com.android.internal.os.BinderLatencyProto.Dims.BLUETOOTH,
bluetoothCallsStats.getLatencyObserver().getProcessSource());
}
private static class TestHandler extends Handler {
ArrayList<Runnable> mRunnables = new ArrayList<>();