Skip to content

Commit 445f0c9

Browse files
committed
NR-517762: feat: add toggle feature for QOE
1 parent 0a84939 commit 445f0c9

File tree

2 files changed

+71
-0
lines changed

2 files changed

+71
-0
lines changed
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
package com.newrelic.videoagent.core.config;
2+
3+
/**
4+
* Configuration manager for New Relic Video Agent functionality.
5+
* Default values are sourced from local.properties, can be overridden by client configuration.
6+
*/
7+
public class NRVideoConfig {
8+
9+
private static final NRVideoConfig INSTANCE = new NRVideoConfig();
10+
11+
// Configuration value - set from local.properties via BuildConfig
12+
private boolean qoeAggregate;
13+
private boolean initialized = false;
14+
15+
private NRVideoConfig() {
16+
}
17+
18+
/**
19+
* Get the singleton instance of NRVideoConfig
20+
* @return NRVideoConfig instance
21+
*/
22+
public static NRVideoConfig getInstance() {
23+
return INSTANCE;
24+
}
25+
26+
/**
27+
* Check if QOE_AGGREGATE events should be sent during harvest cycles
28+
* @return true if QOE_AGGREGATE should be sent, false otherwise
29+
*/
30+
public boolean isQoeAggregateEnabled() {
31+
if (!initialized) {
32+
throw new IllegalStateException("NRVideoConfig not initialized! Call initializeDefaults() first.");
33+
}
34+
return qoeAggregate;
35+
}
36+
37+
/**
38+
* Set whether QOE_AGGREGATE events should be sent during harvest cycles
39+
* This will be called with client configuration in the future
40+
* @param enabled true to enable QOE_AGGREGATE, false to disable
41+
*/
42+
public void setQoeAggregateEnabled(boolean enabled) {
43+
this.qoeAggregate = enabled;
44+
}
45+
46+
/**
47+
* Initialize configuration with default values from local.properties
48+
* This method should be called during app initialization
49+
* @param defaultQoeAggregateEnabled Default value for QOE aggregate from BuildConfig
50+
*/
51+
public void initializeDefaults(boolean defaultQoeAggregateEnabled) {
52+
if (!initialized) {
53+
this.qoeAggregate = defaultQoeAggregateEnabled;
54+
this.initialized = true;
55+
}
56+
}
57+
58+
/**
59+
* Initialize configuration with client settings
60+
* @param clientQoeAggregateEnabled QOE aggregate setting from client (null if not provided)
61+
*/
62+
public void initializeFromClient(Boolean clientQoeAggregateEnabled) {
63+
// If client provides a value, use it; otherwise keep current default
64+
if (clientQoeAggregateEnabled != null) {
65+
this.qoeAggregate = clientQoeAggregateEnabled;
66+
}
67+
}
68+
}

app/src/main/java/com/newrelic/nrvideoproject/MainActivity.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
import com.newrelic.videoagent.core.NRVideo;
1010
import com.newrelic.videoagent.core.NRVideoConfiguration;
11+
import com.newrelic.videoagent.core.config.NRVideoConfig;
1112

1213
import java.util.HashMap;
1314
import java.util.Map;
@@ -29,6 +30,8 @@ protected void onCreate(Bundle savedInstanceState) {
2930
.enableQoeAggregate(BuildConfig.QOE_AGGREGATE_DEFAULT)
3031
.build();
3132
NRVideo.newBuilder(getApplicationContext()).withConfiguration(config).build();
33+
// Initialize QOE configuration with value from local.properties
34+
NRVideoConfig.getInstance().initializeDefaults(BuildConfig.QOE_AGGREGATE_DEFAULT);
3235
setContentView(R.layout.activity_main);
3336

3437
adsSwitch = findViewById(R.id.ads_switch);

0 commit comments

Comments
 (0)