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

Commit 7093f2f4 authored by Haijie Hong's avatar Haijie Hong
Browse files

Data layer for device details refactor

BUG: 343317785
Test: atest DeviceSettingRepositoryTest
Flag: com.android.settings.flags.enable_bluetooth_device_details_polish
Change-Id: Icb43534a7cbded38bc000f929b77e17cebd5a6f6
parent ad9cfa87
Loading
Loading
Loading
Loading
+14 −2
Original line number Diff line number Diff line
@@ -474,6 +474,19 @@ public class BluetoothUtils {
        return Uri.parse(data);
    }

    /**
     * Gets string metadata from Fast Pair customized fields.
     *
     * @param bluetoothDevice the BluetoothDevice to get metadata
     * @return the string metadata
     */
    @Nullable
    public static String getFastPairCustomizedField(
            @Nullable BluetoothDevice bluetoothDevice, @NonNull String key) {
        String data = getStringMetaData(bluetoothDevice, METADATA_FAST_PAIR_CUSTOMIZED_FIELDS);
        return extraTagValue(key, data);
    }

    /**
     * Get URI Bluetooth metadata for extra control
     *
@@ -481,8 +494,7 @@ public class BluetoothUtils {
     * @return the URI metadata
     */
    public static String getControlUriMetaData(BluetoothDevice bluetoothDevice) {
        String data = getStringMetaData(bluetoothDevice, METADATA_FAST_PAIR_CUSTOMIZED_FIELDS);
        return extraTagValue(KEY_HEARABLE_CONTROL_SLICE, data);
        return getFastPairCustomizedField(bluetoothDevice, KEY_HEARABLE_CONTROL_SLICE);
    }

    /**
+14 −0
Original line number Diff line number Diff line
@@ -21,6 +21,9 @@ import android.os.Parcel;
import android.os.Parcelable;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import java.util.Objects;

/** A data class representing the state of an action/switch preference. */
public class ActionSwitchPreferenceState extends DeviceSettingPreferenceState
@@ -133,4 +136,15 @@ public class ActionSwitchPreferenceState extends DeviceSettingPreferenceState
    public Bundle getExtras() {
        return mExtras;
    }

    @Override
    public boolean equals(@Nullable Object obj) {
        if (!(obj instanceof ActionSwitchPreferenceState other)) return false;
        return mChecked == other.mChecked;
    }

    @Override
    public int hashCode() {
        return Objects.hash(mChecked);
    }
}
+12 −0
Original line number Diff line number Diff line
@@ -21,6 +21,7 @@ import android.os.Parcel;
import android.os.Parcelable;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import java.util.Objects;

@@ -134,4 +135,15 @@ public class DeviceInfo implements Parcelable {
    public Bundle getExtras() {
        return mExtras;
    }

    @Override
    public boolean equals(@Nullable Object obj) {
        if (!(obj instanceof DeviceInfo other)) return false;
        return Objects.equals(mBluetoothAddress, other.getBluetoothAddress());
    }

    @Override
    public int hashCode() {
        return Objects.hash(mBluetoothAddress);
    }
}
+13 −0
Original line number Diff line number Diff line
@@ -21,6 +21,7 @@ import android.os.Parcel;
import android.os.Parcelable;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import java.util.Objects;

@@ -162,4 +163,16 @@ public class DeviceSettingState implements Parcelable {
    public Bundle getExtras() {
        return mExtras;
    }

    @Override
    public boolean equals(@Nullable Object obj) {
        if (!(obj instanceof DeviceSettingState other)) return false;
        return mSettingId == other.mSettingId
                && Objects.equals(mPreferenceState, other.mPreferenceState);
    }

    @Override
    public int hashCode() {
        return Objects.hash(mSettingId, mPreferenceState);
    }
}
+24 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2024 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.settingslib.bluetooth.devicesettings;

import com.android.settingslib.bluetooth.devicesettings.DeviceInfo;
import com.android.settingslib.bluetooth.devicesettings.DeviceSettingsConfig;

interface IDeviceSettingsConfigProviderService {
   DeviceSettingsConfig getDeviceSettingsConfig(in DeviceInfo device);
}
 No newline at end of file
Loading