1951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen/*
2951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen * Copyright (C) 2012 The Android Open Source Project
3951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen *
4951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen * Licensed under the Apache License, Version 2.0 (the "License");
5951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen * you may not use this file except in compliance with the License.
6951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen * You may obtain a copy of the License at
7951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen *
8951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen *      http://www.apache.org/licenses/LICENSE-2.0
9951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen *
10951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen * Unless required by applicable law or agreed to in writing, software
11951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen * distributed under the License is distributed on an "AS IS" BASIS,
12951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen * See the License for the specific language governing permissions and
14951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen * limitations under the License.
15951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen */
16951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen
17951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen#ifndef ANDROID_ICOMMONTIMECONFIG_H
18951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen#define ANDROID_ICOMMONTIMECONFIG_H
19951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen
20951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen#include <stdint.h>
21951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen#include <linux/socket.h>
22951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen
23951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen#include <binder/IInterface.h>
24951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen#include <binder/IServiceManager.h>
25951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen
26951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chennamespace android {
27951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen
28951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chenclass String16;
29951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen
30951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chenclass ICommonTimeConfig : public IInterface {
31951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen  public:
32951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen    DECLARE_META_INTERFACE(CommonTimeConfig);
33951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen
34951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen    // Name of the ICommonTimeConfig service registered with the service
35951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen    // manager.
36951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen    static const String16 kServiceName;
37951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen
38951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen    virtual status_t getMasterElectionPriority(uint8_t *priority) = 0;
39951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen    virtual status_t setMasterElectionPriority(uint8_t priority) = 0;
40951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen    virtual status_t getMasterElectionEndpoint(struct sockaddr_storage *addr) = 0;
41951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen    virtual status_t setMasterElectionEndpoint(const struct sockaddr_storage *addr) = 0;
42951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen    virtual status_t getMasterElectionGroupId(uint64_t *id) = 0;
43951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen    virtual status_t setMasterElectionGroupId(uint64_t id) = 0;
44951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen    virtual status_t getInterfaceBinding(String16& ifaceName) = 0;
45951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen    virtual status_t setInterfaceBinding(const String16& ifaceName) = 0;
46951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen    virtual status_t getMasterAnnounceInterval(int *interval) = 0;
47951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen    virtual status_t setMasterAnnounceInterval(int interval) = 0;
48951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen    virtual status_t getClientSyncInterval(int *interval) = 0;
49951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen    virtual status_t setClientSyncInterval(int interval) = 0;
50951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen    virtual status_t getPanicThreshold(int *threshold) = 0;
51951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen    virtual status_t setPanicThreshold(int threshold) = 0;
52951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen    virtual status_t getAutoDisable(bool *autoDisable) = 0;
53951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen    virtual status_t setAutoDisable(bool autoDisable) = 0;
54951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen    virtual status_t forceNetworklessMasterMode() = 0;
55951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen
56951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen    // Simple helper to make it easier to connect to the CommonTimeConfig service.
57951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen    static inline sp<ICommonTimeConfig> getInstance() {
58951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen        sp<IBinder> binder = defaultServiceManager()->checkService(
59951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen                ICommonTimeConfig::kServiceName);
60951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen        sp<ICommonTimeConfig> clk = interface_cast<ICommonTimeConfig>(binder);
61951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen        return clk;
62951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen    }
63951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen};
64951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen
65951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chenclass BnCommonTimeConfig : public BnInterface<ICommonTimeConfig> {
66951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen  public:
67951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen    virtual status_t onTransact(uint32_t code, const Parcel& data,
68951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen                                Parcel* reply, uint32_t flags = 0);
69951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen};
70951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen
71951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen};  // namespace android
72951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen
73951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen#endif  // ANDROID_ICOMMONTIMECONFIG_H
74