diff options
author | James Dong <jdong@google.com> | 2012-03-28 10:42:44 -0700 |
---|---|---|
committer | James Dong <jdong@google.com> | 2012-03-28 10:42:44 -0700 |
commit | d927a1d99630c05ff773f0e9e8791ca9a965e020 (patch) | |
tree | 760f8a19e317d68f937eda312efab59200880ecd /libs/common_time | |
parent | f9c1f9935b349fe1a3f27be4462026dd212f8b78 (diff) | |
download | frameworks_base-d927a1d99630c05ff773f0e9e8791ca9a965e020.zip frameworks_base-d927a1d99630c05ff773f0e9e8791ca9a965e020.tar.gz frameworks_base-d927a1d99630c05ff773f0e9e8791ca9a965e020.tar.bz2 |
Deleted the media, camera, drm related files since they are relocated
Change-Id: I9bc5573ee07e30b305b5b879023aa9ec69e10b91
Diffstat (limited to 'libs/common_time')
-rw-r--r-- | libs/common_time/Android.mk | 21 | ||||
-rw-r--r-- | libs/common_time/ICommonClock.cpp | 432 | ||||
-rw-r--r-- | libs/common_time/ICommonTimeConfig.cpp | 508 | ||||
-rw-r--r-- | libs/common_time/cc_helper.cpp | 129 | ||||
-rw-r--r-- | libs/common_time/local_clock.cpp | 92 | ||||
-rw-r--r-- | libs/common_time/utils.cpp | 89 | ||||
-rw-r--r-- | libs/common_time/utils.h | 34 |
7 files changed, 0 insertions, 1305 deletions
diff --git a/libs/common_time/Android.mk b/libs/common_time/Android.mk deleted file mode 100644 index 526f17b..0000000 --- a/libs/common_time/Android.mk +++ /dev/null @@ -1,21 +0,0 @@ -LOCAL_PATH:= $(call my-dir) -# -# libcommon_time_client -# (binder marshalers for ICommonClock as well as common clock and local clock -# helper code) -# - -include $(CLEAR_VARS) - -LOCAL_MODULE := libcommon_time_client -LOCAL_MODULE_TAGS := optional -LOCAL_SRC_FILES := cc_helper.cpp \ - local_clock.cpp \ - ICommonClock.cpp \ - ICommonTimeConfig.cpp \ - utils.cpp -LOCAL_SHARED_LIBRARIES := libbinder \ - libhardware \ - libutils - -include $(BUILD_SHARED_LIBRARY) diff --git a/libs/common_time/ICommonClock.cpp b/libs/common_time/ICommonClock.cpp deleted file mode 100644 index 28b43ac..0000000 --- a/libs/common_time/ICommonClock.cpp +++ /dev/null @@ -1,432 +0,0 @@ -/* - * Copyright (C) 2012 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -#include <linux/socket.h> - -#include <common_time/ICommonClock.h> -#include <binder/Parcel.h> - -#include "utils.h" - -namespace android { - -/***** ICommonClock *****/ - -enum { - IS_COMMON_TIME_VALID = IBinder::FIRST_CALL_TRANSACTION, - COMMON_TIME_TO_LOCAL_TIME, - LOCAL_TIME_TO_COMMON_TIME, - GET_COMMON_TIME, - GET_COMMON_FREQ, - GET_LOCAL_TIME, - GET_LOCAL_FREQ, - GET_ESTIMATED_ERROR, - GET_TIMELINE_ID, - GET_STATE, - GET_MASTER_ADDRESS, - REGISTER_LISTENER, - UNREGISTER_LISTENER, -}; - -const String16 ICommonClock::kServiceName("common_time.clock"); -const uint64_t ICommonClock::kInvalidTimelineID = 0; -const int32_t ICommonClock::kErrorEstimateUnknown = 0x7FFFFFFF; - -class BpCommonClock : public BpInterface<ICommonClock> -{ - public: - BpCommonClock(const sp<IBinder>& impl) - : BpInterface<ICommonClock>(impl) {} - - virtual status_t isCommonTimeValid(bool* valid, uint32_t* timelineID) { - Parcel data, reply; - data.writeInterfaceToken(ICommonClock::getInterfaceDescriptor()); - status_t status = remote()->transact(IS_COMMON_TIME_VALID, - data, - &reply); - if (status == OK) { - status = reply.readInt32(); - if (status == OK) { - *valid = reply.readInt32(); - *timelineID = reply.readInt32(); - } - } - return status; - } - - virtual status_t commonTimeToLocalTime(int64_t commonTime, - int64_t* localTime) { - Parcel data, reply; - data.writeInterfaceToken(ICommonClock::getInterfaceDescriptor()); - data.writeInt64(commonTime); - status_t status = remote()->transact(COMMON_TIME_TO_LOCAL_TIME, - data, &reply); - if (status == OK) { - status = reply.readInt32(); - if (status == OK) { - *localTime = reply.readInt64(); - } - } - return status; - } - - virtual status_t localTimeToCommonTime(int64_t localTime, - int64_t* commonTime) { - Parcel data, reply; - data.writeInterfaceToken(ICommonClock::getInterfaceDescriptor()); - data.writeInt64(localTime); - status_t status = remote()->transact(LOCAL_TIME_TO_COMMON_TIME, - data, &reply); - if (status == OK) { - status = reply.readInt32(); - if (status == OK) { - *commonTime = reply.readInt64(); - } - } - return status; - } - - virtual status_t getCommonTime(int64_t* commonTime) { - Parcel data, reply; - data.writeInterfaceToken(ICommonClock::getInterfaceDescriptor()); - status_t status = remote()->transact(GET_COMMON_TIME, data, &reply); - if (status == OK) { - status = reply.readInt32(); - if (status == OK) { - *commonTime = reply.readInt64(); - } - } - return status; - } - - virtual status_t getCommonFreq(uint64_t* freq) { - Parcel data, reply; - data.writeInterfaceToken(ICommonClock::getInterfaceDescriptor()); - status_t status = remote()->transact(GET_COMMON_FREQ, data, &reply); - if (status == OK) { - status = reply.readInt32(); - if (status == OK) { - *freq = reply.readInt64(); - } - } - return status; - } - - virtual status_t getLocalTime(int64_t* localTime) { - Parcel data, reply; - data.writeInterfaceToken(ICommonClock::getInterfaceDescriptor()); - status_t status = remote()->transact(GET_LOCAL_TIME, data, &reply); - if (status == OK) { - status = reply.readInt32(); - if (status == OK) { - *localTime = reply.readInt64(); - } - } - return status; - } - - virtual status_t getLocalFreq(uint64_t* freq) { - Parcel data, reply; - data.writeInterfaceToken(ICommonClock::getInterfaceDescriptor()); - status_t status = remote()->transact(GET_LOCAL_FREQ, data, &reply); - if (status == OK) { - status = reply.readInt32(); - if (status == OK) { - *freq = reply.readInt64(); - } - } - return status; - } - - virtual status_t getEstimatedError(int32_t* estimate) { - Parcel data, reply; - data.writeInterfaceToken(ICommonClock::getInterfaceDescriptor()); - status_t status = remote()->transact(GET_ESTIMATED_ERROR, data, &reply); - if (status == OK) { - status = reply.readInt32(); - if (status == OK) { - *estimate = reply.readInt32(); - } - } - return status; - } - - virtual status_t getTimelineID(uint64_t* id) { - Parcel data, reply; - data.writeInterfaceToken(ICommonClock::getInterfaceDescriptor()); - status_t status = remote()->transact(GET_TIMELINE_ID, data, &reply); - if (status == OK) { - status = reply.readInt32(); - if (status == OK) { - *id = static_cast<uint64_t>(reply.readInt64()); - } - } - return status; - } - - virtual status_t getState(State* state) { - Parcel data, reply; - data.writeInterfaceToken(ICommonClock::getInterfaceDescriptor()); - status_t status = remote()->transact(GET_STATE, data, &reply); - if (status == OK) { - status = reply.readInt32(); - if (status == OK) { - *state = static_cast<State>(reply.readInt32()); - } - } - return status; - } - - virtual status_t getMasterAddr(struct sockaddr_storage* addr) { - Parcel data, reply; - data.writeInterfaceToken(ICommonClock::getInterfaceDescriptor()); - status_t status = remote()->transact(GET_MASTER_ADDRESS, data, &reply); - if (status == OK) { - status = reply.readInt32(); - if (status == OK) - deserializeSockaddr(&reply, addr); - } - return status; - } - - virtual status_t registerListener( - const sp<ICommonClockListener>& listener) { - Parcel data, reply; - data.writeInterfaceToken(ICommonClock::getInterfaceDescriptor()); - data.writeStrongBinder(listener->asBinder()); - - status_t status = remote()->transact(REGISTER_LISTENER, data, &reply); - - if (status == OK) { - status = reply.readInt32(); - } - - return status; - } - - virtual status_t unregisterListener( - const sp<ICommonClockListener>& listener) { - Parcel data, reply; - data.writeInterfaceToken(ICommonClock::getInterfaceDescriptor()); - data.writeStrongBinder(listener->asBinder()); - status_t status = remote()->transact(UNREGISTER_LISTENER, data, &reply); - - if (status == OK) { - status = reply.readInt32(); - } - - return status; - } -}; - -IMPLEMENT_META_INTERFACE(CommonClock, "android.os.ICommonClock"); - -status_t BnCommonClock::onTransact(uint32_t code, - const Parcel& data, - Parcel* reply, - uint32_t flags) { - switch(code) { - case IS_COMMON_TIME_VALID: { - CHECK_INTERFACE(ICommonClock, data, reply); - bool valid; - uint32_t timelineID; - status_t status = isCommonTimeValid(&valid, &timelineID); - reply->writeInt32(status); - if (status == OK) { - reply->writeInt32(valid); - reply->writeInt32(timelineID); - } - return OK; - } break; - - case COMMON_TIME_TO_LOCAL_TIME: { - CHECK_INTERFACE(ICommonClock, data, reply); - int64_t commonTime = data.readInt64(); - int64_t localTime; - status_t status = commonTimeToLocalTime(commonTime, &localTime); - reply->writeInt32(status); - if (status == OK) { - reply->writeInt64(localTime); - } - return OK; - } break; - - case LOCAL_TIME_TO_COMMON_TIME: { - CHECK_INTERFACE(ICommonClock, data, reply); - int64_t localTime = data.readInt64(); - int64_t commonTime; - status_t status = localTimeToCommonTime(localTime, &commonTime); - reply->writeInt32(status); - if (status == OK) { - reply->writeInt64(commonTime); - } - return OK; - } break; - - case GET_COMMON_TIME: { - CHECK_INTERFACE(ICommonClock, data, reply); - int64_t commonTime; - status_t status = getCommonTime(&commonTime); - reply->writeInt32(status); - if (status == OK) { - reply->writeInt64(commonTime); - } - return OK; - } break; - - case GET_COMMON_FREQ: { - CHECK_INTERFACE(ICommonClock, data, reply); - uint64_t freq; - status_t status = getCommonFreq(&freq); - reply->writeInt32(status); - if (status == OK) { - reply->writeInt64(freq); - } - return OK; - } break; - - case GET_LOCAL_TIME: { - CHECK_INTERFACE(ICommonClock, data, reply); - int64_t localTime; - status_t status = getLocalTime(&localTime); - reply->writeInt32(status); - if (status == OK) { - reply->writeInt64(localTime); - } - return OK; - } break; - - case GET_LOCAL_FREQ: { - CHECK_INTERFACE(ICommonClock, data, reply); - uint64_t freq; - status_t status = getLocalFreq(&freq); - reply->writeInt32(status); - if (status == OK) { - reply->writeInt64(freq); - } - return OK; - } break; - - case GET_ESTIMATED_ERROR: { - CHECK_INTERFACE(ICommonClock, data, reply); - int32_t error; - status_t status = getEstimatedError(&error); - reply->writeInt32(status); - if (status == OK) { - reply->writeInt32(error); - } - return OK; - } break; - - case GET_TIMELINE_ID: { - CHECK_INTERFACE(ICommonClock, data, reply); - uint64_t id; - status_t status = getTimelineID(&id); - reply->writeInt32(status); - if (status == OK) { - reply->writeInt64(static_cast<int64_t>(id)); - } - return OK; - } break; - - case GET_STATE: { - CHECK_INTERFACE(ICommonClock, data, reply); - State state; - status_t status = getState(&state); - reply->writeInt32(status); - if (status == OK) { - reply->writeInt32(static_cast<int32_t>(state)); - } - return OK; - } break; - - case GET_MASTER_ADDRESS: { - CHECK_INTERFACE(ICommonClock, data, reply); - struct sockaddr_storage addr; - status_t status = getMasterAddr(&addr); - - if ((status == OK) && !canSerializeSockaddr(&addr)) { - status = UNKNOWN_ERROR; - } - - reply->writeInt32(status); - - if (status == OK) { - serializeSockaddr(reply, &addr); - } - - return OK; - } break; - - case REGISTER_LISTENER: { - CHECK_INTERFACE(ICommonClock, data, reply); - sp<ICommonClockListener> listener = - interface_cast<ICommonClockListener>(data.readStrongBinder()); - status_t status = registerListener(listener); - reply->writeInt32(status); - return OK; - } break; - - case UNREGISTER_LISTENER: { - CHECK_INTERFACE(ICommonClock, data, reply); - sp<ICommonClockListener> listener = - interface_cast<ICommonClockListener>(data.readStrongBinder()); - status_t status = unregisterListener(listener); - reply->writeInt32(status); - return OK; - } break; - } - return BBinder::onTransact(code, data, reply, flags); -} - -/***** ICommonClockListener *****/ - -enum { - ON_TIMELINE_CHANGED = IBinder::FIRST_CALL_TRANSACTION, -}; - -class BpCommonClockListener : public BpInterface<ICommonClockListener> -{ - public: - BpCommonClockListener(const sp<IBinder>& impl) - : BpInterface<ICommonClockListener>(impl) {} - - virtual void onTimelineChanged(uint64_t timelineID) { - Parcel data, reply; - data.writeInterfaceToken( - ICommonClockListener::getInterfaceDescriptor()); - data.writeInt64(timelineID); - remote()->transact(ON_TIMELINE_CHANGED, data, &reply); - } -}; - -IMPLEMENT_META_INTERFACE(CommonClockListener, - "android.os.ICommonClockListener"); - -status_t BnCommonClockListener::onTransact( - uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags) { - switch(code) { - case ON_TIMELINE_CHANGED: { - CHECK_INTERFACE(ICommonClockListener, data, reply); - uint32_t timelineID = data.readInt64(); - onTimelineChanged(timelineID); - return NO_ERROR; - } break; - } - - return BBinder::onTransact(code, data, reply, flags); -} - -}; // namespace android diff --git a/libs/common_time/ICommonTimeConfig.cpp b/libs/common_time/ICommonTimeConfig.cpp deleted file mode 100644 index 8eb37cb..0000000 --- a/libs/common_time/ICommonTimeConfig.cpp +++ /dev/null @@ -1,508 +0,0 @@ -/* - * Copyright (C) 2011 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -#include <linux/socket.h> - -#include <common_time/ICommonTimeConfig.h> -#include <binder/Parcel.h> - -#include "utils.h" - -namespace android { - -/***** ICommonTimeConfig *****/ - -enum { - GET_MASTER_ELECTION_PRIORITY = IBinder::FIRST_CALL_TRANSACTION, - SET_MASTER_ELECTION_PRIORITY, - GET_MASTER_ELECTION_ENDPOINT, - SET_MASTER_ELECTION_ENDPOINT, - GET_MASTER_ELECTION_GROUP_ID, - SET_MASTER_ELECTION_GROUP_ID, - GET_INTERFACE_BINDING, - SET_INTERFACE_BINDING, - GET_MASTER_ANNOUNCE_INTERVAL, - SET_MASTER_ANNOUNCE_INTERVAL, - GET_CLIENT_SYNC_INTERVAL, - SET_CLIENT_SYNC_INTERVAL, - GET_PANIC_THRESHOLD, - SET_PANIC_THRESHOLD, - GET_AUTO_DISABLE, - SET_AUTO_DISABLE, - FORCE_NETWORKLESS_MASTER_MODE, -}; - -const String16 ICommonTimeConfig::kServiceName("common_time.config"); - -class BpCommonTimeConfig : public BpInterface<ICommonTimeConfig> -{ - public: - BpCommonTimeConfig(const sp<IBinder>& impl) - : BpInterface<ICommonTimeConfig>(impl) {} - - virtual status_t getMasterElectionPriority(uint8_t *priority) { - Parcel data, reply; - data.writeInterfaceToken(ICommonTimeConfig::getInterfaceDescriptor()); - status_t status = remote()->transact(GET_MASTER_ELECTION_PRIORITY, - data, - &reply); - if (status == OK) { - status = reply.readInt32(); - if (status == OK) { - *priority = static_cast<uint8_t>(reply.readInt32()); - } - } - - return status; - } - - virtual status_t setMasterElectionPriority(uint8_t priority) { - Parcel data, reply; - data.writeInterfaceToken(ICommonTimeConfig::getInterfaceDescriptor()); - data.writeInt32(static_cast<int32_t>(priority)); - status_t status = remote()->transact(SET_MASTER_ELECTION_PRIORITY, - data, - &reply); - if (status == OK) { - status = reply.readInt32(); - } - - return status; - } - - virtual status_t getMasterElectionEndpoint(struct sockaddr_storage *addr) { - Parcel data, reply; - data.writeInterfaceToken(ICommonTimeConfig::getInterfaceDescriptor()); - status_t status = remote()->transact(GET_MASTER_ELECTION_ENDPOINT, - data, - &reply); - if (status == OK) { - status = reply.readInt32(); - if (status == OK) { - deserializeSockaddr(&reply, addr); - } - } - - return status; - } - - virtual status_t setMasterElectionEndpoint( - const struct sockaddr_storage *addr) { - Parcel data, reply; - data.writeInterfaceToken(ICommonTimeConfig::getInterfaceDescriptor()); - if (!canSerializeSockaddr(addr)) - return BAD_VALUE; - if (NULL == addr) { - data.writeInt32(0); - } else { - data.writeInt32(1); - serializeSockaddr(&data, addr); - } - status_t status = remote()->transact(SET_MASTER_ELECTION_ENDPOINT, - data, - &reply); - if (status == OK) { - status = reply.readInt32(); - } - - return status; - } - - virtual status_t getMasterElectionGroupId(uint64_t *id) { - Parcel data, reply; - data.writeInterfaceToken(ICommonTimeConfig::getInterfaceDescriptor()); - status_t status = remote()->transact(GET_MASTER_ELECTION_GROUP_ID, - data, - &reply); - - if (status == OK) { - status = reply.readInt32(); - if (status == OK) { - *id = static_cast<uint64_t>(reply.readInt64()); - } - } - - return status; - } - - virtual status_t setMasterElectionGroupId(uint64_t id) { - Parcel data, reply; - data.writeInterfaceToken(ICommonTimeConfig::getInterfaceDescriptor()); - data.writeInt64(id); - status_t status = remote()->transact(SET_MASTER_ELECTION_GROUP_ID, - data, - &reply); - - if (status == OK) { - status = reply.readInt32(); - } - - return status; - } - - virtual status_t getInterfaceBinding(String16& ifaceName) { - Parcel data, reply; - data.writeInterfaceToken(ICommonTimeConfig::getInterfaceDescriptor()); - status_t status = remote()->transact(GET_INTERFACE_BINDING, - data, - &reply); - if (status == OK) { - status = reply.readInt32(); - if (status == OK) { - ifaceName = reply.readString16(); - } - } - - return status; - } - - virtual status_t setInterfaceBinding(const String16& ifaceName) { - Parcel data, reply; - data.writeInterfaceToken(ICommonTimeConfig::getInterfaceDescriptor()); - data.writeString16(ifaceName); - status_t status = remote()->transact(SET_INTERFACE_BINDING, - data, - &reply); - if (status == OK) { - status = reply.readInt32(); - } - - return status; - } - - virtual status_t getMasterAnnounceInterval(int *interval) { - Parcel data, reply; - data.writeInterfaceToken(ICommonTimeConfig::getInterfaceDescriptor()); - status_t status = remote()->transact(GET_MASTER_ANNOUNCE_INTERVAL, - data, - &reply); - if (status == OK) { - status = reply.readInt32(); - if (status == OK) { - *interval = reply.readInt32(); - } - } - - return status; - } - - virtual status_t setMasterAnnounceInterval(int interval) { - Parcel data, reply; - data.writeInterfaceToken(ICommonTimeConfig::getInterfaceDescriptor()); - data.writeInt32(interval); - status_t status = remote()->transact(SET_MASTER_ANNOUNCE_INTERVAL, - data, - &reply); - if (status == OK) { - status = reply.readInt32(); - } - - return status; - } - - virtual status_t getClientSyncInterval(int *interval) { - Parcel data, reply; - data.writeInterfaceToken(ICommonTimeConfig::getInterfaceDescriptor()); - status_t status = remote()->transact(GET_CLIENT_SYNC_INTERVAL, - data, - &reply); - if (status == OK) { - status = reply.readInt32(); - if (status == OK) { - *interval = reply.readInt32(); - } - } - - return status; - } - - virtual status_t setClientSyncInterval(int interval) { - Parcel data, reply; - data.writeInterfaceToken(ICommonTimeConfig::getInterfaceDescriptor()); - data.writeInt32(interval); - status_t status = remote()->transact(SET_CLIENT_SYNC_INTERVAL, - data, - &reply); - if (status == OK) { - status = reply.readInt32(); - } - - return status; - } - - virtual status_t getPanicThreshold(int *threshold) { - Parcel data, reply; - data.writeInterfaceToken(ICommonTimeConfig::getInterfaceDescriptor()); - status_t status = remote()->transact(GET_PANIC_THRESHOLD, - data, - &reply); - if (status == OK) { - status = reply.readInt32(); - if (status == OK) { - *threshold = reply.readInt32(); - } - } - - return status; - } - - virtual status_t setPanicThreshold(int threshold) { - Parcel data, reply; - data.writeInterfaceToken(ICommonTimeConfig::getInterfaceDescriptor()); - data.writeInt32(threshold); - status_t status = remote()->transact(SET_PANIC_THRESHOLD, - data, - &reply); - if (status == OK) { - status = reply.readInt32(); - } - - return status; - } - - virtual status_t getAutoDisable(bool *autoDisable) { - Parcel data, reply; - data.writeInterfaceToken(ICommonTimeConfig::getInterfaceDescriptor()); - status_t status = remote()->transact(GET_AUTO_DISABLE, - data, - &reply); - if (status == OK) { - status = reply.readInt32(); - if (status == OK) { - *autoDisable = (0 != reply.readInt32()); - } - } - - return status; - } - - virtual status_t setAutoDisable(bool autoDisable) { - Parcel data, reply; - data.writeInterfaceToken(ICommonTimeConfig::getInterfaceDescriptor()); - data.writeInt32(autoDisable ? 1 : 0); - status_t status = remote()->transact(SET_AUTO_DISABLE, - data, - &reply); - - if (status == OK) { - status = reply.readInt32(); - } - - return status; - } - - virtual status_t forceNetworklessMasterMode() { - Parcel data, reply; - data.writeInterfaceToken(ICommonTimeConfig::getInterfaceDescriptor()); - status_t status = remote()->transact(FORCE_NETWORKLESS_MASTER_MODE, - data, - &reply); - - if (status == OK) { - status = reply.readInt32(); - } - - return status; - } -}; - -IMPLEMENT_META_INTERFACE(CommonTimeConfig, "android.os.ICommonTimeConfig"); - -status_t BnCommonTimeConfig::onTransact(uint32_t code, - const Parcel& data, - Parcel* reply, - uint32_t flags) { - switch(code) { - case GET_MASTER_ELECTION_PRIORITY: { - CHECK_INTERFACE(ICommonTimeConfig, data, reply); - uint8_t priority; - status_t status = getMasterElectionPriority(&priority); - reply->writeInt32(status); - if (status == OK) { - reply->writeInt32(static_cast<int32_t>(priority)); - } - return OK; - } break; - - case SET_MASTER_ELECTION_PRIORITY: { - CHECK_INTERFACE(ICommonTimeConfig, data, reply); - uint8_t priority = static_cast<uint8_t>(data.readInt32()); - status_t status = setMasterElectionPriority(priority); - reply->writeInt32(status); - return OK; - } break; - - case GET_MASTER_ELECTION_ENDPOINT: { - CHECK_INTERFACE(ICommonTimeConfig, data, reply); - struct sockaddr_storage addr; - status_t status = getMasterElectionEndpoint(&addr); - - if ((status == OK) && !canSerializeSockaddr(&addr)) { - status = UNKNOWN_ERROR; - } - - reply->writeInt32(status); - - if (status == OK) { - serializeSockaddr(reply, &addr); - } - - return OK; - } break; - - case SET_MASTER_ELECTION_ENDPOINT: { - CHECK_INTERFACE(ICommonTimeConfig, data, reply); - struct sockaddr_storage addr; - int hasAddr = data.readInt32(); - - status_t status; - if (hasAddr) { - deserializeSockaddr(&data, &addr); - status = setMasterElectionEndpoint(&addr); - } else { - status = setMasterElectionEndpoint(&addr); - } - - reply->writeInt32(status); - return OK; - } break; - - case GET_MASTER_ELECTION_GROUP_ID: { - CHECK_INTERFACE(ICommonTimeConfig, data, reply); - uint64_t id; - status_t status = getMasterElectionGroupId(&id); - reply->writeInt32(status); - if (status == OK) { - reply->writeInt64(id); - } - return OK; - } break; - - case SET_MASTER_ELECTION_GROUP_ID: { - CHECK_INTERFACE(ICommonTimeConfig, data, reply); - uint64_t id = static_cast<uint64_t>(data.readInt64()); - status_t status = setMasterElectionGroupId(id); - reply->writeInt32(status); - return OK; - } break; - - case GET_INTERFACE_BINDING: { - CHECK_INTERFACE(ICommonTimeConfig, data, reply); - String16 ret; - status_t status = getInterfaceBinding(ret); - reply->writeInt32(status); - if (status == OK) { - reply->writeString16(ret); - } - return OK; - } break; - - case SET_INTERFACE_BINDING: { - CHECK_INTERFACE(ICommonTimeConfig, data, reply); - String16 ifaceName; - ifaceName = data.readString16(); - status_t status = setInterfaceBinding(ifaceName); - reply->writeInt32(status); - return OK; - } break; - - case GET_MASTER_ANNOUNCE_INTERVAL: { - CHECK_INTERFACE(ICommonTimeConfig, data, reply); - int interval; - status_t status = getMasterAnnounceInterval(&interval); - reply->writeInt32(status); - if (status == OK) { - reply->writeInt32(interval); - } - return OK; - } break; - - case SET_MASTER_ANNOUNCE_INTERVAL: { - CHECK_INTERFACE(ICommonTimeConfig, data, reply); - int interval = data.readInt32(); - status_t status = setMasterAnnounceInterval(interval); - reply->writeInt32(status); - return OK; - } break; - - case GET_CLIENT_SYNC_INTERVAL: { - CHECK_INTERFACE(ICommonTimeConfig, data, reply); - int interval; - status_t status = getClientSyncInterval(&interval); - reply->writeInt32(status); - if (status == OK) { - reply->writeInt32(interval); - } - return OK; - } break; - - case SET_CLIENT_SYNC_INTERVAL: { - CHECK_INTERFACE(ICommonTimeConfig, data, reply); - int interval = data.readInt32(); - status_t status = setClientSyncInterval(interval); - reply->writeInt32(status); - return OK; - } break; - - case GET_PANIC_THRESHOLD: { - CHECK_INTERFACE(ICommonTimeConfig, data, reply); - int threshold; - status_t status = getPanicThreshold(&threshold); - reply->writeInt32(status); - if (status == OK) { - reply->writeInt32(threshold); - } - return OK; - } break; - - case SET_PANIC_THRESHOLD: { - CHECK_INTERFACE(ICommonTimeConfig, data, reply); - int threshold = data.readInt32(); - status_t status = setPanicThreshold(threshold); - reply->writeInt32(status); - return OK; - } break; - - case GET_AUTO_DISABLE: { - CHECK_INTERFACE(ICommonTimeConfig, data, reply); - bool autoDisable; - status_t status = getAutoDisable(&autoDisable); - reply->writeInt32(status); - if (status == OK) { - reply->writeInt32(autoDisable ? 1 : 0); - } - return OK; - } break; - - case SET_AUTO_DISABLE: { - CHECK_INTERFACE(ICommonTimeConfig, data, reply); - bool autoDisable = (0 != data.readInt32()); - status_t status = setAutoDisable(autoDisable); - reply->writeInt32(status); - return OK; - } break; - - case FORCE_NETWORKLESS_MASTER_MODE: { - CHECK_INTERFACE(ICommonTimeConfig, data, reply); - status_t status = forceNetworklessMasterMode(); - reply->writeInt32(status); - return OK; - } break; - } - return BBinder::onTransact(code, data, reply, flags); -} - -}; // namespace android - diff --git a/libs/common_time/cc_helper.cpp b/libs/common_time/cc_helper.cpp deleted file mode 100644 index 8d8556c..0000000 --- a/libs/common_time/cc_helper.cpp +++ /dev/null @@ -1,129 +0,0 @@ -/* - * Copyright (C) 2011 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include <stdint.h> - -#include <common_time/cc_helper.h> -#include <common_time/ICommonClock.h> -#include <utils/threads.h> - -namespace android { - -Mutex CCHelper::lock_; -sp<ICommonClock> CCHelper::common_clock_; -sp<ICommonClockListener> CCHelper::common_clock_listener_; -uint32_t CCHelper::ref_count_ = 0; - -bool CCHelper::verifyClock_l() { - bool ret = false; - - if (common_clock_ == NULL) { - common_clock_ = ICommonClock::getInstance(); - if (common_clock_ == NULL) - goto bailout; - } - - if (ref_count_ > 0) { - if (common_clock_listener_ == NULL) { - common_clock_listener_ = new CommonClockListener(); - if (common_clock_listener_ == NULL) - goto bailout; - - if (OK != common_clock_->registerListener(common_clock_listener_)) - goto bailout; - } - } - - ret = true; - -bailout: - if (!ret) { - common_clock_listener_ = NULL; - common_clock_ = NULL; - } - return ret; -} - -CCHelper::CCHelper() { - Mutex::Autolock lock(&lock_); - ref_count_++; - verifyClock_l(); -} - -CCHelper::~CCHelper() { - Mutex::Autolock lock(&lock_); - - assert(ref_count_ > 0); - ref_count_--; - - // If we were the last CCHelper instance in the system, and we had - // previously register a listener, unregister it now so that the common time - // service has the chance to go into auto-disabled mode. - if (!ref_count_ && - (common_clock_ != NULL) && - (common_clock_listener_ != NULL)) { - common_clock_->unregisterListener(common_clock_listener_); - common_clock_listener_ = NULL; - } -} - -void CCHelper::CommonClockListener::onTimelineChanged(uint64_t timelineID) { - // do nothing; listener is only really used as a token so the server can - // find out when clients die. -} - -// Helper methods which attempts to make calls to the common time binder -// service. If the first attempt fails with DEAD_OBJECT, the helpers will -// attempt to make a connection to the service again (assuming that the process -// hosting the service had crashed and the client proxy we are holding is dead) -// If the second attempt fails, or no connection can be made, the we let the -// error propagate up the stack and let the caller deal with the situation as -// best they can. -#define CCHELPER_METHOD(decl, call) \ - status_t CCHelper::decl { \ - Mutex::Autolock lock(&lock_); \ - \ - if (!verifyClock_l()) \ - return DEAD_OBJECT; \ - \ - status_t status = common_clock_->call; \ - if (DEAD_OBJECT == status) { \ - if (!verifyClock_l()) \ - return DEAD_OBJECT; \ - status = common_clock_->call; \ - } \ - \ - return status; \ - } - -#define VERIFY_CLOCK() - -CCHELPER_METHOD(isCommonTimeValid(bool* valid, uint32_t* timelineID), - isCommonTimeValid(valid, timelineID)) -CCHELPER_METHOD(commonTimeToLocalTime(int64_t commonTime, int64_t* localTime), - commonTimeToLocalTime(commonTime, localTime)) -CCHELPER_METHOD(localTimeToCommonTime(int64_t localTime, int64_t* commonTime), - localTimeToCommonTime(localTime, commonTime)) -CCHELPER_METHOD(getCommonTime(int64_t* commonTime), - getCommonTime(commonTime)) -CCHELPER_METHOD(getCommonFreq(uint64_t* freq), - getCommonFreq(freq)) -CCHELPER_METHOD(getLocalTime(int64_t* localTime), - getLocalTime(localTime)) -CCHELPER_METHOD(getLocalFreq(uint64_t* freq), - getLocalFreq(freq)) - -} // namespace android diff --git a/libs/common_time/local_clock.cpp b/libs/common_time/local_clock.cpp deleted file mode 100644 index a7c61fc..0000000 --- a/libs/common_time/local_clock.cpp +++ /dev/null @@ -1,92 +0,0 @@ -/* - * Copyright (C) 2011 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#define LOG_TAG "common_time" -#include <utils/Log.h> - -#include <assert.h> -#include <stdint.h> - -#include <common_time/local_clock.h> -#include <hardware/hardware.h> -#include <hardware/local_time_hal.h> -#include <utils/Errors.h> -#include <utils/threads.h> - -namespace android { - -Mutex LocalClock::dev_lock_; -local_time_hw_device_t* LocalClock::dev_ = NULL; - -LocalClock::LocalClock() { - int res; - const hw_module_t* mod; - - AutoMutex lock(&dev_lock_); - - if (dev_ != NULL) - return; - - res = hw_get_module_by_class(LOCAL_TIME_HARDWARE_MODULE_ID, NULL, &mod); - if (res) { - ALOGE("Failed to open local time HAL module (res = %d)", res); - } else { - res = local_time_hw_device_open(mod, &dev_); - if (res) { - ALOGE("Failed to open local time HAL device (res = %d)", res); - dev_ = NULL; - } - } -} - -bool LocalClock::initCheck() { - return (NULL != dev_); -} - -int64_t LocalClock::getLocalTime() { - assert(NULL != dev_); - assert(NULL != dev_->get_local_time); - - return dev_->get_local_time(dev_); -} - -uint64_t LocalClock::getLocalFreq() { - assert(NULL != dev_); - assert(NULL != dev_->get_local_freq); - - return dev_->get_local_freq(dev_); -} - -status_t LocalClock::setLocalSlew(int16_t rate) { - assert(NULL != dev_); - - if (!dev_->set_local_slew) - return INVALID_OPERATION; - - return static_cast<status_t>(dev_->set_local_slew(dev_, rate)); -} - -int32_t LocalClock::getDebugLog(struct local_time_debug_event* records, - int max_records) { - assert(NULL != dev_); - - if (!dev_->get_debug_log) - return INVALID_OPERATION; - - return dev_->get_debug_log(dev_, records, max_records); -} - -} // namespace android diff --git a/libs/common_time/utils.cpp b/libs/common_time/utils.cpp deleted file mode 100644 index 6539171..0000000 --- a/libs/common_time/utils.cpp +++ /dev/null @@ -1,89 +0,0 @@ -/* - * Copyright (C) 2012 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include <arpa/inet.h> -#include <linux/socket.h> - -#include <binder/Parcel.h> - -namespace android { - -bool canSerializeSockaddr(const struct sockaddr_storage* addr) { - switch (addr->ss_family) { - case AF_INET: - case AF_INET6: - return true; - default: - return false; - } -} - -void serializeSockaddr(Parcel* p, const struct sockaddr_storage* addr) { - switch (addr->ss_family) { - case AF_INET: { - const struct sockaddr_in* s = - reinterpret_cast<const struct sockaddr_in*>(addr); - p->writeInt32(AF_INET); - p->writeInt32(ntohl(s->sin_addr.s_addr)); - p->writeInt32(static_cast<int32_t>(ntohs(s->sin_port))); - } break; - - case AF_INET6: { - const struct sockaddr_in6* s = - reinterpret_cast<const struct sockaddr_in6*>(addr); - const int32_t* a = - reinterpret_cast<const int32_t*>(s->sin6_addr.s6_addr); - p->writeInt32(AF_INET6); - p->writeInt32(ntohl(a[0])); - p->writeInt32(ntohl(a[1])); - p->writeInt32(ntohl(a[2])); - p->writeInt32(ntohl(a[3])); - p->writeInt32(static_cast<int32_t>(ntohs(s->sin6_port))); - p->writeInt32(ntohl(s->sin6_flowinfo)); - p->writeInt32(ntohl(s->sin6_scope_id)); - } break; - } -} - -void deserializeSockaddr(const Parcel* p, struct sockaddr_storage* addr) { - memset(addr, 0, sizeof(addr)); - - addr->ss_family = p->readInt32(); - switch(addr->ss_family) { - case AF_INET: { - struct sockaddr_in* s = - reinterpret_cast<struct sockaddr_in*>(addr); - s->sin_addr.s_addr = htonl(p->readInt32()); - s->sin_port = htons(static_cast<uint16_t>(p->readInt32())); - } break; - - case AF_INET6: { - struct sockaddr_in6* s = - reinterpret_cast<struct sockaddr_in6*>(addr); - int32_t* a = reinterpret_cast<int32_t*>(s->sin6_addr.s6_addr); - - a[0] = htonl(p->readInt32()); - a[1] = htonl(p->readInt32()); - a[2] = htonl(p->readInt32()); - a[3] = htonl(p->readInt32()); - s->sin6_port = htons(static_cast<uint16_t>(p->readInt32())); - s->sin6_flowinfo = htonl(p->readInt32()); - s->sin6_scope_id = htonl(p->readInt32()); - } break; - } -} - -} // namespace android diff --git a/libs/common_time/utils.h b/libs/common_time/utils.h deleted file mode 100644 index ce79d0d..0000000 --- a/libs/common_time/utils.h +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright (C) 2012 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef ANDROID_LIBCOMMONCLOCK_UTILS_H -#define ANDROID_LIBCOMMONCLOCK_UTILS_H - -#include <linux/socket.h> - -#include <binder/Parcel.h> -#include <utils/Errors.h> - -namespace android { - -extern bool canSerializeSockaddr(const struct sockaddr_storage* addr); -extern void serializeSockaddr(Parcel* p, const struct sockaddr_storage* addr); -extern status_t deserializeSockaddr(const Parcel* p, - struct sockaddr_storage* addr); - -}; // namespace android - -#endif // ANDROID_LIBCOMMONCLOCK_UTILS_H |