Migrate CT namespace to "network_security"
Instead of the current "tehtering" namespace. Also, flags pushed via DeviceConfig come with a "CertificateTransparencyLogList" feature prefix. Flag: com.android.net.ct.flags.certificate_transparency_service Bug: 319829948 Test: atest NetworkSecurityUnitTests Change-Id: I565f888409f21e78cc28684cbf7daaae44b95d57
This commit is contained in:
parent
9daf0afa3d
commit
5319f5c363
3 changed files with 21 additions and 15 deletions
|
|
@ -15,8 +15,6 @@
|
|||
*/
|
||||
package com.android.server.net.ct;
|
||||
|
||||
import static android.provider.DeviceConfig.NAMESPACE_TETHERING;
|
||||
|
||||
import android.annotation.RequiresApi;
|
||||
import android.content.Context;
|
||||
import android.os.Build;
|
||||
|
|
@ -46,7 +44,7 @@ class CertificateTransparencyFlagsListener implements DeviceConfig.OnPropertiesC
|
|||
mDataStore.load();
|
||||
mCertificateTransparencyDownloader.registerReceiver();
|
||||
DeviceConfig.addOnPropertiesChangedListener(
|
||||
NAMESPACE_TETHERING, Executors.newSingleThreadExecutor(), this);
|
||||
Config.NAMESPACE_NETWORK_SECURITY, Executors.newSingleThreadExecutor(), this);
|
||||
if (Config.DEBUG) {
|
||||
Log.d(TAG, "CertificateTransparencyFlagsListener initialized successfully");
|
||||
}
|
||||
|
|
@ -55,14 +53,18 @@ class CertificateTransparencyFlagsListener implements DeviceConfig.OnPropertiesC
|
|||
|
||||
@Override
|
||||
public void onPropertiesChanged(Properties properties) {
|
||||
if (!NAMESPACE_TETHERING.equals(properties.getNamespace())) {
|
||||
if (!Config.NAMESPACE_NETWORK_SECURITY.equals(properties.getNamespace())) {
|
||||
return;
|
||||
}
|
||||
|
||||
String newVersion = DeviceConfig.getString(NAMESPACE_TETHERING, Config.VERSION, "");
|
||||
String newContentUrl = DeviceConfig.getString(NAMESPACE_TETHERING, Config.CONTENT_URL, "");
|
||||
String newVersion =
|
||||
DeviceConfig.getString(Config.NAMESPACE_NETWORK_SECURITY, Config.FLAG_VERSION, "");
|
||||
String newContentUrl =
|
||||
DeviceConfig.getString(
|
||||
Config.NAMESPACE_NETWORK_SECURITY, Config.FLAG_CONTENT_URL, "");
|
||||
String newMetadataUrl =
|
||||
DeviceConfig.getString(NAMESPACE_TETHERING, Config.METADATA_URL, "");
|
||||
DeviceConfig.getString(
|
||||
Config.NAMESPACE_NETWORK_SECURITY, Config.FLAG_METADATA_URL, "");
|
||||
if (TextUtils.isEmpty(newVersion)
|
||||
|| TextUtils.isEmpty(newContentUrl)
|
||||
|| TextUtils.isEmpty(newMetadataUrl)) {
|
||||
|
|
|
|||
|
|
@ -19,27 +19,23 @@ import android.annotation.RequiresApi;
|
|||
import android.content.Context;
|
||||
import android.net.ct.ICertificateTransparencyManager;
|
||||
import android.os.Build;
|
||||
import android.provider.DeviceConfig;
|
||||
|
||||
import com.android.net.ct.flags.Flags;
|
||||
import com.android.net.module.util.DeviceConfigUtils;
|
||||
import com.android.server.SystemService;
|
||||
|
||||
/** Implementation of the Certificate Transparency service. */
|
||||
@RequiresApi(Build.VERSION_CODES.VANILLA_ICE_CREAM)
|
||||
public class CertificateTransparencyService extends ICertificateTransparencyManager.Stub {
|
||||
|
||||
private static final String CERTIFICATE_TRANSPARENCY_ENABLED =
|
||||
"certificate_transparency_service_enabled";
|
||||
|
||||
private final CertificateTransparencyFlagsListener mFlagsListener;
|
||||
|
||||
/**
|
||||
* @return true if the CertificateTransparency service is enabled.
|
||||
*/
|
||||
public static boolean enabled(Context context) {
|
||||
// TODO: replace isTetheringFeatureEnabled with CT namespace flag.
|
||||
return DeviceConfigUtils.isTetheringFeatureEnabled(
|
||||
context, CERTIFICATE_TRANSPARENCY_ENABLED)
|
||||
return DeviceConfig.getBoolean(
|
||||
Config.NAMESPACE_NETWORK_SECURITY, Config.FLAG_SERVICE_ENABLED, false)
|
||||
&& Flags.certificateTransparencyService();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -33,7 +33,15 @@ final class Config {
|
|||
private static final String PREFERENCES_FILE_NAME = "ct.preferences";
|
||||
static final File PREFERENCES_FILE = new File(DEVICE_PROTECTED_DATA_DIR, PREFERENCES_FILE_NAME);
|
||||
|
||||
// flags and properties names
|
||||
// Phenotype flags
|
||||
static final String NAMESPACE_NETWORK_SECURITY = "network_security";
|
||||
private static final String FLAGS_PREFIX = "CertificateTransparencyLogList__";
|
||||
static final String FLAG_SERVICE_ENABLED = FLAGS_PREFIX + "service_enabled";
|
||||
static final String FLAG_CONTENT_URL = FLAGS_PREFIX + "content_url";
|
||||
static final String FLAG_METADATA_URL = FLAGS_PREFIX + "metadata_url";
|
||||
static final String FLAG_VERSION = FLAGS_PREFIX + "version";
|
||||
|
||||
// properties
|
||||
static final String VERSION_PENDING = "version_pending";
|
||||
static final String VERSION = "version";
|
||||
static final String CONTENT_URL_PENDING = "content_url_pending";
|
||||
|
|
|
|||
Loading…
Reference in a new issue