1 /* 2 * Copyright (C) 2019 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 package com.android.server.locksettings; 17 18 import android.content.ContentResolver; 19 import android.os.UserHandle; 20 import android.provider.Settings; 21 22 public class FakeSettings { 23 24 private int mDeviceProvisioned; 25 private int mSecureFrpMode; 26 private int mUserSetupComplete; 27 setDeviceProvisioned(boolean provisioned)28 public void setDeviceProvisioned(boolean provisioned) { 29 mDeviceProvisioned = provisioned ? 1 : 0; 30 } 31 setSecureFrpMode(boolean secure)32 public void setSecureFrpMode(boolean secure) { 33 mSecureFrpMode = secure ? 1 : 0; 34 } 35 setUserSetupComplete(boolean complete)36 public void setUserSetupComplete(boolean complete) { 37 mUserSetupComplete = complete ? 1 : 0; 38 } 39 globalGetInt(String keyName)40 public int globalGetInt(String keyName) { 41 switch (keyName) { 42 case Settings.Global.DEVICE_PROVISIONED: 43 return mDeviceProvisioned; 44 default: 45 throw new IllegalArgumentException("Unhandled global settings: " + keyName); 46 } 47 } 48 secureGetInt(ContentResolver contentResolver, String keyName, int defaultValue, int userId)49 public int secureGetInt(ContentResolver contentResolver, String keyName, int defaultValue, 50 int userId) { 51 if (Settings.Secure.SECURE_FRP_MODE.equals(keyName) && userId == UserHandle.USER_SYSTEM) { 52 return mSecureFrpMode; 53 } 54 if (Settings.Secure.USER_SETUP_COMPLETE.equals(keyName) 55 && userId == UserHandle.USER_SYSTEM) { 56 return mUserSetupComplete; 57 } 58 return defaultValue; 59 } 60 } 61