Move Java PeerConnectionFactory.fieldTrialsFindFullName to different file.

Currently, Java equivalent of webrtc::field_trial::FindFullName is in
PeeerConnectionFactory, which belongs to peerconnection_java GN target.

Move that method into a separate file and GN target to make it easier
to use the fieldTrialsFindFullName method in other code.

Bug: webrtc:13973
Change-Id: I4d7d30339883af76c1d066f72270c6caf9c64c49
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/261500
Reviewed-by: Xavier Lepaul‎ <xalep@webrtc.org>
Commit-Queue: Xavier Lepaul‎ <xalep@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#37233}
This commit is contained in:
Byoungchan Lee
2022-06-16 07:01:45 +09:00
committed by WebRTC LUCI CQ
parent 50674f7f69
commit d609473b9c
5 changed files with 98 additions and 20 deletions

View File

@ -0,0 +1,26 @@
/*
* Copyright (c) 2022 The WebRTC project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
* tree. An additional intellectual property rights grant can be found
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
*/
package org.webrtc;
public class FieldTrial {
// Wrapper of webrtc::field_trial::FindFullName. Develop the feature with default behaviour off.
// Example usage:
// if (FieldTrial.fieldTrialsFindFullName("WebRTCExperiment").equals("Enabled")) {
// method1();
// } else {
// method2();
// }
public static String fieldTrialsFindFullName(String name) {
return NativeLibrary.isLoaded() ? nativeFindFieldTrialsFullName(name) : "";
}
private static native String nativeFindFieldTrialsFullName(String name);
}

View File

@ -14,6 +14,7 @@ import android.content.Context;
import android.os.Process;
import androidx.annotation.Nullable;
import java.util.List;
import org.webrtc.FieldTrial;
import org.webrtc.Logging.Severity;
import org.webrtc.PeerConnection;
import org.webrtc.audio.AudioDeviceModule;
@ -335,15 +336,12 @@ public class PeerConnectionFactory {
nativeInitializeFieldTrials(fieldTrialsInitString);
}
// Wrapper of webrtc::field_trial::FindFullName. Develop the feature with default behaviour off.
// Example usage:
// if (PeerConnectionFactory.fieldTrialsFindFullName("WebRTCExperiment").equals("Enabled")) {
// method1();
// } else {
// method2();
// }
/**
* @deprecated Use {@link org.webrtc.FieldTrial#fieldTrialsFindFullName(String) } instead.
*/
@Deprecated
public static String fieldTrialsFindFullName(String name) {
return NativeLibrary.isLoaded() ? nativeFindFieldTrialsFullName(name) : "";
return FieldTrial.fieldTrialsFindFullName(name);
}
// Start/stop internal capturing of internal tracing.
public static boolean startInternalTracingCapture(String tracingFilename) {
@ -582,7 +580,6 @@ public class PeerConnectionFactory {
// (for example, at application startup time).
private static native void nativeInitializeAndroidGlobals();
private static native void nativeInitializeFieldTrials(String fieldTrialsInitString);
private static native String nativeFindFieldTrialsFullName(String name);
private static native void nativeInitializeInternalTracer();
// Internal tracing shutdown, called to prevent resource leaks. Must be called after
// PeerConnectionFactory is gone to prevent races with code performing tracing.