1951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen/*
2951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen * Copyright (C) 2011 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 */
16e5167f88f3734a048dc44199f3fff0432589db43Elliott Hughes
17e5167f88f3734a048dc44199f3fff0432589db43Elliott Hughes#include <sys/socket.h>
18951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen
19951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen#include <common_time/ICommonTimeConfig.h>
20951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen#include <binder/Parcel.h>
21951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen
22951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen#include "utils.h"
23951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen
24951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chennamespace android {
25951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen
26951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen/***** ICommonTimeConfig *****/
27951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen
28951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chenenum {
29951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen    GET_MASTER_ELECTION_PRIORITY = IBinder::FIRST_CALL_TRANSACTION,
30951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen    SET_MASTER_ELECTION_PRIORITY,
31951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen    GET_MASTER_ELECTION_ENDPOINT,
32951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen    SET_MASTER_ELECTION_ENDPOINT,
33951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen    GET_MASTER_ELECTION_GROUP_ID,
34951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen    SET_MASTER_ELECTION_GROUP_ID,
35951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen    GET_INTERFACE_BINDING,
36951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen    SET_INTERFACE_BINDING,
37951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen    GET_MASTER_ANNOUNCE_INTERVAL,
38951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen    SET_MASTER_ANNOUNCE_INTERVAL,
39951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen    GET_CLIENT_SYNC_INTERVAL,
40951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen    SET_CLIENT_SYNC_INTERVAL,
41951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen    GET_PANIC_THRESHOLD,
42951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen    SET_PANIC_THRESHOLD,
43951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen    GET_AUTO_DISABLE,
44951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen    SET_AUTO_DISABLE,
45951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen    FORCE_NETWORKLESS_MASTER_MODE,
46951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen};
47951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen
48951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chenconst String16 ICommonTimeConfig::kServiceName("common_time.config");
49951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen
50951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chenclass BpCommonTimeConfig : public BpInterface<ICommonTimeConfig>
51951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen{
52951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen  public:
53951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen    BpCommonTimeConfig(const sp<IBinder>& impl)
54951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen        : BpInterface<ICommonTimeConfig>(impl) {}
55951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen
56951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen    virtual status_t getMasterElectionPriority(uint8_t *priority) {
57951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen        Parcel data, reply;
58951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen        data.writeInterfaceToken(ICommonTimeConfig::getInterfaceDescriptor());
59951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen        status_t status = remote()->transact(GET_MASTER_ELECTION_PRIORITY,
60951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen                                             data,
61951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen                                             &reply);
62951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen        if (status == OK) {
63951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen            status = reply.readInt32();
64951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen            if (status == OK) {
65951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen                *priority = static_cast<uint8_t>(reply.readInt32());
66951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen            }
67951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen        }
68951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen
69951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen        return status;
70951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen    }
71951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen
72951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen    virtual status_t setMasterElectionPriority(uint8_t priority) {
73951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen        Parcel data, reply;
74951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen        data.writeInterfaceToken(ICommonTimeConfig::getInterfaceDescriptor());
75951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen        data.writeInt32(static_cast<int32_t>(priority));
76951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen        status_t status = remote()->transact(SET_MASTER_ELECTION_PRIORITY,
77951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen                                             data,
78951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen                                             &reply);
79951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen        if (status == OK) {
80951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen            status = reply.readInt32();
81951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen        }
82951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen
83951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen        return status;
84951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen    }
85951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen
86951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen    virtual status_t getMasterElectionEndpoint(struct sockaddr_storage *addr) {
87951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen        Parcel data, reply;
88951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen        data.writeInterfaceToken(ICommonTimeConfig::getInterfaceDescriptor());
89951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen        status_t status = remote()->transact(GET_MASTER_ELECTION_ENDPOINT,
90951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen                                             data,
91951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen                                             &reply);
92951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen        if (status == OK) {
93951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen            status = reply.readInt32();
94951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen            if (status == OK) {
95951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen                deserializeSockaddr(&reply, addr);
96951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen            }
97951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen        }
98951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen
99951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen        return status;
100951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen    }
101951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen
102951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen    virtual status_t setMasterElectionEndpoint(
103951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen            const struct sockaddr_storage *addr) {
104951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen        Parcel data, reply;
105951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen        data.writeInterfaceToken(ICommonTimeConfig::getInterfaceDescriptor());
106951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen        if (!canSerializeSockaddr(addr))
107951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen            return BAD_VALUE;
108951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen        if (NULL == addr) {
109951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen            data.writeInt32(0);
110951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen        } else {
111951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen            data.writeInt32(1);
112951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen            serializeSockaddr(&data, addr);
113951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen        }
114951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen        status_t status = remote()->transact(SET_MASTER_ELECTION_ENDPOINT,
115951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen                                             data,
116951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen                                             &reply);
117951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen        if (status == OK) {
118951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen            status = reply.readInt32();
119951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen        }
120951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen
121951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen        return status;
122951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen    }
123951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen
124951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen    virtual status_t getMasterElectionGroupId(uint64_t *id) {
125951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen        Parcel data, reply;
126951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen        data.writeInterfaceToken(ICommonTimeConfig::getInterfaceDescriptor());
127951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen        status_t status = remote()->transact(GET_MASTER_ELECTION_GROUP_ID,
128951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen                                             data,
129951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen                                             &reply);
130951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen
131951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen        if (status == OK) {
132951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen            status = reply.readInt32();
133951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen            if (status == OK) {
134951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen                *id = static_cast<uint64_t>(reply.readInt64());
135951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen            }
136951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen        }
137951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen
138951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen        return status;
139951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen    }
140951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen
141951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen    virtual status_t setMasterElectionGroupId(uint64_t id) {
142951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen        Parcel data, reply;
143951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen        data.writeInterfaceToken(ICommonTimeConfig::getInterfaceDescriptor());
144951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen        data.writeInt64(id);
145951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen        status_t status = remote()->transact(SET_MASTER_ELECTION_GROUP_ID,
146951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen                                             data,
147951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen                                             &reply);
148951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen
149951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen        if (status == OK) {
150951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen            status = reply.readInt32();
151951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen        }
152951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen
153951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen        return status;
154951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen    }
155951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen
156951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen    virtual status_t getInterfaceBinding(String16& ifaceName) {
157951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen        Parcel data, reply;
158951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen        data.writeInterfaceToken(ICommonTimeConfig::getInterfaceDescriptor());
159951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen        status_t status = remote()->transact(GET_INTERFACE_BINDING,
160951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen                                             data,
161951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen                                             &reply);
162951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen        if (status == OK) {
163951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen            status = reply.readInt32();
164951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen            if (status == OK) {
165951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen                ifaceName = reply.readString16();
166951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen            }
167951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen        }
168951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen
169951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen        return status;
170951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen    }
171951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen
172951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen    virtual status_t setInterfaceBinding(const String16& ifaceName) {
173951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen        Parcel data, reply;
174951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen        data.writeInterfaceToken(ICommonTimeConfig::getInterfaceDescriptor());
175951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen        data.writeString16(ifaceName);
176951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen        status_t status = remote()->transact(SET_INTERFACE_BINDING,
177951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen                                             data,
178951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen                                             &reply);
179951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen        if (status == OK) {
180951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen            status = reply.readInt32();
181951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen        }
182951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen
183951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen        return status;
184951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen    }
185951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen
186951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen    virtual status_t getMasterAnnounceInterval(int *interval) {
187951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen        Parcel data, reply;
188951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen        data.writeInterfaceToken(ICommonTimeConfig::getInterfaceDescriptor());
189951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen        status_t status = remote()->transact(GET_MASTER_ANNOUNCE_INTERVAL,
190951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen                                             data,
191951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen                                             &reply);
192951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen        if (status == OK) {
193951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen            status = reply.readInt32();
194951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen            if (status == OK) {
195951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen                *interval = reply.readInt32();
196951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen            }
197951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen        }
198951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen
199951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen        return status;
200951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen    }
201951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen
202951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen    virtual status_t setMasterAnnounceInterval(int interval) {
203951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen        Parcel data, reply;
204951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen        data.writeInterfaceToken(ICommonTimeConfig::getInterfaceDescriptor());
205951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen        data.writeInt32(interval);
206951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen        status_t status = remote()->transact(SET_MASTER_ANNOUNCE_INTERVAL,
207951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen                                             data,
208951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen                                             &reply);
209951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen        if (status == OK) {
210951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen            status = reply.readInt32();
211951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen        }
212951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen
213951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen        return status;
214951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen    }
215951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen
216951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen    virtual status_t getClientSyncInterval(int *interval) {
217951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen        Parcel data, reply;
218951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen        data.writeInterfaceToken(ICommonTimeConfig::getInterfaceDescriptor());
219951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen        status_t status = remote()->transact(GET_CLIENT_SYNC_INTERVAL,
220951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen                                             data,
221951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen                                             &reply);
222951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen        if (status == OK) {
223951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen            status = reply.readInt32();
224951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen            if (status == OK) {
225951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen                *interval = reply.readInt32();
226951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen            }
227951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen        }
228951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen
229951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen        return status;
230951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen    }
231951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen
232951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen    virtual status_t setClientSyncInterval(int interval) {
233951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen        Parcel data, reply;
234951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen        data.writeInterfaceToken(ICommonTimeConfig::getInterfaceDescriptor());
235951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen        data.writeInt32(interval);
236951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen        status_t status = remote()->transact(SET_CLIENT_SYNC_INTERVAL,
237951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen                                             data,
238951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen                                             &reply);
239951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen        if (status == OK) {
240951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen            status = reply.readInt32();
241951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen        }
242951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen
243951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen        return status;
244951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen    }
245951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen
246951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen    virtual status_t getPanicThreshold(int *threshold) {
247951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen        Parcel data, reply;
248951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen        data.writeInterfaceToken(ICommonTimeConfig::getInterfaceDescriptor());
249951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen        status_t status = remote()->transact(GET_PANIC_THRESHOLD,
250951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen                                             data,
251951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen                                             &reply);
252951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen        if (status == OK) {
253951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen            status = reply.readInt32();
254951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen            if (status == OK) {
255951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen                *threshold = reply.readInt32();
256951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen            }
257951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen        }
258951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen
259951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen        return status;
260951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen    }
261951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen
262951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen    virtual status_t setPanicThreshold(int threshold) {
263951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen        Parcel data, reply;
264951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen        data.writeInterfaceToken(ICommonTimeConfig::getInterfaceDescriptor());
265951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen        data.writeInt32(threshold);
266951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen        status_t status = remote()->transact(SET_PANIC_THRESHOLD,
267951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen                                             data,
268951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen                                             &reply);
269951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen        if (status == OK) {
270951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen            status = reply.readInt32();
271951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen        }
272951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen
273951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen        return status;
274951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen    }
275951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen
276951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen    virtual status_t getAutoDisable(bool *autoDisable) {
277951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen        Parcel data, reply;
278951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen        data.writeInterfaceToken(ICommonTimeConfig::getInterfaceDescriptor());
279951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen        status_t status = remote()->transact(GET_AUTO_DISABLE,
280951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen                                             data,
281951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen                                             &reply);
282951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen        if (status == OK) {
283951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen            status = reply.readInt32();
284951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen            if (status == OK) {
285951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen                *autoDisable = (0 != reply.readInt32());
286951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen            }
287951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen        }
288951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen
289951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen        return status;
290951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen    }
291951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen
292951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen    virtual status_t setAutoDisable(bool autoDisable) {
293951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen        Parcel data, reply;
294951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen        data.writeInterfaceToken(ICommonTimeConfig::getInterfaceDescriptor());
295951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen        data.writeInt32(autoDisable ? 1 : 0);
296951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen        status_t status = remote()->transact(SET_AUTO_DISABLE,
297951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen                                             data,
298951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen                                             &reply);
299951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen
300951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen        if (status == OK) {
301951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen            status = reply.readInt32();
302951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen        }
303951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen
304951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen        return status;
305951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen    }
306951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen
307951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen    virtual status_t forceNetworklessMasterMode() {
308951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen        Parcel data, reply;
309951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen        data.writeInterfaceToken(ICommonTimeConfig::getInterfaceDescriptor());
310951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen        status_t status = remote()->transact(FORCE_NETWORKLESS_MASTER_MODE,
311951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen                                             data,
312951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen                                             &reply);
313