Add button to check for presence of log list in CT demo app
Bug: N/A Test: m CertificateTransparencyDemoApp Flag: TEST_ONLY Change-Id: Icac546e2c291d105193d8457c58b14935a8bf6ae
This commit is contained in:
parent
4be13fb54d
commit
4e50caac29
3 changed files with 49 additions and 2 deletions
|
|
@ -24,8 +24,7 @@
|
|||
android:label="@string/app_name"
|
||||
android:networkSecurityConfig="@xml/network_security_config"
|
||||
android:supportsRtl="true"
|
||||
android:theme="@style/Theme.AppCompat.DayNight.NoActionBar"
|
||||
tools:targetApi="34">
|
||||
android:theme="@style/Theme.AppCompat.DayNight.NoActionBar">
|
||||
<profileable android:shell="true" />
|
||||
<activity
|
||||
android:name=".MainActivity"
|
||||
|
|
|
|||
|
|
@ -48,6 +48,11 @@
|
|||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Connect to no-sct.badssl.com" />
|
||||
<Button
|
||||
android:id="@+id/button_check_log_list"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Check log list" />
|
||||
<TextView
|
||||
android:id="@+id/textView"
|
||||
android:layout_width="match_parent"
|
||||
|
|
|
|||
|
|
@ -31,6 +31,9 @@ import java.io.InputStream;
|
|||
import java.net.HttpURLConnection;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
|
||||
|
|
@ -98,6 +101,33 @@ public class MainActivity extends AppCompatActivity {
|
|||
urlConnection.disconnect();
|
||||
}
|
||||
|
||||
private void checkLogList(TextView textView) {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
Path root = Paths.get("/data/misc/keychain/ct/");
|
||||
try {
|
||||
for (Path version : Files.newDirectoryStream(root, "v*")) {
|
||||
if (Files.isDirectory(version)) {
|
||||
for (Path dir : Files.newDirectoryStream(version)) {
|
||||
if (!dir.endsWith("current")) {
|
||||
builder.append(dir.toString() + "\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (IOException e) {
|
||||
builder = new StringBuilder();
|
||||
builder.append(e.toString());
|
||||
}
|
||||
final String text = builder.toString();
|
||||
handler.post(
|
||||
new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
textView.setText(text);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
|
@ -107,6 +137,7 @@ public class MainActivity extends AppCompatActivity {
|
|||
Button buttonWikipedia = (Button) findViewById(R.id.button_wikipedia);
|
||||
Button buttonValid = (Button) findViewById(R.id.button_valid_badssl);
|
||||
Button buttonNoSCT = (Button) findViewById(R.id.button_no_sct_badssl);
|
||||
Button buttonCheckLogList = (Button) findViewById(R.id.button_check_log_list);
|
||||
final TextView textView = (TextView) findViewById(R.id.textView);
|
||||
buttonWikipedia.setOnClickListener(
|
||||
new View.OnClickListener() {
|
||||
|
|
@ -144,5 +175,17 @@ public class MainActivity extends AppCompatActivity {
|
|||
});
|
||||
}
|
||||
});
|
||||
buttonCheckLogList.setOnClickListener(
|
||||
new View.OnClickListener() {
|
||||
public void onClick(View v) {
|
||||
executor.execute(
|
||||
new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
checkLogList(textView);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue