1 /* 2 * Copyright (C) 2012 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 #ifndef ANDROID_ICOMMONTIMECONFIG_H 18 #define ANDROID_ICOMMONTIMECONFIG_H 19 20 #include <stdint.h> 21 #include <linux/socket.h> 22 23 #include <binder/IInterface.h> 24 #include <binder/IServiceManager.h> 25 26 namespace android { 27 28 class String16; 29 30 class ICommonTimeConfig : public IInterface { 31 public: 32 DECLARE_META_INTERFACE(CommonTimeConfig); 33 34 // Name of the ICommonTimeConfig service registered with the service 35 // manager. 36 static const String16 kServiceName; 37 38 virtual status_t getMasterElectionPriority(uint8_t *priority) = 0; 39 virtual status_t setMasterElectionPriority(uint8_t priority) = 0; 40 virtual status_t getMasterElectionEndpoint(struct sockaddr_storage *addr) = 0; 41 virtual status_t setMasterElectionEndpoint(const struct sockaddr_storage *addr) = 0; 42 virtual status_t getMasterElectionGroupId(uint64_t *id) = 0; 43 virtual status_t setMasterElectionGroupId(uint64_t id) = 0; 44 virtual status_t getInterfaceBinding(String16& ifaceName) = 0; 45 virtual status_t setInterfaceBinding(const String16& ifaceName) = 0; 46 virtual status_t getMasterAnnounceInterval(int *interval) = 0; 47 virtual status_t setMasterAnnounceInterval(int interval) = 0; 48 virtual status_t getClientSyncInterval(int *interval) = 0; 49 virtual status_t setClientSyncInterval(int interval) = 0; 50 virtual status_t getPanicThreshold(int *threshold) = 0; 51 virtual status_t setPanicThreshold(int threshold) = 0; 52 virtual status_t getAutoDisable(bool *autoDisable) = 0; 53 virtual status_t setAutoDisable(bool autoDisable) = 0; 54 virtual status_t forceNetworklessMasterMode() = 0; 55 56 // Simple helper to make it easier to connect to the CommonTimeConfig service. 57 static inline sp<ICommonTimeConfig> getInstance() { 58 sp<IBinder> binder = defaultServiceManager()->checkService( 59 ICommonTimeConfig::kServiceName); 60 sp<ICommonTimeConfig> clk = interface_cast<ICommonTimeConfig>(binder); 61 return clk; 62 } 63 }; 64 65 class BnCommonTimeConfig : public BnInterface<ICommonTimeConfig> { 66 public: 67 virtual status_t onTransact(uint32_t code, const Parcel& data, 68 Parcel* reply, uint32_t flags = 0); 69 }; 70 71 }; // namespace android 72 73 #endif // ANDROID_ICOMMONTIMECONFIG_H 74