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

Commit 8012faf7 authored by Romain Hunault's avatar Romain Hunault
Browse files

Merge branch 'cm-14.1' into eelo-0.1

parents 16d20d45 efbac329
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
@@ -155,6 +155,11 @@ public class ChooseLockGeneric extends SettingsActivity {
        @Override
        public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            final Activity activity = getActivity();
            if (!Utils.isDeviceProvisioned(activity) && !canRunBeforeDeviceProvisioned()) {
                activity.finish();
                return;
            }

            String chooseLockAction = getActivity().getIntent().getAction();
            mFingerprintManager =
@@ -234,6 +239,10 @@ public class ChooseLockGeneric extends SettingsActivity {
            addHeaderView();
        }

        protected boolean canRunBeforeDeviceProvisioned() {
            return false;
        }

        protected void addHeaderView() {
            if (mForFingerprint) {
                setHeaderView(R.layout.choose_lock_generic_fingerprint_header);
+2 −2
Original line number Diff line number Diff line
@@ -650,8 +650,8 @@ public class SettingsActivity extends SettingsDrawerActivity
            } else {
                // No UP affordance if we are displaying the main Dashboard
                mDisplayHomeAsUpEnabled = false;
                // Show Search affordance
                mDisplaySearch = true;
                // Show Search affordance (if device is provisioned)
                mDisplaySearch = Utils.isDeviceProvisioned(this);
                mInitialTitleResId = R.string.dashboard_title;

                // add argument to indicate which settings tab should be initially selected
+5 −0
Original line number Diff line number Diff line
@@ -138,6 +138,11 @@ public class SetupChooseLockGeneric extends ChooseLockGeneric {
            return layout.onCreateRecyclerView(inflater, parent, savedInstanceState);
        }

        @Override
        protected boolean canRunBeforeDeviceProvisioned() {
            return true;
        }

        /***
         * Disables preferences that are less secure than required quality and shows only secure
         * screen lock options here.
+65 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2018 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License
 */

package com.android.settings.password;

import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;

import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
import android.provider.Settings.Global;

import com.android.settings.password.ChooseLockGeneric.ChooseLockGenericFragment;
import com.android.settings.testutils.SettingsRobolectricTestRunner;
import com.android.settings.testutils.shadow.SettingsShadowResources;

import org.junit.After;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.RuntimeEnvironment;
import org.robolectric.annotation.Config;

@RunWith(SettingsRobolectricTestRunner.class)
public class ChooseLockGenericTest {

    @After
    public void tearDown() {
        Global.putInt(RuntimeEnvironment.application.getContentResolver(),
            Global.DEVICE_PROVISIONED, 1);
    }

    @Test
    @Config(shadows = SettingsShadowResources.SettingsShadowTheme.class)
    public void onCreate_deviceNotProvisioned_shouldFinishActivity() {
        final Context context = RuntimeEnvironment.application;
        Global.putInt(context.getContentResolver(), Global.DEVICE_PROVISIONED, 0);
        final Activity activity = mock(Activity.class);
        when(activity.getContentResolver()).thenReturn(context.getContentResolver());
        when(activity.getTheme()).thenReturn(context.getTheme());

        final ChooseLockGenericFragment fragment = spy(new ChooseLockGenericFragment());
        when(fragment.getActivity()).thenReturn(activity);
        when(fragment.getArguments()).thenReturn(Bundle.EMPTY);

        fragment.onCreate(Bundle.EMPTY);
        verify(activity).finish();
    }

}