aboutsummaryrefslogtreecommitdiff
path: root/app/src/main/java/invalid/lena/scrcpy/Licenses.java
diff options
context:
space:
mode:
Diffstat (limited to 'app/src/main/java/invalid/lena/scrcpy/Licenses.java')
-rw-r--r--app/src/main/java/invalid/lena/scrcpy/Licenses.java48
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);
+ }
+ }
+}