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

Commit 4a0c7825 authored by Amit Talreja (xWF)'s avatar Amit Talreja (xWF) Committed by Android (Google) Code Review
Browse files

Merge "Removed intermediate page in mobile network security settings flow page." into main

parents 3e99c16a 41ac5b16
Loading
Loading
Loading
Loading
+9 −31
Original line number Diff line number Diff line
@@ -18,12 +18,10 @@ package com.android.settings.network;

import android.app.settings.SettingsEnums;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.os.Build;
import android.os.Bundle;
import android.safetycenter.SafetyCenterManager;
import android.safetycenter.SafetySourceData;
import android.telephony.SubscriptionInfo;
import android.telephony.TelephonyManager;
import android.text.TextUtils;
@@ -48,7 +46,6 @@ import java.util.List;
public class CellularSecurityPreferenceController extends BasePreferenceController {

    private static final String LOG_TAG = "CellularSecurityPreferenceController";
    private static final String SAFETY_SOURCE_ID = "AndroidCellularNetworkSecurity";

    private @Nullable TelephonyManager mTelephonyManager;

@@ -136,25 +133,7 @@ public class CellularSecurityPreferenceController extends BasePreferenceControll
            // being not supported on the device.
            return false;
        }
        // Need to check that both Safety Center is available on device, and also that the HALs are
        // enabled before showing the Safety Center UI. Otherwise, we need to take them to the page
        // where the HALs can be enabled.
        SafetyCenterManager safetyCenterManager = mContext.getSystemService(
                SafetyCenterManager.class);
        SafetySourceData data = null;
        if (safetyCenterManager.isSafetyCenterEnabled()) {
            data = safetyCenterManager.getSafetySourceData(SAFETY_SOURCE_ID);
        }
        // Can only redirect to SafetyCenter if it has received data via the SafetySource, as
        // SafetyCenter doesn't support redirecting to a specific page associated with a source
        // if it hasn't received data from that source. See b/373942609 for details.
        if (data != null && areNotificationsEnabled()) {
            Intent safetyCenterIntent = new Intent(Intent.ACTION_SAFETY_CENTER);
            safetyCenterIntent.putExtra(SafetyCenterManager.EXTRA_SAFETY_SOURCES_GROUP_ID,
                    "AndroidCellularNetworkSecuritySources");
            mContext.startActivity(safetyCenterIntent);
        } else {
            Log.v(LOG_TAG, "Hardware APIs not enabled, or data source is null.");
        Log.v(LOG_TAG, "Load mobile network security screen.");
        final Bundle bundle = new Bundle();
        bundle.putString(CellularSecuritySettingsFragment.KEY_CELLULAR_SECURITY_PREFERENCE, "");

@@ -163,7 +142,6 @@ public class CellularSecurityPreferenceController extends BasePreferenceControll
                .setArguments(bundle)
                .setSourceMetricsCategory(SettingsEnums.CELLULAR_SECURITY_SETTINGS)
                .launch();
        }
        return true;
    }

+27 −0
Original line number Diff line number Diff line
@@ -21,6 +21,8 @@ import static com.android.settings.core.BasePreferenceController.UNSUPPORTED_ON_

import static com.google.common.truth.Truth.assertThat;

import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.doNothing;
import static org.mockito.Mockito.doReturn;
@@ -83,6 +85,31 @@ public final class CellularSecurityPreferenceControllerTest {
        mPreferenceScreen.addPreference(mPreference);
    }

    @Test
    public void handlePreferenceTreeClick_launchCellularSecuritySettingsFragment() {
        boolean result = mController.handlePreferenceTreeClick(mPreference);

        assertTrue(result);
    }

    @Test
    public void handlePreferenceTreeClick_preferenceKeyNotMatch() {
        mPreference.setKey("PREF_KEY");

        boolean result = mController.handlePreferenceTreeClick(mPreference);

        assertFalse(result);
    }

    @Test
    public void handlePreferenceTreeClick_SafetyCenterManagerIsNull() {
        when(mContext.getSystemService(SafetyCenterManager.class)).thenReturn(null);

        boolean result = mController.handlePreferenceTreeClick(mPreference);

        assertFalse(result);
    }

    @Test
    public void getAvailabilityStatus_hardwareSupported_shouldReturnTrue() {
        // Hardware support is enabled