diff options
| author | Lena <lena@omega> | 2026-08-01 00:00:00 +0000 |
|---|---|---|
| committer | Lena <lena@omega> | 2026-08-01 00:00:00 +0000 |
| commit | 852a8a00273c9128efeed0217a8e5d3fcd8bf780 (patch) | |
| tree | c72f959731fa3c7c809cf1a0222363b6c9c9b03b /app/src/main/java/invalid/lena/scrcpy/Licenses.java | |
| parent | f379b93d52bf0dbd3816ec3f64d165314771d2a6 (diff) | |
| download | scrcpy-android-852a8a00273c9128efeed0217a8e5d3fcd8bf780.tar.gz | |
app: harden mirroring lifecycle and state
Diffstat (limited to 'app/src/main/java/invalid/lena/scrcpy/Licenses.java')
| -rw-r--r-- | app/src/main/java/invalid/lena/scrcpy/Licenses.java | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/app/src/main/java/invalid/lena/scrcpy/Licenses.java b/app/src/main/java/invalid/lena/scrcpy/Licenses.java new file mode 100644 index 0000000..8e66912 --- /dev/null +++ b/app/src/main/java/invalid/lena/scrcpy/Licenses.java @@ -0,0 +1,48 @@ +package invalid.lena.scrcpy; + +import android.app.Activity; +import android.os.Bundle; +import android.view.WindowInsets; +import android.widget.TextView; + +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.nio.charset.StandardCharsets; + +// Shows the bundled third-party notices. +// +// This is a legal requirement, not a courtesy. The APK links +// libspake2.so, which is LGPL-3.0: section 4 lets an LGPL library be +// combined into a differently-licensed work only if the combined work +// gives prominent notice that the library is used and is covered by the +// LGPL, and points at the source needed to relink it. Shipping that text +// as an asset no code reads is not notice. This screen is what makes it +// notice. +public final class Licenses extends Activity { + + private static final String ASSET = "THIRD_PARTY_NOTICES"; + + @Override + protected void onCreate(Bundle saved) { + super.onCreate(saved); + setContentView(R.layout.licenses); + Ui.padForInsets(findViewById(R.id.root), WindowInsets.Type.systemBars()); + ((TextView) findViewById(R.id.notices)).setText(read()); + } + + private String read() { + try (InputStream in = getAssets().open(ASSET)) { + ByteArrayOutputStream out = new ByteArrayOutputStream(); + byte[] buf = new byte[8192]; + for (int n; (n = in.read(buf)) >= 0; ) { + if (n == 0) throw new IOException("license asset read made no progress"); + out.write(buf, 0, n); + } + return out.toString(StandardCharsets.UTF_8.name()); + } catch (IOException e) { + Log.e(e, "licenses: cannot read %s", ASSET); + return getString(R.string.licenses_unavailable); + } + } +} |