Skip to content

Commit 905775c

Browse files
committed
Project import generated by Copybara.
PiperOrigin-RevId: 874012482
1 parent 5255c88 commit 905775c

4 files changed

Lines changed: 107 additions & 2 deletions

File tree

android-stub/src/main/java/android/crypto/hpke/HpkeSpi.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -168,8 +168,7 @@ void engineInitRecipient(@NonNull byte[] encapsulated, @NonNull PrivateKey recip
168168
* as a sender
169169
* @throws GeneralSecurityException on decryption failures
170170
*/
171-
@NonNull
172-
byte[] engineOpen(@NonNull byte[] ciphertext, @Nullable byte[] aad)
171+
@NonNull byte[] engineOpen(@NonNull byte[] ciphertext, @Nullable byte[] aad)
173172
throws GeneralSecurityException;
174173

175174
/**
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
/*
2+
* Copyright 2020 The Android Open Source Project
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package org.conscrypt;
18+
19+
/**
20+
* Stub class for logging statistics events.
21+
*/
22+
public class ConscryptStatsLog {
23+
public static final int TLS_HANDSHAKE_REPORTED = 0;
24+
25+
public static void write(int code, boolean arg1, int arg2, int arg3, int arg4) {}
26+
}

common/src/main/java/org/conscrypt/ConscryptEngineSocket.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,7 @@ public void onHandshakeFinished() {
142142
// references to the given ConscryptEngineSocket. Our internal engine will call
143143
// the SSLEngine-receiving methods, but our callers expect the SSLSocket-receiving
144144
// methods to get called.
145+
@SuppressWarnings("CustomX509TrustManager")
145146
private static X509TrustManager getDelegatingTrustManager(final X509TrustManager delegate,
146147
final ConscryptEngineSocket socket) {
147148
if (delegate instanceof X509ExtendedTrustManager) {

fix_format.py

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
#!/usr/bin/env python3
2+
import shutil
3+
import subprocess
4+
import sys
5+
from pathlib import Path
6+
from typing import List, FrozenSet
7+
8+
CLANG_FORMAT_BIN: str = "clang-format"
9+
PROJECT_PREFIX: str = "//depot/google3/third_party/java_src/conscrypt/"
10+
VALID_EXTENSIONS: FrozenSet[str] = frozenset({".java", ".cc", ".h", ".cpp", ".c"})
11+
12+
def get_g4_output() -> str:
13+
"""Runs g4 opened and returns the stdout."""
14+
try:
15+
return subprocess.check_output(["g4", "opened"], text=True)
16+
except subprocess.CalledProcessError as e:
17+
sys.exit(f"ERROR: Failed to run 'g4 opened'.\nDetails: {e}")
18+
19+
def parse_files(g4_output: str, project_prefix: str, root_dir: Path) -> List[str]:
20+
"""Parses g4 output and returns a list of absolute file paths to format."""
21+
files_to_format: List[str] = []
22+
23+
for line in g4_output.splitlines():
24+
line = line.strip()
25+
if not line:
26+
continue
27+
28+
depot_path = line.split('#')[0]
29+
30+
if not depot_path.endswith(tuple(VALID_EXTENSIONS)):
31+
continue
32+
33+
if not depot_path.startswith(project_prefix):
34+
continue
35+
36+
relative_path = depot_path[len(project_prefix):]
37+
38+
abs_path = root_dir / relative_path
39+
files_to_format.append(str(abs_path))
40+
41+
return files_to_format
42+
43+
def main() -> None:
44+
script_dir = Path(__file__).resolve().parent
45+
config_path = script_dir / ".clang-format"
46+
47+
try:
48+
if not config_path.is_file():
49+
raise FileNotFoundError(f"Config file missing at {config_path}")
50+
except OSError as e:
51+
sys.exit(f"ERROR: Could not access config file.\nDetails: {e}")
52+
53+
if not shutil.which(CLANG_FORMAT_BIN):
54+
sys.exit(f"ERROR: '{CLANG_FORMAT_BIN}' not found in PATH.")
55+
56+
print("Querying opened files...")
57+
g4_output = get_g4_output()
58+
files_to_format = parse_files(g4_output, PROJECT_PREFIX, script_dir)
59+
60+
if not files_to_format:
61+
print(f"No source files under {PROJECT_PREFIX} are currently open.")
62+
sys.exit(0)
63+
64+
print(f"Formatting {len(files_to_format)} file(s) with config: {config_path}")
65+
66+
cmd = [
67+
CLANG_FORMAT_BIN,
68+
"-i",
69+
f"-style=file:{config_path}",
70+
] + files_to_format
71+
72+
try:
73+
subprocess.run(cmd, check=True)
74+
print("Done.")
75+
except subprocess.CalledProcessError as e:
76+
sys.exit(f"ERROR: clang-format failed.\nDetails: {e}")
77+
78+
if __name__ == "__main__":
79+
main()

0 commit comments

Comments
 (0)