Mike J. Chen a94f7642a8 Add lib/aah_timesrv
aah_timesrv is a library that provides access to the local clock
and the common time service.

This is a squashed merge from master-tungsten of the following changes:

commit a59f6fce4ad7bb664270b70484958210780a9bdd
Author: John Grossman <johngro@google.com>
Date:   Fri Aug 12 11:49:03 2011 -0700

    Adapt to a change in the local time HAL.

    Changed the definition of the slew function in the local time HAL to take an
    int16 instead of an int32 and to use the full range of the int instead of
    attempting to imply any particular PPM range.

    Change-Id: Ie8825a4f7ae36aeeb2b23a1613f84b1672f37a26

commit f7e0cdac72592be1e24f08803e922f7be696d14b
Author: John Grossman <johngro@google.com>
Date:   Mon Jun 27 17:29:21 2011 -0700

    Remove "primary" from the local_time HAL.

    Interface instances are a pattern which should only be used by audio.  Remove
    its use from the local_time HAL.

    Change-Id: Ib96faaacc7f5b9f10f4bfd67e491316e99dc3c96

commit a148e2674b1d3cb73289b82b85c333f0a66824a9
Author: John Grossman <johngro@google.com>
Date:   Mon Jun 20 17:02:24 2011 -0700

    Move the A@H time service into frameworks/base

    Change-Id: I5c570cde70e8931e205516cb33517585804ce841

Change-Id: I0a840e5803f015659d3d21d5be287f98712c75eb
Signed-off-by: Mike J. Chen <mjchen@google.com>
Signed-off-by: John Grossman <johngro@google.com>
2011-10-28 10:14:48 -04:00

84 lines
2.8 KiB
C++

/*
* 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.
*/
#ifndef ANDROID_ICOMMONCLOCK_H
#define ANDROID_ICOMMONCLOCK_H
#include <stdint.h>
#include <binder/IInterface.h>
#include <binder/IServiceManager.h>
namespace android {
class ICommonClockListener : public IInterface {
public:
DECLARE_META_INTERFACE(CommonClockListener);
virtual void onClockSync(uint32_t timelineID) = 0;
virtual void onClockSyncLoss() = 0;
};
class BnCommonClockListener : public BnInterface<ICommonClockListener> {
public:
virtual status_t onTransact(uint32_t code, const Parcel& data,
Parcel* reply, uint32_t flags = 0);
};
class ICommonClock : public IInterface {
public:
DECLARE_META_INTERFACE(CommonClock);
// Name of the ICommonClock service registered with the service manager.
static const String16 kServiceName;
// a reserved invalid timeline ID
static const uint32_t kInvalidTimelineID;
virtual status_t isCommonTimeValid(bool* valid, uint32_t* timelineID) = 0;
virtual status_t commonTimeToLocalTime(int64_t commonTime,
int64_t* localTime) = 0;
virtual status_t localTimeToCommonTime(int64_t localTime,
int64_t* commonTime) = 0;
virtual status_t getCommonTime(int64_t* commonTime) = 0;
virtual status_t getCommonFreq(uint64_t* freq) = 0;
virtual status_t getLocalTime(int64_t* localTime) = 0;
virtual status_t getLocalFreq(uint64_t* freq) = 0;
virtual status_t registerListener(
const sp<ICommonClockListener>& listener) = 0;
virtual status_t unregisterListener(
const sp<ICommonClockListener>& listener) = 0;
// Simple helper to make it easier to connect to the CommonClock service.
static inline sp<ICommonClock> getInstance() {
sp<IBinder> binder = defaultServiceManager()->checkService(
ICommonClock::kServiceName);
sp<ICommonClock> clk = interface_cast<ICommonClock>(binder);
return clk;
}
};
class BnCommonClock : public BnInterface<ICommonClock> {
public:
virtual status_t onTransact(uint32_t code, const Parcel& data,
Parcel* reply, uint32_t flags = 0);
};
}; // namespace android
#endif // ANDROID_ICOMMONCLOCK_H