1 /* 2 * Copyright (C) 2023 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 17 package com.android.devicelockcontroller.storage; 18 19 import android.app.Service; 20 import android.content.Context; 21 import android.content.Intent; 22 import android.os.Bundle; 23 import android.os.IBinder; 24 25 import com.android.devicelockcontroller.common.DeviceLockConstants.ProvisioningType; 26 import com.android.devicelockcontroller.util.LogUtil; 27 28 import java.util.List; 29 30 /** 31 * A class exposing Setup Parameters as a service. 32 */ 33 public final class SetupParametersService extends Service { 34 private static final String TAG = "SetupParametersService"; 35 private Context mContext; 36 37 private final ISetupParametersService.Stub mBinder = 38 new ISetupParametersService.Stub() { 39 @Override 40 public void overridePrefs(Bundle bundle) { 41 SetupParameters.overridePrefs(mContext, bundle); 42 } 43 44 @Override 45 public void createPrefs(Bundle bundle) { 46 SetupParameters.createPrefs(mContext, bundle); 47 } 48 49 @Override 50 public void dump() { 51 SetupParameters.dumpParameters(mContext); 52 } 53 54 @Override 55 public void clear() { 56 SetupParameters.clear(mContext); 57 } 58 59 @Override 60 public String getKioskPackage() { 61 return SetupParameters.getKioskPackage(mContext); 62 } 63 64 @Override 65 public boolean getOutgoingCallsDisabled() { 66 return SetupParameters.getOutgoingCallsDisabled(mContext); 67 } 68 69 @Override 70 public List<String> getKioskAllowlist() { 71 return SetupParameters.getKioskAllowlist(mContext); 72 } 73 74 @Override 75 public boolean isNotificationsInLockTaskModeEnabled() { 76 return SetupParameters.isNotificationsInLockTaskModeEnabled(mContext); 77 } 78 79 @Override 80 public boolean isDebuggingAllowed() { 81 return SetupParameters.isDebuggingAllowed(mContext); 82 } 83 84 @Override 85 @ProvisioningType 86 public int getProvisioningType() { 87 return SetupParameters.getProvisioningType(mContext); 88 } 89 90 @Override 91 public boolean isProvisionMandatory() { 92 return SetupParameters.isProvisionMandatory(mContext); 93 } 94 95 @Override 96 public String getKioskAppProviderName() { 97 return SetupParameters.getKioskAppProviderName(mContext); 98 } 99 100 @Override 101 public boolean isInstallingFromUnknownSourcesDisallowed() { 102 return SetupParameters.isInstallingFromUnknownSourcesDisallowed(mContext); 103 } 104 105 @Override 106 public String getTermsAndConditionsUrl() { 107 return SetupParameters.getTermsAndConditionsUrl(mContext); 108 } 109 110 @Override 111 public String getSupportUrl() { 112 return SetupParameters.getSupportUrl(mContext); 113 } 114 }; 115 116 @Override onCreate()117 public void onCreate() { 118 LogUtil.d(TAG, "onCreate"); 119 mContext = this; 120 } 121 122 @Override onBind(Intent intent)123 public IBinder onBind(Intent intent) { 124 return mBinder; 125 } 126 } 127