blob: 8e669121469d5932e54fb5e0a4e9d3ba66b3e361 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
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);
}
}
}
|