122a905eef16878f7f654497c279bb1d82b7df9a9Adrian Roos/* 222a905eef16878f7f654497c279bb1d82b7df9a9Adrian Roos * Copyright (C) 2017 The Android Open Source Project 322a905eef16878f7f654497c279bb1d82b7df9a9Adrian Roos * 422a905eef16878f7f654497c279bb1d82b7df9a9Adrian Roos * Licensed under the Apache License, Version 2.0 (the "License"); 522a905eef16878f7f654497c279bb1d82b7df9a9Adrian Roos * you may not use this file except in compliance with the License. 622a905eef16878f7f654497c279bb1d82b7df9a9Adrian Roos * You may obtain a copy of the License at 722a905eef16878f7f654497c279bb1d82b7df9a9Adrian Roos * 822a905eef16878f7f654497c279bb1d82b7df9a9Adrian Roos * http://www.apache.org/licenses/LICENSE-2.0 922a905eef16878f7f654497c279bb1d82b7df9a9Adrian Roos * 1022a905eef16878f7f654497c279bb1d82b7df9a9Adrian Roos * Unless required by applicable law or agreed to in writing, software 1122a905eef16878f7f654497c279bb1d82b7df9a9Adrian Roos * distributed under the License is distributed on an "AS IS" BASIS, 1222a905eef16878f7f654497c279bb1d82b7df9a9Adrian Roos * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1322a905eef16878f7f654497c279bb1d82b7df9a9Adrian Roos * See the License for the specific language governing permissions and 1422a905eef16878f7f654497c279bb1d82b7df9a9Adrian Roos * limitations under the License. 1522a905eef16878f7f654497c279bb1d82b7df9a9Adrian Roos */ 1622a905eef16878f7f654497c279bb1d82b7df9a9Adrian Roos 1722a905eef16878f7f654497c279bb1d82b7df9a9Adrian Roospackage com.android.systemui.doze; 1822a905eef16878f7f654497c279bb1d82b7df9a9Adrian Roos 1922a905eef16878f7f654497c279bb1d82b7df9a9Adrian Roosimport static org.junit.Assert.assertFalse; 2022a905eef16878f7f654497c279bb1d82b7df9a9Adrian Roos 2122a905eef16878f7f654497c279bb1d82b7df9a9Adrian Roosimport android.os.UserHandle; 2222a905eef16878f7f654497c279bb1d82b7df9a9Adrian Roosimport android.provider.Settings; 2322a905eef16878f7f654497c279bb1d82b7df9a9Adrian Roosimport android.support.test.filters.SmallTest; 2422a905eef16878f7f654497c279bb1d82b7df9a9Adrian Roosimport android.support.test.runner.AndroidJUnit4; 2522a905eef16878f7f654497c279bb1d82b7df9a9Adrian Roos 2622a905eef16878f7f654497c279bb1d82b7df9a9Adrian Roosimport com.android.internal.hardware.AmbientDisplayConfiguration; 2722a905eef16878f7f654497c279bb1d82b7df9a9Adrian Roosimport com.android.systemui.SysuiTestCase; 2822a905eef16878f7f654497c279bb1d82b7df9a9Adrian Roos 2922a905eef16878f7f654497c279bb1d82b7df9a9Adrian Roosimport org.junit.Before; 3022a905eef16878f7f654497c279bb1d82b7df9a9Adrian Roosimport org.junit.Test; 3122a905eef16878f7f654497c279bb1d82b7df9a9Adrian Roosimport org.junit.runner.RunWith; 3222a905eef16878f7f654497c279bb1d82b7df9a9Adrian Roos 3322a905eef16878f7f654497c279bb1d82b7df9a9Adrian Roos@RunWith(AndroidJUnit4.class) 3422a905eef16878f7f654497c279bb1d82b7df9a9Adrian Roos@SmallTest 3522a905eef16878f7f654497c279bb1d82b7df9a9Adrian Roospublic class DozeConfigurationTest extends SysuiTestCase { 3622a905eef16878f7f654497c279bb1d82b7df9a9Adrian Roos 3722a905eef16878f7f654497c279bb1d82b7df9a9Adrian Roos private AmbientDisplayConfiguration mDozeConfig; 3822a905eef16878f7f654497c279bb1d82b7df9a9Adrian Roos 3922a905eef16878f7f654497c279bb1d82b7df9a9Adrian Roos @Before 4022a905eef16878f7f654497c279bb1d82b7df9a9Adrian Roos public void setup() { 4122a905eef16878f7f654497c279bb1d82b7df9a9Adrian Roos mDozeConfig = new AmbientDisplayConfiguration(mContext); 4222a905eef16878f7f654497c279bb1d82b7df9a9Adrian Roos } 4322a905eef16878f7f654497c279bb1d82b7df9a9Adrian Roos 4422a905eef16878f7f654497c279bb1d82b7df9a9Adrian Roos @Test 4522a905eef16878f7f654497c279bb1d82b7df9a9Adrian Roos public void alwaysOn_offByDefault() throws Exception { 4622a905eef16878f7f654497c279bb1d82b7df9a9Adrian Roos if (!mDozeConfig.alwaysOnAvailable()) { 4722a905eef16878f7f654497c279bb1d82b7df9a9Adrian Roos return; 4822a905eef16878f7f654497c279bb1d82b7df9a9Adrian Roos } 4922a905eef16878f7f654497c279bb1d82b7df9a9Adrian Roos 50f06a317039a6502252c2b4b1a878520d166a38c6Jason Monk Settings.Secure.putString(mContext.getContentResolver(), Settings.Secure.DOZE_ALWAYS_ON, 51f06a317039a6502252c2b4b1a878520d166a38c6Jason Monk null); 5222a905eef16878f7f654497c279bb1d82b7df9a9Adrian Roos 5322a905eef16878f7f654497c279bb1d82b7df9a9Adrian Roos assertFalse(mDozeConfig.alwaysOnEnabled(UserHandle.USER_CURRENT)); 5422a905eef16878f7f654497c279bb1d82b7df9a9Adrian Roos } 5522a905eef16878f7f654497c279bb1d82b7df9a9Adrian Roos} 56