1 /* 2 * Copyright (C) 2022 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.uwb.discovery; 17 18 import android.util.Log; 19 20 /** Abstract class for Discovery Provider */ 21 public abstract class DiscoveryProvider { 22 private static final String TAG = DiscoveryProvider.class.getSimpleName(); 23 24 /* Indicates whether the server has started. 25 */ 26 protected boolean mStarted = false; 27 28 /** 29 * Checks if the server has started. 30 * 31 * @return indicates if the server has started. 32 */ isStarted()33 public boolean isStarted() { 34 return mStarted; 35 } 36 37 /** 38 * Starts the discovery. 39 * 40 * @return indicates if successfully started. 41 */ start()42 public boolean start() { 43 if (isStarted()) { 44 Log.i(TAG, "Discovery already started."); 45 return false; 46 } 47 return true; 48 } 49 50 /** 51 * Stops the discovery. 52 * 53 * @return indicates if successfully stopped. 54 */ stop()55 public boolean stop() { 56 if (!isStarted()) { 57 Log.i(TAG, "Discovery already stopped."); 58 return false; 59 } 60 return true; 61 } 62 } 63