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

Commit aed54f78 authored by Wei Wang's avatar Wei Wang Committed by android-build-merger
Browse files

Merge "Add LOCATION_HARDWARE permission to Rtt API." into oc-mr1-dev

am: 90658fab

Change-Id: I06af71e194a693d2cefc72ed93f7eb8446140ee4
parents 58770c57 90658fab
Loading
Loading
Loading
Loading
+49 −1
Original line number Diff line number Diff line
package android.net.wifi;

import android.Manifest;
import android.annotation.NonNull;
import android.annotation.RequiresPermission;
import android.annotation.SuppressLint;
@@ -313,6 +314,7 @@ public class RttManager {
             };
    }

    @RequiresPermission(Manifest.permission.LOCATION_HARDWARE)
    public RttCapabilities getRttCapabilities() {
        synchronized (mCapabilitiesLock) {
            if (mRttCapabilities == null) {
@@ -925,6 +927,51 @@ public class RttManager {
        public void onAborted();
    }

    /**
     * A parcelable that contains rtt client information.
     *
     * @hide
     */
    public static class RttClient implements Parcelable {
        // Package name of RttClient.
        private final String mPackageName;

        public RttClient(String packageName) {
            mPackageName = packageName;
        }

        protected RttClient(Parcel in) {
            mPackageName = in.readString();
        }

        public static final Creator<RttManager.RttClient> CREATOR =
                new Creator<RttManager.RttClient>() {
            @Override
            public RttManager.RttClient createFromParcel(Parcel in) {
                return new RttManager.RttClient(in);
            }

            @Override
            public RttManager.RttClient[] newArray(int size) {
                return new RttManager.RttClient[size];
            }
        };

        @Override
        public int describeContents() {
            return 0;
        }

        @Override
        public void writeToParcel(Parcel parcel, int i) {
            parcel.writeString(mPackageName);
        }

        public String getPackageName() {
            return mPackageName;
        }
    }

    private boolean rttParamSanity(RttParams params, int index) {
        if (mRttCapabilities == null) {
            if(getRttCapabilities() == null) {
@@ -1236,7 +1283,8 @@ public class RttManager {
        mAsyncChannel.connectSync(mContext, handler, messenger);
        // We cannot use fullyConnectSync because it sends the FULL_CONNECTION message
        // synchronously, which causes RttService to receive the wrong replyTo value.
        mAsyncChannel.sendMessage(AsyncChannel.CMD_CHANNEL_FULL_CONNECTION);
        mAsyncChannel.sendMessage(AsyncChannel.CMD_CHANNEL_FULL_CONNECTION,
                new RttClient(context.getPackageName()));
        mAsyncChannel.sendMessage(CMD_OP_REG_BINDER, key[0]);
    }