diff --git a/android-stub/src/main/java/android/crypto/hpke/HpkeSpi.java b/android-stub/src/main/java/android/crypto/hpke/HpkeSpi.java index fe2672325..d309998ea 100644 --- a/android-stub/src/main/java/android/crypto/hpke/HpkeSpi.java +++ b/android-stub/src/main/java/android/crypto/hpke/HpkeSpi.java @@ -168,8 +168,7 @@ void engineInitRecipient(@NonNull byte[] encapsulated, @NonNull PrivateKey recip * as a sender * @throws GeneralSecurityException on decryption failures */ - @NonNull - byte[] engineOpen(@NonNull byte[] ciphertext, @Nullable byte[] aad) + @NonNull byte[] engineOpen(@NonNull byte[] ciphertext, @Nullable byte[] aad) throws GeneralSecurityException; /** diff --git a/android/src/main/java/org/conscrypt/ConscryptStatsLog.java b/android/src/main/java/org/conscrypt/ConscryptStatsLog.java new file mode 100644 index 000000000..19ab61631 --- /dev/null +++ b/android/src/main/java/org/conscrypt/ConscryptStatsLog.java @@ -0,0 +1,26 @@ +/* + * Copyright 2020 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.conscrypt; + +/** + * Stub class for logging statistics events. + */ +public class ConscryptStatsLog { + public static final int TLS_HANDSHAKE_REPORTED = 0; + + public static void write(int code, boolean arg1, int arg2, int arg3, int arg4) {} +} diff --git a/common/src/main/java/org/conscrypt/ConscryptEngineSocket.java b/common/src/main/java/org/conscrypt/ConscryptEngineSocket.java index c46a2cf7c..93de52def 100644 --- a/common/src/main/java/org/conscrypt/ConscryptEngineSocket.java +++ b/common/src/main/java/org/conscrypt/ConscryptEngineSocket.java @@ -142,6 +142,7 @@ public void onHandshakeFinished() { // references to the given ConscryptEngineSocket. Our internal engine will call // the SSLEngine-receiving methods, but our callers expect the SSLSocket-receiving // methods to get called. + @SuppressWarnings("CustomX509TrustManager") private static X509TrustManager getDelegatingTrustManager(final X509TrustManager delegate, final ConscryptEngineSocket socket) { if (delegate instanceof X509ExtendedTrustManager) { diff --git a/fix_format.py b/fix_format.py new file mode 100755 index 000000000..065dad46e --- /dev/null +++ b/fix_format.py @@ -0,0 +1,79 @@ +#!/usr/bin/env python3 +import shutil +import subprocess +import sys +from pathlib import Path +from typing import List, FrozenSet + +CLANG_FORMAT_BIN: str = "clang-format" +PROJECT_PREFIX: str = "//depot/google3/third_party/java_src/conscrypt/" +VALID_EXTENSIONS: FrozenSet[str] = frozenset({".java", ".cc", ".h", ".cpp", ".c"}) + +def get_g4_output() -> str: + """Runs g4 opened and returns the stdout.""" + try: + return subprocess.check_output(["g4", "opened"], text=True) + except subprocess.CalledProcessError as e: + sys.exit(f"ERROR: Failed to run 'g4 opened'.\nDetails: {e}") + +def parse_files(g4_output: str, project_prefix: str, root_dir: Path) -> List[str]: + """Parses g4 output and returns a list of absolute file paths to format.""" + files_to_format: List[str] = [] + + for line in g4_output.splitlines(): + line = line.strip() + if not line: + continue + + depot_path = line.split('#')[0] + + if not depot_path.endswith(tuple(VALID_EXTENSIONS)): + continue + + if not depot_path.startswith(project_prefix): + continue + + relative_path = depot_path[len(project_prefix):] + + abs_path = root_dir / relative_path + files_to_format.append(str(abs_path)) + + return files_to_format + +def main() -> None: + script_dir = Path(__file__).resolve().parent + config_path = script_dir / ".clang-format" + + try: + if not config_path.is_file(): + raise FileNotFoundError(f"Config file missing at {config_path}") + except OSError as e: + sys.exit(f"ERROR: Could not access config file.\nDetails: {e}") + + if not shutil.which(CLANG_FORMAT_BIN): + sys.exit(f"ERROR: '{CLANG_FORMAT_BIN}' not found in PATH.") + + print("Querying opened files...") + g4_output = get_g4_output() + files_to_format = parse_files(g4_output, PROJECT_PREFIX, script_dir) + + if not files_to_format: + print(f"No source files under {PROJECT_PREFIX} are currently open.") + sys.exit(0) + + print(f"Formatting {len(files_to_format)} file(s) with config: {config_path}") + + cmd = [ + CLANG_FORMAT_BIN, + "-i", + f"-style=file:{config_path}", + ] + files_to_format + + try: + subprocess.run(cmd, check=True) + print("Done.") + except subprocess.CalledProcessError as e: + sys.exit(f"ERROR: clang-format failed.\nDetails: {e}") + +if __name__ == "__main__": + main() \ No newline at end of file