Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit f37576bc authored by Jakub Pawlowski's avatar Jakub Pawlowski Committed by Gerrit Code Review
Browse files

Merge changes from topics "parcel_uuid_and_fd_native", "bluetooth_socket_manager_native"

* changes:
  Make ParcelUuid and ParcelFileDescriptor accesible to native Binder (1/2)
  Add IBluetoothSocketManager (1/3)
parents 6ac26a6e 0275cd31
Loading
Loading
Loading
Loading
+8 −1
Original line number Diff line number Diff line
cc_library_shared {
    name: "bluetooth_binder_interface",
    name: "libbluetooth-binder",
    srcs: [
        "android/bluetooth/IBluetoothSocketManager.aidl",
        "android/os/parcel_file_descriptor.cc",
        "android/os/parcel_uuid.cc",
/* TODO: Uncomment this files as they get converted one-by-one into native implementation
        "android/bluetooth/IBluetooth.aidl",
        "android/bluetooth/IBluetoothA2dp.aidl",
@@ -33,10 +36,14 @@ cc_library_shared {
        "android/bluetooth/le/IScannerCallback.aidl"
*/
     ],
    export_include_dirs: [ "./"],
    aidl: {
        export_aidl_headers: true,
        include_dirs: [
            "frameworks/native/aidl/binder",

             /* required for android.os.ParcelUuid, and android.os.ParcelFileDescriptor */
            "frameworks/base/core/java",
        ],
    },
    include_dirs: [
+2 −0
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@
package android.bluetooth;

import android.bluetooth.IBluetoothCallback;
import android.bluetooth.IBluetoothSocketManager;
import android.bluetooth.IBluetoothStateChangeCallback;
import android.bluetooth.BluetoothActivityEnergyInfo;
import android.bluetooth.BluetoothClass;
@@ -100,6 +101,7 @@ interface IBluetooth
    // For Socket
    ParcelFileDescriptor connectSocket(in BluetoothDevice device, int type, in ParcelUuid uuid, int port, int flag);
    ParcelFileDescriptor createSocketChannel(int type, in String serviceName, in ParcelUuid uuid, int port, int flag);
    IBluetoothSocketManager getSocketManager();

    boolean factoryReset();

+26 −0
Original line number Diff line number Diff line
/*
 * Copyright 2017, 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 android.bluetooth;

/**
 * API for Bluetooth Sockets service.
 *
 * {@hide}
 */
interface IBluetoothSocketManager
{
}
+41 −0
Original line number Diff line number Diff line
//
//  Copyright 2017, 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 "android/os/parcel_file_descriptor.h"
#include <base/logging.h>

using android::OK;
using android::Parcel;
using android::status_t;

namespace android {
namespace os {

status_t ParcelFileDescriptor::writeToParcel(Parcel* parcel) const {
  status_t status = parcel->writeInt32(0);
  if (status != OK) return status;

  status = parcel->writeDupFileDescriptor(fd);
  return status;
}

status_t ParcelFileDescriptor::readFromParcel(const Parcel* parcel) {
  LOG(FATAL) << "Don't know how to read ParcelFileDescriptor";
  return OK;
}

}  // namespace os
}  // namespace android
 No newline at end of file
+48 −0
Original line number Diff line number Diff line
//
//  Copyright 2017, 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 <binder/Parcel.h>
#include <binder/Parcelable.h>

namespace android {
namespace os {

class ParcelFileDescriptor : public android::Parcelable {
 public:
  ParcelFileDescriptor() = default;
  ~ParcelFileDescriptor() = default;

  // Write |this| parcelable to the given |parcel|.  Keep in mind that
  // implementations of writeToParcel must be manually kept in sync
  // with readFromParcel and the Java equivalent versions of these methods.
  //
  // Returns android::OK on success and an appropriate error otherwise.
  android::status_t writeToParcel(android::Parcel* parcel) const override;

  // Read data from the given |parcel| into |this|.  After readFromParcel
  // completes, |this| should have equivalent state to the object that
  // wrote itself to the parcel.
  //
  // Returns android::OK on success and an appropriate error otherwise.
  android::status_t readFromParcel(const android::Parcel* parcel) override;

  int fd;
};

}  // namespace os
}  // namespace android
Loading