Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a0146d3f authored by Stanley Wang's avatar Stanley Wang
Browse files

Fix the problem that some items can't be searched in Privacy category.

The source of problem is that the controller returns the wrong
availability status value and the searchable attribut of the preference
is false.

Fix: 200249682
Test: manual test and see the search result
Change-Id: I2265514c49303f6a0910f1be84b281fccb9abb45
parent 128d733d
Loading
Loading
Loading
Loading
+1 −3
Original line number Diff line number Diff line
@@ -49,7 +49,6 @@
        android:key="privacy_permissions_usage"
        android:title="@string/permissions_usage_title"
        android:summary="@string/permissions_usage_summary"
        settings:searchable="false"
        settings:controller="com.android.settings.privacy.PrivacyHubPreferenceController">
        <intent android:action="android.intent.action.REVIEW_PERMISSION_USAGE"/>
    </Preference>
@@ -58,8 +57,7 @@
    <Preference
        android:key="privacy_manage_perms"
        android:title="@string/app_permissions"
        android:summary="@string/runtime_permissions_summary_control_app_access"
        settings:searchable="false">
        android:summary="@string/runtime_permissions_summary_control_app_access">
        <intent android:action="android.intent.action.MANAGE_PERMISSIONS"/>
    </Preference>

+1 −1
Original line number Diff line number Diff line
@@ -40,7 +40,7 @@ public class CameraToggleController extends SensorToggleController {
    public int getAvailabilityStatus() {
        return mSensorPrivacyManagerHelper.supportsSensorToggle(getSensor())
                && DeviceConfig.getBoolean(DeviceConfig.NAMESPACE_PRIVACY, "camera_toggle_enabled",
                true) ? AVAILABLE_UNSEARCHABLE : UNSUPPORTED_ON_DEVICE;
                true) ? AVAILABLE : UNSUPPORTED_ON_DEVICE;
    }

    @Override
+1 −1
Original line number Diff line number Diff line
@@ -40,7 +40,7 @@ public class MicToggleController extends SensorToggleController {
    public int getAvailabilityStatus() {
        return mSensorPrivacyManagerHelper.supportsSensorToggle(getSensor())
                && DeviceConfig.getBoolean(DeviceConfig.NAMESPACE_PRIVACY, "mic_toggle_enabled",
                true) ? AVAILABLE_UNSEARCHABLE : UNSUPPORTED_ON_DEVICE;
                true) ? AVAILABLE : UNSUPPORTED_ON_DEVICE;
    }

    @Override
+1 −3
Original line number Diff line number Diff line
@@ -37,9 +37,7 @@ public class WorkPolicyInfoPreferenceController extends BasePreferenceController

    @Override
    public int getAvailabilityStatus() {
        return mEnterpriseProvider.hasWorkPolicyInfo()
                ? AVAILABLE_UNSEARCHABLE
                : UNSUPPORTED_ON_DEVICE;
        return mEnterpriseProvider.hasWorkPolicyInfo() ? AVAILABLE : UNSUPPORTED_ON_DEVICE;
    }

    @Override
+4 −4
Original line number Diff line number Diff line
@@ -16,7 +16,7 @@

package com.android.settings.privacy;

import static com.android.settings.core.BasePreferenceController.AVAILABLE_UNSEARCHABLE;
import static com.android.settings.core.BasePreferenceController.AVAILABLE;
import static com.android.settings.core.BasePreferenceController.UNSUPPORTED_ON_DEVICE;

import static com.google.common.truth.Truth.assertThat;
@@ -33,8 +33,8 @@ import com.android.settings.enterprise.EnterprisePrivacyFeatureProvider;
import com.android.settings.testutils.FakeFeatureFactory;

import org.junit.Before;
import org.junit.runner.RunWith;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.MockitoAnnotations;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.RuntimeEnvironment;
@@ -64,12 +64,12 @@ public class WorkPolicyInfoPreferenceControllerTest {
    }

    @Test
    public void getAvailabilityStatus_haveWorkPolicyInfo_shouldReturnAvailableUnsearchable() {
    public void getAvailabilityStatus_haveWorkPolicyInfo_shouldReturnAvailable() {
        when(mEnterpriseProvider.hasWorkPolicyInfo()).thenReturn(true);
        WorkPolicyInfoPreferenceController controller =
                new WorkPolicyInfoPreferenceController(mContext, "test_key");

        assertThat(controller.getAvailabilityStatus()).isEqualTo(AVAILABLE_UNSEARCHABLE);
        assertThat(controller.getAvailabilityStatus()).isEqualTo(AVAILABLE);
    }

    @Test