Fix Content Capture service starting after restriction
When a device owner and a profile owner restrict Content Capture, there should be no toggle setting to turn on Content Capture. Bug: 250573776 Test: Manual. Use setps on the comment#3, make sure no toggle setting in the Privacy page. Change-Id: Ia17f852b224c67b9c1cf5846ee9ad5592a485bab
This commit is contained in:
@@ -18,6 +18,8 @@ package com.android.settings.privacy;
|
||||
|
||||
import android.annotation.NonNull;
|
||||
import android.content.Context;
|
||||
import android.os.UserHandle;
|
||||
import android.os.UserManager;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.core.TogglePreferenceController;
|
||||
@@ -42,9 +44,15 @@ public final class EnableContentCapturePreferenceController extends TogglePrefer
|
||||
|
||||
@Override
|
||||
public int getAvailabilityStatus() {
|
||||
boolean available = ContentCaptureUtils.isFeatureAvailable()
|
||||
&& ContentCaptureUtils.getServiceSettingsComponentName() == null;
|
||||
return available ? AVAILABLE : UNSUPPORTED_ON_DEVICE;
|
||||
if (!ContentCaptureUtils.isFeatureAvailable()
|
||||
|| ContentCaptureUtils.getServiceSettingsComponentName() != null) {
|
||||
return UNSUPPORTED_ON_DEVICE;
|
||||
}
|
||||
if (UserManager.get(mContext).hasUserRestrictionForUser(
|
||||
UserManager.DISALLOW_CONTENT_CAPTURE, UserHandle.of(UserHandle.myUserId()))) {
|
||||
return DISABLED_FOR_USER;
|
||||
}
|
||||
return AVAILABLE;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
Reference in New Issue
Block a user