Refactor to use the utils class.

Bug: 298076922

Change-Id: I0085fdf7594d0ba9243a7b44600252d8c5b21608
This commit is contained in:
Wa Gao
2023-11-15 18:03:02 +00:00
parent bd073bc18c
commit b9835cea12
2 changed files with 35 additions and 91 deletions

View File

@@ -36,32 +36,8 @@ public class ContentProtectionPreferenceController extends BasePreferenceControl
@Override
public int getAvailabilityStatus() {
if (!settingUiEnabled() || getContentProtectionServiceComponentName() == null) {
return UNSUPPORTED_ON_DEVICE;
}
return AVAILABLE;
}
@VisibleForTesting
@Nullable
protected String getContentProtectionServiceFlatComponentName() {
return mContext.getString(config_defaultContentProtectionService);
}
@Nullable
private ComponentName getContentProtectionServiceComponentName() {
String flatComponentName = getContentProtectionServiceFlatComponentName();
if (flatComponentName == null) {
return null;
}
return ComponentName.unflattenFromString(flatComponentName);
}
@VisibleForTesting
protected boolean settingUiEnabled() {
return DeviceConfig.getBoolean(
DeviceConfig.NAMESPACE_CONTENT_CAPTURE,
ContentCaptureManager.DEVICE_CONFIG_PROPERTY_ENABLE_CONTENT_PROTECTION_RECEIVER,
ContentCaptureManager.DEFAULT_ENABLE_CONTENT_PROTECTION_RECEIVER);
return ContentProtectionPreferenceUtils.isAvailable(mContext)
? AVAILABLE
: UNSUPPORTED_ON_DEVICE;
}
}