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

Commit 2d29d34f authored by Eugene Susla's avatar Eugene Susla Committed by Android (Google) Code Review
Browse files

Merge "[DO NOT MERGE] Scan and notify apps when their companion devices are nearby" into sc-dev

parents abffec26 6ce1f410
Loading
Loading
Loading
Loading
+55 −0
Original line number Diff line number Diff line
@@ -3197,6 +3197,61 @@ public final class BluetoothAdapter {
        void onLeScan(BluetoothDevice device, int rssi, byte[] scanRecord);
    }

    /**
     * Register a callback to receive events whenever the bluetooth stack goes down and back up,
     * e.g. in the event the bluetooth is turned off/on via settings.
     *
     * If the bluetooth stack is currently up, there will not be an initial callback call.
     * You can use the return value as an indication of this being the case.
     *
     * Callbacks will be delivered on a binder thread.
     *
     * @return whether bluetooth is already up currently
     *
     * @hide
     */
    public boolean registerServiceLifecycleCallback(ServiceLifecycleCallback callback) {
        return getBluetoothService(callback.mRemote) != null;
    }

    /**
     * Unregister a callback registered via {@link #registerServiceLifecycleCallback}
     *
     * @hide
     */
    public void unregisterServiceLifecycleCallback(ServiceLifecycleCallback callback) {
        removeServiceStateCallback(callback.mRemote);
    }

    /**
     * A callback for {@link #registerServiceLifecycleCallback}
     *
     * @hide
     */
    public abstract static class ServiceLifecycleCallback {

        /** Called when the bluetooth stack is up */
        public abstract void onBluetoothServiceUp();

        /** Called when the bluetooth stack is down */
        public abstract void onBluetoothServiceDown();

        IBluetoothManagerCallback mRemote = new IBluetoothManagerCallback.Stub() {
            @Override
            public void onBluetoothServiceUp(IBluetooth bluetoothService) {
                ServiceLifecycleCallback.this.onBluetoothServiceUp();
            }

            @Override
            public void onBluetoothServiceDown() {
                ServiceLifecycleCallback.this.onBluetoothServiceDown();
            }

            @Override
            public void onBrEdrDown() {}
        };
    }

    /**
     * Starts a scan for Bluetooth LE devices.
     *
+15 −15
Original line number Diff line number Diff line
@@ -38,7 +38,7 @@ public final class Association implements Parcelable {
    private final @NonNull String mDeviceMacAddress;
    private final @NonNull String mPackageName;
    private final @Nullable String mDeviceProfile;
    private final boolean mKeepProfilePrivilegesWhenDeviceAway;
    private final boolean mNotifyOnDeviceNearby;

    /** @hide */
    public int getUserId() {
@@ -47,7 +47,7 @@ public final class Association implements Parcelable {



    // Code below generated by codegen v1.0.21.
    // Code below generated by codegen v1.0.22.
    //
    // DO NOT MODIFY!
    // CHECKSTYLE:OFF Generated code
@@ -71,7 +71,7 @@ public final class Association implements Parcelable {
            @NonNull String deviceMacAddress,
            @NonNull String packageName,
            @Nullable String deviceProfile,
            boolean keepProfilePrivilegesWhenDeviceAway) {
            boolean notifyOnDeviceNearby) {
        this.mUserId = userId;
        com.android.internal.util.AnnotationValidations.validate(
                UserIdInt.class, null, mUserId);
@@ -82,7 +82,7 @@ public final class Association implements Parcelable {
        com.android.internal.util.AnnotationValidations.validate(
                NonNull.class, null, mPackageName);
        this.mDeviceProfile = deviceProfile;
        this.mKeepProfilePrivilegesWhenDeviceAway = keepProfilePrivilegesWhenDeviceAway;
        this.mNotifyOnDeviceNearby = notifyOnDeviceNearby;

        // onConstructed(); // You can define this method to get a callback
    }
@@ -103,8 +103,8 @@ public final class Association implements Parcelable {
    }

    @DataClass.Generated.Member
    public boolean isKeepProfilePrivilegesWhenDeviceAway() {
        return mKeepProfilePrivilegesWhenDeviceAway;
    public boolean isNotifyOnDeviceNearby() {
        return mNotifyOnDeviceNearby;
    }

    @Override
@@ -118,7 +118,7 @@ public final class Association implements Parcelable {
                "deviceMacAddress = " + mDeviceMacAddress + ", " +
                "packageName = " + mPackageName + ", " +
                "deviceProfile = " + mDeviceProfile + ", " +
                "keepProfilePrivilegesWhenDeviceAway = " + mKeepProfilePrivilegesWhenDeviceAway +
                "notifyOnDeviceNearby = " + mNotifyOnDeviceNearby +
        " }";
    }

@@ -139,7 +139,7 @@ public final class Association implements Parcelable {
                && Objects.equals(mDeviceMacAddress, that.mDeviceMacAddress)
                && Objects.equals(mPackageName, that.mPackageName)
                && Objects.equals(mDeviceProfile, that.mDeviceProfile)
                && mKeepProfilePrivilegesWhenDeviceAway == that.mKeepProfilePrivilegesWhenDeviceAway;
                && mNotifyOnDeviceNearby == that.mNotifyOnDeviceNearby;
    }

    @Override
@@ -153,7 +153,7 @@ public final class Association implements Parcelable {
        _hash = 31 * _hash + Objects.hashCode(mDeviceMacAddress);
        _hash = 31 * _hash + Objects.hashCode(mPackageName);
        _hash = 31 * _hash + Objects.hashCode(mDeviceProfile);
        _hash = 31 * _hash + Boolean.hashCode(mKeepProfilePrivilegesWhenDeviceAway);
        _hash = 31 * _hash + Boolean.hashCode(mNotifyOnDeviceNearby);
        return _hash;
    }

@@ -164,7 +164,7 @@ public final class Association implements Parcelable {
        // void parcelFieldName(Parcel dest, int flags) { ... }

        byte flg = 0;
        if (mKeepProfilePrivilegesWhenDeviceAway) flg |= 0x10;
        if (mNotifyOnDeviceNearby) flg |= 0x10;
        if (mDeviceProfile != null) flg |= 0x8;
        dest.writeByte(flg);
        dest.writeInt(mUserId);
@@ -185,7 +185,7 @@ public final class Association implements Parcelable {
        // static FieldType unparcelFieldName(Parcel in) { ... }

        byte flg = in.readByte();
        boolean keepProfilePrivilegesWhenDeviceAway = (flg & 0x10) != 0;
        boolean notifyOnDeviceNearby = (flg & 0x10) != 0;
        int userId = in.readInt();
        String deviceMacAddress = in.readString();
        String packageName = in.readString();
@@ -201,7 +201,7 @@ public final class Association implements Parcelable {
        com.android.internal.util.AnnotationValidations.validate(
                NonNull.class, null, mPackageName);
        this.mDeviceProfile = deviceProfile;
        this.mKeepProfilePrivilegesWhenDeviceAway = keepProfilePrivilegesWhenDeviceAway;
        this.mNotifyOnDeviceNearby = notifyOnDeviceNearby;

        // onConstructed(); // You can define this method to get a callback
    }
@@ -221,10 +221,10 @@ public final class Association implements Parcelable {
    };

    @DataClass.Generated(
            time = 1606940835778L,
            codegenVersion = "1.0.21",
            time = 1610482674799L,
            codegenVersion = "1.0.22",
            sourceFile = "frameworks/base/core/java/android/companion/Association.java",
            inputSignatures = "private final @android.annotation.UserIdInt int mUserId\nprivate final @android.annotation.NonNull java.lang.String mDeviceMacAddress\nprivate final @android.annotation.NonNull java.lang.String mPackageName\nprivate final @android.annotation.Nullable java.lang.String mDeviceProfile\nprivate final  boolean mKeepProfilePrivilegesWhenDeviceAway\npublic  int getUserId()\nclass Association extends java.lang.Object implements [android.os.Parcelable]\n@com.android.internal.util.DataClass(genEqualsHashCode=true, genToString=true, genHiddenConstructor=true)")
            inputSignatures = "private final @android.annotation.UserIdInt int mUserId\nprivate final @android.annotation.NonNull java.lang.String mDeviceMacAddress\nprivate final @android.annotation.NonNull java.lang.String mPackageName\nprivate final @android.annotation.Nullable java.lang.String mDeviceProfile\nprivate final  boolean mNotifyOnDeviceNearby\npublic  int getUserId()\nclass Association extends java.lang.Object implements [android.os.Parcelable]\n@com.android.internal.util.DataClass(genEqualsHashCode=true, genToString=true, genHiddenConstructor=true)")
    @Deprecated
    private void __metadata() {}

+296 −15

File changed.

Preview size limit exceeded, changes collapsed.