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

Commit 799af024 authored by Ugo Yu's avatar Ugo Yu
Browse files

Change database package name align with the directory name

* Change database package name to btservice.storage to align with
  the directory name.
* Add missed annotation processor to fix Room database sometimes
  failed to generate implementation files and cause Bluetooth crash.

Bug: 123316789
Bug: 123312335
Test: Manual
Change-Id: I2b6b1ce1b67eebe289fa3c8153fd296b1ee8cf19
parent 38c3e8c7
Loading
Loading
Loading
Loading
+4 −1
Original line number Diff line number Diff line
@@ -26,10 +26,10 @@ LOCAL_STATIC_JAVA_LIBRARIES := \
        services.net \
        libprotobuf-java-lite \
        bluetooth-protos-lite \
        androidx.lifecycle_lifecycle-livedata \

LOCAL_STATIC_ANDROID_LIBRARIES := \
        androidx.core_core \
        androidx.lifecycle_lifecycle-livedata \
        androidx.room_room-runtime \

LOCAL_ANNOTATION_PROCESSORS := \
@@ -47,6 +47,9 @@ LOCAL_ANNOTATION_PROCESSORS := \
        guava-21.0 \
        kotlin-stdlib

LOCAL_ANNOTATION_PROCESSOR_CLASSES := \
        androidx.room.RoomProcessor

LOCAL_REQUIRED_MODULES := libbluetooth
LOCAL_PROGUARD_ENABLED := disabled
include $(BUILD_PACKAGE)
+2 −0
Original line number Diff line number Diff line
@@ -70,6 +70,8 @@ import androidx.room.Room;
import com.android.bluetooth.BluetoothMetricsProto;
import com.android.bluetooth.Utils;
import com.android.bluetooth.btservice.RemoteDevices.DeviceProperties;
import com.android.bluetooth.btservice.storage.DatabaseManager;
import com.android.bluetooth.btservice.storage.MetadataDatabase;
import com.android.bluetooth.gatt.GattService;
import com.android.bluetooth.sdp.SdpManager;
import com.android.internal.R;
+1 −1
Original line number Diff line number Diff line
@@ -14,7 +14,7 @@
 * limitations under the License.
 */

package com.android.bluetooth.btservice;
package com.android.bluetooth.btservice.storage;

import androidx.room.Entity;

+20 −5
Original line number Diff line number Diff line
@@ -14,7 +14,7 @@
 * limitations under the License.
 */

package com.android.bluetooth.btservice;
package com.android.bluetooth.btservice.storage;

import android.bluetooth.BluetoothA2dp;
import android.bluetooth.BluetoothAdapter;
@@ -32,6 +32,7 @@ import android.os.Message;
import android.provider.Settings;
import android.util.Log;

import com.android.bluetooth.btservice.AdapterService;
import com.android.internal.annotations.VisibleForTesting;

import java.util.HashMap;
@@ -67,7 +68,10 @@ public class DatabaseManager {
    private static final int MSG_CLEAR_DATABASE = 100;
    private static final String LOCAL_STORAGE = "LocalStorage";

    DatabaseManager(AdapterService service) {
    /**
     * Constructor of the DatabaseManager
     */
    public DatabaseManager(AdapterService service) {
        mAdapterService = service;
    }

@@ -500,7 +504,12 @@ public class DatabaseManager {
        return mHandlerThread.getLooper();
    }

    void start(MetadataDatabase database) {
    /**
     * Start and initialize the DatabaseManager
     *
     * @param database the Bluetooth storage {@link MetadataDatabase}
     */
    public void start(MetadataDatabase database) {
        if (DBG) {
            Log.d(TAG, "start()");
        }
@@ -535,13 +544,19 @@ public class DatabaseManager {
                .getAbsolutePath();
    }

    void factoryReset() {
    /**
     * Clear all persistence data in database
     */
    public void factoryReset() {
        Log.w(TAG, "factoryReset");
        Message message = mHandler.obtainMessage(MSG_CLEAR_DATABASE);
        mHandler.sendMessage(message);
    }

    void cleanup() {
    /**
     * Close and de-init the DatabaseManager
     */
    public void cleanup() {
        removeUnusedMetadata();
        mAdapterService.unregisterReceiver(mReceiver);
        if (mHandlerThread != null) {
+1 −1
Original line number Diff line number Diff line
@@ -14,7 +14,7 @@
 * limitations under the License.
 */

package com.android.bluetooth.btservice;
package com.android.bluetooth.btservice.storage;

import android.bluetooth.BluetoothA2dp;
import android.bluetooth.BluetoothDevice;
Loading