1 /* 2 * Copyright (C) 2021 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 package com.android.launcher3.model; 17 18 import androidx.room.Dao; 19 import androidx.room.Database; 20 import androidx.room.Insert; 21 import androidx.room.OnConflictStrategy; 22 import androidx.room.Query; 23 import androidx.room.RoomDatabase; 24 import androidx.room.Update; 25 26 import java.util.List; 27 28 /** 29 * This database maintains a collection of AppShareabilityStatus items 30 * In its intended use case, there will be one entry for each app installed on the device 31 */ 32 @Database(entities = {AppShareabilityStatus.class}, exportSchema = false, version = 1) 33 public abstract class AppShareabilityDatabase extends RoomDatabase { 34 /** 35 * Data Access Object for this database 36 */ 37 @Dao 38 public interface ShareabilityDao { 39 /** Add an AppShareabilityStatus to the database */ 40 @Insert(onConflict = OnConflictStrategy.REPLACE) insertAppStatus(AppShareabilityStatus status)41 void insertAppStatus(AppShareabilityStatus status); 42 43 /** Add a collection of AppShareabilityStatus objects to the database */ 44 @Insert(onConflict = OnConflictStrategy.REPLACE) insertAppStatuses(AppShareabilityStatus... statuses)45 void insertAppStatuses(AppShareabilityStatus... statuses); 46 47 /** 48 * Update an AppShareabilityStatus in the database 49 * @return The number of entries successfully updated 50 */ 51 @Update updateAppStatus(AppShareabilityStatus status)52 int updateAppStatus(AppShareabilityStatus status); 53 54 /** Retrieve all entries from the database */ 55 @Query("SELECT * FROM AppShareabilityStatus") getAllEntries()56 List<AppShareabilityStatus> getAllEntries(); 57 } 58 shareabilityDao()59 protected abstract ShareabilityDao shareabilityDao(); 60 } 61