[SettingsLibs] Add room DAO for mobile network

Bug: 236919685
Test: manual
Change-Id: I5e6b2169f58b32b29acc535074cf96b2dbf9a6e9
This commit is contained in:
Zoey Chen
2022-09-21 07:44:29 +00:00
parent 1921977940
commit e8c3df87ad
3 changed files with 161 additions and 0 deletions

View File

@@ -0,0 +1,53 @@
/*
* Copyright (C) 2022 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.mobile.dataservice;
import java.util.List;
import androidx.lifecycle.LiveData;
import androidx.room.Dao;
import androidx.room.Insert;
import androidx.room.OnConflictStrategy;
import androidx.room.Query;
@Dao
public interface MobileNetworkInfoDao {
@Insert(onConflict = OnConflictStrategy.REPLACE)
void insertMobileNetworkInfo(MobileNetworkInfoEntity... mobileNetworkInfo);
@Query("SELECT * FROM " + DataServiceUtils.MobileNetworkInfoData.TABLE_NAME + " ORDER BY "
+ DataServiceUtils.MobileNetworkInfoData.COLUMN_ID)
LiveData<List<MobileNetworkInfoEntity>> queryAllMobileNetworkInfos();
@Query("SELECT * FROM " + DataServiceUtils.MobileNetworkInfoData.TABLE_NAME + " WHERE "
+ DataServiceUtils.MobileNetworkInfoData.COLUMN_ID + " = :subId")
LiveData<MobileNetworkInfoEntity> queryMobileNetworkInfoBySubId(String subId);
@Query("SELECT * FROM " + DataServiceUtils.MobileNetworkInfoData.TABLE_NAME + " WHERE "
+ DataServiceUtils.MobileNetworkInfoData.COLUMN_IS_MOBILE_DATA_ENABLED
+ " = :isMobileDataEnabled")
LiveData<List<MobileNetworkInfoEntity>> queryMobileNetworkInfosByMobileDataStatus(
boolean isMobileDataEnabled);
@Query("SELECT COUNT(*) FROM " + DataServiceUtils.MobileNetworkInfoData.TABLE_NAME)
int count();
@Query("DELETE FROM " + DataServiceUtils.MobileNetworkInfoData.TABLE_NAME + " WHERE "
+ DataServiceUtils.MobileNetworkInfoData.COLUMN_ID + " = :subId")
void deleteBySubId(String subId);
}

View File

@@ -0,0 +1,57 @@
/*
* Copyright (C) 2022 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.mobile.dataservice;
import java.util.List;
import androidx.lifecycle.LiveData;
import androidx.room.Dao;
import androidx.room.Insert;
import androidx.room.OnConflictStrategy;
import androidx.room.Query;
import androidx.room.Update;
@Dao
public interface SubscriptionInfoDao {
@Insert(onConflict = OnConflictStrategy.REPLACE)
void insertSubsInfo(SubscriptionInfoEntity... subscriptionInfo);
@Query("SELECT * FROM " + DataServiceUtils.SubscriptionInfoData.TABLE_NAME + " ORDER BY "
+ DataServiceUtils.SubscriptionInfoData.COLUMN_ID)
LiveData<List<SubscriptionInfoEntity>> queryAvailableSubInfos();
@Query("SELECT * FROM " + DataServiceUtils.SubscriptionInfoData.TABLE_NAME + " WHERE "
+ DataServiceUtils.SubscriptionInfoData.COLUMN_ID + " = :subId")
LiveData<SubscriptionInfoEntity> querySubInfoById(String subId);
@Query("SELECT * FROM " + DataServiceUtils.SubscriptionInfoData.TABLE_NAME + " WHERE "
+ DataServiceUtils.SubscriptionInfoData.COLUMN_IS_ACTIVE_SUBSCRIPTION_ID
+ " = :isActiveSubscription" + " AND "
+ DataServiceUtils.SubscriptionInfoData.COLUMN_IS_SUBSCRIPTION_VISIBLE
+ " = :isSubscriptionVisible")
LiveData<List<SubscriptionInfoEntity>> queryActiveSubInfos(
boolean isActiveSubscription, boolean isSubscriptionVisible);
@Query("SELECT COUNT(*) FROM " + DataServiceUtils.SubscriptionInfoData.TABLE_NAME)
int count();
@Query("DELETE FROM " + DataServiceUtils.SubscriptionInfoData.TABLE_NAME + " WHERE "
+ DataServiceUtils.SubscriptionInfoData.COLUMN_ID + " = :id")
void deleteBySubId(String id);
}

View File

@@ -0,0 +1,51 @@
/*
* Copyright (C) 2022 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.mobile.dataservice;
import java.util.List;
import androidx.lifecycle.LiveData;
import androidx.room.Dao;
import androidx.room.Insert;
import androidx.room.OnConflictStrategy;
import androidx.room.Query;
@Dao
public interface UiccInfoDao {
@Insert(onConflict = OnConflictStrategy.REPLACE)
void insertUiccInfo(UiccInfoEntity... uiccInfo);
@Query("SELECT * FROM " + DataServiceUtils.UiccInfoData.TABLE_NAME + " ORDER BY "
+ DataServiceUtils.UiccInfoData.COLUMN_ID)
LiveData<List<UiccInfoEntity>> queryAllUiccInfos();
@Query("SELECT * FROM " + DataServiceUtils.UiccInfoData.TABLE_NAME + " WHERE "
+ DataServiceUtils.UiccInfoData.COLUMN_ID + " = :subId")
LiveData<UiccInfoEntity> queryUiccInfoById(String subId);
@Query("SELECT * FROM " + DataServiceUtils.UiccInfoData.TABLE_NAME + " WHERE "
+ DataServiceUtils.UiccInfoData.COLUMN_IS_EUICC + " = :isEuicc")
LiveData<List<UiccInfoEntity>> queryUiccInfosByEuicc(boolean isEuicc);
@Query("SELECT COUNT(*) FROM " + DataServiceUtils.UiccInfoData.TABLE_NAME)
int count();
@Query("DELETE FROM " + DataServiceUtils.UiccInfoData.TABLE_NAME + " WHERE "
+ DataServiceUtils.UiccInfoData.COLUMN_ID + " = :id")
void deleteBySubId(String id);
}