diff options
130 files changed, 11895 insertions, 804 deletions
diff --git a/AndroidProducts.mk b/AndroidProducts.mk index 364f4ed7..90437183 100644 --- a/AndroidProducts.mk +++ b/AndroidProducts.mk @@ -1,3 +1,4 @@ PRODUCT_MAKEFILES := \ $(LOCAL_DIR)/sdk_phone_x86_vendor.mk \ - $(LOCAL_DIR)/fvp.mk + $(LOCAL_DIR)/fvp.mk \ + $(LOCAL_DIR)/fvp_mini.mk diff --git a/audio/Android.bp b/audio/Android.bp index 668a1e75..170d2c1f 100644 --- a/audio/Android.bp +++ b/audio/Android.bp @@ -14,6 +14,13 @@ // limitations under the License. cc_library_shared { + name: "android.hardware.audio.legacy@6.0-impl.ranchu", + defaults: ["android.hardware.audio@6.0-impl_default"], + relative_install_path: "hw", + vendor: true, +} + +cc_library_shared { name: "android.hardware.audio@6.0-impl.ranchu", vendor: true, vintf_fragments: ["android.hardware.audio@6.0-impl.ranchu.xml"], @@ -30,6 +37,8 @@ cc_library_shared { "device_port_source.cpp", "device_port_sink.cpp", "talsa.cpp", + "ring_buffer.cpp", + "audio_ops.cpp", "util.cpp", ], shared_libs: [ @@ -52,4 +61,11 @@ cc_library_shared { cflags: [ "-DLOG_TAG=\"android.hardware.audio@6.0-impl.ranchu\"", ], + // a.h.audio@6.0-impl.ranchu (see above) loads a.h.audio.legacy@6.0-impl + // which loads audio.r_submix.default which provides the r_submix device, + // see b/161485545. Should be retired once a better r_submix is available. + required: [ + "android.hardware.audio.legacy@6.0-impl.ranchu", + "audio.r_submix.default", + ], } diff --git a/audio/audio_ops.cpp b/audio/audio_ops.cpp new file mode 100644 index 00000000..088c9349 --- /dev/null +++ b/audio/audio_ops.cpp @@ -0,0 +1,79 @@ +/* + * Copyright (C) 2020 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 <string.h> +#include <math.h> +#include "audio_ops.h" + +namespace android { +namespace hardware { +namespace audio { +namespace V6_0 { +namespace implementation { +namespace aops { + +void multiplyByVolume(const float volume, int16_t *a, const size_t n) { + constexpr int_fast32_t kDenominator = 32768; + const int_fast32_t numerator = + static_cast<int_fast32_t>(round(volume * kDenominator)); + + if (numerator >= kDenominator) { + return; // (numerator > kDenominator) is not expected + } else if (numerator <= 0) { + memset(a, 0, n * sizeof(*a)); + return; // (numerator < 0) is not expected + } + + int16_t *end = a + n; + + // The unroll code below is to save on CPU branch instructions. + // 8 is arbitrary chosen. + +#define STEP \ + *a = (*a * numerator + kDenominator / 2) / kDenominator; \ + ++a + + switch (n % 8) { + case 7: goto l7; + case 6: goto l6; + case 5: goto l5; + case 4: goto l4; + case 3: goto l3; + case 2: goto l2; + case 1: goto l1; + default: break; + } + + while (a < end) { + STEP; +l7: STEP; +l6: STEP; +l5: STEP; +l4: STEP; +l3: STEP; +l2: STEP; +l1: STEP; + } + +#undef STEP +} + +} // namespace aops +} // namespace implementation +} // namespace V6_0 +} // namespace audio +} // namespace hardware +} // namespace android diff --git a/audio/audio_ops.h b/audio/audio_ops.h new file mode 100644 index 00000000..3822a139 --- /dev/null +++ b/audio/audio_ops.h @@ -0,0 +1,34 @@ +/* + * Copyright (C) 2020 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. + */ + +#pragma once +#include <stdint.h> + +namespace android { +namespace hardware { +namespace audio { +namespace V6_0 { +namespace implementation { +namespace aops { + +void multiplyByVolume(float volume, int16_t *a, size_t n); + +} // namespace aops +} // namespace implementation +} // namespace V6_0 +} // namespace audio +} // namespace hardware +} // namespace android diff --git a/audio/device_factory.cpp b/audio/device_factory.cpp index ccbd7d07..d399b5ba 100644 --- a/audio/device_factory.cpp +++ b/audio/device_factory.cpp @@ -14,11 +14,11 @@ * limitations under the License. */ +#include <system/audio.h> +#include <log/log.h> #include "device_factory.h" #include "primary_device.h" #include "debug.h" -#include <system/audio.h> -#include <log/log.h> namespace android { namespace hardware { @@ -28,41 +28,39 @@ namespace implementation { using ::android::hardware::Void; -wp<PrimaryDevice> gPrimaryDevice; // volume levels and the mic state are global +#ifdef __LP64__ +#define LIB_PATH_PREFIX "vendor/lib64/hw/" +#else +#define LIB_PATH_PREFIX "vendor/lib/hw/" +#endif -template <class D> sp<D> getCachedDevice(wp<D>& cache) { - sp<D> result = cache.promote(); - if (!result) { - result = new D; - cache = result; - } - return result; +DevicesFactory::DevicesFactory() { + mLegacyLib.reset(dlopen( + LIB_PATH_PREFIX "android.hardware.audio.legacy@6.0-impl.ranchu.so", RTLD_NOW)); + LOG_ALWAYS_FATAL_IF(!mLegacyLib); + + typedef IDevicesFactory *(*Func)(const char *); + const auto func = reinterpret_cast<Func>( + dlsym(mLegacyLib.get(), "HIDL_FETCH_IDevicesFactory")); + LOG_ALWAYS_FATAL_IF(!func); + + mLegacyFactory.reset((*func)("default")); + LOG_ALWAYS_FATAL_IF(!mLegacyFactory); } Return<void> DevicesFactory::openDevice(const hidl_string& device, openDevice_cb _hidl_cb) { - Result result = Result::OK; - sp<IDevice> dev; - - if (device == AUDIO_HARDWARE_MODULE_ID_PRIMARY) { - dev = getCachedDevice(gPrimaryDevice); - } else if (device == AUDIO_HARDWARE_MODULE_ID_REMOTE_SUBMIX) { - dev = getCachedDevice(gPrimaryDevice); - } else { - result = FAILURE(Result::INVALID_ARGUMENTS); - } - - if (!dev) { - ALOGE("DevicesFactory::%s:%d: failed, device='%s' result='%s'", - __func__, __LINE__, device.c_str(), toString(result).c_str()); + if (device == AUDIO_HARDWARE_MODULE_ID_PRIMARY) + _hidl_cb(Result::OK, new PrimaryDevice); + else { + mLegacyFactory->openDevice(device, _hidl_cb); } - _hidl_cb(result, std::move(dev)); return Void(); } Return<void> DevicesFactory::openPrimaryDevice(openPrimaryDevice_cb _hidl_cb) { - _hidl_cb(Result::OK, getCachedDevice(gPrimaryDevice)); + _hidl_cb(Result::OK, new PrimaryDevice); return Void(); } diff --git a/audio/device_factory.h b/audio/device_factory.h index ac653d0d..cc33be5a 100644 --- a/audio/device_factory.h +++ b/audio/device_factory.h @@ -15,7 +15,9 @@ */ #pragma once +#include <memory> #include <android/hardware/audio/6.0/IDevicesFactory.h> +#include <dlfcn.h> namespace android { namespace hardware { @@ -29,8 +31,20 @@ using ::android::hardware::Return; using namespace ::android::hardware::audio::V6_0; struct DevicesFactory : public IDevicesFactory { + DevicesFactory(); + Return<void> openDevice(const hidl_string& device, openDevice_cb _hidl_cb) override; Return<void> openPrimaryDevice(openPrimaryDevice_cb _hidl_cb) override; + +private: + struct DLDeleter { + void operator()(void* dl) const { + ::dlclose(dl); + } + }; + + std::unique_ptr<void, DLDeleter> mLegacyLib; + std::unique_ptr<IDevicesFactory> mLegacyFactory; }; } // namespace implementation diff --git a/audio/device_port_sink.cpp b/audio/device_port_sink.cpp index ffc68164..bcf21e6c 100644 --- a/audio/device_port_sink.cpp +++ b/audio/device_port_sink.cpp @@ -14,10 +14,15 @@ * limitations under the License. */ +#include <chrono> +#include <thread> #include <log/log.h> #include <utils/Timers.h> +#include <utils/ThreadDefs.h> #include "device_port_sink.h" #include "talsa.h" +#include "audio_ops.h" +#include "ring_buffer.h" #include "util.h" #include "debug.h" @@ -29,50 +34,179 @@ namespace implementation { namespace { +constexpr int kMaxJitterUs = 3000; // Enforced by CTS, should be <= 6ms + struct TinyalsaSink : public DevicePortSink { TinyalsaSink(unsigned pcmCard, unsigned pcmDevice, - const AudioConfig &cfg, uint64_t &frames) - : mFrames(frames) + const AudioConfig &cfg, + uint64_t &frames) + : mStartNs(systemTime(SYSTEM_TIME_MONOTONIC)) + , mSampleRateHz(cfg.sampleRateHz) + , mFrameSize(util::countChannels(cfg.channelMask) * sizeof(int16_t)) + , mWriteSizeFrames(cfg.frameCount) + , mFrames(frames) + , mRingBuffer(mFrameSize * cfg.frameCount * 3) + , mMixer(pcmCard) , mPcm(talsa::pcmOpen(pcmCard, pcmDevice, util::countChannels(cfg.channelMask), cfg.sampleRateHz, cfg.frameCount, - true /* isOut */)) {} + true /* isOut */)) { + mConsumeThread = std::thread(&TinyalsaSink::consumeThread, this); + } + + ~TinyalsaSink() { + mConsumeThreadRunning = false; + mConsumeThread.join(); + } Result getPresentationPosition(uint64_t &frames, TimeSpec &ts) override { + const nsecs_t nowNs = systemTime(SYSTEM_TIME_MONOTONIC); + const uint64_t nowFrames = getPresentationFrames(nowNs); + mFrames += (nowFrames - mPreviousFrames); + mPreviousFrames = nowFrames; + frames = mFrames; - ts = util::nsecs2TimeSpec(systemTime(SYSTEM_TIME_MONOTONIC)); + ts = util::nsecs2TimeSpec(nowNs); return Result::OK; } - int write(const void *data, size_t nBytes) override { - const int res = ::pcm_write(mPcm.get(), data, nBytes); - if (res < 0) { - return FAILURE(res); - } else if (res == 0) { - mFrames += ::pcm_bytes_to_frames(mPcm.get(), nBytes); - return nBytes; - } else { - mFrames += ::pcm_bytes_to_frames(mPcm.get(), res); - return res; + uint64_t getPresentationFrames(const nsecs_t nowNs) const { + return uint64_t(mSampleRateHz) * ns2us(nowNs - mStartNs) / 1000000; + } + + uint64_t getAvailableFrames(const nsecs_t nowNs) const { + return getPresentationFrames(nowNs) - mReceivedFrames; + } + + uint64_t getAvailableFramesNow() const { + return getAvailableFrames(systemTime(SYSTEM_TIME_MONOTONIC)); + } + + size_t getWaitFramesNow(const size_t requestedFrames) const { + const size_t availableFrames = getAvailableFramesNow(); + return (requestedFrames > availableFrames) + ? (requestedFrames - availableFrames) : 0; + } + + size_t write(float volume, size_t bytesToWrite, IReader &reader) { + size_t framesLost = 0; + const size_t waitFrames = getWaitFramesNow(bytesToWrite / mFrameSize); + const auto blockUntil = + std::chrono::high_resolution_clock::now() + + + std::chrono::microseconds(waitFrames * 1000000 / mSampleRateHz); + + while (bytesToWrite > 0) { + if (mRingBuffer.waitForProduceAvailable(blockUntil + + std::chrono::microseconds(kMaxJitterUs))) { + auto produceChunk = mRingBuffer.getProduceChunk(); + if (produceChunk.size >= bytesToWrite) { + // Since the ring buffer has more bytes free than we need, + // make sure we are not too early here: tinyalsa is jittery, + // we don't want to go faster than SYSTEM_TIME_MONOTONIC + std::this_thread::sleep_until(blockUntil); + } + + const size_t szFrames = + std::min(produceChunk.size, bytesToWrite) / mFrameSize; + const size_t szBytes = szFrames * mFrameSize; + LOG_ALWAYS_FATAL_IF(reader(produceChunk.data, szBytes) < szBytes); + + aops::multiplyByVolume(volume, + static_cast<int16_t *>(produceChunk.data), + szBytes / sizeof(int16_t)); + + LOG_ALWAYS_FATAL_IF(mRingBuffer.produce(szBytes) < szBytes); + mReceivedFrames += szFrames; + bytesToWrite -= szBytes; + } else { + ALOGW("TinyalsaSink::%s:%d pcm_write was late reading " + "frames, dropping %zu us of audio", + __func__, __LINE__, + size_t(1000000 * bytesToWrite / mFrameSize / mSampleRateHz)); + + // drop old audio to make room for new + const size_t bytesLost = mRingBuffer.makeRoomForProduce(bytesToWrite); + framesLost += bytesLost / mFrameSize; + + while (bytesToWrite > 0) { + auto produceChunk = mRingBuffer.getProduceChunk(); + const size_t szFrames = + std::min(produceChunk.size, bytesToWrite) / mFrameSize; + const size_t szBytes = szFrames * mFrameSize; + LOG_ALWAYS_FATAL_IF(reader(produceChunk.data, szBytes) < szBytes); + + aops::multiplyByVolume(volume, + static_cast<int16_t *>(produceChunk.data), + szBytes / sizeof(int16_t)); + + LOG_ALWAYS_FATAL_IF(mRingBuffer.produce(szBytes) < szBytes); + mReceivedFrames += szFrames; + bytesToWrite -= szBytes; + } + break; + } + } + + return framesLost; + } + + void consumeThread() { + util::setThreadPriority(PRIORITY_URGENT_AUDIO); + std::vector<uint8_t> writeBuffer(mWriteSizeFrames * mFrameSize); + + while (mConsumeThreadRunning) { + if (mRingBuffer.waitForConsumeAvailable( + std::chrono::high_resolution_clock::now() + + std::chrono::microseconds(100000))) { + size_t szBytes; + { + auto chunk = mRingBuffer.getConsumeChunk(); + szBytes = std::min(writeBuffer.size(), chunk.size); + // We have to memcpy because the consumer holds the lock + // into RingBuffer and pcm_write takes too long to hold + // this lock. + memcpy(writeBuffer.data(), chunk.data, szBytes); + LOG_ALWAYS_FATAL_IF(mRingBuffer.consume(chunk, szBytes) < szBytes); + } + + int res = ::pcm_write(mPcm.get(), writeBuffer.data(), szBytes); + if (res < 0) { + ALOGW("TinyalsaSink::%s:%d pcm_write failed with res=%d", + __func__, __LINE__, res); + } + } } } static std::unique_ptr<TinyalsaSink> create(unsigned pcmCard, unsigned pcmDevice, const AudioConfig &cfg, + size_t readerBufferSizeHint, uint64_t &frames) { - auto src = std::make_unique<TinyalsaSink>(pcmCard, pcmDevice, cfg, frames); - if (src->mPcm) { - return src; + (void)readerBufferSizeHint; + auto sink = std::make_unique<TinyalsaSink>(pcmCard, pcmDevice, + cfg, frames); + if (sink->mMixer && sink->mPcm) { + return sink; } else { return FAILURE(nullptr); } } private: + const nsecs_t mStartNs; + const unsigned mSampleRateHz; + const unsigned mFrameSize; + const unsigned mWriteSizeFrames; uint64_t &mFrames; + uint64_t mPreviousFrames = 0; + uint64_t mReceivedFrames = 0; + RingBuffer mRingBuffer; + talsa::Mixer mMixer; talsa::PcmPtr mPcm; + std::thread mConsumeThread; + std::atomic<bool> mConsumeThreadRunning = true; }; struct NullSink : public DevicePortSink { @@ -89,10 +223,20 @@ struct NullSink : public DevicePortSink { return Result::OK; } - int write(const void *, size_t nBytes) override { - simulatePresentationPosition(); - mAvailableFrames += nBytes / mNChannels / sizeof(int16_t); - return nBytes; + size_t write(float volume, size_t bytesToWrite, IReader &reader) override { + (void)volume; + + while (bytesToWrite > 0) { + size_t chunkSize = std::min(bytesToWrite, sizeof(mWriteBuffer)); + chunkSize = reader(mWriteBuffer, chunkSize); + if (chunkSize > 0) { + bytesToWrite -= chunkSize; + } else { + break; // reader failed + } + } + + return 0; } void simulatePresentationPosition() { @@ -111,7 +255,9 @@ struct NullSink : public DevicePortSink { } static std::unique_ptr<NullSink> create(const AudioConfig &cfg, + size_t readerBufferSizeHint, uint64_t &frames) { + (void)readerBufferSizeHint; return std::make_unique<NullSink>(cfg, frames); } @@ -121,12 +267,14 @@ private: const unsigned mNChannels; uint64_t mAvailableFrames = 0; nsecs_t mTimestamp; + char mWriteBuffer[1024]; }; } // namespace std::unique_ptr<DevicePortSink> -DevicePortSink::create(const DeviceAddress &address, +DevicePortSink::create(size_t readerBufferSizeHint, + const DeviceAddress &address, const AudioConfig &cfg, const hidl_bitfield<AudioOutputFlag> &flags, uint64_t &frames) { @@ -140,12 +288,13 @@ DevicePortSink::create(const DeviceAddress &address, switch (address.device) { case AudioDevice::OUT_SPEAKER: return TinyalsaSink::create(talsa::kPcmCard, talsa::kPcmDevice, - cfg, frames); + cfg, readerBufferSizeHint, frames); case AudioDevice::OUT_TELEPHONY_TX: - return NullSink::create(cfg, frames); + return NullSink::create(cfg, readerBufferSizeHint, frames); default: + ALOGE("%s:%d unsupported device: %x", __func__, __LINE__, address.device); return FAILURE(nullptr); } } diff --git a/audio/device_port_sink.h b/audio/device_port_sink.h index 5714cd06..5159b509 100644 --- a/audio/device_port_sink.h +++ b/audio/device_port_sink.h @@ -18,6 +18,7 @@ #include <memory> #include <android/hardware/audio/common/6.0/types.h> #include <android/hardware/audio/6.0/types.h> +#include "ireader.h" namespace android { namespace hardware { @@ -31,9 +32,10 @@ using namespace ::android::hardware::audio::V6_0; struct DevicePortSink { virtual ~DevicePortSink() {} virtual Result getPresentationPosition(uint64_t &frames, TimeSpec &ts) = 0; - virtual int write(const void *data, size_t nBytes) = 0; + virtual size_t write(float volume, size_t bytesToWrite, IReader &) = 0; - static std::unique_ptr<DevicePortSink> create(const DeviceAddress &, + static std::unique_ptr<DevicePortSink> create(size_t readerBufferSizeHint, + const DeviceAddress &, const AudioConfig &, const hidl_bitfield<AudioOutputFlag> &, uint64_t &frames); diff --git a/audio/device_port_source.cpp b/audio/device_port_source.cpp index 24c3f704..3bdb766a 100644 --- a/audio/device_port_source.cpp +++ b/audio/device_port_source.cpp @@ -17,12 +17,16 @@ #include <cmath> #include <chrono> #include <thread> +#include <unistd.h> #include <audio_utils/channels.h> #include <audio_utils/format.h> #include <log/log.h> +#include <utils/ThreadDefs.h> #include <utils/Timers.h> #include "device_port_source.h" #include "talsa.h" +#include "ring_buffer.h" +#include "audio_ops.h" #include "util.h" #include "debug.h" @@ -34,41 +38,156 @@ namespace implementation { namespace { +constexpr int kMaxJitterUs = 3000; // Enforced by CTS, should be <= 6ms + struct TinyalsaSource : public DevicePortSource { TinyalsaSource(unsigned pcmCard, unsigned pcmDevice, const AudioConfig &cfg, uint64_t &frames) - : mFrames(frames) + : mStartNs(systemTime(SYSTEM_TIME_MONOTONIC)) + , mSampleRateHz(cfg.sampleRateHz) + , mFrameSize(util::countChannels(cfg.channelMask) * sizeof(int16_t)) + , mReadSizeFrames(cfg.frameCount) + , mFrames(frames) + , mRingBuffer(mFrameSize * cfg.frameCount * 3) + , mMixer(pcmCard) , mPcm(talsa::pcmOpen(pcmCard, pcmDevice, util::countChannels(cfg.channelMask), cfg.sampleRateHz, cfg.frameCount, - false /* isOut */)) {} + false /* isOut */)) { + mProduceThread = std::thread(&TinyalsaSource::producerThread, this); + } + + ~TinyalsaSource() { + mProduceThreadRunning = false; + mProduceThread.join(); + } Result getCapturePosition(uint64_t &frames, uint64_t &time) override { + const nsecs_t nowNs = systemTime(SYSTEM_TIME_MONOTONIC); + const uint64_t nowFrames = getCaptureFrames(nowNs); + mFrames += (nowFrames - mPreviousFrames); + mPreviousFrames = nowFrames; + frames = mFrames; - time = systemTime(SYSTEM_TIME_MONOTONIC); + time = nowNs; return Result::OK; } - int read(void *data, size_t toReadBytes) override { - const int res = ::pcm_read(mPcm.get(), data, toReadBytes); + uint64_t getCaptureFrames(const nsecs_t nowNs) const { + return uint64_t(mSampleRateHz) * ns2us(nowNs - mStartNs) / 1000000; + } + + uint64_t getAvailableFrames(const nsecs_t nowNs) const { + return getCaptureFrames(nowNs) - mSentFrames; + } + + uint64_t getAvailableFramesNow() const { + return getAvailableFrames(systemTime(SYSTEM_TIME_MONOTONIC)); + } + + size_t getWaitFramesNow(const size_t requestedFrames) const { + const size_t availableFrames = getAvailableFramesNow(); + return (requestedFrames > availableFrames) + ? (requestedFrames - availableFrames) : 0; + } + + size_t read(float volume, size_t bytesToRead, IWriter &writer) override { + const size_t waitFrames = getWaitFramesNow(bytesToRead / mFrameSize); + const auto blockUntil = + std::chrono::high_resolution_clock::now() + + + std::chrono::microseconds(waitFrames * 1000000 / mSampleRateHz); + + while (bytesToRead > 0) { + if (mRingBuffer.waitForConsumeAvailable(blockUntil + + std::chrono::microseconds(kMaxJitterUs))) { + if (mRingBuffer.availableToConsume() >= bytesToRead) { + // Since the ring buffer has all bytes we need, make sure we + // are not too early here: tinyalsa is jittery, we don't + // want to go faster than SYSTEM_TIME_MONOTONIC + std::this_thread::sleep_until(blockUntil); + } + + auto chunk = mRingBuffer.getConsumeChunk(); + const size_t writeBufSzBytes = std::min(chunk.size, bytesToRead); + + aops::multiplyByVolume(volume, + static_cast<int16_t *>(chunk.data), + writeBufSzBytes / sizeof(int16_t)); + + writer(chunk.data, writeBufSzBytes); + LOG_ALWAYS_FATAL_IF(mRingBuffer.consume(chunk, writeBufSzBytes) < writeBufSzBytes); + + bytesToRead -= writeBufSzBytes; + mSentFrames += writeBufSzBytes / mFrameSize; + } else { + ALOGW("TinyalsaSource::%s:%d pcm_read was late delivering " + "frames, inserting %zu us of silence", + __func__, __LINE__, + size_t(1000000 * bytesToRead / mFrameSize / mSampleRateHz)); + + static const uint8_t zeroes[256] = {0}; + + while (bytesToRead > 0) { + const size_t nZeroFrames = + std::min(bytesToRead, sizeof(zeroes)) / mFrameSize; + const size_t nZeroBytes = nZeroFrames * mFrameSize; + + writer(zeroes, nZeroBytes); + mSentFrames += nZeroFrames; + bytesToRead -= nZeroBytes; + } + break; + } + } + + return mFramesLost.exchange(0); + } + + void producerThread() { + util::setThreadPriority(PRIORITY_URGENT_AUDIO); + std::vector<uint8_t> readBuf(mReadSizeFrames * mFrameSize); + + while (mProduceThreadRunning) { + const size_t bytesLost = mRingBuffer.makeRoomForProduce(readBuf.size()); + mFramesLost += bytesLost / mFrameSize; + + auto produceChunk = mRingBuffer.getProduceChunk(); + if (produceChunk.size < readBuf.size()) { + const size_t sz = doRead(readBuf.data(), readBuf.size()); + if (sz > 0) { + LOG_ALWAYS_FATAL_IF(mRingBuffer.produce(readBuf.data(), sz) < sz); + } + } else { + const size_t sz = doRead(produceChunk.data, readBuf.size()); + if (sz > 0) { + LOG_ALWAYS_FATAL_IF(mRingBuffer.produce(readBuf.size()) < sz); + } + } + } + } + + size_t doRead(void *dst, size_t sz) { + const int res = ::pcm_read(mPcm.get(), dst, sz); if (res < 0) { - return FAILURE(res); - } else if (res == 0) { - mFrames += ::pcm_bytes_to_frames(mPcm.get(), toReadBytes); - return toReadBytes; - } else { - mFrames += ::pcm_bytes_to_frames(mPcm.get(), res); - return res; + ALOGW("TinyalsaSource::%s:%d pcm_read failed with res=%d", + __func__, __LINE__, res); + return 0; } + + return sz; } static std::unique_ptr<TinyalsaSource> create(unsigned pcmCard, unsigned pcmDevice, const AudioConfig &cfg, + size_t writerBufferSizeHint, uint64_t &frames) { - auto src = std::make_unique<TinyalsaSource>(pcmCard, pcmDevice, cfg, frames); - if (src->mPcm) { + (void)writerBufferSizeHint; + + auto src = std::make_unique<TinyalsaSource>(pcmCard, pcmDevice, + cfg, frames); + if (src->mMixer && src->mPcm) { return src; } else { return FAILURE(nullptr); @@ -76,13 +195,28 @@ struct TinyalsaSource : public DevicePortSource { } private: + const nsecs_t mStartNs; + const unsigned mSampleRateHz; + const unsigned mFrameSize; + const unsigned mReadSizeFrames; uint64_t &mFrames; + uint64_t mPreviousFrames = 0; + uint64_t mSentFrames = 0; + std::atomic<uint32_t> mFramesLost = 0; + RingBuffer mRingBuffer; + talsa::Mixer mMixer; talsa::PcmPtr mPcm; + std::thread mProduceThread; + std::atomic<bool> mProduceThreadRunning = true; }; template <class G> struct GeneratedSource : public DevicePortSource { - GeneratedSource(const AudioConfig &cfg, uint64_t &frames, G generator) - : mFrames(frames) + GeneratedSource(const AudioConfig &cfg, + size_t writerBufferSizeHint, + uint64_t &frames, + G generator) + : mWriteBuffer(writerBufferSizeHint / sizeof(int16_t)) + , mFrames(frames) , mStartNs(systemTime(SYSTEM_TIME_MONOTONIC)) , mSampleRateHz(cfg.sampleRateHz) , mNChannels(util::countChannels(cfg.channelMask)) @@ -90,7 +224,7 @@ template <class G> struct GeneratedSource : public DevicePortSource { Result getCapturePosition(uint64_t &frames, uint64_t &time) override { const nsecs_t nowNs = systemTime(SYSTEM_TIME_MONOTONIC); - const uint64_t nowFrames = getNowFrames(nowNs); + const uint64_t nowFrames = getCaptureFrames(nowNs); mFrames += (nowFrames - mPreviousFrames); mPreviousFrames = nowFrames; frames = mFrames; @@ -98,19 +232,25 @@ template <class G> struct GeneratedSource : public DevicePortSource { return Result::OK; } - uint64_t getNowFrames(const nsecs_t nowNs) const { - return uint64_t(mSampleRateHz) * ns2ms(nowNs - mStartNs) / 1000; + uint64_t getCaptureFrames(const nsecs_t nowNs) const { + return uint64_t(mSampleRateHz) * ns2us(nowNs - mStartNs) / 1000000; } - int read(void *data, size_t toReadBytes) override { - int16_t *samples = static_cast<int16_t *>(data); + uint64_t getAvailableFrames(const nsecs_t nowNs) const { + return getCaptureFrames(nowNs) - mSentFrames; + } + + size_t read(float volume, size_t bytesToRead, IWriter &writer) override { + mWriteBuffer.resize(bytesToRead / sizeof(int16_t)); + + int16_t *samples = mWriteBuffer.data(); const unsigned nChannels = mNChannels; - const unsigned requestedFrames = toReadBytes / nChannels / sizeof(*samples); + const unsigned requestedFrames = bytesToRead / nChannels / sizeof(*samples); unsigned availableFrames; while (true) { const nsecs_t nowNs = systemTime(SYSTEM_TIME_MONOTONIC); - availableFrames = getNowFrames(nowNs) - mSentFrames; + availableFrames = getAvailableFrames(nowNs); if (availableFrames < requestedFrames / 2) { const unsigned neededMoreFrames = requestedFrames / 2 - availableFrames; @@ -128,12 +268,18 @@ template <class G> struct GeneratedSource : public DevicePortSource { adjust_channels(samples, 1, samples, nChannels, sizeof(*samples), sizeBytes); } - mSentFrames += nFrames; - return sizeBytes; + + aops::multiplyByVolume(volume, + mWriteBuffer.data(), + sizeBytes / sizeof(int16_t)); + + writer(mWriteBuffer.data(), sizeBytes); + return 0; } private: + std::vector<int16_t> mWriteBuffer; uint64_t &mFrames; const nsecs_t mStartNs; const unsigned mSampleRateHz; @@ -236,14 +382,21 @@ std::vector<float> generateSinePattern(uint32_t sampleRateHz, } template <class G> std::unique_ptr<GeneratedSource<G>> -createGeneratedSource(const AudioConfig &cfg, uint64_t &frames, G generator) { - return std::make_unique<GeneratedSource<G>>(cfg, frames, std::move(generator)); +createGeneratedSource(const AudioConfig &cfg, + size_t writerBufferSizeHint, + uint64_t &frames, + G generator) { + return std::make_unique<GeneratedSource<G>>(cfg, + writerBufferSizeHint, + frames, + std::move(generator)); } } // namespace std::unique_ptr<DevicePortSource> -DevicePortSource::create(const DeviceAddress &address, +DevicePortSource::create(size_t writerBufferSizeHint, + const DeviceAddress &address, const AudioConfig &cfg, const hidl_bitfield<AudioOutputFlag> &flags, uint64_t &frames) { @@ -257,18 +410,19 @@ DevicePortSource::create(const DeviceAddress &address, switch (address.device) { case AudioDevice::IN_BUILTIN_MIC: return TinyalsaSource::create(talsa::kPcmCard, talsa::kPcmDevice, - cfg, frames); + cfg, writerBufferSizeHint, frames); case AudioDevice::IN_TELEPHONY_RX: - return createGeneratedSource(cfg, frames, + return createGeneratedSource(cfg, writerBufferSizeHint, frames, BusySignalGenerator(cfg.sampleRateHz)); case AudioDevice::IN_FM_TUNER: return createGeneratedSource( - cfg, frames, + cfg, writerBufferSizeHint, frames, RepeatGenerator(generateSinePattern(cfg.sampleRateHz, 440.0, 1.0))); default: + ALOGE("%s:%d unsupported device: %x", __func__, __LINE__, address.device); return FAILURE(nullptr); } } diff --git a/audio/device_port_source.h b/audio/device_port_source.h index 3cc39ffe..16b5d27c 100644 --- a/audio/device_port_source.h +++ b/audio/device_port_source.h @@ -18,6 +18,7 @@ #include <memory> #include <android/hardware/audio/common/6.0/types.h> #include <android/hardware/audio/6.0/types.h> +#include "iwriter.h" namespace android { namespace hardware { @@ -31,9 +32,10 @@ using namespace ::android::hardware::audio::V6_0; struct DevicePortSource { virtual ~DevicePortSource() {} virtual Result getCapturePosition(uint64_t &frames, uint64_t &time) = 0; - virtual int read(void *data, size_t nBytes) = 0; + virtual size_t read(float volume, size_t bytesToRead, IWriter &) = 0; - static std::unique_ptr<DevicePortSource> create(const DeviceAddress &, + static std::unique_ptr<DevicePortSource> create(size_t writerBufferSizeHint, + const DeviceAddress &, const AudioConfig &, const hidl_bitfield<AudioOutputFlag> &, uint64_t &frames); diff --git a/audio/ireader.h b/audio/ireader.h new file mode 100644 index 00000000..cb20e2b6 --- /dev/null +++ b/audio/ireader.h @@ -0,0 +1,35 @@ +/* + * Copyright (C) 2020 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. + */ + +#pragma once +#include <stdint.h> + +namespace android { +namespace hardware { +namespace audio { +namespace V6_0 { +namespace implementation { + +struct IReader { + virtual ~IReader() {} + virtual size_t operator()(void* dst, size_t szBytes) = 0; +}; + +} // namespace implementation +} // namespace V6_0 +} // namespace audio +} // namespace hardware +} // namespace android diff --git a/audio/iwriter.h b/audio/iwriter.h new file mode 100644 index 00000000..d204ab1e --- /dev/null +++ b/audio/iwriter.h @@ -0,0 +1,35 @@ +/* + * Copyright (C) 2020 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. + */ + +#pragma once +#include <stdint.h> + +namespace android { +namespace hardware { +namespace audio { +namespace V6_0 { +namespace implementation { + +struct IWriter { + virtual ~IWriter() {} + virtual size_t operator()(const void* src, size_t szBytes) = 0; +}; + +} // namespace implementation +} // namespace V6_0 +} // namespace audio +} // namespace hardware +} // namespace android diff --git a/audio/policy/r_submix_audio_policy_configuration.xml b/audio/policy/r_submix_audio_policy_configuration.xml deleted file mode 100644 index f74185e3..00000000 --- a/audio/policy/r_submix_audio_policy_configuration.xml +++ /dev/null @@ -1,47 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- Copyright (C) 2020 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. ---> -<!-- Remote Submix Audio Policy Configuration file --> -<module name="r_submix" halVersion="2.0"> - <attachedDevices> - <item>Remote Submix In</item> - </attachedDevices> - <mixPorts> - <mixPort name="r_submix output" role="source"> - <profile name="" format="AUDIO_FORMAT_PCM_16_BIT" - samplingRates="44100" channelMasks="AUDIO_CHANNEL_OUT_STEREO"/> - </mixPort> - <mixPort name="r_submix input" role="sink"> - <profile name="" format="AUDIO_FORMAT_PCM_16_BIT" - samplingRates="44100" channelMasks="AUDIO_CHANNEL_IN_STEREO"/> - </mixPort> - </mixPorts> - <devicePorts> - <devicePort tagName="Remote Submix Out" type="AUDIO_DEVICE_OUT_REMOTE_SUBMIX" role="sink"> - <profile name="" format="AUDIO_FORMAT_PCM_16_BIT" - samplingRates="44100" channelMasks="AUDIO_CHANNEL_OUT_STEREO"/> - </devicePort> - <devicePort tagName="Remote Submix In" type="AUDIO_DEVICE_IN_REMOTE_SUBMIX" role="source"> - <profile name="" format="AUDIO_FORMAT_PCM_16_BIT" - samplingRates="44100" channelMasks="AUDIO_CHANNEL_IN_STEREO"/> - </devicePort> - </devicePorts> - <routes> - <route type="mix" sink="Remote Submix Out" - sources="r_submix output"/> - <route type="mix" sink="r_submix input" - sources="Remote Submix In"/> - </routes> -</module> diff --git a/audio/primary_device.cpp b/audio/primary_device.cpp index 251c7d32..3ba4bf8f 100644 --- a/audio/primary_device.cpp +++ b/audio/primary_device.cpp @@ -33,23 +33,10 @@ constexpr size_t kOutBufferDurationMs = 22; using ::android::hardware::Void; -PrimaryDevice::PrimaryDevice() - : mMixer(talsa::mixerOpen(talsa::kPcmDevice)) { - if (mMixer) { - mMixerMasterVolumeCtl = mixer_get_ctl_by_name(mMixer.get(), "Master Playback Volume"); - mMixerCaptureVolumeCtl = mixer_get_ctl_by_name(mMixer.get(), "Capture Volume"); - mMixerMasterPaybackSwitchCtl = mixer_get_ctl_by_name(mMixer.get(), "Master Playback Switch"); - mMixerCaptureSwitchCtl = mixer_get_ctl_by_name(mMixer.get(), "Capture Switch"); - - talsa::mixerSetPercentAll(mMixerMasterVolumeCtl, 100); - talsa::mixerSetPercentAll(mMixerCaptureVolumeCtl, 100); - talsa::mixerSetValueAll(mMixerMasterPaybackSwitchCtl, 1); - talsa::mixerSetValueAll(mMixerCaptureSwitchCtl, 1); - } -} +PrimaryDevice::PrimaryDevice() {} Return<Result> PrimaryDevice::initCheck() { - return mMixer ? Result::OK : FAILURE(Result::NOT_INITIALIZED); + return Result::OK; } Return<Result> PrimaryDevice::setMasterVolume(float volume) { @@ -57,61 +44,35 @@ Return<Result> PrimaryDevice::setMasterVolume(float volume) { return FAILURE(Result::INVALID_ARGUMENTS); } - if (!mMixerMasterVolumeCtl) { - return FAILURE(Result::INVALID_STATE); - } - - talsa::mixerSetPercentAll(mMixerMasterVolumeCtl, int(100 * volume)); mMasterVolume = volume; + updateOutputStreamVolume(mMasterMute ? 0.0f : volume); return Result::OK; } Return<void> PrimaryDevice::getMasterVolume(getMasterVolume_cb _hidl_cb) { - if (mMixerMasterVolumeCtl) { - _hidl_cb(Result::OK, mMasterVolume); - } else { - _hidl_cb(FAILURE(Result::INVALID_STATE), 0); - } - + _hidl_cb(Result::OK, mMasterVolume); return Void(); } Return<Result> PrimaryDevice::PrimaryDevice::setMicMute(bool mute) { - if (mMixerCaptureSwitchCtl) { - talsa::mixerSetValueAll(mMixerCaptureSwitchCtl, mute ? 0 : 1); - return Result::OK; - } else { - return FAILURE(Result::INVALID_STATE); - } + mMicMute = mute; + updateInputStreamMicMute(mute); + return Result::OK; } Return<void> PrimaryDevice::getMicMute(getMicMute_cb _hidl_cb) { - if (mMixerCaptureSwitchCtl) { - const int value = mixer_ctl_get_value(mMixerCaptureSwitchCtl, 0); - _hidl_cb(Result::OK, value == 0); - } else { - _hidl_cb(FAILURE(Result::INVALID_STATE), 0); - } + _hidl_cb(Result::OK, mMicMute); return Void(); } Return<Result> PrimaryDevice::setMasterMute(bool mute) { - if (mMixerMasterPaybackSwitchCtl) { - talsa::mixerSetValueAll(mMixerMasterPaybackSwitchCtl, mute ? 0 : 1); - return Result::OK; - } else { - return FAILURE(Result::INVALID_STATE); - } + mMasterMute = mute; + updateOutputStreamVolume(mute ? 0.0f : mMasterVolume); + return Result::OK; } Return<void> PrimaryDevice::getMasterMute(getMasterMute_cb _hidl_cb) { - if (mMixerMasterPaybackSwitchCtl) { - const int value = mixer_ctl_get_value(mMixerMasterPaybackSwitchCtl, 0); - _hidl_cb(Result::OK, value == 0); - } else { - _hidl_cb(FAILURE(Result::NOT_SUPPORTED), 0); - } - + _hidl_cb(Result::OK, mMasterMute); return Void(); } @@ -141,11 +102,17 @@ Return<void> PrimaryDevice::openOutputStream(int32_t ioHandle, openOutputStream_cb _hidl_cb) { AudioConfig suggestedConfig; if (util::checkAudioConfig(true, kOutBufferDurationMs, config, suggestedConfig)) { - ++mNStreams; - _hidl_cb(Result::OK, - new StreamOut(this, &unrefDevice, - ioHandle, device, suggestedConfig, flags, sourceMetadata), - config); + auto stream = std::make_unique<StreamOut>( + this, ioHandle, device, suggestedConfig, flags, sourceMetadata); + + stream->setMasterVolume(mMasterMute ? 0.0f : mMasterVolume); + + { + std::lock_guard<std::mutex> guard(mMutex); + LOG_ALWAYS_FATAL_IF(!mOutputStreams.insert(stream.get()).second); + } + + _hidl_cb(Result::OK, stream.release(), config); } else { ALOGE("PrimaryDevice::%s:%d failed", __func__, __LINE__); _hidl_cb(FAILURE(Result::INVALID_ARGUMENTS), nullptr, suggestedConfig); @@ -162,11 +129,17 @@ Return<void> PrimaryDevice::openInputStream(int32_t ioHandle, openInputStream_cb _hidl_cb) { AudioConfig suggestedConfig; if (util::checkAudioConfig(false, kInBufferDurationMs, config, suggestedConfig)) { - ++mNStreams; - _hidl_cb(Result::OK, - new StreamIn(this, &unrefDevice, - ioHandle, device, suggestedConfig, flags, sinkMetadata), - config); + auto stream = std::make_unique<StreamIn>( + this, ioHandle, device, suggestedConfig, flags, sinkMetadata); + + stream->setMicMute(mMicMute); + + { + std::lock_guard<std::mutex> guard(mMutex); + LOG_ALWAYS_FATAL_IF(!mInputStreams.insert(stream.get()).second); + } + + _hidl_cb(Result::OK, stream.release(), config); } else { ALOGE("PrimaryDevice::%s:%d failed", __func__, __LINE__); _hidl_cb(FAILURE(Result::INVALID_ARGUMENTS), nullptr, suggestedConfig); @@ -204,6 +177,29 @@ Return<void> PrimaryDevice::createAudioPatch(const hidl_vec<AudioPortConfig>& so return Void(); } +Return<void> PrimaryDevice::updateAudioPatch(AudioPatchHandle previousPatchHandle, + const hidl_vec<AudioPortConfig>& sources, + const hidl_vec<AudioPortConfig>& sinks, + updateAudioPatch_cb _hidl_cb) { + const auto i = mAudioPatches.find(previousPatchHandle); + if (i == mAudioPatches.end()) { + _hidl_cb(FAILURE(Result::INVALID_ARGUMENTS), previousPatchHandle); + } else { + if (sources.size() == 1 && sinks.size() == 1) { + AudioPatch patch; + patch.source = sources[0]; + patch.sink = sinks[0]; + i->second = patch; + + _hidl_cb(Result::OK, previousPatchHandle); + } else { + _hidl_cb(Result::NOT_SUPPORTED, previousPatchHandle); + } + } + + return Void(); +} + Return<Result> PrimaryDevice::releaseAudioPatch(AudioPatchHandle patchHandle) { return (mAudioPatches.erase(patchHandle) == 1) ? Result::OK : FAILURE(Result::INVALID_ARGUMENTS); } @@ -259,18 +255,10 @@ Return<Result> PrimaryDevice::setConnectedState(const DeviceAddress& dev_addr, b } Return<Result> PrimaryDevice::close() { - if (mNStreams > 0) { - return FAILURE(Result::INVALID_STATE); - } else if (mMixer) { - mMixerMasterVolumeCtl = nullptr; - mMixerCaptureVolumeCtl = nullptr; - mMixerMasterPaybackSwitchCtl = nullptr; - mMixerCaptureSwitchCtl = nullptr; - mMixer.reset(); - return Result::OK; - } else { - return FAILURE(Result::INVALID_STATE); - } + std::lock_guard<std::mutex> guard(mMutex); + + return (mInputStreams.empty() && mOutputStreams.empty()) + ? Result::OK : FAILURE(Result::INVALID_STATE); } Return<Result> PrimaryDevice::addDeviceEffect(AudioPortHandle device, uint64_t effectId) { @@ -372,12 +360,28 @@ Return<Result> PrimaryDevice::updateRotation(IPrimaryDevice::Rotation rotation) return FAILURE(Result::NOT_SUPPORTED); } -void PrimaryDevice::unrefDevice(IDevice *dev) { - static_cast<PrimaryDevice *>(dev)->unrefDeviceImpl(); +void PrimaryDevice::unrefDevice(StreamIn *sin) { + std::lock_guard<std::mutex> guard(mMutex); + LOG_ALWAYS_FATAL_IF(mInputStreams.erase(sin) < 1); } -void PrimaryDevice::unrefDeviceImpl() { - LOG_ALWAYS_FATAL_IF(--mNStreams < 0); +void PrimaryDevice::unrefDevice(StreamOut *sout) { + std::lock_guard<std::mutex> guard(mMutex); + LOG_ALWAYS_FATAL_IF(mOutputStreams.erase(sout) < 1); +} + +void PrimaryDevice::updateOutputStreamVolume(float masterVolume) const { + std::lock_guard<std::mutex> guard(mMutex); + for (StreamOut *stream : mOutputStreams) { + stream->setMasterVolume(masterVolume); + } +} + +void PrimaryDevice::updateInputStreamMicMute(bool micMute) const { + std::lock_guard<std::mutex> guard(mMutex); + for (StreamIn *stream : mInputStreams) { + stream->setMicMute(micMute); + } } } // namespace implementation diff --git a/audio/primary_device.h b/audio/primary_device.h index 32fa90a3..2a956806 100644 --- a/audio/primary_device.h +++ b/audio/primary_device.h @@ -16,9 +16,9 @@ #pragma once #include <android/hardware/audio/6.0/IPrimaryDevice.h> -#include <atomic> +#include <mutex> #include <unordered_map> -#include "talsa.h" +#include <unordered_set> namespace android { namespace hardware { @@ -35,6 +35,9 @@ using ::android::hardware::Return; using namespace ::android::hardware::audio::common::V6_0; using namespace ::android::hardware::audio::V6_0; +struct StreamIn; +struct StreamOut; + struct PrimaryDevice : public IPrimaryDevice { PrimaryDevice(); @@ -63,6 +66,10 @@ struct PrimaryDevice : public IPrimaryDevice { Return<void> createAudioPatch(const hidl_vec<AudioPortConfig>& sources, const hidl_vec<AudioPortConfig>& sinks, createAudioPatch_cb _hidl_cb) override; + Return<void> updateAudioPatch(AudioPatchHandle previousPatch, + const hidl_vec<AudioPortConfig>& sources, + const hidl_vec<AudioPortConfig>& sinks, + updateAudioPatch_cb _hidl_cb) override; Return<Result> releaseAudioPatch(AudioPatchHandle patch) override; Return<void> getAudioPort(const AudioPort& port, getAudioPort_cb _hidl_cb) override; Return<Result> setAudioPortConfig(const AudioPortConfig& config) override; @@ -96,16 +103,13 @@ struct PrimaryDevice : public IPrimaryDevice { Return<Result> updateRotation(IPrimaryDevice::Rotation rotation) override; private: - static void unrefDevice(IDevice*); - void unrefDeviceImpl(); + friend StreamIn; + friend StreamOut; - talsa::MixerPtr mMixer; - talsa::mixer_ctl_t *mMixerMasterVolumeCtl = nullptr; - talsa::mixer_ctl_t *mMixerCaptureVolumeCtl = nullptr; - talsa::mixer_ctl_t *mMixerMasterPaybackSwitchCtl = nullptr; - talsa::mixer_ctl_t *mMixerCaptureSwitchCtl = nullptr; - float mMasterVolume = 1.0f; - std::atomic<int> mNStreams = 0; + void unrefDevice(StreamIn *); + void unrefDevice(StreamOut *); + void updateOutputStreamVolume(float masterVolume) const; + void updateInputStreamMicMute(bool micMute) const; struct AudioPatch { AudioPortConfig source; @@ -114,6 +118,14 @@ private: AudioPatchHandle mNextAudioPatchHandle = 0; std::unordered_map<AudioPatchHandle, AudioPatch> mAudioPatches; + + std::unordered_set<StreamIn *> mInputStreams; // requires mMutex + std::unordered_set<StreamOut *> mOutputStreams; // requires mMutex + mutable std::mutex mMutex; + + float mMasterVolume = 1.0f; + bool mMasterMute = false; + bool mMicMute = false; }; } // namespace implementation diff --git a/audio/ring_buffer.cpp b/audio/ring_buffer.cpp new file mode 100644 index 00000000..b2cc8c4f --- /dev/null +++ b/audio/ring_buffer.cpp @@ -0,0 +1,155 @@ +/* + * Copyright (C) 2020 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 <log/log.h> +#include "ring_buffer.h" + +namespace android { +namespace hardware { +namespace audio { +namespace V6_0 { +namespace implementation { + +RingBuffer::RingBuffer(size_t capacity) + : mBuffer(new uint8_t[capacity]) + , mCapacity(capacity) {} + +size_t RingBuffer::availableToProduce() const { + std::lock_guard<std::mutex> guard(mMutex); + return mCapacity - mAvailableToConsume; +} + +size_t RingBuffer::availableToConsume() const { + std::unique_lock<std::mutex> lock(mMutex); + return mAvailableToConsume; +} + +size_t RingBuffer::makeRoomForProduce(size_t atLeast) { + std::unique_lock<std::mutex> lock(mMutex); + LOG_ALWAYS_FATAL_IF(atLeast >= mCapacity); + + const size_t toProduce = mCapacity - mAvailableToConsume; + const size_t toDrop = (atLeast <= toProduce) + ? 0 : atLeast - toProduce; + + mConsumePos = (mConsumePos + toDrop) % mCapacity; + mAvailableToConsume -= toDrop; + + return toDrop; +} + +bool RingBuffer::waitForProduceAvailable(Timepoint blockUntil) const { + std::unique_lock<std::mutex> lock(mMutex); + while (true) { + if (mAvailableToConsume < mCapacity) { + return true; + } else if (mProduceAvailable.wait_until(lock, blockUntil) == std::cv_status::timeout) { + return false; + } + } +} + +RingBuffer::ContiniousChunk RingBuffer::getProduceChunk() const { + std::unique_lock<std::mutex> lock(mMutex); + const int availableToProduce = mCapacity - mAvailableToConsume; + + ContiniousChunk chunk; + + chunk.data = &mBuffer[mProducePos]; + chunk.size = (mProducePos >= mConsumePos) + ? std::min(mCapacity - mProducePos, availableToProduce) + : std::min(mConsumePos - mProducePos, availableToProduce); + + return chunk; +} + +size_t RingBuffer::produce(size_t size) { + std::unique_lock<std::mutex> lock(mMutex); + const int availableToProduce = mCapacity - mAvailableToConsume; + size = std::min(size, size_t(availableToProduce)); + + mProducePos = (mProducePos + size) % mCapacity; + mAvailableToConsume += size; + + mConsumeAvailable.notify_one(); + return size; +} + +size_t RingBuffer::produce(const void *srcRaw, size_t size) { + std::unique_lock<std::mutex> lock(mMutex); + int produceSize = std::min(mCapacity - mAvailableToConsume, int(size)); + size = produceSize; + const uint8_t *src = static_cast<const uint8_t *>(srcRaw); + + while (produceSize > 0) { + const int availableToProduce = mCapacity - mAvailableToConsume; + const int chunkSz = (mProducePos >= mConsumePos) + ? std::min(mCapacity - mProducePos, availableToProduce) + : std::min(mConsumePos - mProducePos, availableToProduce); + void *dst = &mBuffer[mProducePos]; + + memcpy(dst, src, chunkSz); + src += chunkSz; + mProducePos = (mProducePos + chunkSz) % mCapacity; + mAvailableToConsume += chunkSz; + produceSize -= chunkSz; + } + + mConsumeAvailable.notify_one(); + return size; +} + +bool RingBuffer::waitForConsumeAvailable(Timepoint blockUntil) const { + std::unique_lock<std::mutex> lock(mMutex); + while (true) { + if (mAvailableToConsume > 0) { + return true; + } else if (mConsumeAvailable.wait_until(lock, blockUntil) == std::cv_status::timeout) { + return false; + } + } +} + +RingBuffer::ContiniousLockedChunk RingBuffer::getConsumeChunk() const { + std::unique_lock<std::mutex> lock(mMutex); + + ContiniousLockedChunk chunk; + + chunk.data = &mBuffer[mConsumePos]; + chunk.size = (mConsumePos >= mProducePos) + ? std::min(mCapacity - mConsumePos, mAvailableToConsume) + : std::min(mProducePos - mConsumePos, mAvailableToConsume); + chunk.lock = std::move(lock); + + return chunk; +} + +size_t RingBuffer::consume(const ContiniousLockedChunk &lock, size_t size) { + (void)lock; // the lock is provided by getConsumeChunk + size = std::min(size, size_t(mAvailableToConsume)); + + mConsumePos = (mConsumePos + size) % mCapacity; + mAvailableToConsume -= size; + + mProduceAvailable.notify_one(); + return size; +} + +} // namespace implementation +} // namespace V6_0 +} // namespace audio +} // namespace hardware +} // namespace android diff --git a/audio/ring_buffer.h b/audio/ring_buffer.h new file mode 100644 index 00000000..41916779 --- /dev/null +++ b/audio/ring_buffer.h @@ -0,0 +1,102 @@ +/* + * Copyright (C) 2020 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. + */ + +#pragma once +#include <memory> +#include <chrono> +#include <utility> +#include <condition_variable> +#include <mutex> +#include <stdint.h> + +namespace android { +namespace hardware { +namespace audio { +namespace V6_0 { +namespace implementation { + +// A one-producer-one-consumer ring buffer. +struct RingBuffer { + typedef std::chrono::time_point<std::chrono::high_resolution_clock> Timepoint; + + RingBuffer(size_t capacity); + + size_t capacity() const { return mCapacity; } + size_t availableToProduce() const; + size_t availableToConsume() const; + + struct ContiniousChunk { + void *data; + size_t size; + std::unique_lock<std::mutex> lock; + }; + + struct ContiniousLockedChunk : public ContiniousChunk{ + std::unique_lock<std::mutex> lock; + }; + + size_t makeRoomForProduce(size_t atLeast); + + bool waitForProduceAvailable(Timepoint blockUntil) const; + + // `getProduceChunk` is a non-blocking function which returns a pointer + // (`result.data`) inside RingBuffer's buffer, `result.size` is the + // size of the continious chunk (can be smaller than availableToProduce()). + ContiniousChunk getProduceChunk() const; + + // Tries to move the `produce` cursor by `size`, returns the actual size + // moved. + size_t produce(size_t size); + + // Tried to write `size` bytes into the internal buffer from `data`, + // returns the actual size written. + size_t produce(const void *data, size_t size); + + bool waitForConsumeAvailable(Timepoint blockUntil) const; + + // `getConsumeChunk` is a non-blocking function which a pointer + // (`result.data`) inside RingBuffer's buffer, `result.size` is the + // size of the continious chunk (can be smaller than availableToConsume()). + // IMPORTANT: do not call long running functions while have an instance of + // ContiniousLockedChunk, it might block the producer because + // it need to drop the stale audio data to replace it with + // more recent one. + // NOTE: ContiniousLockedChunk holds a lock inside, it might deadlock + // if you calling other RingBuffer's functions that assume it is + // unlocked, in this case you want to introduce a function like + // `consume` below. + ContiniousLockedChunk getConsumeChunk() const; + + // Tries to move the `consume` cursor by `size`, returns the actual size + // moved. + size_t consume(const ContiniousLockedChunk&, size_t size); + +private: + std::unique_ptr<uint8_t[]> mBuffer; + mutable std::condition_variable mProduceAvailable; + mutable std::condition_variable mConsumeAvailable; + mutable std::mutex mMutex; + const int mCapacity; + int mAvailableToConsume = 0; + int mProducePos = 0; + int mConsumePos = 0; +}; + +} // namespace implementation +} // namespace V6_0 +} // namespace audio +} // namespace hardware +} // namespace android diff --git a/audio/stream_in.cpp b/audio/stream_in.cpp index c3ef62f2..ee7bcfcd 100644 --- a/audio/stream_in.cpp +++ b/audio/stream_in.cpp @@ -19,17 +19,15 @@ #include <fmq/MessageQueue.h> #include <hidl/MQDescriptor.h> #include <hidl/Status.h> +#include <utils/ThreadDefs.h> +#include <future> +#include <thread> #include "stream_in.h" #include "device_port_source.h" #include "deleters.h" +#include "audio_ops.h" #include "util.h" #include "debug.h" -#include <sys/resource.h> -#include <pthread.h> -#include <cutils/sched_policy.h> -#include <utils/ThreadDefs.h> -#include <future> -#include <thread> namespace android { namespace hardware { @@ -98,8 +96,7 @@ struct ReadThread : public IOThread { } void threadLoop() { - setpriority(PRIO_PROCESS, 0, PRIORITY_URGENT_AUDIO); - set_sched_policy(0, SP_FOREGROUND); + util::setThreadPriority(PRIORITY_URGENT_AUDIO); mTid.set_value(pthread_self()); while (true) { @@ -112,15 +109,12 @@ struct ReadThread : public IOThread { if (efState & STAND_BY_REQUEST) { mSource.reset(); - mBuffer.reset(); } if (efState & (MessageQueueFlagBits::NOT_FULL | 0)) { if (!mSource) { - mBuffer.reset(new uint8_t[mDataMQ.getQuantumCount()]); - LOG_ALWAYS_FATAL_IF(!mBuffer); - - mSource = DevicePortSource::create(mStream->getDeviceAddress(), + mSource = DevicePortSource::create(mDataMQ.getQuantumCount(), + mStream->getDeviceAddress(), mStream->getAudioConfig(), mStream->getAudioOutputFlags(), mStream->getFrameCounter()); @@ -166,36 +160,40 @@ struct ReadThread : public IOThread { } IStreamIn::ReadStatus doRead(const IStreamIn::ReadParameters &rParameters) { + struct MQWriter : public IWriter { + explicit MQWriter(DataMQ &mq) : dataMQ(mq) {} + + size_t operator()(const void *dst, size_t sz) override { + if (dataMQ.write(static_cast<const uint8_t *>(dst), sz)) { + totalWritten += sz; + return sz; + } else { + ALOGE("WriteThread::%s:%d: DataMQ::write failed", + __func__, __LINE__); + return 0; + } + } + + size_t totalWritten = 0; + DataMQ &dataMQ; + }; + const size_t bytesToRead = std::min(mDataMQ.availableToWrite(), static_cast<size_t>(rParameters.params.read)); - IStreamIn::ReadStatus status; - size_t read = 0; - status.retval = doReadImpl(&mBuffer[0], bytesToRead, read); - if (status.retval == Result::OK) { - if (!mDataMQ.write(&mBuffer[0], read)) { - ALOGE("ReadThread::%s:%d: mDataMQ.write failed", __func__, __LINE__); - } - status.reply.read = read; + MQWriter writer(mDataMQ); + const size_t framesLost = + mSource->read(mStream->getEffectiveVolume(), bytesToRead, writer); + if (framesLost > 0) { + mStream->addInputFramesLost(framesLost); } + IStreamIn::ReadStatus status; + status.retval = Result::OK; + status.reply.read = writer.totalWritten; return status; } - Result doReadImpl(uint8_t *const data, const size_t toRead, size_t &read) { - const int res = mSource->read(data, toRead); - if (res < 0) { - memset(data, 0, toRead); - read = toRead; - ALOGE("StreamInReadThread::%s:%d pcm_read failed with %s", - __func__, __LINE__, strerror(-res)); - } else { - read = res; - } - - return Result::OK; - } - IStreamIn::ReadStatus doGetCapturePosition() { IStreamIn::ReadStatus status; @@ -211,7 +209,6 @@ struct ReadThread : public IOThread { StatusMQ mStatusMQ; DataMQ mDataMQ; std::unique_ptr<EventFlag, deleters::forEventFlag> mEfGroup; - std::unique_ptr<uint8_t[]> mBuffer; std::unique_ptr<DevicePortSource> mSource; std::thread mThread; std::promise<pthread_t> mTid; @@ -219,15 +216,13 @@ struct ReadThread : public IOThread { } // namespace -StreamIn::StreamIn(sp<IDevice> dev, - void (*unrefDevice)(IDevice*), +StreamIn::StreamIn(sp<PrimaryDevice> dev, int32_t ioHandle, const DeviceAddress& device, const AudioConfig& config, hidl_bitfield<AudioInputFlag> flags, const SinkMetadata& sinkMetadata) : mDev(std::move(dev)) - , mUnrefDevice(unrefDevice) , mCommon(ioHandle, device, config, flags) , mSinkMetadata(sinkMetadata) { } @@ -364,7 +359,7 @@ Return<void> StreamIn::getMmapPosition(getMmapPosition_cb _hidl_cb) { Result StreamIn::closeImpl(const bool fromDctor) { if (mDev) { mReadThread.reset(); - mUnrefDevice(mDev.get()); + mDev->unrefDevice(this); mDev = nullptr; return Result::OK; } else if (fromDctor) { @@ -449,6 +444,12 @@ Return<Result> StreamIn::setMicrophoneFieldDimension(float zoom) { return FAILURE(Result::NOT_SUPPORTED); } +void StreamIn::setMicMute(bool mute) { + mEffectiveVolume = + (mute && (getDeviceAddress().device & AudioDevice::IN_BUILTIN_MIC)) + ? 0.0f : 1.0f; +} + } // namespace implementation } // namespace V6_0 } // namespace audio diff --git a/audio/stream_in.h b/audio/stream_in.h index 2a769814..dfc38a65 100644 --- a/audio/stream_in.h +++ b/audio/stream_in.h @@ -19,6 +19,7 @@ #include <android/hardware/audio/6.0/IDevice.h> #include "stream_common.h" #include "io_thread.h" +#include "primary_device.h" namespace android { namespace hardware { @@ -35,8 +36,7 @@ using namespace ::android::hardware::audio::common::V6_0; using namespace ::android::hardware::audio::V6_0; struct StreamIn : public IStreamIn { - StreamIn(sp<IDevice> dev, - void (*unrefDevice)(IDevice*), + StreamIn(sp<PrimaryDevice> dev, int32_t ioHandle, const DeviceAddress& device, const AudioConfig& config, @@ -92,18 +92,23 @@ struct StreamIn : public IStreamIn { const hidl_bitfield<AudioOutputFlag> &getAudioOutputFlags() const { return mCommon.m_flags; } uint64_t &getFrameCounter() { return mFrames; } + void setMicMute(bool mute); + void addInputFramesLost(size_t n) { mInputFramesLost += n; } + float getEffectiveVolume() const { return mEffectiveVolume; } private: Result closeImpl(bool fromDctor); - sp<IDevice> mDev; - void (* const mUnrefDevice)(IDevice*); + sp<PrimaryDevice> mDev; const StreamCommon mCommon; const SinkMetadata mSinkMetadata; std::unique_ptr<IOThread> mReadThread; // The count is not reset to zero when output enters standby. uint64_t mFrames = 0; + + std::atomic<uint32_t> mInputFramesLost = 0; + std::atomic<float> mEffectiveVolume = 1.0f; }; } // namespace implementation diff --git a/audio/stream_out.cpp b/audio/stream_out.cpp index c35aca63..a34c2c6e 100644 --- a/audio/stream_out.cpp +++ b/audio/stream_out.cpp @@ -19,18 +19,15 @@ #include <fmq/MessageQueue.h> #include <hidl/MQDescriptor.h> #include <hidl/Status.h> -#include <math.h> +#include <utils/ThreadDefs.h> +#include <future> +#include <thread> #include "stream_out.h" #include "device_port_sink.h" #include "deleters.h" +#include "audio_ops.h" #include "util.h" #include "debug.h" -#include <sys/resource.h> -#include <pthread.h> -#include <cutils/sched_policy.h> -#include <utils/ThreadDefs.h> -#include <future> -#include <thread> namespace android { namespace hardware { @@ -101,8 +98,7 @@ struct WriteThread : public IOThread { } void threadLoop() { - setpriority(PRIO_PROCESS, 0, PRIORITY_URGENT_AUDIO); - set_sched_policy(0, SP_FOREGROUND); + util::setThreadPriority(PRIORITY_URGENT_AUDIO); mTid.set_value(pthread_self()); while (true) { @@ -119,10 +115,8 @@ struct WriteThread : public IOThread { if (efState & (MessageQueueFlagBits::NOT_EMPTY | 0)) { if (!mSink) { - mBuffer.reset(new uint8_t[mDataMQ.getQuantumCount()]); - LOG_ALWAYS_FATAL_IF(!mBuffer); - - mSink = DevicePortSink::create(mStream->getDeviceAddress(), + mSink = DevicePortSink::create(mDataMQ.getQuantumCount(), + mStream->getDeviceAddress(), mStream->getAudioConfig(), mStream->getAudioOutputFlags(), mStream->getFrameCounter()); @@ -172,35 +166,31 @@ struct WriteThread : public IOThread { } IStreamOut::WriteStatus doWrite() { - IStreamOut::WriteStatus status; - - const size_t availToRead = mDataMQ.availableToRead(); - size_t written = 0; - if (mDataMQ.read(&mBuffer[0], availToRead)) { - applyVolume(&mBuffer[0], availToRead, mStream->getVolumeNumerator()); - status.retval = doWriteImpl(&mBuffer[0], availToRead, written); - status.reply.written = written; - } else { - ALOGE("WriteThread::%s:%d: mDataMQ.read failed", __func__, __LINE__); - status.retval = Result::OK; - } - - return status; - } + struct MQReader : public IReader { + explicit MQReader(DataMQ &mq) : dataMQ(mq) {} + + size_t operator()(void *dst, size_t sz) override { + if (dataMQ.read(static_cast<uint8_t *>(dst), sz)) { + totalRead += sz; + return sz; + } else { + ALOGE("WriteThread::%s:%d: DataMQ::read failed", + __func__, __LINE__); + return 0; + } + } - static void applyVolume(void *buf, const size_t szBytes, const int32_t numerator) { - constexpr int32_t kDenominator = StreamOut::kVolumeDenominator; + size_t totalRead = 0; + DataMQ &dataMQ; + }; - if (numerator == kDenominator) { - return; - } + MQReader reader(mDataMQ); + mSink->write(mStream->getEffectiveVolume(), mDataMQ.availableToRead(), reader); - int16_t *samples = static_cast<int16_t *>(buf); - std::for_each(samples, - samples + szBytes / sizeof(*samples), - [numerator](int16_t &x) { - x = (x * numerator + kDenominator / 2) / kDenominator; - }); + IStreamOut::WriteStatus status; + status.retval = Result::OK; + status.reply.written = reader.totalRead; + return status; } IStreamOut::WriteStatus doGetPresentationPosition() { @@ -222,27 +212,11 @@ struct WriteThread : public IOThread { return status; } - Result doWriteImpl(const uint8_t *const data, - const size_t toWrite, - size_t &written) { - const int res = mSink->write(data, toWrite); - if (res < 0) { - ALOGE("WriteThread::%s:%d: DevicePortSink::write failed with %s", - __func__, __LINE__, strerror(-res)); - written = toWrite; - } else { - written = res; - } - - return Result::OK; - } - StreamOut *const mStream; CommandMQ mCommandMQ; StatusMQ mStatusMQ; DataMQ mDataMQ; std::unique_ptr<EventFlag, deleters::forEventFlag> mEfGroup; - std::unique_ptr<uint8_t[]> mBuffer; std::unique_ptr<DevicePortSink> mSink; std::thread mThread; std::promise<pthread_t> mTid; @@ -250,15 +224,13 @@ struct WriteThread : public IOThread { } // namespace -StreamOut::StreamOut(sp<IDevice> dev, - void (*unrefDevice)(IDevice*), +StreamOut::StreamOut(sp<PrimaryDevice> dev, int32_t ioHandle, const DeviceAddress& device, const AudioConfig& config, hidl_bitfield<AudioOutputFlag> flags, const SourceMetadata& sourceMetadata) : mDev(std::move(dev)) - , mUnrefDevice(unrefDevice) , mCommon(ioHandle, device, config, flags) , mSourceMetadata(sourceMetadata) {} @@ -374,7 +346,7 @@ Return<Result> StreamOut::setHwAvSync(uint32_t hwAvSync) { Result StreamOut::closeImpl(const bool fromDctor) { if (mDev) { mWriteThread.reset(); - mUnrefDevice(mDev.get()); + mDev->unrefDevice(this); mDev = nullptr; return Result::OK; } else if (fromDctor) { @@ -420,7 +392,9 @@ Return<Result> StreamOut::setVolume(float left, float right) { return FAILURE(Result::INVALID_ARGUMENTS); } - mVolumeNumerator = int16_t((left + right) * kVolumeDenominator / 2); + std::lock_guard<std::mutex> guard(mMutex); + mStreamVolume = (left + right) / 2.0f; + updateEffectiveVolumeLocked(); return Result::OK; } @@ -478,6 +452,11 @@ Return<Result> StreamOut::clearCallback() { return FAILURE(Result::NOT_SUPPORTED); } +Return<Result> StreamOut::setEventCallback(const sp<IStreamOutEventCallback>& callback) { + (void)callback; + return FAILURE(Result::NOT_SUPPORTED); +} + Return<void> StreamOut::supportsPauseAndResume(supportsPauseAndResume_cb _hidl_cb) { _hidl_cb(false, false); return Void(); @@ -516,6 +495,46 @@ Return<Result> StreamOut::selectPresentation(int32_t presentationId, return FAILURE(Result::NOT_SUPPORTED); } +Return<void> StreamOut::getDualMonoMode(getDualMonoMode_cb _hidl_cb) { + _hidl_cb(FAILURE(Result::NOT_SUPPORTED), {}); + return Void(); +} + +Return<Result> StreamOut::setDualMonoMode(DualMonoMode mode) { + (void)mode; + return FAILURE(Result::NOT_SUPPORTED); +} + +Return<void> StreamOut::getAudioDescriptionMixLevel(getAudioDescriptionMixLevel_cb _hidl_cb) { + _hidl_cb(FAILURE(Result::NOT_SUPPORTED), 0); + return Void(); +} + +Return<Result> StreamOut::setAudioDescriptionMixLevel(float leveldB) { + (void)leveldB; + return FAILURE(Result::NOT_SUPPORTED); +} + +Return<void> StreamOut::getPlaybackRateParameters(getPlaybackRateParameters_cb _hidl_cb) { + _hidl_cb(FAILURE(Result::NOT_SUPPORTED), {}); + return Void(); +} + +Return<Result> StreamOut::setPlaybackRateParameters(const PlaybackRate &playbackRate) { + (void)playbackRate; + return FAILURE(Result::NOT_SUPPORTED); +} + +void StreamOut::setMasterVolume(float masterVolume) { + std::lock_guard<std::mutex> guard(mMutex); + mMasterVolume = masterVolume; + updateEffectiveVolumeLocked(); +} + +void StreamOut::updateEffectiveVolumeLocked() { + mEffectiveVolume = mMasterVolume * mStreamVolume; +} + } // namespace implementation } // namespace V6_0 } // namespace audio diff --git a/audio/stream_out.h b/audio/stream_out.h index 2d689ac4..20e42286 100644 --- a/audio/stream_out.h +++ b/audio/stream_out.h @@ -20,6 +20,7 @@ #include <android/hardware/audio/6.0/IDevice.h> #include "stream_common.h" #include "io_thread.h" +#include "primary_device.h" namespace android { namespace hardware { @@ -36,8 +37,7 @@ using namespace ::android::hardware::audio::common::V6_0; using namespace ::android::hardware::audio::V6_0; struct StreamOut : public IStreamOut { - StreamOut(sp<IDevice> dev, - void (*unrefDevice)(IDevice*), + StreamOut(sp<PrimaryDevice> dev, int32_t ioHandle, const DeviceAddress& device, const AudioConfig& config, @@ -45,8 +45,6 @@ struct StreamOut : public IStreamOut { const SourceMetadata& sourceMetadata); ~StreamOut(); - static constexpr int16_t kVolumeDenominator = 1 << 14; - // IStream Return<uint64_t> getFrameSize() override; Return<uint64_t> getFrameCount() override; @@ -88,6 +86,7 @@ struct StreamOut : public IStreamOut { Return<void> getNextWriteTimestamp(getNextWriteTimestamp_cb _hidl_cb) override; Return<Result> setCallback(const sp<IStreamOutCallback>& callback) override; Return<Result> clearCallback() override; + Return<Result> setEventCallback(const sp<IStreamOutEventCallback>& callback) override; Return<void> supportsPauseAndResume(supportsPauseAndResume_cb _hidl_cb) override; Return<Result> pause() override; Return<Result> resume() override; @@ -96,8 +95,15 @@ struct StreamOut : public IStreamOut { Return<Result> flush() override; Return<void> getPresentationPosition(getPresentationPosition_cb _hidl_cb) override; Return<Result> selectPresentation(int32_t presentationId, int32_t programId) override; + Return<void> getDualMonoMode(getDualMonoMode_cb _hidl_cb) override; + Return<Result> setDualMonoMode(DualMonoMode mode) override; + Return<void> getAudioDescriptionMixLevel(getAudioDescriptionMixLevel_cb _hidl_cb) override; + Return<Result> setAudioDescriptionMixLevel(float leveldB) override; + Return<void> getPlaybackRateParameters(getPlaybackRateParameters_cb _hidl_cb) override; + Return<Result> setPlaybackRateParameters(const PlaybackRate &playbackRate) override; - int16_t getVolumeNumerator() const { return mVolumeNumerator; }; + void setMasterVolume(float volume); + float getEffectiveVolume() const { return mEffectiveVolume; } const DeviceAddress &getDeviceAddress() const { return mCommon.m_device; } const AudioConfig &getAudioConfig() const { return mCommon.m_config; } const hidl_bitfield<AudioOutputFlag> &getAudioOutputFlags() const { return mCommon.m_flags; } @@ -106,13 +112,17 @@ struct StreamOut : public IStreamOut { private: Result closeImpl(bool fromDctor); + void updateEffectiveVolumeLocked(); - sp<IDevice> mDev; - void (* const mUnrefDevice)(IDevice*); + sp<PrimaryDevice> mDev; const StreamCommon mCommon; const SourceMetadata mSourceMetadata; std::unique_ptr<IOThread> mWriteThread; - std::atomic<int16_t> mVolumeNumerator = kVolumeDenominator; + + float mMasterVolume = 1.0f; // requires mMutex + float mStreamVolume = 1.0f; // requires mMutex + std::atomic<float> mEffectiveVolume = 1.0f; + std::mutex mMutex; // The count is not reset to zero when output enters standby. uint64_t mFrames = 0; diff --git a/audio/talsa.cpp b/audio/talsa.cpp index 29b15ee0..5afb8156 100644 --- a/audio/talsa.cpp +++ b/audio/talsa.cpp @@ -14,9 +14,10 @@ * limitations under the License. */ +#include <mutex> +#include <log/log.h> #include "talsa.h" #include "debug.h" -#include <log/log.h> namespace android { namespace hardware { @@ -25,14 +26,81 @@ namespace V6_0 { namespace implementation { namespace talsa { -void PcmDeleter::operator()(pcm_t *x) const { - LOG_ALWAYS_FATAL_IF(pcm_close(x) != 0); -}; +namespace { + +struct mixer *gMixer0 = nullptr; +int gMixerRefcounter0 = 0; +std::mutex gMixerMutex; + +void mixerSetValueAll(struct mixer_ctl *ctl, int value) { + const unsigned int n = mixer_ctl_get_num_values(ctl); + for (unsigned int i = 0; i < n; i++) { + ::mixer_ctl_set_value(ctl, i, value); + } +} + +void mixerSetPercentAll(struct mixer_ctl *ctl, int percent) { + const unsigned int n = mixer_ctl_get_num_values(ctl); + for (unsigned int i = 0; i < n; i++) { + ::mixer_ctl_set_percent(ctl, i, percent); + } +} + +struct mixer *mixerGetOrOpenImpl(const unsigned card, + struct mixer *&gMixer, + int &refcounter) { + if (!gMixer) { + struct mixer *mixer = ::mixer_open(card); + if (!mixer) { + return FAILURE(nullptr); + } + + mixerSetPercentAll(::mixer_get_ctl_by_name(mixer, "Master Playback Volume"), 100); + mixerSetPercentAll(::mixer_get_ctl_by_name(mixer, "Capture Volume"), 100); + + mixerSetValueAll(::mixer_get_ctl_by_name(mixer, "Master Playback Switch"), 1); + mixerSetValueAll(::mixer_get_ctl_by_name(mixer, "Capture Switch"), 1); + + gMixer = mixer; + } + + ++refcounter; + return gMixer; +} -void MixerDeleter::operator()(struct mixer *x) const { - mixer_close(x); +struct mixer *mixerGetOrOpen(const unsigned card) { + std::lock_guard<std::mutex> guard(gMixerMutex); + + switch (card) { + case 0: return mixerGetOrOpenImpl(card, gMixer0, gMixerRefcounter0); + default: return FAILURE(nullptr); + } +} + +bool mixerUnrefImpl(struct mixer *mixer, struct mixer *&gMixer, int &refcounter) { + if (mixer == gMixer) { + if (0 == --refcounter) { + ::mixer_close(mixer); + gMixer = nullptr; + } + return true; + } else { + return false; + } } +bool mixerUnref(struct mixer *mixer) { + std::lock_guard<std::mutex> guard(gMixerMutex); + + return mixerUnrefImpl(mixer, gMixer0, gMixerRefcounter0); +} + +} // namespace + +void PcmDeleter::operator()(pcm_t *x) const { + LOG_ALWAYS_FATAL_IF(::pcm_close(x) != 0); +}; + std::unique_ptr<pcm_t, PcmDeleter> pcmOpen(const unsigned int dev, const unsigned int card, const unsigned int nChannels, @@ -45,7 +113,7 @@ std::unique_ptr<pcm_t, PcmDeleter> pcmOpen(const unsigned int dev, pcm_config.channels = nChannels; pcm_config.rate = sampleRateHz; pcm_config.period_size = frameCount; // Approx frames between interrupts - pcm_config.period_count = 4; // Approx interrupts per buffer + pcm_config.period_count = 8; // Approx interrupts per buffer pcm_config.format = PCM_FORMAT_S16_LE; pcm_config.start_threshold = 0; pcm_config.stop_threshold = isOut ? 0 : INT_MAX; @@ -65,25 +133,14 @@ std::unique_ptr<pcm_t, PcmDeleter> pcmOpen(const unsigned int dev, } } -MixerPtr mixerOpen(unsigned int card) { - return MixerPtr(::mixer_open(card)); -} +Mixer::Mixer(unsigned card): mMixer(mixerGetOrOpen(card)) {} -void mixerSetValueAll(mixer_ctl_t *ctl, int value) { - const unsigned int n = mixer_ctl_get_num_values(ctl); - for (unsigned int i = 0; i < n; i++) { - mixer_ctl_set_value(ctl, i, value); +Mixer::~Mixer() { + if (mMixer) { + LOG_ALWAYS_FATAL_IF(!mixerUnref(mMixer)); } } -void mixerSetPercentAll(mixer_ctl_t *ctl, int percent) { - const unsigned int n = mixer_ctl_get_num_values(ctl); - for (unsigned int i = 0; i < n; i++) { - mixer_ctl_set_percent(ctl, i, percent); - } -} - - } // namespace talsa } // namespace implementation } // namespace V6_0 diff --git a/audio/talsa.h b/audio/talsa.h index 0b05bfc8..b461d63c 100644 --- a/audio/talsa.h +++ b/audio/talsa.h @@ -33,13 +33,21 @@ struct PcmDeleter { void operator()(pcm_t *x) const; }; typedef std::unique_ptr<pcm_t, PcmDeleter> PcmPtr; PcmPtr pcmOpen(unsigned int dev, unsigned int card, unsigned int nChannels, size_t sampleRateHz, size_t frameCount, bool isOut); -typedef struct mixer mixer_t; -typedef struct mixer_ctl mixer_ctl_t; -struct MixerDeleter { void operator()(struct mixer *m) const; }; -typedef std::unique_ptr<mixer_t, MixerDeleter> MixerPtr; -MixerPtr mixerOpen(unsigned int card); -void mixerSetValueAll(mixer_ctl_t *ctl, int value); -void mixerSetPercentAll(mixer_ctl_t *ctl, int percent); +class Mixer { +public: + Mixer(unsigned card); + ~Mixer(); + + operator bool() const { return mMixer != nullptr; } + + Mixer(const Mixer &) = delete; + Mixer &operator=(const Mixer &) = delete; + Mixer(Mixer &&) = delete; + Mixer &operator=(Mixer &&) = delete; + +private: + struct mixer *mMixer; +}; } // namespace talsa } // namespace implementation diff --git a/audio/util.cpp b/audio/util.cpp index dbe620ba..00678d59 100644 --- a/audio/util.cpp +++ b/audio/util.cpp @@ -16,7 +16,10 @@ #include <log/log.h> #include <cutils/bitops.h> +#include <cutils/sched_policy.h> #include <system/audio.h> +#include <sys/resource.h> +#include <pthread.h> #include "util.h" #include "debug.h" @@ -153,6 +156,11 @@ TimeSpec nsecs2TimeSpec(nsecs_t ns) { return ts; } +void setThreadPriority(int prio) { + setpriority(PRIO_PROCESS, 0, prio); + set_sched_policy(0, SP_FOREGROUND); +} + } // namespace util } // namespace implementation } // namespace V6_0 diff --git a/audio/util.h b/audio/util.h index aae8f535..5337c7b6 100644 --- a/audio/util.h +++ b/audio/util.h @@ -45,6 +45,8 @@ bool checkAudioConfig(bool isOut, TimeSpec nsecs2TimeSpec(nsecs_t); +void setThreadPriority(int prio); + } // namespace util } // namespace implementation } // namespace V6_0 diff --git a/camera/EmulatedCamera.cpp b/camera/EmulatedCamera.cpp index 89888f07..90fdc1e4 100755 --- a/camera/EmulatedCamera.cpp +++ b/camera/EmulatedCamera.cpp @@ -701,7 +701,7 @@ status_t EmulatedCamera::setParameters(const char* parms) return NO_ERROR; } -/* A dumb variable indicating "no params" / error on the exit from +/* A variable indicating "no params" / error on the exit from * EmulatedCamera::getParameters(). */ static char lNoParam = '\0'; char* EmulatedCamera::getParameters() diff --git a/camera/EmulatedCameraFactory.cpp b/camera/EmulatedCameraFactory.cpp index 9acdbd2a..d4b08f35 100755 --- a/camera/EmulatedCameraFactory.cpp +++ b/camera/EmulatedCameraFactory.cpp @@ -458,12 +458,11 @@ void EmulatedCameraFactory::waitForQemuSfFakeCameraPropertyAvailable() { } bool EmulatedCameraFactory::isFakeCameraEmulationOn(bool backCamera) { - /* - * Defined by 'qemu.sf.fake_camera' boot property. If the property exists, - * and if it's set to 'both', then fake cameras are used to emulate both - * sides. If it's set to 'back' or 'front', then a fake camera is used only - * to emulate the back or front camera, respectively. - */ + // Always return false, because another HAL (Google Camera HAL) + // will create the fake cameras + if (!property_get_bool("ro.kernel.qemu.legacy_fake_camera", false)) { + return false; + } char prop[PROPERTY_VALUE_MAX]; if ((property_get("qemu.sf.fake_camera", prop, nullptr) > 0) && (!strcmp(prop, "both") || diff --git a/camera/Exif.cpp b/camera/Exif.cpp index 0f451ffd..9e9f159c 100644 --- a/camera/Exif.cpp +++ b/camera/Exif.cpp @@ -233,11 +233,11 @@ static bool getCameraParam(const CameraParameters& parameters, int64_t* outValue) { const char* value = parameters.get(parameterKey); if (value) { - char dummy = 0; + char trailing = 0; // Attempt to scan an extra character and then make sure it was not // scanned by checking that the return value indicates only one item. // This way we fail on any trailing characters - if (sscanf(value, "%" SCNd64 "%c", outValue, &dummy) == 1) { + if (sscanf(value, "%" SCNd64 "%c", outValue, &trailing) == 1) { return true; } } diff --git a/camera/QemuClient.cpp b/camera/QemuClient.cpp index cceca04e..6fa143d7 100755 --- a/camera/QemuClient.cpp +++ b/camera/QemuClient.cpp @@ -21,6 +21,7 @@ #define LOG_NDEBUG 1 #define LOG_TAG "EmulatedCamera_QemuClient" +#include <inttypes.h> #include <log/log.h> #include "EmulatedCamera.h" #include "QemuClient.h" @@ -576,11 +577,11 @@ status_t CameraQemuClient::queryFrame(int width, float exposure_comp, int64_t* frame_time) { - ALOGV("%s: w %d h %d %.4s offset 0x%llx", __FUNCTION__, width, height, + ALOGV("%s: w %d h %d %.4s offset 0x%" PRIu64 "", __FUNCTION__, width, height, (char*)(&pixel_format), offset); char query_str[256]; - snprintf(query_str, sizeof(query_str), "%s dim=%dx%d pix=%d offset=%llu whiteb=%g,%g,%g expcomp=%g time=%d", + snprintf(query_str, sizeof(query_str), "%s dim=%dx%d pix=%d offset=%" PRIu64 " whiteb=%g,%g,%g expcomp=%g time=%d", mQueryFrame, width, height, pixel_format, offset, r_scale, g_scale, b_scale, exposure_comp, frame_time != nullptr ? 1 : 0); diff --git a/data/etc/config.ini.foldable b/data/etc/config.ini.foldable index 017cf5c2..a8f94ba5 100644 --- a/data/etc/config.ini.foldable +++ b/data/etc/config.ini.foldable @@ -1,5 +1,6 @@ avd.ini.encoding=UTF-8 disk.dataPartition.size=2G +fastboot.forceColdBoot = yes hw.accelerometer=yes hw.audioInput=yes hw.battery=yes @@ -18,4 +19,4 @@ hw.keyboard.lid=yes image.sysdir.1=x86/ skin.dynamic=no skin.name=1536x2152 -skin.path=1536x2152
\ No newline at end of file +skin.path=1536x2152 diff --git a/data/etc/config.ini.freeform b/data/etc/config.ini.freeform new file mode 100644 index 00000000..81cf0e3b --- /dev/null +++ b/data/etc/config.ini.freeform @@ -0,0 +1,23 @@ +avd.ini.encoding=UTF-8 +disk.dataPartition.size=6G +display.settings.xml=freeform +fastboot.forceColdBoot = yes +hw.accelerometer=yes +hw.audioInput=yes +hw.battery=yes +hw.camera.back=emulated +hw.camera.front=emulated +hw.dPad=no +hw.gps=yes +hw.gpu.enabled=yes +hw.keyboard=yes +hw.lcd.density=240 +hw.mainKeys=no +hw.ramSize=4096 +hw.sensors.orientation=yes +hw.sensors.proximity=yes +image.sysdir.1=x86/ +skin.dynamic=no +skin.name=3000x2000 +skin.path=3000x2000 + diff --git a/data/etc/config.ini.tv b/data/etc/config.ini.tv index 5e050800..be5f95e9 100644 --- a/data/etc/config.ini.tv +++ b/data/etc/config.ini.tv @@ -1,9 +1,10 @@ avd.ini.encoding=UTF-8 disk.dataPartition.size=2G +fastboot.forceColdBoot = yes hw.accelerometer=no hw.audioInput=yes hw.battery=no -hw.camera.back=emulated +hw.camera.back=none hw.camera.front=none hw.dPad=no hw.gps=yes diff --git a/data/etc/configs/gpu.config b/data/etc/configs/gpu.config new file mode 100644 index 00000000..0e79db50 --- /dev/null +++ b/data/etc/configs/gpu.config @@ -0,0 +1,5 @@ +hw.gltransport=asg +hw.lcd.density=480 +skin.dynamic=no +skin.name=1080x1920 +skin.path=1080x1920 diff --git a/data/etc/handheld_core_hardware.xml b/data/etc/handheld_core_hardware.xml index 01ab175b..3fe79abb 100644 --- a/data/etc/handheld_core_hardware.xml +++ b/data/etc/handheld_core_hardware.xml @@ -31,6 +31,7 @@ android.hardware.sensor.proximity android.hardware.sensor.relative_humidity android.hardware.sensor.gyroscope + android.hardware.sensor.hinge_angle android.hardware.telephony android.hardware.telephony.gsm android.software.midi @@ -50,6 +51,7 @@ <feature name="android.hardware.sensor.proximity" /> <feature name="android.hardware.sensor.relative_humidity" /> <feature name="android.hardware.sensor.gyroscope" /> + <feature name="android.hardware.sensor.hinge_angle" /> <feature name="android.hardware.telephony" /> <feature name="android.hardware.telephony.gsm" /> <feature name="android.hardware.touchscreen" /> @@ -68,6 +70,7 @@ <feature name="android.software.print" /> <feature name="android.software.cant_save_state" /> <feature name="android.software.secure_lock_screen" /> + <feature name="android.software.companion_device_setup" /> <!-- Feature to specify if the device supports adding device admins. --> <feature name="android.software.device_admin" /> diff --git a/display_settings_freeform.xml b/display_settings_freeform.xml new file mode 100644 index 00000000..6bdabde7 --- /dev/null +++ b/display_settings_freeform.xml @@ -0,0 +1,10 @@ +<?xml version='1.0' encoding='utf-8' standalone='yes' ?> +<display-settings> +<!-- Use physical port number instead of local id --> +<config identifier="1" /> + +<!-- Set windowing mode to WINDOWING_MODE_FREEFORM --> +<display name="port:0" + windowingMode="5" /> + +</display-settings>
\ No newline at end of file diff --git a/emulator-info.txt b/emulator-info.txt index fb45a7e0..0f77dfa4 100644 --- a/emulator-info.txt +++ b/emulator-info.txt @@ -1,2 +1,2 @@ # Emulator (stable) version -require version-emulator=6629878 +require version-emulator=6768950 @@ -1,5 +1,5 @@ # -# Copyright 2019 The Android Open Source Project +# Copyright 2020 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. @@ -23,7 +23,7 @@ PRODUCT_OTA_ENFORCE_VINTF_KERNEL_REQUIREMENTS := false # All components inherited here go to system image # $(call inherit-product, $(SRC_TARGET_DIR)/product/core_64_bit.mk) -$(call inherit-product, $(SRC_TARGET_DIR)/product/mainline_system.mk) +$(call inherit-product, $(SRC_TARGET_DIR)/product/generic_system.mk) # # All components inherited here go to system_ext image @@ -51,7 +51,7 @@ PRODUCT_PACKAGES += \ audio.r_submix.default \ android.hardware.drm@1.0-service \ android.hardware.drm@1.0-impl \ - android.hardware.drm@1.2-service.clearkey \ + android.hardware.drm@1.3-service.clearkey \ android.hardware.gatekeeper@1.0-service.software \ android.hardware.graphics.allocator@2.0-service \ android.hardware.graphics.allocator@2.0-impl \ @@ -109,3 +109,6 @@ WITH_DEXPREOPT_BOOT_IMG_AND_SYSTEM_SERVER_ONLY := false DEVICE_MANIFEST_FILE := device/generic/goldfish/fvpbase/manifest.xml +# Use a multilib setup (see fvpbase/BoardConfig.mk). +FVP_MULTILIB_BUILD := true + diff --git a/fvp_mini.mk b/fvp_mini.mk new file mode 100644 index 00000000..e0e3721c --- /dev/null +++ b/fvp_mini.mk @@ -0,0 +1,57 @@ +# +# Copyright 2020 Arm Ltd. All rights reserved. +# +# 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. +# + +$(call inherit-product, $(LOCAL_PATH)/minimal_system.mk) + +$(call inherit-product, $(SRC_TARGET_DIR)/product/updatable_apex.mk) + +$(call inherit-product, $(SRC_TARGET_DIR)/product/core_64_bit_only.mk) + +PRODUCT_NAME := fvp_mini +PRODUCT_DEVICE := fvpbase +PRODUCT_BRAND := Android +PRODUCT_MODEL := AOSP on FVP +PRODUCT_SOONG_NAMESPACES += device/generic/goldfish + +PRODUCT_SHIPPING_API_LEVEL := 29 +PRODUCT_USE_DYNAMIC_PARTITIONS := true +PRODUCT_FULL_TREBLE_OVERRIDE := true +PRODUCT_OTA_ENFORCE_VINTF_KERNEL_REQUIREMENTS := false +PRODUCT_BUILD_BOOT_IMAGE := true + +OVERRIDE_TARGET_FLATTEN_APEX := true + +# Use a multilib setup (see fvpbase/BoardConfig.mk). +FVP_MULTILIB_BUILD ?= true + +PRODUCT_PACKAGES += \ + com.android.runtime \ + gdbserver \ + init_vendor \ + ip \ + ping \ + selinux_policy_nonsystem \ + +PRODUCT_HOST_PACKAGES += \ + bind_to_localhost + +PRODUCT_COPY_FILES += \ + device/generic/goldfish/fvpbase/fstab.fvpbase:$(TARGET_COPY_OUT_VENDOR)/etc/fstab.fvpbase \ + device/generic/goldfish/fvpbase/fstab.fvpbase.initrd:$(TARGET_COPY_OUT_RAMDISK)/fstab.fvpbase \ + device/generic/goldfish/fvpbase/init.fvpbase.rc:$(TARGET_COPY_OUT_VENDOR)/etc/init/hw/init.fvpbase.rc \ + device/generic/goldfish/fvpbase/mini_network.rc:system/etc/init/mini_network.rc \ + device/generic/goldfish/fvpbase/mini_network.sh:/system/bin/mini_network.sh \ + device/generic/goldfish/fvpbase/required_images:required_images \ diff --git a/fvpbase/BoardConfig.mk b/fvpbase/BoardConfig.mk index 8dbe4ba3..d3e3da1e 100644 --- a/fvpbase/BoardConfig.mk +++ b/fvpbase/BoardConfig.mk @@ -1,4 +1,4 @@ -# Copyright (C) 2019 The Android Open Source Project +# Copyright (C) 2020 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. @@ -18,11 +18,13 @@ TARGET_ARCH_VARIANT := armv8-a TARGET_CPU_VARIANT := generic TARGET_CPU_ABI := arm64-v8a +ifeq ($(FVP_MULTILIB_BUILD),true) TARGET_2ND_ARCH := arm TARGET_2ND_CPU_ABI := armeabi-v7a TARGET_2ND_CPU_ABI2 := armeabi TARGET_2ND_ARCH_VARIANT := armv8-a TARGET_2ND_CPU_VARIANT := generic +endif include build/make/target/board/BoardConfigMainlineCommon.mk @@ -63,7 +65,7 @@ BOARD_KERNEL_CMDLINE := \ console=ttyAMA0 \ earlycon=pl011,0x1c090000 \ androidboot.hardware=fvpbase \ - androidboot.boot_device=bus@8000000/bus@8000000:motherboard/bus@8000000:motherboard:iofpga@3,00000000/1c130000.virtio-block \ + androidboot.boot_device=bus@8000000/bus@8000000:motherboard-bus/bus@8000000:motherboard-bus:iofpga-bus@300000000/1c130000.virtio-block \ loglevel=9 \ BOARD_SEPOLICY_DIRS += device/generic/goldfish/fvpbase/sepolicy diff --git a/fvpbase/README.md b/fvpbase/README.md index f701615a..75e051a9 100644 --- a/fvpbase/README.md +++ b/fvpbase/README.md @@ -5,10 +5,18 @@ the ARM Fixed Virtual Platform. ``` . build/envsetup.sh -lunch fvp-eng # or fvp-userdebug +lunch $TARGET m ``` +Where $TARGET above is one of: fvp-eng, fvp-userdebug, fvp_mini-eng or fvp_mini-userdebug +The fvp-* will build a full Android with UI support, while fvp_mini-* will build a small +subset needed to boot to shell and support command line executables. + +It is possible to disable 32 bit support in fvp_mini-* targets with the following command +before ``m``: +`export FVP_MULTILIB_BUILD=false` + Note that running ``m`` requires that the kernel is built first following the instructions below. diff --git a/fvpbase/mini_network.rc b/fvpbase/mini_network.rc new file mode 100644 index 00000000..15a13f87 --- /dev/null +++ b/fvpbase/mini_network.rc @@ -0,0 +1,19 @@ +# +# Copyright 2020 Arm Ltd. All rights reserved. +# +# 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. +# + +service mini_network /system/bin/mini_network.sh + class core + oneshot diff --git a/fvpbase/mini_network.sh b/fvpbase/mini_network.sh new file mode 100755 index 00000000..f2c90673 --- /dev/null +++ b/fvpbase/mini_network.sh @@ -0,0 +1,24 @@ +#!/system/bin/sh +# +# Copyright 2020 Arm Ltd. All rights reserved. +# +# 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. +# + +# The Android network stack is not included in Nano, so we need to +# configure the network manually. The configuration below is the same as +# would be obtained from the fast model's emulated DHCP. + +ip address add 172.20.51.1/24 broadcast 172.20.51.255 dev eth0 +ip link set eth0 up +ip route add default via 172.20.51.254 diff --git a/fvpbase/sepolicy/file_contexts b/fvpbase/sepolicy/file_contexts index ecd4cf6f..81c79485 100644 --- a/fvpbase/sepolicy/file_contexts +++ b/fvpbase/sepolicy/file_contexts @@ -6,3 +6,4 @@ /vendor/lib(64)?/libEGL_swiftshader\.so u:object_r:same_process_hal_file:s0 /vendor/lib(64)?/libGLESv1_CM_swiftshader\.so u:object_r:same_process_hal_file:s0 /vendor/lib(64)?/libGLESv2_swiftshader\.so u:object_r:same_process_hal_file:s0 +/system/bin/mini_network.sh u:object_r:mini_network_exec:s0 diff --git a/fvpbase/sepolicy/mini_network.te b/fvpbase/sepolicy/mini_network.te new file mode 100644 index 00000000..c330c8c4 --- /dev/null +++ b/fvpbase/sepolicy/mini_network.te @@ -0,0 +1,10 @@ +type mini_network, domain, coredomain; +type mini_network_exec, exec_type, system_file_type, file_type; + +init_daemon_domain(mini_network) + +allow mini_network self:capability net_admin; +allow mini_network self:netlink_route_socket { bind create getattr nlmsg_write read setopt write }; +allow mini_network self:udp_socket { create ioctl }; +allow mini_network shell_exec:file { execute getattr map read }; +allow mini_network system_file:file execute_no_trans; diff --git a/fvpbase/sepolicy/property.te b/fvpbase/sepolicy/property.te index f014ad52..50f7b343 100644 --- a/fvpbase/sepolicy/property.te +++ b/fvpbase/sepolicy/property.te @@ -1 +1 @@ -type vendor_device_prop, property_type; +vendor_internal_prop(vendor_device_prop) diff --git a/gnss/data_sink.cpp b/gnss/data_sink.cpp index 4b0c52cf..357ee7fe 100644 --- a/gnss/data_sink.cpp +++ b/gnss/data_sink.cpp @@ -21,7 +21,7 @@ namespace goldfish { void DataSink::gnssLocation(const ahg20::GnssLocation& loc) const { std::unique_lock<std::mutex> lock(mtx); - if (cb20) { + if (cb20 && isWarmedUd()) { cb20->gnssLocationCb_2_0(loc); } } @@ -43,7 +43,7 @@ void DataSink::gnssStatus(const ahg10::IGnssCallback::GnssStatusValue status) co void DataSink::gnssNmea(const ahg10::GnssUtcTime t, const hidl_string& nmea) const { std::unique_lock<std::mutex> lock(mtx); - if (cb20) { + if (cb20 && isWarmedUd()) { cb20->gnssNmeaCb(t, nmea); } } @@ -58,4 +58,13 @@ void DataSink::cleanup() { cb20 = nullptr; } +void DataSink::start() { + std::unique_lock<std::mutex> lock(mtx); + warmedUpTime = std::chrono::steady_clock::now() + std::chrono::milliseconds(3500); +} + +bool DataSink::isWarmedUd() const { + return std::chrono::steady_clock::now() >= warmedUpTime; +} + } // namespace goldfish diff --git a/gnss/data_sink.h b/gnss/data_sink.h index d182f2d0..7c6678bf 100644 --- a/gnss/data_sink.h +++ b/gnss/data_sink.h @@ -16,6 +16,7 @@ #pragma once #include <android/hardware/gnss/2.0/IGnss.h> +#include <chrono> #include <mutex> namespace goldfish { @@ -35,10 +36,14 @@ public: void gnssNmea(const ahg10::GnssUtcTime, const hidl_string&) const; void setCallback20(sp<ahg20::IGnssCallback>); + void start(); void cleanup(); private: + bool isWarmedUd() const; + sp<ahg20::IGnssCallback> cb20; + std::chrono::steady_clock::time_point warmedUpTime; mutable std::mutex mtx; }; diff --git a/gnss/gnss.cpp b/gnss/gnss.cpp index 8fa81fcc..d1a4f832 100644 --- a/gnss/gnss.cpp +++ b/gnss/gnss.cpp @@ -96,6 +96,7 @@ Return<bool> Gnss20::setPositionMode_1_1(ahg10::IGnss::GnssPositionMode mode, Return<bool> Gnss20::start() { std::unique_lock<std::mutex> lock(m_gnssHwConnMtx); if (m_gnssHwConn) { + m_dataSink.start(); return m_gnssHwConn->start(); } else { return false; diff --git a/gnss/gnss_measurement.cpp b/gnss/gnss_measurement.cpp index 6acedd4f..0885c284 100644 --- a/gnss/gnss_measurement.cpp +++ b/gnss/gnss_measurement.cpp @@ -16,10 +16,82 @@ #include <chrono> #include "gnss_measurement.h" -#include "util.h" namespace goldfish { using ::android::hardware::hidl_vec; +using GnssClockFlags10 = ahg10::IGnssMeasurementCallback::GnssClockFlags; +using GnssMeasurementT20 = ahg20::IGnssMeasurementCallback::GnssMeasurement; + +namespace { +void initGnssData(GnssData20& data, + int64_t elapsedRealtimeNs, + int64_t timeNs, + int64_t fullBiasNs, + double biasUncertaintyNs, + size_t nMeasurements) { + data.elapsedRealtime.flags = ahg20::ElapsedRealtimeFlags::HAS_TIMESTAMP_NS | 0; + data.elapsedRealtime.timestampNs = static_cast<uint64_t>(elapsedRealtimeNs); + data.clock.gnssClockFlags = GnssClockFlags10::HAS_FULL_BIAS | 0; + data.clock.timeNs = timeNs; + data.clock.fullBiasNs = fullBiasNs; + data.clock.biasUncertaintyNs = biasUncertaintyNs; + data.measurements.resize(nMeasurements); +} + +GnssMeasurementT20 makeGnssMeasurementT20(int svid, + int state, + int64_t receivedSvTimeInNs, + int64_t receivedSvTimeUncertaintyInNs, + double cN0DbHz, + double pseudorangeRateMps, + double pseudorangeRateUncertaintyMps, + int accumulatedDeltaRangeState, + double accumulatedDeltaRangeM, + double accumulatedDeltaRangeUncertaintyM, + int multipathIndicator, + int constellation) { + using GnssMeasurementFlags10 = ahg10::IGnssMeasurementCallback::GnssMeasurementFlags; + using GnssMultipathIndicator10 = ahg10::IGnssMeasurementCallback::GnssMultipathIndicator; + using GnssAccumulatedDeltaRangeState11 = ahg11::IGnssMeasurementCallback::GnssAccumulatedDeltaRangeState; + using GnssMeasurementState20 = ahg20::IGnssMeasurementCallback::GnssMeasurementState; + + GnssMeasurementT20 m20; + auto& m11 = m20.v1_1; + auto& m10 = m11.v1_0; + + m10.flags = GnssMeasurementFlags10::HAS_CARRIER_FREQUENCY | 0; + m10.svid = svid; + m10.receivedSvTimeInNs = receivedSvTimeInNs; + m10.receivedSvTimeUncertaintyInNs = receivedSvTimeUncertaintyInNs; + m10.cN0DbHz = cN0DbHz; + m10.pseudorangeRateMps = pseudorangeRateMps; + m10.pseudorangeRateUncertaintyMps = pseudorangeRateUncertaintyMps; + m10.accumulatedDeltaRangeM = accumulatedDeltaRangeM; + m10.accumulatedDeltaRangeUncertaintyM = accumulatedDeltaRangeUncertaintyM; + m10.carrierFrequencyHz = 1.59975e+09; + m10.multipathIndicator = static_cast<GnssMultipathIndicator10>(multipathIndicator); + m11.accumulatedDeltaRangeState = + GnssAccumulatedDeltaRangeState11::ADR_STATE_UNKNOWN | accumulatedDeltaRangeState; + m20.codeType = "UNKNOWN"; + m20.state = GnssMeasurementState20::STATE_UNKNOWN | state; + m20.constellation = static_cast<ahg20::GnssConstellationType>(constellation); + + return m20; +} +} // namespace + +GnssMeasurement20::GnssMeasurement20() { + m_gnssData.resize(1); + + initGnssData(m_gnssData[0], 139287, 116834000000, -1189181444165780000, 5.26068202130163, 7); + m_gnssData[0].measurements[0] = makeGnssMeasurementT20(22, 47, 3927349114, 29, 29.9917297363281, 245.509362821673, 0.148940800975766, 1, 6620.74237064615, 0.00271145859733223, 0, 1); + m_gnssData[0].measurements[1] = makeGnssMeasurementT20(23, 47, 3920005435, 14, 36.063377380371, -731.947951627658, 0.0769754027959242, 1, -23229.096048105, 0.00142954161856323, 0, 1); + m_gnssData[0].measurements[2] = makeGnssMeasurementT20(25, 47, 3923720994, 56, 24.5171585083007, -329.789995021822, 0.277918601850871, 1, -15511.1976492851, 0.00509250536561012, 0, 1); + m_gnssData[0].measurements[3] = makeGnssMeasurementT20(31, 47, 3925772934, 11, 37.9193840026855, -380.23772244582, 0.0602980729893803, 1, -11325.9094456612, 0.00115450704470276, 0, 1); + m_gnssData[0].measurements[4] = makeGnssMeasurementT20(32, 47, 3919018415, 21, 32.8980560302734, 581.800347848025, 0.109060249597082, 1, 15707.8963147985, 0.00205808319151401, 0, 1); + m_gnssData[0].measurements[5] = makeGnssMeasurementT20(10, 227, 69142929947304, 127, 23.432445526123, 259.17838762857, 0.31591691295607, 4, 8152.78081298147, 3.40282346638528E+38, 0, 3); + m_gnssData[0].measurements[6] = makeGnssMeasurementT20(2, 227, 69142935176327, 41, 33.180908203125, -53.8773853795901, 0.104984458760586, 1, -1708.08166640048, 0.00196184404194355, 0, 3); +} GnssMeasurement20::~GnssMeasurement20() { if (m_isRunning) { @@ -72,74 +144,10 @@ void GnssMeasurement20::stopLocked() { } void GnssMeasurement20::update() { - using GnssMeasurement20 = ahg20::IGnssMeasurementCallback::GnssMeasurement; - using GnssAccumulatedDeltaRangeState10 = ahg10::IGnssMeasurementCallback::GnssAccumulatedDeltaRangeState; - using GnssMeasurementFlags10 = ahg10::IGnssMeasurementCallback::GnssMeasurementFlags; - using GnssMultipathIndicator10 = ahg10::IGnssMeasurementCallback::GnssMultipathIndicator; - using GnssMeasurementState20 = ahg20::IGnssMeasurementCallback::GnssMeasurementState; - using GnssData = ahg20::IGnssMeasurementCallback::GnssData; - - ahg10::IGnssMeasurementCallback::GnssMeasurement measurement10 = { - .flags = GnssMeasurementFlags10::HAS_CARRIER_FREQUENCY | 0, - .svid = 6, - .constellation = ahg10::GnssConstellationType::GPS, - .timeOffsetNs = 0.0, - .receivedSvTimeInNs = 8195997131077, - .receivedSvTimeUncertaintyInNs = 15, - .cN0DbHz = 30.0, - .pseudorangeRateMps = -484.13739013671875, - .pseudorangeRateUncertaintyMps = 0.12, - .accumulatedDeltaRangeState = GnssAccumulatedDeltaRangeState10::ADR_STATE_UNKNOWN | 0, - .accumulatedDeltaRangeM = 0.0, - .accumulatedDeltaRangeUncertaintyM = 0.0, - .carrierFrequencyHz = 1.59975e+09, - .multipathIndicator = GnssMultipathIndicator10::INDICATOR_UNKNOWN - }; - ahg11::IGnssMeasurementCallback::GnssMeasurement measurement11 = { - .v1_0 = measurement10, - .accumulatedDeltaRangeState = 0 - }; - - ahg20::IGnssMeasurementCallback::GnssMeasurement measurement20 = { - .v1_1 = measurement11, - .codeType = "C", - .state = GnssMeasurementState20::STATE_CODE_LOCK | - GnssMeasurementState20::STATE_BIT_SYNC | - GnssMeasurementState20::STATE_SUBFRAME_SYNC | - GnssMeasurementState20::STATE_TOW_DECODED | - GnssMeasurementState20::STATE_GLO_STRING_SYNC | - GnssMeasurementState20::STATE_GLO_TOD_DECODED, - .constellation = ahg20::GnssConstellationType::GPS, - }; - - hidl_vec<GnssMeasurement20> measurements(1); - measurements[0] = measurement20; - - const int64_t nowNs = util::nowNanos(); - const int64_t fullBiasNs = (nowNs % 15331) * ((nowNs & 1) ? -1 : 1); - const int64_t hwTimeNs = nowNs + fullBiasNs; // local hardware clock - - ahg10::IGnssMeasurementCallback::GnssClock clock10 = { - .gnssClockFlags = 0, - .leapSecond = 0, - .timeNs = hwTimeNs, - .timeUncertaintyNs = 4.5, - .fullBiasNs = fullBiasNs, - .biasNs = 1.5, - .biasUncertaintyNs = .7, - .driftNsps = -51.757811607455452, - .driftUncertaintyNsps = 310.64968328491528, - .hwClockDiscontinuityCount = 1 - }; - - GnssData gnssData = { - .measurements = measurements, - .clock = clock10, - .elapsedRealtime = util::makeElapsedRealtime(util::nowNanos()) - }; - std::unique_lock<std::mutex> lock(m_mtx); - m_callback->gnssMeasurementCb_2_0(gnssData); + + m_callback->gnssMeasurementCb_2_0(m_gnssData[m_gnssDataIndex]); + m_gnssDataIndex = (m_gnssDataIndex + 1) % m_gnssData.size(); } /// old and deprecated ///////////////////////////////////////////////////////// @@ -151,5 +159,4 @@ Return<GnssMeasurementStatus10> GnssMeasurement20::setCallback(const sp<ahg10::I return GnssMeasurementStatus10::ERROR_GENERIC; } - } // namespace goldfish diff --git a/gnss/gnss_measurement.h b/gnss/gnss_measurement.h index 8da3b4c1..10110807 100644 --- a/gnss/gnss_measurement.h +++ b/gnss/gnss_measurement.h @@ -26,11 +26,13 @@ namespace ahg20 = ahg::V2_0; namespace ahg11 = ahg::V1_1; namespace ahg10 = ahg::V1_0; using GnssMeasurementStatus10 = ahg10::IGnssMeasurement::GnssMeasurementStatus; +using GnssData20 = ahg20::IGnssMeasurementCallback::GnssData; using ::android::sp; using ::android::hardware::Return; struct GnssMeasurement20 : public ahg20::IGnssMeasurement { + GnssMeasurement20(); ~GnssMeasurement20(); // Methods from V2_0::IGnssMeasurement follow. @@ -51,7 +53,10 @@ private: sp<ahg20::IGnssMeasurementCallback> m_callback; std::thread m_thread; std::atomic<bool> m_isRunning; + int m_gnssDataIndex = 0; mutable std::mutex m_mtx; + + std::vector<GnssData20> m_gnssData; }; } // namespace goldfish diff --git a/init.goldfish.rc b/init.goldfish.rc index 70dca25c..efe12572 100644 --- a/init.goldfish.rc +++ b/init.goldfish.rc @@ -108,8 +108,7 @@ service fingerprintd /system/bin/fingerprintd class late_start user system -service bugreport /system/bin/dumpstate -d -p -B \ - -o /data/user_de/0/com.android.shell/files/bugreports/bugreport +service bugreport /system/bin/dumpstate -d -p class main disabled oneshot diff --git a/init.ranchu.rc b/init.ranchu.rc index 1eb8f5ae..4a98d351 100644 --- a/init.ranchu.rc +++ b/init.ranchu.rc @@ -49,7 +49,7 @@ on post-fs-data mkdir /data/vendor/var 0755 root root mkdir /data/vendor/var/run 0755 root root mkdir /data/vendor/var/run/netns 0755 root root - start ranchu-net + start create_router_ns on zygote-start # Create the directories used by the Wireless subsystem @@ -65,6 +65,10 @@ on boot setprop ro.opengles.version ${ro.kernel.qemu.opengles.version} setprop ro.zygote.disable_gl_preload 1 + # 0: omx; 4: c2 default now + setprop debug.stagefright.ccodec 4 + setprop debug.stagefright.ccodec ${ro.kernel.qemu.media.ccodec} + setprop dalvik.vm.heapsize 192m setprop dalvik.vm.heapsize ${ro.kernel.qemu.dalvik.vm.heapsize} chown root system /sys/power/wake_lock @@ -76,7 +80,7 @@ on boot start goldfish-logcat - # Create a dummy USB gadget to allow sysfs testing + # Create an unused USB gadget to allow sysfs testing mkdir /config/usb_gadget/g1 0770 root root service ranchu-setup /vendor/bin/init.ranchu-core.sh @@ -95,6 +99,9 @@ on property:dev.bootcomplete=1 setprop vendor.qemu.dev.bootcomplete 1 start ranchu-setup +on property:qemu.networknamespace=ready + start ranchu-net + service ranchu-net /vendor/bin/init.ranchu-net.sh class late_start user root @@ -112,6 +119,12 @@ service netmgr /vendor/bin/execns router /vendor/bin/netmgr --if-prefix wlan1 -- group root wifi disabled +service create_router_ns /vendor/bin/createns router + user root + group root + disabled + oneshot + service wifi_forwarder /vendor/bin/wifi_forwarder user root group root wifi @@ -159,8 +172,7 @@ service goldfish-logcat /system/bin/logcat -Q group log oneshot -service bugreport /system/bin/dumpstate -d -p -B -z \ - -o /data/user_de/0/com.android.shell/files/bugreports/bugreport +service bugreport /system/bin/dumpstate -d -p -z class main disabled oneshot @@ -170,6 +182,7 @@ service wpa_supplicant /vendor/bin/hw/wpa_supplicant -Dnl80211 -iwlan0 -c/vendor interface android.hardware.wifi.supplicant@1.0::ISupplicant default interface android.hardware.wifi.supplicant@1.1::ISupplicant default interface android.hardware.wifi.supplicant@1.2::ISupplicant default + interface android.hardware.wifi.supplicant@1.3::ISupplicant default socket wpa_wlan0 dgram 660 wifi wifi group system wifi inet oneshot diff --git a/input-mt/virtio_input_multi_touch_2.idc b/input-mt/virtio_input_multi_touch_2.idc index 548d5b0e..8e1b02ab 100644 --- a/input-mt/virtio_input_multi_touch_2.idc +++ b/input-mt/virtio_input_multi_touch_2.idc @@ -9,4 +9,4 @@ cursor.orientationAware = 1 # This displayID matches the unique ID of the virtual display created for Emulator. # This will indicate to input flinger than it should link this input device # with the virtual display. -touch.displayId = local:1 +touch.displayId = local:8140900251843329 diff --git a/input-mt/virtio_input_multi_touch_3.idc b/input-mt/virtio_input_multi_touch_3.idc index d255d5fa..6a112404 100644 --- a/input-mt/virtio_input_multi_touch_3.idc +++ b/input-mt/virtio_input_multi_touch_3.idc @@ -9,4 +9,4 @@ cursor.orientationAware = 1 # This displayID matches the unique ID of the virtual display created for Emulator. # This will indicate to input flinger than it should link this input device # with the virtual display. -touch.displayId = local:2 +touch.displayId = local:8140940453066754 diff --git a/manifest.camera.xml b/manifest.camera.xml index 908c05c1..ff4dae34 100644 --- a/manifest.camera.xml +++ b/manifest.camera.xml @@ -2,10 +2,6 @@ <hal format="hidl"> <name>android.hardware.camera.provider</name> <transport>hwbinder</transport> - <version>2.4</version> - <interface> - <name>ICameraProvider</name> - <instance>legacy/0</instance> - </interface> + <fqname>@2.4::ICameraProvider/legacy/0</fqname> </hal> </manifest> diff --git a/manifest.xml b/manifest.xml index 8768250a..8d8d572e 100644 --- a/manifest.xml +++ b/manifest.xml @@ -80,7 +80,7 @@ <hal format="hidl"> <name>android.hardware.graphics.composer</name> <transport>hwbinder</transport> - <version>2.1</version> + <version>2.3</version> <interface> <name>IComposer</name> <instance>default</instance> @@ -108,32 +108,5 @@ <instance>slot1</instance> </interface> </hal> - <hal format="hidl"> - <name>android.hardware.wifi</name> - <transport>hwbinder</transport> - <version>1.3</version> - <interface> - <name>IWifi</name> - <instance>default</instance> - </interface> - </hal> - <hal format="hidl"> - <name>android.hardware.wifi.hostapd</name> - <transport>hwbinder</transport> - <version>1.0</version> - <interface> - <name>IHostapd</name> - <instance>default</instance> - </interface> - </hal> - <hal format="hidl"> - <name>android.hardware.wifi.supplicant</name> - <transport>hwbinder</transport> - <version>1.2</version> - <interface> - <name>ISupplicant</name> - <instance>default</instance> - </interface> - </hal> <kernel target-level="5"/> </manifest> diff --git a/minimal_system.mk b/minimal_system.mk new file mode 100644 index 00000000..97851eb0 --- /dev/null +++ b/minimal_system.mk @@ -0,0 +1,61 @@ +# +# Copyright 2020 Arm Ltd. All rights reserved. +# +# 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. +# + +# This file contains system partition contents needed for a minimal +# Android build that boots to shell. The items here should be present in +# build/make/target/product/base_system.mk. + +PRODUCT_PACKAGES += \ + adbd_system_api \ + apexd \ + boringssl_self_test \ + cgroups.json \ + com.android.adbd \ + com.android.conscrypt \ + debuggerd \ + hwservicemanager \ + init.environ.rc \ + init_system \ + libbinder \ + libc.bootstrap \ + libdl.bootstrap \ + libdl_android.bootstrap \ + libm.bootstrap \ + libstdc++ \ + linker \ + linkerconfig \ + logcat \ + logd \ + run-as \ + selinux_policy_system \ + servicemanager \ + shell_and_utilities_system \ + tombstoned \ + vold \ + +PRODUCT_HOST_PACKAGES += \ + adb \ + +PRODUCT_COPY_FILES += \ + system/core/rootdir/init.usb.rc:system/etc/init/hw/init.usb.rc \ + system/core/rootdir/init.usb.configfs.rc:system/etc/init/hw/init.usb.configfs.rc \ + system/core/rootdir/etc/hosts:system/etc/hosts + +PRODUCT_SYSTEM_PROPERTIES += debug.atrace.tags.enableflags=0 + +PRODUCT_PACKAGES_DEBUG := \ + strace \ + su \ diff --git a/overlay/frameworks/base/core/res/res/values/config.xml b/overlay/frameworks/base/core/res/res/values/config.xml index b466231b..b9f0babf 100644 --- a/overlay/frameworks/base/core/res/res/values/config.xml +++ b/overlay/frameworks/base/core/res/res/values/config.xml @@ -40,4 +40,18 @@ to get a smaller screen and opening the lid causes the device to enter the unfolded state which means to get a larger screen. --> <bool name="config_lidControlsDisplayFold">true</bool> + + <!-- Allow testing SoftAP using the simulated interfaces on the emulator. --> + <string-array name="config_tether_wifi_regexs"> + <item>"wlan\\d"</item> + </string-array> + + <!-- List of biometric sensors on the device, in decreasing strength. Consumed by AuthService + when registering authenticators with BiometricService. Format must be ID:Modality:Strength, + where: IDs are unique per device, Modality as defined in BiometricAuthenticator.java, + and Strength as defined in Authenticators.java --> + <string-array name="config_biometric_sensors" translatable="false" > + <item>0:2:15</item> <!-- ID0:Fingerprint:Strong --> + </string-array> + </resources> diff --git a/overlay/frameworks/base/packages/overlays/DisplayCutoutEmulationEmu01/Android.bp b/overlay/frameworks/base/packages/overlays/DisplayCutoutEmulationEmu01/Android.bp deleted file mode 100644 index 1bb89a1d..00000000 --- a/overlay/frameworks/base/packages/overlays/DisplayCutoutEmulationEmu01/Android.bp +++ /dev/null @@ -1,10 +0,0 @@ -runtime_resource_overlay { - name: "DisplayCutoutEmulationEmu01Overlay", - package_name: "DisplayCutoutEmulationEmu01Overlay", - theme: "DisplayCutoutEmulationEmu01", - certificate: "platform", - resource_dirs: [ - "res", - ], - product_specific: true, -} diff --git a/overlay/frameworks/base/packages/overlays/DisplayCutoutEmulationEmu01/Android.mk b/overlay/frameworks/base/packages/overlays/DisplayCutoutEmulationEmu01/Android.mk new file mode 100644 index 00000000..18c01387 --- /dev/null +++ b/overlay/frameworks/base/packages/overlays/DisplayCutoutEmulationEmu01/Android.mk @@ -0,0 +1,14 @@ +LOCAL_PATH:= $(call my-dir) +include $(CLEAR_VARS) + +LOCAL_RRO_THEME := DisplayCutoutEmulationEmu01 +LOCAL_CERTIFICATE := platform + +LOCAL_SRC_FILES := $(call all-subdir-java-files) + +LOCAL_RESOURCE_DIR := $(LOCAL_PATH)/res + +LOCAL_PACKAGE_NAME := DisplayCutoutEmulationEmu01Overlay +LOCAL_SDK_VERSION := current + +include $(BUILD_RRO_PACKAGE) diff --git a/radio/Android.bp b/radio/Android.bp new file mode 100644 index 00000000..a4d35789 --- /dev/null +++ b/radio/Android.bp @@ -0,0 +1,5 @@ +cc_library_headers { + name: "goldfish_ril_headers", + vendor: true, + export_include_dirs: ["include"], +} diff --git a/radio/RadioConfig/Android.bp b/radio/RadioConfig/Android.bp new file mode 100644 index 00000000..47857ae5 --- /dev/null +++ b/radio/RadioConfig/Android.bp @@ -0,0 +1,7 @@ +prebuilt_etc { + name: "privapp_whitelist_com.android.emulator.radio.config", + system_ext_specific: true, + sub_dir: "permissions", + src: "com.android.emulator.radio.config.xml", + filename_from_src: true, +} diff --git a/radio/RadioConfig/Android.mk b/radio/RadioConfig/Android.mk new file mode 100644 index 00000000..393b4017 --- /dev/null +++ b/radio/RadioConfig/Android.mk @@ -0,0 +1,14 @@ +LOCAL_PATH:= $(call my-dir) +include $(CLEAR_VARS) + +LOCAL_MODULE_TAGS := optional +LOCAL_PRIVILEGED_MODULE := true +LOCAL_SRC_FILES := $(call all-subdir-java-files) +LOCAL_PACKAGE_NAME := EmulatorRadioConfig +LOCAL_PRIVATE_PLATFORM_APIS := true +LOCAL_CERTIFICATE := platform +LOCAL_SYSTEM_EXT_MODULE := true +LOCAL_REQUIRED_MODULES := privapp_whitelist_com.android.emulator.radio.config +LOCAL_PROGUARD_ENABLED := disabled + +include $(BUILD_PACKAGE) diff --git a/radio/RadioConfig/AndroidManifest.xml b/radio/RadioConfig/AndroidManifest.xml new file mode 100644 index 00000000..3663fb02 --- /dev/null +++ b/radio/RadioConfig/AndroidManifest.xml @@ -0,0 +1,31 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + Copyright (C) 2020 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. + --> +<manifest xmlns:android="http://schemas.android.com/apk/res/android" + package="com.android.emulator.radio.config"> + + <uses-permission android:name="android.permission.MODIFY_PHONE_STATE" /> + <uses-permission android:name="android.permission.MANAGE_SUBSCRIPTION_PLANS"/> + <uses-permission android:name="android.permission.FOREGROUND_SERVICE" /> + <application> + <service + android:name=".MeterService" + android:enabled="true" + android:exported="true"> + </service> + </application> +</manifest> + diff --git a/radio/RadioConfig/NOTICE b/radio/RadioConfig/NOTICE new file mode 100644 index 00000000..c5b1efa7 --- /dev/null +++ b/radio/RadioConfig/NOTICE @@ -0,0 +1,190 @@ + + Copyright (c) 2005-2008, 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. + + 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. + + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + diff --git a/radio/RadioConfig/com.android.emulator.radio.config.xml b/radio/RadioConfig/com.android.emulator.radio.config.xml new file mode 100644 index 00000000..c21e63fe --- /dev/null +++ b/radio/RadioConfig/com.android.emulator.radio.config.xml @@ -0,0 +1,23 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- + ~ Copyright (C) 2020 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 + --> + +<permissions> + <privapp-permissions package="com.android.emulator.radio.config"> + <permission name="android.permission.MODIFY_PHONE_STATE"/> + <permission name="android.permission.MANAGE_SUBSCRIPTION_PLANS"/> + </privapp-permissions> +</permissions> diff --git a/radio/RadioConfig/radioconfig.xml b/radio/RadioConfig/radioconfig.xml new file mode 100644 index 00000000..8782c06b --- /dev/null +++ b/radio/RadioConfig/radioconfig.xml @@ -0,0 +1,48 @@ +<?xml version='1.0' encoding='utf-8'?> +<!-- + ~ Copyright (C) 2020 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 + --> + +<mobile_data> +<meterness> + +<enable> +<adb> +<string-array description="adb shell commands to turn on metered mobile data plan" num="6"> + <item value="am"/> + <item value="start-foreground-service"/> + <item value="-e"/> + <item value="meter"/> + <item value="on"/> + <item value="com.android.emulator.radio.config/.MeterService"/> +</string-array> +</adb> +</enable> + +<disable> +<adb> +<string-array description="adb shell commands to turn off metered mobile data plan" num="6"> + <item value="am"/> + <item value="start-foreground-service"/> + <item value="-e"/> + <item value="meter"/> + <item value="off"/> + <item value="com.android.emulator.radio.config/.MeterService"/> +</string-array> +</adb> +</disable> + +</meterness> +</mobile_data> diff --git a/radio/RadioConfig/src/com/android/emulator/radio/config/MeterService.java b/radio/RadioConfig/src/com/android/emulator/radio/config/MeterService.java new file mode 100644 index 00000000..644bbe5c --- /dev/null +++ b/radio/RadioConfig/src/com/android/emulator/radio/config/MeterService.java @@ -0,0 +1,112 @@ +/* + * Copyright (C) 2020 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. + */ + +package com.android.emulator.radio.config; + +import android.app.Notification; +import android.app.Notification.Builder; +import android.app.NotificationChannel; +import android.app.NotificationManager; +import android.app.Service; +import android.content.Context; +import android.content.Intent; +import android.os.IBinder; +import android.os.ServiceManager; +import android.telephony.SubscriptionInfo; +import android.telephony.SubscriptionManager; +import android.telephony.SubscriptionPlan; +import android.telephony.TelephonyManager; +import android.util.Log; +import java.time.Period; +import java.time.ZonedDateTime; +import java.util.Arrays; +import java.util.List; + +public class MeterService extends Service { + public MeterService() {} + private final String TAG = "MeterService"; + + private String createNotificationChannel(String channelId, String channelName) { + NotificationChannel chan = + new NotificationChannel(channelId, channelName, NotificationManager.IMPORTANCE_LOW); + NotificationManager service = + getApplicationContext().getSystemService(NotificationManager.class); + service.createNotificationChannel(chan); + return channelId; + } + + @Override + public int onStartCommand(Intent intent, int flags, int startId) { + String msg = intent.getStringExtra("meter"); + String meterStatus = "METERED"; + if ("on".equals(msg)) { + turnOn(); + } else if ("off".equals(msg)) { + meterStatus = "TEMPORARILY_NOT_METERED"; + turnOff(); + } + + Notification.Builder builder = + new Notification + .Builder(this, createNotificationChannel("emulator_radio_config", "Meter Service")) + .setContentTitle("Mobile Data Meter Status") + .setContentText(meterStatus) + .setSmallIcon(android.R.drawable.ic_info) + .setAutoCancel(true); + + Notification notification = builder.build(); + + startForeground(1, notification); + + return START_NOT_STICKY; + } + + private void turnOn() { + Log.v(TAG, "setting metered mobile data now"); + turn(false); + Log.v(TAG, "done setting metered mobile data"); + } + + private void turnOff() { + Log.v(TAG, "setting unmetered mobile data now"); + turn(true); + Log.v(TAG, "done setting unmetered mobile data"); + } + + private void turn(boolean status) { + SubscriptionManager mSm = getApplicationContext().getSystemService(SubscriptionManager.class); + int mSubId = SubscriptionManager.getDefaultDataSubscriptionId(); + if (mSm.getSubscriptionPlans(mSubId).isEmpty()) { + mSm.setSubscriptionPlans(mSubId, Arrays.asList(buildValidSubscriptionPlan())); + } + + mSm.setSubscriptionOverrideUnmetered(mSubId, status, 0); + } + + private static SubscriptionPlan buildValidSubscriptionPlan() { + return SubscriptionPlan.Builder + .createRecurring(ZonedDateTime.parse("2020-05-14T00:00:00.000Z"), Period.ofMonths(1)) + .setTitle("EmulatorDataPlan") + .setDataLimit(2_000_000_000, SubscriptionPlan.LIMIT_BEHAVIOR_DISABLED) + .setDataUsage(200_000_000, System.currentTimeMillis()) + .build(); + } + + @Override + public IBinder onBind(Intent intent) { + return null; + } +} diff --git a/radio/include/libril/ril_ex.h b/radio/include/libril/ril_ex.h new file mode 100644 index 00000000..757bcf9d --- /dev/null +++ b/radio/include/libril/ril_ex.h @@ -0,0 +1,49 @@ +/* +* Copyright (C) 2014 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 RIL_EX_H_INCLUDED +#define RIL_EX_H_INCLUDED + +#include <telephony/ril.h> +#include <telephony/record_stream.h> + +#define NUM_ELEMS_SOCKET(a) (sizeof (a) / sizeof (a)[0]) + +struct ril_event; + +void rilEventAddWakeup_helper(struct ril_event *ev); +int blockingWrite_helper(int fd, void* data, size_t len); + +enum SocketWakeType {DONT_WAKE, WAKE_PARTIAL}; + +typedef enum { + RIL_TELEPHONY_SOCKET, + RIL_SAP_SOCKET +} RIL_SOCKET_TYPE; + +typedef struct SocketListenParam { + RIL_SOCKET_ID socket_id; + int fdListen; + int fdCommand; + const char* processName; + struct ril_event* commands_event; + struct ril_event* listen_event; + void (*processCommandsCallback)(int fd, short flags, void *param); + RecordStream *p_rs; + RIL_SOCKET_TYPE type; +} SocketListenParam; + +#endif diff --git a/radio/include/telephony/librilutils.h b/radio/include/telephony/librilutils.h new file mode 100644 index 00000000..d06b3e9b --- /dev/null +++ b/radio/include/telephony/librilutils.h @@ -0,0 +1,38 @@ +/* + * Copyright (C) 2013 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 LIBRILUTILS_H +#define LIBRILUTILS_H + +#include <stdint.h> + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * Return system time in nanos. + * + * This is a monotonicly increasing clock and + * return the same value as System.nanoTime in java. + */ +uint64_t ril_nano_time(); + +#ifdef __cplusplus +} +#endif + +#endif // LIBRILUTILS_H diff --git a/radio/include/telephony/record_stream.h b/radio/include/telephony/record_stream.h new file mode 100644 index 00000000..7a89ae4f --- /dev/null +++ b/radio/include/telephony/record_stream.h @@ -0,0 +1,43 @@ +/* + * Copyright (C) 2006 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. + */ + +/* + * A simple utility for reading fixed records out of a stream fd + */ + +#ifndef _LIBRIL_RECORD_STREAM_H +#define _LIBRIL_RECORD_STREAM_H + +#ifdef __cplusplus +extern "C" { +#endif + + +typedef struct RecordStream RecordStream; + +extern RecordStream *record_stream_new(int fd, size_t maxRecordLen); +extern void record_stream_free(RecordStream *p_rs); + +extern int record_stream_get_next (RecordStream *p_rs, void ** p_outRecord, + size_t *p_outRecordLen); + +#ifdef __cplusplus +} +#endif + + +#endif /*_LIBRIL_RECORD_STREAM_H*/ + diff --git a/radio/include/telephony/ril.h b/radio/include/telephony/ril.h new file mode 100644 index 00000000..c879873d --- /dev/null +++ b/radio/include/telephony/ril.h @@ -0,0 +1,7378 @@ +/* + * Copyright (C) 2006 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_RIL_H +#define ANDROID_RIL_H 1 + +#include <stdlib.h> +#include <stdint.h> +#include <telephony/ril_cdma_sms.h> +#include <telephony/ril_nv_items.h> +#include <telephony/ril_msim.h> + +#ifndef FEATURE_UNIT_TEST +#include <sys/time.h> +#endif /* !FEATURE_UNIT_TEST */ + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef SIM_COUNT +#if defined(ANDROID_SIM_COUNT_2) +#define SIM_COUNT 2 +#elif defined(ANDROID_SIM_COUNT_3) +#define SIM_COUNT 3 +#elif defined(ANDROID_SIM_COUNT_4) +#define SIM_COUNT 4 +#else +#define SIM_COUNT 1 +#endif + +#ifndef ANDROID_MULTI_SIM +#define SIM_COUNT 1 +#endif +#endif + +/* + * RIL version. + * Value of RIL_VERSION should not be changed in future. Here onwards, + * when a new change is supposed to be introduced which could involve new + * schemes added like Wakelocks, data structures added/updated, etc, we would + * just document RIL version associated with that change below. When OEM updates its + * RIL with those changes, they would return that new RIL version during RIL_REGISTER. + * We should make use of the returned version by vendor to identify appropriate scheme + * or data structure version to use. + * + * Documentation of RIL version and associated changes + * RIL_VERSION = 12 : This version corresponds to updated data structures namely + * RIL_Data_Call_Response_v11, RIL_SIM_IO_v6, RIL_CardStatus_v6, + * RIL_SimRefreshResponse_v7, RIL_CDMA_CallWaiting_v6, + * RIL_LTE_SignalStrength_v8, RIL_SignalStrength_v10, RIL_CellIdentityGsm_v12 + * RIL_CellIdentityWcdma_v12, RIL_CellIdentityLte_v12,RIL_CellInfoGsm_v12, + * RIL_CellInfoWcdma_v12, RIL_CellInfoLte_v12, RIL_CellInfo_v12. + * + * RIL_VERSION = 13 : This version includes new wakelock semantics and as the first + * strongly versioned version it enforces structure use. + * + * RIL_VERSION = 14 : New data structures are added, namely RIL_CarrierMatchType, + * RIL_Carrier, RIL_CarrierRestrictions and RIL_PCO_Data. + * New commands added: RIL_REQUEST_SET_CARRIER_RESTRICTIONS, + * RIL_REQUEST_SET_CARRIER_RESTRICTIONS and RIL_UNSOL_PCO_DATA. + * + * RIL_VERSION = 15 : New commands added: + * RIL_UNSOL_MODEM_RESTART, + * RIL_REQUEST_SEND_DEVICE_STATE, + * RIL_REQUEST_SET_UNSOLICITED_RESPONSE_FILTER, + * RIL_REQUEST_SET_SIM_CARD_POWER, + * RIL_REQUEST_SET_CARRIER_INFO_IMSI_ENCRYPTION, + * RIL_UNSOL_CARRIER_INFO_IMSI_ENCRYPTION + * The new parameters for RIL_REQUEST_SETUP_DATA_CALL, + * Updated data structures: RIL_DataProfileInfo_v15, RIL_InitialAttachApn_v15 + * New data structure RIL_DataRegistrationStateResponse, + * RIL_VoiceRegistrationStateResponse same is + * used in RIL_REQUEST_DATA_REGISTRATION_STATE and + * RIL_REQUEST_VOICE_REGISTRATION_STATE respectively. + * New data structure RIL_OpenChannelParams. + * RIL_REQUEST_START_NETWORK_SCAN + * RIL_REQUEST_STOP_NETWORK_SCAN + * RIL_UNSOL_NETWORK_SCAN_RESULT + */ +#define RIL_VERSION 12 +#define LAST_IMPRECISE_RIL_VERSION 12 // Better self-documented name +#define RIL_VERSION_MIN 6 /* Minimum RIL_VERSION supported */ + +#define CDMA_ALPHA_INFO_BUFFER_LENGTH 64 +#define CDMA_NUMBER_INFO_BUFFER_LENGTH 81 + +#define MAX_RILDS 3 +#define MAX_SERVICE_NAME_LENGTH 6 +#define MAX_CLIENT_ID_LENGTH 2 +#define MAX_DEBUG_SOCKET_NAME_LENGTH 12 +#define MAX_QEMU_PIPE_NAME_LENGTH 11 +#define MAX_UUID_LENGTH 64 +#define MAX_BANDS 8 +#define MAX_CHANNELS 32 +#define MAX_RADIO_ACCESS_NETWORKS 8 +#define MAX_BROADCAST_SMS_CONFIG_INFO 25 + + +typedef void * RIL_Token; + +typedef enum { + RIL_SOCKET_1, +#if (SIM_COUNT >= 2) + RIL_SOCKET_2, +#if (SIM_COUNT >= 3) + RIL_SOCKET_3, +#endif +#if (SIM_COUNT >= 4) + RIL_SOCKET_4, +#endif +#endif + RIL_SOCKET_NUM +} RIL_SOCKET_ID; + + +typedef enum { + RIL_E_SUCCESS = 0, + RIL_E_RADIO_NOT_AVAILABLE = 1, /* If radio did not start or is resetting */ + RIL_E_GENERIC_FAILURE = 2, + RIL_E_PASSWORD_INCORRECT = 3, /* for PIN/PIN2 methods only! */ + RIL_E_SIM_PIN2 = 4, /* Operation requires SIM PIN2 to be entered */ + RIL_E_SIM_PUK2 = 5, /* Operation requires SIM PIN2 to be entered */ + RIL_E_REQUEST_NOT_SUPPORTED = 6, + RIL_E_CANCELLED = 7, + RIL_E_OP_NOT_ALLOWED_DURING_VOICE_CALL = 8, /* data ops are not allowed during voice + call on a Class C GPRS device */ + RIL_E_OP_NOT_ALLOWED_BEFORE_REG_TO_NW = 9, /* data ops are not allowed before device + registers in network */ + RIL_E_SMS_SEND_FAIL_RETRY = 10, /* fail to send sms and need retry */ + RIL_E_SIM_ABSENT = 11, /* fail to set the location where CDMA subscription + shall be retrieved because of SIM or RUIM + card absent */ + RIL_E_SUBSCRIPTION_NOT_AVAILABLE = 12, /* fail to find CDMA subscription from specified + location */ + RIL_E_MODE_NOT_SUPPORTED = 13, /* HW does not support preferred network type */ + RIL_E_FDN_CHECK_FAILURE = 14, /* command failed because recipient is not on FDN list */ + RIL_E_ILLEGAL_SIM_OR_ME = 15, /* network selection failed due to + illegal SIM or ME */ + RIL_E_MISSING_RESOURCE = 16, /* no logical channel available */ + RIL_E_NO_SUCH_ELEMENT = 17, /* application not found on SIM */ + RIL_E_DIAL_MODIFIED_TO_USSD = 18, /* DIAL request modified to USSD */ + RIL_E_DIAL_MODIFIED_TO_SS = 19, /* DIAL request modified to SS */ + RIL_E_DIAL_MODIFIED_TO_DIAL = 20, /* DIAL request modified to DIAL with different + data */ + RIL_E_USSD_MODIFIED_TO_DIAL = 21, /* USSD request modified to DIAL */ + RIL_E_USSD_MODIFIED_TO_SS = 22, /* USSD request modified to SS */ + RIL_E_USSD_MODIFIED_TO_USSD = 23, /* USSD request modified to different USSD + request */ + RIL_E_SS_MODIFIED_TO_DIAL = 24, /* SS request modified to DIAL */ + RIL_E_SS_MODIFIED_TO_USSD = 25, /* SS request modified to USSD */ + RIL_E_SUBSCRIPTION_NOT_SUPPORTED = 26, /* Subscription not supported by RIL */ + RIL_E_SS_MODIFIED_TO_SS = 27, /* SS request modified to different SS request */ + RIL_E_LCE_NOT_SUPPORTED = 36, /* LCE service not supported(36 in RILConstants.java) */ + RIL_E_NO_MEMORY = 37, /* Not sufficient memory to process the request */ + RIL_E_INTERNAL_ERR = 38, /* Modem hit unexpected error scenario while handling + this request */ + RIL_E_SYSTEM_ERR = 39, /* Hit platform or system error */ + RIL_E_MODEM_ERR = 40, /* Vendor RIL got unexpected or incorrect response + from modem for this request */ + RIL_E_INVALID_STATE = 41, /* Unexpected request for the current state */ + RIL_E_NO_RESOURCES = 42, /* Not sufficient resource to process the request */ + RIL_E_SIM_ERR = 43, /* Received error from SIM card */ + RIL_E_INVALID_ARGUMENTS = 44, /* Received invalid arguments in request */ + RIL_E_INVALID_SIM_STATE = 45, /* Can not process the request in current SIM state */ + RIL_E_INVALID_MODEM_STATE = 46, /* Can not process the request in current Modem state */ + RIL_E_INVALID_CALL_ID = 47, /* Received invalid call id in request */ + RIL_E_NO_SMS_TO_ACK = 48, /* ACK received when there is no SMS to ack */ + RIL_E_NETWORK_ERR = 49, /* Received error from network */ + RIL_E_REQUEST_RATE_LIMITED = 50, /* Operation denied due to overly-frequent requests */ + RIL_E_SIM_BUSY = 51, /* SIM is busy */ + RIL_E_SIM_FULL = 52, /* The target EF is full */ + RIL_E_NETWORK_REJECT = 53, /* Request is rejected by network */ + RIL_E_OPERATION_NOT_ALLOWED = 54, /* Not allowed the request now */ + RIL_E_EMPTY_RECORD = 55, /* The request record is empty */ + RIL_E_INVALID_SMS_FORMAT = 56, /* Invalid sms format */ + RIL_E_ENCODING_ERR = 57, /* Message not encoded properly */ + RIL_E_INVALID_SMSC_ADDRESS = 58, /* SMSC address specified is invalid */ + RIL_E_NO_SUCH_ENTRY = 59, /* No such entry present to perform the request */ + RIL_E_NETWORK_NOT_READY = 60, /* Network is not ready to perform the request */ + RIL_E_NOT_PROVISIONED = 61, /* Device doesnot have this value provisioned */ + RIL_E_NO_SUBSCRIPTION = 62, /* Device doesnot have subscription */ + RIL_E_NO_NETWORK_FOUND = 63, /* Network cannot be found */ + RIL_E_DEVICE_IN_USE = 64, /* Operation cannot be performed because the device + is currently in use */ + RIL_E_ABORTED = 65, /* Operation aborted */ + RIL_E_INVALID_RESPONSE = 66, /* Invalid response sent by vendor code */ + // OEM specific error codes. To be used by OEM when they don't want to reveal + // specific error codes which would be replaced by Generic failure. + RIL_E_OEM_ERROR_1 = 501, + RIL_E_OEM_ERROR_2 = 502, + RIL_E_OEM_ERROR_3 = 503, + RIL_E_OEM_ERROR_4 = 504, + RIL_E_OEM_ERROR_5 = 505, + RIL_E_OEM_ERROR_6 = 506, + RIL_E_OEM_ERROR_7 = 507, + RIL_E_OEM_ERROR_8 = 508, + RIL_E_OEM_ERROR_9 = 509, + RIL_E_OEM_ERROR_10 = 510, + RIL_E_OEM_ERROR_11 = 511, + RIL_E_OEM_ERROR_12 = 512, + RIL_E_OEM_ERROR_13 = 513, + RIL_E_OEM_ERROR_14 = 514, + RIL_E_OEM_ERROR_15 = 515, + RIL_E_OEM_ERROR_16 = 516, + RIL_E_OEM_ERROR_17 = 517, + RIL_E_OEM_ERROR_18 = 518, + RIL_E_OEM_ERROR_19 = 519, + RIL_E_OEM_ERROR_20 = 520, + RIL_E_OEM_ERROR_21 = 521, + RIL_E_OEM_ERROR_22 = 522, + RIL_E_OEM_ERROR_23 = 523, + RIL_E_OEM_ERROR_24 = 524, + RIL_E_OEM_ERROR_25 = 525 +} RIL_Errno; + +typedef enum { + RIL_CALL_ACTIVE = 0, + RIL_CALL_HOLDING = 1, + RIL_CALL_DIALING = 2, /* MO call only */ + RIL_CALL_ALERTING = 3, /* MO call only */ + RIL_CALL_INCOMING = 4, /* MT call only */ + RIL_CALL_WAITING = 5 /* MT call only */ +} RIL_CallState; + +typedef enum { + RADIO_STATE_OFF = 0, /* Radio explictly powered off (eg CFUN=0) */ + RADIO_STATE_UNAVAILABLE = 1, /* Radio unavailable (eg, resetting or not booted) */ + RADIO_STATE_ON = 10 /* Radio is on */ +} RIL_RadioState; + +typedef enum { + RADIO_TECH_UNKNOWN = 0, + RADIO_TECH_GPRS = 1, + RADIO_TECH_EDGE = 2, + RADIO_TECH_UMTS = 3, + RADIO_TECH_IS95A = 4, + RADIO_TECH_IS95B = 5, + RADIO_TECH_1xRTT = 6, + RADIO_TECH_EVDO_0 = 7, + RADIO_TECH_EVDO_A = 8, + RADIO_TECH_HSDPA = 9, + RADIO_TECH_HSUPA = 10, + RADIO_TECH_HSPA = 11, + RADIO_TECH_EVDO_B = 12, + RADIO_TECH_EHRPD = 13, + RADIO_TECH_LTE = 14, + RADIO_TECH_HSPAP = 15, // HSPA+ + RADIO_TECH_GSM = 16, // Only supports voice + RADIO_TECH_TD_SCDMA = 17, + RADIO_TECH_IWLAN = 18, + RADIO_TECH_LTE_CA = 19 +} RIL_RadioTechnology; + +typedef enum { + RAF_UNKNOWN = (1 << RADIO_TECH_UNKNOWN), + RAF_GPRS = (1 << RADIO_TECH_GPRS), + RAF_EDGE = (1 << RADIO_TECH_EDGE), + RAF_UMTS = (1 << RADIO_TECH_UMTS), + RAF_IS95A = (1 << RADIO_TECH_IS95A), + RAF_IS95B = (1 << RADIO_TECH_IS95B), + RAF_1xRTT = (1 << RADIO_TECH_1xRTT), + RAF_EVDO_0 = (1 << RADIO_TECH_EVDO_0), + RAF_EVDO_A = (1 << RADIO_TECH_EVDO_A), + RAF_HSDPA = (1 << RADIO_TECH_HSDPA), + RAF_HSUPA = (1 << RADIO_TECH_HSUPA), + RAF_HSPA = (1 << RADIO_TECH_HSPA), + RAF_EVDO_B = (1 << RADIO_TECH_EVDO_B), + RAF_EHRPD = (1 << RADIO_TECH_EHRPD), + RAF_LTE = (1 << RADIO_TECH_LTE), + RAF_HSPAP = (1 << RADIO_TECH_HSPAP), + RAF_GSM = (1 << RADIO_TECH_GSM), + RAF_TD_SCDMA = (1 << RADIO_TECH_TD_SCDMA), + RAF_LTE_CA = (1 << RADIO_TECH_LTE_CA) +} RIL_RadioAccessFamily; + +typedef enum { + BAND_MODE_UNSPECIFIED = 0, //"unspecified" (selected by baseband automatically) + BAND_MODE_EURO = 1, //"EURO band" (GSM-900 / DCS-1800 / WCDMA-IMT-2000) + BAND_MODE_USA = 2, //"US band" (GSM-850 / PCS-1900 / WCDMA-850 / WCDMA-PCS-1900) + BAND_MODE_JPN = 3, //"JPN band" (WCDMA-800 / WCDMA-IMT-2000) + BAND_MODE_AUS = 4, //"AUS band" (GSM-900 / DCS-1800 / WCDMA-850 / WCDMA-IMT-2000) + BAND_MODE_AUS_2 = 5, //"AUS band 2" (GSM-900 / DCS-1800 / WCDMA-850) + BAND_MODE_CELL_800 = 6, //"Cellular" (800-MHz Band) + BAND_MODE_PCS = 7, //"PCS" (1900-MHz Band) + BAND_MODE_JTACS = 8, //"Band Class 3" (JTACS Band) + BAND_MODE_KOREA_PCS = 9, //"Band Class 4" (Korean PCS Band) + BAND_MODE_5_450M = 10, //"Band Class 5" (450-MHz Band) + BAND_MODE_IMT2000 = 11, //"Band Class 6" (2-GMHz IMT2000 Band) + BAND_MODE_7_700M_2 = 12, //"Band Class 7" (Upper 700-MHz Band) + BAND_MODE_8_1800M = 13, //"Band Class 8" (1800-MHz Band) + BAND_MODE_9_900M = 14, //"Band Class 9" (900-MHz Band) + BAND_MODE_10_800M_2 = 15, //"Band Class 10" (Secondary 800-MHz Band) + BAND_MODE_EURO_PAMR_400M = 16, //"Band Class 11" (400-MHz European PAMR Band) + BAND_MODE_AWS = 17, //"Band Class 15" (AWS Band) + BAND_MODE_USA_2500M = 18 //"Band Class 16" (US 2.5-GHz Band) +} RIL_RadioBandMode; + +typedef enum { + RC_PHASE_CONFIGURED = 0, // LM is configured is initial value and value after FINISH completes + RC_PHASE_START = 1, // START is sent before Apply and indicates that an APPLY will be + // forthcoming with these same parameters + RC_PHASE_APPLY = 2, // APPLY is sent after all LM's receive START and returned + // RIL_RadioCapability.status = 0, if any START's fail no + // APPLY will be sent + RC_PHASE_UNSOL_RSP = 3, // UNSOL_RSP is sent with RIL_UNSOL_RADIO_CAPABILITY + RC_PHASE_FINISH = 4 // FINISH is sent after all commands have completed. If an error + // occurs in any previous command the RIL_RadioAccessesFamily and + // logicalModemUuid fields will be the prior configuration thus + // restoring the configuration to the previous value. An error + // returned by this command will generally be ignored or may + // cause that logical modem to be removed from service. +} RadioCapabilityPhase; + +typedef enum { + RC_STATUS_NONE = 0, // This parameter has no meaning with RC_PHASE_START, + // RC_PHASE_APPLY + RC_STATUS_SUCCESS = 1, // Tell modem the action transaction of set radio + // capability was success with RC_PHASE_FINISH + RC_STATUS_FAIL = 2, // Tell modem the action transaction of set radio + // capability is fail with RC_PHASE_FINISH. +} RadioCapabilityStatus; + +#define RIL_RADIO_CAPABILITY_VERSION 1 +typedef struct { + int version; // Version of structure, RIL_RADIO_CAPABILITY_VERSION + int session; // Unique session value defined by framework returned in all "responses/unsol" + int phase; // CONFIGURED, START, APPLY, FINISH + int rat; // RIL_RadioAccessFamily for the radio + char logicalModemUuid[MAX_UUID_LENGTH]; // A UUID typically "com.xxxx.lmX where X is the logical modem. + int status; // Return status and an input parameter for RC_PHASE_FINISH +} RIL_RadioCapability; + +// Do we want to split Data from Voice and the use +// RIL_RadioTechnology for get/setPreferredVoice/Data ? +typedef enum { + PREF_NET_TYPE_GSM_WCDMA = 0, /* GSM/WCDMA (WCDMA preferred) */ + PREF_NET_TYPE_GSM_ONLY = 1, /* GSM only */ + PREF_NET_TYPE_WCDMA = 2, /* WCDMA */ + PREF_NET_TYPE_GSM_WCDMA_AUTO = 3, /* GSM/WCDMA (auto mode, according to PRL) */ + PREF_NET_TYPE_CDMA_EVDO_AUTO = 4, /* CDMA and EvDo (auto mode, according to PRL) */ + PREF_NET_TYPE_CDMA_ONLY = 5, /* CDMA only */ + PREF_NET_TYPE_EVDO_ONLY = 6, /* EvDo only */ + PREF_NET_TYPE_GSM_WCDMA_CDMA_EVDO_AUTO = 7, /* GSM/WCDMA, CDMA, and EvDo (auto mode, according to PRL) */ + PREF_NET_TYPE_LTE_CDMA_EVDO = 8, /* LTE, CDMA and EvDo */ + PREF_NET_TYPE_LTE_GSM_WCDMA = 9, /* LTE, GSM/WCDMA */ + PREF_NET_TYPE_LTE_CMDA_EVDO_GSM_WCDMA = 10, /* LTE, CDMA, EvDo, GSM/WCDMA */ + PREF_NET_TYPE_LTE_ONLY = 11, /* LTE only */ + PREF_NET_TYPE_LTE_WCDMA = 12, /* LTE/WCDMA */ + PREF_NET_TYPE_TD_SCDMA_ONLY = 13, /* TD-SCDMA only */ + PREF_NET_TYPE_TD_SCDMA_WCDMA = 14, /* TD-SCDMA and WCDMA */ + PREF_NET_TYPE_TD_SCDMA_LTE = 15, /* TD-SCDMA and LTE */ + PREF_NET_TYPE_TD_SCDMA_GSM = 16, /* TD-SCDMA and GSM */ + PREF_NET_TYPE_TD_SCDMA_GSM_LTE = 17, /* TD-SCDMA,GSM and LTE */ + PREF_NET_TYPE_TD_SCDMA_GSM_WCDMA = 18, /* TD-SCDMA, GSM/WCDMA */ + PREF_NET_TYPE_TD_SCDMA_WCDMA_LTE = 19, /* TD-SCDMA, WCDMA and LTE */ + PREF_NET_TYPE_TD_SCDMA_GSM_WCDMA_LTE = 20, /* TD-SCDMA, GSM/WCDMA and LTE */ + PREF_NET_TYPE_TD_SCDMA_GSM_WCDMA_CDMA_EVDO_AUTO = 21, /* TD-SCDMA, GSM/WCDMA, CDMA and EvDo */ + PREF_NET_TYPE_TD_SCDMA_LTE_CDMA_EVDO_GSM_WCDMA = 22 /* TD-SCDMA, LTE, CDMA, EvDo GSM/WCDMA */ +} RIL_PreferredNetworkType; + +/* Source for cdma subscription */ +typedef enum { + CDMA_SUBSCRIPTION_SOURCE_RUIM_SIM = 0, + CDMA_SUBSCRIPTION_SOURCE_NV = 1 +} RIL_CdmaSubscriptionSource; + +/* User-to-User signaling Info activation types derived from 3GPP 23.087 v8.0 */ +typedef enum { + RIL_UUS_TYPE1_IMPLICIT = 0, + RIL_UUS_TYPE1_REQUIRED = 1, + RIL_UUS_TYPE1_NOT_REQUIRED = 2, + RIL_UUS_TYPE2_REQUIRED = 3, + RIL_UUS_TYPE2_NOT_REQUIRED = 4, + RIL_UUS_TYPE3_REQUIRED = 5, + RIL_UUS_TYPE3_NOT_REQUIRED = 6 +} RIL_UUS_Type; + +/* User-to-User Signaling Information data coding schemes. Possible values for + * Octet 3 (Protocol Discriminator field) in the UUIE. The values have been + * specified in section 10.5.4.25 of 3GPP TS 24.008 */ +typedef enum { + RIL_UUS_DCS_USP = 0, /* User specified protocol */ + RIL_UUS_DCS_OSIHLP = 1, /* OSI higher layer protocol */ + RIL_UUS_DCS_X244 = 2, /* X.244 */ + RIL_UUS_DCS_RMCF = 3, /* Reserved for system mangement + convergence function */ + RIL_UUS_DCS_IA5c = 4 /* IA5 characters */ +} RIL_UUS_DCS; + +/* User-to-User Signaling Information defined in 3GPP 23.087 v8.0 + * This data is passed in RIL_ExtensionRecord and rec contains this + * structure when type is RIL_UUS_INFO_EXT_REC */ +typedef struct { + RIL_UUS_Type uusType; /* UUS Type */ + RIL_UUS_DCS uusDcs; /* UUS Data Coding Scheme */ + int uusLength; /* Length of UUS Data */ + char * uusData; /* UUS Data */ +} RIL_UUS_Info; + +/* CDMA Signal Information Record as defined in C.S0005 section 3.7.5.5 */ +typedef struct { + char isPresent; /* non-zero if signal information record is present */ + char signalType; /* as defined 3.7.5.5-1 */ + char alertPitch; /* as defined 3.7.5.5-2 */ + char signal; /* as defined 3.7.5.5-3, 3.7.5.5-4 or 3.7.5.5-5 */ +} RIL_CDMA_SignalInfoRecord; + +typedef struct { + RIL_CallState state; + int index; /* Connection Index for use with, eg, AT+CHLD */ + int toa; /* type of address, eg 145 = intl */ + char isMpty; /* nonzero if is mpty call */ + char isMT; /* nonzero if call is mobile terminated */ + char als; /* ALS line indicator if available + (0 = line 1) */ + char isVoice; /* nonzero if this is is a voice call */ + char isVoicePrivacy; /* nonzero if CDMA voice privacy mode is active */ + char * number; /* Remote party number */ + int numberPresentation; /* 0=Allowed, 1=Restricted, 2=Not Specified/Unknown 3=Payphone */ + char * name; /* Remote party name */ + int namePresentation; /* 0=Allowed, 1=Restricted, 2=Not Specified/Unknown 3=Payphone */ + RIL_UUS_Info * uusInfo; /* NULL or Pointer to User-User Signaling Information */ +} RIL_Call; + +/* Deprecated, use RIL_Data_Call_Response_v6 */ +typedef struct { + int cid; /* Context ID, uniquely identifies this call */ + int active; /* 0=inactive, 1=active/physical link down, 2=active/physical link up */ + char * type; /* One of the PDP_type values in TS 27.007 section 10.1.1. + For example, "IP", "IPV6", "IPV4V6", or "PPP". */ + char * apn; /* ignored */ + char * address; /* An address, e.g., "192.0.1.3" or "2001:db8::1". */ +} RIL_Data_Call_Response_v4; + +/* + * Returned by RIL_REQUEST_SETUP_DATA_CALL, RIL_REQUEST_DATA_CALL_LIST + * and RIL_UNSOL_DATA_CALL_LIST_CHANGED, on error status != 0. + */ +typedef struct { + int status; /* A RIL_DataCallFailCause, 0 which is PDP_FAIL_NONE if no error */ + int suggestedRetryTime; /* If status != 0, this fields indicates the suggested retry + back-off timer value RIL wants to override the one + pre-configured in FW. + The unit is miliseconds. + The value < 0 means no value is suggested. + The value 0 means retry should be done ASAP. + The value of INT_MAX(0x7fffffff) means no retry. */ + int cid; /* Context ID, uniquely identifies this call */ + int active; /* 0=inactive, 1=active/physical link down, 2=active/physical link up */ + char * type; /* One of the PDP_type values in TS 27.007 section 10.1.1. + For example, "IP", "IPV6", "IPV4V6", or "PPP". If status is + PDP_FAIL_ONLY_SINGLE_BEARER_ALLOWED this is the type supported + such as "IP" or "IPV6" */ + char * ifname; /* The network interface name */ + char * addresses; /* A space-delimited list of addresses with optional "/" prefix length, + e.g., "192.0.1.3" or "192.0.1.11/16 2001:db8::1/64". + May not be empty, typically 1 IPv4 or 1 IPv6 or + one of each. If the prefix length is absent the addresses + are assumed to be point to point with IPv4 having a prefix + length of 32 and IPv6 128. */ + char * dnses; /* A space-delimited list of DNS server addresses, + e.g., "192.0.1.3" or "192.0.1.11 2001:db8::1". + May be empty. */ + char * gateways; /* A space-delimited list of default gateway addresses, + e.g., "192.0.1.3" or "192.0.1.11 2001:db8::1". + May be empty in which case the addresses represent point + to point connections. */ +} RIL_Data_Call_Response_v6; + +typedef struct { + int status; /* A RIL_DataCallFailCause, 0 which is PDP_FAIL_NONE if no error */ + int suggestedRetryTime; /* If status != 0, this fields indicates the suggested retry + back-off timer value RIL wants to override the one + pre-configured in FW. + The unit is miliseconds. + The value < 0 means no value is suggested. + The value 0 means retry should be done ASAP. + The value of INT_MAX(0x7fffffff) means no retry. */ + int cid; /* Context ID, uniquely identifies this call */ + int active; /* 0=inactive, 1=active/physical link down, 2=active/physical link up */ + char * type; /* One of the PDP_type values in TS 27.007 section 10.1.1. + For example, "IP", "IPV6", "IPV4V6", or "PPP". If status is + PDP_FAIL_ONLY_SINGLE_BEARER_ALLOWED this is the type supported + such as "IP" or "IPV6" */ + char * ifname; /* The network interface name */ + char * addresses; /* A space-delimited list of addresses with optional "/" prefix length, + e.g., "192.0.1.3" or "192.0.1.11/16 2001:db8::1/64". + May not be empty, typically 1 IPv4 or 1 IPv6 or + one of each. If the prefix length is absent the addresses + are assumed to be point to point with IPv4 having a prefix + length of 32 and IPv6 128. */ + char * dnses; /* A space-delimited list of DNS server addresses, + e.g., "192.0.1.3" or "192.0.1.11 2001:db8::1". + May be empty. */ + char * gateways; /* A space-delimited list of default gateway addresses, + e.g., "192.0.1.3" or "192.0.1.11 2001:db8::1". + May be empty in which case the addresses represent point + to point connections. */ + char * pcscf; /* the Proxy Call State Control Function address + via PCO(Protocol Configuration Option) for IMS client. */ +} RIL_Data_Call_Response_v9; + +typedef struct { + int status; /* A RIL_DataCallFailCause, 0 which is PDP_FAIL_NONE if no error */ + int suggestedRetryTime; /* If status != 0, this fields indicates the suggested retry + back-off timer value RIL wants to override the one + pre-configured in FW. + The unit is miliseconds. + The value < 0 means no value is suggested. + The value 0 means retry should be done ASAP. + The value of INT_MAX(0x7fffffff) means no retry. */ + int cid; /* Context ID, uniquely identifies this call */ + int active; /* 0=inactive, 1=active/physical link down, 2=active/physical link up */ + char * type; /* One of the PDP_type values in TS 27.007 section 10.1.1. + For example, "IP", "IPV6", "IPV4V6", or "PPP". If status is + PDP_FAIL_ONLY_SINGLE_BEARER_ALLOWED this is the type supported + such as "IP" or "IPV6" */ + char * ifname; /* The network interface name */ + char * addresses; /* A space-delimited list of addresses with optional "/" prefix length, + e.g., "192.0.1.3" or "192.0.1.11/16 2001:db8::1/64". + May not be empty, typically 1 IPv4 or 1 IPv6 or + one of each. If the prefix length is absent the addresses + are assumed to be point to point with IPv4 having a prefix + length of 32 and IPv6 128. */ + char * dnses; /* A space-delimited list of DNS server addresses, + e.g., "192.0.1.3" or "192.0.1.11 2001:db8::1". + May be empty. */ + char * gateways; /* A space-delimited list of default gateway addresses, + e.g., "192.0.1.3" or "192.0.1.11 2001:db8::1". + May be empty in which case the addresses represent point + to point connections. */ + char * pcscf; /* the Proxy Call State Control Function address + via PCO(Protocol Configuration Option) for IMS client. */ + int mtu; /* MTU received from network + Value <= 0 means network has either not sent a value or + sent an invalid value */ +} RIL_Data_Call_Response_v11; + +typedef enum { + RADIO_TECH_3GPP = 1, /* 3GPP Technologies - GSM, WCDMA */ + RADIO_TECH_3GPP2 = 2 /* 3GPP2 Technologies - CDMA */ +} RIL_RadioTechnologyFamily; + +typedef struct { + RIL_RadioTechnologyFamily tech; + unsigned char retry; /* 0 == not retry, nonzero == retry */ + int messageRef; /* Valid field if retry is set to nonzero. + Contains messageRef from RIL_SMS_Response + corresponding to failed MO SMS. + */ + + union { + /* Valid field if tech is RADIO_TECH_3GPP2. See RIL_REQUEST_CDMA_SEND_SMS */ + RIL_CDMA_SMS_Message* cdmaMessage; + + /* Valid field if tech is RADIO_TECH_3GPP. See RIL_REQUEST_SEND_SMS */ + char** gsmMessage; /* This is an array of pointers where pointers + are contiguous but elements pointed by those pointers + are not contiguous + */ + } message; +} RIL_IMS_SMS_Message; + +typedef struct { + int messageRef; /* TP-Message-Reference for GSM, + and BearerData MessageId for CDMA + (See 3GPP2 C.S0015-B, v2.0, table 4.5-1). */ + char *ackPDU; /* or NULL if n/a */ + int errorCode; /* See 3GPP 27.005, 3.2.5 for GSM/UMTS, + 3GPP2 N.S0005 (IS-41C) Table 171 for CDMA, + -1 if unknown or not applicable*/ +} RIL_SMS_Response; + +/** Used by RIL_REQUEST_WRITE_SMS_TO_SIM */ +typedef struct { + int status; /* Status of message. See TS 27.005 3.1, "<stat>": */ + /* 0 = "REC UNREAD" */ + /* 1 = "REC READ" */ + /* 2 = "STO UNSENT" */ + /* 3 = "STO SENT" */ + char * pdu; /* PDU of message to write, as an ASCII hex string less the SMSC address, + the TP-layer length is "strlen(pdu)/2". */ + char * smsc; /* SMSC address in GSM BCD format prefixed by a length byte + (as expected by TS 27.005) or NULL for default SMSC */ +} RIL_SMS_WriteArgs; + +/** Used by RIL_REQUEST_DIAL */ +typedef struct { + char * address; + int clir; + /* (same as 'n' paremeter in TS 27.007 7.7 "+CLIR" + * clir == 0 on "use subscription default value" + * clir == 1 on "CLIR invocation" (restrict CLI presentation) + * clir == 2 on "CLIR suppression" (allow CLI presentation) + */ + RIL_UUS_Info * uusInfo; /* NULL or Pointer to User-User Signaling Information */ +} RIL_Dial; + +typedef struct { + int command; /* one of the commands listed for TS 27.007 +CRSM*/ + int fileid; /* EF id */ + char *path; /* "pathid" from TS 27.007 +CRSM command. + Path is in hex asciii format eg "7f205f70" + Path must always be provided. + */ + int p1; + int p2; + int p3; + char *data; /* May be NULL*/ + char *pin2; /* May be NULL*/ +} RIL_SIM_IO_v5; + +typedef struct { + int command; /* one of the commands listed for TS 27.007 +CRSM*/ + int fileid; /* EF id */ + char *path; /* "pathid" from TS 27.007 +CRSM command. + Path is in hex asciii format eg "7f205f70" + Path must always be provided. + */ + int p1; + int p2; + int p3; + char *data; /* May be NULL*/ + char *pin2; /* May be NULL*/ + char *aidPtr; /* AID value, See ETSI 102.221 8.1 and 101.220 4, NULL if no value. */ +} RIL_SIM_IO_v6; + +/* Used by RIL_REQUEST_SIM_TRANSMIT_APDU_CHANNEL and + * RIL_REQUEST_SIM_TRANSMIT_APDU_BASIC. */ +typedef struct { + int sessionid; /* "sessionid" from TS 27.007 +CGLA command. Should be + ignored for +CSIM command. */ + + /* Following fields are used to derive the APDU ("command" and "length" + values in TS 27.007 +CSIM and +CGLA commands). */ + int cla; + int instruction; + int p1; + int p2; + int p3; /* A negative P3 implies a 4 byte APDU. */ + char *data; /* May be NULL. In hex string format. */ +} RIL_SIM_APDU; + +typedef struct { + int sw1; + int sw2; + char *simResponse; /* In hex string format ([a-fA-F0-9]*), except for SIM_AUTHENTICATION + response for which it is in Base64 format, see 3GPP TS 31.102 7.1.2 */ +} RIL_SIM_IO_Response; + +/* See also com.android.internal.telephony.gsm.CallForwardInfo */ + +typedef struct { + int status; /* + * For RIL_REQUEST_QUERY_CALL_FORWARD_STATUS + * status 1 = active, 0 = not active + * + * For RIL_REQUEST_SET_CALL_FORWARD: + * status is: + * 0 = disable + * 1 = enable + * 2 = interrogate + * 3 = registeration + * 4 = erasure + */ + + int reason; /* from TS 27.007 7.11 "reason" */ + int serviceClass;/* From 27.007 +CCFC/+CLCK "class" + See table for Android mapping from + MMI service code + 0 means user doesn't input class */ + int toa; /* "type" from TS 27.007 7.11 */ + char * number; /* "number" from TS 27.007 7.11. May be NULL */ + int timeSeconds; /* for CF no reply only */ +}RIL_CallForwardInfo; + +typedef struct { + char * cid; /* Combination of LAC and Cell Id in 32 bits in GSM. + * Upper 16 bits is LAC and lower 16 bits + * is CID (as described in TS 27.005) + * Primary Scrambling Code (as described in TS 25.331) + * in 9 bits in UMTS + * Valid values are hexadecimal 0x0000 - 0xffffffff. + */ + int rssi; /* Received RSSI in GSM, + * Level index of CPICH Received Signal Code Power in UMTS + */ +} RIL_NeighboringCell; + +typedef struct { + char lce_status; /* LCE service status: + * -1 = not supported; + * 0 = stopped; + * 1 = active. + */ + unsigned int actual_interval_ms; /* actual LCE reporting interval, + * meaningful only if LCEStatus = 1. + */ +} RIL_LceStatusInfo; + +typedef struct { + unsigned int last_hop_capacity_kbps; /* last-hop cellular capacity: kilobits/second. */ + unsigned char confidence_level; /* capacity estimate confidence: 0-100 */ + unsigned char lce_suspended; /* LCE report going to be suspended? (e.g., radio + * moves to inactive state or network type change) + * 1 = suspended; + * 0 = not suspended. + */ +} RIL_LceDataInfo; + +typedef enum { + RIL_MATCH_ALL = 0, /* Apply to all carriers with the same mcc/mnc */ + RIL_MATCH_SPN = 1, /* Use SPN and mcc/mnc to identify the carrier */ + RIL_MATCH_IMSI_PREFIX = 2, /* Use IMSI prefix and mcc/mnc to identify the carrier */ + RIL_MATCH_GID1 = 3, /* Use GID1 and mcc/mnc to identify the carrier */ + RIL_MATCH_GID2 = 4, /* Use GID2 and mcc/mnc to identify the carrier */ +} RIL_CarrierMatchType; + +typedef struct { + const char * mcc; + const char * mnc; + RIL_CarrierMatchType match_type; /* Specify match type for the carrier. + * If it’s RIL_MATCH_ALL, match_data is null; + * otherwise, match_data is the value for the match type. + */ + const char * match_data; +} RIL_Carrier; + +typedef struct { + int32_t len_allowed_carriers; /* length of array allowed_carriers */ + int32_t len_excluded_carriers; /* length of array excluded_carriers */ + RIL_Carrier * allowed_carriers; /* list of allowed carriers */ + RIL_Carrier * excluded_carriers; /* list of explicitly excluded carriers + * which match allowed_carriers. Eg. allowed_carriers match + * mcc/mnc, excluded_carriers has same mcc/mnc and gid1 + * is ABCD. It means except the carrier whose gid1 is ABCD, + * all carriers with the same mcc/mnc are allowed. + */ +} RIL_CarrierRestrictions; + +typedef struct { + char * mcc; /* MCC of the Carrier. */ + char * mnc ; /* MNC of the Carrier. */ + uint8_t * carrierKey; /* Public Key from the Carrier used to encrypt the + * IMSI/IMPI. + */ + int32_t carrierKeyLength; /* Length of the Public Key. */ + char * keyIdentifier; /* The keyIdentifier Attribute value pair that helps + * a server locate the private key to decrypt the + * permanent identity. + */ + int64_t expirationTime; /* Date-Time (in UTC) when the key will expire. */ + +} RIL_CarrierInfoForImsiEncryption; + +/* See RIL_REQUEST_LAST_CALL_FAIL_CAUSE */ +typedef enum { + CALL_FAIL_UNOBTAINABLE_NUMBER = 1, + CALL_FAIL_NO_ROUTE_TO_DESTINATION = 3, + CALL_FAIL_CHANNEL_UNACCEPTABLE = 6, + CALL_FAIL_OPERATOR_DETERMINED_BARRING = 8, + CALL_FAIL_NORMAL = 16, + CALL_FAIL_BUSY = 17, + CALL_FAIL_NO_USER_RESPONDING = 18, + CALL_FAIL_NO_ANSWER_FROM_USER = 19, + CALL_FAIL_CALL_REJECTED = 21, + CALL_FAIL_NUMBER_CHANGED = 22, + CALL_FAIL_PREEMPTION = 25, + CALL_FAIL_DESTINATION_OUT_OF_ORDER = 27, + CALL_FAIL_INVALID_NUMBER_FORMAT = 28, + CALL_FAIL_FACILITY_REJECTED = 29, + CALL_FAIL_RESP_TO_STATUS_ENQUIRY = 30, + CALL_FAIL_NORMAL_UNSPECIFIED = 31, + CALL_FAIL_CONGESTION = 34, + CALL_FAIL_NETWORK_OUT_OF_ORDER = 38, + CALL_FAIL_TEMPORARY_FAILURE = 41, + CALL_FAIL_SWITCHING_EQUIPMENT_CONGESTION = 42, + CALL_FAIL_ACCESS_INFORMATION_DISCARDED = 43, + CALL_FAIL_REQUESTED_CIRCUIT_OR_CHANNEL_NOT_AVAILABLE = 44, + CALL_FAIL_RESOURCES_UNAVAILABLE_OR_UNSPECIFIED = 47, + CALL_FAIL_QOS_UNAVAILABLE = 49, + CALL_FAIL_REQUESTED_FACILITY_NOT_SUBSCRIBED = 50, + CALL_FAIL_INCOMING_CALLS_BARRED_WITHIN_CUG = 55, + CALL_FAIL_BEARER_CAPABILITY_NOT_AUTHORIZED = 57, + CALL_FAIL_BEARER_CAPABILITY_UNAVAILABLE = 58, + CALL_FAIL_SERVICE_OPTION_NOT_AVAILABLE = 63, + CALL_FAIL_BEARER_SERVICE_NOT_IMPLEMENTED = 65, + CALL_FAIL_ACM_LIMIT_EXCEEDED = 68, + CALL_FAIL_REQUESTED_FACILITY_NOT_IMPLEMENTED = 69, + CALL_FAIL_ONLY_DIGITAL_INFORMATION_BEARER_AVAILABLE = 70, + CALL_FAIL_SERVICE_OR_OPTION_NOT_IMPLEMENTED = 79, + CALL_FAIL_INVALID_TRANSACTION_IDENTIFIER = 81, + CALL_FAIL_USER_NOT_MEMBER_OF_CUG = 87, + CALL_FAIL_INCOMPATIBLE_DESTINATION = 88, + CALL_FAIL_INVALID_TRANSIT_NW_SELECTION = 91, + CALL_FAIL_SEMANTICALLY_INCORRECT_MESSAGE = 95, + CALL_FAIL_INVALID_MANDATORY_INFORMATION = 96, + CALL_FAIL_MESSAGE_TYPE_NON_IMPLEMENTED = 97, + CALL_FAIL_MESSAGE_TYPE_NOT_COMPATIBLE_WITH_PROTOCOL_STATE = 98, + CALL_FAIL_INFORMATION_ELEMENT_NON_EXISTENT = 99, + CALL_FAIL_CONDITIONAL_IE_ERROR = 100, + CALL_FAIL_MESSAGE_NOT_COMPATIBLE_WITH_PROTOCOL_STATE = 101, + CALL_FAIL_RECOVERY_ON_TIMER_EXPIRED = 102, + CALL_FAIL_PROTOCOL_ERROR_UNSPECIFIED = 111, + CALL_FAIL_INTERWORKING_UNSPECIFIED = 127, + CALL_FAIL_CALL_BARRED = 240, + CALL_FAIL_FDN_BLOCKED = 241, + CALL_FAIL_IMSI_UNKNOWN_IN_VLR = 242, + CALL_FAIL_IMEI_NOT_ACCEPTED = 243, + CALL_FAIL_DIAL_MODIFIED_TO_USSD = 244, /* STK Call Control */ + CALL_FAIL_DIAL_MODIFIED_TO_SS = 245, + CALL_FAIL_DIAL_MODIFIED_TO_DIAL = 246, + CALL_FAIL_RADIO_OFF = 247, /* Radio is OFF */ + CALL_FAIL_OUT_OF_SERVICE = 248, /* No cellular coverage */ + CALL_FAIL_NO_VALID_SIM = 249, /* No valid SIM is present */ + CALL_FAIL_RADIO_INTERNAL_ERROR = 250, /* Internal error at Modem */ + CALL_FAIL_NETWORK_RESP_TIMEOUT = 251, /* No response from network */ + CALL_FAIL_NETWORK_REJECT = 252, /* Explicit network reject */ + CALL_FAIL_RADIO_ACCESS_FAILURE = 253, /* RRC connection failure. Eg.RACH */ + CALL_FAIL_RADIO_LINK_FAILURE = 254, /* Radio Link Failure */ + CALL_FAIL_RADIO_LINK_LOST = 255, /* Radio link lost due to poor coverage */ + CALL_FAIL_RADIO_UPLINK_FAILURE = 256, /* Radio uplink failure */ + CALL_FAIL_RADIO_SETUP_FAILURE = 257, /* RRC connection setup failure */ + CALL_FAIL_RADIO_RELEASE_NORMAL = 258, /* RRC connection release, normal */ + CALL_FAIL_RADIO_RELEASE_ABNORMAL = 259, /* RRC connection release, abnormal */ + CALL_FAIL_ACCESS_CLASS_BLOCKED = 260, /* Access class barring */ + CALL_FAIL_NETWORK_DETACH = 261, /* Explicit network detach */ + CALL_FAIL_CDMA_LOCKED_UNTIL_POWER_CYCLE = 1000, + CALL_FAIL_CDMA_DROP = 1001, + CALL_FAIL_CDMA_INTERCEPT = 1002, + CALL_FAIL_CDMA_REORDER = 1003, + CALL_FAIL_CDMA_SO_REJECT = 1004, + CALL_FAIL_CDMA_RETRY_ORDER = 1005, + CALL_FAIL_CDMA_ACCESS_FAILURE = 1006, + CALL_FAIL_CDMA_PREEMPTED = 1007, + CALL_FAIL_CDMA_NOT_EMERGENCY = 1008, /* For non-emergency number dialed + during emergency callback mode */ + CALL_FAIL_CDMA_ACCESS_BLOCKED = 1009, /* CDMA network access probes blocked */ + + /* OEM specific error codes. Used to distinguish error from + * CALL_FAIL_ERROR_UNSPECIFIED and help assist debugging */ + CALL_FAIL_OEM_CAUSE_1 = 0xf001, + CALL_FAIL_OEM_CAUSE_2 = 0xf002, + CALL_FAIL_OEM_CAUSE_3 = 0xf003, + CALL_FAIL_OEM_CAUSE_4 = 0xf004, + CALL_FAIL_OEM_CAUSE_5 = 0xf005, + CALL_FAIL_OEM_CAUSE_6 = 0xf006, + CALL_FAIL_OEM_CAUSE_7 = 0xf007, + CALL_FAIL_OEM_CAUSE_8 = 0xf008, + CALL_FAIL_OEM_CAUSE_9 = 0xf009, + CALL_FAIL_OEM_CAUSE_10 = 0xf00a, + CALL_FAIL_OEM_CAUSE_11 = 0xf00b, + CALL_FAIL_OEM_CAUSE_12 = 0xf00c, + CALL_FAIL_OEM_CAUSE_13 = 0xf00d, + CALL_FAIL_OEM_CAUSE_14 = 0xf00e, + CALL_FAIL_OEM_CAUSE_15 = 0xf00f, + + CALL_FAIL_ERROR_UNSPECIFIED = 0xffff /* This error will be deprecated soon, + vendor code should make sure to map error + code to specific error */ +} RIL_LastCallFailCause; + +typedef struct { + RIL_LastCallFailCause cause_code; + char * vendor_cause; +} RIL_LastCallFailCauseInfo; + +/* See RIL_REQUEST_LAST_DATA_CALL_FAIL_CAUSE */ +typedef enum { + PDP_FAIL_NONE = 0, /* No error, connection ok */ + + /* an integer cause code defined in TS 24.008 + section 6.1.3.1.3 or TS 24.301 Release 8+ Annex B. + If the implementation does not have access to the exact cause codes, + then it should return one of the following values, + as the UI layer needs to distinguish these + cases for error notification and potential retries. */ + PDP_FAIL_OPERATOR_BARRED = 0x08, /* no retry */ + PDP_FAIL_NAS_SIGNALLING = 0x0E, + PDP_FAIL_LLC_SNDCP = 0x19, + PDP_FAIL_INSUFFICIENT_RESOURCES = 0x1A, + PDP_FAIL_MISSING_UKNOWN_APN = 0x1B, /* no retry */ + PDP_FAIL_UNKNOWN_PDP_ADDRESS_TYPE = 0x1C, /* no retry */ + PDP_FAIL_USER_AUTHENTICATION = 0x1D, /* no retry */ + PDP_FAIL_ACTIVATION_REJECT_GGSN = 0x1E, /* no retry */ + PDP_FAIL_ACTIVATION_REJECT_UNSPECIFIED = 0x1F, + PDP_FAIL_SERVICE_OPTION_NOT_SUPPORTED = 0x20, /* no retry */ + PDP_FAIL_SERVICE_OPTION_NOT_SUBSCRIBED = 0x21, /* no retry */ + PDP_FAIL_SERVICE_OPTION_OUT_OF_ORDER = 0x22, + PDP_FAIL_NSAPI_IN_USE = 0x23, /* no retry */ + PDP_FAIL_REGULAR_DEACTIVATION = 0x24, /* possibly restart radio, + based on framework config */ + PDP_FAIL_QOS_NOT_ACCEPTED = 0x25, + PDP_FAIL_NETWORK_FAILURE = 0x26, + PDP_FAIL_UMTS_REACTIVATION_REQ = 0x27, + PDP_FAIL_FEATURE_NOT_SUPP = 0x28, + PDP_FAIL_TFT_SEMANTIC_ERROR = 0x29, + PDP_FAIL_TFT_SYTAX_ERROR = 0x2A, + PDP_FAIL_UNKNOWN_PDP_CONTEXT = 0x2B, + PDP_FAIL_FILTER_SEMANTIC_ERROR = 0x2C, + PDP_FAIL_FILTER_SYTAX_ERROR = 0x2D, + PDP_FAIL_PDP_WITHOUT_ACTIVE_TFT = 0x2E, + PDP_FAIL_ONLY_IPV4_ALLOWED = 0x32, /* no retry */ + PDP_FAIL_ONLY_IPV6_ALLOWED = 0x33, /* no retry */ + PDP_FAIL_ONLY_SINGLE_BEARER_ALLOWED = 0x34, + PDP_FAIL_ESM_INFO_NOT_RECEIVED = 0x35, + PDP_FAIL_PDN_CONN_DOES_NOT_EXIST = 0x36, + PDP_FAIL_MULTI_CONN_TO_SAME_PDN_NOT_ALLOWED = 0x37, + PDP_FAIL_MAX_ACTIVE_PDP_CONTEXT_REACHED = 0x41, + PDP_FAIL_UNSUPPORTED_APN_IN_CURRENT_PLMN = 0x42, + PDP_FAIL_INVALID_TRANSACTION_ID = 0x51, + PDP_FAIL_MESSAGE_INCORRECT_SEMANTIC = 0x5F, + PDP_FAIL_INVALID_MANDATORY_INFO = 0x60, + PDP_FAIL_MESSAGE_TYPE_UNSUPPORTED = 0x61, + PDP_FAIL_MSG_TYPE_NONCOMPATIBLE_STATE = 0x62, + PDP_FAIL_UNKNOWN_INFO_ELEMENT = 0x63, + PDP_FAIL_CONDITIONAL_IE_ERROR = 0x64, + PDP_FAIL_MSG_AND_PROTOCOL_STATE_UNCOMPATIBLE = 0x65, + PDP_FAIL_PROTOCOL_ERRORS = 0x6F, /* no retry */ + PDP_FAIL_APN_TYPE_CONFLICT = 0x70, + PDP_FAIL_INVALID_PCSCF_ADDR = 0x71, + PDP_FAIL_INTERNAL_CALL_PREEMPT_BY_HIGH_PRIO_APN = 0x72, + PDP_FAIL_EMM_ACCESS_BARRED = 0x73, + PDP_FAIL_EMERGENCY_IFACE_ONLY = 0x74, + PDP_FAIL_IFACE_MISMATCH = 0x75, + PDP_FAIL_COMPANION_IFACE_IN_USE = 0x76, + PDP_FAIL_IP_ADDRESS_MISMATCH = 0x77, + PDP_FAIL_IFACE_AND_POL_FAMILY_MISMATCH = 0x78, + PDP_FAIL_EMM_ACCESS_BARRED_INFINITE_RETRY = 0x79, + PDP_FAIL_AUTH_FAILURE_ON_EMERGENCY_CALL = 0x7A, + + // OEM specific error codes. To be used by OEMs when they don't want to + // reveal error code which would be replaced by PDP_FAIL_ERROR_UNSPECIFIED + PDP_FAIL_OEM_DCFAILCAUSE_1 = 0x1001, + PDP_FAIL_OEM_DCFAILCAUSE_2 = 0x1002, + PDP_FAIL_OEM_DCFAILCAUSE_3 = 0x1003, + PDP_FAIL_OEM_DCFAILCAUSE_4 = 0x1004, + PDP_FAIL_OEM_DCFAILCAUSE_5 = 0x1005, + PDP_FAIL_OEM_DCFAILCAUSE_6 = 0x1006, + PDP_FAIL_OEM_DCFAILCAUSE_7 = 0x1007, + PDP_FAIL_OEM_DCFAILCAUSE_8 = 0x1008, + PDP_FAIL_OEM_DCFAILCAUSE_9 = 0x1009, + PDP_FAIL_OEM_DCFAILCAUSE_10 = 0x100A, + PDP_FAIL_OEM_DCFAILCAUSE_11 = 0x100B, + PDP_FAIL_OEM_DCFAILCAUSE_12 = 0x100C, + PDP_FAIL_OEM_DCFAILCAUSE_13 = 0x100D, + PDP_FAIL_OEM_DCFAILCAUSE_14 = 0x100E, + PDP_FAIL_OEM_DCFAILCAUSE_15 = 0x100F, + + /* Not mentioned in the specification */ + PDP_FAIL_VOICE_REGISTRATION_FAIL = -1, + PDP_FAIL_DATA_REGISTRATION_FAIL = -2, + + /* reasons for data call drop - network/modem disconnect */ + PDP_FAIL_SIGNAL_LOST = -3, + PDP_FAIL_PREF_RADIO_TECH_CHANGED = -4,/* preferred technology has changed, should retry + with parameters appropriate for new technology */ + PDP_FAIL_RADIO_POWER_OFF = -5, /* data call was disconnected because radio was resetting, + powered off - no retry */ + PDP_FAIL_TETHERED_CALL_ACTIVE = -6, /* data call was disconnected by modem because tethered + mode was up on same APN/data profile - no retry until + tethered call is off */ + + PDP_FAIL_ERROR_UNSPECIFIED = 0xffff, /* retry silently. Will be deprecated soon as + new error codes are added making this unnecessary */ +} RIL_DataCallFailCause; + +/* See RIL_REQUEST_SETUP_DATA_CALL */ +typedef enum { + RIL_DATA_PROFILE_DEFAULT = 0, + RIL_DATA_PROFILE_TETHERED = 1, + RIL_DATA_PROFILE_IMS = 2, + RIL_DATA_PROFILE_FOTA = 3, + RIL_DATA_PROFILE_CBS = 4, + RIL_DATA_PROFILE_OEM_BASE = 1000, /* Start of OEM-specific profiles */ + RIL_DATA_PROFILE_INVALID = 0xFFFFFFFF +} RIL_DataProfile; + +/* Used by RIL_UNSOL_SUPP_SVC_NOTIFICATION */ +typedef struct { + int notificationType; /* + * 0 = MO intermediate result code + * 1 = MT unsolicited result code + */ + int code; /* See 27.007 7.17 + "code1" for MO + "code2" for MT. */ + int index; /* CUG index. See 27.007 7.17. */ + int type; /* "type" from 27.007 7.17 (MT only). */ + char * number; /* "number" from 27.007 7.17 + (MT only, may be NULL). */ +} RIL_SuppSvcNotification; + +#define RIL_CARD_MAX_APPS 8 + +typedef enum { + RIL_CARDSTATE_ABSENT = 0, + RIL_CARDSTATE_PRESENT = 1, + RIL_CARDSTATE_ERROR = 2, + RIL_CARDSTATE_RESTRICTED = 3 /* card is present but not usable due to carrier restrictions.*/ +} RIL_CardState; + +typedef enum { + RIL_PERSOSUBSTATE_UNKNOWN = 0, /* initial state */ + RIL_PERSOSUBSTATE_IN_PROGRESS = 1, /* in between each lock transition */ + RIL_PERSOSUBSTATE_READY = 2, /* when either SIM or RUIM Perso is finished + since each app can only have 1 active perso + involved */ + RIL_PERSOSUBSTATE_SIM_NETWORK = 3, + RIL_PERSOSUBSTATE_SIM_NETWORK_SUBSET = 4, + RIL_PERSOSUBSTATE_SIM_CORPORATE = 5, + RIL_PERSOSUBSTATE_SIM_SERVICE_PROVIDER = 6, + RIL_PERSOSUBSTATE_SIM_SIM = 7, + RIL_PERSOSUBSTATE_SIM_NETWORK_PUK = 8, /* The corresponding perso lock is blocked */ + RIL_PERSOSUBSTATE_SIM_NETWORK_SUBSET_PUK = 9, + RIL_PERSOSUBSTATE_SIM_CORPORATE_PUK = 10, + RIL_PERSOSUBSTATE_SIM_SERVICE_PROVIDER_PUK = 11, + RIL_PERSOSUBSTATE_SIM_SIM_PUK = 12, + RIL_PERSOSUBSTATE_RUIM_NETWORK1 = 13, + RIL_PERSOSUBSTATE_RUIM_NETWORK2 = 14, + RIL_PERSOSUBSTATE_RUIM_HRPD = 15, + RIL_PERSOSUBSTATE_RUIM_CORPORATE = 16, + RIL_PERSOSUBSTATE_RUIM_SERVICE_PROVIDER = 17, + RIL_PERSOSUBSTATE_RUIM_RUIM = 18, + RIL_PERSOSUBSTATE_RUIM_NETWORK1_PUK = 19, /* The corresponding perso lock is blocked */ + RIL_PERSOSUBSTATE_RUIM_NETWORK2_PUK = 20, + RIL_PERSOSUBSTATE_RUIM_HRPD_PUK = 21, + RIL_PERSOSUBSTATE_RUIM_CORPORATE_PUK = 22, + RIL_PERSOSUBSTATE_RUIM_SERVICE_PROVIDER_PUK = 23, + RIL_PERSOSUBSTATE_RUIM_RUIM_PUK = 24 +} RIL_PersoSubstate; + +typedef enum { + RIL_APPSTATE_UNKNOWN = 0, + RIL_APPSTATE_DETECTED = 1, + RIL_APPSTATE_PIN = 2, /* If PIN1 or UPin is required */ + RIL_APPSTATE_PUK = 3, /* If PUK1 or Puk for UPin is required */ + RIL_APPSTATE_SUBSCRIPTION_PERSO = 4, /* perso_substate should be look at + when app_state is assigned to this value */ + RIL_APPSTATE_READY = 5 +} RIL_AppState; + +typedef enum { + RIL_PINSTATE_UNKNOWN = 0, + RIL_PINSTATE_ENABLED_NOT_VERIFIED = 1, + RIL_PINSTATE_ENABLED_VERIFIED = 2, + RIL_PINSTATE_DISABLED = 3, + RIL_PINSTATE_ENABLED_BLOCKED = 4, + RIL_PINSTATE_ENABLED_PERM_BLOCKED = 5 +} RIL_PinState; + +typedef enum { + RIL_APPTYPE_UNKNOWN = 0, + RIL_APPTYPE_SIM = 1, + RIL_APPTYPE_USIM = 2, + RIL_APPTYPE_RUIM = 3, + RIL_APPTYPE_CSIM = 4, + RIL_APPTYPE_ISIM = 5 +} RIL_AppType; + +/* + * Please note that registration state UNKNOWN is + * treated as "out of service" in the Android telephony. + * Registration state REG_DENIED must be returned if Location Update + * Reject (with cause 17 - Network Failure) is received + * repeatedly from the network, to facilitate + * "managed roaming" + */ +typedef enum { + RIL_NOT_REG_AND_NOT_SEARCHING = 0, // Not registered, MT is not currently searching + // a new operator to register + RIL_REG_HOME = 1, // Registered, home network + RIL_NOT_REG_AND_SEARCHING = 2, // Not registered, but MT is currently searching + // a new operator to register + RIL_REG_DENIED = 3, // Registration denied + RIL_UNKNOWN = 4, // Unknown + RIL_REG_ROAMING = 5, // Registered, roaming + RIL_NOT_REG_AND_EMERGENCY_AVAILABLE_AND_NOT_SEARCHING = 10, // Same as + // RIL_NOT_REG_AND_NOT_SEARCHING but indicates that + // emergency calls are enabled. + RIL_NOT_REG_AND_EMERGENCY_AVAILABLE_AND_SEARCHING = 12, // Same as RIL_NOT_REG_AND_SEARCHING + // but indicates that + // emergency calls are enabled. + RIL_REG_DENIED_AND_EMERGENCY_AVAILABLE = 13, // Same as REG_DENIED but indicates that + // emergency calls are enabled. + RIL_UNKNOWN_AND_EMERGENCY_AVAILABLE = 14, // Same as UNKNOWN but indicates that + // emergency calls are enabled. +} RIL_RegState; + +typedef struct +{ + RIL_AppType app_type; + RIL_AppState app_state; + RIL_PersoSubstate perso_substate; /* applicable only if app_state == + RIL_APPSTATE_SUBSCRIPTION_PERSO */ + char *aid_ptr; /* null terminated string, e.g., from 0xA0, 0x00 -> 0x41, + 0x30, 0x30, 0x30 */ + char *app_label_ptr; /* null terminated string */ + int pin1_replaced; /* applicable to USIM, CSIM & ISIM */ + RIL_PinState pin1; + RIL_PinState pin2; +} RIL_AppStatus; + +/* Deprecated, use RIL_CardStatus_v6 */ +typedef struct +{ + RIL_CardState card_state; + RIL_PinState universal_pin_state; /* applicable to USIM and CSIM: RIL_PINSTATE_xxx */ + int gsm_umts_subscription_app_index; /* value < RIL_CARD_MAX_APPS, -1 if none */ + int cdma_subscription_app_index; /* value < RIL_CARD_MAX_APPS, -1 if none */ + int num_applications; /* value <= RIL_CARD_MAX_APPS */ + RIL_AppStatus applications[RIL_CARD_MAX_APPS]; +} RIL_CardStatus_v5; + +typedef struct +{ + RIL_CardState card_state; + RIL_PinState universal_pin_state; /* applicable to USIM and CSIM: RIL_PINSTATE_xxx */ + int gsm_umts_subscription_app_index; /* value < RIL_CARD_MAX_APPS, -1 if none */ + int cdma_subscription_app_index; /* value < RIL_CARD_MAX_APPS, -1 if none */ + int ims_subscription_app_index; /* value < RIL_CARD_MAX_APPS, -1 if none */ + int num_applications; /* value <= RIL_CARD_MAX_APPS */ + RIL_AppStatus applications[RIL_CARD_MAX_APPS]; +} RIL_CardStatus_v6; + +/** The result of a SIM refresh, returned in data[0] of RIL_UNSOL_SIM_REFRESH + * or as part of RIL_SimRefreshResponse_v7 + */ +typedef enum { + /* A file on SIM has been updated. data[1] contains the EFID. */ + SIM_FILE_UPDATE = 0, + /* SIM initialized. All files should be re-read. */ + SIM_INIT = 1, + /* SIM reset. SIM power required, SIM may be locked and all files should be re-read. */ + SIM_RESET = 2 +} RIL_SimRefreshResult; + +typedef struct { + RIL_SimRefreshResult result; + int ef_id; /* is the EFID of the updated file if the result is */ + /* SIM_FILE_UPDATE or 0 for any other result. */ + char * aid; /* is AID(application ID) of the card application */ + /* See ETSI 102.221 8.1 and 101.220 4 */ + /* For SIM_FILE_UPDATE result it can be set to AID of */ + /* application in which updated EF resides or it can be */ + /* NULL if EF is outside of an application. */ + /* For SIM_INIT result this field is set to AID of */ + /* application that caused REFRESH */ + /* For SIM_RESET result it is NULL. */ +} RIL_SimRefreshResponse_v7; + +/* Deprecated, use RIL_CDMA_CallWaiting_v6 */ +typedef struct { + char * number; /* Remote party number */ + int numberPresentation; /* 0=Allowed, 1=Restricted, 2=Not Specified/Unknown */ + char * name; /* Remote party name */ + RIL_CDMA_SignalInfoRecord signalInfoRecord; +} RIL_CDMA_CallWaiting_v5; + +typedef struct { + char * number; /* Remote party number */ + int numberPresentation; /* 0=Allowed, 1=Restricted, 2=Not Specified/Unknown */ + char * name; /* Remote party name */ + RIL_CDMA_SignalInfoRecord signalInfoRecord; + /* Number type/Number plan required to support International Call Waiting */ + int number_type; /* 0=Unknown, 1=International, 2=National, + 3=Network specific, 4=subscriber */ + int number_plan; /* 0=Unknown, 1=ISDN, 3=Data, 4=Telex, 8=Nat'l, 9=Private */ +} RIL_CDMA_CallWaiting_v6; + +/** + * Which types of Cell Broadcast Message (CBM) are to be received by the ME + * + * uFromServiceID - uToServiceID defines a range of CBM message identifiers + * whose value is 0x0000 - 0xFFFF as defined in TS 23.041 9.4.1.2.2 for GMS + * and 9.4.4.2.2 for UMTS. All other values can be treated as empty + * CBM message ID. + * + * uFromCodeScheme - uToCodeScheme defines a range of CBM data coding schemes + * whose value is 0x00 - 0xFF as defined in TS 23.041 9.4.1.2.3 for GMS + * and 9.4.4.2.3 for UMTS. + * All other values can be treated as empty CBM data coding scheme. + * + * selected 0 means message types specified in <fromServiceId, toServiceId> + * and <fromCodeScheme, toCodeScheme>are not accepted, while 1 means accepted. + * + * Used by RIL_REQUEST_GSM_GET_BROADCAST_CONFIG and + * RIL_REQUEST_GSM_SET_BROADCAST_CONFIG. + */ +typedef struct { + int fromServiceId; + int toServiceId; + int fromCodeScheme; + int toCodeScheme; + unsigned char selected; +} RIL_GSM_BroadcastSmsConfigInfo; + +/* No restriction at all including voice/SMS/USSD/SS/AV64 and packet data. */ +#define RIL_RESTRICTED_STATE_NONE 0x00 +/* Block emergency call due to restriction. But allow all normal voice/SMS/USSD/SS/AV64. */ +#define RIL_RESTRICTED_STATE_CS_EMERGENCY 0x01 +/* Block all normal voice/SMS/USSD/SS/AV64 due to restriction. Only Emergency call allowed. */ +#define RIL_RESTRICTED_STATE_CS_NORMAL 0x02 +/* Block all voice/SMS/USSD/SS/AV64 including emergency call due to restriction.*/ +#define RIL_RESTRICTED_STATE_CS_ALL 0x04 +/* Block packet data access due to restriction. */ +#define RIL_RESTRICTED_STATE_PS_ALL 0x10 + +/* The status for an OTASP/OTAPA session */ +typedef enum { + CDMA_OTA_PROVISION_STATUS_SPL_UNLOCKED, + CDMA_OTA_PROVISION_STATUS_SPC_RETRIES_EXCEEDED, + CDMA_OTA_PROVISION_STATUS_A_KEY_EXCHANGED, + CDMA_OTA_PROVISION_STATUS_SSD_UPDATED, + CDMA_OTA_PROVISION_STATUS_NAM_DOWNLOADED, + CDMA_OTA_PROVISION_STATUS_MDN_DOWNLOADED, + CDMA_OTA_PROVISION_STATUS_IMSI_DOWNLOADED, + CDMA_OTA_PROVISION_STATUS_PRL_DOWNLOADED, + CDMA_OTA_PROVISION_STATUS_COMMITTED, + CDMA_OTA_PROVISION_STATUS_OTAPA_STARTED, + CDMA_OTA_PROVISION_STATUS_OTAPA_STOPPED, + CDMA_OTA_PROVISION_STATUS_OTAPA_ABORTED +} RIL_CDMA_OTA_ProvisionStatus; + +typedef struct { + int signalStrength; /* Valid values are (0-31, 99) as defined in TS 27.007 8.5 */ + int bitErrorRate; /* bit error rate (0-7, 99) as defined in TS 27.007 8.5 */ +} RIL_GW_SignalStrength; + +typedef struct { + int signalStrength; /* Valid values are (0-31, 99) as defined in TS 27.007 8.5 */ + int bitErrorRate; /* bit error rate (0-7, 99) as defined in TS 27.007 8.5 */ + int timingAdvance; /* Timing Advance in bit periods. 1 bit period = 48/13 us. + * INT_MAX denotes invalid value */ +} RIL_GSM_SignalStrength_v12; + +typedef struct { + int signalStrength; /* Valid values are (0-31, 99) as defined in TS 27.007 8.5 */ + int bitErrorRate; /* bit error rate (0-7, 99) as defined in TS 27.007 8.5 */ +} RIL_SignalStrengthWcdma; + +typedef struct { + int dbm; /* Valid values are positive integers. This value is the actual RSSI value + * multiplied by -1. Example: If the actual RSSI is -75, then this response + * value will be 75. + */ + int ecio; /* Valid values are positive integers. This value is the actual Ec/Io multiplied + * by -10. Example: If the actual Ec/Io is -12.5 dB, then this response value + * will be 125. + */ +} RIL_CDMA_SignalStrength; + + +typedef struct { + int dbm; /* Valid values are positive integers. This value is the actual RSSI value + * multiplied by -1. Example: If the actual RSSI is -75, then this response + * value will be 75. + */ + int ecio; /* Valid values are positive integers. This value is the actual Ec/Io multiplied + * by -10. Example: If the actual Ec/Io is -12.5 dB, then this response value + * will be 125. + */ + int signalNoiseRatio; /* Valid values are 0-8. 8 is the highest signal to noise ratio. */ +} RIL_EVDO_SignalStrength; + +typedef struct { + int signalStrength; /* Valid values are (0-31, 99) as defined in TS 27.007 8.5 */ + int rsrp; /* The current Reference Signal Receive Power in dBm multipled by -1. + * Range: 44 to 140 dBm + * INT_MAX: 0x7FFFFFFF denotes invalid value. + * Reference: 3GPP TS 36.133 9.1.4 */ + int rsrq; /* The current Reference Signal Receive Quality in dB multiplied by -1. + * Range: 20 to 3 dB. + * INT_MAX: 0x7FFFFFFF denotes invalid value. + * Reference: 3GPP TS 36.133 9.1.7 */ + int rssnr; /* The current reference signal signal-to-noise ratio in 0.1 dB units. + * Range: -200 to +300 (-200 = -20.0 dB, +300 = 30dB). + * INT_MAX : 0x7FFFFFFF denotes invalid value. + * Reference: 3GPP TS 36.101 8.1.1 */ + int cqi; /* The current Channel Quality Indicator. + * Range: 0 to 15. + * INT_MAX : 0x7FFFFFFF denotes invalid value. + * Reference: 3GPP TS 36.101 9.2, 9.3, A.4 */ +} RIL_LTE_SignalStrength; + +typedef struct { + int signalStrength; /* Valid values are (0-31, 99) as defined in TS 27.007 8.5 */ + int rsrp; /* The current Reference Signal Receive Power in dBm multipled by -1. + * Range: 44 to 140 dBm + * INT_MAX: 0x7FFFFFFF denotes invalid value. + * Reference: 3GPP TS 36.133 9.1.4 */ + int rsrq; /* The current Reference Signal Receive Quality in dB multiplied by -1. + * Range: 20 to 3 dB. + * INT_MAX: 0x7FFFFFFF denotes invalid value. + * Reference: 3GPP TS 36.133 9.1.7 */ + int rssnr; /* The current reference signal signal-to-noise ratio in 0.1 dB units. + * Range: -200 to +300 (-200 = -20.0 dB, +300 = 30dB). + * INT_MAX : 0x7FFFFFFF denotes invalid value. + * Reference: 3GPP TS 36.101 8.1.1 */ + int cqi; /* The current Channel Quality Indicator. + * Range: 0 to 15. + * INT_MAX : 0x7FFFFFFF denotes invalid value. + * Reference: 3GPP TS 36.101 9.2, 9.3, A.4 */ + int timingAdvance; /* timing advance in micro seconds for a one way trip from cell to device. + * Approximate distance can be calculated using 300m/us * timingAdvance. + * Range: 0 to 0x7FFFFFFE + * INT_MAX : 0x7FFFFFFF denotes invalid value. + * Reference: 3GPP 36.321 section 6.1.3.5 + * also: http://www.cellular-planningoptimization.com/2010/02/timing-advance-with-calculation.html */ +} RIL_LTE_SignalStrength_v8; + +typedef struct { + int rscp; /* The Received Signal Code Power in dBm multipled by -1. + * Range : 25 to 120 + * INT_MAX: 0x7FFFFFFF denotes invalid value. + * Reference: 3GPP TS 25.123, section 9.1.1.1 */ +} RIL_TD_SCDMA_SignalStrength; + +/* Deprecated, use RIL_SignalStrength_v6 */ +typedef struct { + RIL_GW_SignalStrength GW_SignalStrength; + RIL_CDMA_SignalStrength CDMA_SignalStrength; + RIL_EVDO_SignalStrength EVDO_SignalStrength; +} RIL_SignalStrength_v5; + +typedef struct { + RIL_GW_SignalStrength GW_SignalStrength; + RIL_CDMA_SignalStrength CDMA_SignalStrength; + RIL_EVDO_SignalStrength EVDO_SignalStrength; + RIL_LTE_SignalStrength LTE_SignalStrength; +} RIL_SignalStrength_v6; + +typedef struct { + RIL_GW_SignalStrength GW_SignalStrength; + RIL_CDMA_SignalStrength CDMA_SignalStrength; + RIL_EVDO_SignalStrength EVDO_SignalStrength; + RIL_LTE_SignalStrength_v8 LTE_SignalStrength; +} RIL_SignalStrength_v8; + +typedef struct { + RIL_GW_SignalStrength GW_SignalStrength; + RIL_CDMA_SignalStrength CDMA_SignalStrength; + RIL_EVDO_SignalStrength EVDO_SignalStrength; + RIL_LTE_SignalStrength_v8 LTE_SignalStrength; + RIL_TD_SCDMA_SignalStrength TD_SCDMA_SignalStrength; +} RIL_SignalStrength_v10; + +typedef struct { + int mcc; /* 3-digit Mobile Country Code, 0..999, INT_MAX if unknown */ + int mnc; /* 2 or 3-digit Mobile Network Code, 0..999; + the most significant nibble encodes the number of digits - {2, 3, 0 (unset)}; + INT_MAX if unknown */ + int lac; /* 16-bit Location Area Code, 0..65535, INT_MAX if unknown */ + int cid; /* 16-bit GSM Cell Identity described in TS 27.007, 0..65535, INT_MAX if unknown */ +} RIL_CellIdentityGsm; + +typedef struct { + int mcc; /* 3-digit Mobile Country Code, 0..999, INT_MAX if unknown */ + int mnc; /* 2 or 3-digit Mobile Network Code, 0..999; + the most significant nibble encodes the number of digits - {2, 3, 0 (unset)}; + INT_MAX if unknown */ + int lac; /* 16-bit Location Area Code, 0..65535, INT_MAX if unknown */ + int cid; /* 16-bit GSM Cell Identity described in TS 27.007, 0..65535, INT_MAX if unknown */ + int arfcn; /* 16-bit GSM Absolute RF channel number; this value must be reported */ + uint8_t bsic; /* 6-bit Base Station Identity Code; 0xFF if unknown */ +} RIL_CellIdentityGsm_v12; + +typedef struct { + int mcc; /* 3-digit Mobile Country Code, 0..999, INT_MAX if unknown */ + int mnc; /* 2 or 3-digit Mobile Network Code, 0..999; + the most significant nibble encodes the number of digits - {2, 3, 0 (unset)}; + INT_MAX if unknown */ + int lac; /* 16-bit Location Area Code, 0..65535, INT_MAX if unknown */ + int cid; /* 28-bit UMTS Cell Identity described in TS 25.331, 0..268435455, INT_MAX if unknown */ + int psc; /* 9-bit UMTS Primary Scrambling Code described in TS 25.331, 0..511, INT_MAX if unknown */ +} RIL_CellIdentityWcdma; + +typedef struct { + int mcc; /* 3-digit Mobile Country Code, 0..999, INT_MAX if unknown */ + int mnc; /* 2 or 3-digit Mobile Network Code, 0..999; + the most significant nibble encodes the number of digits - {2, 3, 0 (unset)}; + INT_MAX if unknown */ + int lac; /* 16-bit Location Area Code, 0..65535, INT_MAX if unknown */ + int cid; /* 28-bit UMTS Cell Identity described in TS 25.331, 0..268435455, INT_MAX if unknown */ + int psc; /* 9-bit UMTS Primary Scrambling Code described in TS 25.331, 0..511; this value must be reported */ + int uarfcn; /* 16-bit UMTS Absolute RF Channel Number; this value must be reported */ +} RIL_CellIdentityWcdma_v12; + +typedef struct { + int networkId; /* Network Id 0..65535, INT_MAX if unknown */ + int systemId; /* CDMA System Id 0..32767, INT_MAX if unknown */ + int basestationId; /* Base Station Id 0..65535, INT_MAX if unknown */ + int longitude; /* Longitude is a decimal number as specified in 3GPP2 C.S0005-A v6.0. + * It is represented in units of 0.25 seconds and ranges from -2592000 + * to 2592000, both values inclusive (corresponding to a range of -180 + * to +180 degrees). INT_MAX if unknown */ + + int latitude; /* Latitude is a decimal number as specified in 3GPP2 C.S0005-A v6.0. + * It is represented in units of 0.25 seconds and ranges from -1296000 + * to 1296000, both values inclusive (corresponding to a range of -90 + * to +90 degrees). INT_MAX if unknown */ +} RIL_CellIdentityCdma; + +typedef struct { + int mcc; /* 3-digit Mobile Country Code, 0..999, INT_MAX if unknown */ + int mnc; /* 2 or 3-digit Mobile Network Code, 0..999; + the most significant nibble encodes the number of digits - {2, 3, 0 (unset)}; + INT_MAX if unknown */ + int ci; /* 28-bit Cell Identity described in TS ???, INT_MAX if unknown */ + int pci; /* physical cell id 0..503, INT_MAX if unknown */ + int tac; /* 16-bit tracking area code, INT_MAX if unknown */ +} RIL_CellIdentityLte; + +typedef struct { + int mcc; /* 3-digit Mobile Country Code, 0..999, INT_MAX if unknown */ + int mnc; /* 2 or 3-digit Mobile Network Code, 0..999; + the most significant nibble encodes the number of digits - {2, 3, 0 (unset)}; + INT_MAX if unknown */ + int ci; /* 28-bit Cell Identity described in TS ???, INT_MAX if unknown */ + int pci; /* physical cell id 0..503; this value must be reported */ + int tac; /* 16-bit tracking area code, INT_MAX if unknown */ + int earfcn; /* 18-bit LTE Absolute RF Channel Number; this value must be reported */ +} RIL_CellIdentityLte_v12; + +typedef struct { + int mcc; /* 3-digit Mobile Country Code, 0..999, INT_MAX if unknown */ + int mnc; /* 2 or 3-digit Mobile Network Code, 0..999; + the most significant nibble encodes the number of digits - {2, 3, 0 (unset)}; + INT_MAX if unknown */ + int lac; /* 16-bit Location Area Code, 0..65535, INT_MAX if unknown */ + int cid; /* 28-bit UMTS Cell Identity described in TS 25.331, 0..268435455, INT_MAX if unknown */ + int cpid; /* 8-bit Cell Parameters ID described in TS 25.331, 0..127, INT_MAX if unknown */ +} RIL_CellIdentityTdscdma; + +typedef struct { + RIL_CellIdentityGsm cellIdentityGsm; + RIL_GW_SignalStrength signalStrengthGsm; +} RIL_CellInfoGsm; + +typedef struct { + RIL_CellIdentityGsm_v12 cellIdentityGsm; + RIL_GSM_SignalStrength_v12 signalStrengthGsm; +} RIL_CellInfoGsm_v12; + +typedef struct { + RIL_CellIdentityWcdma cellIdentityWcdma; + RIL_SignalStrengthWcdma signalStrengthWcdma; +} RIL_CellInfoWcdma; + +typedef struct { + RIL_CellIdentityWcdma_v12 cellIdentityWcdma; + RIL_SignalStrengthWcdma signalStrengthWcdma; +} RIL_CellInfoWcdma_v12; + +typedef struct { + RIL_CellIdentityCdma cellIdentityCdma; + RIL_CDMA_SignalStrength signalStrengthCdma; + RIL_EVDO_SignalStrength signalStrengthEvdo; +} RIL_CellInfoCdma; + +typedef struct { + RIL_CellIdentityLte cellIdentityLte; + RIL_LTE_SignalStrength_v8 signalStrengthLte; +} RIL_CellInfoLte; + +typedef struct { + RIL_CellIdentityLte_v12 cellIdentityLte; + RIL_LTE_SignalStrength_v8 signalStrengthLte; +} RIL_CellInfoLte_v12; + +typedef struct { + RIL_CellIdentityTdscdma cellIdentityTdscdma; + RIL_TD_SCDMA_SignalStrength signalStrengthTdscdma; +} RIL_CellInfoTdscdma; + +// Must be the same as CellInfo.TYPE_XXX +typedef enum { + RIL_CELL_INFO_TYPE_NONE = 0, /* indicates no cell information */ + RIL_CELL_INFO_TYPE_GSM = 1, + RIL_CELL_INFO_TYPE_CDMA = 2, + RIL_CELL_INFO_TYPE_LTE = 3, + RIL_CELL_INFO_TYPE_WCDMA = 4, + RIL_CELL_INFO_TYPE_TD_SCDMA = 5 +} RIL_CellInfoType; + +// Must be the same as CellInfo.TIMESTAMP_TYPE_XXX +typedef enum { + RIL_TIMESTAMP_TYPE_UNKNOWN = 0, + RIL_TIMESTAMP_TYPE_ANTENNA = 1, + RIL_TIMESTAMP_TYPE_MODEM = 2, + RIL_TIMESTAMP_TYPE_OEM_RIL = 3, + RIL_TIMESTAMP_TYPE_JAVA_RIL = 4, +} RIL_TimeStampType; + +typedef struct { + RIL_CellInfoType cellInfoType; /* cell type for selecting from union CellInfo */ + int registered; /* !0 if this cell is registered 0 if not registered */ + RIL_TimeStampType timeStampType; /* type of time stamp represented by timeStamp */ + uint64_t timeStamp; /* Time in nanos as returned by ril_nano_time */ + union { + RIL_CellInfoGsm gsm; + RIL_CellInfoCdma cdma; + RIL_CellInfoLte lte; + RIL_CellInfoWcdma wcdma; + RIL_CellInfoTdscdma tdscdma; + } CellInfo; +} RIL_CellInfo; + +typedef struct { + RIL_CellInfoType cellInfoType; /* cell type for selecting from union CellInfo */ + int registered; /* !0 if this cell is registered 0 if not registered */ + RIL_TimeStampType timeStampType; /* type of time stamp represented by timeStamp */ + uint64_t timeStamp; /* Time in nanos as returned by ril_nano_time */ + union { + RIL_CellInfoGsm_v12 gsm; + RIL_CellInfoCdma cdma; + RIL_CellInfoLte_v12 lte; + RIL_CellInfoWcdma_v12 wcdma; + RIL_CellInfoTdscdma tdscdma; + } CellInfo; +} RIL_CellInfo_v12; + +typedef struct { + RIL_CellInfoType cellInfoType; /* cell type for selecting from union CellInfo */ + union { + RIL_CellIdentityGsm_v12 cellIdentityGsm; + RIL_CellIdentityWcdma_v12 cellIdentityWcdma; + RIL_CellIdentityLte_v12 cellIdentityLte; + RIL_CellIdentityTdscdma cellIdentityTdscdma; + RIL_CellIdentityCdma cellIdentityCdma; + }; +}RIL_CellIdentity_v16; + +typedef struct { + RIL_RegState regState; // Valid reg states are RIL_NOT_REG_AND_NOT_SEARCHING, + // REG_HOME, RIL_NOT_REG_AND_SEARCHING, REG_DENIED, + // UNKNOWN, REG_ROAMING defined in RegState + RIL_RadioTechnology rat; // indicates the available voice radio technology, + // valid values as defined by RadioTechnology. + int32_t cssSupported; // concurrent services support indicator. if + // registered on a CDMA system. + // 0 - Concurrent services not supported, + // 1 - Concurrent services supported + int32_t roamingIndicator; // TSB-58 Roaming Indicator if registered + // on a CDMA or EVDO system or -1 if not. + // Valid values are 0-255. + int32_t systemIsInPrl; // indicates whether the current system is in the + // PRL if registered on a CDMA or EVDO system or -1 if + // not. 0=not in the PRL, 1=in the PRL + int32_t defaultRoamingIndicator; // default Roaming Indicator from the PRL, + // if registered on a CDMA or EVDO system or -1 if not. + // Valid values are 0-255. + int32_t reasonForDenial; // reasonForDenial if registration state is 3 + // (Registration denied) this is an enumerated reason why + // registration was denied. See 3GPP TS 24.008, + // 10.5.3.6 and Annex G. + // 0 - General + // 1 - Authentication Failure + // 2 - IMSI unknown in HLR + // 3 - Illegal MS + // 4 - Illegal ME + // 5 - PLMN not allowed + // 6 - Location area not allowed + // 7 - Roaming not allowed + // 8 - No Suitable Cells in this Location Area + // 9 - Network failure + // 10 - Persistent location update reject + // 11 - PLMN not allowed + // 12 - Location area not allowed + // 13 - Roaming not allowed in this Location Area + // 15 - No Suitable Cells in this Location Area + // 17 - Network Failure + // 20 - MAC Failure + // 21 - Sync Failure + // 22 - Congestion + // 23 - GSM Authentication unacceptable + // 25 - Not Authorized for this CSG + // 32 - Service option not supported + // 33 - Requested service option not subscribed + // 34 - Service option temporarily out of order + // 38 - Call cannot be identified + // 48-63 - Retry upon entry into a new cell + // 95 - Semantically incorrect message + // 96 - Invalid mandatory information + // 97 - Message type non-existent or not implemented + // 98 - Message type not compatible with protocol state + // 99 - Information element non-existent or + // not implemented + // 100 - Conditional IE error + // 101 - Message not compatible with protocol state; + RIL_CellIdentity_v16 cellIdentity; // current cell information +}RIL_VoiceRegistrationStateResponse; + + +typedef struct { + RIL_RegState regState; // Valid reg states are RIL_NOT_REG_AND_NOT_SEARCHING, + // REG_HOME, RIL_NOT_REG_AND_SEARCHING, REG_DENIED, + // UNKNOWN, REG_ROAMING defined in RegState + RIL_RadioTechnology rat; // indicates the available data radio technology, + // valid values as defined by RadioTechnology. + int32_t reasonDataDenied; // if registration state is 3 (Registration + // denied) this is an enumerated reason why + // registration was denied. See 3GPP TS 24.008, + // Annex G.6 "Additional cause codes for GMM". + // 7 == GPRS services not allowed + // 8 == GPRS services and non-GPRS services not allowed + // 9 == MS identity cannot be derived by the network + // 10 == Implicitly detached + // 14 == GPRS services not allowed in this PLMN + // 16 == MSC temporarily not reachable + // 40 == No PDP context activated + int32_t maxDataCalls; // The maximum number of simultaneous Data Calls that + // must be established using setupDataCall(). + RIL_CellIdentity_v16 cellIdentity; // Current cell information +}RIL_DataRegistrationStateResponse; + +/* Names of the CDMA info records (C.S0005 section 3.7.5) */ +typedef enum { + RIL_CDMA_DISPLAY_INFO_REC, + RIL_CDMA_CALLED_PARTY_NUMBER_INFO_REC, + RIL_CDMA_CALLING_PARTY_NUMBER_INFO_REC, + RIL_CDMA_CONNECTED_NUMBER_INFO_REC, + RIL_CDMA_SIGNAL_INFO_REC, + RIL_CDMA_REDIRECTING_NUMBER_INFO_REC, + RIL_CDMA_LINE_CONTROL_INFO_REC, + RIL_CDMA_EXTENDED_DISPLAY_INFO_REC, + RIL_CDMA_T53_CLIR_INFO_REC, + RIL_CDMA_T53_RELEASE_INFO_REC, + RIL_CDMA_T53_AUDIO_CONTROL_INFO_REC +} RIL_CDMA_InfoRecName; + +/* Display Info Rec as defined in C.S0005 section 3.7.5.1 + Extended Display Info Rec as defined in C.S0005 section 3.7.5.16 + Note: the Extended Display info rec contains multiple records of the + form: display_tag, display_len, and display_len occurrences of the + chari field if the display_tag is not 10000000 or 10000001. + To save space, the records are stored consecutively in a byte buffer. + The display_tag, display_len and chari fields are all 1 byte. +*/ + +typedef struct { + char alpha_len; + char alpha_buf[CDMA_ALPHA_INFO_BUFFER_LENGTH]; +} RIL_CDMA_DisplayInfoRecord; + +/* Called Party Number Info Rec as defined in C.S0005 section 3.7.5.2 + Calling Party Number Info Rec as defined in C.S0005 section 3.7.5.3 + Connected Number Info Rec as defined in C.S0005 section 3.7.5.4 +*/ + +typedef struct { + char len; + char buf[CDMA_NUMBER_INFO_BUFFER_LENGTH]; + char number_type; + char number_plan; + char pi; + char si; +} RIL_CDMA_NumberInfoRecord; + +/* Redirecting Number Information Record as defined in C.S0005 section 3.7.5.11 */ +typedef enum { + RIL_REDIRECTING_REASON_UNKNOWN = 0, + RIL_REDIRECTING_REASON_CALL_FORWARDING_BUSY = 1, + RIL_REDIRECTING_REASON_CALL_FORWARDING_NO_REPLY = 2, + RIL_REDIRECTING_REASON_CALLED_DTE_OUT_OF_ORDER = 9, + RIL_REDIRECTING_REASON_CALL_FORWARDING_BY_THE_CALLED_DTE = 10, + RIL_REDIRECTING_REASON_CALL_FORWARDING_UNCONDITIONAL = 15, + RIL_REDIRECTING_REASON_RESERVED +} RIL_CDMA_RedirectingReason; + +typedef struct { + RIL_CDMA_NumberInfoRecord redirectingNumber; + /* redirectingReason is set to RIL_REDIRECTING_REASON_UNKNOWN if not included */ + RIL_CDMA_RedirectingReason redirectingReason; +} RIL_CDMA_RedirectingNumberInfoRecord; + +/* Line Control Information Record as defined in C.S0005 section 3.7.5.15 */ +typedef struct { + char lineCtrlPolarityIncluded; + char lineCtrlToggle; + char lineCtrlReverse; + char lineCtrlPowerDenial; +} RIL_CDMA_LineControlInfoRecord; + +/* T53 CLIR Information Record */ +typedef struct { + char cause; +} RIL_CDMA_T53_CLIRInfoRecord; + +/* T53 Audio Control Information Record */ +typedef struct { + char upLink; + char downLink; +} RIL_CDMA_T53_AudioControlInfoRecord; + +typedef struct { + + RIL_CDMA_InfoRecName name; + + union { + /* Display and Extended Display Info Rec */ + RIL_CDMA_DisplayInfoRecord display; + + /* Called Party Number, Calling Party Number, Connected Number Info Rec */ + RIL_CDMA_NumberInfoRecord number; + + /* Signal Info Rec */ + RIL_CDMA_SignalInfoRecord signal; + + /* Redirecting Number Info Rec */ + RIL_CDMA_RedirectingNumberInfoRecord redir; + + /* Line Control Info Rec */ + RIL_CDMA_LineControlInfoRecord lineCtrl; + + /* T53 CLIR Info Rec */ + RIL_CDMA_T53_CLIRInfoRecord clir; + + /* T53 Audio Control Info Rec */ + RIL_CDMA_T53_AudioControlInfoRecord audioCtrl; + } rec; +} RIL_CDMA_InformationRecord; + +#define RIL_CDMA_MAX_NUMBER_OF_INFO_RECS 10 + +typedef struct { + char numberOfInfoRecs; + RIL_CDMA_InformationRecord infoRec[RIL_CDMA_MAX_NUMBER_OF_INFO_RECS]; +} RIL_CDMA_InformationRecords; + +/* See RIL_REQUEST_NV_READ_ITEM */ +typedef struct { + RIL_NV_Item itemID; +} RIL_NV_ReadItem; + +/* See RIL_REQUEST_NV_WRITE_ITEM */ +typedef struct { + RIL_NV_Item itemID; + char * value; +} RIL_NV_WriteItem; + +typedef enum { + HANDOVER_STARTED = 0, + HANDOVER_COMPLETED = 1, + HANDOVER_FAILED = 2, + HANDOVER_CANCELED = 3 +} RIL_SrvccState; + +/* hardware configuration reported to RILJ. */ +typedef enum { + RIL_HARDWARE_CONFIG_MODEM = 0, + RIL_HARDWARE_CONFIG_SIM = 1, +} RIL_HardwareConfig_Type; + +typedef enum { + RIL_HARDWARE_CONFIG_STATE_ENABLED = 0, + RIL_HARDWARE_CONFIG_STATE_STANDBY = 1, + RIL_HARDWARE_CONFIG_STATE_DISABLED = 2, +} RIL_HardwareConfig_State; + +typedef struct { + int rilModel; + uint32_t rat; /* bitset - ref. RIL_RadioTechnology. */ + int maxVoice; + int maxData; + int maxStandby; +} RIL_HardwareConfig_Modem; + +typedef struct { + char modemUuid[MAX_UUID_LENGTH]; +} RIL_HardwareConfig_Sim; + +typedef struct { + RIL_HardwareConfig_Type type; + char uuid[MAX_UUID_LENGTH]; + RIL_HardwareConfig_State state; + union { + RIL_HardwareConfig_Modem modem; + RIL_HardwareConfig_Sim sim; + } cfg; +} RIL_HardwareConfig; + +typedef enum { + SS_CFU, + SS_CF_BUSY, + SS_CF_NO_REPLY, + SS_CF_NOT_REACHABLE, + SS_CF_ALL, + SS_CF_ALL_CONDITIONAL, + SS_CLIP, + SS_CLIR, + SS_COLP, + SS_COLR, + SS_WAIT, + SS_BAOC, + SS_BAOIC, + SS_BAOIC_EXC_HOME, + SS_BAIC, + SS_BAIC_ROAMING, + SS_ALL_BARRING, + SS_OUTGOING_BARRING, + SS_INCOMING_BARRING +} RIL_SsServiceType; + +typedef enum { + SS_ACTIVATION, + SS_DEACTIVATION, + SS_INTERROGATION, + SS_REGISTRATION, + SS_ERASURE +} RIL_SsRequestType; + +typedef enum { + SS_ALL_TELE_AND_BEARER_SERVICES, + SS_ALL_TELESEVICES, + SS_TELEPHONY, + SS_ALL_DATA_TELESERVICES, + SS_SMS_SERVICES, + SS_ALL_TELESERVICES_EXCEPT_SMS +} RIL_SsTeleserviceType; + +#define SS_INFO_MAX 4 +#define NUM_SERVICE_CLASSES 7 + +typedef struct { + int numValidIndexes; /* This gives the number of valid values in cfInfo. + For example if voice is forwarded to one number and data + is forwarded to a different one then numValidIndexes will be + 2 indicating total number of valid values in cfInfo. + Similarly if all the services are forwarded to the same + number then the value of numValidIndexes will be 1. */ + + RIL_CallForwardInfo cfInfo[NUM_SERVICE_CLASSES]; /* This is the response data + for SS request to query call + forward status. see + RIL_REQUEST_QUERY_CALL_FORWARD_STATUS */ +} RIL_CfData; + +typedef struct { + RIL_SsServiceType serviceType; + RIL_SsRequestType requestType; + RIL_SsTeleserviceType teleserviceType; + int serviceClass; + RIL_Errno result; + + union { + int ssInfo[SS_INFO_MAX]; /* This is the response data for most of the SS GET/SET + RIL requests. E.g. RIL_REQUSET_GET_CLIR returns + two ints, so first two values of ssInfo[] will be + used for response if serviceType is SS_CLIR and + requestType is SS_INTERROGATION */ + + RIL_CfData cfData; + }; +} RIL_StkCcUnsolSsResponse; + +/** + * Data connection power state + */ +typedef enum { + RIL_DC_POWER_STATE_LOW = 1, // Low power state + RIL_DC_POWER_STATE_MEDIUM = 2, // Medium power state + RIL_DC_POWER_STATE_HIGH = 3, // High power state + RIL_DC_POWER_STATE_UNKNOWN = INT32_MAX // Unknown state +} RIL_DcPowerStates; + +/** + * Data connection real time info + */ +typedef struct { + uint64_t time; // Time in nanos as returned by ril_nano_time + RIL_DcPowerStates powerState; // Current power state +} RIL_DcRtInfo; + +/** + * Data profile to modem + */ +typedef struct { + /* id of the data profile */ + int profileId; + /* the APN to connect to */ + char* apn; + /** one of the PDP_type values in TS 27.007 section 10.1.1. + * For example, "IP", "IPV6", "IPV4V6", or "PPP". + */ + char* protocol; + /** authentication protocol used for this PDP context + * (None: 0, PAP: 1, CHAP: 2, PAP&CHAP: 3) + */ + int authType; + /* the username for APN, or NULL */ + char* user; + /* the password for APN, or NULL */ + char* password; + /* the profile type, TYPE_COMMON-0, TYPE_3GPP-1, TYPE_3GPP2-2 */ + int type; + /* the period in seconds to limit the maximum connections */ + int maxConnsTime; + /* the maximum connections during maxConnsTime */ + int maxConns; + /** the required wait time in seconds after a successful UE initiated + * disconnect of a given PDN connection before the device can send + * a new PDN connection request for that given PDN + */ + int waitTime; + /* true to enable the profile, 0 to disable, 1 to enable */ + int enabled; +} RIL_DataProfileInfo; + +typedef struct { + /* id of the data profile */ + int profileId; + /* the APN to connect to */ + char* apn; + /** one of the PDP_type values in TS 27.007 section 10.1.1. + * For example, "IP", "IPV6", "IPV4V6", or "PPP". + */ + char* protocol; + /** one of the PDP_type values in TS 27.007 section 10.1.1 used on roaming network. + * For example, "IP", "IPV6", "IPV4V6", or "PPP". + */ + char *roamingProtocol; + /** authentication protocol used for this PDP context + * (None: 0, PAP: 1, CHAP: 2, PAP&CHAP: 3) + */ + int authType; + /* the username for APN, or NULL */ + char* user; + /* the password for APN, or NULL */ + char* password; + /* the profile type, TYPE_COMMON-0, TYPE_3GPP-1, TYPE_3GPP2-2 */ + int type; + /* the period in seconds to limit the maximum connections */ + int maxConnsTime; + /* the maximum connections during maxConnsTime */ + int maxConns; + /** the required wait time in seconds after a successful UE initiated + * disconnect of a given PDN connection before the device can send + * a new PDN connection request for that given PDN + */ + int waitTime; + /* true to enable the profile, 0 to disable, 1 to enable */ + int enabled; + /* supported APN types bitmask. See RIL_ApnTypes for the value of each bit. */ + int supportedTypesBitmask; + /** the bearer bitmask. See RIL_RadioAccessFamily for the value of each bit. */ + int bearerBitmask; + /** maximum transmission unit (MTU) size in bytes */ + int mtu; + /** the MVNO type: possible values are "imsi", "gid", "spn" */ + char *mvnoType; + /** MVNO match data. Can be anything defined by the carrier. For example, + * SPN like: "A MOBILE", "BEN NL", etc... + * IMSI like: "302720x94", "2060188", etc... + * GID like: "4E", "33", etc... + */ + char *mvnoMatchData; +} RIL_DataProfileInfo_v15; + +/* Tx Power Levels */ +#define RIL_NUM_TX_POWER_LEVELS 5 + +/** + * Aggregate modem activity information + */ +typedef struct { + + /* total time (in ms) when modem is in a low power or + * sleep state + */ + uint32_t sleep_mode_time_ms; + + /* total time (in ms) when modem is awake but neither + * the transmitter nor receiver are active/awake */ + uint32_t idle_mode_time_ms; + + /* total time (in ms) during which the transmitter is active/awake, + * subdivided by manufacturer-defined device-specific + * contiguous increasing ranges of transmit power between + * 0 and the transmitter's maximum transmit power. + */ + uint32_t tx_mode_time_ms[RIL_NUM_TX_POWER_LEVELS]; + + /* total time (in ms) for which receiver is active/awake and + * the transmitter is inactive */ + uint32_t rx_mode_time_ms; +} RIL_ActivityStatsInfo; + +typedef enum { + RIL_APN_TYPE_UNKNOWN = 0x0, // Unknown + RIL_APN_TYPE_DEFAULT = 0x1, // APN type for default data traffic + RIL_APN_TYPE_MMS = 0x2, // APN type for MMS traffic + RIL_APN_TYPE_SUPL = 0x4, // APN type for SUPL assisted GPS + RIL_APN_TYPE_DUN = 0x8, // APN type for DUN traffic + RIL_APN_TYPE_HIPRI = 0x10, // APN type for HiPri traffic + RIL_APN_TYPE_FOTA = 0x20, // APN type for FOTA + RIL_APN_TYPE_IMS = 0x40, // APN type for IMS + RIL_APN_TYPE_CBS = 0x80, // APN type for CBS + RIL_APN_TYPE_IA = 0x100, // APN type for IA Initial Attach APN + RIL_APN_TYPE_EMERGENCY = 0x200, // APN type for Emergency PDN. This is not an IA apn, + // but is used for access to carrier services in an + // emergency call situation. + RIL_APN_TYPE_ALL = 0xFFFFFFFF // All APN types +} RIL_ApnTypes; + +typedef enum { + RIL_DST_POWER_SAVE_MODE, // Device power save mode (provided by PowerManager) + // True indicates the device is in power save mode. + RIL_DST_CHARGING_STATE, // Device charging state (provided by BatteryManager) + // True indicates the device is charging. + RIL_DST_LOW_DATA_EXPECTED // Low data expected mode. True indicates low data traffic + // is expected, for example, when the device is idle + // (e.g. not doing tethering in the background). Note + // this doesn't mean no data is expected. +} RIL_DeviceStateType; + +typedef enum { + RIL_UR_SIGNAL_STRENGTH = 0x01, // When this bit is set, modem should always send the + // signal strength update through + // RIL_UNSOL_SIGNAL_STRENGTH, otherwise suppress it. + RIL_UR_FULL_NETWORK_STATE = 0x02, // When this bit is set, modem should always send + // RIL_UNSOL_RESPONSE_VOICE_NETWORK_STATE_CHANGED + // when any field in + // RIL_REQUEST_VOICE_REGISTRATION_STATE or + // RIL_REQUEST_DATA_REGISTRATION_STATE changes. When + // this bit is not set, modem should suppress + // RIL_UNSOL_RESPONSE_VOICE_NETWORK_STATE_CHANGED + // only when insignificant fields change + // (e.g. cell info). + // Modem should continue sending + // RIL_UNSOL_RESPONSE_VOICE_NETWORK_STATE_CHANGED + // when significant fields are updated even when this + // bit is not set. The following fields are + // considered significant, registration state and + // radio technology. + RIL_UR_DATA_CALL_DORMANCY_CHANGED = 0x04 // When this bit is set, modem should send the data + // call list changed unsolicited response + // RIL_UNSOL_DATA_CALL_LIST_CHANGED whenever any + // field in RIL_Data_Call_Response changes. + // Otherwise modem should suppress the unsolicited + // response when the only changed field is 'active' + // (for data dormancy). For all other fields change, + // modem should continue sending + // RIL_UNSOL_DATA_CALL_LIST_CHANGED regardless this + // bit is set or not. +} RIL_UnsolicitedResponseFilter; + +typedef struct { + char * aidPtr; /* AID value, See ETSI 102.221 and 101.220*/ + int p2; /* P2 parameter (described in ISO 7816-4) + P2Constants:NO_P2 if to be ignored */ +} RIL_OpenChannelParams; + +typedef enum { + RIL_ONE_SHOT = 0x01, // Performs the scan only once + RIL_PERIODIC = 0x02 // Performs the scan periodically until cancelled +} RIL_ScanType; + +typedef enum { + GERAN = 0x01, // GSM EDGE Radio Access Network + UTRAN = 0x02, // Universal Terrestrial Radio Access Network + EUTRAN = 0x03, // Evolved Universal Terrestrial Radio Access Network +} RIL_RadioAccessNetworks; + +typedef enum { + GERAN_BAND_T380 = 1, + GERAN_BAND_T410 = 2, + GERAN_BAND_450 = 3, + GERAN_BAND_480 = 4, + GERAN_BAND_710 = 5, + GERAN_BAND_750 = 6, + GERAN_BAND_T810 = 7, + GERAN_BAND_850 = 8, + GERAN_BAND_P900 = 9, + GERAN_BAND_E900 = 10, + GERAN_BAND_R900 = 11, + GERAN_BAND_DCS1800 = 12, + GERAN_BAND_PCS1900 = 13, + GERAN_BAND_ER900 = 14, +} RIL_GeranBands; + +typedef enum { + UTRAN_BAND_1 = 1, + UTRAN_BAND_2 = 2, + UTRAN_BAND_3 = 3, + UTRAN_BAND_4 = 4, + UTRAN_BAND_5 = 5, + UTRAN_BAND_6 = 6, + UTRAN_BAND_7 = 7, + UTRAN_BAND_8 = 8, + UTRAN_BAND_9 = 9, + UTRAN_BAND_10 = 10, + UTRAN_BAND_11 = 11, + UTRAN_BAND_12 = 12, + UTRAN_BAND_13 = 13, + UTRAN_BAND_14 = 14, + UTRAN_BAND_19 = 19, + UTRAN_BAND_20 = 20, + UTRAN_BAND_21 = 21, + UTRAN_BAND_22 = 22, + UTRAN_BAND_25 = 25, + UTRAN_BAND_26 = 26, +} RIL_UtranBands; + +typedef enum { + EUTRAN_BAND_1 = 1, + EUTRAN_BAND_2 = 2, + EUTRAN_BAND_3 = 3, + EUTRAN_BAND_4 = 4, + EUTRAN_BAND_5 = 5, + EUTRAN_BAND_6 = 6, + EUTRAN_BAND_7 = 7, + EUTRAN_BAND_8 = 8, + EUTRAN_BAND_9 = 9, + EUTRAN_BAND_10 = 10, + EUTRAN_BAND_11 = 11, + EUTRAN_BAND_12 = 12, + EUTRAN_BAND_13 = 13, + EUTRAN_BAND_14 = 14, + EUTRAN_BAND_17 = 17, + EUTRAN_BAND_18 = 18, + EUTRAN_BAND_19 = 19, + EUTRAN_BAND_20 = 20, + EUTRAN_BAND_21 = 21, + EUTRAN_BAND_22 = 22, + EUTRAN_BAND_23 = 23, + EUTRAN_BAND_24 = 24, + EUTRAN_BAND_25 = 25, + EUTRAN_BAND_26 = 26, + EUTRAN_BAND_27 = 27, + EUTRAN_BAND_28 = 28, + EUTRAN_BAND_30 = 30, + EUTRAN_BAND_31 = 31, + EUTRAN_BAND_33 = 33, + EUTRAN_BAND_34 = 34, + EUTRAN_BAND_35 = 35, + EUTRAN_BAND_36 = 36, + EUTRAN_BAND_37 = 37, + EUTRAN_BAND_38 = 38, + EUTRAN_BAND_39 = 39, + EUTRAN_BAND_40 = 40, + EUTRAN_BAND_41 = 41, + EUTRAN_BAND_42 = 42, + EUTRAN_BAND_43 = 43, + EUTRAN_BAND_44 = 44, + EUTRAN_BAND_45 = 45, + EUTRAN_BAND_46 = 46, + EUTRAN_BAND_47 = 47, + EUTRAN_BAND_48 = 48, + EUTRAN_BAND_65 = 65, + EUTRAN_BAND_66 = 66, + EUTRAN_BAND_68 = 68, + EUTRAN_BAND_70 = 70, +} RIL_EutranBands; + +typedef struct { + RIL_RadioAccessNetworks radio_access_network; // The type of network to scan. + uint32_t bands_length; // Length of bands + union { + RIL_GeranBands geran_bands[MAX_BANDS]; + RIL_UtranBands utran_bands[MAX_BANDS]; + RIL_EutranBands eutran_bands[MAX_BANDS]; + } bands; + uint32_t channels_length; // Length of channels + uint32_t channels[MAX_CHANNELS]; // Frequency channels to scan +} RIL_RadioAccessSpecifier; + +typedef struct { + RIL_ScanType type; // Type of the scan + int32_t interval; // Time interval in seconds + // between periodic scans, only + // valid when type=RIL_PERIODIC + uint32_t specifiers_length; // Length of specifiers + RIL_RadioAccessSpecifier specifiers[MAX_RADIO_ACCESS_NETWORKS]; // Radio access networks + // with bands/channels. +} RIL_NetworkScanRequest; + +typedef enum { + PARTIAL = 0x01, // The result contains a part of the scan results + COMPLETE = 0x02, // The result contains the last part of the scan results +} RIL_ScanStatus; + +typedef struct { + RIL_ScanStatus status; // The status of the scan + uint32_t network_infos_length; // Total length of RIL_CellInfo + RIL_CellInfo_v12* network_infos; // List of network information + RIL_Errno error; +} RIL_NetworkScanResult; + +/** + * RIL_REQUEST_GET_SIM_STATUS + * + * Requests status of the SIM interface and the SIM card + * + * "data" is NULL + * + * "response" is const RIL_CardStatus_v6 * + * + * Valid errors: + * + * SUCCESS + * RADIO_NOT_AVAILABLE + * INTERNAL_ERR + * NO_MEMORY + * NO_RESOURCES + * CANCELLED + * REQUEST_NOT_SUPPORTED + */ +#define RIL_REQUEST_GET_SIM_STATUS 1 + +/** + * RIL_REQUEST_ENTER_SIM_PIN + * + * Supplies SIM PIN. Only called if RIL_CardStatus has RIL_APPSTATE_PIN state + * + * "data" is const char ** + * ((const char **)data)[0] is PIN value + * ((const char **)data)[1] is AID value, See ETSI 102.221 8.1 and 101.220 4, NULL if no value. + * + * "response" is int * + * ((int *)response)[0] is the number of retries remaining, or -1 if unknown + * + * Valid errors: + * + * SUCCESS + * RADIO_NOT_AVAILABLE (radio resetting) + * PASSWORD_INCORRECT + * INTERNAL_ERR + * NO_MEMORY + * NO_RESOURCES + * CANCELLED + * INVALID_ARGUMENTS + * INVALID_SIM_STATE + * REQUEST_NOT_SUPPORTED + */ + +#define RIL_REQUEST_ENTER_SIM_PIN 2 + +/** + * RIL_REQUEST_ENTER_SIM_PUK + * + * Supplies SIM PUK and new PIN. + * + * "data" is const char ** + * ((const char **)data)[0] is PUK value + * ((const char **)data)[1] is new PIN value + * ((const char **)data)[2] is AID value, See ETSI 102.221 8.1 and 101.220 4, NULL if no value. + * + * "response" is int * + * ((int *)response)[0] is the number of retries remaining, or -1 if unknown + * + * Valid errors: + * + * SUCCESS + * RADIO_NOT_AVAILABLE (radio resetting) + * PASSWORD_INCORRECT + * (PUK is invalid) + * INTERNAL_ERR + * NO_MEMORY + * NO_RESOURCES + * CANCELLED + * INVALID_ARGUMENTS + * INVALID_SIM_STATE + * REQUEST_NOT_SUPPORTED + */ + +#define RIL_REQUEST_ENTER_SIM_PUK 3 + +/** + * RIL_REQUEST_ENTER_SIM_PIN2 + * + * Supplies SIM PIN2. Only called following operation where SIM_PIN2 was + * returned as a a failure from a previous operation. + * + * "data" is const char ** + * ((const char **)data)[0] is PIN2 value + * ((const char **)data)[1] is AID value, See ETSI 102.221 8.1 and 101.220 4, NULL if no value. + * + * "response" is int * + * ((int *)response)[0] is the number of retries remaining, or -1 if unknown + * + * Valid errors: + * + * SUCCESS + * RADIO_NOT_AVAILABLE (radio resetting) + * PASSWORD_INCORRECT + * INTERNAL_ERR + * NO_MEMORY + * NO_RESOURCES + * CANCELLED + * INVALID_ARGUMENTS + * INVALID_SIM_STATE + * REQUEST_NOT_SUPPORTED + */ + +#define RIL_REQUEST_ENTER_SIM_PIN2 4 + +/** + * RIL_REQUEST_ENTER_SIM_PUK2 + * + * Supplies SIM PUK2 and new PIN2. + * + * "data" is const char ** + * ((const char **)data)[0] is PUK2 value + * ((const char **)data)[1] is new PIN2 value + * ((const char **)data)[2] is AID value, See ETSI 102.221 8.1 and 101.220 4, NULL if no value. + * + * "response" is int * + * ((int *)response)[0] is the number of retries remaining, or -1 if unknown + * + * Valid errors: + * + * SUCCESS + * RADIO_NOT_AVAILABLE (radio resetting) + * PASSWORD_INCORRECT + * (PUK2 is invalid) + * INTERNAL_ERR + * NO_MEMORY + * NO_RESOURCES + * CANCELLED + * INVALID_ARGUMENTS + * INVALID_SIM_STATE + * REQUEST_NOT_SUPPORTED + */ + +#define RIL_REQUEST_ENTER_SIM_PUK2 5 + +/** + * RIL_REQUEST_CHANGE_SIM_PIN + * + * Supplies old SIM PIN and new PIN. + * + * "data" is const char ** + * ((const char **)data)[0] is old PIN value + * ((const char **)data)[1] is new PIN value + * ((const char **)data)[2] is AID value, See ETSI 102.221 8.1 and 101.220 4, NULL if no value. + * + * "response" is int * + * ((int *)response)[0] is the number of retries remaining, or -1 if unknown + * + * Valid errors: + * + * SUCCESS + * RADIO_NOT_AVAILABLE (radio resetting) + * PASSWORD_INCORRECT + * (old PIN is invalid) + * INTERNAL_ERR + * NO_MEMORY + * NO_RESOURCES + * CANCELLED + * INVALID_ARGUMENTS + * INVALID_SIM_STATE + * REQUEST_NOT_SUPPORTED + */ + +#define RIL_REQUEST_CHANGE_SIM_PIN 6 + + +/** + * RIL_REQUEST_CHANGE_SIM_PIN2 + * + * Supplies old SIM PIN2 and new PIN2. + * + * "data" is const char ** + * ((const char **)data)[0] is old PIN2 value + * ((const char **)data)[1] is new PIN2 value + * ((const char **)data)[2] is AID value, See ETSI 102.221 8.1 and 101.220 4, NULL if no value. + * + * "response" is int * + * ((int *)response)[0] is the number of retries remaining, or -1 if unknown + * + * Valid errors: + * + * SUCCESS + * RADIO_NOT_AVAILABLE (radio resetting) + * PASSWORD_INCORRECT + * (old PIN2 is invalid) + * INTERNAL_ERR + * NO_MEMORY + * NO_RESOURCES + * CANCELLED + * INVALID_ARGUMENTS + * INVALID_SIM_STATE + * REQUEST_NOT_SUPPORTED + * + */ + +#define RIL_REQUEST_CHANGE_SIM_PIN2 7 + +/** + * RIL_REQUEST_ENTER_NETWORK_DEPERSONALIZATION + * + * Requests that network personlization be deactivated + * + * "data" is const char ** + * ((const char **)(data))[0]] is network depersonlization code + * + * "response" is int * + * ((int *)response)[0] is the number of retries remaining, or -1 if unknown + * + * Valid errors: + * + * SUCCESS + * RADIO_NOT_AVAILABLE (radio resetting) + * PASSWORD_INCORRECT + * SIM_ABSENT + * (code is invalid) + * INTERNAL_ERR + * NO_MEMORY + * NO_RESOURCES + * CANCELLED + * REQUEST_NOT_SUPPORTED + */ + +#define RIL_REQUEST_ENTER_NETWORK_DEPERSONALIZATION 8 + +/** + * RIL_REQUEST_GET_CURRENT_CALLS + * + * Requests current call list + * + * "data" is NULL + * + * "response" must be a "const RIL_Call **" + * + * Valid errors: + * + * SUCCESS + * RADIO_NOT_AVAILABLE (radio resetting) + * NO_MEMORY + * (request will be made again in a few hundred msec) + * INTERNAL_ERR + * NO_RESOURCES + * CANCELLED + * REQUEST_NOT_SUPPORTED + */ + +#define RIL_REQUEST_GET_CURRENT_CALLS 9 + + +/** + * RIL_REQUEST_DIAL + * + * Initiate voice call + * + * "data" is const RIL_Dial * + * "response" is NULL + * + * This method is never used for supplementary service codes + * + * Valid errors: + * SUCCESS + * RADIO_NOT_AVAILABLE (radio resetting) + * DIAL_MODIFIED_TO_USSD + * DIAL_MODIFIED_TO_SS + * DIAL_MODIFIED_TO_DIAL + * INVALID_ARGUMENTS + * NO_MEMORY + * INVALID_STATE + * NO_RESOURCES + * INTERNAL_ERR + * FDN_CHECK_FAILURE + * MODEM_ERR + * NO_SUBSCRIPTION + * NO_NETWORK_FOUND + * INVALID_CALL_ID + * DEVICE_IN_USE + * OPERATION_NOT_ALLOWED + * ABORTED + * CANCELLED + * REQUEST_NOT_SUPPORTED + */ +#define RIL_REQUEST_DIAL 10 + +/** + * RIL_REQUEST_GET_IMSI + * + * Get the SIM IMSI + * + * Only valid when radio state is "RADIO_STATE_ON" + * + * "data" is const char ** + * ((const char **)data)[0] is AID value, See ETSI 102.221 8.1 and 101.220 4, NULL if no value. + * "response" is a const char * containing the IMSI + * + * Valid errors: + * SUCCESS + * RADIO_NOT_AVAILABLE (radio resetting) + * INTERNAL_ERR + * NO_MEMORY + * NO_RESOURCES + * CANCELLED + * INVALID_SIM_STATE + * REQUEST_NOT_SUPPORTED + */ + +#define RIL_REQUEST_GET_IMSI 11 + +/** + * RIL_REQUEST_HANGUP + * + * Hang up a specific line (like AT+CHLD=1x) + * + * After this HANGUP request returns, RIL should show the connection is NOT + * active anymore in next RIL_REQUEST_GET_CURRENT_CALLS query. + * + * "data" is an int * + * (int *)data)[0] contains Connection index (value of 'x' in CHLD above) + * + * "response" is NULL + * + * Valid errors: + * SUCCESS + * RADIO_NOT_AVAILABLE (radio resetting) + * INVALID_ARGUMENTS + * NO_MEMORY + * INVALID_STATE + * MODEM_ERR + * INTERNAL_ERR + * NO_MEMORY + * INVALID_CALL_ID + * INVALID_ARGUMENTS + * NO_RESOURCES + * CANCELLED + * REQUEST_NOT_SUPPORTED + */ + +#define RIL_REQUEST_HANGUP 12 + +/** + * RIL_REQUEST_HANGUP_WAITING_OR_BACKGROUND + * + * Hang up waiting or held (like AT+CHLD=0) + * + * After this HANGUP request returns, RIL should show the connection is NOT + * active anymore in next RIL_REQUEST_GET_CURRENT_CALLS query. + * + * "data" is NULL + * "response" is NULL + * + * Valid errors: + * SUCCESS + * RADIO_NOT_AVAILABLE (radio resetting) + * INVALID_STATE + * NO_MEMORY + * MODEM_ERR + * INTERNAL_ERR + * NO_MEMORY + * INVALID_CALL_ID + * NO_RESOURCES + * OPERATION_NOT_ALLOWED + * INVALID_ARGUMENTS + * NO_RESOURCES + * CANCELLED + * REQUEST_NOT_SUPPORTED + */ + +#define RIL_REQUEST_HANGUP_WAITING_OR_BACKGROUND 13 + +/** + * RIL_REQUEST_HANGUP_FOREGROUND_RESUME_BACKGROUND + * + * Hang up waiting or held (like AT+CHLD=1) + * + * After this HANGUP request returns, RIL should show the connection is NOT + * active anymore in next RIL_REQUEST_GET_CURRENT_CALLS query. + * + * "data" is NULL + * "response" is NULL + * + * Valid errors: + * SUCCESS + * RADIO_NOT_AVAILABLE (radio resetting) + * INVALID_STATE + * NO_MEMORY + * MODEM_ERR + * INTERNAL_ERR + * INVALID_CALL_ID + * OPERATION_NOT_ALLOWED + * INVALID_ARGUMENTS + * NO_RESOURCES + * CANCELLED + * REQUEST_NOT_SUPPORTED + */ + +#define RIL_REQUEST_HANGUP_FOREGROUND_RESUME_BACKGROUND 14 + +/** + * RIL_REQUEST_SWITCH_WAITING_OR_HOLDING_AND_ACTIVE + * + * Switch waiting or holding call and active call (like AT+CHLD=2) + * + * State transitions should be is follows: + * + * If call 1 is waiting and call 2 is active, then if this re + * + * BEFORE AFTER + * Call 1 Call 2 Call 1 Call 2 + * ACTIVE HOLDING HOLDING ACTIVE + * ACTIVE WAITING HOLDING ACTIVE + * HOLDING WAITING HOLDING ACTIVE + * ACTIVE IDLE HOLDING IDLE + * IDLE IDLE IDLE IDLE + * + * "data" is NULL + * "response" is NULL + * + * Valid errors: + * SUCCESS + * RADIO_NOT_AVAILABLE (radio resetting) + * INVALID_STATE + * NO_MEMORY + * MODEM_ERR + * INTERNAL_ERR + * INVALID_STATE + * INVALID_ARGUMENTS + * INVALID_CALL_ID + * OPERATION_NOT_ALLOWED + * NO_RESOURCES + * CANCELLED + * REQUEST_NOT_SUPPORTED + */ + +#define RIL_REQUEST_SWITCH_WAITING_OR_HOLDING_AND_ACTIVE 15 +#define RIL_REQUEST_SWITCH_HOLDING_AND_ACTIVE 15 + +/** + * RIL_REQUEST_CONFERENCE + * + * Conference holding and active (like AT+CHLD=3) + + * "data" is NULL + * "response" is NULL + * + * Valid errors: + * SUCCESS + * RADIO_NOT_AVAILABLE (radio resetting) + * NO_MEMORY + * MODEM_ERR + * INTERNAL_ERR + * INVALID_STATE + * INVALID_CALL_ID + * INVALID_ARGUMENTS + * OPERATION_NOT_ALLOWED + * NO_RESOURCES + * CANCELLED + * REQUEST_NOT_SUPPORTED + */ +#define RIL_REQUEST_CONFERENCE 16 + +/** + * RIL_REQUEST_UDUB + * + * Send UDUB (user determined used busy) to ringing or + * waiting call answer)(RIL_BasicRequest r); + * + * "data" is NULL + * "response" is NULL + * + * Valid errors: + * SUCCESS + * RADIO_NOT_AVAILABLE (radio resetting) + * INVALID_STATE + * NO_RESOURCES + * NO_MEMORY + * MODEM_ERR + * INTERNAL_ERR + * INVALID_CALL_ID + * OPERATION_NOT_ALLOWED + * INVALID_ARGUMENTS + * CANCELLED + * REQUEST_NOT_SUPPORTED + */ +#define RIL_REQUEST_UDUB 17 + +/** + * RIL_REQUEST_LAST_CALL_FAIL_CAUSE + * + * Requests the failure cause code for the most recently terminated call + * + * "data" is NULL + * "response" is a const RIL_LastCallFailCauseInfo * + * RIL_LastCallFailCauseInfo contains LastCallFailCause and vendor cause. + * The vendor cause code must be used for debugging purpose only. + * The implementation must return one of the values of LastCallFailCause + * as mentioned below. + * + * GSM failure reasons codes for the cause codes defined in TS 24.008 Annex H + * where possible. + * CDMA failure reasons codes for the possible call failure scenarios + * described in the "CDMA IS-2000 Release A (C.S0005-A v6.0)" standard. + * Any of the following reason codes if the call is failed or dropped due to reason + * mentioned with in the braces. + * + * CALL_FAIL_RADIO_OFF (Radio is OFF) + * CALL_FAIL_OUT_OF_SERVICE (No cell coverage) + * CALL_FAIL_NO_VALID_SIM (No valid SIM) + * CALL_FAIL_RADIO_INTERNAL_ERROR (Modem hit unexpected error scenario) + * CALL_FAIL_NETWORK_RESP_TIMEOUT (No response from network) + * CALL_FAIL_NETWORK_REJECT (Explicit network reject) + * CALL_FAIL_RADIO_ACCESS_FAILURE (RRC connection failure. Eg.RACH) + * CALL_FAIL_RADIO_LINK_FAILURE (Radio Link Failure) + * CALL_FAIL_RADIO_LINK_LOST (Radio link lost due to poor coverage) + * CALL_FAIL_RADIO_UPLINK_FAILURE (Radio uplink failure) + * CALL_FAIL_RADIO_SETUP_FAILURE (RRC connection setup failure) + * CALL_FAIL_RADIO_RELEASE_NORMAL (RRC connection release, normal) + * CALL_FAIL_RADIO_RELEASE_ABNORMAL (RRC connection release, abnormal) + * CALL_FAIL_ACCESS_CLASS_BLOCKED (Access class barring) + * CALL_FAIL_NETWORK_DETACH (Explicit network detach) + * + * OEM causes (CALL_FAIL_OEM_CAUSE_XX) must be used for debug purpose only + * + * If the implementation does not have access to the exact cause codes, + * then it should return one of the values listed in RIL_LastCallFailCause, + * as the UI layer needs to distinguish these cases for tone generation or + * error notification. + * + * Valid errors: + * SUCCESS + * RADIO_NOT_AVAILABLE + * NO_MEMORY + * INTERNAL_ERR + * NO_RESOURCES + * CANCELLED + * REQUEST_NOT_SUPPORTED + * + * See also: RIL_REQUEST_LAST_DATA_CALL_FAIL_CAUSE + */ +#define RIL_REQUEST_LAST_CALL_FAIL_CAUSE 18 + +/** + * RIL_REQUEST_SIGNAL_STRENGTH + * + * Requests current signal strength and associated information + * + * Must succeed if radio is on. + * + * "data" is NULL + * + * "response" is a const RIL_SignalStrength * + * + * Valid errors: + * SUCCESS + * RADIO_NOT_AVAILABLE + * NO_MEMORY + * INTERNAL_ERR + * SYSTEM_ERR + * MODEM_ERR + * NOT_PROVISIONED + * REQUEST_NOT_SUPPORTED + * NO_RESOURCES + * CANCELLED + */ +#define RIL_REQUEST_SIGNAL_STRENGTH 19 + +/** + * RIL_REQUEST_VOICE_REGISTRATION_STATE + * + * Request current registration state + * + * "data" is NULL + * "response" is a const RIL_VoiceRegistrationStateResponse * + * + * Valid errors: + * SUCCESS + * RADIO_NOT_AVAILABLE + * INTERNAL_ERR + * NO_MEMORY + * NO_RESOURCES + * CANCELLED + * REQUEST_NOT_SUPPORTED + */ +#define RIL_REQUEST_VOICE_REGISTRATION_STATE 20 + +/** + * RIL_REQUEST_DATA_REGISTRATION_STATE + * + * Request current DATA registration state + * + * "data" is NULL + * "response" is a const RIL_DataRegistrationStateResponse * + * + * Valid errors: + * SUCCESS + * RADIO_NOT_AVAILABLE + * NO_MEMORY + * INTERNAL_ERR + * SYSTEM_ERR + * MODEM_ERR + * NOT_PROVISIONED + * REQUEST_NOT_SUPPORTED + * NO_RESOURCES + * CANCELLED + */ +#define RIL_REQUEST_DATA_REGISTRATION_STATE 21 + +/** + * RIL_REQUEST_OPERATOR + * + * Request current operator ONS or EONS + * + * "data" is NULL + * "response" is a "const char **" + * ((const char **)response)[0] is long alpha ONS or EONS + * or NULL if unregistered + * + * ((const char **)response)[1] is short alpha ONS or EONS + * or NULL if unregistered + * ((const char **)response)[2] is 5 or 6 digit numeric code (MCC + MNC) + * or NULL if unregistered + * + * Valid errors: + * SUCCESS + * RADIO_NOT_AVAILABLE + * NO_MEMORY + * INTERNAL_ERR + * SYSTEM_ERR + * REQUEST_NOT_SUPPORTED + * NO_RESOURCES + * CANCELLED + */ +#define RIL_REQUEST_OPERATOR 22 + +/** + * RIL_REQUEST_RADIO_POWER + * + * Toggle radio on and off (for "airplane" mode) + * If the radio is is turned off/on the radio modem subsystem + * is expected return to an initialized state. For instance, + * any voice and data calls will be terminated and all associated + * lists emptied. + * + * "data" is int * + * ((int *)data)[0] is > 0 for "Radio On" + * ((int *)data)[0] is == 0 for "Radio Off" + * + * "response" is NULL + * + * Turn radio on if "on" > 0 + * Turn radio off if "on" == 0 + * + * Valid errors: + * SUCCESS + * RADIO_NOT_AVAILABLE + * OPERATION_NOT_ALLOWED + * INVALID_STATE + * NO_MEMORY + * INTERNAL_ERR + * SYSTEM_ERR + * INVALID_ARGUMENTS + * MODEM_ERR + * DEVICE_IN_USE + * OPERATION_NOT_ALLOWED + * INVALID_MODEM_STATE + * REQUEST_NOT_SUPPORTED + * NO_RESOURCES + * CANCELLED + */ +#define RIL_REQUEST_RADIO_POWER 23 + +/** + * RIL_REQUEST_DTMF + * + * Send a DTMF tone + * + * If the implementation is currently playing a tone requested via + * RIL_REQUEST_DTMF_START, that tone should be cancelled and the new tone + * should be played instead + * + * "data" is a char * containing a single character with one of 12 values: 0-9,*,# + * "response" is NULL + * + * FIXME should this block/mute microphone? + * How does this interact with local DTMF feedback? + * + * Valid errors: + * SUCCESS + * RADIO_NOT_AVAILABLE + * INVALID_ARGUMENTS + * NO_RESOURCES + * NO_MEMORY + * MODEM_ERR + * INTERNAL_ERR + * INVALID_CALL_ID + * NO_RESOURCES + * CANCELLED + * INVALID_MODEM_STATE + * REQUEST_NOT_SUPPORTED + * + * See also: RIL_REQUEST_DTMF_STOP, RIL_REQUEST_DTMF_START + * + */ +#define RIL_REQUEST_DTMF 24 + +/** + * RIL_REQUEST_SEND_SMS + * + * Send an SMS message + * + * "data" is const char ** + * ((const char **)data)[0] is SMSC address in GSM BCD format prefixed + * by a length byte (as expected by TS 27.005) or NULL for default SMSC + * ((const char **)data)[1] is SMS in PDU format as an ASCII hex string + * less the SMSC address + * TP-Layer-Length is be "strlen(((const char **)data)[1])/2" + * + * "response" is a const RIL_SMS_Response * + * + * Based on the return error, caller decides to resend if sending sms + * fails. SMS_SEND_FAIL_RETRY means retry (i.e. error cause is 332) + * + * Valid errors: + * SUCCESS + * RADIO_NOT_AVAILABLE + * SMS_SEND_FAIL_RETRY + * FDN_CHECK_FAILURE + * NETWORK_REJECT + * INVALID_STATE + * INVALID_ARGUMENTS + * NO_MEMORY + * REQUEST_RATE_LIMITED + * INVALID_SMS_FORMAT + * SYSTEM_ERR + * ENCODING_ERR + * INVALID_SMSC_ADDRESS + * MODEM_ERR + * NETWORK_ERR + * OPERATION_NOT_ALLOWED + * NO_MEMORY + * NO_RESOURCES + * CANCELLED + * REQUEST_NOT_SUPPORTED + * MODE_NOT_SUPPORTED + * SIM_ABSENT + * + * FIXME how do we specify TP-Message-Reference if we need to resend? + */ +#define RIL_REQUEST_SEND_SMS 25 + + +/** + * RIL_REQUEST_SEND_SMS_EXPECT_MORE + * + * Send an SMS message. Identical to RIL_REQUEST_SEND_SMS, + * except that more messages are expected to be sent soon. If possible, + * keep SMS relay protocol link open (eg TS 27.005 AT+CMMS command) + * + * "data" is const char ** + * ((const char **)data)[0] is SMSC address in GSM BCD format prefixed + * by a length byte (as expected by TS 27.005) or NULL for default SMSC + * ((const char **)data)[1] is SMS in PDU format as an ASCII hex string + * less the SMSC address + * TP-Layer-Length is be "strlen(((const char **)data)[1])/2" + * + * "response" is a const RIL_SMS_Response * + * + * Based on the return error, caller decides to resend if sending sms + * fails. SMS_SEND_FAIL_RETRY means retry (i.e. error cause is 332) + * + * Valid errors: + * SUCCESS + * RADIO_NOT_AVAILABLE + * SMS_SEND_FAIL_RETRY + * NETWORK_REJECT + * INVALID_STATE + * INVALID_ARGUMENTS + * NO_MEMORY + * INVALID_SMS_FORMAT + * SYSTEM_ERR + * REQUEST_RATE_LIMITED + * FDN_CHECK_FAILURE + * MODEM_ERR + * NETWORK_ERR + * ENCODING_ERR + * INVALID_SMSC_ADDRESS + * OPERATION_NOT_ALLOWED + * INTERNAL_ERR + * NO_RESOURCES + * CANCELLED + * REQUEST_NOT_SUPPORTED + * MODE_NOT_SUPPORTED + * SIM_ABSENT + * + */ +#define RIL_REQUEST_SEND_SMS_EXPECT_MORE 26 + + +/** + * RIL_REQUEST_SETUP_DATA_CALL + * + * Setup a packet data connection. If RIL_Data_Call_Response_v6.status + * return success it is added to the list of data calls and a + * RIL_UNSOL_DATA_CALL_LIST_CHANGED is sent. The call remains in the + * list until RIL_REQUEST_DEACTIVATE_DATA_CALL is issued or the + * radio is powered off/on. This list is returned by RIL_REQUEST_DATA_CALL_LIST + * and RIL_UNSOL_DATA_CALL_LIST_CHANGED. + * + * The RIL is expected to: + * - Create one data call context. + * - Create and configure a dedicated interface for the context + * - The interface must be point to point. + * - The interface is configured with one or more addresses and + * is capable of sending and receiving packets. The prefix length + * of the addresses must be /32 for IPv4 and /128 for IPv6. + * - Must NOT change the linux routing table. + * - Support up to RIL_REQUEST_DATA_REGISTRATION_STATE response[5] + * number of simultaneous data call contexts. + * + * "data" is a const char ** + * ((const char **)data)[0] Radio technology to use: 0-CDMA, 1-GSM/UMTS, 2... + * for values above 2 this is RIL_RadioTechnology + 2. + * ((const char **)data)[1] is a RIL_DataProfile (support is optional) + * ((const char **)data)[2] is the APN to connect to if radio technology is GSM/UMTS. This APN will + * override the one in the profile. NULL indicates no APN overrride. + * ((const char **)data)[3] is the username for APN, or NULL + * ((const char **)data)[4] is the password for APN, or NULL + * ((const char **)data)[5] is the PAP / CHAP auth type. Values: + * 0 => PAP and CHAP is never performed. + * 1 => PAP may be performed; CHAP is never performed. + * 2 => CHAP may be performed; PAP is never performed. + * 3 => PAP / CHAP may be performed - baseband dependent. + * ((const char **)data)[6] is the non-roaming/home connection type to request. Must be one of the + * PDP_type values in TS 27.007 section 10.1.1. + * For example, "IP", "IPV6", "IPV4V6", or "PPP". + * ((const char **)data)[7] is the roaming connection type to request. Must be one of the + * PDP_type values in TS 27.007 section 10.1.1. + * For example, "IP", "IPV6", "IPV4V6", or "PPP". + * ((const char **)data)[8] is the bitmask of APN type in decimal string format. The + * bitmask will encapsulate the following values: + * ia,mms,agps,supl,hipri,fota,dun,ims,default. + * ((const char **)data)[9] is the bearer bitmask in decimal string format. Each bit is a + * RIL_RadioAccessFamily. "0" or NULL indicates all RATs. + * ((const char **)data)[10] is the boolean in string format indicating the APN setting was + * sent to the modem through RIL_REQUEST_SET_DATA_PROFILE earlier. + * ((const char **)data)[11] is the mtu size in bytes of the mobile interface to which + * the apn is connected. + * ((const char **)data)[12] is the MVNO type: + * possible values are "imsi", "gid", "spn". + * ((const char **)data)[13] is MVNO match data in string. Can be anything defined by the carrier. + * For example, + * SPN like: "A MOBILE", "BEN NL", etc... + * IMSI like: "302720x94", "2060188", etc... + * GID like: "4E", "33", etc... + * ((const char **)data)[14] is the boolean string indicating data roaming is allowed or not. "1" + * indicates data roaming is enabled by the user, "0" indicates disabled. + * + * "response" is a RIL_Data_Call_Response_v11 + * + * FIXME may need way to configure QoS settings + * + * Valid errors: + * SUCCESS should be returned on both success and failure of setup with + * the RIL_Data_Call_Response_v6.status containing the actual status. + * For all other errors the RIL_Data_Call_Resonse_v6 is ignored. + * + * Other errors could include: + * RADIO_NOT_AVAILABLE, OP_NOT_ALLOWED_BEFORE_REG_TO_NW, + * OP_NOT_ALLOWED_DURING_VOICE_CALL, REQUEST_NOT_SUPPORTED, + * INVALID_ARGUMENTS, INTERNAL_ERR, NO_MEMORY, NO_RESOURCES, + * CANCELLED and SIM_ABSENT + * + * See also: RIL_REQUEST_DEACTIVATE_DATA_CALL + */ +#define RIL_REQUEST_SETUP_DATA_CALL 27 + + +/** + * RIL_REQUEST_SIM_IO + * + * Request SIM I/O operation. + * This is similar to the TS 27.007 "restricted SIM" operation + * where it assumes all of the EF selection will be done by the + * callee. + * + * "data" is a const RIL_SIM_IO_v6 * + * Please note that RIL_SIM_IO has a "PIN2" field which may be NULL, + * or may specify a PIN2 for operations that require a PIN2 (eg + * updating FDN records) + * + * "response" is a const RIL_SIM_IO_Response * + * + * Arguments and responses that are unused for certain + * values of "command" should be ignored or set to NULL + * + * Valid errors: + * SUCCESS + * RADIO_NOT_AVAILABLE + * SIM_PIN2 + * SIM_PUK2 + * INVALID_SIM_STATE + * SIM_ERR + * REQUEST_NOT_SUPPORTED + */ +#define RIL_REQUEST_SIM_IO 28 + +/** + * RIL_REQUEST_SEND_USSD + * + * Send a USSD message + * + * If a USSD session already exists, the message should be sent in the + * context of that session. Otherwise, a new session should be created. + * + * The network reply should be reported via RIL_UNSOL_ON_USSD + * + * Only one USSD session may exist at a time, and the session is assumed + * to exist until: + * a) The android system invokes RIL_REQUEST_CANCEL_USSD + * b) The implementation sends a RIL_UNSOL_ON_USSD with a type code + * of "0" (USSD-Notify/no further action) or "2" (session terminated) + * + * "data" is a const char * containing the USSD request in UTF-8 format + * "response" is NULL + * + * Valid errors: + * SUCCESS + * RADIO_NOT_AVAILABLE + * FDN_CHECK_FAILURE + * USSD_MODIFIED_TO_DIAL + * USSD_MODIFIED_TO_SS + * USSD_MODIFIED_TO_USSD + * SIM_BUSY + * OPERATION_NOT_ALLOWED + * INVALID_ARGUMENTS + * NO_MEMORY + * MODEM_ERR + * INTERNAL_ERR + * ABORTED + * SYSTEM_ERR + * INVALID_STATE + * NO_RESOURCES + * CANCELLED + * REQUEST_NOT_SUPPORTED + * + * See also: RIL_REQUEST_CANCEL_USSD, RIL_UNSOL_ON_USSD + */ + +#define RIL_REQUEST_SEND_USSD 29 + +/** + * RIL_REQUEST_CANCEL_USSD + * + * Cancel the current USSD session if one exists + * + * "data" is null + * "response" is NULL + * + * Valid errors: + * SUCCESS + * RADIO_NOT_AVAILABLE + * SIM_BUSY + * OPERATION_NOT_ALLOWED + * MODEM_ERR + * INTERNAL_ERR + * NO_MEMORY + * INVALID_STATE + * NO_RESOURCES + * CANCELLED + * REQUEST_NOT_SUPPORTED + */ + +#define RIL_REQUEST_CANCEL_USSD 30 + +/** + * RIL_REQUEST_GET_CLIR + * + * Gets current CLIR status + * "data" is NULL + * "response" is int * + * ((int *)data)[0] is "n" parameter from TS 27.007 7.7 + * ((int *)data)[1] is "m" parameter from TS 27.007 7.7 + * + * Valid errors: + * SUCCESS + * RADIO_NOT_AVAILABLE + * SS_MODIFIED_TO_DIAL + * SS_MODIFIED_TO_USSD + * SS_MODIFIED_TO_SS + * NO_MEMORY + * MODEM_ERR + * INTERNAL_ERR + * FDN_CHECK_FAILURE + * SYSTEM_ERR + * NO_RESOURCES + * CANCELLED + * REQUEST_NOT_SUPPORTED + */ +#define RIL_REQUEST_GET_CLIR 31 + +/** + * RIL_REQUEST_SET_CLIR + * + * "data" is int * + * ((int *)data)[0] is "n" parameter from TS 27.007 7.7 + * + * "response" is NULL + * + * Valid errors: + * SUCCESS + * RADIO_NOT_AVAILABLE + * SS_MODIFIED_TO_DIAL + * SS_MODIFIED_TO_USSD + * SS_MODIFIED_TO_SS + * INVALID_ARGUMENTS + * SYSTEM_ERR + * INTERNAL_ERR + * NO_MEMORY + * NO_RESOURCES + * CANCELLED + * REQUEST_NOT_SUPPORTED + */ +#define RIL_REQUEST_SET_CLIR 32 + +/** + * RIL_REQUEST_QUERY_CALL_FORWARD_STATUS + * + * "data" is const RIL_CallForwardInfo * + * + * "response" is const RIL_CallForwardInfo ** + * "response" points to an array of RIL_CallForwardInfo *'s, one for + * each distinct registered phone number. + * + * For example, if data is forwarded to +18005551212 and voice is forwarded + * to +18005559999, then two separate RIL_CallForwardInfo's should be returned + * + * If, however, both data and voice are forwarded to +18005551212, then + * a single RIL_CallForwardInfo can be returned with the service class + * set to "data + voice = 3") + * + * Valid errors: + * SUCCESS + * RADIO_NOT_AVAILABLE + * SS_MODIFIED_TO_DIAL + * SS_MODIFIED_TO_USSD + * SS_MODIFIED_TO_SS + * INVALID_ARGUMENTS + * NO_MEMORY + * SYSTEM_ERR + * MODEM_ERR + * INTERNAL_ERR + * NO_MEMORY + * FDN_CHECK_FAILURE + * NO_RESOURCES + * CANCELLED + * REQUEST_NOT_SUPPORTED + */ +#define RIL_REQUEST_QUERY_CALL_FORWARD_STATUS 33 + + +/** + * RIL_REQUEST_SET_CALL_FORWARD + * + * Configure call forward rule + * + * "data" is const RIL_CallForwardInfo * + * "response" is NULL + * + * Valid errors: + * SUCCESS + * RADIO_NOT_AVAILABLE + * SS_MODIFIED_TO_DIAL + * SS_MODIFIED_TO_USSD + * SS_MODIFIED_TO_SS + * INVALID_ARGUMENTS + * NO_MEMORY + * SYSTEM_ERR + * MODEM_ERR + * INTERNAL_ERR + * INVALID_STATE + * FDN_CHECK_FAILURE + * NO_RESOURCES + * CANCELLED + * REQUEST_NOT_SUPPORTED + */ +#define RIL_REQUEST_SET_CALL_FORWARD 34 + + +/** + * RIL_REQUEST_QUERY_CALL_WAITING + * + * Query current call waiting state + * + * "data" is const int * + * ((const int *)data)[0] is the TS 27.007 service class to query. + * "response" is a const int * + * ((const int *)response)[0] is 0 for "disabled" and 1 for "enabled" + * + * If ((const int *)response)[0] is = 1, then ((const int *)response)[1] + * must follow, with the TS 27.007 service class bit vector of services + * for which call waiting is enabled. + * + * For example, if ((const int *)response)[0] is 1 and + * ((const int *)response)[1] is 3, then call waiting is enabled for data + * and voice and disabled for everything else + * + * Valid errors: + * SUCCESS + * RADIO_NOT_AVAILABLE + * SS_MODIFIED_TO_DIAL + * SS_MODIFIED_TO_USSD + * SS_MODIFIED_TO_SS + * NO_MEMORY + * MODEM_ERR + * INTERNAL_ERR + * NO_MEMORY + * FDN_CHECK_FAILURE + * INVALID_ARGUMENTS + * NO_RESOURCES + * CANCELLED + * REQUEST_NOT_SUPPORTED + */ +#define RIL_REQUEST_QUERY_CALL_WAITING 35 + + +/** + * RIL_REQUEST_SET_CALL_WAITING + * + * Configure current call waiting state + * + * "data" is const int * + * ((const int *)data)[0] is 0 for "disabled" and 1 for "enabled" + * ((const int *)data)[1] is the TS 27.007 service class bit vector of + * services to modify + * "response" is NULL + * + * Valid errors: + * SUCCESS + * RADIO_NOT_AVAILABLE + * SS_MODIFIED_TO_DIAL + * SS_MODIFIED_TO_USSD + * SS_MODIFIED_TO_SS + * INVALID_ARGUMENTS + * NO_MEMORY + * MODEM_ERR + * INTERNAL_ERR + * INVALID_STATE + * FDN_CHECK_FAILURE + * NO_RESOURCES + * CANCELLED + * REQUEST_NOT_SUPPORTED + */ +#define RIL_REQUEST_SET_CALL_WAITING 36 + +/** + * RIL_REQUEST_SMS_ACKNOWLEDGE + * + * Acknowledge successful or failed receipt of SMS previously indicated + * via RIL_UNSOL_RESPONSE_NEW_SMS + * + * "data" is int * + * ((int *)data)[0] is 1 on successful receipt + * (basically, AT+CNMA=1 from TS 27.005 + * is 0 on failed receipt + * (basically, AT+CNMA=2 from TS 27.005) + * ((int *)data)[1] if data[0] is 0, this contains the failure cause as defined + * in TS 23.040, 9.2.3.22. Currently only 0xD3 (memory + * capacity exceeded) and 0xFF (unspecified error) are + * reported. + * + * "response" is NULL + * + * FIXME would like request that specified RP-ACK/RP-ERROR PDU + * + * Valid errors: + * SUCCESS + * RADIO_NOT_AVAILABLE + * INTERNAL_ERR + * NO_MEMORY + * NO_RESOURCES + * CANCELLED + * REQUEST_NOT_SUPPORTED + */ +#define RIL_REQUEST_SMS_ACKNOWLEDGE 37 + +/** + * RIL_REQUEST_GET_IMEI - DEPRECATED + * + * Get the device IMEI, including check digit + * + * The request is DEPRECATED, use RIL_REQUEST_DEVICE_IDENTITY + * Valid when RadioState is not RADIO_STATE_UNAVAILABLE + * + * "data" is NULL + * "response" is a const char * containing the IMEI + * + * Valid errors: + * SUCCESS + * RADIO_NOT_AVAILABLE (radio resetting) + * NO_MEMORY + * INTERNAL_ERR + * SYSTEM_ERR + * MODEM_ERR + * NOT_PROVISIONED + * REQUEST_NOT_SUPPORTED + * NO_RESOURCES + * CANCELLED + */ + +#define RIL_REQUEST_GET_IMEI 38 + +/** + * RIL_REQUEST_GET_IMEISV - DEPRECATED + * + * Get the device IMEISV, which should be two decimal digits + * + * The request is DEPRECATED, use RIL_REQUEST_DEVICE_IDENTITY + * Valid when RadioState is not RADIO_STATE_UNAVAILABLE + * + * "data" is NULL + * "response" is a const char * containing the IMEISV + * + * Valid errors: + * SUCCESS + * RADIO_NOT_AVAILABLE (radio resetting) + * NO_MEMORY + * INTERNAL_ERR + * SYSTEM_ERR + * MODEM_ERR + * NOT_PROVISIONED + * REQUEST_NOT_SUPPORTED + * NO_RESOURCES + * CANCELLED + */ + +#define RIL_REQUEST_GET_IMEISV 39 + + +/** + * RIL_REQUEST_ANSWER + * + * Answer incoming call + * + * Will not be called for WAITING calls. + * RIL_REQUEST_SWITCH_WAITING_OR_HOLDING_AND_ACTIVE will be used in this case + * instead + * + * "data" is NULL + * "response" is NULL + * + * Valid errors: + * SUCCESS + * RADIO_NOT_AVAILABLE (radio resetting) + * INVALID_STATE + * NO_MEMORY + * SYSTEM_ERR + * MODEM_ERR + * INTERNAL_ERR + * INVALID_CALL_ID + * NO_RESOURCES + * CANCELLED + * REQUEST_NOT_SUPPORTED + */ + +#define RIL_REQUEST_ANSWER 40 + +/** + * RIL_REQUEST_DEACTIVATE_DATA_CALL + * + * Deactivate packet data connection and remove from the + * data call list if SUCCESS is returned. Any other return + * values should also try to remove the call from the list, + * but that may not be possible. In any event a + * RIL_REQUEST_RADIO_POWER off/on must clear the list. An + * RIL_UNSOL_DATA_CALL_LIST_CHANGED is not expected to be + * issued because of an RIL_REQUEST_DEACTIVATE_DATA_CALL. + * + * "data" is const char ** + * ((char**)data)[0] indicating CID + * ((char**)data)[1] indicating Disconnect Reason + * 0 => No specific reason specified + * 1 => Radio shutdown requested + * + * "response" is NULL + * + * Valid errors: + * SUCCESS + * RADIO_NOT_AVAILABLE + * INVALID_CALL_ID + * INVALID_STATE + * INVALID_ARGUMENTS + * REQUEST_NOT_SUPPORTED + * INTERNAL_ERR + * NO_MEMORY + * NO_RESOURCES + * CANCELLED + * SIM_ABSENT + * + * See also: RIL_REQUEST_SETUP_DATA_CALL + */ +#define RIL_REQUEST_DEACTIVATE_DATA_CALL 41 + +/** + * RIL_REQUEST_QUERY_FACILITY_LOCK + * + * Query the status of a facility lock state + * + * "data" is const char ** + * ((const char **)data)[0] is the facility string code from TS 27.007 7.4 + * (eg "AO" for BAOC, "SC" for SIM lock) + * ((const char **)data)[1] is the password, or "" if not required + * ((const char **)data)[2] is the TS 27.007 service class bit vector of + * services to query + * ((const char **)data)[3] is AID value, See ETSI 102.221 8.1 and 101.220 4, NULL if no value. + * This is only applicable in the case of Fixed Dialing Numbers + * (FDN) requests. + * + * "response" is an int * + * ((const int *)response) 0 is the TS 27.007 service class bit vector of + * services for which the specified barring facility + * is active. "0" means "disabled for all" + * + * + * Valid errors: + * SUCCESS + * RADIO_NOT_AVAILABLE + * SS_MODIFIED_TO_DIAL + * SS_MODIFIED_TO_USSD + * SS_MODIFIED_TO_SS + * INVALID_ARGUMENTS + * NO_MEMORY + * INTERNAL_ERR + * SYSTEM_ERR + * MODEM_ERR + * FDN_CHECK_FAILURE + * NO_RESOURCES + * CANCELLED + * REQUEST_NOT_SUPPORTED + * + */ +#define RIL_REQUEST_QUERY_FACILITY_LOCK 42 + +/** + * RIL_REQUEST_SET_FACILITY_LOCK + * + * Enable/disable one facility lock + * + * "data" is const char ** + * + * ((const char **)data)[0] = facility string code from TS 27.007 7.4 + * (eg "AO" for BAOC) + * ((const char **)data)[1] = "0" for "unlock" and "1" for "lock" + * ((const char **)data)[2] = password + * ((const char **)data)[3] = string representation of decimal TS 27.007 + * service class bit vector. Eg, the string + * "1" means "set this facility for voice services" + * ((const char **)data)[4] = AID value, See ETSI 102.221 8.1 and 101.220 4, NULL if no value. + * This is only applicable in the case of Fixed Dialing Numbers + * (FDN) requests. + * + * "response" is int * + * ((int *)response)[0] is the number of retries remaining, or -1 if unknown + * + * Valid errors: + * SUCCESS + * RADIO_NOT_AVAILABLE + * SS_MODIFIED_TO_DIAL + * SS_MODIFIED_TO_USSD + * SS_MODIFIED_TO_SS + * INVALID_ARGUMENTS + * INTERNAL_ERR + * NO_MEMORY + * MODEM_ERR + * INVALID_STATE + * FDN_CHECK_FAILURE + * NO_RESOURCES + * CANCELLED + * REQUEST_NOT_SUPPORTED + * + */ +#define RIL_REQUEST_SET_FACILITY_LOCK 43 + +/** + * RIL_REQUEST_CHANGE_BARRING_PASSWORD + * + * Change call barring facility password + * + * "data" is const char ** + * + * ((const char **)data)[0] = facility string code from TS 27.007 7.4 + * (eg "AO" for BAOC) + * ((const char **)data)[1] = old password + * ((const char **)data)[2] = new password + * + * "response" is NULL + * + * Valid errors: + * SUCCESS + * RADIO_NOT_AVAILABLE + * SS_MODIFIED_TO_DIAL + * SS_MODIFIED_TO_USSD + * SS_MODIFIED_TO_SS + * INVALID_ARGUMENTS + * NO_MEMORY + * MODEM_ERR + * INTERNAL_ERR + * SYSTEM_ERR + * FDN_CHECK_FAILURE + * NO_RESOURCES + * CANCELLED + * REQUEST_NOT_SUPPORTED + * + */ +#define RIL_REQUEST_CHANGE_BARRING_PASSWORD 44 + +/** + * RIL_REQUEST_QUERY_NETWORK_SELECTION_MODE + * + * Query current network selectin mode + * + * "data" is NULL + * + * "response" is int * + * ((const int *)response)[0] is + * 0 for automatic selection + * 1 for manual selection + * + * Valid errors: + * SUCCESS + * RADIO_NOT_AVAILABLE + * NO_MEMORY + * INTERNAL_ERR + * SYSTEM_ERR + * INVALID_ARGUMENTS + * MODEM_ERR + * REQUEST_NOT_SUPPORTED + * NO_RESOURCES + * CANCELLED + * + */ +#define RIL_REQUEST_QUERY_NETWORK_SELECTION_MODE 45 + +/** + * RIL_REQUEST_SET_NETWORK_SELECTION_AUTOMATIC + * + * Specify that the network should be selected automatically + * + * "data" is NULL + * "response" is NULL + * + * This request must not respond until the new operator is selected + * and registered + * + * Valid errors: + * SUCCESS + * RADIO_NOT_AVAILABLE + * ILLEGAL_SIM_OR_ME + * OPERATION_NOT_ALLOWED + * NO_MEMORY + * INTERNAL_ERR + * SYSTEM_ERR + * INVALID_ARGUMENTS + * MODEM_ERR + * REQUEST_NOT_SUPPORTED + * NO_RESOURCES + * CANCELLED + * + * Note: Returns ILLEGAL_SIM_OR_ME when the failure is permanent and + * no retries needed, such as illegal SIM or ME. + * + */ +#define RIL_REQUEST_SET_NETWORK_SELECTION_AUTOMATIC 46 + +/** + * RIL_REQUEST_SET_NETWORK_SELECTION_MANUAL + * + * Manually select a specified network. + * + * "data" is const char * specifying MCCMNC of network to select (eg "310170") + * "response" is NULL + * + * This request must not respond until the new operator is selected + * and registered + * + * Valid errors: + * SUCCESS + * RADIO_NOT_AVAILABLE + * ILLEGAL_SIM_OR_ME + * OPERATION_NOT_ALLOWED + * INVALID_STATE + * NO_MEMORY + * INTERNAL_ERR + * SYSTEM_ERR + * INVALID_ARGUMENTS + * MODEM_ERR + * REQUEST_NOT_SUPPORTED + * NO_RESOURCES + * CANCELLED + * + * Note: Returns ILLEGAL_SIM_OR_ME when the failure is permanent and + * no retries needed, such as illegal SIM or ME. + * + */ +#define RIL_REQUEST_SET_NETWORK_SELECTION_MANUAL 47 + +/** + * RIL_REQUEST_QUERY_AVAILABLE_NETWORKS + * + * Scans for available networks + * + * "data" is NULL + * "response" is const char ** that should be an array of n*4 strings, where + * n is the number of available networks + * For each available network: + * + * ((const char **)response)[n+0] is long alpha ONS or EONS + * ((const char **)response)[n+1] is short alpha ONS or EONS + * ((const char **)response)[n+2] is 5 or 6 digit numeric code (MCC + MNC) + * ((const char **)response)[n+3] is a string value of the status: + * "unknown" + * "available" + * "current" + * "forbidden" + * + * Valid errors: + * SUCCESS + * RADIO_NOT_AVAILABLE + * OPERATION_NOT_ALLOWED + * ABORTED + * DEVICE_IN_USE + * INTERNAL_ERR + * NO_MEMORY + * MODEM_ERR + * REQUEST_NOT_SUPPORTED + * CANCELLED + * OPERATION_NOT_ALLOWED + * NO_RESOURCES + * CANCELLED + * + */ +#define RIL_REQUEST_QUERY_AVAILABLE_NETWORKS 48 + +/** + * RIL_REQUEST_DTMF_START + * + * Start playing a DTMF tone. Continue playing DTMF tone until + * RIL_REQUEST_DTMF_STOP is received + * + * If a RIL_REQUEST_DTMF_START is received while a tone is currently playing, + * it should cancel the previous tone and play the new one. + * + * "data" is a char * + * ((char *)data)[0] is a single character with one of 12 values: 0-9,*,# + * "response" is NULL + * + * Valid errors: + * SUCCESS + * RADIO_NOT_AVAILABLE + * INVALID_ARGUMENTS + * NO_RESOURCES + * NO_MEMORY + * SYSTEM_ERR + * MODEM_ERR + * INTERNAL_ERR + * INVALID_CALL_ID + * CANCELLED + * INVALID_MODEM_STATE + * REQUEST_NOT_SUPPORTED + * + * See also: RIL_REQUEST_DTMF, RIL_REQUEST_DTMF_STOP + */ +#define RIL_REQUEST_DTMF_START 49 + +/** + * RIL_REQUEST_DTMF_STOP + * + * Stop playing a currently playing DTMF tone. + * + * "data" is NULL + * "response" is NULL + * + * Valid errors: + * SUCCESS + * RADIO_NOT_AVAILABLE + * OPERATION_NOT_ALLOWED + * NO_RESOURCES + * NO_MEMORY + * INVALID_ARGUMENTS + * SYSTEM_ERR + * MODEM_ERR + * INTERNAL_ERR + * INVALID_CALL_ID + * CANCELLED + * INVALID_MODEM_STATE + * REQUEST_NOT_SUPPORTED + * + * See also: RIL_REQUEST_DTMF, RIL_REQUEST_DTMF_START + */ +#define RIL_REQUEST_DTMF_STOP 50 + +/** + * RIL_REQUEST_BASEBAND_VERSION + * + * Return string value indicating baseband version, eg + * response from AT+CGMR + * + * "data" is NULL + * "response" is const char * containing version string for log reporting + * + * Valid errors: + * SUCCESS + * RADIO_NOT_AVAILABLE + * EMPTY_RECORD + * NO_MEMORY + * INTERNAL_ERR + * SYSTEM_ERR + * MODEM_ERR + * NOT_PROVISIONED + * REQUEST_NOT_SUPPORTED + * NO_RESOURCES + * CANCELLED + * + */ +#define RIL_REQUEST_BASEBAND_VERSION 51 + +/** + * RIL_REQUEST_SEPARATE_CONNECTION + * + * Separate a party from a multiparty call placing the multiparty call + * (less the specified party) on hold and leaving the specified party + * as the only other member of the current (active) call + * + * Like AT+CHLD=2x + * + * See TS 22.084 1.3.8.2 (iii) + * TS 22.030 6.5.5 "Entering "2X followed by send" + * TS 27.007 "AT+CHLD=2x" + * + * "data" is an int * + * (int *)data)[0] contains Connection index (value of 'x' in CHLD above) "response" is NULL + * + * "response" is NULL + * + * Valid errors: + * SUCCESS + * RADIO_NOT_AVAILABLE (radio resetting) + * INVALID_ARGUMENTS + * INVALID_STATE + * NO_RESOURCES + * NO_MEMORY + * SYSTEM_ERR + * MODEM_ERR + * INTERNAL_ERR + * INVALID_CALL_ID + * INVALID_STATE + * OPERATION_NOT_ALLOWED + * CANCELLED + * REQUEST_NOT_SUPPORTED + */ +#define RIL_REQUEST_SEPARATE_CONNECTION 52 + + +/** + * RIL_REQUEST_SET_MUTE + * + * Turn on or off uplink (microphone) mute. + * + * Will only be sent while voice call is active. + * Will always be reset to "disable mute" when a new voice call is initiated + * + * "data" is an int * + * (int *)data)[0] is 1 for "enable mute" and 0 for "disable mute" + * + * "response" is NULL + * + * Valid errors: + * SUCCESS + * RADIO_NOT_AVAILABLE (radio resetting) + * INVALID_ARGUMENTS + * NO_MEMORY + * REQUEST_RATE_LIMITED + * INTERNAL_ERR + * NO_RESOURCES + * CANCELLED + * REQUEST_NOT_SUPPORTED + */ + +#define RIL_REQUEST_SET_MUTE 53 + +/** + * RIL_REQUEST_GET_MUTE + * + * Queries the current state of the uplink mute setting + * + * "data" is NULL + * "response" is an int * + * (int *)response)[0] is 1 for "mute enabled" and 0 for "mute disabled" + * + * Valid errors: + * SUCCESS + * RADIO_NOT_AVAILABLE (radio resetting) + * SS_MODIFIED_TO_DIAL + * SS_MODIFIED_TO_USSD + * SS_MODIFIED_TO_SS + * NO_MEMORY + * REQUEST_RATE_LIMITED + * INTERNAL_ERR + * NO_RESOURCES + * CANCELLED + * REQUEST_NOT_SUPPORTED + */ + +#define RIL_REQUEST_GET_MUTE 54 + +/** + * RIL_REQUEST_QUERY_CLIP + * + * Queries the status of the CLIP supplementary service + * + * (for MMI code "*#30#") + * + * "data" is NULL + * "response" is an int * + * (int *)response)[0] is 1 for "CLIP provisioned" + * and 0 for "CLIP not provisioned" + * and 2 for "unknown, e.g. no network etc" + * + * Valid errors: + * SUCCESS + * RADIO_NOT_AVAILABLE (radio resetting) + * NO_MEMORY + * SYSTEM_ERR + * MODEM_ERR + * INTERNAL_ERR + * FDN_CHECK_FAILURE + * NO_RESOURCES + * CANCELLED + * REQUEST_NOT_SUPPORTED + */ + +#define RIL_REQUEST_QUERY_CLIP 55 + +/** + * RIL_REQUEST_LAST_DATA_CALL_FAIL_CAUSE - Deprecated use the status + * field in RIL_Data_Call_Response_v6. + * + * Requests the failure cause code for the most recently failed PDP + * context or CDMA data connection active + * replaces RIL_REQUEST_LAST_PDP_FAIL_CAUSE + * + * "data" is NULL + * + * "response" is a "int *" + * ((int *)response)[0] is an integer cause code defined in TS 24.008 + * section 6.1.3.1.3 or close approximation + * + * If the implementation does not have access to the exact cause codes, + * then it should return one of the values listed in + * RIL_DataCallFailCause, as the UI layer needs to distinguish these + * cases for error notification + * and potential retries. + * + * Valid errors: + * SUCCESS + * RADIO_NOT_AVAILABLE + * INTERNAL_ERR + * NO_MEMORY + * NO_RESOURCES + * CANCELLED + * REQUEST_NOT_SUPPORTED + * + * See also: RIL_REQUEST_LAST_CALL_FAIL_CAUSE + * + * Deprecated use the status field in RIL_Data_Call_Response_v6. + */ + +#define RIL_REQUEST_LAST_DATA_CALL_FAIL_CAUSE 56 + +/** + * RIL_REQUEST_DATA_CALL_LIST + * + * Returns the data call list. An entry is added when a + * RIL_REQUEST_SETUP_DATA_CALL is issued and removed on a + * RIL_REQUEST_DEACTIVATE_DATA_CALL. The list is emptied + * when RIL_REQUEST_RADIO_POWER off/on is issued. + * + * "data" is NULL + * "response" is an array of RIL_Data_Call_Response_v6 + * + * Valid errors: + * SUCCESS + * RADIO_NOT_AVAILABLE (radio resetting) + * INTERNAL_ERR + * NO_MEMORY + * NO_RESOURCES + * CANCELLED + * REQUEST_NOT_SUPPORTED + * SIM_ABSENT + * + * See also: RIL_UNSOL_DATA_CALL_LIST_CHANGED + */ + +#define RIL_REQUEST_DATA_CALL_LIST 57 + +/** + * RIL_REQUEST_RESET_RADIO - DEPRECATED + * + * Request a radio reset. The RIL implementation may postpone + * the reset until after this request is responded to if the baseband + * is presently busy. + * + * The request is DEPRECATED, use RIL_REQUEST_RADIO_POWER + * + * "data" is NULL + * "response" is NULL + * + * Valid errors: + * SUCCESS + * RADIO_NOT_AVAILABLE (radio resetting) + * REQUEST_NOT_SUPPORTED + */ + +#define RIL_REQUEST_RESET_RADIO 58 + +/** + * RIL_REQUEST_OEM_HOOK_RAW + * + * This request reserved for OEM-specific uses. It passes raw byte arrays + * back and forth. + * + * It can be invoked on the Java side from + * com.android.internal.telephony.Phone.invokeOemRilRequestRaw() + * + * "data" is a char * of bytes copied from the byte[] data argument in java + * "response" is a char * of bytes that will returned via the + * caller's "response" Message here: + * (byte[])(((AsyncResult)response.obj).result) + * + * An error response here will result in + * (((AsyncResult)response.obj).result) == null and + * (((AsyncResult)response.obj).exception) being an instance of + * com.android.internal.telephony.gsm.CommandException + * + * Valid errors: + * All + */ + +#define RIL_REQUEST_OEM_HOOK_RAW 59 + +/** + * RIL_REQUEST_OEM_HOOK_STRINGS + * + * This request reserved for OEM-specific uses. It passes strings + * back and forth. + * + * It can be invoked on the Java side from + * com.android.internal.telephony.Phone.invokeOemRilRequestStrings() + * + * "data" is a const char **, representing an array of null-terminated UTF-8 + * strings copied from the "String[] strings" argument to + * invokeOemRilRequestStrings() + * + * "response" is a const char **, representing an array of null-terminated UTF-8 + * stings that will be returned via the caller's response message here: + * + * (String[])(((AsyncResult)response.obj).result) + * + * An error response here will result in + * (((AsyncResult)response.obj).result) == null and + * (((AsyncResult)response.obj).exception) being an instance of + * com.android.internal.telephony.gsm.CommandException + * + * Valid errors: + * All + */ + +#define RIL_REQUEST_OEM_HOOK_STRINGS 60 + +/** + * RIL_REQUEST_SCREEN_STATE - DEPRECATED + * + * Indicates the current state of the screen. When the screen is off, the + * RIL should notify the baseband to suppress certain notifications (eg, + * signal strength and changes in LAC/CID or BID/SID/NID/latitude/longitude) + * in an effort to conserve power. These notifications should resume when the + * screen is on. + * + * Note this request is deprecated. Use RIL_REQUEST_SEND_DEVICE_STATE to report the device state + * to the modem and use RIL_REQUEST_SET_UNSOLICITED_RESPONSE_FILTER to turn on/off unsolicited + * response from the modem in different scenarios. + * + * "data" is int * + * ((int *)data)[0] is == 1 for "Screen On" + * ((int *)data)[0] is == 0 for "Screen Off" + * + * "response" is NULL + * + * Valid errors: + * SUCCESS + * NO_MEMORY + * INTERNAL_ERR + * SYSTEM_ERR + * INVALID_ARGUMENTS + * NO_RESOURCES + * CANCELLED + * REQUEST_NOT_SUPPORTED + */ +#define RIL_REQUEST_SCREEN_STATE 61 + + +/** + * RIL_REQUEST_SET_SUPP_SVC_NOTIFICATION + * + * Enables/disables supplementary service related notifications + * from the network. + * + * Notifications are reported via RIL_UNSOL_SUPP_SVC_NOTIFICATION. + * + * "data" is int * + * ((int *)data)[0] is == 1 for notifications enabled + * ((int *)data)[0] is == 0 for notifications disabled + * + * "response" is NULL + * + * Valid errors: + * SUCCESS + * RADIO_NOT_AVAILABLE + * SIM_BUSY + * INVALID_ARGUMENTS + * NO_MEMORY + * SYSTEM_ERR + * MODEM_ERR + * INTERNAL_ERR + * NO_RESOURCES + * CANCELLED + * REQUEST_NOT_SUPPORTED + * + * See also: RIL_UNSOL_SUPP_SVC_NOTIFICATION. + */ +#define RIL_REQUEST_SET_SUPP_SVC_NOTIFICATION 62 + +/** + * RIL_REQUEST_WRITE_SMS_TO_SIM + * + * Stores a SMS message to SIM memory. + * + * "data" is RIL_SMS_WriteArgs * + * + * "response" is int * + * ((const int *)response)[0] is the record index where the message is stored. + * + * Valid errors: + * SUCCESS + * SIM_FULL + * INVALID_ARGUMENTS + * INVALID_SMS_FORMAT + * INTERNAL_ERR + * MODEM_ERR + * ENCODING_ERR + * NO_MEMORY + * NO_RESOURCES + * INVALID_MODEM_STATE + * OPERATION_NOT_ALLOWED + * INVALID_SMSC_ADDRESS + * CANCELLED + * INVALID_MODEM_STATE + * REQUEST_NOT_SUPPORTED + * SIM_ABSENT + * + */ +#define RIL_REQUEST_WRITE_SMS_TO_SIM 63 + +/** + * RIL_REQUEST_DELETE_SMS_ON_SIM + * + * Deletes a SMS message from SIM memory. + * + * "data" is int * + * ((int *)data)[0] is the record index of the message to delete. + * + * "response" is NULL + * + * Valid errors: + * SUCCESS + * SIM_FULL + * INVALID_ARGUMENTS + * NO_MEMORY + * REQUEST_RATE_LIMITED + * SYSTEM_ERR + * MODEM_ERR + * NO_SUCH_ENTRY + * INTERNAL_ERR + * NO_RESOURCES + * CANCELLED + * INVALID_MODEM_STATE + * REQUEST_NOT_SUPPORTED + * SIM_ABSENT + * + */ +#define RIL_REQUEST_DELETE_SMS_ON_SIM 64 + +/** + * RIL_REQUEST_SET_BAND_MODE + * + * Assign a specified band for RF configuration. + * + * "data" is int * + * ((int *)data)[0] is a RIL_RadioBandMode + * + * "response" is NULL + * + * Valid errors: + * SUCCESS + * RADIO_NOT_AVAILABLE + * OPERATION_NOT_ALLOWED + * NO_MEMORY + * INTERNAL_ERR + * SYSTEM_ERR + * INVALID_ARGUMENTS + * MODEM_ERR + * REQUEST_NOT_SUPPORTED + * NO_RESOURCES + * CANCELLED + * + * See also: RIL_REQUEST_QUERY_AVAILABLE_BAND_MODE + */ +#define RIL_REQUEST_SET_BAND_MODE 65 + +/** + * RIL_REQUEST_QUERY_AVAILABLE_BAND_MODE + * + * Query the list of band mode supported by RF. + * + * "data" is NULL + * + * "response" is int * + * "response" points to an array of int's, the int[0] is the size of array; + * subsequent values are a list of RIL_RadioBandMode listing supported modes. + * + * Valid errors: + * SUCCESS + * RADIO_NOT_AVAILABLE + * NO_MEMORY + * INTERNAL_ERR + * SYSTEM_ERR + * MODEM_ERR + * REQUEST_NOT_SUPPORTED + * NO_RESOURCES + * CANCELLED + * + * See also: RIL_REQUEST_SET_BAND_MODE + */ +#define RIL_REQUEST_QUERY_AVAILABLE_BAND_MODE 66 + +/** + * RIL_REQUEST_STK_GET_PROFILE + * + * Requests the profile of SIM tool kit. + * The profile indicates the SAT/USAT features supported by ME. + * The SAT/USAT features refer to 3GPP TS 11.14 and 3GPP TS 31.111 + * + * "data" is NULL + * + * "response" is a const char * containing SAT/USAT profile + * in hexadecimal format string starting with first byte of terminal profile + * + * Valid errors: + * RIL_E_SUCCESS + * RIL_E_RADIO_NOT_AVAILABLE (radio resetting) + * INTERNAL_ERR + * NO_MEMORY + * NO_RESOURCES + * CANCELLED + * REQUEST_NOT_SUPPORTED + */ +#define RIL_REQUEST_STK_GET_PROFILE 67 + +/** + * RIL_REQUEST_STK_SET_PROFILE + * + * Download the STK terminal profile as part of SIM initialization + * procedure + * + * "data" is a const char * containing SAT/USAT profile + * in hexadecimal format string starting with first byte of terminal profile + * + * "response" is NULL + * + * Valid errors: + * RIL_E_SUCCESS + * RIL_E_RADIO_NOT_AVAILABLE (radio resetting) + * INTERNAL_ERR + * NO_MEMORY + * NO_RESOURCES + * CANCELLED + * REQUEST_NOT_SUPPORTED + */ +#define RIL_REQUEST_STK_SET_PROFILE 68 + +/** + * RIL_REQUEST_STK_SEND_ENVELOPE_COMMAND + * + * Requests to send a SAT/USAT envelope command to SIM. + * The SAT/USAT envelope command refers to 3GPP TS 11.14 and 3GPP TS 31.111 + * + * "data" is a const char * containing SAT/USAT command + * in hexadecimal format string starting with command tag + * + * "response" is a const char * containing SAT/USAT response + * in hexadecimal format string starting with first byte of response + * (May be NULL) + * + * Valid errors: + * RIL_E_SUCCESS + * RIL_E_RADIO_NOT_AVAILABLE (radio resetting) + * SIM_BUSY + * OPERATION_NOT_ALLOWED + * INTERNAL_ERR + * NO_MEMORY + * NO_RESOURCES + * CANCELLED + * INVALID_ARGUMENTS + * MODEM_ERR + * REQUEST_NOT_SUPPORTED + */ +#define RIL_REQUEST_STK_SEND_ENVELOPE_COMMAND 69 + +/** + * RIL_REQUEST_STK_SEND_TERMINAL_RESPONSE + * + * Requests to send a terminal response to SIM for a received + * proactive command + * + * "data" is a const char * containing SAT/USAT response + * in hexadecimal format string starting with first byte of response data + * + * "response" is NULL + * + * Valid errors: + * RIL_E_SUCCESS + * RIL_E_RADIO_NOT_AVAILABLE (radio resetting) + * RIL_E_OPERATION_NOT_ALLOWED + * INTERNAL_ERR + * NO_MEMORY + * NO_RESOURCES + * CANCELLED + * INVALID_MODEM_STATE + * REQUEST_NOT_SUPPORTED + */ +#define RIL_REQUEST_STK_SEND_TERMINAL_RESPONSE 70 + +/** + * RIL_REQUEST_STK_HANDLE_CALL_SETUP_REQUESTED_FROM_SIM + * + * When STK application gets RIL_UNSOL_STK_CALL_SETUP, the call actually has + * been initialized by ME already. (We could see the call has been in the 'call + * list') So, STK application needs to accept/reject the call according as user + * operations. + * + * "data" is int * + * ((int *)data)[0] is > 0 for "accept" the call setup + * ((int *)data)[0] is == 0 for "reject" the call setup + * + * "response" is NULL + * + * Valid errors: + * RIL_E_SUCCESS + * RIL_E_RADIO_NOT_AVAILABLE (radio resetting) + * RIL_E_OPERATION_NOT_ALLOWED + * INTERNAL_ERR + * NO_MEMORY + * NO_RESOURCES + * CANCELLED + * REQUEST_NOT_SUPPORTED + */ +#define RIL_REQUEST_STK_HANDLE_CALL_SETUP_REQUESTED_FROM_SIM 71 + +/** + * RIL_REQUEST_EXPLICIT_CALL_TRANSFER + * + * Connects the two calls and disconnects the subscriber from both calls. + * + * "data" is NULL + * "response" is NULL + * + * Valid errors: + * SUCCESS + * RADIO_NOT_AVAILABLE (radio resetting) + * INVALID_STATE + * NO_RESOURCES + * NO_MEMORY + * INVALID_ARGUMENTS + * SYSTEM_ERR + * MODEM_ERR + * INTERNAL_ERR + * INVALID_CALL_ID + * INVALID_STATE + * OPERATION_NOT_ALLOWED + * NO_RESOURCES + * CANCELLED + * REQUEST_NOT_SUPPORTED + */ +#define RIL_REQUEST_EXPLICIT_CALL_TRANSFER 72 + +/** + * RIL_REQUEST_SET_PREFERRED_NETWORK_TYPE + * + * Requests to set the preferred network type for searching and registering + * (CS/PS domain, RAT, and operation mode) + * + * "data" is int * which is RIL_PreferredNetworkType + * + * "response" is NULL + * + * Valid errors: + * SUCCESS + * RADIO_NOT_AVAILABLE (radio resetting) + * OPERATION_NOT_ALLOWED + * MODE_NOT_SUPPORTED + * NO_MEMORY + * INTERNAL_ERR + * SYSTEM_ERR + * INVALID_ARGUMENTS + * MODEM_ERR + * REQUEST_NOT_SUPPORTED + * NO_RESOURCES + * CANCELLED + */ +#define RIL_REQUEST_SET_PREFERRED_NETWORK_TYPE 73 + +/** + * RIL_REQUEST_GET_PREFERRED_NETWORK_TYPE + * + * Query the preferred network type (CS/PS domain, RAT, and operation mode) + * for searching and registering + * + * "data" is NULL + * + * "response" is int * + * ((int *)reponse)[0] is == RIL_PreferredNetworkType + * + * Valid errors: + * SUCCESS + * RADIO_NOT_AVAILABLE + * NO_MEMORY + * INTERNAL_ERR + * SYSTEM_ERR + * INVALID_ARGUMENTS + * MODEM_ERR + * REQUEST_NOT_SUPPORTED + * NO_RESOURCES + * CANCELLED + * + * See also: RIL_REQUEST_SET_PREFERRED_NETWORK_TYPE + */ +#define RIL_REQUEST_GET_PREFERRED_NETWORK_TYPE 74 + +/** + * RIL_REQUEST_NEIGHBORING_CELL_IDS + * + * Request neighboring cell id in GSM network + * + * "data" is NULL + * "response" must be a " const RIL_NeighboringCell** " + * + * Valid errors: + * SUCCESS + * RADIO_NOT_AVAILABLE + * NO_MEMORY + * INTERNAL_ERR + * SYSTEM_ERR + * MODEM_ERR + * NO_NETWORK_FOUND + * REQUEST_NOT_SUPPORTED + * NO_RESOURCES + * CANCELLED + */ +#define RIL_REQUEST_GET_NEIGHBORING_CELL_IDS 75 + +/** + * RIL_REQUEST_SET_LOCATION_UPDATES + * + * Enables/disables network state change notifications due to changes in + * LAC and/or CID (for GSM) or BID/SID/NID/latitude/longitude (for CDMA). + * Basically +CREG=2 vs. +CREG=1 (TS 27.007). + * + * Note: The RIL implementation should default to "updates enabled" + * when the screen is on and "updates disabled" when the screen is off. + * + * "data" is int * + * ((int *)data)[0] is == 1 for updates enabled (+CREG=2) + * ((int *)data)[0] is == 0 for updates disabled (+CREG=1) + * + * "response" is NULL + * + * Valid errors: + * SUCCESS + * RADIO_NOT_AVAILABLE + * NO_MEMORY + * INTERNAL_ERR + * SYSTEM_ERR + * INVALID_ARGUMENTS + * MODEM_ERR + * REQUEST_NOT_SUPPORTED + * NO_RESOURCES + * CANCELLED + * + * See also: RIL_REQUEST_SCREEN_STATE, RIL_UNSOL_RESPONSE_NETWORK_STATE_CHANGED + */ +#define RIL_REQUEST_SET_LOCATION_UPDATES 76 + +/** + * RIL_REQUEST_CDMA_SET_SUBSCRIPTION_SOURCE + * + * Request to set the location where the CDMA subscription shall + * be retrieved + * + * "data" is int * + * ((int *)data)[0] is == RIL_CdmaSubscriptionSource + * + * "response" is NULL + * + * Valid errors: + * SUCCESS + * RADIO_NOT_AVAILABLE + * SIM_ABSENT + * SUBSCRIPTION_NOT_AVAILABLE + * INTERNAL_ERR + * NO_MEMORY + * NO_RESOURCES + * CANCELLED + * REQUEST_NOT_SUPPORTED + * + * See also: RIL_REQUEST_CDMA_GET_SUBSCRIPTION_SOURCE + */ +#define RIL_REQUEST_CDMA_SET_SUBSCRIPTION_SOURCE 77 + +/** + * RIL_REQUEST_CDMA_SET_ROAMING_PREFERENCE + * + * Request to set the roaming preferences in CDMA + * + * "data" is int * + * ((int *)data)[0] is == 0 for Home Networks only, as defined in PRL + * ((int *)data)[0] is == 1 for Roaming on Affiliated networks, as defined in PRL + * ((int *)data)[0] is == 2 for Roaming on Any Network, as defined in the PRL + * + * "response" is NULL + * + * Valid errors: + * SUCCESS + * RADIO_NOT_AVAILABLE + * NO_MEMORY + * INTERNAL_ERR + * SYSTEM_ERR + * INVALID_ARGUMENTS + * MODEM_ERR + * REQUEST_NOT_SUPPORTED + * OPERATION_NOT_ALLOWED + * NO_RESOURCES + * CANCELLED + */ +#define RIL_REQUEST_CDMA_SET_ROAMING_PREFERENCE 78 + +/** + * RIL_REQUEST_CDMA_QUERY_ROAMING_PREFERENCE + * + * Request the actual setting of the roaming preferences in CDMA in the modem + * + * "data" is NULL + * + * "response" is int * + * ((int *)response)[0] is == 0 for Home Networks only, as defined in PRL + * ((int *)response)[0] is == 1 for Roaming on Affiliated networks, as defined in PRL + * ((int *)response)[0] is == 2 for Roaming on Any Network, as defined in the PRL + * + * "response" is NULL + * + * Valid errors: + * SUCCESS + * RADIO_NOT_AVAILABLE + * NO_MEMORY + * INTERNAL_ERR + * SYSTEM_ERR + * INVALID_ARGUMENTS + * MODEM_ERR + * REQUEST_NOT_SUPPORTED + * NO_RESOURCES + * CANCELLED + */ +#define RIL_REQUEST_CDMA_QUERY_ROAMING_PREFERENCE 79 + +/** + * RIL_REQUEST_SET_TTY_MODE + * + * Request to set the TTY mode + * + * "data" is int * + * ((int *)data)[0] is == 0 for TTY off + * ((int *)data)[0] is == 1 for TTY Full + * ((int *)data)[0] is == 2 for TTY HCO (hearing carryover) + * ((int *)data)[0] is == 3 for TTY VCO (voice carryover) + * + * "response" is NULL + * + * Valid errors: + * SUCCESS + * RADIO_NOT_AVAILABLE + * INVALID_ARGUMENTS + * MODEM_ERR + * INTERNAL_ERR + * NO_MEMORY + * INVALID_ARGUMENTS + * MODEM_ERR + * INTERNAL_ERR + * NO_MEMORY + * NO_RESOURCES + * CANCELLED + * REQUEST_NOT_SUPPORTED + */ +#define RIL_REQUEST_SET_TTY_MODE 80 + +/** + * RIL_REQUEST_QUERY_TTY_MODE + * + * Request the setting of TTY mode + * + * "data" is NULL + * + * "response" is int * + * ((int *)response)[0] is == 0 for TTY off + * ((int *)response)[0] is == 1 for TTY Full + * ((int *)response)[0] is == 2 for TTY HCO (hearing carryover) + * ((int *)response)[0] is == 3 for TTY VCO (voice carryover) + * + * "response" is NULL + * + * Valid errors: + * SUCCESS + * RADIO_NOT_AVAILABLE + * MODEM_ERR + * INTERNAL_ERR + * NO_MEMORY + * INVALID_ARGUMENTS + * NO_RESOURCES + * CANCELLED + * REQUEST_NOT_SUPPORTED + */ +#define RIL_REQUEST_QUERY_TTY_MODE 81 + +/** + * RIL_REQUEST_CDMA_SET_PREFERRED_VOICE_PRIVACY_MODE + * + * Request to set the preferred voice privacy mode used in voice + * scrambling + * + * "data" is int * + * ((int *)data)[0] is == 0 for Standard Privacy Mode (Public Long Code Mask) + * ((int *)data)[0] is == 1 for Enhanced Privacy Mode (Private Long Code Mask) + * + * "response" is NULL + * + * Valid errors: + * SUCCESS + * RADIO_NOT_AVAILABLE + * INVALID_ARGUMENTS + * SYSTEM_ERR + * MODEM_ERR + * INTERNAL_ERR + * NO_MEMORY + * INVALID_CALL_ID + * NO_RESOURCES + * CANCELLED + * REQUEST_NOT_SUPPORTED + */ +#define RIL_REQUEST_CDMA_SET_PREFERRED_VOICE_PRIVACY_MODE 82 + +/** + * RIL_REQUEST_CDMA_QUERY_PREFERRED_VOICE_PRIVACY_MODE + * + * Request the setting of preferred voice privacy mode + * + * "data" is NULL + * + * "response" is int * + * ((int *)response)[0] is == 0 for Standard Privacy Mode (Public Long Code Mask) + * ((int *)response)[0] is == 1 for Enhanced Privacy Mode (Private Long Code Mask) + * + * "response" is NULL + * + * Valid errors: + * SUCCESS + * RADIO_NOT_AVAILABLE + * MODEM_ERR + * INTERNAL_ERR + * NO_MEMORY + * INVALID_ARGUMENTS + * NO_RESOURCES + * CANCELLED + * REQUEST_NOT_SUPPORTED + */ +#define RIL_REQUEST_CDMA_QUERY_PREFERRED_VOICE_PRIVACY_MODE 83 + +/** + * RIL_REQUEST_CDMA_FLASH + * + * Send FLASH + * + * "data" is const char * + * ((const char *)data)[0] is a FLASH string + * + * "response" is NULL + * + * Valid errors: + * SUCCESS + * RADIO_NOT_AVAILABLE + * INVALID_ARGUMENTS + * NO_MEMORY + * SYSTEM_ERR + * MODEM_ERR + * INTERNAL_ERR + * INVALID_CALL_ID + * INVALID_STATE + * NO_RESOURCES + * CANCELLED + * REQUEST_NOT_SUPPORTED + * + */ +#define RIL_REQUEST_CDMA_FLASH 84 + +/** + * RIL_REQUEST_CDMA_BURST_DTMF + * + * Send DTMF string + * + * "data" is const char ** + * ((const char **)data)[0] is a DTMF string + * ((const char **)data)[1] is the DTMF ON length in milliseconds, or 0 to use + * default + * ((const char **)data)[2] is the DTMF OFF length in milliseconds, or 0 to use + * default + * + * "response" is NULL + * + * Valid errors: + * SUCCESS + * RADIO_NOT_AVAILABLE + * INVALID_ARGUMENTS + * NO_MEMORY + * SYSTEM_ERR + * MODEM_ERR + * INTERNAL_ERR + * INVALID_CALL_ID + * NO_RESOURCES + * CANCELLED + * OPERATION_NOT_ALLOWED + * REQUEST_NOT_SUPPORTED + * + */ +#define RIL_REQUEST_CDMA_BURST_DTMF 85 + +/** + * RIL_REQUEST_CDMA_VALIDATE_AND_WRITE_AKEY + * + * Takes a 26 digit string (20 digit AKEY + 6 digit checksum). + * If the checksum is valid the 20 digit AKEY is written to NV, + * replacing the existing AKEY no matter what it was before. + * + * "data" is const char * + * ((const char *)data)[0] is a 26 digit string (ASCII digits '0'-'9') + * where the last 6 digits are a checksum of the + * first 20, as specified in TR45.AHAG + * "Common Cryptographic Algorithms, Revision D.1 + * Section 2.2" + * + * "response" is NULL + * + * Valid errors: + * SUCCESS + * RADIO_NOT_AVAILABLE + * NO_MEMORY + * INTERNAL_ERR + * SYSTEM_ERR + * INVALID_ARGUMENTS + * MODEM_ERR + * REQUEST_NOT_SUPPORTED + * NO_RESOURCES + * CANCELLED + * + */ +#define RIL_REQUEST_CDMA_VALIDATE_AND_WRITE_AKEY 86 + +/** + * RIL_REQUEST_CDMA_SEND_SMS + * + * Send a CDMA SMS message + * + * "data" is const RIL_CDMA_SMS_Message * + * + * "response" is a const RIL_SMS_Response * + * + * Based on the return error, caller decides to resend if sending sms + * fails. The CDMA error class is derived as follows, + * SUCCESS is error class 0 (no error) + * SMS_SEND_FAIL_RETRY is error class 2 (temporary failure) + * + * Valid errors: + * SUCCESS + * RADIO_NOT_AVAILABLE + * SMS_SEND_FAIL_RETRY + * NETWORK_REJECT + * INVALID_STATE + * INVALID_ARGUMENTS + * NO_MEMORY + * REQUEST_RATE_LIMITED + * INVALID_SMS_FORMAT + * SYSTEM_ERR + * FDN_CHECK_FAILURE + * MODEM_ERR + * NETWORK_ERR + * ENCODING_ERR + * INVALID_SMSC_ADDRESS + * OPERATION_NOT_ALLOWED + * NO_RESOURCES + * CANCELLED + * REQUEST_NOT_SUPPORTED + * MODE_NOT_SUPPORTED + * SIM_ABSENT + * + */ +#define RIL_REQUEST_CDMA_SEND_SMS 87 + +/** + * RIL_REQUEST_CDMA_SMS_ACKNOWLEDGE + * + * Acknowledge the success or failure in the receipt of SMS + * previously indicated via RIL_UNSOL_RESPONSE_CDMA_NEW_SMS + * + * "data" is const RIL_CDMA_SMS_Ack * + * + * "response" is NULL + * + * Valid errors: + * SUCCESS + * RADIO_NOT_AVAILABLE + * INVALID_ARGUMENTS + * NO_SMS_TO_ACK + * INVALID_STATE + * NO_MEMORY + * REQUEST_RATE_LIMITED + * SYSTEM_ERR + * MODEM_ERR + * INVALID_STATE + * OPERATION_NOT_ALLOWED + * NETWORK_NOT_READY + * INVALID_MODEM_STATE + * REQUEST_NOT_SUPPORTED + * + */ +#define RIL_REQUEST_CDMA_SMS_ACKNOWLEDGE 88 + +/** + * RIL_REQUEST_GSM_GET_BROADCAST_SMS_CONFIG + * + * Request the setting of GSM/WCDMA Cell Broadcast SMS config. + * + * "data" is NULL + * + * "response" is a const RIL_GSM_BroadcastSmsConfigInfo ** + * "responselen" is count * sizeof (RIL_GSM_BroadcastSmsConfigInfo *) + * + * Valid errors: + * SUCCESS + * RADIO_NOT_AVAILABLE + * INVALID_STATE + * NO_MEMORY + * REQUEST_RATE_LIMITED + * SYSTEM_ERR + * NO_RESOURCES + * MODEM_ERR + * SYSTEM_ERR + * INTERNAL_ERR + * NO_RESOURCES + * CANCELLED + * INVALID_MODEM_STATE + * REQUEST_NOT_SUPPORTED + */ +#define RIL_REQUEST_GSM_GET_BROADCAST_SMS_CONFIG 89 + +/** + * RIL_REQUEST_GSM_SET_BROADCAST_SMS_CONFIG + * + * Set GSM/WCDMA Cell Broadcast SMS config + * + * "data" is a const RIL_GSM_BroadcastSmsConfigInfo ** + * "datalen" is count * sizeof(RIL_GSM_BroadcastSmsConfigInfo *) + * + * "response" is NULL + * + * Valid errors: + * SUCCESS + * RADIO_NOT_AVAILABLE + * INVALID_STATE + * INVALID_ARGUMENTS + * NO_MEMORY + * SYSTEM_ERR + * REQUEST_RATE_LIMITED + * MODEM_ERR + * SYSTEM_ERR + * INTERNAL_ERR + * NO_RESOURCES + * CANCELLED + * INVALID_MODEM_STATE + * REQUEST_NOT_SUPPORTED + * + */ +#define RIL_REQUEST_GSM_SET_BROADCAST_SMS_CONFIG 90 + +/** + * RIL_REQUEST_GSM_SMS_BROADCAST_ACTIVATION + * +* Enable or disable the reception of GSM/WCDMA Cell Broadcast SMS + * + * "data" is const int * + * (const int *)data[0] indicates to activate or turn off the + * reception of GSM/WCDMA Cell Broadcast SMS, 0-1, + * 0 - Activate, 1 - Turn off + * + * "response" is NULL + * + * Valid errors: + * SUCCESS + * RADIO_NOT_AVAILABLE + * INVALID_STATE + * INVALID_ARGUMENTS + * NO_MEMORY + * SYSTEM_ERR + * REQUEST_RATE_LIMITED +* MODEM_ERR +* INTERNAL_ERR +* NO_RESOURCES +* CANCELLED +* INVALID_MODEM_STATE + * REQUEST_NOT_SUPPORTED + * + */ +#define RIL_REQUEST_GSM_SMS_BROADCAST_ACTIVATION 91 + +/** + * RIL_REQUEST_CDMA_GET_BROADCAST_SMS_CONFIG + * + * Request the setting of CDMA Broadcast SMS config + * + * "data" is NULL + * + * "response" is a const RIL_CDMA_BroadcastSmsConfigInfo ** + * "responselen" is count * sizeof (RIL_CDMA_BroadcastSmsConfigInfo *) + * + * Valid errors: + * SUCCESS + * RADIO_NOT_AVAILABLE + * INVALID_STATE + * NO_MEMORY + * REQUEST_RATE_LIMITED + * SYSTEM_ERR + * NO_RESOURCES + * MODEM_ERR + * SYSTEM_ERR + * INTERNAL_ERR + * NO_RESOURCES + * CANCELLED + * INVALID_MODEM_STATE + * REQUEST_NOT_SUPPORTED + * + */ +#define RIL_REQUEST_CDMA_GET_BROADCAST_SMS_CONFIG 92 + +/** + * RIL_REQUEST_CDMA_SET_BROADCAST_SMS_CONFIG + * + * Set CDMA Broadcast SMS config + * + * "data" is a const RIL_CDMA_BroadcastSmsConfigInfo ** + * "datalen" is count * sizeof(const RIL_CDMA_BroadcastSmsConfigInfo *) + * + * "response" is NULL + * + * Valid errors: + * SUCCESS + * RADIO_NOT_AVAILABLE + * INVALID_STATE + * INVALID_ARGUMENTS + * NO_MEMORY + * SYSTEM_ERR + * REQUEST_RATE_LIMITED + * MODEM_ERR + * SYSTEM_ERR + * INTERNAL_ERR + * NO_RESOURCES + * CANCELLED + * INVALID_MODEM_STATE + * REQUEST_NOT_SUPPORTED + * + */ +#define RIL_REQUEST_CDMA_SET_BROADCAST_SMS_CONFIG 93 + +/** + * RIL_REQUEST_CDMA_SMS_BROADCAST_ACTIVATION + * + * Enable or disable the reception of CDMA Broadcast SMS + * + * "data" is const int * + * (const int *)data[0] indicates to activate or turn off the + * reception of CDMA Broadcast SMS, 0-1, + * 0 - Activate, 1 - Turn off + * + * "response" is NULL + * + * Valid errors: + * SUCCESS + * RADIO_NOT_AVAILABLE + * INVALID_STATE + * INVALID_ARGUMENTS + * NO_MEMORY + * SYSTEM_ERR + * REQUEST_RATE_LIMITED + * MODEM_ERR + * INTERNAL_ERR + * NO_RESOURCES + * CANCELLED + * INVALID_MODEM_STATE + * REQUEST_NOT_SUPPORTED + * + */ +#define RIL_REQUEST_CDMA_SMS_BROADCAST_ACTIVATION 94 + +/** + * RIL_REQUEST_CDMA_SUBSCRIPTION + * + * Request the device MDN / H_SID / H_NID. + * + * The request is only allowed when CDMA subscription is available. When CDMA + * subscription is changed, application layer should re-issue the request to + * update the subscription information. + * + * If a NULL value is returned for any of the device id, it means that error + * accessing the device. + * + * "response" is const char ** + * ((const char **)response)[0] is MDN if CDMA subscription is available + * ((const char **)response)[1] is a comma separated list of H_SID (Home SID) if + * CDMA subscription is available, in decimal format + * ((const char **)response)[2] is a comma separated list of H_NID (Home NID) if + * CDMA subscription is available, in decimal format + * ((const char **)response)[3] is MIN (10 digits, MIN2+MIN1) if CDMA subscription is available + * ((const char **)response)[4] is PRL version if CDMA subscription is available + * + * Valid errors: + * SUCCESS + * RIL_E_SUBSCRIPTION_NOT_AVAILABLE + * NO_MEMORY + * INTERNAL_ERR + * SYSTEM_ERR + * INVALID_ARGUMENTS + * MODEM_ERR + * NOT_PROVISIONED + * REQUEST_NOT_SUPPORTED + * INTERNAL_ERR + * NO_RESOURCES + * CANCELLED + * + */ + +#define RIL_REQUEST_CDMA_SUBSCRIPTION 95 + +/** + * RIL_REQUEST_CDMA_WRITE_SMS_TO_RUIM + * + * Stores a CDMA SMS message to RUIM memory. + * + * "data" is RIL_CDMA_SMS_WriteArgs * + * + * "response" is int * + * ((const int *)response)[0] is the record index where the message is stored. + * + * Valid errors: + * SUCCESS + * RADIO_NOT_AVAILABLE + * SIM_FULL + * INVALID_ARGUMENTS + * INVALID_SMS_FORMAT + * INTERNAL_ERR + * MODEM_ERR + * ENCODING_ERR + * NO_MEMORY + * NO_RESOURCES + * INVALID_MODEM_STATE + * OPERATION_NOT_ALLOWED + * INVALID_SMSC_ADDRESS + * CANCELLED + * INVALID_MODEM_STATE + * REQUEST_NOT_SUPPORTED + * SIM_ABSENT + * + */ +#define RIL_REQUEST_CDMA_WRITE_SMS_TO_RUIM 96 + +/** + * RIL_REQUEST_CDMA_DELETE_SMS_ON_RUIM + * + * Deletes a CDMA SMS message from RUIM memory. + * + * "data" is int * + * ((int *)data)[0] is the record index of the message to delete. + * + * "response" is NULL + * + * Valid errors: + * SUCCESS + * RADIO_NOT_AVAILABLE + * INVALID_ARGUMENTS + * NO_MEMORY + * REQUEST_RATE_LIMITED + * SYSTEM_ERR + * MODEM_ERR + * NO_SUCH_ENTRY + * INTERNAL_ERR + * NO_RESOURCES + * CANCELLED + * INVALID_MODEM_STATE + * REQUEST_NOT_SUPPORTED + * SIM_ABSENT + */ +#define RIL_REQUEST_CDMA_DELETE_SMS_ON_RUIM 97 + +/** + * RIL_REQUEST_DEVICE_IDENTITY + * + * Request the device ESN / MEID / IMEI / IMEISV. + * + * The request is always allowed and contains GSM and CDMA device identity; + * it substitutes the deprecated requests RIL_REQUEST_GET_IMEI and + * RIL_REQUEST_GET_IMEISV. + * + * If a NULL value is returned for any of the device id, it means that error + * accessing the device. + * + * When CDMA subscription is changed the ESN/MEID may change. The application + * layer should re-issue the request to update the device identity in this case. + * + * "response" is const char ** + * ((const char **)response)[0] is IMEI if GSM subscription is available + * ((const char **)response)[1] is IMEISV if GSM subscription is available + * ((const char **)response)[2] is ESN if CDMA subscription is available + * ((const char **)response)[3] is MEID if CDMA subscription is available + * + * Valid errors: + * SUCCESS + * RADIO_NOT_AVAILABLE + * NO_MEMORY + * INTERNAL_ERR + * SYSTEM_ERR + * INVALID_ARGUMENTS + * MODEM_ERR + * NOT_PROVISIONED + * REQUEST_NOT_SUPPORTED + * NO_RESOURCES + * CANCELLED + * + */ +#define RIL_REQUEST_DEVICE_IDENTITY 98 + +/** + * RIL_REQUEST_EXIT_EMERGENCY_CALLBACK_MODE + * + * Request the radio's system selection module to exit emergency + * callback mode. RIL will not respond with SUCCESS until the modem has + * completely exited from Emergency Callback Mode. + * + * "data" is NULL + * + * "response" is NULL + * + * Valid errors: + * SUCCESS + * RADIO_NOT_AVAILABLE + * OPERATION_NOT_ALLOWED + * NO_MEMORY + * INTERNAL_ERR + * SYSTEM_ERR + * INVALID_ARGUMENTS + * MODEM_ERR + * REQUEST_NOT_SUPPORTED + * NO_RESOURCES + * CANCELLED + * + */ +#define RIL_REQUEST_EXIT_EMERGENCY_CALLBACK_MODE 99 + +/** + * RIL_REQUEST_GET_SMSC_ADDRESS + * + * Queries the default Short Message Service Center address on the device. + * + * "data" is NULL + * + * "response" is const char * containing the SMSC address. + * + * Valid errors: + * SUCCESS + * RADIO_NOT_AVAILABLE + * NO_MEMORY + * REQUEST_RATE_LIMITED + * SYSTEM_ERR + * INTERNAL_ERR + * MODEM_ERR + * INVALID_ARGUMENTS + * INVALID_MODEM_STATE + * NOT_PROVISIONED + * NO_RESOURCES + * CANCELLED + * REQUEST_NOT_SUPPORTED + * SIM_ABSENT + * + */ +#define RIL_REQUEST_GET_SMSC_ADDRESS 100 + +/** + * RIL_REQUEST_SET_SMSC_ADDRESS + * + * Sets the default Short Message Service Center address on the device. + * + * "data" is const char * containing the SMSC address. + * + * "response" is NULL + * + * Valid errors: + * SUCCESS + * RADIO_NOT_AVAILABLE + * INVALID_ARGUMENTS + * INVALID_SMS_FORMAT + * NO_MEMORY + * SYSTEM_ERR + * REQUEST_RATE_LIMITED + * MODEM_ERR + * NO_RESOURCES + * INTERNAL_ERR + * CANCELLED + * REQUEST_NOT_SUPPORTED + * SIM_ABSENT + */ +#define RIL_REQUEST_SET_SMSC_ADDRESS 101 + +/** + * RIL_REQUEST_REPORT_SMS_MEMORY_STATUS + * + * Indicates whether there is storage available for new SMS messages. + * + * "data" is int * + * ((int *)data)[0] is 1 if memory is available for storing new messages + * is 0 if memory capacity is exceeded + * + * "response" is NULL + * + * Valid errors: + * SUCCESS + * RADIO_NOT_AVAILABLE + * INVALID_ARGUMENTS + * NO_MEMORY + * INVALID_STATE + * SYSTEM_ERR + * REQUEST_RATE_LIMITED + * MODEM_ERR + * INTERNAL_ERR + * NO_RESOURCES + * CANCELLED + * REQUEST_NOT_SUPPORTED + * + */ +#define RIL_REQUEST_REPORT_SMS_MEMORY_STATUS 102 + +/** + * RIL_REQUEST_REPORT_STK_SERVICE_IS_RUNNING + * + * Indicates that the StkSerivce is running and is + * ready to receive RIL_UNSOL_STK_XXXXX commands. + * + * "data" is NULL + * "response" is NULL + * + * Valid errors: + * SUCCESS + * RADIO_NOT_AVAILABLE + * INTERNAL_ERR + * NO_MEMORY + * NO_RESOURCES + * CANCELLED + * REQUEST_NOT_SUPPORTED + * + */ +#define RIL_REQUEST_REPORT_STK_SERVICE_IS_RUNNING 103 + +/** + * RIL_REQUEST_CDMA_GET_SUBSCRIPTION_SOURCE + * + * Request to query the location where the CDMA subscription shall + * be retrieved + * + * "data" is NULL + * + * "response" is int * + * ((int *)data)[0] is == RIL_CdmaSubscriptionSource + * + * Valid errors: + * SUCCESS + * RADIO_NOT_AVAILABLE + * SUBSCRIPTION_NOT_AVAILABLE + * INTERNAL_ERR + * NO_MEMORY + * NO_RESOURCES + * CANCELLED + * REQUEST_NOT_SUPPORTED + * + * See also: RIL_REQUEST_CDMA_SET_SUBSCRIPTION_SOURCE + */ +#define RIL_REQUEST_CDMA_GET_SUBSCRIPTION_SOURCE 104 + +/** + * RIL_REQUEST_ISIM_AUTHENTICATION + * + * Request the ISIM application on the UICC to perform AKA + * challenge/response algorithm for IMS authentication + * + * "data" is a const char * containing the challenge string in Base64 format + * "response" is a const char * containing the response in Base64 format + * + * Valid errors: + * SUCCESS + * RADIO_NOT_AVAILABLE + * INTERNAL_ERR + * NO_MEMORY + * NO_RESOURCES + * CANCELLED + * REQUEST_NOT_SUPPORTED + */ +#define RIL_REQUEST_ISIM_AUTHENTICATION 105 + +/** + * RIL_REQUEST_ACKNOWLEDGE_INCOMING_GSM_SMS_WITH_PDU + * + * Acknowledge successful or failed receipt of SMS previously indicated + * via RIL_UNSOL_RESPONSE_NEW_SMS, including acknowledgement TPDU to send + * as the RP-User-Data element of the RP-ACK or RP-ERROR PDU. + * + * "data" is const char ** + * ((const char **)data)[0] is "1" on successful receipt (send RP-ACK) + * is "0" on failed receipt (send RP-ERROR) + * ((const char **)data)[1] is the acknowledgement TPDU in hexadecimal format + * + * "response" is NULL + * + * Valid errors: + * SUCCESS + * RADIO_NOT_AVAILABLE + * INTERNAL_ERR + * NO_MEMORY + * NO_RESOURCES + * CANCELLED + * REQUEST_NOT_SUPPORTED + */ +#define RIL_REQUEST_ACKNOWLEDGE_INCOMING_GSM_SMS_WITH_PDU 106 + +/** + * RIL_REQUEST_STK_SEND_ENVELOPE_WITH_STATUS + * + * Requests to send a SAT/USAT envelope command to SIM. + * The SAT/USAT envelope command refers to 3GPP TS 11.14 and 3GPP TS 31.111. + * + * This request has one difference from RIL_REQUEST_STK_SEND_ENVELOPE_COMMAND: + * the SW1 and SW2 status bytes from the UICC response are returned along with + * the response data, using the same structure as RIL_REQUEST_SIM_IO. + * + * The RIL implementation shall perform the normal processing of a '91XX' + * response in SW1/SW2 to retrieve the pending proactive command and send it + * as an unsolicited response, as RIL_REQUEST_STK_SEND_ENVELOPE_COMMAND does. + * + * "data" is a const char * containing the SAT/USAT command + * in hexadecimal format starting with command tag + * + * "response" is a const RIL_SIM_IO_Response * + * + * Valid errors: + * RIL_E_SUCCESS + * RIL_E_RADIO_NOT_AVAILABLE (radio resetting) + * SIM_BUSY + * OPERATION_NOT_ALLOWED + * INTERNAL_ERR + * NO_MEMORY + * NO_RESOURCES + * CANCELLED + * REQUEST_NOT_SUPPORTED + * SIM_ABSENT + */ +#define RIL_REQUEST_STK_SEND_ENVELOPE_WITH_STATUS 107 + +/** + * RIL_REQUEST_VOICE_RADIO_TECH + * + * Query the radio technology type (3GPP/3GPP2) used for voice. Query is valid only + * when radio state is not RADIO_STATE_UNAVAILABLE + * + * "data" is NULL + * "response" is int * + * ((int *) response)[0] is of type const RIL_RadioTechnology + * + * Valid errors: + * SUCCESS + * RADIO_NOT_AVAILABLE + * INTERNAL_ERR + * NO_MEMORY + * NO_RESOURCES + * CANCELLED + * REQUEST_NOT_SUPPORTED + */ +#define RIL_REQUEST_VOICE_RADIO_TECH 108 + +/** + * RIL_REQUEST_GET_CELL_INFO_LIST + * + * Request all of the current cell information known to the radio. The radio + * must a list of all current cells, including the neighboring cells. If for a particular + * cell information isn't known then the appropriate unknown value will be returned. + * This does not cause or change the rate of RIL_UNSOL_CELL_INFO_LIST. + * + * "data" is NULL + * + * "response" is an array of RIL_CellInfo_v12. + * + * Valid errors: + * SUCCESS + * RADIO_NOT_AVAILABLE + * NO_MEMORY + * INTERNAL_ERR + * SYSTEM_ERR + * MODEM_ERR + * NO_NETWORK_FOUND + * REQUEST_NOT_SUPPORTED + * NO_RESOURCES + * CANCELLED + * + */ +#define RIL_REQUEST_GET_CELL_INFO_LIST 109 + +/** + * RIL_REQUEST_SET_UNSOL_CELL_INFO_LIST_RATE + * + * Sets the minimum time between when RIL_UNSOL_CELL_INFO_LIST should be invoked. + * A value of 0, means invoke RIL_UNSOL_CELL_INFO_LIST when any of the reported + * information changes. Setting the value to INT_MAX(0x7fffffff) means never issue + * a RIL_UNSOL_CELL_INFO_LIST. + * + * "data" is int * + * ((int *)data)[0] is minimum time in milliseconds + * + * "response" is NULL + * + * Valid errors: + * SUCCESS + * RADIO_NOT_AVAILABLE + * NO_MEMORY + * INTERNAL_ERR + * SYSTEM_ERR + * INVALID_ARGUMENTS + * REQUEST_NOT_SUPPORTED + * NO_RESOURCES + * CANCELLED + */ +#define RIL_REQUEST_SET_UNSOL_CELL_INFO_LIST_RATE 110 + +/** + * RIL_REQUEST_SET_INITIAL_ATTACH_APN + * + * Set an apn to initial attach network + * + * "data" is a const char ** + * ((const char **)data)[0] is the APN to connect if radio technology is LTE + * ((const char **)data)[1] is the connection type to request must be one of the + * PDP_type values in TS 27.007 section 10.1.1. + * For example, "IP", "IPV6", "IPV4V6", or "PPP". + * ((const char **)data)[2] is the PAP / CHAP auth type. Values: + * 0 => PAP and CHAP is never performed. + * 1 => PAP may be performed; CHAP is never performed. + * 2 => CHAP may be performed; PAP is never performed. + * 3 => PAP / CHAP may be performed - baseband dependent. + * ((const char **)data)[3] is the username for APN, or NULL + * ((const char **)data)[4] is the password for APN, or NULL + * + * "response" is NULL + * + * Valid errors: + * SUCCESS + * RADIO_NOT_AVAILABLE (radio resetting) + * SUBSCRIPTION_NOT_AVAILABLE + * NO_MEMORY + * INTERNAL_ERR + * SYSTEM_ERR + * INVALID_ARGUMENTS + * MODEM_ERR + * NOT_PROVISIONED + * REQUEST_NOT_SUPPORTED + * NO_RESOURCES + * CANCELLED + * + */ +#define RIL_REQUEST_SET_INITIAL_ATTACH_APN 111 + +/** + * RIL_REQUEST_IMS_REGISTRATION_STATE + * + * This message is DEPRECATED and shall be removed in a future release (target: 2018); + * instead, provide IMS registration status via an IMS Service. + * + * Request current IMS registration state + * + * "data" is NULL + * + * "response" is int * + * ((int *)response)[0] is registration state: + * 0 - Not registered + * 1 - Registered + * + * If ((int*)response)[0] is = 1, then ((int *) response)[1] + * must follow with IMS SMS format: + * + * ((int *) response)[1] is of type RIL_RadioTechnologyFamily + * + * Valid errors: + * SUCCESS + * RADIO_NOT_AVAILABLE + * INTERNAL_ERR + * NO_MEMORY + * NO_RESOURCES + * CANCELLED + * INVALID_MODEM_STATE + * REQUEST_NOT_SUPPORTED + */ +#define RIL_REQUEST_IMS_REGISTRATION_STATE 112 + +/** + * RIL_REQUEST_IMS_SEND_SMS + * + * Send a SMS message over IMS + * + * "data" is const RIL_IMS_SMS_Message * + * + * "response" is a const RIL_SMS_Response * + * + * Based on the return error, caller decides to resend if sending sms + * fails. SMS_SEND_FAIL_RETRY means retry, and other errors means no retry. + * In case of retry, data is encoded based on Voice Technology available. + * + * Valid errors: + * SUCCESS + * RADIO_NOT_AVAILABLE + * SMS_SEND_FAIL_RETRY + * FDN_CHECK_FAILURE + * NETWORK_REJECT + * INVALID_ARGUMENTS + * INVALID_STATE + * NO_MEMORY + * INVALID_SMS_FORMAT + * SYSTEM_ERR + * REQUEST_RATE_LIMITED + * MODEM_ERR + * NETWORK_ERR + * ENCODING_ERR + * INVALID_SMSC_ADDRESS + * OPERATION_NOT_ALLOWED + * INTERNAL_ERR + * NO_RESOURCES + * CANCELLED + * REQUEST_NOT_SUPPORTED + * + */ +#define RIL_REQUEST_IMS_SEND_SMS 113 + +/** + * RIL_REQUEST_SIM_TRANSMIT_APDU_BASIC + * + * Request APDU exchange on the basic channel. This command reflects TS 27.007 + * "generic SIM access" operation (+CSIM). The modem must ensure proper function + * of GSM/CDMA, and filter commands appropriately. It should filter + * channel management and SELECT by DF name commands. + * + * "data" is a const RIL_SIM_APDU * + * "sessionid" field should be ignored. + * + * "response" is a const RIL_SIM_IO_Response * + * + * Valid errors: + * SUCCESS + * RADIO_NOT_AVAILABLE + * INTERNAL_ERR + * NO_MEMORY + * NO_RESOURCES + * CANCELLED + * REQUEST_NOT_SUPPORTED + */ +#define RIL_REQUEST_SIM_TRANSMIT_APDU_BASIC 114 + +/** + * RIL_REQUEST_SIM_OPEN_CHANNEL + * + * Open a new logical channel and select the given application. This command + * reflects TS 27.007 "open logical channel" operation (+CCHO). This request + * also specifies the P2 parameter (described in ISO 7816-4). + * + * "data" is a const RIL_OpenChannelParam * + * + * "response" is int * + * ((int *)data)[0] contains the session id of the logical channel. + * ((int *)data)[1] onwards may optionally contain the select response for the + * open channel command with one byte per integer. + * + * Valid errors: + * SUCCESS + * RADIO_NOT_AVAILABLE + * MISSING_RESOURCE + * NO_SUCH_ELEMENT + * INTERNAL_ERR + * NO_MEMORY + * NO_RESOURCES + * CANCELLED + * SIM_ERR + * INVALID_SIM_STATE + * MISSING_RESOURCE + * REQUEST_NOT_SUPPORTED + */ +#define RIL_REQUEST_SIM_OPEN_CHANNEL 115 + +/** + * RIL_REQUEST_SIM_CLOSE_CHANNEL + * + * Close a previously opened logical channel. This command reflects TS 27.007 + * "close logical channel" operation (+CCHC). + * + * "data" is int * + * ((int *)data)[0] is the session id of logical the channel to close. + * + * "response" is NULL + * + * Valid errors: + * SUCCESS + * RADIO_NOT_AVAILABLE + * INTERNAL_ERR + * NO_MEMORY + * NO_RESOURCES + * CANCELLED + * REQUEST_NOT_SUPPORTED + */ +#define RIL_REQUEST_SIM_CLOSE_CHANNEL 116 + +/** + * RIL_REQUEST_SIM_TRANSMIT_APDU_CHANNEL + * + * Exchange APDUs with a UICC over a previously opened logical channel. This + * command reflects TS 27.007 "generic logical channel access" operation + * (+CGLA). The modem should filter channel management and SELECT by DF name + * commands. + * + * "data" is a const RIL_SIM_APDU* + * + * "response" is a const RIL_SIM_IO_Response * + * + * Valid errors: + * SUCCESS + * RADIO_NOT_AVAILABLE + * INTERNAL_ERR + * NO_MEMORY + * NO_RESOURCES + * CANCELLED + * REQUEST_NOT_SUPPORTED + */ +#define RIL_REQUEST_SIM_TRANSMIT_APDU_CHANNEL 117 + +/** + * RIL_REQUEST_NV_READ_ITEM + * + * Read one of the radio NV items defined in RadioNVItems.java / ril_nv_items.h. + * This is used for device configuration by some CDMA operators. + * + * "data" is a const RIL_NV_ReadItem * + * + * "response" is const char * containing the contents of the NV item + * + * Valid errors: + * SUCCESS + * RADIO_NOT_AVAILABLE + * REQUEST_NOT_SUPPORTED + */ +#define RIL_REQUEST_NV_READ_ITEM 118 + +/** + * RIL_REQUEST_NV_WRITE_ITEM + * + * Write one of the radio NV items defined in RadioNVItems.java / ril_nv_items.h. + * This is used for device configuration by some CDMA operators. + * + * "data" is a const RIL_NV_WriteItem * + * + * "response" is NULL + * + * Valid errors: + * SUCCESS + * RADIO_NOT_AVAILABLE + * REQUEST_NOT_SUPPORTED + */ +#define RIL_REQUEST_NV_WRITE_ITEM 119 + +/** + * RIL_REQUEST_NV_WRITE_CDMA_PRL + * + * Update the CDMA Preferred Roaming List (PRL) in the radio NV storage. + * This is used for device configuration by some CDMA operators. + * + * "data" is a const char * containing the PRL as a byte array + * + * "response" is NULL + * + * Valid errors: + * SUCCESS + * RADIO_NOT_AVAILABLE + * REQUEST_NOT_SUPPORTED + */ +#define RIL_REQUEST_NV_WRITE_CDMA_PRL 120 + +/** + * RIL_REQUEST_NV_RESET_CONFIG + * + * Reset the radio NV configuration to the factory state. + * This is used for device configuration by some CDMA operators. + * + * "data" is int * + * ((int *)data)[0] is 1 to reload all NV items + * ((int *)data)[0] is 2 for erase NV reset (SCRTN) + * ((int *)data)[0] is 3 for factory reset (RTN) + * + * "response" is NULL + * + * Valid errors: + * SUCCESS + * RADIO_NOT_AVAILABLE + * REQUEST_NOT_SUPPORTED + */ +#define RIL_REQUEST_NV_RESET_CONFIG 121 + + /** RIL_REQUEST_SET_UICC_SUBSCRIPTION + * FIXME This API needs to have more documentation. + * + * Selection/de-selection of a subscription from a SIM card + * "data" is const RIL_SelectUiccSub* + + * + * "response" is NULL + * + * Valid errors: + * SUCCESS + * RADIO_NOT_AVAILABLE (radio resetting) + * SUBSCRIPTION_NOT_SUPPORTED + * NO_MEMORY + * INTERNAL_ERR + * SYSTEM_ERR + * INVALID_ARGUMENTS + * MODEM_ERR + * REQUEST_NOT_SUPPORTED + * NO_RESOURCES + * CANCELLED + * + */ +#define RIL_REQUEST_SET_UICC_SUBSCRIPTION 122 + +/** + * RIL_REQUEST_ALLOW_DATA + * + * Tells the modem whether data calls are allowed or not + * + * "data" is int * + * FIXME slotId and aid will be added. + * ((int *)data)[0] is == 0 to allow data calls + * ((int *)data)[0] is == 1 to disallow data calls + * + * "response" is NULL + * + * Valid errors: + * + * SUCCESS + * RADIO_NOT_AVAILABLE (radio resetting) + * NO_MEMORY + * INTERNAL_ERR + * SYSTEM_ERR + * MODEM_ERR + * INVALID_ARGUMENTS + * DEVICE_IN_USE + * INVALID_MODEM_STATE + * REQUEST_NOT_SUPPORTED + * NO_RESOURCES + * CANCELLED + * + */ +#define RIL_REQUEST_ALLOW_DATA 123 + +/** + * RIL_REQUEST_GET_HARDWARE_CONFIG + * + * Request all of the current hardware (modem and sim) associated + * with the RIL. + * + * "data" is NULL + * + * "response" is an array of RIL_HardwareConfig. + * + * Valid errors: + * RADIO_NOT_AVAILABLE + * REQUEST_NOT_SUPPORTED + */ +#define RIL_REQUEST_GET_HARDWARE_CONFIG 124 + +/** + * RIL_REQUEST_SIM_AUTHENTICATION + * + * Returns the response of SIM Authentication through RIL to a + * challenge request. + * + * "data" Base64 encoded string containing challenge: + * int authContext; P2 value of authentication command, see P2 parameter in + * 3GPP TS 31.102 7.1.2 + * char *authData; the challenge string in Base64 format, see 3GPP + * TS 31.102 7.1.2 + * char *aid; AID value, See ETSI 102.221 8.1 and 101.220 4, + * NULL if no value + * + * "response" Base64 encoded strings containing response: + * int sw1; Status bytes per 3GPP TS 31.102 section 7.3 + * int sw2; + * char *simResponse; Response in Base64 format, see 3GPP TS 31.102 7.1.2 + * + * Valid errors: + * RADIO_NOT_AVAILABLE + * INTERNAL_ERR + * NO_MEMORY + * NO_RESOURCES + * CANCELLED + * INVALID_MODEM_STATE + * INVALID_ARGUMENTS + * SIM_ERR + * REQUEST_NOT_SUPPORTED + */ +#define RIL_REQUEST_SIM_AUTHENTICATION 125 + +/** + * RIL_REQUEST_GET_DC_RT_INFO + * + * The request is DEPRECATED, use RIL_REQUEST_GET_ACTIVITY_INFO + * Requests the Data Connection Real Time Info + * + * "data" is NULL + * + * "response" is the most recent RIL_DcRtInfo + * + * Valid errors: + * SUCCESS + * RADIO_NOT_AVAILABLE + * REQUEST_NOT_SUPPORTED + * INTERNAL_ERR + * NO_MEMORY + * NO_RESOURCES + * CANCELLED + * + * See also: RIL_UNSOL_DC_RT_INFO_CHANGED + */ +#define RIL_REQUEST_GET_DC_RT_INFO 126 + +/** + * RIL_REQUEST_SET_DC_RT_INFO_RATE + * + * The request is DEPRECATED + * This is the minimum number of milliseconds between successive + * RIL_UNSOL_DC_RT_INFO_CHANGED messages and defines the highest rate + * at which RIL_UNSOL_DC_RT_INFO_CHANGED's will be sent. A value of + * 0 means send as fast as possible. + * + * "data" The number of milliseconds as an int + * + * "response" is null + * + * Valid errors: + * SUCCESS must not fail + */ +#define RIL_REQUEST_SET_DC_RT_INFO_RATE 127 + +/** + * RIL_REQUEST_SET_DATA_PROFILE + * + * Set data profile in modem + * Modem should erase existed profiles from framework, and apply new profiles + * "data" is a const RIL_DataProfileInfo ** + * "datalen" is count * sizeof(const RIL_DataProfileInfo *) + * "response" is NULL + * + * Valid errors: + * SUCCESS + * RADIO_NOT_AVAILABLE (radio resetting) + * SUBSCRIPTION_NOT_AVAILABLE + * INTERNAL_ERR + * NO_MEMORY + * NO_RESOURCES + * CANCELLED + * REQUEST_NOT_SUPPORTED + * SIM_ABSENT + */ +#define RIL_REQUEST_SET_DATA_PROFILE 128 + +/** + * RIL_REQUEST_SHUTDOWN + * + * Device is shutting down. All further commands are ignored + * and RADIO_NOT_AVAILABLE must be returned. + * + * "data" is null + * "response" is NULL + * + * Valid errors: + * SUCCESS + * RADIO_NOT_AVAILABLE + * OPERATION_NOT_ALLOWED + * NO_MEMORY + * INTERNAL_ERR + * SYSTEM_ERR + * REQUEST_NOT_SUPPORTED + * NO_RESOURCES + * CANCELLED + */ +#define RIL_REQUEST_SHUTDOWN 129 + +/** + * RIL_REQUEST_GET_RADIO_CAPABILITY + * + * Used to get phone radio capablility. + * + * "data" is the RIL_RadioCapability structure + * + * Valid errors: + * SUCCESS + * RADIO_NOT_AVAILABLE + * OPERATION_NOT_ALLOWED + * INVALID_STATE + * REQUEST_NOT_SUPPORTED + * INTERNAL_ERR + * NO_MEMORY + * NO_RESOURCES + * CANCELLED + */ +#define RIL_REQUEST_GET_RADIO_CAPABILITY 130 + +/** + * RIL_REQUEST_SET_RADIO_CAPABILITY + * + * Used to set the phones radio capability. Be VERY careful + * using this request as it may cause some vendor modems to reset. Because + * of the possible modem reset any RIL commands after this one may not be + * processed. + * + * "data" is the RIL_RadioCapability structure + * + * "response" is the RIL_RadioCapability structure, used to feedback return status + * + * Valid errors: + * SUCCESS means a RIL_UNSOL_RADIO_CAPABILITY will be sent within 30 seconds. + * RADIO_NOT_AVAILABLE + * OPERATION_NOT_ALLOWED + * NO_MEMORY + * INTERNAL_ERR + * SYSTEM_ERR + * INVALID_ARGUMENTS + * MODEM_ERR + * INVALID_STATE + * REQUEST_NOT_SUPPORTED + * NO_RESOURCES + * CANCELLED + */ +#define RIL_REQUEST_SET_RADIO_CAPABILITY 131 + +/** + * RIL_REQUEST_START_LCE + * + * Start Link Capacity Estimate (LCE) service if supported by the radio. + * + * "data" is const int * + * ((const int*)data)[0] specifies the desired reporting interval (ms). + * ((const int*)data)[1] specifies the LCE service mode. 1: PULL; 0: PUSH. + * + * "response" is the RIL_LceStatusInfo. + * + * Valid errors: + * SUCCESS + * RADIO_NOT_AVAILABLE + * LCE_NOT_SUPPORTED + * INTERNAL_ERR + * REQUEST_NOT_SUPPORTED + * NO_MEMORY + * NO_RESOURCES + * CANCELLED + * SIM_ABSENT + */ +#define RIL_REQUEST_START_LCE 132 + +/** + * RIL_REQUEST_STOP_LCE + * + * Stop Link Capacity Estimate (LCE) service, the STOP operation should be + * idempotent for the radio modem. + * + * "response" is the RIL_LceStatusInfo. + * + * Valid errors: + * SUCCESS + * RADIO_NOT_AVAILABLE + * LCE_NOT_SUPPORTED + * INTERNAL_ERR + * NO_MEMORY + * NO_RESOURCES + * CANCELLED + * REQUEST_NOT_SUPPORTED + * SIM_ABSENT + */ +#define RIL_REQUEST_STOP_LCE 133 + +/** + * RIL_REQUEST_PULL_LCEDATA + * + * Pull LCE service for capacity information. + * + * "response" is the RIL_LceDataInfo. + * + * Valid errors: + * SUCCESS + * RADIO_NOT_AVAILABLE + * LCE_NOT_SUPPORTED + * INTERNAL_ERR + * NO_MEMORY + * NO_RESOURCES + * CANCELLED + * REQUEST_NOT_SUPPORTED + * SIM_ABSENT + */ +#define RIL_REQUEST_PULL_LCEDATA 134 + +/** + * RIL_REQUEST_GET_ACTIVITY_INFO + * + * Get modem activity information for power consumption estimation. + * + * Request clear-on-read statistics information that is used for + * estimating the per-millisecond power consumption of the cellular + * modem. + * + * "data" is null + * "response" is const RIL_ActivityStatsInfo * + * + * Valid errors: + * + * SUCCESS + * RADIO_NOT_AVAILABLE (radio resetting) + * NO_MEMORY + * INTERNAL_ERR + * SYSTEM_ERR + * MODEM_ERR + * NOT_PROVISIONED + * REQUEST_NOT_SUPPORTED + * NO_RESOURCES CANCELLED + */ +#define RIL_REQUEST_GET_ACTIVITY_INFO 135 + +/** + * RIL_REQUEST_SET_CARRIER_RESTRICTIONS + * + * Set carrier restrictions for this sim slot. Expected modem behavior: + * If never receives this command + * - Must allow all carriers + * Receives this command with data being NULL + * - Must allow all carriers. If a previously allowed SIM is present, modem must not reload + * the SIM. If a previously disallowed SIM is present, reload the SIM and notify Android. + * Receives this command with a list of carriers + * - Only allow specified carriers, persist across power cycles and FDR. If a present SIM + * is in the allowed list, modem must not reload the SIM. If a present SIM is *not* in + * the allowed list, modem must detach from the registered network and only keep emergency + * service, and notify Android SIM refresh reset with new SIM state being + * RIL_CARDSTATE_RESTRICTED. Emergency service must be enabled. + * + * "data" is const RIL_CarrierRestrictions * + * A list of allowed carriers and possibly a list of excluded carriers. + * If data is NULL, means to clear previous carrier restrictions and allow all carriers + * + * "response" is int * + * ((int *)data)[0] contains the number of allowed carriers which have been set correctly. + * On success, it should match the length of list data->allowed_carriers. + * If data is NULL, the value must be 0. + * + * Valid errors: + * RIL_E_SUCCESS + * RIL_E_INVALID_ARGUMENTS + * RIL_E_RADIO_NOT_AVAILABLE + * RIL_E_REQUEST_NOT_SUPPORTED + * INTERNAL_ERR + * NO_MEMORY + * NO_RESOURCES + * CANCELLED + */ +#define RIL_REQUEST_SET_CARRIER_RESTRICTIONS 136 + +/** + * RIL_REQUEST_GET_CARRIER_RESTRICTIONS + * + * Get carrier restrictions for this sim slot. Expected modem behavior: + * Return list of allowed carriers, or null if all carriers are allowed. + * + * "data" is NULL + * + * "response" is const RIL_CarrierRestrictions *. + * If response is NULL, it means all carriers are allowed. + * + * Valid errors: + * RIL_E_SUCCESS + * RIL_E_RADIO_NOT_AVAILABLE + * RIL_E_REQUEST_NOT_SUPPORTED + * INTERNAL_ERR + * NO_MEMORY + * NO_RESOURCES + * CANCELLED + */ +#define RIL_REQUEST_GET_CARRIER_RESTRICTIONS 137 + +/** + * RIL_REQUEST_SEND_DEVICE_STATE + * + * Send the updated device state. + * Modem can perform power saving based on the provided device state. + * "data" is const int * + * ((const int*)data)[0] A RIL_DeviceStateType that specifies the device state type. + * ((const int*)data)[1] Specifies the state. See RIL_DeviceStateType for the definition of each + * type. + * + * "datalen" is count * sizeof(const RIL_DeviceState *) + * "response" is NULL + * + * Valid errors: + * SUCCESS + * RADIO_NOT_AVAILABLE (radio resetting) + * NO_MEMORY + * INTERNAL_ERR + * SYSTEM_ERR + * INVALID_ARGUMENTS + * REQUEST_NOT_SUPPORTED + * NO_RESOURCES + * CANCELLED + */ +#define RIL_REQUEST_SEND_DEVICE_STATE 138 + +/** + * RIL_REQUEST_SET_UNSOLICITED_RESPONSE_FILTER + * + * Set the unsolicited response filter + * This is used to prevent unnecessary application processor + * wake up for power saving purposes by suppressing the + * unsolicited responses in certain scenarios. + * + * "data" is an int * + * + * ((int *)data)[0] is a 32-bit bitmask of RIL_UnsolicitedResponseFilter + * + * "response" is NULL + * + * Valid errors: + * SUCCESS + * INVALID_ARGUMENTS (e.g. the requested filter doesn't exist) + * RADIO_NOT_AVAILABLE (radio resetting) + * NO_MEMORY + * INTERNAL_ERR + * SYSTEM_ERR + * REQUEST_NOT_SUPPORTED + * NO_RESOURCES + * CANCELLED + */ +#define RIL_REQUEST_SET_UNSOLICITED_RESPONSE_FILTER 139 + + /** + * RIL_REQUEST_SET_SIM_CARD_POWER + * + * Set SIM card power up or down + * + * Request is equivalent to inserting and removing the card, with + * an additional effect where the ability to detect card removal/insertion + * is disabled when the SIM card is powered down. + * + * This will generate RIL_UNSOL_RESPONSE_SIM_STATUS_CHANGED + * as if the SIM had been inserted or removed. + * + * "data" is int * + * ((int *)data)[0] is 1 for "SIM POWER UP" + * ((int *)data)[0] is 0 for "SIM POWER DOWN" + * + * "response" is NULL + * + * Valid errors: + * SUCCESS + * RADIO_NOT_AVAILABLE + * REQUEST_NOT_SUPPORTED + * SIM_ABSENT + * INVALID_ARGUMENTS + * INTERNAL_ERR + * NO_MEMORY + * NO_RESOURCES + * CANCELLED + */ +#define RIL_REQUEST_SET_SIM_CARD_POWER 140 + +/** + * RIL_REQUEST_SET_CARRIER_INFO_IMSI_ENCRYPTION + * + * Provide Carrier specific information to the modem that will be used to + * encrypt the IMSI and IMPI. Sent by the framework during boot, carrier + * switch and everytime we receive a new certificate. + * + * "data" is the RIL_CarrierInfoForImsiEncryption * structure. + * + * "response" is NULL + * + * Valid errors: + * RIL_E_SUCCESS + * RIL_E_RADIO_NOT_AVAILABLE + * SIM_ABSENT + * RIL_E_REQUEST_NOT_SUPPORTED + * INVALID_ARGUMENTS + * MODEM_INTERNAL_FAILURE + * INTERNAL_ERR + * NO_MEMORY + * NO_RESOURCES + * CANCELLED + */ +#define RIL_REQUEST_SET_CARRIER_INFO_IMSI_ENCRYPTION 141 + +/** + * RIL_REQUEST_START_NETWORK_SCAN + * + * Starts a new network scan + * + * Request to start a network scan with specified radio access networks with frequency bands and/or + * channels. + * + * "data" is a const RIL_NetworkScanRequest *. + * "response" is NULL + * + * Valid errors: + * SUCCESS + * RADIO_NOT_AVAILABLE + * OPERATION_NOT_ALLOWED + * DEVICE_IN_USE + * INTERNAL_ERR + * NO_MEMORY + * MODEM_ERR + * INVALID_ARGUMENTS + * REQUEST_NOT_SUPPORTED + * NO_RESOURCES + * CANCELLED + * + */ +#define RIL_REQUEST_START_NETWORK_SCAN 142 + +/** + * RIL_REQUEST_STOP_NETWORK_SCAN + * + * Stops an ongoing network scan + * + * Request to stop the ongoing network scan. Since the modem can only perform one scan at a time, + * there is no parameter for this request. + * + * "data" is NULL + * "response" is NULL + * + * Valid errors: + * SUCCESS + * INTERNAL_ERR + * MODEM_ERR + * NO_MEMORY + * NO_RESOURCES + * CANCELLED + * REQUEST_NOT_SUPPORTED + * + */ +#define RIL_REQUEST_STOP_NETWORK_SCAN 143 + +/** + * RIL_REQUEST_START_KEEPALIVE + * + * Start a keepalive session + * + * Request that the modem begin sending keepalive packets on a particular + * data call, with a specified source, destination, and format. + * + * "data" is a const RIL_RequestKeepalive + * "response" is RIL_KeepaliveStatus with a valid "handle" + * + * Valid errors: + * SUCCESS + * NO_RESOURCES + * INVALID_ARGUMENTS + * + */ +#define RIL_REQUEST_START_KEEPALIVE 144 + +/** + * RIL_REQUEST_STOP_KEEPALIVE + * + * Stops an ongoing keepalive session + * + * Requests that a keepalive session with the given handle be stopped. + * there is no parameter for this request. + * + * "data" is an integer handle + * "response" is NULL + * + * Valid errors: + * SUCCESS + * INVALID_ARGUMENTS + * + */ +#define RIL_REQUEST_STOP_KEEPALIVE 145 + +/***********************************************************************/ + +/** + * RIL_RESPONSE_ACKNOWLEDGEMENT + * + * This is used by Asynchronous solicited messages and Unsolicited messages + * to acknowledge the receipt of those messages in RIL.java so that the ack + * can be used to let ril.cpp to release wakelock. + * + * Valid errors + * SUCCESS + * RADIO_NOT_AVAILABLE + */ + +#define RIL_RESPONSE_ACKNOWLEDGEMENT 800 + +/***********************************************************************/ + + +#define RIL_UNSOL_RESPONSE_BASE 1000 + +/** + * RIL_UNSOL_RESPONSE_RADIO_STATE_CHANGED + * + * Indicate when value of RIL_RadioState has changed. + * + * Callee will invoke RIL_RadioStateRequest method on main thread + * + * "data" is NULL + */ + +#define RIL_UNSOL_RESPONSE_RADIO_STATE_CHANGED 1000 + + +/** + * RIL_UNSOL_RESPONSE_CALL_STATE_CHANGED + * + * Indicate when call state has changed + * + * Callee will invoke RIL_REQUEST_GET_CURRENT_CALLS on main thread + * + * "data" is NULL + * + * Response should be invoked on, for example, + * "RING", "BUSY", "NO CARRIER", and also call state + * transitions (DIALING->ALERTING ALERTING->ACTIVE) + * + * Redundent or extraneous invocations are tolerated + */ +#define RIL_UNSOL_RESPONSE_CALL_STATE_CHANGED 1001 + + +/** + * RIL_UNSOL_RESPONSE_VOICE_NETWORK_STATE_CHANGED + * + * Called when the voice network state changed + * + * Callee will invoke the following requests on main thread: + * + * RIL_REQUEST_VOICE_REGISTRATION_STATE + * RIL_REQUEST_OPERATOR + * + * "data" is NULL + * + * FIXME should this happen when SIM records are loaded? (eg, for + * EONS) + */ +#define RIL_UNSOL_RESPONSE_VOICE_NETWORK_STATE_CHANGED 1002 + +/** + * RIL_UNSOL_RESPONSE_NEW_SMS + * + * Called when new SMS is received. + * + * "data" is const char * + * This is a pointer to a string containing the PDU of an SMS-DELIVER + * as an ascii string of hex digits. The PDU starts with the SMSC address + * per TS 27.005 (+CMT:) + * + * Callee will subsequently confirm the receipt of thei SMS with a + * RIL_REQUEST_SMS_ACKNOWLEDGE + * + * No new RIL_UNSOL_RESPONSE_NEW_SMS + * or RIL_UNSOL_RESPONSE_NEW_SMS_STATUS_REPORT messages should be sent until a + * RIL_REQUEST_SMS_ACKNOWLEDGE has been received + */ + +#define RIL_UNSOL_RESPONSE_NEW_SMS 1003 + +/** + * RIL_UNSOL_RESPONSE_NEW_SMS_STATUS_REPORT + * + * Called when new SMS Status Report is received. + * + * "data" is const char * + * This is a pointer to a string containing the PDU of an SMS-STATUS-REPORT + * as an ascii string of hex digits. The PDU starts with the SMSC address + * per TS 27.005 (+CDS:). + * + * Callee will subsequently confirm the receipt of the SMS with a + * RIL_REQUEST_SMS_ACKNOWLEDGE + * + * No new RIL_UNSOL_RESPONSE_NEW_SMS + * or RIL_UNSOL_RESPONSE_NEW_SMS_STATUS_REPORT messages should be sent until a + * RIL_REQUEST_SMS_ACKNOWLEDGE has been received + */ + +#define RIL_UNSOL_RESPONSE_NEW_SMS_STATUS_REPORT 1004 + +/** + * RIL_UNSOL_RESPONSE_NEW_SMS_ON_SIM + * + * Called when new SMS has been stored on SIM card + * + * "data" is const int * + * ((const int *)data)[0] contains the slot index on the SIM that contains + * the new message + */ + +#define RIL_UNSOL_RESPONSE_NEW_SMS_ON_SIM 1005 + +/** + * RIL_UNSOL_ON_USSD + * + * Called when a new USSD message is received. + * + * "data" is const char ** + * ((const char **)data)[0] points to a type code, which is + * one of these string values: + * "0" USSD-Notify -- text in ((const char **)data)[1] + * "1" USSD-Request -- text in ((const char **)data)[1] + * "2" Session terminated by network + * "3" other local client (eg, SIM Toolkit) has responded + * "4" Operation not supported + * "5" Network timeout + * + * The USSD session is assumed to persist if the type code is "1", otherwise + * the current session (if any) is assumed to have terminated. + * + * ((const char **)data)[1] points to a message string if applicable, which + * should always be in UTF-8. + */ +#define RIL_UNSOL_ON_USSD 1006 +/* Previously #define RIL_UNSOL_ON_USSD_NOTIFY 1006 */ + +/** + * RIL_UNSOL_ON_USSD_REQUEST + * + * Obsolete. Send via RIL_UNSOL_ON_USSD + */ +#define RIL_UNSOL_ON_USSD_REQUEST 1007 + +/** + * RIL_UNSOL_NITZ_TIME_RECEIVED + * + * Called when radio has received a NITZ time message + * + * "data" is const char * pointing to NITZ time string + * in the form "yy/mm/dd,hh:mm:ss(+/-)tz,dt" + */ +#define RIL_UNSOL_NITZ_TIME_RECEIVED 1008 + +/** + * RIL_UNSOL_SIGNAL_STRENGTH + * + * Radio may report signal strength rather han have it polled. + * + * "data" is a const RIL_SignalStrength * + */ +#define RIL_UNSOL_SIGNAL_STRENGTH 1009 + + +/** + * RIL_UNSOL_DATA_CALL_LIST_CHANGED + * + * "data" is an array of RIL_Data_Call_Response_v6 identical to that + * returned by RIL_REQUEST_DATA_CALL_LIST. It is the complete list + * of current data contexts including new contexts that have been + * activated. A data call is only removed from this list when the + * framework sends a RIL_REQUEST_DEACTIVATE_DATA_CALL or the radio + * is powered off/on. + * + * See also: RIL_REQUEST_DATA_CALL_LIST + */ + +#define RIL_UNSOL_DATA_CALL_LIST_CHANGED 1010 + +/** + * RIL_UNSOL_SUPP_SVC_NOTIFICATION + * + * Reports supplementary service related notification from the network. + * + * "data" is a const RIL_SuppSvcNotification * + * + */ + +#define RIL_UNSOL_SUPP_SVC_NOTIFICATION 1011 + +/** + * RIL_UNSOL_STK_SESSION_END + * + * Indicate when STK session is terminated by SIM. + * + * "data" is NULL + */ +#define RIL_UNSOL_STK_SESSION_END 1012 + +/** + * RIL_UNSOL_STK_PROACTIVE_COMMAND + * + * Indicate when SIM issue a STK proactive command to applications + * + * "data" is a const char * containing SAT/USAT proactive command + * in hexadecimal format string starting with command tag + * + */ +#define RIL_UNSOL_STK_PROACTIVE_COMMAND 1013 + +/** + * RIL_UNSOL_STK_EVENT_NOTIFY + * + * Indicate when SIM notifies applcations some event happens. + * Generally, application does not need to have any feedback to + * SIM but shall be able to indicate appropriate messages to users. + * + * "data" is a const char * containing SAT/USAT commands or responses + * sent by ME to SIM or commands handled by ME, in hexadecimal format string + * starting with first byte of response data or command tag + * + */ +#define RIL_UNSOL_STK_EVENT_NOTIFY 1014 + +/** + * RIL_UNSOL_STK_CALL_SETUP + * + * Indicate when SIM wants application to setup a voice call. + * + * "data" is const int * + * ((const int *)data)[0] contains timeout value (in milliseconds) + */ +#define RIL_UNSOL_STK_CALL_SETUP 1015 + +/** + * RIL_UNSOL_SIM_SMS_STORAGE_FULL + * + * Indicates that SMS storage on the SIM is full. Sent when the network + * attempts to deliver a new SMS message. Messages cannot be saved on the + * SIM until space is freed. In particular, incoming Class 2 messages + * cannot be stored. + * + * "data" is null + * + */ +#define RIL_UNSOL_SIM_SMS_STORAGE_FULL 1016 + +/** + * RIL_UNSOL_SIM_REFRESH + * + * Indicates that file(s) on the SIM have been updated, or the SIM + * has been reinitialized. + * + * In the case where RIL is version 6 or older: + * "data" is an int * + * ((int *)data)[0] is a RIL_SimRefreshResult. + * ((int *)data)[1] is the EFID of the updated file if the result is + * SIM_FILE_UPDATE or NULL for any other result. + * + * In the case where RIL is version 7: + * "data" is a RIL_SimRefreshResponse_v7 * + * + * Note: If the SIM state changes as a result of the SIM refresh (eg, + * SIM_READY -> SIM_LOCKED_OR_ABSENT), RIL_UNSOL_RESPONSE_SIM_STATUS_CHANGED + * should be sent. + */ +#define RIL_UNSOL_SIM_REFRESH 1017 + +/** + * RIL_UNSOL_CALL_RING + * + * Ring indication for an incoming call (eg, RING or CRING event). + * There must be at least one RIL_UNSOL_CALL_RING at the beginning + * of a call and sending multiple is optional. If the system property + * ro.telephony.call_ring.multiple is false then the upper layers + * will generate the multiple events internally. Otherwise the vendor + * ril must generate multiple RIL_UNSOL_CALL_RING if + * ro.telephony.call_ring.multiple is true or if it is absent. + * + * The rate of these events is controlled by ro.telephony.call_ring.delay + * and has a default value of 3000 (3 seconds) if absent. + * + * "data" is null for GSM + * "data" is const RIL_CDMA_SignalInfoRecord * if CDMA + */ +#define RIL_UNSOL_CALL_RING 1018 + +/** + * RIL_UNSOL_RESPONSE_SIM_STATUS_CHANGED + * + * Indicates that SIM state changes. + * + * Callee will invoke RIL_REQUEST_GET_SIM_STATUS on main thread + + * "data" is null + */ +#define RIL_UNSOL_RESPONSE_SIM_STATUS_CHANGED 1019 + +/** + * RIL_UNSOL_RESPONSE_CDMA_NEW_SMS + * + * Called when new CDMA SMS is received + * + * "data" is const RIL_CDMA_SMS_Message * + * + * Callee will subsequently confirm the receipt of the SMS with + * a RIL_REQUEST_CDMA_SMS_ACKNOWLEDGE + * + * No new RIL_UNSOL_RESPONSE_CDMA_NEW_SMS should be sent until + * RIL_REQUEST_CDMA_SMS_ACKNOWLEDGE has been received + * + */ +#define RIL_UNSOL_RESPONSE_CDMA_NEW_SMS 1020 + +/** + * RIL_UNSOL_RESPONSE_NEW_BROADCAST_SMS + * + * Called when new Broadcast SMS is received + * + * "data" can be one of the following: + * If received from GSM network, "data" is const char of 88 bytes + * which indicates each page of a CBS Message sent to the MS by the + * BTS as coded in 3GPP 23.041 Section 9.4.1.2. + * If received from UMTS network, "data" is const char of 90 up to 1252 + * bytes which contain between 1 and 15 CBS Message pages sent as one + * packet to the MS by the BTS as coded in 3GPP 23.041 Section 9.4.2.2. + * + */ +#define RIL_UNSOL_RESPONSE_NEW_BROADCAST_SMS 1021 + +/** + * RIL_UNSOL_CDMA_RUIM_SMS_STORAGE_FULL + * + * Indicates that SMS storage on the RUIM is full. Messages + * cannot be saved on the RUIM until space is freed. + * + * "data" is null + * + */ +#define RIL_UNSOL_CDMA_RUIM_SMS_STORAGE_FULL 1022 + +/** + * RIL_UNSOL_RESTRICTED_STATE_CHANGED + * + * Indicates a restricted state change (eg, for Domain Specific Access Control). + * + * Radio need send this msg after radio off/on cycle no matter it is changed or not. + * + * "data" is an int * + * ((int *)data)[0] contains a bitmask of RIL_RESTRICTED_STATE_* values. + */ +#define RIL_UNSOL_RESTRICTED_STATE_CHANGED 1023 + +/** + * RIL_UNSOL_ENTER_EMERGENCY_CALLBACK_MODE + * + * Indicates that the radio system selection module has + * autonomously entered emergency callback mode. + * + * "data" is null + * + */ +#define RIL_UNSOL_ENTER_EMERGENCY_CALLBACK_MODE 1024 + +/** + * RIL_UNSOL_CDMA_CALL_WAITING + * + * Called when CDMA radio receives a call waiting indication. + * + * "data" is const RIL_CDMA_CallWaiting * + * + */ +#define RIL_UNSOL_CDMA_CALL_WAITING 1025 + +/** + * RIL_UNSOL_CDMA_OTA_PROVISION_STATUS + * + * Called when CDMA radio receives an update of the progress of an + * OTASP/OTAPA call. + * + * "data" is const int * + * For CDMA this is an integer OTASP/OTAPA status listed in + * RIL_CDMA_OTA_ProvisionStatus. + * + */ +#define RIL_UNSOL_CDMA_OTA_PROVISION_STATUS 1026 + +/** + * RIL_UNSOL_CDMA_INFO_REC + * + * Called when CDMA radio receives one or more info recs. + * + * "data" is const RIL_CDMA_InformationRecords * + * + */ +#define RIL_UNSOL_CDMA_INFO_REC 1027 + +/** + * RIL_UNSOL_OEM_HOOK_RAW + * + * This is for OEM specific use. + * + * "data" is a byte[] + */ +#define RIL_UNSOL_OEM_HOOK_RAW 1028 + +/** + * RIL_UNSOL_RINGBACK_TONE + * + * Indicates that nework doesn't have in-band information, need to + * play out-band tone. + * + * "data" is an int * + * ((int *)data)[0] == 0 for stop play ringback tone. + * ((int *)data)[0] == 1 for start play ringback tone. + */ +#define RIL_UNSOL_RINGBACK_TONE 1029 + +/** + * RIL_UNSOL_RESEND_INCALL_MUTE + * + * Indicates that framework/application need reset the uplink mute state. + * + * There may be situations where the mute state becomes out of sync + * between the application and device in some GSM infrastructures. + * + * "data" is null + */ +#define RIL_UNSOL_RESEND_INCALL_MUTE 1030 + +/** + * RIL_UNSOL_CDMA_SUBSCRIPTION_SOURCE_CHANGED + * + * Called when CDMA subscription source changed. + * + * "data" is int * + * ((int *)data)[0] is == RIL_CdmaSubscriptionSource + */ +#define RIL_UNSOL_CDMA_SUBSCRIPTION_SOURCE_CHANGED 1031 + +/** + * RIL_UNSOL_CDMA_PRL_CHANGED + * + * Called when PRL (preferred roaming list) changes. + * + * "data" is int * + * ((int *)data)[0] is PRL_VERSION as would be returned by RIL_REQUEST_CDMA_SUBSCRIPTION + */ +#define RIL_UNSOL_CDMA_PRL_CHANGED 1032 + +/** + * RIL_UNSOL_EXIT_EMERGENCY_CALLBACK_MODE + * + * Called when Emergency Callback Mode Ends + * + * Indicates that the radio system selection module has + * proactively exited emergency callback mode. + * + * "data" is NULL + * + */ +#define RIL_UNSOL_EXIT_EMERGENCY_CALLBACK_MODE 1033 + +/** + * RIL_UNSOL_RIL_CONNECTED + * + * Called the ril connects and returns the version + * + * "data" is int * + * ((int *)data)[0] is RIL_VERSION + */ +#define RIL_UNSOL_RIL_CONNECTED 1034 + +/** + * RIL_UNSOL_VOICE_RADIO_TECH_CHANGED + * + * Indicates that voice technology has changed. Contains new radio technology + * as a data in the message. + * + * "data" is int * + * ((int *)data)[0] is of type const RIL_RadioTechnology + * + */ +#define RIL_UNSOL_VOICE_RADIO_TECH_CHANGED 1035 + +/** + * RIL_UNSOL_CELL_INFO_LIST + * + * Same information as returned by RIL_REQUEST_GET_CELL_INFO_LIST, but returned + * at the rate no greater than specified by RIL_REQUEST_SET_UNSOL_CELL_INFO_RATE. + * + * "data" is NULL + * + * "response" is an array of RIL_CellInfo_v12. + */ +#define RIL_UNSOL_CELL_INFO_LIST 1036 + +/** + * RIL_UNSOL_RESPONSE_IMS_NETWORK_STATE_CHANGED + * + * This message is DEPRECATED and shall be removed in a future release (target: 2018); + * instead, provide IMS registration status via an IMS Service. + * + * Called when IMS registration state has changed + * + * To get IMS registration state and IMS SMS format, callee needs to invoke the + * following request on main thread: + * + * RIL_REQUEST_IMS_REGISTRATION_STATE + * + * "data" is NULL + * + */ +#define RIL_UNSOL_RESPONSE_IMS_NETWORK_STATE_CHANGED 1037 + +/** + * RIL_UNSOL_UICC_SUBSCRIPTION_STATUS_CHANGED + * + * Indicated when there is a change in subscription status. + * This event will be sent in the following scenarios + * - subscription readiness at modem, which was selected by telephony layer + * - when subscription is deactivated by modem due to UICC card removal + * - When network invalidates the subscription i.e. attach reject due to authentication reject + * + * "data" is const int * + * ((const int *)data)[0] == 0 for Subscription Deactivated + * ((const int *)data)[0] == 1 for Subscription Activated + * + */ +#define RIL_UNSOL_UICC_SUBSCRIPTION_STATUS_CHANGED 1038 + +/** + * RIL_UNSOL_SRVCC_STATE_NOTIFY + * + * Called when Single Radio Voice Call Continuity(SRVCC) + * progress state has changed + * + * "data" is int * + * ((int *)data)[0] is of type const RIL_SrvccState + * + */ + +#define RIL_UNSOL_SRVCC_STATE_NOTIFY 1039 + +/** + * RIL_UNSOL_HARDWARE_CONFIG_CHANGED + * + * Called when the hardware configuration associated with the RILd changes + * + * "data" is an array of RIL_HardwareConfig + * + */ +#define RIL_UNSOL_HARDWARE_CONFIG_CHANGED 1040 + +/** + * RIL_UNSOL_DC_RT_INFO_CHANGED + * + * The message is DEPRECATED, use RIL_REQUEST_GET_ACTIVITY_INFO + * Sent when the DC_RT_STATE changes but the time + * between these messages must not be less than the + * value set by RIL_REQUEST_SET_DC_RT_RATE. + * + * "data" is the most recent RIL_DcRtInfo + * + */ +#define RIL_UNSOL_DC_RT_INFO_CHANGED 1041 + +/** + * RIL_UNSOL_RADIO_CAPABILITY + * + * Sent when RIL_REQUEST_SET_RADIO_CAPABILITY completes. + * Returns the phone radio capability exactly as + * RIL_REQUEST_GET_RADIO_CAPABILITY and should be the + * same set as sent by RIL_REQUEST_SET_RADIO_CAPABILITY. + * + * "data" is the RIL_RadioCapability structure + */ +#define RIL_UNSOL_RADIO_CAPABILITY 1042 + +/* + * RIL_UNSOL_ON_SS + * + * Called when SS response is received when DIAL/USSD/SS is changed to SS by + * call control. + * + * "data" is const RIL_StkCcUnsolSsResponse * + * + */ +#define RIL_UNSOL_ON_SS 1043 + +/** + * RIL_UNSOL_STK_CC_ALPHA_NOTIFY + * + * Called when there is an ALPHA from UICC during Call Control. + * + * "data" is const char * containing ALPHA string from UICC in UTF-8 format. + * + */ +#define RIL_UNSOL_STK_CC_ALPHA_NOTIFY 1044 + +/** + * RIL_UNSOL_LCEDATA_RECV + * + * Called when there is an incoming Link Capacity Estimate (LCE) info report. + * + * "data" is the RIL_LceDataInfo structure. + * + */ +#define RIL_UNSOL_LCEDATA_RECV 1045 + + /** + * RIL_UNSOL_PCO_DATA + * + * Called when there is new Carrier PCO data received for a data call. Ideally + * only new data will be forwarded, though this is not required. Multiple + * boxes of carrier PCO data for a given call should result in a series of + * RIL_UNSOL_PCO_DATA calls. + * + * "data" is the RIL_PCO_Data structure. + * + */ +#define RIL_UNSOL_PCO_DATA 1046 + + /** + * RIL_UNSOL_MODEM_RESTART + * + * Called when there is a modem reset. + * + * "reason" is "const char *" containing the reason for the reset. It + * could be a crash signature if the restart was due to a crash or some + * string such as "user-initiated restart" or "AT command initiated + * restart" that explains the cause of the modem restart. + * + * When modem restarts, one of the following radio state transitions will happen + * 1) RADIO_STATE_ON->RADIO_STATE_UNAVAILABLE->RADIO_STATE_ON or + * 2) RADIO_STATE_OFF->RADIO_STATE_UNAVAILABLE->RADIO_STATE_OFF + * This message can be sent either just before the RADIO_STATE changes to RADIO_STATE_UNAVAILABLE + * or just after but should never be sent after the RADIO_STATE changes from UNAVAILABLE to + * AVAILABLE(RADIO_STATE_ON/RADIO_STATE_OFF) again. + * + * It should NOT be sent after the RADIO_STATE changes to AVAILABLE after the + * modem restart as that could be interpreted as a second modem reset by the + * framework. + */ +#define RIL_UNSOL_MODEM_RESTART 1047 + +/** + * RIL_UNSOL_CARRIER_INFO_IMSI_ENCRYPTION + * + * Called when the modem needs Carrier specific information that will + * be used to encrypt IMSI and IMPI. + * + * "data" is NULL + * + */ +#define RIL_UNSOL_CARRIER_INFO_IMSI_ENCRYPTION 1048 + +/** + * RIL_UNSOL_NETWORK_SCAN_RESULT + * + * Returns incremental result for the network scan which is started by + * RIL_REQUEST_START_NETWORK_SCAN, sent to report results, status, or errors. + * + * "data" is NULL + * "response" is a const RIL_NetworkScanResult * + */ +#define RIL_UNSOL_NETWORK_SCAN_RESULT 1049 + +/** + * RIL_UNSOL_KEEPALIVE_STATUS + * + * "data" is NULL + * "response" is a const RIL_KeepaliveStatus * + */ +#define RIL_UNSOL_KEEPALIVE_STATUS 1050 + +/***********************************************************************/ + + +#if defined(ANDROID_MULTI_SIM) +/** + * RIL_Request Function pointer + * + * @param request is one of RIL_REQUEST_* + * @param data is pointer to data defined for that RIL_REQUEST_* + * data is owned by caller, and should not be modified or freed by callee + * structures passed as data may contain pointers to non-contiguous memory + * @param t should be used in subsequent call to RIL_onResponse + * @param datalen is the length of "data" which is defined as other argument. It may or may + * not be equal to sizeof(data). Refer to the documentation of individual structures + * to find if pointers listed in the structure are contiguous and counted in the datalen + * length or not. + * (Eg: RIL_IMS_SMS_Message where we don't have datalen equal to sizeof(data)) + * + */ +typedef void (*RIL_RequestFunc) (int request, void *data, + size_t datalen, RIL_Token t, RIL_SOCKET_ID socket_id); + +/** + * This function should return the current radio state synchronously + */ +typedef RIL_RadioState (*RIL_RadioStateRequest)(RIL_SOCKET_ID socket_id); + +#else +/* Backward compatible */ + +/** + * RIL_Request Function pointer + * + * @param request is one of RIL_REQUEST_* + * @param data is pointer to data defined for that RIL_REQUEST_* + * data is owned by caller, and should not be modified or freed by callee + * structures passed as data may contain pointers to non-contiguous memory + * @param t should be used in subsequent call to RIL_onResponse + * @param datalen is the length of "data" which is defined as other argument. It may or may + * not be equal to sizeof(data). Refer to the documentation of individual structures + * to find if pointers listed in the structure are contiguous and counted in the datalen + * length or not. + * (Eg: RIL_IMS_SMS_Message where we don't have datalen equal to sizeof(data)) + * + */ +typedef void (*RIL_RequestFunc) (int request, void *data, + size_t datalen, RIL_Token t); + +/** + * This function should return the current radio state synchronously + */ +typedef RIL_RadioState (*RIL_RadioStateRequest)(); + +#endif + + +/** + * This function returns "1" if the specified RIL_REQUEST code is + * supported and 0 if it is not + * + * @param requestCode is one of RIL_REQUEST codes + */ + +typedef int (*RIL_Supports)(int requestCode); + +/** + * This function is called from a separate thread--not the + * thread that calls RIL_RequestFunc--and indicates that a pending + * request should be cancelled. + * + * On cancel, the callee should do its best to abandon the request and + * call RIL_onRequestComplete with RIL_Errno CANCELLED at some later point. + * + * Subsequent calls to RIL_onRequestComplete for this request with + * other results will be tolerated but ignored. (That is, it is valid + * to ignore the cancellation request) + * + * RIL_Cancel calls should return immediately, and not wait for cancellation + * + * Please see ITU v.250 5.6.1 for how one might implement this on a TS 27.007 + * interface + * + * @param t token wants to be canceled + */ + +typedef void (*RIL_Cancel)(RIL_Token t); + +typedef void (*RIL_TimedCallback) (void *param); + +/** + * Return a version string for your RIL implementation + */ +typedef const char * (*RIL_GetVersion) (void); + +typedef struct { + int version; /* set to RIL_VERSION */ + RIL_RequestFunc onRequest; + RIL_RadioStateRequest onStateRequest; + RIL_Supports supports; + RIL_Cancel onCancel; + RIL_GetVersion getVersion; +} RIL_RadioFunctions; + +typedef struct { + char *apn; /* the APN to connect to */ + char *protocol; /* one of the PDP_type values in TS 27.007 section 10.1.1 used on + roaming network. For example, "IP", "IPV6", "IPV4V6", or "PPP".*/ + int authtype; /* authentication protocol used for this PDP context + (None: 0, PAP: 1, CHAP: 2, PAP&CHAP: 3) */ + char *username; /* the username for APN, or NULL */ + char *password; /* the password for APN, or NULL */ +} RIL_InitialAttachApn; + +typedef struct { + char *apn; /* the APN to connect to */ + char *protocol; /* one of the PDP_type values in TS 27.007 section 10.1.1 used on + home network. For example, "IP", "IPV6", "IPV4V6", or "PPP". */ + char *roamingProtocol; /* one of the PDP_type values in TS 27.007 section 10.1.1 used on + roaming network. For example, "IP", "IPV6", "IPV4V6", or "PPP".*/ + int authtype; /* authentication protocol used for this PDP context + (None: 0, PAP: 1, CHAP: 2, PAP&CHAP: 3) */ + char *username; /* the username for APN, or NULL */ + char *password; /* the password for APN, or NULL */ + int supportedTypesBitmask; /* supported APN types bitmask. See RIL_ApnTypes for the value of + each bit. */ + int bearerBitmask; /* the bearer bitmask. See RIL_RadioAccessFamily for the value of + each bit. */ + int modemCognitive; /* indicating the APN setting was sent to the modem through + setDataProfile earlier. */ + int mtu; /* maximum transmission unit (MTU) size in bytes */ + char *mvnoType; /* the MVNO type: possible values are "imsi", "gid", "spn" */ + char *mvnoMatchData; /* MVNO match data. Can be anything defined by the carrier. + For example, + SPN like: "A MOBILE", "BEN NL", etc... + IMSI like: "302720x94", "2060188", etc... + GID like: "4E", "33", etc... */ +} RIL_InitialAttachApn_v15; + +typedef struct { + int authContext; /* P2 value of authentication command, see P2 parameter in + 3GPP TS 31.102 7.1.2 */ + char *authData; /* the challenge string in Base64 format, see 3GPP + TS 31.102 7.1.2 */ + char *aid; /* AID value, See ETSI 102.221 8.1 and 101.220 4, + NULL if no value. */ +} RIL_SimAuthentication; + +typedef struct { + int cid; /* Context ID, uniquely identifies this call */ + char *bearer_proto; /* One of the PDP_type values in TS 27.007 section 10.1.1. + For example, "IP", "IPV6", "IPV4V6". */ + int pco_id; /* The protocol ID for this box. Note that only IDs from + FF00H - FFFFH are accepted. If more than one is included + from the network, multiple calls should be made to send all + of them. */ + int contents_length; /* The number of octets in the contents. */ + char *contents; /* Carrier-defined content. It is binary, opaque and + loosely defined in LTE Layer 3 spec 24.008 */ +} RIL_PCO_Data; + +typedef enum { + NATT_IPV4 = 0, /* Keepalive specified by RFC 3948 Sec. 2.3 using IPv4 */ + NATT_IPV6 = 1 /* Keepalive specified by RFC 3948 Sec. 2.3 using IPv6 */ +} RIL_KeepaliveType; + +#define MAX_INADDR_LEN 16 +typedef struct { + RIL_KeepaliveType type; /* Type of keepalive packet */ + char sourceAddress[MAX_INADDR_LEN]; /* Source address in network-byte order */ + int sourcePort; /* Source port if applicable, or 0x7FFFFFFF; + the maximum value is 65535 */ + char destinationAddress[MAX_INADDR_LEN]; /* Destination address in network-byte order */ + int destinationPort; /* Destination port if applicable or 0x7FFFFFFF; + the maximum value is 65535 */ + int maxKeepaliveIntervalMillis; /* Maximum milliseconds between two packets */ + int cid; /* Context ID, uniquely identifies this call */ +} RIL_KeepaliveRequest; + +typedef enum { + KEEPALIVE_ACTIVE, /* Keepalive session is active */ + KEEPALIVE_INACTIVE, /* Keepalive session is inactive */ + KEEPALIVE_PENDING /* Keepalive session status not available */ +} RIL_KeepaliveStatusCode; + +typedef struct { + uint32_t sessionHandle; + RIL_KeepaliveStatusCode code; +} RIL_KeepaliveStatus; + +#ifdef RIL_SHLIB +struct RIL_Env { + /** + * "t" is parameter passed in on previous call to RIL_Notification + * routine. + * + * If "e" != SUCCESS, then response can be null/is ignored + * + * "response" is owned by caller, and should not be modified or + * freed by callee + * + * RIL_onRequestComplete will return as soon as possible + */ + void (*OnRequestComplete)(RIL_Token t, RIL_Errno e, + void *response, size_t responselen); + +#if defined(ANDROID_MULTI_SIM) + /** + * "unsolResponse" is one of RIL_UNSOL_RESPONSE_* + * "data" is pointer to data defined for that RIL_UNSOL_RESPONSE_* + * + * "data" is owned by caller, and should not be modified or freed by callee + */ + void (*OnUnsolicitedResponse)(int unsolResponse, const void *data, size_t datalen, RIL_SOCKET_ID socket_id); +#else + /** + * "unsolResponse" is one of RIL_UNSOL_RESPONSE_* + * "data" is pointer to data defined for that RIL_UNSOL_RESPONSE_* + * + * "data" is owned by caller, and should not be modified or freed by callee + */ + void (*OnUnsolicitedResponse)(int unsolResponse, const void *data, size_t datalen); +#endif + /** + * Call user-specifed "callback" function on on the same thread that + * RIL_RequestFunc is called. If "relativeTime" is specified, then it specifies + * a relative time value at which the callback is invoked. If relativeTime is + * NULL or points to a 0-filled structure, the callback will be invoked as + * soon as possible + */ + + void (*RequestTimedCallback) (RIL_TimedCallback callback, + void *param, const struct timeval *relativeTime); + /** + * "t" is parameter passed in on previous call RIL_Notification routine + * + * RIL_onRequestAck will be called by vendor when an Async RIL request was received + * by them and an ack needs to be sent back to java ril. + */ + void (*OnRequestAck) (RIL_Token t); +}; + + +/** + * RIL implementations must defined RIL_Init + * argc and argv will be command line arguments intended for the RIL implementation + * Return NULL on error + * + * @param env is environment point defined as RIL_Env + * @param argc number of arguments + * @param argv list fo arguments + * + */ +const RIL_RadioFunctions *RIL_Init(const struct RIL_Env *env, int argc, char **argv); + +/** + * If BT SAP(SIM Access Profile) is supported, then RIL implementations must define RIL_SAP_Init + * for initializing RIL_RadioFunctions used for BT SAP communcations. It is called whenever RILD + * starts or modem restarts. Returns handlers for SAP related request that are made on SAP + * sepecific socket, analogous to the RIL_RadioFunctions returned by the call to RIL_Init + * and used on the general RIL socket. + * argc and argv will be command line arguments intended for the RIL implementation + * Return NULL on error. + * + * @param env is environment point defined as RIL_Env + * @param argc number of arguments + * @param argv list fo arguments + * + */ +const RIL_RadioFunctions *RIL_SAP_Init(const struct RIL_Env *env, int argc, char **argv); + +#else /* RIL_SHLIB */ + +/** + * Call this once at startup to register notification routine + * + * @param callbacks user-specifed callback function + */ +void RIL_register (const RIL_RadioFunctions *callbacks); + +void rilc_thread_pool(); + + +/** + * + * RIL_onRequestComplete will return as soon as possible + * + * @param t is parameter passed in on previous call to RIL_Notification + * routine. + * @param e error code + * if "e" != SUCCESS, then response can be null/is ignored + * @param response is owned by caller, and should not be modified or + * freed by callee + * @param responselen the length of response in byte + */ +void RIL_onRequestComplete(RIL_Token t, RIL_Errno e, + void *response, size_t responselen); + +/** + * RIL_onRequestAck will be called by vendor when an Async RIL request was received by them and + * an ack needs to be sent back to java ril. This doesn't mark the end of the command or it's + * results, just that the command was received and will take a while. After sending this Ack + * its vendor's responsibility to make sure that AP is up whenever needed while command is + * being processed. + * + * @param t is parameter passed in on previous call to RIL_Notification + * routine. + */ +void RIL_onRequestAck(RIL_Token t); + +#if defined(ANDROID_MULTI_SIM) +/** + * @param unsolResponse is one of RIL_UNSOL_RESPONSE_* + * @param data is pointer to data defined for that RIL_UNSOL_RESPONSE_* + * "data" is owned by caller, and should not be modified or freed by callee + * @param datalen the length of data in byte + */ + +void RIL_onUnsolicitedResponse(int unsolResponse, const void *data, + size_t datalen, RIL_SOCKET_ID socket_id); +#else +/** + * @param unsolResponse is one of RIL_UNSOL_RESPONSE_* + * @param data is pointer to data defined for that RIL_UNSOL_RESPONSE_* + * "data" is owned by caller, and should not be modified or freed by callee + * @param datalen the length of data in byte + */ + +void RIL_onUnsolicitedResponse(int unsolResponse, const void *data, + size_t datalen); +#endif + +/** + * Call user-specifed "callback" function on on the same thread that + * RIL_RequestFunc is called. If "relativeTime" is specified, then it specifies + * a relative time value at which the callback is invoked. If relativeTime is + * NULL or points to a 0-filled structure, the callback will be invoked as + * soon as possible + * + * @param callback user-specifed callback function + * @param param parameter list + * @param relativeTime a relative time value at which the callback is invoked + */ + +void RIL_requestTimedCallback (RIL_TimedCallback callback, + void *param, const struct timeval *relativeTime); + +#endif /* RIL_SHLIB */ + +#ifdef __cplusplus +} +#endif + +#endif /*ANDROID_RIL_H*/ diff --git a/radio/include/telephony/ril_cdma_sms.h b/radio/include/telephony/ril_cdma_sms.h new file mode 100644 index 00000000..835bc92a --- /dev/null +++ b/radio/include/telephony/ril_cdma_sms.h @@ -0,0 +1,806 @@ +/* + * Copyright (C) 2006 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. + */ + +/* + * ISSUES: + * + */ + +/** + * TODO + * + * + */ + + +#ifndef ANDROID_RIL_CDMA_SMS_H +#define ANDROID_RIL_CDMA_SMS_H 1 + +#include <stdlib.h> + +#ifdef __cplusplus +extern "C" { +#endif + +/* Used by RIL_REQUEST_CDMA_SEND_SMS and RIL_UNSOL_RESPONSE_CDMA_NEW_SMS */ + +#define RIL_CDMA_SMS_ADDRESS_MAX 36 +#define RIL_CDMA_SMS_SUBADDRESS_MAX 36 +#define RIL_CDMA_SMS_BEARER_DATA_MAX 255 + +typedef enum { + RIL_CDMA_SMS_DIGIT_MODE_4_BIT = 0, /* DTMF digits */ + RIL_CDMA_SMS_DIGIT_MODE_8_BIT = 1, + RIL_CDMA_SMS_DIGIT_MODE_MAX32 = 0x10000000 /* Force constant ENUM size in structures */ +} RIL_CDMA_SMS_DigitMode; + +typedef enum { + RIL_CDMA_SMS_NUMBER_MODE_NOT_DATA_NETWORK = 0, + RIL_CDMA_SMS_NUMBER_MODE_DATA_NETWORK = 1, + RIL_CDMA_SMS_NUMBER_MODE_MAX32 = 0x10000000 /* Force constant ENUM size in structures */ +} RIL_CDMA_SMS_NumberMode; + +typedef enum { + RIL_CDMA_SMS_NUMBER_TYPE_UNKNOWN = 0, + RIL_CDMA_SMS_NUMBER_TYPE_INTERNATIONAL_OR_DATA_IP = 1, + /* INTERNATIONAL is used when number mode is not data network address. + * DATA_IP is used when the number mode is data network address + */ + RIL_CDMA_SMS_NUMBER_TYPE_NATIONAL_OR_INTERNET_MAIL = 2, + /* NATIONAL is used when the number mode is not data network address. + * INTERNET_MAIL is used when the number mode is data network address. + * For INTERNET_MAIL, in the address data "digits", each byte contains + * an ASCII character. Examples are "x@y.com,a@b.com - ref TIA/EIA-637A 3.4.3.3 + */ + RIL_CDMA_SMS_NUMBER_TYPE_NETWORK = 3, + RIL_CDMA_SMS_NUMBER_TYPE_SUBSCRIBER = 4, + RIL_CDMA_SMS_NUMBER_TYPE_ALPHANUMERIC = 5, + /* GSM SMS: address value is GSM 7-bit chars */ + RIL_CDMA_SMS_NUMBER_TYPE_ABBREVIATED = 6, + RIL_CDMA_SMS_NUMBER_TYPE_RESERVED_7 = 7, + RIL_CDMA_SMS_NUMBER_TYPE_MAX32 = 0x10000000 /* Force constant ENUM size in structures */ +} RIL_CDMA_SMS_NumberType; + +typedef enum { + RIL_CDMA_SMS_NUMBER_PLAN_UNKNOWN = 0, + RIL_CDMA_SMS_NUMBER_PLAN_TELEPHONY = 1, /* CCITT E.164 and E.163, including ISDN plan */ + RIL_CDMA_SMS_NUMBER_PLAN_RESERVED_2 = 2, + RIL_CDMA_SMS_NUMBER_PLAN_DATA = 3, /* CCITT X.121 */ + RIL_CDMA_SMS_NUMBER_PLAN_TELEX = 4, /* CCITT F.69 */ + RIL_CDMA_SMS_NUMBER_PLAN_RESERVED_5 = 5, + RIL_CDMA_SMS_NUMBER_PLAN_RESERVED_6 = 6, + RIL_CDMA_SMS_NUMBER_PLAN_RESERVED_7 = 7, + RIL_CDMA_SMS_NUMBER_PLAN_RESERVED_8 = 8, + RIL_CDMA_SMS_NUMBER_PLAN_PRIVATE = 9, + RIL_CDMA_SMS_NUMBER_PLAN_RESERVED_10 = 10, + RIL_CDMA_SMS_NUMBER_PLAN_RESERVED_11 = 11, + RIL_CDMA_SMS_NUMBER_PLAN_RESERVED_12 = 12, + RIL_CDMA_SMS_NUMBER_PLAN_RESERVED_13 = 13, + RIL_CDMA_SMS_NUMBER_PLAN_RESERVED_14 = 14, + RIL_CDMA_SMS_NUMBER_PLAN_RESERVED_15 = 15, + RIL_CDMA_SMS_NUMBER_PLAN_MAX32 = 0x10000000 /* Force constant ENUM size in structures */ +} RIL_CDMA_SMS_NumberPlan; + +typedef struct { + RIL_CDMA_SMS_DigitMode digit_mode; + /* Indicates 4-bit or 8-bit */ + RIL_CDMA_SMS_NumberMode number_mode; + /* Used only when digitMode is 8-bit */ + RIL_CDMA_SMS_NumberType number_type; + /* Used only when digitMode is 8-bit. + * To specify an international address, use the following: + * digitMode = RIL_CDMA_SMS_DIGIT_MODE_8_BIT + * numberMode = RIL_CDMA_SMS_NOT_DATA_NETWORK + * numberType = RIL_CDMA_SMS_NUMBER_TYPE_INTERNATIONAL_OR_DATA_IP + * numberPlan = RIL_CDMA_SMS_NUMBER_PLAN_TELEPHONY + * numberOfDigits = number of digits + * digits = ASCII digits, e.g. '1', '2', '3'3, '4', and '5' + */ + RIL_CDMA_SMS_NumberPlan number_plan; + /* Used only when digitMode is 8-bit */ + unsigned char number_of_digits; + unsigned char digits[ RIL_CDMA_SMS_ADDRESS_MAX ]; + /* Each byte in this array represnts a 4-bit or 8-bit digit of address data */ +} RIL_CDMA_SMS_Address; + +typedef enum { + RIL_CDMA_SMS_SUBADDRESS_TYPE_NSAP = 0, /* CCITT X.213 or ISO 8348 AD2 */ + RIL_CDMA_SMS_SUBADDRESS_TYPE_USER_SPECIFIED = 1, /* e.g. X.25 */ + RIL_CDMA_SMS_SUBADDRESS_TYPE_MAX32 = 0x10000000 /* Force constant ENUM size in structures */ +} RIL_CDMA_SMS_SubaddressType; + +typedef struct { + RIL_CDMA_SMS_SubaddressType subaddressType; + /* 1 means the last byte's lower 4 bits should be ignored */ + unsigned char odd; + unsigned char number_of_digits; + /* Each byte respresents a 8-bit digit of subaddress data */ + unsigned char digits[ RIL_CDMA_SMS_SUBADDRESS_MAX ]; +} RIL_CDMA_SMS_Subaddress; + +typedef struct { + int uTeleserviceID; + unsigned char bIsServicePresent; + int uServicecategory; + RIL_CDMA_SMS_Address sAddress; + RIL_CDMA_SMS_Subaddress sSubAddress; + int uBearerDataLen; + unsigned char aBearerData[ RIL_CDMA_SMS_BEARER_DATA_MAX ]; +} RIL_CDMA_SMS_Message; + +/* Used by RIL_REQUEST_CDMA_SMS_ACKNOWLEDGE */ + +typedef enum { + RIL_CDMA_SMS_NO_ERROR = 0, + RIL_CDMA_SMS_ERROR = 1, + RIL_CDMA_SMS_ERROR_MAX32 = 0x10000000 /* Force constant ENUM size in structures */ +} RIL_CDMA_SMS_ErrorClass; + +typedef struct { + RIL_CDMA_SMS_ErrorClass uErrorClass; + int uSMSCauseCode; /* As defined in N.S00005, 6.5.2.125. + Currently, only 35 (resource shortage) and + 39 (other terminal problem) are reported. */ +} RIL_CDMA_SMS_Ack; + +/* Used by RIL_REQUEST_CDMA_SMS_GET_BROADCAST_CONFIG and + RIL_REQUEST_CDMA_SMS_SET_BROADCAST_CONFIG */ + +typedef struct { + int service_category; + int language; + unsigned char selected; +} RIL_CDMA_BroadcastSmsConfigInfo; + +/* Used by RIL_REQUEST_CDMA_WRITE_SMS_TO_RUIM */ + +typedef struct { + int status; /* Status of message. See TS 27.005 3.1, "<stat>": */ + /* 0 = "REC UNREAD" */ + /* 1 = "REC READ" */ + /* 2 = "STO UNSENT" */ + /* 3 = "STO SENT" */ + + RIL_CDMA_SMS_Message message; +} RIL_CDMA_SMS_WriteArgs; + + +/* Used by RIL_REQUEST_ENCODE_CDMA_SMS and RIL_REQUEST_DECODE_CDMA_SMS*/ + +#define RIL_CDMA_SMS_UDH_MAX_SND_SIZE 128 +#define RIL_CDMA_SMS_UDH_EO_DATA_SEGMENT_MAX 131 /* 140 - 3 - 6 */ +#define RIL_CDMA_SMS_MAX_UD_HEADERS 7 +#define RIL_CDMA_SMS_USER_DATA_MAX 229 +#define RIL_CDMA_SMS_ADDRESS_MAX 36 +#define RIL_CDMA_SMS_UDH_LARGE_PIC_SIZE 128 +#define RIL_CDMA_SMS_UDH_SMALL_PIC_SIZE 32 +#define RIL_CDMA_SMS_UDH_VAR_PIC_SIZE 134 +#define RIL_CDMA_SMS_UDH_ANIM_NUM_BITMAPS 4 +#define RIL_CDMA_SMS_UDH_LARGE_BITMAP_SIZE 32 +#define RIL_CDMA_SMS_UDH_SMALL_BITMAP_SIZE 8 +#define RIL_CDMA_SMS_UDH_OTHER_SIZE 226 +#define RIL_CDMA_SMS_IP_ADDRESS_SIZE 4 + +/* ------------------- */ +/* ---- User Data ---- */ +/* ------------------- */ +typedef enum { + RIL_CDMA_SMS_UDH_CONCAT_8 = 0x00, + RIL_CDMA_SMS_UDH_SPECIAL_SM, + /* 02 - 03 Reserved */ + RIL_CDMA_SMS_UDH_PORT_8 = 0x04, + RIL_CDMA_SMS_UDH_PORT_16, + RIL_CDMA_SMS_UDH_SMSC_CONTROL, + RIL_CDMA_SMS_UDH_SOURCE, + RIL_CDMA_SMS_UDH_CONCAT_16, + RIL_CDMA_SMS_UDH_WCMP, + RIL_CDMA_SMS_UDH_TEXT_FORMATING, + RIL_CDMA_SMS_UDH_PRE_DEF_SOUND, + RIL_CDMA_SMS_UDH_USER_DEF_SOUND, + RIL_CDMA_SMS_UDH_PRE_DEF_ANIM, + RIL_CDMA_SMS_UDH_LARGE_ANIM, + RIL_CDMA_SMS_UDH_SMALL_ANIM, + RIL_CDMA_SMS_UDH_LARGE_PICTURE, + RIL_CDMA_SMS_UDH_SMALL_PICTURE, + RIL_CDMA_SMS_UDH_VAR_PICTURE, + + RIL_CDMA_SMS_UDH_USER_PROMPT = 0x13, + RIL_CDMA_SMS_UDH_EXTENDED_OBJECT = 0x14, + + /* 15 - 1F Reserved for future EMS */ + + RIL_CDMA_SMS_UDH_RFC822 = 0x20, + + /* 21 - 6F Reserved for future use */ + /* 70 - 7f Reserved for (U)SIM Toolkit Security Headers */ + /* 80 - 9F SME to SME specific use */ + /* A0 - BF Reserved for future use */ + /* C0 - DF SC specific use */ + /* E0 - FF Reserved for future use */ + + RIL_CDMA_SMS_UDH_OTHER = 0xFFFF, /* For unsupported or proprietary headers */ + RIL_CDMA_SMS_UDH_ID_MAX32 = 0x10000000 /* Force constant ENUM size in structures */ + +} RIL_CDMA_SMS_UdhId; + +typedef struct { + /*indicates the reference number for a particular concatenated short message. */ + /*it is constant for every short message which makes up a particular concatenated short message*/ + unsigned char msg_ref; + + /*indicates the total number of short messages within the concatenated short message. + The value shall start at 1 and remain constant for every + short message which makes up the concatenated short message. + if it is 0 then the receiving entity shall ignore the whole Information Element*/ + unsigned char total_sm; + + /* + * it indicates the sequence number of a particular short message within the concatenated short + * message. The value shall start at 1 and increment by one for every short message sent + * within the concatenated short message. If the value is zero or the value is + * greater than the value in octet 2 then the receiving + * entity shall ignore the whole Information Element. + */ + unsigned char seq_num; +} RIL_CDMA_SMS_UdhConcat8; + +/* GW message waiting actions +*/ +typedef enum { + RIL_CDMA_SMS_GW_MSG_WAITING_NONE, + RIL_CDMA_SMS_GW_MSG_WAITING_DISCARD, + RIL_CDMA_SMS_GW_MSG_WAITING_STORE, + RIL_CDMA_SMS_GW_MSG_WAITING_NONE_1111, + RIL_CDMA_SMS_GW_MSG_WAITING_MAX32 = 0x10000000 /* Force constant ENUM size in structures */ +} RIL_CDMA_SMS_GWMsgWaiting; + +/* GW message waiting types +*/ +typedef enum { + RIL_CDMA_SMS_GW_MSG_WAITING_VOICEMAIL, + RIL_CDMA_SMS_GW_MSG_WAITING_FAX, + RIL_CDMA_SMS_GW_MSG_WAITING_EMAIL, + RIL_CDMA_SMS_GW_MSG_WAITING_OTHER, + RIL_CDMA_SMS_GW_MSG_WAITING_KIND_MAX32 = 0x10000000 /* Force constant ENUM size in structures */ +} RIL_CDMA_SMS_GWMsgWaitingKind; + +typedef struct { + RIL_CDMA_SMS_GWMsgWaiting msg_waiting; + RIL_CDMA_SMS_GWMsgWaitingKind msg_waiting_kind; + + /*it indicates the number of messages of the type specified in Octet 1 waiting.*/ + unsigned char message_count; +} RIL_CDMA_SMS_UdhSpecialSM; + +typedef struct { + unsigned char dest_port; + unsigned char orig_port; +} RIL_CDMA_SMS_UdhWap8; + +typedef struct { + unsigned short dest_port; + unsigned short orig_port; +} RIL_CDMA_SMS_UdhWap16; + +typedef struct { + unsigned short msg_ref; + unsigned char total_sm; + unsigned char seq_num; + +} RIL_CDMA_SMS_UdhConcat16; + +typedef enum { + RIL_CDMA_SMS_UDH_LEFT_ALIGNMENT = 0, + RIL_CDMA_SMS_UDH_CENTER_ALIGNMENT, + RIL_CDMA_SMS_UDH_RIGHT_ALIGNMENT, + RIL_CDMA_SMS_UDH_DEFAULT_ALIGNMENT, + RIL_CDMA_SMS_UDH_MAX_ALIGNMENT, + RIL_CDMA_SMS_UDH_ALIGNMENT_MAX32 = 0x10000000 /* Force constant ENUM size in structures */ +} RIL_CDMA_SMS_UdhAlignment; + +typedef enum { + RIL_CDMA_SMS_UDH_FONT_NORMAL = 0, + RIL_CDMA_SMS_UDH_FONT_LARGE, + RIL_CDMA_SMS_UDH_FONT_SMALL, + RIL_CDMA_SMS_UDH_FONT_RESERVED, + RIL_CDMA_SMS_UDH_FONT_MAX, + RIL_CDMA_SMS_UDH_FONT_MAX32 = 0x10000000 /* Force constant ENUM size in structures */ +} RIL_CDMA_SMS_UdhFontSize; + +typedef enum { + RIL_CDMA_SMS_UDH_TEXT_COLOR_BLACK = 0x0, + RIL_CDMA_SMS_UDH_TEXT_COLOR_DARK_GREY = 0x1, + RIL_CDMA_SMS_UDH_TEXT_COLOR_DARK_RED = 0x2, + RIL_CDMA_SMS_UDH_TEXT_COLOR_DARK_YELLOW = 0x3, + RIL_CDMA_SMS_UDH_TEXT_COLOR_DARK_GREEN = 0x4, + RIL_CDMA_SMS_UDH_TEXT_COLOR_DARK_CYAN = 0x5, + RIL_CDMA_SMS_UDH_TEXT_COLOR_DARK_BLUE = 0x6, + RIL_CDMA_SMS_UDH_TEXT_COLOR_DARK_MAGENTA = 0x7, + RIL_CDMA_SMS_UDH_TEXT_COLOR_GREY = 0x8, + RIL_CDMA_SMS_UDH_TEXT_COLOR_WHITE = 0x9, + RIL_CDMA_SMS_UDH_TEXT_COLOR_BRIGHT_RED = 0xA, + RIL_CDMA_SMS_UDH_TEXT_COLOR_BRIGHT_YELLOW = 0xB, + RIL_CDMA_SMS_UDH_TEXT_COLOR_BRIGHT_GREEN = 0xC, + RIL_CDMA_SMS_UDH_TEXT_COLOR_BRIGHT_CYAN = 0xD, + RIL_CDMA_SMS_UDH_TEXT_COLOR_BRIGHT_BLUE = 0xE, + RIL_CDMA_SMS_UDH_TEXT_COLOR_BRIGHT_MAGENTA = 0xF, + RIL_CDMA_SMS_UDH_TEXT_COLOR_MAX32 = 0x10000000 /* Force constant ENUM size in structures */ +} RIL_CDMA_SMS_UdhTextColor; + +typedef struct { + unsigned char start_position; + unsigned char text_formatting_length; + RIL_CDMA_SMS_UdhAlignment alignment_type ; /*bit 0 and bit 1*/ + RIL_CDMA_SMS_UdhFontSize font_size ; /*bit 3 and bit 2*/ + unsigned char style_bold; /*bit 4 */ + unsigned char style_italic; /*bit 5 */ + unsigned char style_underlined; /*bit 6 */ + unsigned char style_strikethrough; /*bit 7 */ + + /* if FALSE, ignore the following color information */ + unsigned char is_color_present; + RIL_CDMA_SMS_UdhTextColor text_color_foreground; + RIL_CDMA_SMS_UdhTextColor text_color_background; + +} RIL_CDMA_SMS_UdhTextFormating; + +/* Predefined sound +*/ +typedef struct { + unsigned char position; + unsigned char snd_number; +} RIL_CDMA_SMS_UdhPreDefSound; + +/* User Defined sound +*/ +typedef struct { + unsigned char data_length; + unsigned char position; + unsigned char user_def_sound[RIL_CDMA_SMS_UDH_MAX_SND_SIZE]; +} RIL_CDMA_SMS_UdhUserDefSound; + +/* Large picture +*/ +typedef struct { + unsigned char position; + unsigned char data[RIL_CDMA_SMS_UDH_LARGE_PIC_SIZE]; +} RIL_CDMA_SMS_UdhLargePictureData; + +/* Small picture +*/ +typedef struct { + unsigned char position; + unsigned char data[RIL_CDMA_SMS_UDH_SMALL_PIC_SIZE]; +} RIL_CDMA_SMS_UdhSmallPictureData; + +/* Variable length picture +*/ +typedef struct { + unsigned char position; + unsigned char width; /* Number of pixels - Should be a mutliple of 8 */ + unsigned char height; + unsigned char data[RIL_CDMA_SMS_UDH_VAR_PIC_SIZE]; +} RIL_CDMA_SMS_UdhVarPicture; + +/* Predefined animation +*/ +typedef struct { + unsigned char position; + unsigned char animation_number; +} RIL_CDMA_SMS_UdhPreDefAnim; + +/* Large animation +*/ +typedef struct { + unsigned char position; + unsigned char data[RIL_CDMA_SMS_UDH_ANIM_NUM_BITMAPS][RIL_CDMA_SMS_UDH_LARGE_BITMAP_SIZE]; +} RIL_CDMA_SMS_UdhLargeAnim; + +/* Small animation +*/ +typedef struct { + unsigned char position; + unsigned char data[RIL_CDMA_SMS_UDH_ANIM_NUM_BITMAPS][RIL_CDMA_SMS_UDH_SMALL_BITMAP_SIZE]; +} RIL_CDMA_SMS_UdhSmallAnim; + +/* User Prompt Indicator UDH +*/ +typedef struct { + unsigned char number_of_objects; + /* Number of objects of the same kind that follow this header which will + ** be stitched together by the applications. For example, 5 small pictures + ** are to be stitched together horizontally, or 6 iMelody tones are to be + ** connected together with intermediate iMelody header and footer ignored. + ** Allowed objects to be stitched: + ** - Images (small, large, variable) + ** - User defined sounds + */ +} RIL_CDMA_SMS_UdhUserPrompt; + +typedef struct { + unsigned char length; + + unsigned char data[RIL_CDMA_SMS_UDH_EO_DATA_SEGMENT_MAX]; + /* RIL_CDMA_SMS_UDH_EO_VCARD: See http://www.imc.org/pdi/vcard-21.doc for payload */ + /* RIL_CDMA_SMS_UDH_EO_VCALENDAR: See http://www.imc.org/pdi/vcal-10.doc */ + /* Or: Unsupported/proprietary extended objects */ + +} RIL_CDMA_SMS_UdhEoContent; + +/* Extended Object UDH +*/ +/* Extended Object IDs/types +*/ +typedef enum { + RIL_CDMA_SMS_UDH_EO_VCARD = 0x09, + RIL_CDMA_SMS_UDH_EO_VCALENDAR = 0x0A, + RIL_CDMA_SMS_UDH_EO_MAX32 = 0x10000000 /* Force constant ENUM size in structures */ +} RIL_CDMA_SMS_UdhEoId; + +typedef struct { + /* Extended objects are to be used together with 16-bit concatenation + ** UDH. The max number of segments supported for E.O. is 8 at least. + */ + RIL_CDMA_SMS_UdhEoContent content; + + unsigned char first_segment; + /* The following fields are only present in the first segment of a + ** concatenated SMS message. + */ + unsigned char reference; + /* Identify those extended object segments which should be linked together + */ + unsigned short length; + /* Length of the whole extended object data + */ + unsigned char control; + RIL_CDMA_SMS_UdhEoId type; + unsigned short position; + /* Absolute position of the E.O. in the whole text after concatenation, + ** starting from 1. + */ +} RIL_CDMA_SMS_UdhEo; + +typedef struct { + RIL_CDMA_SMS_UdhId header_id; + unsigned char header_length; + unsigned char data[RIL_CDMA_SMS_UDH_OTHER_SIZE]; +} RIL_CDMA_SMS_UdhOther; + +typedef struct { + unsigned char header_length; +} RIL_CDMA_SMS_UdhRfc822; + +typedef struct { + RIL_CDMA_SMS_UdhId header_id; + + union { + RIL_CDMA_SMS_UdhConcat8 concat_8; // 00 + + RIL_CDMA_SMS_UdhSpecialSM special_sm; // 01 + RIL_CDMA_SMS_UdhWap8 wap_8; // 04 + RIL_CDMA_SMS_UdhWap16 wap_16; // 05 + RIL_CDMA_SMS_UdhConcat16 concat_16; // 08 + RIL_CDMA_SMS_UdhTextFormating text_formating; // 0a + RIL_CDMA_SMS_UdhPreDefSound pre_def_sound; // 0b + RIL_CDMA_SMS_UdhUserDefSound user_def_sound; // 0c + RIL_CDMA_SMS_UdhPreDefAnim pre_def_anim; // 0d + RIL_CDMA_SMS_UdhLargeAnim large_anim; // 0e + RIL_CDMA_SMS_UdhSmallAnim small_anim; // 0f + RIL_CDMA_SMS_UdhLargePictureData large_picture; // 10 + RIL_CDMA_SMS_UdhSmallPictureData small_picture; // 11 + RIL_CDMA_SMS_UdhVarPicture var_picture; // 12 + + RIL_CDMA_SMS_UdhUserPrompt user_prompt; // 13 + RIL_CDMA_SMS_UdhEo eo; // 14 + + RIL_CDMA_SMS_UdhRfc822 rfc822; // 20 + RIL_CDMA_SMS_UdhOther other; + + }u; +} RIL_CDMA_SMS_Udh; + +/* ----------------------------- */ +/* -- User data encoding type -- */ +/* ----------------------------- */ +typedef enum { + RIL_CDMA_SMS_ENCODING_OCTET = 0, /* 8-bit */ + RIL_CDMA_SMS_ENCODING_IS91EP, /* varies */ + RIL_CDMA_SMS_ENCODING_ASCII, /* 7-bit */ + RIL_CDMA_SMS_ENCODING_IA5, /* 7-bit */ + RIL_CDMA_SMS_ENCODING_UNICODE, /* 16-bit */ + RIL_CDMA_SMS_ENCODING_SHIFT_JIS, /* 8 or 16-bit */ + RIL_CDMA_SMS_ENCODING_KOREAN, /* 8 or 16-bit */ + RIL_CDMA_SMS_ENCODING_LATIN_HEBREW, /* 8-bit */ + RIL_CDMA_SMS_ENCODING_LATIN, /* 8-bit */ + RIL_CDMA_SMS_ENCODING_GSM_7_BIT_DEFAULT, /* 7-bit */ + RIL_CDMA_SMS_ENCODING_MAX32 = 0x10000000 + +} RIL_CDMA_SMS_UserDataEncoding; + +/* ------------------------ */ +/* -- IS-91 EP data type -- */ +/* ------------------------ */ +typedef enum { + RIL_CDMA_SMS_IS91EP_VOICE_MAIL = 0x82, + RIL_CDMA_SMS_IS91EP_SHORT_MESSAGE_FULL = 0x83, + RIL_CDMA_SMS_IS91EP_CLI_ORDER = 0x84, + RIL_CDMA_SMS_IS91EP_SHORT_MESSAGE = 0x85, + RIL_CDMA_SMS_IS91EP_MAX32 = 0x10000000 + +} RIL_CDMA_SMS_IS91EPType; + +typedef struct { + /* NOTE: If message_id.udh_present == TRUE: + ** 'num_headers' is the number of User Data Headers (UDHs), + ** and 'headers' include all those headers. + */ + unsigned char num_headers; + RIL_CDMA_SMS_Udh headers[RIL_CDMA_SMS_MAX_UD_HEADERS]; + + RIL_CDMA_SMS_UserDataEncoding encoding; + RIL_CDMA_SMS_IS91EPType is91ep_type; + + /*---------------------------------------------------------------------- + 'data_len' indicates the valid number of bytes in the 'data' array. + + 'padding_bits' (0-7) indicates how many bits in the last byte of 'data' + are invalid bits. This parameter is only used for Mobile-Originated + messages. There is no way for the API to tell how many padding bits + exist in the received message. Instead, the application can find out how + many padding bits exist in the user data when decoding the user data. + + 'data' has the raw bits of the user data field of the SMS message. + The client software should decode the raw user data according to its + supported encoding types and languages. + + EXCEPTION 1: CMT-91 user data raw bits are first translated into BD fields + (e.g. num_messages, callback, etc.) The translated user data field in + VMN and Short Message is in the form of ASCII characters, each occupying + a byte in the resulted 'data'. + + EXCEPTION 2: GSM 7-bit Default characters are decoded so that each byte + has one 7-bit GSM character. + + 'number_of_digits' is the number of digits/characters (7, 8, 16, or + whatever bits) in the raw user data, which can be used by the client + when decoding the user data according to the encoding type and language. + -------------------------------------------------------------------------*/ + unsigned char data_len; + unsigned char padding_bits; + unsigned char data[ RIL_CDMA_SMS_USER_DATA_MAX ]; + unsigned char number_of_digits; + +} RIL_CDMA_SMS_CdmaUserData; + +/* -------------------- */ +/* ---- Message Id ---- */ +/* -------------------- */ +typedef enum { + RIL_CDMA_SMS_BD_TYPE_RESERVED_0 = 0, + RIL_CDMA_SMS_BD_TYPE_DELIVER, /* MT only */ + RIL_CDMA_SMS_BD_TYPE_SUBMIT, /* MO only */ + RIL_CDMA_SMS_BD_TYPE_CANCELLATION, /* MO only */ + RIL_CDMA_SMS_BD_TYPE_DELIVERY_ACK, /* MT only */ + RIL_CDMA_SMS_BD_TYPE_USER_ACK, /* MT & MO */ + RIL_CDMA_SMS_BD_TYPE_READ_ACK, /* MT & MO */ + RIL_CDMA_SMS_BD_TYPE_MAX32 = 0x10000000 + +} RIL_CDMA_SMS_BdMessageType; + +typedef unsigned int RIL_CDMA_SMS_MessageNumber; + +typedef struct { + RIL_CDMA_SMS_BdMessageType type; + RIL_CDMA_SMS_MessageNumber id_number; + unsigned char udh_present; + /* NOTE: if FEATURE_SMS_UDH is not defined, + ** udh_present should be ignored. + */ +} RIL_CDMA_SMS_MessageId; + +typedef unsigned char RIL_CDMA_SMS_UserResponse; + +/* ------------------- */ +/* ---- Timestamp ---- */ +/* ------------------- */ +typedef struct { + /* If 'year' is between 96 and 99, the actual year is 1900 + 'year'; + if 'year' is between 00 and 95, the actual year is 2000 + 'year'. + NOTE: Each field has two BCD digits and byte arrangement is <MSB, ... ,LSB> + */ + unsigned char year; /* 0x00-0x99 */ + unsigned char month; /* 0x01-0x12 */ + unsigned char day; /* 0x01-0x31 */ + unsigned char hour; /* 0x00-0x23 */ + unsigned char minute; /* 0x00-0x59 */ + unsigned char second; /* 0x00-0x59 */ + signed char timezone; /* +/-, [-48,+48] number of 15 minutes - GW only */ +} RIL_CDMA_SMS_Timestamp; + +/* ------------------ */ +/* ---- Priority ---- */ +/* ------------------ */ +typedef enum { + RIL_CDMA_SMS_PRIORITY_NORMAL = 0, + RIL_CDMA_SMS_PRIORITY_INTERACTIVE, + RIL_CDMA_SMS_PRIORITY_URGENT, + RIL_CDMA_SMS_PRIORITY_EMERGENCY, + RIL_CDMA_SMS_PRIORITY_MAX32 = 0x10000000 + +} RIL_CDMA_SMS_Priority; + +/* ----------------- */ +/* ---- Privacy ---- */ +/* ----------------- */ +typedef enum { + RIL_CDMA_SMS_PRIVACY_NORMAL = 0, + RIL_CDMA_SMS_PRIVACY_RESTRICTED, + RIL_CDMA_SMS_PRIVACY_CONFIDENTIAL, + RIL_CDMA_SMS_PRIVACY_SECRET, + RIL_CDMA_SMS_PRIVACY_MAX32 = 0x10000000 + +} RIL_CDMA_SMS_Privacy; + +/* ---------------------- */ +/* ---- Reply option ---- */ +/* ---------------------- */ +typedef struct { + /* whether user ack is requested + */ + unsigned char user_ack_requested; + + /* whether delivery ack is requested. + Should be FALSE for incoming messages. + */ + unsigned char delivery_ack_requested; + + /* Message originator requests the receiving phone to send back a READ_ACK + ** message automatically when the user reads the received message. + */ + unsigned char read_ack_requested; + +} RIL_CDMA_SMS_ReplyOption; + +typedef enum { + RIL_CDMA_SMS_ALERT_MODE_DEFAULT = 0, + RIL_CDMA_SMS_ALERT_MODE_LOW_PRIORITY = 1, + RIL_CDMA_SMS_ALERT_MODE_MEDIUM_PRIORITY = 2, + RIL_CDMA_SMS_ALERT_MODE_HIGH_PRIORITY = 3, + + /* For pre-IS637A implementations, alert_mode only has values of True/False: + */ + RIL_CDMA_SMS_ALERT_MODE_OFF = 0, + RIL_CDMA_SMS_ALERT_MODE_ON = 1 + +} RIL_CDMA_SMS_AlertMode; + +/* ------------------ */ +/* ---- Language ---- */ +/* ------------------ */ +typedef enum { + RIL_CDMA_SMS_LANGUAGE_UNSPECIFIED = 0, + RIL_CDMA_SMS_LANGUAGE_ENGLISH, + RIL_CDMA_SMS_LANGUAGE_FRENCH, + RIL_CDMA_SMS_LANGUAGE_SPANISH, + RIL_CDMA_SMS_LANGUAGE_JAPANESE, + RIL_CDMA_SMS_LANGUAGE_KOREAN, + RIL_CDMA_SMS_LANGUAGE_CHINESE, + RIL_CDMA_SMS_LANGUAGE_HEBREW, + RIL_CDMA_SMS_LANGUAGE_MAX32 = 0x10000000 + +} RIL_CDMA_SMS_Language; + +/* ---------------------------------- */ +/* ---------- Display Mode ---------- */ +/* ---------------------------------- */ +typedef enum { + RIL_CDMA_SMS_DISPLAY_MODE_IMMEDIATE = 0, + RIL_CDMA_SMS_DISPLAY_MODE_DEFAULT = 1, + RIL_CDMA_SMS_DISPLAY_MODE_USER_INVOKE = 2, + RIL_CDMA_SMS_DISPLAY_MODE_RESERVED = 3 +} RIL_CDMA_SMS_DisplayMode; + +/* IS-637B parameters/fields +*/ + +/* ---------------------------------- */ +/* ---------- Delivery Status ------- */ +/* ---------------------------------- */ +typedef enum { + RIL_CDMA_SMS_DELIVERY_STATUS_ACCEPTED = 0, /* ERROR_CLASS_NONE */ + RIL_CDMA_SMS_DELIVERY_STATUS_DEPOSITED_TO_INTERNET = 1, /* ERROR_CLASS_NONE */ + RIL_CDMA_SMS_DELIVERY_STATUS_DELIVERED = 2, /* ERROR_CLASS_NONE */ + RIL_CDMA_SMS_DELIVERY_STATUS_CANCELLED = 3, /* ERROR_CLASS_NONE */ + + RIL_CDMA_SMS_DELIVERY_STATUS_NETWORK_CONGESTION = 4, /* ERROR_CLASS_TEMP & PERM */ + RIL_CDMA_SMS_DELIVERY_STATUS_NETWORK_ERROR = 5, /* ERROR_CLASS_TEMP & PERM */ + RIL_CDMA_SMS_DELIVERY_STATUS_CANCEL_FAILED = 6, /* ERROR_CLASS_PERM */ + RIL_CDMA_SMS_DELIVERY_STATUS_BLOCKED_DESTINATION = 7, /* ERROR_CLASS_PERM */ + RIL_CDMA_SMS_DELIVERY_STATUS_TEXT_TOO_LONG = 8, /* ERROR_CLASS_PERM */ + RIL_CDMA_SMS_DELIVERY_STATUS_DUPLICATE_MESSAGE = 9, /* ERROR_CLASS_PERM */ + RIL_CDMA_SMS_DELIVERY_STATUS_INVALID_DESTINATION = 10, /* ERROR_CLASS_PERM */ + RIL_CDMA_SMS_DELIVERY_STATUS_MESSAGE_EXPIRED = 13, /* ERROR_CLASS_PERM */ + + RIL_CDMA_SMS_DELIVERY_STATUS_UNKNOWN_ERROR = 0x1F /* ERROR_CLASS_PERM */ + + /* All the other values are reserved */ + +} RIL_CDMA_SMS_DeliveryStatusE; + +typedef struct { + RIL_CDMA_SMS_ErrorClass error_class; + RIL_CDMA_SMS_DeliveryStatusE status; +} RIL_CDMA_SMS_DeliveryStatus; + +typedef struct { + unsigned char address[RIL_CDMA_SMS_IP_ADDRESS_SIZE]; + unsigned char is_valid; +} RIL_CDMA_SMS_IpAddress; + +/* This special parameter captures any unrecognized/proprietary parameters +*/ +typedef struct { + unsigned char input_other_len; + unsigned char desired_other_len; /* used during decoding */ + unsigned char * other_data; +} RIL_CDMA_SMS_OtherParm; + +typedef struct { + /* the mask indicates which fields are present in this message */ + unsigned int mask; + + RIL_CDMA_SMS_MessageId message_id; + RIL_CDMA_SMS_CdmaUserData user_data; + RIL_CDMA_SMS_UserResponse user_response; + RIL_CDMA_SMS_Timestamp mc_time; + RIL_CDMA_SMS_Timestamp validity_absolute; + RIL_CDMA_SMS_Timestamp validity_relative; + RIL_CDMA_SMS_Timestamp deferred_absolute; + RIL_CDMA_SMS_Timestamp deferred_relative; + RIL_CDMA_SMS_Priority priority; + RIL_CDMA_SMS_Privacy privacy; + RIL_CDMA_SMS_ReplyOption reply_option; + unsigned char num_messages; /* the actual value; not BCDs */ + RIL_CDMA_SMS_AlertMode alert_mode; + /* For pre-IS-637A implementations, alert_mode is either Off or On. */ + RIL_CDMA_SMS_Language language; + RIL_CDMA_SMS_Address callback; + RIL_CDMA_SMS_DisplayMode display_mode; + + RIL_CDMA_SMS_DeliveryStatus delivery_status; + unsigned int deposit_index; + + RIL_CDMA_SMS_IpAddress ip_address; + unsigned char rsn_no_notify; + + /* See function comments of wms_ts_decode() and + ** wms_ts_decode_cdma_bd_with_other() for details regarding 'other' parameters + */ + RIL_CDMA_SMS_OtherParm other; + +} RIL_CDMA_SMS_ClientBd; + +typedef struct { + unsigned char length; /* length, in bytes, of the encoded SMS message */ + unsigned char * data; /* the encoded SMS message (max 255 bytes) */ +} RIL_CDMA_Encoded_SMS; + +#ifdef __cplusplus +} +#endif + +#endif /*ANDROID_RIL_CDMA_SMS_H*/ diff --git a/radio/include/telephony/ril_mcc.h b/radio/include/telephony/ril_mcc.h new file mode 100644 index 00000000..dc56b126 --- /dev/null +++ b/radio/include/telephony/ril_mcc.h @@ -0,0 +1,71 @@ +/* + * Copyright (C) 2019 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 RIL_MCC_H +#define RIL_MCC_H + +#include <climits> +#include <cstdio> +#include <string> + +namespace ril { +namespace util { +namespace mcc { + +/** + * Decode an integer mcc and encode as 3 digit string + * + * @param an integer mcc, its range should be in 0 to 999. + * + * @return string representation of an encoded MCC or an empty string + * if the MCC is not a valid MCC value. + */ +static inline std::string decode(int mcc) { + char mccStr[4] = {0}; + if (mcc > 999 || mcc < 0) return ""; + + snprintf(mccStr, sizeof(mccStr), "%03d", mcc); + return mccStr; +} + +// echo -e "#include \"hardware/ril/include/telephony/ril_mcc.h\"\nint main()"\ +// "{ return ril::util::mcc::test(); }" > ril_test.cpp \ +// && g++ -o /tmp/ril_test -DTEST_RIL_MCC ril_test.cpp; \ +// rm ril_test.cpp; /tmp/ril_test && [ $? ] && echo "passed" +#ifdef TEST_RIL_MCC +static int test() { + const struct mcc_ints { const int in; const char * out; } legacy_mccs[] = { + {INT_MAX, ""}, + {1, "001"}, + {11, "011"}, + {111, "111"}, + {0, "000"}, + {9999, ""}, + {-12, ""}, + }; + + for (int i=0; i < sizeof(legacy_mccs) / sizeof(struct mcc_ints); i++) { + if (decode(legacy_mccs[i].in).compare(legacy_mccs[i].out)) return 1; + } + + return 0; +} +#endif + +} +} +} +#endif /* !defined(RIL_MCC_H) */ diff --git a/radio/include/telephony/ril_mnc.h b/radio/include/telephony/ril_mnc.h new file mode 100644 index 00000000..fcbae997 --- /dev/null +++ b/radio/include/telephony/ril_mnc.h @@ -0,0 +1,149 @@ +/* + * Copyright (C) 2018 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 RIL_MNC_H +#define RIL_MNC_H + +#include <climits> +#include <cstdio> +#include <string> + +namespace ril { +namespace util { +namespace mnc { + +/** + * Decode an MNC with an optional length indicator provided in the most-significant nibble. + * + * @param mnc an encoded MNC value; if no encoding is provided, then the string is returned + * as a minimum length string representing the provided integer. + * + * @return string representation of an encoded MNC or an empty string if the MNC is not a valid + * MNC value. + */ +static inline std::string decode(int mnc) { + if (mnc == INT_MAX || mnc < 0) return ""; + unsigned umnc = mnc; + char mncNumDigits = (umnc >> (sizeof(int) * 8 - 4)) & 0xF; + + umnc = (umnc << 4) >> 4; + if (umnc > 999) return ""; + + char mncStr[4] = {0}; + switch (mncNumDigits) { + case 0: + // Legacy MNC report hasn't set the number of digits; preserve current + // behavior and make a string of the minimum number of required digits. + return std::to_string(umnc); + + case 2: + snprintf(mncStr, sizeof(mncStr), "%03.3u", umnc); + return mncStr + 1; + + case 3: + snprintf(mncStr, sizeof(mncStr), "%03.3u", umnc); + return mncStr; + + default: + // Error case + return ""; + } + +} + +/** + * Encode an MNC of the given value and a given number of digits + * + * @param mnc an MNC value 0-999 or INT_MAX if unknown + * @param numDigits the number of MNC digits {2, 3} or 0 if unknown + * + * @return an encoded MNC with embedded length information + */ +static inline int encode(int mnc, int numDigits) { + if (mnc > 999 || mnc < 0) return INT_MAX; + switch (numDigits) { + case 0: // fall through + case 2: // fall through + case 3: + break; + + default: + return INT_MAX; + }; + + return (numDigits << (sizeof(int) * 8 - 4)) | mnc; +} + +/** + * Encode an MNC of the given value + * + * @param mnc the string representation of the MNC, with the length equal to the length of the + * provided string. + * + * @return an encoded MNC with embedded length information + */ +static inline int encode(const std::string & mnc) { + return encode(std::stoi(mnc), mnc.length()); +} + +// echo -e "#include \"hardware/ril/include/telephony/ril_mnc.h\"\nint main()"\ +// "{ return ril::util::mnc::test(); }" > ril_test.cpp \ +// && g++ -o /tmp/ril_test -DTEST_RIL_MNC ril_test.cpp; \ +// rm ril_test.cpp; /tmp/ril_test && [ $? ] && echo "passed" +#ifdef TEST_RIL_MNC +static int test() { + const struct mnc_strings { const char * in; const char * out; } mncs[] = { + {"0001",""}, + {"9999",""}, + {"0",""}, + {"9",""}, + {"123","123"}, + {"000","000"}, + {"001","001"}, + {"011","011"}, + {"111","111"}, + {"00","00"}, + {"01","01"}, + {"11","11"}, + {"09","09"}, + {"099","099"}, + {"999", "999"}}; + + for (int i=0; i< sizeof(mncs) / sizeof(struct mnc_strings); i++) { + if (decode(encode(mncs[i].in)).compare(mncs[i].out)) return 1; + } + + const struct mnc_ints { const int in; const char * out; } legacy_mncs[] = { + {INT_MAX, ""}, + {1, "1"}, + {11, "11"}, + {111, "111"}, + {0, "0"}, + {9999, ""}, + }; + + for (int i=0; i < sizeof(legacy_mncs) / sizeof(struct mnc_ints); i++) { + if (decode(legacy_mncs[i].in).compare(legacy_mncs[i].out)) return 1; + } + + return 0; +} +#endif + +} +} +} +#endif /* !defined(RIL_MNC_H) */ diff --git a/radio/include/telephony/ril_msim.h b/radio/include/telephony/ril_msim.h new file mode 100644 index 00000000..5c0b8c51 --- /dev/null +++ b/radio/include/telephony/ril_msim.h @@ -0,0 +1,48 @@ +/* + * Copyright (C) 2014 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_RIL_MSIM_H +#define ANDROID_RIL_MSIM_H 1 + +#ifdef __cplusplus +extern "C" { +#endif + +typedef enum { + RIL_UICC_SUBSCRIPTION_DEACTIVATE = 0, + RIL_UICC_SUBSCRIPTION_ACTIVATE = 1 +} RIL_UiccSubActStatus; + +typedef enum { + RIL_SUBSCRIPTION_1 = 0, + RIL_SUBSCRIPTION_2 = 1, + RIL_SUBSCRIPTION_3 = 2 +} RIL_SubscriptionType; + +typedef struct { + int slot; /* 0, 1, ... etc. */ + int app_index; /* array subscriptor from applications[RIL_CARD_MAX_APPS] in + RIL_REQUEST_GET_SIM_STATUS */ + RIL_SubscriptionType sub_type; /* Indicates subscription 1 or subscription 2 */ + RIL_UiccSubActStatus act_status; +} RIL_SelectUiccSub; + +#ifdef __cplusplus +} +#endif + +#endif /*ANDROID_RIL_MSIM_H*/ diff --git a/radio/include/telephony/ril_nv_items.h b/radio/include/telephony/ril_nv_items.h new file mode 100644 index 00000000..748ea072 --- /dev/null +++ b/radio/include/telephony/ril_nv_items.h @@ -0,0 +1,88 @@ +/* + * Copyright (C) 2014 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_RIL_NV_ITEMS_H +#define ANDROID_RIL_NV_ITEMS_H 1 + +#include <stdlib.h> + +#ifdef __cplusplus +extern "C" { +#endif + +/* Must match the values in RadioNVItems.java in frameworks/opt/telephony. */ +typedef enum { + + // CDMA radio and account information (items 1-10) + RIL_NV_CDMA_MEID = 1, // CDMA MEID (hex) + RIL_NV_CDMA_MIN = 2, // CDMA MIN (MSID) + RIL_NV_CDMA_MDN = 3, // CDMA MDN + RIL_NV_CDMA_ACCOLC = 4, // CDMA access overload control + + // Carrier device provisioning (items 11-30) + RIL_NV_DEVICE_MSL = 11, // device MSL + RIL_NV_RTN_RECONDITIONED_STATUS = 12, // RTN reconditioned status + RIL_NV_RTN_ACTIVATION_DATE = 13, // RTN activation date + RIL_NV_RTN_LIFE_TIMER = 14, // RTN life timer + RIL_NV_RTN_LIFE_CALLS = 15, // RTN life calls + RIL_NV_RTN_LIFE_DATA_TX = 16, // RTN life data TX + RIL_NV_RTN_LIFE_DATA_RX = 17, // RTN life data RX + RIL_NV_OMADM_HFA_LEVEL = 18, // HFA in progress + + // Mobile IP profile information (items 31-50) + RIL_NV_MIP_PROFILE_NAI = 31, // NAI realm + RIL_NV_MIP_PROFILE_HOME_ADDRESS = 32, // MIP home address + RIL_NV_MIP_PROFILE_AAA_AUTH = 33, // AAA auth + RIL_NV_MIP_PROFILE_HA_AUTH = 34, // HA auth + RIL_NV_MIP_PROFILE_PRI_HA_ADDR = 35, // primary HA address + RIL_NV_MIP_PROFILE_SEC_HA_ADDR = 36, // secondary HA address + RIL_NV_MIP_PROFILE_REV_TUN_PREF = 37, // reverse TUN preference + RIL_NV_MIP_PROFILE_HA_SPI = 38, // HA SPI + RIL_NV_MIP_PROFILE_AAA_SPI = 39, // AAA SPI + RIL_NV_MIP_PROFILE_MN_HA_SS = 40, // HA shared secret + RIL_NV_MIP_PROFILE_MN_AAA_SS = 41, // AAA shared secret + + // CDMA network and band config (items 51-70) + RIL_NV_CDMA_PRL_VERSION = 51, // CDMA PRL version + RIL_NV_CDMA_BC10 = 52, // CDMA band class 10 + RIL_NV_CDMA_BC14 = 53, // CDMA band class 14 + RIL_NV_CDMA_SO68 = 54, // CDMA SO68 + RIL_NV_CDMA_SO73_COP0 = 55, // CDMA SO73 COP0 + RIL_NV_CDMA_SO73_COP1TO7 = 56, // CDMA SO73 COP1-7 + RIL_NV_CDMA_1X_ADVANCED_ENABLED = 57, // CDMA 1X Advanced enabled + RIL_NV_CDMA_EHRPD_ENABLED = 58, // CDMA eHRPD enabled + RIL_NV_CDMA_EHRPD_FORCED = 59, // CDMA eHRPD forced + + // LTE network and band config (items 71-90) + RIL_NV_LTE_BAND_ENABLE_25 = 71, // LTE band 25 enable + RIL_NV_LTE_BAND_ENABLE_26 = 72, // LTE band 26 enable + RIL_NV_LTE_BAND_ENABLE_41 = 73, // LTE band 41 enable + + RIL_NV_LTE_SCAN_PRIORITY_25 = 74, // LTE band 25 scan priority + RIL_NV_LTE_SCAN_PRIORITY_26 = 75, // LTE band 26 scan priority + RIL_NV_LTE_SCAN_PRIORITY_41 = 76, // LTE band 41 scan priority + + RIL_NV_LTE_HIDDEN_BAND_PRIORITY_25 = 77, // LTE hidden band 25 priority + RIL_NV_LTE_HIDDEN_BAND_PRIORITY_26 = 78, // LTE hidden band 26 priority + RIL_NV_LTE_HIDDEN_BAND_PRIORITY_41 = 79, // LTE hidden band 41 priority + +} RIL_NV_Item; + +#ifdef __cplusplus +} +#endif + +#endif /* ANDROID_RIL_NV_ITEMS_H */ diff --git a/radio/libril/Android.mk b/radio/libril/Android.mk index e435c09f..cb1fd2e0 100644 --- a/radio/libril/Android.mk +++ b/radio/libril/Android.mk @@ -17,7 +17,7 @@ LOCAL_SHARED_LIBRARIES := \ libutils \ libcutils \ libhardware_legacy \ - librilutils \ + librilutils-goldfish-fork \ android.hardware.radio@1.0 \ android.hardware.radio@1.1 \ android.hardware.radio@1.2 \ diff --git a/radio/libril/RilSapSocket.h b/radio/libril/RilSapSocket.h index 1a816c58..6a941cb1 100644 --- a/radio/libril/RilSapSocket.h +++ b/radio/libril/RilSapSocket.h @@ -19,7 +19,7 @@ #define RIL_SHLIB #include "telephony/ril.h" #include "RilSocket.h" -#include <hardware/ril/librilutils/proto/sap-api.pb.h> +#include <device/generic/goldfish/radio/librilutils/proto/sap-api.pb.h> /** * RilSapSocket is a derived class, derived from the RilSocket abstract diff --git a/radio/libril/rilSocketQueue.h b/radio/libril/rilSocketQueue.h index eaa51552..820aa223 100644 --- a/radio/libril/rilSocketQueue.h +++ b/radio/libril/rilSocketQueue.h @@ -16,7 +16,7 @@ #include "pb_decode.h" #include <pthread.h> -#include <hardware/ril/librilutils/proto/sap-api.pb.h> +#include <device/generic/goldfish/radio/librilutils/proto/sap-api.pb.h> #include <utils/Log.h> using namespace std; diff --git a/radio/libril/ril_service.cpp b/radio/libril/ril_service.cpp index 40ce26b1..073398af 100755 --- a/radio/libril/ril_service.cpp +++ b/radio/libril/ril_service.cpp @@ -3973,6 +3973,11 @@ int radio::getDataRegistrationStateResponse(int slotId, dataRegResponse14.nrIndicators.isEndcAvailable = enableNR ? 1 : 0; dataRegResponse14.nrIndicators.isDcNrRestricted = enableNR ? 0 : 1; dataRegResponse14.nrIndicators.isNrAvailable = enableNR ? 1 : 0; + // override the NR: note, at the moment, NR_SA is not common, so switch to + // NR_NSA(on top of LTE) + if (enableNR) { + dataRegResponse14.base.rat = (int)android::hardware::radio::V1_4::RadioTechnology::LTE_CA; + } if (enableNR) { RLOGD("getDataRegistrationStateResponse enabled 5g"); } else { diff --git a/radio/libril/sap_service.h b/radio/libril/sap_service.h index cb5ae104..a09a19b2 100644 --- a/radio/libril/sap_service.h +++ b/radio/libril/sap_service.h @@ -20,7 +20,7 @@ #include <telephony/ril.h> #include <ril_internal.h> #include <RilSapSocket.h> -#include <hardware/ril/librilutils/proto/sap-api.pb.h> +#include <device/generic/goldfish/radio/librilutils/proto/sap-api.pb.h> namespace sap { diff --git a/radio/librilutils/Android.bp b/radio/librilutils/Android.bp new file mode 100644 index 00000000..0b7597d0 --- /dev/null +++ b/radio/librilutils/Android.bp @@ -0,0 +1,37 @@ +// Copyright 2013 The Android Open Source Project + +cc_library { + name: "librilutils-goldfish-fork", + + srcs: [ + "librilutils.c", + "record_stream.c", + "proto/sap-api.proto", + ], + + header_libs: ["goldfish_ril_headers"], + export_header_lib_headers: ["goldfish_ril_headers"], + + cflags: [ + "-Wall", + "-Wextra", + "-Werror", + "-DPB_FIELD_32BIT" + ], + + proto: { + type: "nanopb-c-enable_malloc-32bit", + export_proto_headers: true, + }, + + vendor: true, +} + +// Create java protobuf code +java_library { + name: "goldfish-fork-sap-api-java-static", + srcs: ["proto/sap-api.proto"], + proto: { + type: "micro", + }, +} diff --git a/radio/librilutils/librilutils.c b/radio/librilutils/librilutils.c new file mode 100644 index 00000000..b1b930ea --- /dev/null +++ b/radio/librilutils/librilutils.c @@ -0,0 +1,24 @@ +/* + * Copyright (C) 2013 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 <telephony/librilutils.h> +#include <time.h> + +uint64_t ril_nano_time() { + struct timespec now; + clock_gettime(CLOCK_MONOTONIC, &now); + return now.tv_sec * 1000000000LL + now.tv_nsec; +} diff --git a/radio/librilutils/proto/sap-api.options b/radio/librilutils/proto/sap-api.options new file mode 100644 index 00000000..f76ba931 --- /dev/null +++ b/radio/librilutils/proto/sap-api.options @@ -0,0 +1,23 @@ +# +# Copyright (C) 2014 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. +# + +MsgHeader.payload type:FT_POINTER +RIL_SIM_SAP_APDU_REQ.command type:FT_POINTER +RIL_SIM_SAP_APDU_RSP.apduResponse type:FT_POINTER +RIL_SIM_SAP_TRANSFER_ATR_RSP.atr type:FT_POINTER + +#RIL_SIM_SAP_REQUEST.apdu type:FT_POINTER +#RIL_SIM_SAP_RESPONSE.apdu type:FT_POINTER diff --git a/radio/librilutils/proto/sap-api.proto b/radio/librilutils/proto/sap-api.proto new file mode 100644 index 00000000..5d125e47 --- /dev/null +++ b/radio/librilutils/proto/sap-api.proto @@ -0,0 +1,306 @@ +syntax = "proto2"; + +option java_package = "org.android.btsap"; +option java_outer_classname = "SapApi"; + +// +// SAP Interface to RIL +// +// The protocol for the binary wire format to RIL shall consist of +// the serialized format of MsgHeader. +// MsgHeader payload field will contain the serialized format of +// the actual message being sent, as described by the type and id +// fields. +// e.g. If type = REQUEST and id == RIL_SIM_SAP_CONNECT, payload +// will contain the serialized wire format of a +// RIL_SIM_SAP_CONNECT_REQ message. +// + +// Message Header +// Each SAP message stream will always be prepended with a MsgHeader +message MsgHeader { + required fixed32 token = 1; // generated dynamically + required MsgType type = 2; + required MsgId id = 3; + required Error error = 4; + required bytes payload = 5; +} + +enum MsgType { + UNKNOWN = 0; + REQUEST = 1; + RESPONSE = 2; + UNSOL_RESPONSE = 3; + } + +enum MsgId { + UNKNOWN_REQ = 0; + + // + // For MsgType: REQUEST ,MsgId: RIL_SIM_SAP_CONNECT, Error: RIL_E_UNUSED, + // Message: message RIL_SIM_SAP_CONNECT_REQ + // For MsgType: RESPONSE, MsgId: RIL_SIM_SAP_CONNECT, Error:Valid errors, + // Message: message RIL_SIM_SAP_CONNECT_RSP + // + RIL_SIM_SAP_CONNECT = 1; + + // + // For MsgType: REQUEST ,MsgId: RIL_SIM_SAP_DISCONNECT, Error: RIL_E_UNUSED, + // Message: message RIL_SIM_SAP_DISCONNECT_REQ + // For MsgType: RESPONSE, MsgId: RIL_SIM_SAP_DISCONNECT, Error:Valid errors, + // Message: message RIL_SIM_SAP_DISCONNECT_RSP + // For MsgType: UNSOL_RESPONSE, MsgId: RIL_SIM_SAP_DISCONNECT, Error: RIL_E_UNUSED, + // Message: message RIL_SIM_SAP_DISCONNECT_IND + // + RIL_SIM_SAP_DISCONNECT = 2; + + // + // For MsgType: REQUEST ,MsgId: RIL_SIM_SAP_APDU, Error: RIL_E_UNUSED, + // Message: message RIL_SIM_SAP_APDU_REQ + // For MsgType: RESPONSE, MsgId: RIL_SIM_SAP_APDU, Error:Valid errors, + // Message: message RIL_SIM_SAP_APDU_RSP + // + RIL_SIM_SAP_APDU = 3; + + // + // For MsgType: REQUEST ,MsgId: RIL_SIM_SAP_TRANSFER_ATR, Error: RIL_E_UNUSED, + // Message: message RIL_SIM_SAP_TRANSFER_ATR_REQ + // For MsgType: RESPONSE, MsgId: RIL_SIM_SAP_TRANSFER_ATR, Error:Valid errors, + // Message: message RIL_SIM_SAP_TRANSFER_ATR_RSP + // + RIL_SIM_SAP_TRANSFER_ATR = 4; + + // + // For MsgType: REQUEST ,MsgId: RIL_SIM_SAP_POWER, Error: RIL_E_UNUSED, + // Message: message RIL_SIM_SAP_POWER_REQ + // For MsgType: RESPONSE, MsgId: RIL_SIM_SAP_POWER, Error:Valid errors, + // Message: message RIL_SIM_SAP_POWER_RSP + // + RIL_SIM_SAP_POWER = 5; + + // + // For MsgType: REQUEST ,MsgId: RIL_SIM_SAP_RESET_SIM, Error: RIL_E_UNUSED, + // Message: message RIL_SIM_SAP_RESET_SIM_REQ + // For MsgType: RESPONSE, MsgId: RIL_SIM_SAP_RESET_SIM, Error:Valid errors, + // Message: message RIL_SIM_SAP_RESET_SIM_RSP + // + RIL_SIM_SAP_RESET_SIM = 6; + + // + // For MsgType: UNSOL_RESPONSE, MsgId: RIL_SIM_SAP_STATUS, Error: RIL_E_UNUSED, + // Message: message RIL_SIM_SAP_STATUS_IND + // + RIL_SIM_SAP_STATUS = 7; + + // + // For MsgType: REQUEST ,MsgId: RIL_SIM_SAP_TRANSFER_CARD_READER_STATUS, Error: RIL_E_UNUSED, + // Message: message RIL_SIM_SAP_TRANSFER_CARD_READER_STATUS_REQ + // For MsgType: RESPONSE, MsgId: RIL_SIM_SAP_TRANSFER_CARD_READER_STATUS, Error:Valid errors, + // Message: message RIL_SIM_SAP_TRANSFER_CARD_READER_STATUS_RSP + // + RIL_SIM_SAP_TRANSFER_CARD_READER_STATUS = 8; + + // + // For MsgType: UNSOL_RESPONSE, MsgId: RIL_SIM_SAP_ERROR_RESP, Error: RIL_E_UNUSED, + // Message: message RIL_SIM_SAP_ERROR_RSP + // + RIL_SIM_SAP_ERROR_RESP = 9; + + // + // For MsgType: REQUEST ,MsgId: RIL_SIM_SAP_SET_TRANSFER_PROTOCOL, Error: RIL_E_UNUSED, + // Message: message RIL_SIM_SAP_SET_TRANSFER_PROTOCOL_REQ + // For MsgType: RESPONSE, MsgId: RIL_SIM_SAP_SET_TRANSFER_PROTOCOL, Error:Valid errors, + // Message: message RIL_SIM_SAP_SET_TRANSFER_PROTOCOL_RSP + // + RIL_SIM_SAP_SET_TRANSFER_PROTOCOL = 10; + } + + enum Error { + RIL_E_SUCCESS = 0; + RIL_E_RADIO_NOT_AVAILABLE = 1; + RIL_E_GENERIC_FAILURE = 2; + RIL_E_REQUEST_NOT_SUPPORTED = 3; + RIL_E_CANCELLED = 4; + RIL_E_INVALID_PARAMETER = 5; + RIL_E_UNUSED = 6; + } + +// SAP 1.1 spec 5.1.1 +message RIL_SIM_SAP_CONNECT_REQ { + required int32 max_message_size = 1; +} + +// SAP 1.1 spec 5.1.2 +message RIL_SIM_SAP_CONNECT_RSP { + enum Response { + RIL_E_SUCCESS = 0; + RIL_E_SAP_CONNECT_FAILURE = 1; + RIL_E_SAP_MSG_SIZE_TOO_LARGE = 2; + RIL_E_SAP_MSG_SIZE_TOO_SMALL = 3; + RIL_E_SAP_CONNECT_OK_CALL_ONGOING = 4; + } + required Response response = 1; +// must be present for RIL_E_SAP_MSG_SIZE_TOO_LARGE and contain the +// the suitable message size + optional int32 max_message_size = 2; +} + +// SAP 1.1 spec 5.1.3 +message RIL_SIM_SAP_DISCONNECT_REQ { + //no params +} + + +// SAP 1.1 spec 5.1.4 +message RIL_SIM_SAP_DISCONNECT_RSP { + //no params +} + + +// SAP 1.1 spec 5.1.5 +message RIL_SIM_SAP_DISCONNECT_IND { + enum DisconnectType { + RIL_S_DISCONNECT_TYPE_GRACEFUL = 0; + RIL_S_DISCONNECT_TYPE_IMMEDIATE = 1; + } + required DisconnectType disconnectType = 1; +} + +// SAP 1.1 spec 5.1.6 +message RIL_SIM_SAP_APDU_REQ { //handles both APDU and APDU7816 + enum Type { + RIL_TYPE_APDU = 0; + RIL_TYPE_APDU7816 = 1; + } + required Type type = 1; + required bytes command = 2; +} + +// SAP 1.1 spec 5.1.7 +message RIL_SIM_SAP_APDU_RSP { //handles both APDU and APDU7816 + enum Type { + RIL_TYPE_APDU = 0; + RIL_TYPE_APDU7816 = 1; + } + required Type type = 1; + enum Response { + RIL_E_SUCCESS = 0; + RIL_E_GENERIC_FAILURE = 1; + RIL_E_SIM_NOT_READY = 2; + RIL_E_SIM_ALREADY_POWERED_OFF = 3; + RIL_E_SIM_ABSENT = 4; + } + required Response response = 2; + optional bytes apduResponse = 3; +} + +// SAP 1.1 spec 5.1.8 +message RIL_SIM_SAP_TRANSFER_ATR_REQ { + // no params +} + +// SAP 1.1 spec 5.1.9 +message RIL_SIM_SAP_TRANSFER_ATR_RSP { + enum Response { + RIL_E_SUCCESS = 0; + RIL_E_GENERIC_FAILURE = 1; + RIL_E_SIM_ALREADY_POWERED_OFF = 3; + RIL_E_SIM_ALREADY_POWERED_ON = 18; + RIL_E_SIM_ABSENT = 4; + RIL_E_SIM_DATA_NOT_AVAILABLE = 6; + } + required Response response = 1; + + optional bytes atr = 2; //must be present on SUCCESS +} + + +// SAP 1.1 spec 5.1.10 +5.1.12 +message RIL_SIM_SAP_POWER_REQ { + required bool state = 1; //true = on, False = off +} + +// SAP 1.1 spec 5.1.11 +5.1.13 +message RIL_SIM_SAP_POWER_RSP { + enum Response { + RIL_E_SUCCESS = 0; + RIL_E_GENERIC_FAILURE = 2; + RIL_E_SIM_ABSENT = 11; + RIL_E_SIM_ALREADY_POWERED_OFF = 17; + RIL_E_SIM_ALREADY_POWERED_ON = 18; + } + required Response response = 1; +} + +// SAP 1.1 spec 5.1.14 +message RIL_SIM_SAP_RESET_SIM_REQ { + // no params +} + +// SAP 1.1 spec 5.1.15 +message RIL_SIM_SAP_RESET_SIM_RSP { + enum Response { + RIL_E_SUCCESS = 0; + RIL_E_GENERIC_FAILURE = 2; + RIL_E_SIM_ABSENT = 11; + RIL_E_SIM_NOT_READY = 16; + RIL_E_SIM_ALREADY_POWERED_OFF = 17; + } + required Response response = 1; +} + +// SAP 1.1 spec 5.1.16 +message RIL_SIM_SAP_STATUS_IND { + enum Status { + RIL_SIM_STATUS_UNKNOWN_ERROR = 0; + RIL_SIM_STATUS_CARD_RESET = 1; + RIL_SIM_STATUS_CARD_NOT_ACCESSIBLE = 2; + RIL_SIM_STATUS_CARD_REMOVED = 3; + RIL_SIM_STATUS_CARD_INSERTED = 4; + RIL_SIM_STATUS_RECOVERED = 5; + } + required Status statusChange = 1; +} + +// SAP 1.1 spec 5.1.17 +message RIL_SIM_SAP_TRANSFER_CARD_READER_STATUS_REQ { + //no params + +} + +// SAP 1.1 spec 5.1.18 +message RIL_SIM_SAP_TRANSFER_CARD_READER_STATUS_RSP { + enum Response { + RIL_E_SUCCESS = 0; + RIL_E_GENERIC_FAILURE = 2; + RIL_E_SIM_DATA_NOT_AVAILABLE = 6; + } + required Response response = 1; + optional int32 CardReaderStatus = 2; +} + +// SAP 1.1 spec 5.1.19 +message RIL_SIM_SAP_ERROR_RSP { + //no params +} + +// SAP 1.1 spec 5.1.20 +message RIL_SIM_SAP_SET_TRANSFER_PROTOCOL_REQ { + enum Protocol { + t0 = 0; + t1 = 1; + } + required Protocol protocol = 1; +} + +// SAP 1.1 spec 5.1.21 +message RIL_SIM_SAP_SET_TRANSFER_PROTOCOL_RSP { + enum Response { + RIL_E_SUCCESS = 0; + RIL_E_GENERIC_FAILURE = 2; + RIL_E_SIM_ABSENT = 11; + RIL_E_SIM_NOT_READY = 16; + RIL_E_SIM_ALREADY_POWERED_OFF = 17; + } + required Response response = 1; +} diff --git a/radio/librilutils/record_stream.c b/radio/librilutils/record_stream.c new file mode 100644 index 00000000..566f6661 --- /dev/null +++ b/radio/librilutils/record_stream.c @@ -0,0 +1,186 @@ +/* +** +** Copyright 2006, 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 <stdlib.h> +#include <unistd.h> +#include <assert.h> +#include <errno.h> +#include <telephony/record_stream.h> +#include <string.h> +#include <stdint.h> +#if defined(_WIN32) +#include <winsock2.h> /* for ntohl */ +#else +#include <netinet/in.h> +#endif + +#define HEADER_SIZE 4 + +struct RecordStream { + int fd; + size_t maxRecordLen; + + unsigned char *buffer; + + unsigned char *unconsumed; + unsigned char *read_end; + unsigned char *buffer_end; +}; + + +extern RecordStream *record_stream_new(int fd, size_t maxRecordLen) +{ + RecordStream *ret; + + assert (maxRecordLen <= 0xffff); + + ret = (RecordStream *)calloc(1, sizeof(RecordStream)); + + ret->fd = fd; + ret->maxRecordLen = maxRecordLen; + ret->buffer = (unsigned char *)malloc (maxRecordLen + HEADER_SIZE); + + ret->unconsumed = ret->buffer; + ret->read_end = ret->buffer; + ret->buffer_end = ret->buffer + maxRecordLen + HEADER_SIZE; + + return ret; +} + + +extern void record_stream_free(RecordStream *rs) +{ + free(rs->buffer); + free(rs); +} + + +/* returns NULL; if there isn't a full record in the buffer */ +static unsigned char * getEndOfRecord (unsigned char *p_begin, + unsigned char *p_end) +{ + size_t len; + unsigned char * p_ret; + + if (p_end < p_begin + HEADER_SIZE) { + return NULL; + } + + //First four bytes are length + len = ntohl(*((uint32_t *)p_begin)); + + p_ret = p_begin + HEADER_SIZE + len; + + if (p_end < p_ret) { + return NULL; + } + + return p_ret; +} + +static void *getNextRecord (RecordStream *p_rs, size_t *p_outRecordLen) +{ + unsigned char *record_start, *record_end; + + record_end = getEndOfRecord (p_rs->unconsumed, p_rs->read_end); + + if (record_end != NULL) { + /* one full line in the buffer */ + record_start = p_rs->unconsumed + HEADER_SIZE; + p_rs->unconsumed = record_end; + + *p_outRecordLen = record_end - record_start; + + return record_start; + } + + return NULL; +} + +/** + * Reads the next record from stream fd + * Records are prefixed by a 16-bit big endian length value + * Records may not be larger than maxRecordLen + * + * Doesn't guard against EINTR + * + * p_outRecord and p_outRecordLen may not be NULL + * + * Return 0 on success, -1 on fail + * Returns 0 with *p_outRecord set to NULL on end of stream + * Returns -1 / errno = EAGAIN if it needs to read again + */ +int record_stream_get_next (RecordStream *p_rs, void ** p_outRecord, + size_t *p_outRecordLen) +{ + void *ret; + + ssize_t countRead; + + /* is there one record already in the buffer? */ + ret = getNextRecord (p_rs, p_outRecordLen); + + if (ret != NULL) { + *p_outRecord = ret; + return 0; + } + + // if the buffer is full and we don't have a full record + if (p_rs->unconsumed == p_rs->buffer + && p_rs->read_end == p_rs->buffer_end + ) { + // this should never happen + //ALOGE("max record length exceeded\n"); + assert (0); + errno = EFBIG; + return -1; + } + + if (p_rs->unconsumed != p_rs->buffer) { + // move remainder to the beginning of the buffer + size_t toMove; + + toMove = p_rs->read_end - p_rs->unconsumed; + if (toMove) { + memmove(p_rs->buffer, p_rs->unconsumed, toMove); + } + + p_rs->read_end = p_rs->buffer + toMove; + p_rs->unconsumed = p_rs->buffer; + } + + countRead = read (p_rs->fd, p_rs->read_end, p_rs->buffer_end - p_rs->read_end); + + if (countRead <= 0) { + /* note: end-of-stream drops through here too */ + *p_outRecord = NULL; + return countRead; + } + + p_rs->read_end += countRead; + + ret = getNextRecord (p_rs, p_outRecordLen); + + if (ret == NULL) { + /* not enough of a buffer to for a whole command */ + errno = EAGAIN; + return -1; + } + + *p_outRecord = ret; + return 0; +} diff --git a/radio/ril/Android.mk b/radio/ril/Android.mk index 4d1b14e1..c9c72f43 100644 --- a/radio/ril/Android.mk +++ b/radio/ril/Android.mk @@ -14,7 +14,7 @@ LOCAL_SRC_FILES:= \ at_tok.c LOCAL_SHARED_LIBRARIES += \ - liblog libcutils libutils libril-goldfish-fork librilutils + liblog libcutils libutils libril-goldfish-fork librilutils-goldfish-fork LOCAL_STATIC_LIBRARIES += libbase libqemud.ranchu diff --git a/radio/ril/reference-ril.c b/radio/ril/reference-ril.c index 75fad711..ac0dd9af 100644 --- a/radio/ril/reference-ril.c +++ b/radio/ril/reference-ril.c @@ -290,6 +290,8 @@ static char s_ipv6_gateway[INET6_ADDRSTRLEN]; // A string containing the IPv6 DNS servers of the radio interface static char s_ipv6_dns[8192]; static pthread_mutex_t s_addresses_mutex = PTHREAD_MUTEX_INITIALIZER; +// Next available handle for keep alive session +static uint32_t s_session_handle = 1; static void pollSIMState (void *param); static void setRadioState(RIL_RadioState newState); @@ -2462,10 +2464,10 @@ static void requestGetRadioCapability(void *data, size_t datalen, RIL_Token t) radioCapability.version = RIL_RADIO_CAPABILITY_VERSION; radioCapability.session = 0; radioCapability.phase = 0; - radioCapability.rat = RAF_LTE; + radioCapability.rat = RAF_NR | RAF_LTE | RAF_UMTS | RAF_GSM; radioCapability.logicalModemUuid[0] = '\0'; radioCapability.status = RC_STATUS_SUCCESS; - + RIL_onRequestComplete(t, RIL_E_SUCCESS, &radioCapability, sizeof(radioCapability)); } @@ -2588,6 +2590,13 @@ static void requestSetCarrierRestrictions(const RIL_CarrierRestrictions *restric } } +static void requestStartKeepalive(RIL_Token t) { + RIL_KeepaliveStatus resp; + resp.sessionHandle = s_session_handle++; + resp.code = KEEPALIVE_ACTIVE; + RIL_onRequestComplete(t, RIL_E_SUCCESS, &resp, sizeof(resp)); +} + /*** Callback methods from the RIL library to us ***/ /** @@ -3064,6 +3073,12 @@ onRequest (int request, void *data, size_t datalen, RIL_Token t) } break; + case RIL_REQUEST_START_KEEPALIVE: + requestStartKeepalive(t); + break; + case RIL_REQUEST_STOP_KEEPALIVE: + RIL_onRequestComplete(t, RIL_E_SUCCESS, NULL, 0); + break; default: RLOGD("Request not supported. Tech: %d",TECH(sMdmInfo)); RIL_onRequestComplete(t, RIL_E_REQUEST_NOT_SUPPORTED, NULL, 0); diff --git a/radio/ril/ril.h b/radio/ril/ril.h index 53c6473b..8e2e2691 100644 --- a/radio/ril/ril.h +++ b/radio/ril/ril.h @@ -285,7 +285,8 @@ typedef enum { RAF_HSPAP = (1 << RADIO_TECH_HSPAP), RAF_GSM = (1 << RADIO_TECH_GSM), RAF_TD_SCDMA = (1 << RADIO_TECH_TD_SCDMA), - RAF_LTE_CA = (1 << RADIO_TECH_LTE_CA) + RAF_LTE_CA = (1 << RADIO_TECH_LTE_CA), + RAF_NR = (1 << RADIO_TECH_NR) } RIL_RadioAccessFamily; typedef enum { @@ -744,8 +745,8 @@ typedef struct { typedef struct { int32_t len_allowed_carriers; /* length of array allowed_carriers */ int32_t len_excluded_carriers; /* length of array excluded_carriers */ - RIL_Carrier * allowed_carriers; /* whitelist for allowed carriers */ - RIL_Carrier * excluded_carriers; /* blacklist for explicitly excluded carriers + RIL_Carrier * allowed_carriers; /* list of allowed carriers */ + RIL_Carrier * excluded_carriers; /* list of explicitly excluded carriers * which match allowed_carriers. Eg. allowed_carriers match * mcc/mnc, excluded_carriers has same mcc/mnc and gid1 * is ABCD. It means except the carrier whose gid1 is ABCD, diff --git a/radio/rild/Android.mk b/radio/rild/Android.mk index 8dc5cde0..d0860c48 100644 --- a/radio/rild/Android.mk +++ b/radio/rild/Android.mk @@ -16,7 +16,7 @@ LOCAL_SHARED_LIBRARIES := \ # Temporary hack for broken vendor RILs. LOCAL_WHOLE_STATIC_LIBRARIES := \ - librilutils + librilutils-goldfish-fork LOCAL_CFLAGS := -DRIL_SHLIB LOCAL_CFLAGS += -Wall -Wextra -Werror diff --git a/rro_overlays/TetheringOverlay/Android.bp b/rro_overlays/TetheringOverlay/Android.bp new file mode 100644 index 00000000..31b0c570 --- /dev/null +++ b/rro_overlays/TetheringOverlay/Android.bp @@ -0,0 +1,22 @@ +// +// Copyright (C) 2020 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. +// + +runtime_resource_overlay { + name: "EmulatorTetheringConfigOverlay", + resource_dirs: ["res"], + product_specific: true, + sdk_version: "current", +} diff --git a/rro_overlays/TetheringOverlay/AndroidManifest.xml b/rro_overlays/TetheringOverlay/AndroidManifest.xml new file mode 100644 index 00000000..fc8c8bd0 --- /dev/null +++ b/rro_overlays/TetheringOverlay/AndroidManifest.xml @@ -0,0 +1,11 @@ +<manifest xmlns:android="http://schemas.android.com/apk/res/android" + package="com.android.networkstack.tethering.emulator" + android:versionCode="1" + android:versionName="1.0"> + <application android:hasCode="false" /> + <overlay + android:targetPackage="com.android.networkstack.tethering" + android:targetName="TetheringConfig" + android:isStatic="true" + android:priority="0"/> +</manifest> diff --git a/rro_overlays/TetheringOverlay/res/values/config.xml b/rro_overlays/TetheringOverlay/res/values/config.xml new file mode 100644 index 00000000..8cb8b405 --- /dev/null +++ b/rro_overlays/TetheringOverlay/res/values/config.xml @@ -0,0 +1,28 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- +/* +** Copyright 2020, 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. +*/ +--> + +<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2"> + <!-- Allow testing SoftAP using the simulated interfaces on the emulator. --> + <string-array name="config_tether_wifi_regexs"> + <item>"wlan\\d"</item> + </string-array> + <string-array name="config_tether_wifi_p2p_regexs"> + <item>"p2p-wlan\\d-.*"</item> + </string-array> +</resources> diff --git a/sensors/Android.bp b/sensors/Android.bp index 4c47036f..f6040f05 100644 --- a/sensors/Android.bp +++ b/sensors/Android.bp @@ -15,7 +15,7 @@ */ cc_library_shared { - name: "android.hardware.sensors@2.0-impl.ranchu", + name: "android.hardware.sensors@2.1-impl.ranchu", vendor: true, relative_install_path: "hw", defaults: ["hidl_defaults"], @@ -28,6 +28,7 @@ cc_library_shared { ], shared_libs: [ "android.hardware.sensors@2.0", + "android.hardware.sensors@2.1", "android.hardware.sensors@2.0-ScopedWakelock", "libbase", "libhidlbase", @@ -35,9 +36,9 @@ cc_library_shared { "libutils", ], static_libs: ["libqemud.ranchu"], - header_libs: ["android.hardware.sensors@2.0-multihal.header"], + header_libs: ["android.hardware.sensors@2.X-multihal.header"], cflags: [ - "-DLOG_TAG=\"android.hardware.sensors@2.0-impl.ranchu\"", + "-DLOG_TAG=\"android.hardware.sensors@2.1-impl.ranchu\"", "-DANDROID_BASE_UNIQUE_FD_DISABLE_IMPLICIT_CONVERSION", ], } diff --git a/sensors/entry.cpp b/sensors/entry.cpp index bc141947..d48c458a 100644 --- a/sensors/entry.cpp +++ b/sensors/entry.cpp @@ -17,11 +17,13 @@ #include <log/log.h> #include "multihal_sensors.h" +using ::android::hardware::sensors::V2_1::implementation::ISensorsSubHal; + namespace { goldfish::MultihalSensors impl; } -extern "C" ISensorsSubHal* sensorsHalGetSubHal(uint32_t* version) { - *version = SUB_HAL_2_0_VERSION; +extern "C" ISensorsSubHal* sensorsHalGetSubHal_2_1(uint32_t* version) { + *version = SUB_HAL_2_1_VERSION; return &impl; } diff --git a/sensors/hals.conf b/sensors/hals.conf index d5dcc832..66593cec 100644 --- a/sensors/hals.conf +++ b/sensors/hals.conf @@ -1 +1 @@ -android.hardware.sensors@2.0-impl.ranchu.so +android.hardware.sensors@2.1-impl.ranchu.so diff --git a/sensors/multihal_sensors.cpp b/sensors/multihal_sensors.cpp index 8baa00be..4fe87c70 100644 --- a/sensors/multihal_sensors.cpp +++ b/sensors/multihal_sensors.cpp @@ -22,11 +22,13 @@ #include "sensor_list.h" namespace goldfish { -using ahs10::SensorType; +using ahs21::SensorType; using ahs10::SensorFlagBits; using ahs10::MetaDataEventType; -MultihalSensors::MultihalSensors() : m_qemuSensorsFd(qemud_channel_open("sensors")) { +MultihalSensors::MultihalSensors() + : m_qemuSensorsFd(qemud_channel_open("sensors")) + , m_batchInfo(getSensorNumber()) { if (!m_qemuSensorsFd.ok()) { ALOGE("%s:%d: m_qemuSensorsFd is not opened", __func__, __LINE__); ::abort(); @@ -56,13 +58,16 @@ MultihalSensors::MultihalSensors() : m_qemuSensorsFd(qemud_channel_open("sensors ::abort(); } buffer[len] = 0; - uint32_t availableSensorsMask = 0; - if (sscanf(buffer, "%u", &availableSensorsMask) != 1) { + uint32_t hostSensorsMask = 0; + if (sscanf(buffer, "%u", &hostSensorsMask) != 1) { ALOGE("%s:%d: Can't parse qemud response", __func__, __LINE__); ::abort(); } m_availableSensorsMask = - availableSensorsMask & ((1u << getSensorNumber()) - 1); + hostSensorsMask & ((1u << getSensorNumber()) - 1); + + ALOGI("%s:%d: host sensors mask=%x, available sensors mask=%x", + __func__, __LINE__, hostSensorsMask, m_availableSensorsMask); if (!::android::base::Socketpair(AF_LOCAL, SOCK_STREAM, 0, &m_callersFd, &m_sensorThreadFd)) { @@ -70,17 +75,23 @@ MultihalSensors::MultihalSensors() : m_qemuSensorsFd(qemud_channel_open("sensors ::abort(); } - m_sensorThread = std::thread(qemuSensorListenerThreadStart, this); + m_sensorThread = std::thread(&MultihalSensors::qemuSensorListenerThread, this); + m_batchThread = std::thread(&MultihalSensors::batchThread, this); } MultihalSensors::~MultihalSensors() { - disableAllSensors(); + setAllQemuSensors(false); + + m_batchRunning = false; + m_batchUpdated.notify_one(); + m_batchThread.join(); + qemuSensorThreadSendCommand(kCMD_QUIT); m_sensorThread.join(); } const std::string MultihalSensors::getName() { - return "hal_sensors_2_0_impl_ranchu"; + return "hal_sensors_2_1_impl_ranchu"; } Return<void> MultihalSensors::debug(const hidl_handle& fd, const hidl_vec<hidl_string>& args) { @@ -89,7 +100,7 @@ Return<void> MultihalSensors::debug(const hidl_handle& fd, const hidl_vec<hidl_s return {}; } -Return<void> MultihalSensors::getSensorsList(getSensorsList_cb _hidl_cb) { +Return<void> MultihalSensors::getSensorsList_2_1(getSensorsList_2_1_cb _hidl_cb) { std::vector<SensorInfo> sensors; uint32_t mask = m_availableSensorsMask; @@ -104,7 +115,7 @@ Return<void> MultihalSensors::getSensorsList(getSensorsList_cb _hidl_cb) { } Return<Result> MultihalSensors::setOperationMode(const OperationMode mode) { - std::unique_lock<std::mutex> lock(m_apiMtx); + std::unique_lock<std::mutex> lock(m_mtx); if (m_activeSensorsMask) { return Result::INVALID_OPERATION; @@ -120,25 +131,31 @@ Return<Result> MultihalSensors::activate(const int32_t sensorHandle, return Result::BAD_VALUE; } - std::unique_lock<std::mutex> lock(m_apiMtx); + std::unique_lock<std::mutex> lock(m_mtx); + BatchInfo& batchInfo = m_batchInfo[sensorHandle]; - uint32_t newActiveMask; if (enabled) { - newActiveMask = m_activeSensorsMask | (1u << sensorHandle); - } else { - newActiveMask = m_activeSensorsMask & ~(1u << sensorHandle); - } - if (m_activeSensorsMask == newActiveMask) { - return Result::OK; - } - - if (m_opMode == OperationMode::NORMAL) { - if (!activateQemuSensorImpl(m_qemuSensorsFd.get(), sensorHandle, enabled)) { - return Result::INVALID_OPERATION; + const SensorInfo* sensor = getSensorInfoByHandle(sensorHandle); + LOG_ALWAYS_FATAL_IF(!sensor); + if (!(sensor->flags & static_cast<uint32_t>(SensorFlagBits::ON_CHANGE_MODE))) { + if (batchInfo.samplingPeriodNs <= 0) { + return Result::BAD_VALUE; + } + + BatchEventRef batchEventRef; + batchEventRef.timestamp = + ::android::elapsedRealtimeNano() + batchInfo.samplingPeriodNs; + batchEventRef.sensorHandle = sensorHandle; + batchEventRef.generation = ++batchInfo.generation; + + m_batchQueue.push(batchEventRef); + m_batchUpdated.notify_one(); } - } - m_activeSensorsMask = newActiveMask; + m_activeSensorsMask = m_activeSensorsMask | (1u << sensorHandle); + } else { + m_activeSensorsMask = m_activeSensorsMask & ~(1u << sensorHandle); + } return Result::OK; } @@ -147,26 +164,35 @@ Return<Result> MultihalSensors::batch(const int32_t sensorHandle, const int64_t maxReportLatencyNs) { (void)maxReportLatencyNs; + if (!isSensorHandleValid(sensorHandle)) { + return Result::BAD_VALUE; + } + const SensorInfo* sensor = getSensorInfoByHandle(sensorHandle); - if (sensor) { - if (samplingPeriodNs >= sensor->minDelay) { - return Result::OK; - } else { - return Result::BAD_VALUE; - } - } else { + LOG_ALWAYS_FATAL_IF(!sensor); + + if (samplingPeriodNs < sensor->minDelay) { return Result::BAD_VALUE; } + + std::unique_lock<std::mutex> lock(m_mtx); + if (m_opMode == OperationMode::NORMAL) { + m_batchInfo[sensorHandle].samplingPeriodNs = samplingPeriodNs; + } + + return Result::OK; } Return<Result> MultihalSensors::flush(const int32_t sensorHandle) { - const SensorInfo* sensor = getSensorInfoByHandle(sensorHandle); - if (!sensor) { + if (!isSensorHandleValid(sensorHandle)) { return Result::BAD_VALUE; } - std::unique_lock<std::mutex> lock(m_apiMtx); - if (!(m_activeSensorsMask & (1u << sensorHandle))) { + const SensorInfo* sensor = getSensorInfoByHandle(sensorHandle); + LOG_ALWAYS_FATAL_IF(!sensor); + + std::unique_lock<std::mutex> lock(m_mtx); + if (!isSensorActive(sensorHandle)) { return Result::BAD_VALUE; } @@ -175,48 +201,58 @@ Return<Result> MultihalSensors::flush(const int32_t sensorHandle) { event.sensorType = SensorType::META_DATA; event.u.meta.what = MetaDataEventType::META_DATA_FLUSH_COMPLETE; - postSensorEventLocked(event); + doPostSensorEventLocked(*sensor, event); return Result::OK; } -Return<Result> MultihalSensors::injectSensorData(const Event& event) { +Return<Result> MultihalSensors::injectSensorData_2_1(const Event& event) { + if (!isSensorHandleValid(event.sensorHandle)) { + return Result::BAD_VALUE; + } if (event.sensorType == SensorType::ADDITIONAL_INFO) { return Result::OK; } - std::unique_lock<std::mutex> lock(m_apiMtx); + std::unique_lock<std::mutex> lock(m_mtx); if (m_opMode != OperationMode::DATA_INJECTION) { return Result::INVALID_OPERATION; } const SensorInfo* sensor = getSensorInfoByHandle(event.sensorHandle); - if (!sensor) { - return Result::BAD_VALUE; - } + LOG_ALWAYS_FATAL_IF(!sensor); if (sensor->type != event.sensorType) { return Result::BAD_VALUE; } - postSensorEventLocked(event); + doPostSensorEventLocked(*sensor, event); return Result::OK; } Return<Result> MultihalSensors::initialize(const sp<IHalProxyCallback>& halProxyCallback) { - std::unique_lock<std::mutex> lock(m_apiMtx); - disableAllSensors(); + std::unique_lock<std::mutex> lock(m_mtx); + setAllQemuSensors(true); // we need to start sampling sensors for batching m_opMode = OperationMode::NORMAL; m_halProxyCallback = halProxyCallback; return Result::OK; } void MultihalSensors::postSensorEvent(const Event& event) { - std::unique_lock<std::mutex> lock(m_apiMtx); - postSensorEventLocked(event); + const SensorInfo* sensor = getSensorInfoByHandle(event.sensorHandle); + LOG_ALWAYS_FATAL_IF(!sensor); + + std::unique_lock<std::mutex> lock(m_mtx); + if (sensor->flags & static_cast<uint32_t>(SensorFlagBits::ON_CHANGE_MODE)) { + if (isSensorActive(event.sensorHandle)) { + doPostSensorEventLocked(*sensor, event); + } + } else { // CONTINUOUS_MODE + m_batchInfo[event.sensorHandle].event = event; + } } -void MultihalSensors::postSensorEventLocked(const Event& event) { +void MultihalSensors::doPostSensorEventLocked(const SensorInfo& sensor, + const Event& event) { const bool isWakeupEvent = - getSensorInfoByHandle(event.sensorHandle)->flags & - static_cast<uint32_t>(SensorFlagBits::WAKE_UP); + sensor.flags & static_cast<uint32_t>(SensorFlagBits::WAKE_UP); m_halProxyCallback->postEvents( {event}, @@ -227,6 +263,62 @@ bool MultihalSensors::qemuSensorThreadSendCommand(const char cmd) const { return TEMP_FAILURE_RETRY(write(m_callersFd.get(), &cmd, 1)) == 1; } +bool MultihalSensors::isSensorHandleValid(int sensorHandle) const { + if (!goldfish::isSensorHandleValid(sensorHandle)) { + return false; + } + + if (!(m_availableSensorsMask & (1u << sensorHandle))) { + return false; + } + + return true; +} + +void MultihalSensors::batchThread() { + while (m_batchRunning) { + std::unique_lock<std::mutex> lock(m_mtx); + if (m_batchQueue.empty()) { + m_batchUpdated.wait(lock); + } else { + const int64_t d = + m_batchQueue.top().timestamp - ::android::elapsedRealtimeNano(); + m_batchUpdated.wait_for(lock, std::chrono::nanoseconds(d)); + } + + const int64_t nowNs = ::android::elapsedRealtimeNano(); + while (!m_batchQueue.empty() && (nowNs >= m_batchQueue.top().timestamp)) { + BatchEventRef evRef = m_batchQueue.top(); + m_batchQueue.pop(); + + const int sensorHandle = evRef.sensorHandle; + LOG_ALWAYS_FATAL_IF(!goldfish::isSensorHandleValid(sensorHandle)); + if (!isSensorActive(sensorHandle)) { + continue; + } + + BatchInfo &batchInfo = m_batchInfo[sensorHandle]; + if (batchInfo.event.sensorType == SensorType::META_DATA) { + ALOGW("%s:%d the host has not provided value yet for sensorHandle=%d", + __func__, __LINE__, sensorHandle); + } else { + batchInfo.event.timestamp = evRef.timestamp; + const SensorInfo* sensor = getSensorInfoByHandle(sensorHandle); + LOG_ALWAYS_FATAL_IF(!sensor); + doPostSensorEventLocked(*sensor, batchInfo.event); + } + + if (evRef.generation == batchInfo.generation) { + const int64_t samplingPeriodNs = batchInfo.samplingPeriodNs; + LOG_ALWAYS_FATAL_IF(samplingPeriodNs <= 0); + + evRef.timestamp += samplingPeriodNs; + m_batchQueue.push(evRef); + } + } + } +} + /// not supported ////////////////////////////////////////////////////////////// Return<void> MultihalSensors::registerDirectChannel(const SharedMemInfo& mem, registerDirectChannel_cb _hidl_cb) { diff --git a/sensors/multihal_sensors.h b/sensors/multihal_sensors.h index dbdc134a..382af7f7 100644 --- a/sensors/multihal_sensors.h +++ b/sensors/multihal_sensors.h @@ -16,17 +16,22 @@ #pragma once #include <android-base/unique_fd.h> -#include <SubHal.h> +#include <V2_1/SubHal.h> +#include <atomic> +#include <condition_variable> #include <cstdint> +#include <queue> #include <thread> +#include <vector> namespace goldfish { namespace ahs = ::android::hardware::sensors; -namespace ahs20 = ahs::V2_0; +namespace ahs21 = ahs::V2_1; namespace ahs10 = ahs::V1_0; -using ahs20::implementation::IHalProxyCallback; -using ahs10::Event; +using ahs21::implementation::IHalProxyCallback; +using ahs21::SensorInfo; +using ahs21::Event; using ahs10::OperationMode; using ahs10::RateLevel; using ahs10::Result; @@ -39,19 +44,19 @@ using ::android::hardware::hidl_vec; using ::android::hardware::Return; using ::android::sp; -struct MultihalSensors : public ahs20::implementation::ISensorsSubHal { +struct MultihalSensors : public ahs21::implementation::ISensorsSubHal { MultihalSensors(); ~MultihalSensors(); Return<void> debug(const hidl_handle& fd, const hidl_vec<hidl_string>& args) override; - Return<void> getSensorsList(getSensorsList_cb _hidl_cb) override; + Return<void> getSensorsList_2_1(getSensorsList_2_1_cb _hidl_cb) override; Return<Result> setOperationMode(OperationMode mode) override; Return<Result> activate(int32_t sensorHandle, bool enabled) override; Return<Result> batch(int32_t sensorHandle, int64_t samplingPeriodNs, int64_t maxReportLatencyNs) override; Return<Result> flush(int32_t sensorHandle) override; - Return<Result> injectSensorData(const Event& event) override; + Return<Result> injectSensorData_2_1(const Event& event) override; Return<void> registerDirectChannel(const SharedMemInfo& mem, @@ -76,16 +81,23 @@ private: float lastProximityValue = kSensorNoValue; float lastLightValue = kSensorNoValue; float lastRelativeHumidityValue = kSensorNoValue; + float lastHingeAngle0Value = kSensorNoValue; + float lastHingeAngle1Value = kSensorNoValue; + float lastHingeAngle2Value = kSensorNoValue; }; + bool isSensorHandleValid(int sensorHandle) const; + bool isSensorActive(int sensorHandle) const { + return m_activeSensorsMask & (1u << sensorHandle); // m_mtx required + } static bool activateQemuSensorImpl(int pipe, int sensorHandle, bool enabled); - bool disableAllSensors(); + bool setAllQemuSensors(bool enabled); void parseQemuSensorEvent(const int pipe, QemuSensorsProtocolState* state); void postSensorEvent(const Event& event); - void postSensorEventLocked(const Event& event); + void doPostSensorEventLocked(const SensorInfo& sensor, const Event& event); void qemuSensorListenerThread(); - static void qemuSensorListenerThreadStart(MultihalSensors* that); + void batchThread(); static constexpr char kCMD_QUIT = 'q'; bool qemuSensorThreadSendCommand(char cmd) const; @@ -102,7 +114,32 @@ private: uint32_t m_activeSensorsMask = 0; OperationMode m_opMode = OperationMode::NORMAL; sp<IHalProxyCallback> m_halProxyCallback; - mutable std::mutex m_apiMtx; + + // batching + struct BatchEventRef { + int64_t timestamp = -1; + int sensorHandle = -1; + int generation = 0; + + bool operator<(const BatchEventRef &rhs) const { + // not a typo, we want m_batchQueue.top() to be the smallest timestamp + return timestamp > rhs.timestamp; + } + }; + + struct BatchInfo { + Event event; + int64_t samplingPeriodNs = 0; + int generation = 0; + }; + + std::priority_queue<BatchEventRef> m_batchQueue; + std::vector<BatchInfo> m_batchInfo; + std::condition_variable m_batchUpdated; + std::thread m_batchThread; + std::atomic<bool> m_batchRunning = true; + + mutable std::mutex m_mtx; }; } // namespace goldfish diff --git a/sensors/multihal_sensors_epoll.cpp b/sensors/multihal_sensors_epoll.cpp index 0be12245..cf2ae56b 100644 --- a/sensors/multihal_sensors_epoll.cpp +++ b/sensors/multihal_sensors_epoll.cpp @@ -38,10 +38,6 @@ int qemuSensortThreadRcvCommand(const int fd) { } } // namespace -void MultihalSensors::qemuSensorListenerThreadStart(MultihalSensors* that) { - that->qemuSensorListenerThread(); -} - void MultihalSensors::qemuSensorListenerThread() { const unique_fd epollFd(epoll_create1(0)); if (!epollFd.ok()) { diff --git a/sensors/multihal_sensors_qemu.cpp b/sensors/multihal_sensors_qemu.cpp index 70d8b6e9..f5da3a15 100644 --- a/sensors/multihal_sensors_qemu.cpp +++ b/sensors/multihal_sensors_qemu.cpp @@ -23,7 +23,7 @@ namespace goldfish { using ahs10::EventPayload; -using ahs10::SensorType; +using ahs21::SensorType; using ahs10::SensorStatus; namespace { @@ -69,19 +69,16 @@ bool MultihalSensors::activateQemuSensorImpl(const int pipe, } } -bool MultihalSensors::disableAllSensors() { - if (m_opMode == OperationMode::NORMAL) { - uint32_t mask = m_activeSensorsMask; - for (int i = 0; mask; ++i, mask >>= 1) { - if (mask & 1) { - if (!activateQemuSensorImpl(m_qemuSensorsFd.get(), i, false)) { - return false; - } +bool MultihalSensors::setAllQemuSensors(const bool enabled) { + uint32_t mask = m_availableSensorsMask; + for (int i = 0; mask; ++i, mask >>= 1) { + if (mask & 1) { + if (!activateQemuSensorImpl(m_qemuSensorsFd.get(), i, enabled)) { + return false; } } } - m_activeSensorsMask = 0; return true; } @@ -222,7 +219,43 @@ void MultihalSensors::parseQemuSensorEvent(const int pipe, } parsed = true; } - } else if (const char* values = testPrefix(buf, end, "guest-sync", ':')) { + } else if (const char* values = testPrefix(buf, end, "hinge-angle0", ':')) { + if (sscanf(values, "%f", &payload->scalar) == 1) { + if (!approximatelyEqual(state->lastHingeAngle0Value, + payload->scalar, 0.001)) { + event.timestamp = nowNs + state->timeBiasNs; + event.sensorHandle = kSensorHandleHingeAngle0; + event.sensorType = SensorType::HINGE_ANGLE; + postSensorEvent(event); + state->lastHingeAngle0Value = payload->scalar; + } + parsed = true; + } + } else if (const char* values = testPrefix(buf, end, "hinge-angle1", ':')) { + if (sscanf(values, "%f", &payload->scalar) == 1) { + if (!approximatelyEqual(state->lastHingeAngle1Value, + payload->scalar, 0.001)) { + event.timestamp = nowNs + state->timeBiasNs; + event.sensorHandle = kSensorHandleHingeAngle1; + event.sensorType = SensorType::HINGE_ANGLE; + postSensorEvent(event); + state->lastHingeAngle1Value = payload->scalar; + } + parsed = true; + } + } else if (const char* values = testPrefix(buf, end, "hinge-angle2", ':')) { + if (sscanf(values, "%f", &payload->scalar) == 1) { + if (!approximatelyEqual(state->lastHingeAngle2Value, + payload->scalar, 0.001)) { + event.timestamp = nowNs + state->timeBiasNs; + event.sensorHandle = kSensorHandleHingeAngle2; + event.sensorType = SensorType::HINGE_ANGLE; + postSensorEvent(event); + state->lastHingeAngle2Value = payload->scalar; + } + parsed = true; + } + } else if (const char* values = testPrefix(buf, end, "guest-sync", ':')) { long long value; if ((sscanf(values, "%lld", &value) == 1) && (value >= 0)) { const int64_t guestTimeNs = static_cast<int64_t>(value * 1000ll); diff --git a/sensors/sensor_list.cpp b/sensors/sensor_list.cpp index 85a57091..0b95294c 100644 --- a/sensors/sensor_list.cpp +++ b/sensors/sensor_list.cpp @@ -17,7 +17,7 @@ #include "sensor_list.h" namespace goldfish { -using ahs::V1_0::SensorType; +using ahs::V2_1::SensorType; using ahs::V1_0::SensorFlagBits; constexpr char kAospVendor[] = "The Android Open Source Project"; @@ -34,6 +34,9 @@ const char* const kQemuSensorName[] = { "humidity", "magnetic-field-uncalibrated", "gyroscope-uncalibrated", + "hinge-angle0", + "hinge-angle1", + "hinge-angle2", }; const SensorInfo kAllSensors[] = { @@ -119,11 +122,11 @@ const SensorInfo kAllSensors[] = { .maxRange = 80.0, .resolution = 1.0, .power = 0.0, - .minDelay = 10000, + .minDelay = 0, .fifoReservedEventCount = 0, .fifoMaxEventCount = 0, .requiredPermission = "", - .maxDelay = 500000, + .maxDelay = 0, .flags = SensorFlagBits::DATA_INJECTION | SensorFlagBits::ON_CHANGE_MODE }, @@ -137,11 +140,11 @@ const SensorInfo kAllSensors[] = { .maxRange = 1.0, .resolution = 1.0, .power = 20.0, - .minDelay = 10000, + .minDelay = 0, .fifoReservedEventCount = 0, .fifoMaxEventCount = 0, .requiredPermission = "", - .maxDelay = 500000, + .maxDelay = 0, .flags = SensorFlagBits::DATA_INJECTION | SensorFlagBits::ON_CHANGE_MODE | SensorFlagBits::WAKE_UP @@ -156,11 +159,11 @@ const SensorInfo kAllSensors[] = { .maxRange = 40000.0, .resolution = 1.0, .power = 20.0, - .minDelay = 10000, + .minDelay = 0, .fifoReservedEventCount = 0, .fifoMaxEventCount = 0, .requiredPermission = "", - .maxDelay = 500000, + .maxDelay = 0, .flags = SensorFlagBits::DATA_INJECTION | SensorFlagBits::ON_CHANGE_MODE }, @@ -192,11 +195,11 @@ const SensorInfo kAllSensors[] = { .maxRange = 100.0, .resolution = 1.0, .power = 20.0, - .minDelay = 10000, + .minDelay = 0, .fifoReservedEventCount = 0, .fifoMaxEventCount = 0, .requiredPermission = "", - .maxDelay = 500000, + .maxDelay = 0, .flags = SensorFlagBits::DATA_INJECTION | SensorFlagBits::ON_CHANGE_MODE }, @@ -235,7 +238,63 @@ const SensorInfo kAllSensors[] = { .flags = SensorFlagBits::DATA_INJECTION | SensorFlagBits::CONTINUOUS_MODE }, -}; + { + .sensorHandle = kSensorHandleHingeAngle0, + .name = "Goldfish hinge sensor0 (in degrees)", + .vendor = kAospVendor, + .version = 1, + .type = SensorType::HINGE_ANGLE, + .typeAsString = "android.sensor.hinge_angle", + .maxRange = 360, + .resolution = 1.0, + .power = 3.0, + .minDelay = 10000, + .fifoReservedEventCount = 0, + .fifoMaxEventCount = 0, + .requiredPermission = "", + .maxDelay = 500000, + .flags = SensorFlagBits::DATA_INJECTION | + SensorFlagBits::ON_CHANGE_MODE | + SensorFlagBits::WAKE_UP + }, + { + .sensorHandle = kSensorHandleHingeAngle1, + .name = "Goldfish hinge sensor1 (in degrees)", + .vendor = kAospVendor, + .version = 1, + .type = SensorType::HINGE_ANGLE, + .typeAsString = "android.sensor.hinge_angle", + .maxRange = 360, + .resolution = 1.0, + .power = 3.0, + .minDelay = 10000, + .fifoReservedEventCount = 0, + .fifoMaxEventCount = 0, + .requiredPermission = "", + .maxDelay = 500000, + .flags = SensorFlagBits::DATA_INJECTION | + SensorFlagBits::ON_CHANGE_MODE | + SensorFlagBits::WAKE_UP + }, + { + .sensorHandle = kSensorHandleHingeAngle2, + .name = "Goldfish hinge sensor2 (in degrees)", + .vendor = kAospVendor, + .version = 1, + .type = SensorType::HINGE_ANGLE, + .typeAsString = "android.sensor.hinge_angle", + .maxRange = 360, + .resolution = 1.0, + .power = 3.0, + .minDelay = 10000, + .fifoReservedEventCount = 0, + .fifoMaxEventCount = 0, + .requiredPermission = "", + .maxDelay = 500000, + .flags = SensorFlagBits::DATA_INJECTION | + SensorFlagBits::ON_CHANGE_MODE | + SensorFlagBits::WAKE_UP + }}; constexpr int kSensorNumber = sizeof(kAllSensors) / sizeof(kAllSensors[0]); diff --git a/sensors/sensor_list.h b/sensors/sensor_list.h index 5eb9d831..b74fce9c 100644 --- a/sensors/sensor_list.h +++ b/sensors/sensor_list.h @@ -15,12 +15,12 @@ */ #pragma once -#include <android/hardware/sensors/1.0/types.h> +#include <android/hardware/sensors/2.1/types.h> namespace goldfish { namespace ahs = ::android::hardware::sensors; -using SensorInfo = ahs::V1_0::SensorInfo; +using SensorInfo = ahs::V2_1::SensorInfo; constexpr int kSensorHandleAccelerometer = 0; constexpr int kSensorHandleGyroscope = 1; @@ -33,6 +33,9 @@ constexpr int kSensorHandlePressure = 7; constexpr int kSensorHandleRelativeHumidity = 8; constexpr int kSensorHandleMagneticFieldUncalibrated = 9; constexpr int kSensorHandleGyroscopeFieldUncalibrated = 10; +constexpr int kSensorHandleHingeAngle0 = 11; +constexpr int kSensorHandleHingeAngle1 = 12; +constexpr int kSensorHandleHingeAngle2 = 13; int getSensorNumber(); bool isSensorHandleValid(int h); diff --git a/sepolicy/common/bootanim.te b/sepolicy/common/bootanim.te index 4d011e10..ad2b4770 100644 --- a/sepolicy/common/bootanim.te +++ b/sepolicy/common/bootanim.te @@ -5,6 +5,3 @@ dontaudit bootanim system_data_file:dir read; allow bootanim graphics_device:chr_file { read ioctl open }; allow bootanim gpu_device:chr_file { read ioctl open }; - -typeattribute bootanim system_writes_vendor_properties_violators; -set_prop(bootanim, qemu_prop) diff --git a/sepolicy/common/createns.te b/sepolicy/common/createns.te index 1eaf9ef5..c74ca3c3 100644 --- a/sepolicy/common/createns.te +++ b/sepolicy/common/createns.te @@ -9,6 +9,7 @@ allow createns varrun_file:dir { add_name search write }; allow createns varrun_file:file { create mounton open read write }; #Allow createns itself to be run by init in its own domain -domain_auto_trans(goldfish_setup, createns_exec, createns); +domain_auto_trans(init, createns_exec, createns); allow createns goldfish_setup:fd use; +set_prop(createns, qemu_prop); diff --git a/sepolicy/common/file_contexts b/sepolicy/common/file_contexts index e73c3596..421952f4 100644 --- a/sepolicy/common/file_contexts +++ b/sepolicy/common/file_contexts @@ -63,3 +63,8 @@ # data /data/vendor/mediadrm(/.*)? u:object_r:mediadrm_vendor_data_file:s0 /data/vendor/var/run(/.*)? u:object_r:varrun_file:s0 + +# not yet AOSP HALs +/vendor/bin/hw/android\.hardware\.camera\.provider@2\.6-service-google u:object_r:hal_camera_default_exec:s0 +/vendor/bin/hw/android\.hardware\.rebootescrow-service\.default u:object_r:hal_rebootescrow_default_exec:s0 +/vendor/bin/hw/android\.hardware\.contexthub@1\.1-service\.mock u:object_r:hal_contexthub_default_exec:s0 diff --git a/sepolicy/common/goldfish_setup.te b/sepolicy/common/goldfish_setup.te index c6b3361b..a0d4738b 100644 --- a/sepolicy/common/goldfish_setup.te +++ b/sepolicy/common/goldfish_setup.te @@ -37,8 +37,6 @@ set_prop(goldfish_setup, qemu_prop); get_prop(goldfish_setup, net_share_prop); # Allow goldfish_setup to run init.wifi.sh allow goldfish_setup goldfish_setup_exec:file execute_no_trans; -#Allow goldfish_setup to run createns in its own domain -domain_auto_trans(goldfish_setup, createns_exec, createns); # iw allow goldfish_setup sysfs:file { read open }; # iptables diff --git a/sepolicy/common/hal_audio_default.te b/sepolicy/common/hal_audio_default.te index 745092f2..d8acc8e6 100644 --- a/sepolicy/common/hal_audio_default.te +++ b/sepolicy/common/hal_audio_default.te @@ -1,2 +1,2 @@ -type hal_audio_default_prop, property_type; +vendor_internal_prop(hal_audio_default_prop) get_prop(hal_audio_default, hal_audio_default_prop) diff --git a/sepolicy/common/hal_bluetooth_sim.te b/sepolicy/common/hal_bluetooth_sim.te index 82bab59a..838bba4e 100644 --- a/sepolicy/common/hal_bluetooth_sim.te +++ b/sepolicy/common/hal_bluetooth_sim.te @@ -1,6 +1,6 @@ type hal_bluetooth_sim, domain; type hal_bluetooth_sim_exec, exec_type, vendor_file_type, file_type; -type hal_bluetooth_sim_prop, property_type; +vendor_internal_prop(hal_bluetooth_sim_prop) hal_server_domain(hal_bluetooth_sim, hal_bluetooth) diff --git a/sepolicy/common/hal_camera_default.te b/sepolicy/common/hal_camera_default.te index 6e020205..57ed6aec 100644 --- a/sepolicy/common/hal_camera_default.te +++ b/sepolicy/common/hal_camera_default.te @@ -1,4 +1,12 @@ +vendor_restricted_prop(vendor_camera_prop) +get_prop(hal_camera_default, vendor_camera_prop) + vndbinder_use(hal_camera_default); allow hal_camera_default hal_graphics_mapper_hwservice:hwservice_manager find; hal_client_domain(hal_camera_default, hal_graphics_allocator); -hal_client_domain(hal_camera_default, hal_graphics_composer) +hal_client_domain(hal_camera_default, hal_graphics_composer); +hal_client_domain(hal_camera_default, hal_thermal); + +# For camera hal to talk with sensor service +binder_call(hal_camera_default, sensor_service_server) +binder_call(sensor_service_server, hal_camera_default) diff --git a/sepolicy/common/hal_dumpstate_default.te b/sepolicy/common/hal_dumpstate_default.te deleted file mode 100644 index df68c1ce..00000000 --- a/sepolicy/common/hal_dumpstate_default.te +++ /dev/null @@ -1,2 +0,0 @@ -type hal_dumpstate_default_prop, property_type; -set_prop(hal_dumpstate_default, hal_dumpstate_default_prop) diff --git a/sepolicy/common/mediaserver.te b/sepolicy/common/mediaserver.te new file mode 100644 index 00000000..a0739c5e --- /dev/null +++ b/sepolicy/common/mediaserver.te @@ -0,0 +1,3 @@ +allow mediaserver vendor_data_file:file { read getattr }; +allow mediaserver vendor_data_file:lnk_file read; +dontaudit mediaserver vendor_data_file:file { open }; diff --git a/sepolicy/common/property.te b/sepolicy/common/property.te index d0e4c1da..8e8a7868 100644 --- a/sepolicy/common/property.te +++ b/sepolicy/common/property.te @@ -1,9 +1,9 @@ -type qemu_prop, property_type; -type qemu_cmdline, property_type; -type radio_noril_prop, property_type; -type net_wlan0_prop, property_type; -type net_eth0_prop, property_type; -type net_radio0_prop, property_type; -type net_share_prop, property_type; -type vendor_net, property_type; -type vendor_build_prop, property_type; +vendor_restricted_prop(qemu_prop) +vendor_restricted_prop(qemu_cmdline) +vendor_restricted_prop(radio_noril_prop) +vendor_restricted_prop(net_wlan0_prop) +vendor_restricted_prop(net_eth0_prop) +vendor_restricted_prop(net_radio0_prop) +vendor_restricted_prop(net_share_prop) +vendor_restricted_prop(vendor_net) +vendor_restricted_prop(vendor_build_prop) diff --git a/sepolicy/common/property_contexts b/sepolicy/common/property_contexts index 1e15c08f..5b236e56 100644 --- a/sepolicy/common/property_contexts +++ b/sepolicy/common/property_contexts @@ -12,6 +12,6 @@ net.radio0. u:object_r:net_radio0_prop:s0 net.shared_net_ip u:object_r:net_share_prop:s0 net.wifi_mac_prefix u:object_r:net_share_prop:s0 ro.zygote.disable_gl_preload u:object_r:qemu_prop:s0 -persist.dumpstate.verbose_logging.enabled u:object_r:hal_dumpstate_default_prop:s0 vendor.bt.rootcanal_mac_address u:object_r:hal_bluetooth_sim_prop:s0 vendor.bt.rootcanal_test_console u:object_r:hal_bluetooth_sim_prop:s0 +persist.camera. u:object_r:vendor_camera_prop:s0 diff --git a/sepolicy/common/surfaceflinger.te b/sepolicy/common/surfaceflinger.te index 575ec1bd..ea8beaf0 100644 --- a/sepolicy/common/surfaceflinger.te +++ b/sepolicy/common/surfaceflinger.te @@ -1,6 +1,3 @@ allow surfaceflinger self:process execmem; allow surfaceflinger ashmem_device:chr_file execute; allow surfaceflinger gpu_device:chr_file { ioctl open read write map }; - -typeattribute surfaceflinger system_writes_vendor_properties_violators; -set_prop(surfaceflinger, qemu_prop) diff --git a/sepolicy/common/zygote.te b/sepolicy/common/zygote.te index da403b5d..390a507a 100644 --- a/sepolicy/common/zygote.te +++ b/sepolicy/common/zygote.te @@ -1,5 +1,3 @@ -typeattribute zygote system_writes_vendor_properties_violators; -set_prop(zygote, qemu_prop) # TODO (b/63631799) fix this access # Suppress denials to storage. Webview zygote should not be accessing. dontaudit webview_zygote mnt_expand_file:dir getattr; diff --git a/soundtrigger/main.cpp b/soundtrigger/main.cpp index 6bf27737..1d901fc2 100644 --- a/soundtrigger/main.cpp +++ b/soundtrigger/main.cpp @@ -34,7 +34,7 @@ struct SoundTriggerHw : public ISoundTriggerHw { props.implementor = "The Android Open Source Project"; props.description = "The Andtoid Studio Emulator Soundtrigger no-op implementation"; - props.version = 0; + props.version = 254868980; props.uuid = (Uuid){ .timeLow = 0x04030201, .timeMid = 0x0605, diff --git a/tools/mk_verified_boot_params.sh b/tools/mk_verified_boot_params.sh index 15813cb6..f1ea9415 100755 --- a/tools/mk_verified_boot_params.sh +++ b/tools/mk_verified_boot_params.sh @@ -79,7 +79,7 @@ readonly ROOT_DIGEST=${DM_SPLIT[15]} readonly SALT=${DM_SPLIT[16]} readonly NUM_OPTIONAL_PARAMS=1 -# Sanity Checks +# Validity Checks [[ $ROOT_DIGEST =~ [[:xdigit:]]{40} ]] || die "ROOT_DIGEST looks incorrect: $ROOT_DIGEST" [[ $SALT =~ [[:xdigit:]]{40} ]] || die "SALT looks incorrect: $SALT" diff --git a/ueventd.ranchu.rc b/ueventd.ranchu.rc index db426342..5be82974 100644 --- a/ueventd.ranchu.rc +++ b/ueventd.ranchu.rc @@ -1,5 +1,6 @@ # These settings are specific to running under the Android emulator /dev/qemu_trace 0666 system system +/dev/ion 0664 system system /dev/goldfish_pipe 0666 system system /dev/ttyS* 0666 system system /dev/goldfish_sync 0666 system system @@ -30,6 +30,8 @@ PRODUCT_SYSTEM_EXT_PROPERTIES += ro.lockscreen.disable.default=1 DISABLE_RILD_OEM_HOOK := true DEVICE_MANIFEST_FILE := device/generic/goldfish/manifest.xml +PRODUCT_SOONG_NAMESPACES += hardware/google/camera +PRODUCT_SOONG_NAMESPACES += hardware/google/camera/devices/EmulatedCamera # Device modules PRODUCT_PACKAGES += \ @@ -43,8 +45,8 @@ PRODUCT_PACKAGES += \ qemu-props \ stagefright \ fingerprint.ranchu \ - android.hardware.graphics.composer@2.1-impl \ - android.hardware.graphics.composer@2.1-service \ + android.hardware.graphics.composer@2.3-impl \ + android.hardware.graphics.composer@2.3-service \ android.hardware.graphics.allocator@3.0-service \ android.hardware.graphics.mapper@3.0-impl-ranchu \ hwcomposer.ranchu \ @@ -56,6 +58,8 @@ PRODUCT_PACKAGES += \ iw_vendor \ local_time.default \ SdkSetup \ + EmulatorRadioConfig \ + EmulatorTetheringConfigOverlay \ libstagefrighthw \ libstagefright_goldfish_vpxdec \ libstagefright_goldfish_avcdec \ @@ -73,11 +77,6 @@ PRODUCT_PACKAGES += \ endif PRODUCT_PACKAGES += \ - audio.r_submix.default \ - android.hardware.audio.service \ - android.hardware.audio.effect@6.0-impl:32 - -PRODUCT_PACKAGES += \ android.hardware.bluetooth@1.1-service.sim \ android.hardware.bluetooth.audio@2.0-impl PRODUCT_PROPERTY_OVERRIDES += vendor.bt.rootcanal_test_console=off @@ -98,7 +97,8 @@ PRODUCT_PACKAGES += \ android.hardware.keymaster@4.1-service PRODUCT_PACKAGES += \ - DisplayCutoutEmulationEmu01Overlay + DisplayCutoutEmulationEmu01Overlay \ + NavigationBarMode2ButtonOverlay \ ifneq ($(EMULATOR_VENDOR_NO_GNSS),true) PRODUCT_PACKAGES += android.hardware.gnss@2.0-service.ranchu @@ -106,10 +106,10 @@ endif ifneq ($(EMULATOR_VENDOR_NO_SENSORS),true) PRODUCT_PACKAGES += \ - android.hardware.sensors@2.0-service.multihal \ - android.hardware.sensors@2.0-impl.ranchu + android.hardware.sensors@2.1-service.multihal \ + android.hardware.sensors@2.1-impl.ranchu # TODO(rkir): -# add a soong namespace and move this into a.h.sensors@2.0-impl.ranchu +# add a soong namespace and move this into a.h.sensors@2.1-impl.ranchu # as prebuilt_etc. For now soong_namespace causes a build break because the fw # refers to our wifi HAL in random places. PRODUCT_COPY_FILES += \ @@ -119,8 +119,8 @@ endif PRODUCT_PACKAGES += \ android.hardware.drm@1.0-service \ android.hardware.drm@1.0-impl \ - android.hardware.drm@1.2-service.clearkey \ - android.hardware.drm@1.2-service.widevine + android.hardware.drm@1.3-service.clearkey \ + android.hardware.drm@1.3-service.widevine PRODUCT_PACKAGES += \ android.hardware.power-service.example \ @@ -143,20 +143,28 @@ PRODUCT_PACKAGES += \ android.hardware.camera.provider@2.4-service \ android.hardware.camera.provider@2.4-impl \ camera.ranchu \ - camera.ranchu.jpeg + camera.ranchu.jpeg \ + android.hardware.camera.provider@2.6-service-google \ + libgooglecamerahwl_impl \ + android.hardware.camera.provider@2.6-impl-google DEVICE_MANIFEST_FILE += device/generic/goldfish/manifest.camera.xml endif -ifneq ($(EMULATOR_VENDOR_NO_SOUND_TRIGGER),true) -PRODUCT_PACKAGES += android.hardware.soundtrigger@2.2-impl.ranchu -endif - ifneq ($(EMULATOR_VENDOR_NO_SOUND),true) -PRODUCT_PACKAGES += android.hardware.audio@6.0-impl.ranchu +PRODUCT_PACKAGES += \ + android.hardware.audio.service \ + android.hardware.audio@6.0-impl.ranchu \ + android.hardware.soundtrigger@2.2-impl.ranchu \ + android.hardware.audio.effect@6.0-impl \ + PRODUCT_COPY_FILES += \ device/generic/goldfish/audio/policy/audio_policy_configuration.xml:$(TARGET_COPY_OUT_VENDOR)/etc/audio_policy_configuration.xml \ device/generic/goldfish/audio/policy/primary_audio_policy_configuration.xml:$(TARGET_COPY_OUT_VENDOR)/etc/primary_audio_policy_configuration.xml \ - device/generic/goldfish/audio/policy/r_submix_audio_policy_configuration.xml:$(TARGET_COPY_OUT_VENDOR)/etc/r_submix_audio_policy_configuration.xml + frameworks/av/services/audiopolicy/config/r_submix_audio_policy_configuration.xml:$(TARGET_COPY_OUT_VENDOR)/etc/r_submix_audio_policy_configuration.xml \ + frameworks/av/services/audiopolicy/config/audio_policy_volumes.xml:$(TARGET_COPY_OUT_VENDOR)/etc/audio_policy_volumes.xml \ + frameworks/av/services/audiopolicy/config/default_volume_tables.xml:$(TARGET_COPY_OUT_VENDOR)/etc/default_volume_tables.xml \ + frameworks/av/media/libeffects/data/audio_effects.xml:$(TARGET_COPY_OUT_VENDOR)/etc/audio_effects.xml \ + endif PRODUCT_PACKAGES += \ @@ -209,13 +217,35 @@ PRODUCT_PACKAGES += \ PRODUCT_PACKAGES += \ android.hardware.power.stats@1.0-service.mock +# Reboot escrow +PRODUCT_PACKAGES += \ + android.hardware.rebootescrow-service.default + +# Extension implementation for Jetpack WindowManager +PRODUCT_PACKAGES += \ + androidx.window.sidecar + +PRODUCT_PACKAGES += \ + android.hardware.biometrics.face@1.0-service.example + +PRODUCT_PACKAGES += \ + android.hardware.contexthub@1.1-service.mock + # Goldfish does not support ION needed for Codec 2.0 -PRODUCT_PROPERTY_OVERRIDES += \ - debug.stagefright.ccodec=0 +# still disable it until b/143473631 is fixed +# now this is setup on init.ranchu.rc +# -qemu -append qemu.media.ccodec=<value> can override it; default 0 +#PRODUCT_PROPERTY_OVERRIDES += \ +# debug.stagefright.ccodec=0 + +# Enable Incremental on the device via kernel driver +PRODUCT_PROPERTY_OVERRIDES += ro.incremental.enable=yes + PRODUCT_COPY_FILES += \ device/generic/goldfish/data/etc/dtb.img:dtb.img \ device/generic/goldfish/data/etc/apns-conf.xml:data/misc/apns/apns-conf.xml \ + device/generic/goldfish/radio/RadioConfig/radioconfig.xml:data/misc/emulator/config/radioconfig.xml \ device/generic/goldfish/data/etc/local.prop:data/local.prop \ device/generic/goldfish/init.ranchu-core.sh:$(TARGET_COPY_OUT_VENDOR)/bin/init.ranchu-core.sh \ device/generic/goldfish/init.ranchu-net.sh:$(TARGET_COPY_OUT_VENDOR)/bin/init.ranchu-net.sh \ @@ -256,15 +286,23 @@ PRODUCT_COPY_FILES += \ frameworks/native/data/etc/android.hardware.touchscreen.multitouch.jazzhand.xml:$(TARGET_COPY_OUT_VENDOR)/etc/permissions/android.hardware.touchscreen.multitouch.jazzhand.xml \ frameworks/native/data/etc/android.hardware.camera.ar.xml:$(TARGET_COPY_OUT_VENDOR)/etc/permissions/android.hardware.camera.ar.xml \ frameworks/native/data/etc/android.hardware.camera.autofocus.xml:$(TARGET_COPY_OUT_VENDOR)/etc/permissions/android.hardware.camera.autofocus.xml \ + frameworks/native/data/etc/android.hardware.camera.front.xml:$(TARGET_COPY_OUT_VENDOR)/etc/permissions/android.hardware.camera.front.xml \ frameworks/native/data/etc/android.hardware.camera.full.xml:$(TARGET_COPY_OUT_VENDOR)/etc/permissions/android.hardware.camera.full.xml \ frameworks/native/data/etc/android.hardware.fingerprint.xml:$(TARGET_COPY_OUT_VENDOR)/etc/permissions/android.hardware.fingerprint.xml \ frameworks/native/data/etc/android.hardware.vulkan.level-1.xml:$(TARGET_COPY_OUT_VENDOR)/etc/permissions/android.hardware.vulkan.level.xml \ frameworks/native/data/etc/android.hardware.vulkan.compute-0.xml:$(TARGET_COPY_OUT_VENDOR)/etc/permissions/android.hardware.vulkan.compute.xml \ frameworks/native/data/etc/android.hardware.vulkan.version-1_1.xml:$(TARGET_COPY_OUT_VENDOR)/etc/permissions/android.hardware.vulkan.version.xml \ - device/generic/goldfish/data/etc/android.software.vulkan.deqp.level-2019-03-01.xml:$(TARGET_COPY_OUT_VENDOR)/etc/permissions/android.software.vulkan.deqp.level-2019-03-01.xml \ + frameworks/native/data/etc/android.software.vulkan.deqp.level-2020-03-01.xml:$(TARGET_COPY_OUT_VENDOR)/etc/permissions/android.software.vulkan.deqp.level.xml \ frameworks/native/data/etc/android.software.autofill.xml:$(TARGET_COPY_OUT_VENDOR)/etc/permissions/android.software.autofill.xml \ frameworks/native/data/etc/android.software.verified_boot.xml:${TARGET_COPY_OUT_PRODUCT}/etc/permissions/android.software.verified_boot.xml \ frameworks/av/media/libeffects/data/audio_effects.xml:$(TARGET_COPY_OUT_VENDOR)/etc/audio_effects.xml \ frameworks/av/services/audiopolicy/config/audio_policy_volumes.xml:$(TARGET_COPY_OUT_VENDOR)/etc/audio_policy_volumes.xml \ frameworks/av/services/audiopolicy/config/default_volume_tables.xml:$(TARGET_COPY_OUT_VENDOR)/etc/default_volume_tables.xml \ - device/generic/goldfish/data/etc/permissions/privapp-permissions-goldfish.xml:$(TARGET_COPY_OUT_PRODUCT)/etc/permissions/privapp-permissions-goldfish.xml + device/generic/goldfish/data/etc/permissions/privapp-permissions-goldfish.xml:$(TARGET_COPY_OUT_PRODUCT)/etc/permissions/privapp-permissions-goldfish.xml \ + hardware/google/camera/devices/EmulatedCamera/hwl/configs/emu_camera_back.json:$(TARGET_COPY_OUT_VENDOR)/etc/config/emu_camera_back.json \ + hardware/google/camera/devices/EmulatedCamera/hwl/configs/emu_camera_front.json:$(TARGET_COPY_OUT_VENDOR)/etc/config/emu_camera_front.json \ + hardware/google/camera/devices/EmulatedCamera/hwl/configs/emu_camera_depth.json:$(TARGET_COPY_OUT_VENDOR)/etc/config/emu_camera_depth.json \ + +# Windowing settings config files +PRODUCT_COPY_FILES += \ + device/generic/goldfish/display_settings_freeform.xml:$(TARGET_COPY_OUT_DATA)/system/display_settings_freeform.xml diff --git a/wifi/createns/createns.cpp b/wifi/createns/createns.cpp index 95aff530..c540932d 100644 --- a/wifi/createns/createns.cpp +++ b/wifi/createns/createns.cpp @@ -17,6 +17,7 @@ #define LOG_TAG "createns" #include <log/log.h> +#include <cutils/properties.h> #include <errno.h> #include <fcntl.h> #include <inttypes.h> @@ -148,85 +149,11 @@ static bool writeNamespacePid(const char* name, pid_t pid) { return true; } -static pid_t daemonize(int fd) { - // This convoluted way of demonizing the process is described in - // man (7) daemon. - - // (1) Close all files, we don't have any open files at this point - // (2) Reset all signal handlers to default, they already are - // (3) Reset the signal mask, we never changed it - // (4) Sanitize environment block, we didn't change the environment - // (5) Call fork - pid_t pid = ::fork(); - if (pid != 0) { - // In the parent, nothing more to do - return pid; - } - - // (6) Acquire a new session to detach from terminal - ::setsid(); - - // (7) Fork again to avoid the daemon being attached to a terminal again - pid = ::fork(); - if (pid != 0) { - // (8) This is the first child, needs to call exit - exit(0); - return pid; - } - // (9) Connect /dev/null to stdin, stdout, stderr - ::close(STDIN_FILENO); - ::close(STDOUT_FILENO); - ::close(STDERR_FILENO); - // Since open will always reuse the lowest available fd and we have closed - // every single fd at this point we can just open them in the correct order. - if (::open("/dev/null", O_RDONLY) == -1) { - ALOGE("Unable to open /dev/null as stdin"); - } - if (::open("/dev/null", O_WRONLY) == -1) { - ALOGE("Unable to open /dev/null as stdout"); - } - if (::open("/dev/null", O_WRONLY) == -1) { - ALOGE("Unable to open /dev/null as stderr"); - } - // (10) Reset umask to zero - ::umask(0); - // (11) Change directory to root (/) - if (::chdir("/") != 0) { - ALOGE("Failed to set working directory to root: %s", strerror(errno)); - } - // (12) Write the pid of the daemon to a file, we're passing this to - // the process that starts the daemon to ensure that the pid file exists - // once that process exits. Atomicity is guaranteed by that write requiring - // that the pid file does not exist to begin with. - pid = ::getpid(); - if (::write(fd, &pid, sizeof(pid)) != sizeof(pid)) { - ALOGE("Unable to write pid to pipe: %s", strerror(errno)); - ::close(fd); - exit(1); - } - ::close(fd); - // (13) Drop privileges, doing this causes problems for execns when it's - // trying to open the proc/ns/net file of this process so we can't do that. - // (14) Notify the starting process that the daemon is running, this is done - // in step (12) above. - // (15) Exit starting process happens in main where it returns. - return 0; -} - int main(int argc, char* argv[]) { if (argc != 2) { usage(argv[0]); return 1; } - int fds[2]; - if (::pipe2(fds, O_CLOEXEC) != 0) { - ALOGE("Failed to create pipe: %s", strerror(errno)); - return 1; - } - - Fd readPipe(fds[0]); - Fd writePipe(fds[1]); - if (::unshare(CLONE_NEWNET) != 0) { ALOGE("Failed to create network namespace '%s': %s", argv[1], @@ -240,8 +167,7 @@ int main(int argc, char* argv[]) { } { // Open and then immediately close the fd - Fd fd(::open(path.c_str(), O_CREAT | O_TRUNC | O_RDONLY | O_CLOEXEC, - S_IRUSR | S_IWUSR | S_IRGRP)); + Fd fd(::open(path.c_str(), O_CREAT|O_RDONLY, S_IRUSR | S_IRGRP)); if (fd.get() == -1) { ALOGE("Failed to open file %s: %s", path.c_str(), strerror(errno)); return 1; @@ -257,28 +183,13 @@ int main(int argc, char* argv[]) { return 1; } - // At this point we fork. This way we keep a process in the namespace alive - // without this command being blocking. This is valuable because it allows - // us to write the pid to a file before we exit. That way we can guarantee - // that after this command completes there is a pid to be read, there is no - // asynchronous behavior going on. - pid_t pid = daemonize(writePipe.get()); - if (pid == 0) { - // In the child - for (;;) { - pause(); - } - } else { - // In the parent, read the pid of the daemon from the pipe and write it - // to a file. - pid_t child = 0; - if (::read(readPipe.get(), &child, sizeof(child)) != sizeof(child)) { - ALOGE("Failed to read child PID from pipe: %s", strerror(errno)); - return 1; - } - if (!writeNamespacePid(argv[1], child)) { - return 1; - } + if (!writeNamespacePid(argv[1], ::getpid())) { + return 1; + } + property_set("qemu.networknamespace", "ready"); + + for (;;) { + pause(); } return 0; diff --git a/wifi/init.wifi.sh b/wifi/init.wifi.sh index ea34447b..108cbf42 100755 --- a/wifi/init.wifi.sh +++ b/wifi/init.wifi.sh @@ -47,7 +47,6 @@ if [ -n "$wifi_mac_prefix" ]; then fi NAMESPACE="router" -createns ${NAMESPACE} # createns will have created a file that contains the process id (pid) of a # process running in the network namespace. This pid is needed for some commands @@ -86,3 +85,5 @@ fi # Start hostapd, the access point software setprop ctl.start emu_hostapd + +ifconfig radio0 -multicast diff --git a/wifi/wifi_hal/Android.bp b/wifi/wifi_hal/Android.bp index 88c1e30d..64310034 100644 --- a/wifi/wifi_hal/Android.bp +++ b/wifi/wifi_hal/Android.bp @@ -28,6 +28,7 @@ cc_library_static { "wifi_hal.cpp", ], shared_libs: [ + "libnl", "liblog", "libcutils", "libhardware_legacy", diff --git a/wifi/wifi_hal/interface.cpp b/wifi/wifi_hal/interface.cpp index 9c5c01e2..47d81543 100644 --- a/wifi/wifi_hal/interface.cpp +++ b/wifi/wifi_hal/interface.cpp @@ -86,6 +86,9 @@ wifi_error Interface::getName(char* name, size_t size) { return WIFI_SUCCESS; } +// Wifi legacy HAL implicitly assumes getLinkStats is blocking and +// handler will be set to nullptr immediately after invocation. +// Therefore, this function will wait until onLinkStatsReply is called. wifi_error Interface::getLinkStats(wifi_request_id requestId, wifi_stats_result_handler handler) { NetlinkMessage message(RTM_GETLINK, mNetlink.getSequenceNumber()); @@ -97,12 +100,21 @@ wifi_error Interface::getLinkStats(wifi_request_id requestId, info->ifi_flags = 0; info->ifi_change = 0xFFFFFFFF; - bool success = mNetlink.sendMessage(message, - std::bind(&Interface::onLinkStatsReply, - this, - requestId, - handler, - std::placeholders::_1)); + std::condition_variable condition; + std::mutex mutex; + std::unique_lock<std::mutex> lock(mutex); + bool stopped = false; + auto callback = [this, requestId, &handler, + &mutex, &condition, &stopped] (const NetlinkMessage& message) { + stopped = true; + std::unique_lock<std::mutex> lock(mutex); + onLinkStatsReply(requestId, handler, message); + condition.notify_all(); + }; + bool success = mNetlink.sendMessage(message, callback); + while (!stopped) { + condition.wait(lock); + } return success ? WIFI_SUCCESS : WIFI_ERROR_UNKNOWN; } @@ -257,6 +269,24 @@ Interface::getWakeReasonStats(WLAN_DRIVER_WAKE_REASON_CNT* wakeReasonCount) { return WIFI_SUCCESS; } +wifi_error Interface::startSendingOffloadedPacket(wifi_request_id /*id*/, + u16 /*ether_type*/, + u8 * /*ip_packet*/, + u16 /*ip_packet_len*/, + u8 * /*src_mac_addr*/, + u8 * /*dst_mac_addr*/, + u32 /*period_msec*/) { + // Drop the packet and pretend everything is fine. Currentlty this is only + // used for keepalive packets to allow the CPU to go to sleep and let the + // hardware send keepalive packets on its own. By dropping this we lose the + // keepalive packets but networking will still be fine. + return WIFI_SUCCESS; +} + +wifi_error Interface::stopSendingOffloadedPacket(wifi_request_id /*id*/) { + return WIFI_SUCCESS; +} + void Interface::onLinkStatsReply(wifi_request_id requestId, wifi_stats_result_handler handler, const NetlinkMessage& message) { diff --git a/wifi/wifi_hal/interface.h b/wifi/wifi_hal/interface.h index a793330f..de01c16f 100644 --- a/wifi/wifi_hal/interface.h +++ b/wifi/wifi_hal/interface.h @@ -70,6 +70,15 @@ public: size_t* numProvidedFates); wifi_error getPacketFilterCapabilities(u32* version, u32* maxLength); wifi_error getWakeReasonStats(WLAN_DRIVER_WAKE_REASON_CNT* wakeReasonCount); + wifi_error startSendingOffloadedPacket(wifi_request_id id, + u16 ether_type, + u8 *ip_packet, + u16 ip_packet_len, + u8 *src_mac_addr, + u8 *dst_mac_addr, + u32 period_msec); + wifi_error stopSendingOffloadedPacket(wifi_request_id id); + private: Interface(const Interface&) = delete; Interface& operator=(const Interface&) = delete; diff --git a/wifi/wifi_hal/netlinkmessage.cpp b/wifi/wifi_hal/netlinkmessage.cpp index baf5800d..06bb7438 100644 --- a/wifi/wifi_hal/netlinkmessage.cpp +++ b/wifi/wifi_hal/netlinkmessage.cpp @@ -22,6 +22,7 @@ #include <linux/rtnetlink.h> #include <sys/types.h> #include <unistd.h> +#include <netlink/msg.h> size_t getSpaceForMessageType(uint16_t type) { switch (type) { @@ -51,13 +52,12 @@ NetlinkMessage::NetlinkMessage(const char* data, size_t size) bool NetlinkMessage::getAttribute(int attributeId, void* data, size_t size) const { const void* value = nullptr; - uint16_t attrSize = 0; - if (!findAttribute(attributeId, &value, &attrSize)) { - return false; - } - if (size > attrSize) { + const auto attr = nlmsg_find_attr((struct nlmsghdr*)mData.data(), sizeof(ifinfomsg), attributeId); + if (!attr) { return false; } + value = (const uint8_t*) attr + NLA_HDRLEN; + size = attr->nla_len; memcpy(data, value, size); return true; } @@ -71,30 +71,3 @@ uint32_t NetlinkMessage::sequence() const { auto header = reinterpret_cast<const nlmsghdr*>(mData.data()); return header->nlmsg_seq; } - -bool NetlinkMessage::findAttribute(int attributeId, - const void** value, - uint16_t* size) const { - const uint8_t* end = mData.data() + mData.size(); - size_t attrOffset = getSpaceForMessageType(type()); - if (attrOffset == 0) { - return false; - } - const uint8_t* attribute = mData.data() + attrOffset; - while (attribute < end) { - auto header = reinterpret_cast<const nlattr*>(attribute); - if (header->nla_len == 0) { - // The length should include the header so the length should always - // be greater than zero. If it doesn't we're going to end up looping - // forever so ignore this. - return false; - } - if (header->nla_type == attributeId) { - *value = attribute + NLA_HDRLEN; - *size = header->nla_len; - return true; - } - attribute += header->nla_len; - } - return false; -} diff --git a/wifi/wifi_hal/netlinkmessage.h b/wifi/wifi_hal/netlinkmessage.h index 45fd7cdb..5e1a3b80 100644 --- a/wifi/wifi_hal/netlinkmessage.h +++ b/wifi/wifi_hal/netlinkmessage.h @@ -60,9 +60,6 @@ private: NetlinkMessage& operator=(const NetlinkMessage&) = delete; bool getAttribute(int attributeId, void* data, size_t size) const; - bool findAttribute(int attributeId, - const void** value, - uint16_t* size) const; std::vector<uint8_t> mData; }; diff --git a/wifi/wifi_hal/wifi_hal.cpp b/wifi/wifi_hal/wifi_hal.cpp index 2d093241..62ac061b 100644 --- a/wifi/wifi_hal/wifi_hal.cpp +++ b/wifi/wifi_hal/wifi_hal.cpp @@ -366,6 +366,35 @@ wifi_get_wake_reason_stats(wifi_interface_handle handle, return asInterface(handle)->getWakeReasonStats(wifi_wake_reason_cnt); } +wifi_error wifi_start_sending_offloaded_packet(wifi_request_id id, + wifi_interface_handle handle, + u16 ether_type, + u8 *ip_packet, + u16 ip_packet_len, + u8 *src_mac_addr, + u8 *dst_mac_addr, + u32 period_msec) { + if (handle == nullptr) { + return WIFI_ERROR_INVALID_ARGS; + } + + return asInterface(handle)->startSendingOffloadedPacket(id, + ether_type, + ip_packet, + ip_packet_len, + src_mac_addr, + dst_mac_addr, + period_msec); +} + +wifi_error wifi_stop_sending_offloaded_packet(wifi_request_id id, + wifi_interface_handle handle) { + if (handle == nullptr) { + return WIFI_ERROR_INVALID_ARGS; + } + + return asInterface(handle)->stopSendingOffloadedPacket(id); +} wifi_error init_wifi_vendor_hal_func_table(wifi_hal_fn* fn) { @@ -405,6 +434,10 @@ wifi_error init_wifi_vendor_hal_func_table(wifi_hal_fn* fn) = wifi_get_packet_filter_capabilities; fn->wifi_get_wake_reason_stats = wifi_get_wake_reason_stats; + fn->wifi_start_sending_offloaded_packet + = wifi_start_sending_offloaded_packet; + fn->wifi_stop_sending_offloaded_packet = wifi_stop_sending_offloaded_packet; + // These function will either return WIFI_ERROR_NOT_SUPPORTED or do nothing notSupported(fn->wifi_set_nodfs_flag); notSupported(fn->wifi_get_concurrency_matrix); @@ -428,8 +461,6 @@ wifi_error init_wifi_vendor_hal_func_table(wifi_hal_fn* fn) notSupported(fn->wifi_reset_log_handler); notSupported(fn->wifi_start_rssi_monitoring); notSupported(fn->wifi_stop_rssi_monitoring); - notSupported(fn->wifi_start_sending_offloaded_packet); - notSupported(fn->wifi_stop_sending_offloaded_packet); notSupported(fn->wifi_set_packet_filter); return WIFI_SUCCESS; diff --git a/wifi/wpa_supplicant_8_lib/driver_cmd_nl80211.c b/wifi/wpa_supplicant_8_lib/driver_cmd_nl80211.c index 9589e853..fb068c66 100644 --- a/wifi/wpa_supplicant_8_lib/driver_cmd_nl80211.c +++ b/wifi/wpa_supplicant_8_lib/driver_cmd_nl80211.c @@ -9,6 +9,7 @@ * license. */ +#include "includes.h" #include "driver_cmd_nl80211.h" #include <stddef.h> diff --git a/x86_64-vendor.mk b/x86_64-vendor.mk index 2334fa6c..f64067cc 100644 --- a/x86_64-vendor.mk +++ b/x86_64-vendor.mk @@ -21,6 +21,9 @@ PRODUCT_SDK_ADDON_COPY_FILES += \ device/generic/goldfish/data/etc/encryptionkey.img:images/x86_64/encryptionkey.img \ prebuilts/qemu-kernel/x86_64/$(PRODUCT_KERNEL_VERSION)/kernel-qemu2:images/x86_64/kernel-ranchu +PRODUCT_COPY_FILES += \ + device/generic/goldfish/data/etc/configs/gpu.config:data/misc/gceconfigs/gpu.config + PRODUCT_PACKAGES += \ emulatorip |