Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@
import androidx.test.core.app.ApplicationProvider;
import androidx.test.ext.junit.runners.AndroidJUnit4;

import org.appdevforall.k2go.delivery.data.AnalyticsConsent;
import org.appdevforall.k2go.delivery.data.OnlineConsent;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;

Expand All @@ -29,34 +30,41 @@ private Context ctx() {
return ApplicationProvider.getApplicationContext();
}

private boolean before;

@Before
public void setUp() {
before = OnlineConsent.isEnabled(ctx());
}

@After
public void tearDown() {
AnalyticsConsent.setEnabled(ctx(), false);
OnlineConsent.setEnabled(ctx(), before);
}

@Test
public void consentDefaultsOff() {
Context ctx = ctx();
AnalyticsConsent.setEnabled(ctx, false);
assertFalse(AnalyticsConsent.isEnabled(ctx));
ctx.getSharedPreferences("iiab_delivery", Context.MODE_PRIVATE).edit().remove("online_choice").commit();
assertFalse(OnlineConsent.isEnabled(ctx));
}

@Test
public void gatedPath_doesNotThrow_whenConsentOff() {
Context ctx = ctx();
AnalyticsConsent.setEnabled(ctx, false);
OnlineConsent.setEnabled(ctx, false);
emitAll(AnalyticsClient.with(ctx));
assertFalse(AnalyticsConsent.isEnabled(ctx));
assertFalse(OnlineConsent.isEnabled(ctx));
}

@Test
public void emitPath_doesNotThrow_whenConsentOn() {
Context ctx = ctx();
AnalyticsConsent.setEnabled(ctx, true);
OnlineConsent.setEnabled(ctx, true);
AnalyticsClient client = AnalyticsClient.with(ctx);
client.applyConsent();
emitAll(client);
assertTrue(AnalyticsConsent.isEnabled(ctx));
assertTrue(OnlineConsent.isEnabled(ctx));
}

private void emitAll(AnalyticsClient client) {
Expand Down
1 change: 0 additions & 1 deletion controller/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,6 @@
android:screenOrientation="portrait"
tools:replace="screenOrientation" />

<activity android:name=".SetupActivity" />

<!-- ADFA-4725: new content-first UI shell (scoped Material 3 theme). -->
<activity
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,19 +50,15 @@ public void onCreate() {
Log.e("IIABApplication", "Error initializing Conscrypt", e);
}

// ADFA-4533: crash reporting to GlitchTip (Sentry SDK), gated by its OWN opt-in
// (CrashReportConsent, default OFF, K2GO-579) -- independent of usage-analytics consent, since error
// reports are operational, not behavioural telemetry, and carry no PII
// (io.sentry.send-default-pii=false). No-op unless a DSN was built in (empty DSN -> SDK
// stays inert); manifest sets io.sentry.auto-init=false, so this is the only init path.
// Init here (before our handler) so K2GoUncaughtExceptionHandler wraps Sentry: save -> report.
try {
if (org.appdevforall.k2go.delivery.data.CrashReportConsent.isEnabled(this)) {
io.sentry.android.core.SentryAndroid.init(this);
}
} catch (Throwable t) {
Log.e("IIABApplication", "Sentry init skipped", t);
}
// K2GO-588: no outbound request before the first app call goes out with a device-revealing
// User-Agent; every HttpURLConnection without its own agent sends this neutral one.
System.setProperty("http.agent", "K2Go");

// K2GO-588: the one privacy choice replaces the two old opt-ins; their answers are dropped
// and the user is asked again (OnlineChoiceDialog). Crash reports start here, before our
// handler, so K2GoUncaughtExceptionHandler wraps Sentry: save -> report.
org.appdevforall.k2go.delivery.data.OnlineConsent.dropOldAnswers(this);
org.appdevforall.k2go.delivery.OnlineChoiceEffects.startCrashReports(this);

// Capture uncaught exceptions into a crash report, offered on next launch.
Thread.UncaughtExceptionHandler previous = Thread.getDefaultUncaughtExceptionHandler();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,13 +148,17 @@ public static void getOrFetchCatalog(Context context, CacheListener listener) {
}
}

// K2GO-588: an automatic read with no user tap: only with the online choice on.
if (!org.appdevforall.k2go.networkpolicy.data.NetworkCostAdmission.allowsAutomatic(context)) {
new Handler(Looper.getMainLooper()).post(() -> listener.onError("offline"));
return;
}

try {
URL url = new URL(KIWIX_URL);
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
conn.setRequestProperty("User-Agent", "Mozilla/5.0");
conn.setConnectTimeout(8000);
conn.setReadTimeout(8000);

BufferedReader reader = new BufferedReader(new InputStreamReader(conn.getInputStream()));
StringBuilder html = new StringBuilder();
String line;
Expand Down

This file was deleted.

Loading
Loading