Disable content protection settings if no service
Bug: 308613762 Test: Unit tests and manual end-to-end Change-Id: I0cc1ff1a260a7e14537036497a155135b7e2f0a9
This commit is contained in:
@@ -17,9 +17,14 @@ package com.android.settings.security;
|
||||
|
||||
import static android.view.contentprotection.flags.Flags.settingUiEnabled;
|
||||
|
||||
import static com.android.internal.R.string.config_defaultContentProtectionService;
|
||||
|
||||
import android.content.ComponentName;
|
||||
import android.content.Context;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.annotation.VisibleForTesting;
|
||||
|
||||
import com.android.settings.core.BasePreferenceController;
|
||||
|
||||
@@ -31,7 +36,24 @@ public class ContentProtectionPreferenceController extends BasePreferenceControl
|
||||
|
||||
@Override
|
||||
public int getAvailabilityStatus() {
|
||||
// TODO(b/306565942): Add a resource value check.
|
||||
return settingUiEnabled() ? AVAILABLE : UNSUPPORTED_ON_DEVICE;
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user