• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2019 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 
17 package com.android.services.telephony;
18 
19 import android.content.Context;
20 import android.provider.Settings;
21 import android.telecom.TelecomManager;
22 
23 import com.android.internal.telephony.PhoneConstants;
24 import com.android.phone.R;
25 
26 /**
27  * Abstracts device state and settings for better testability.
28  */
29 public class DeviceState {
30 
shouldCheckSimStateBeforeOutgoingCall(Context context)31     public boolean shouldCheckSimStateBeforeOutgoingCall(Context context) {
32         return context.getResources().getBoolean(
33                 R.bool.config_checkSimStateBeforeOutgoingCall);
34     }
35 
isSuplDdsSwitchRequiredForEmergencyCall(Context context)36     public boolean isSuplDdsSwitchRequiredForEmergencyCall(Context context) {
37         return context.getResources().getBoolean(
38                 R.bool.config_gnss_supl_requires_default_data_for_emergency);
39     }
40 
isRadioPowerDownAllowedOnBluetooth(Context context)41     public boolean isRadioPowerDownAllowedOnBluetooth(Context context) {
42         return context.getResources().getBoolean(R.bool.config_allowRadioPowerDownOnBluetooth);
43     }
44 
isAirplaneModeOn(Context context)45     public boolean isAirplaneModeOn(Context context) {
46         return Settings.Global.getInt(context.getContentResolver(),
47                 Settings.Global.AIRPLANE_MODE_ON, 0) > 0;
48     }
49 
getCellOnStatus(Context context)50     public int getCellOnStatus(Context context) {
51         return Settings.Global.getInt(context.getContentResolver(), Settings.Global.CELL_ON,
52                 PhoneConstants.CELL_ON_FLAG);
53     }
54 
isTtyModeEnabled(Context context)55     public boolean isTtyModeEnabled(Context context) {
56         return android.provider.Settings.Secure.getInt(context.getContentResolver(),
57                 android.provider.Settings.Secure.PREFERRED_TTY_MODE,
58                 TelecomManager.TTY_MODE_OFF) != TelecomManager.TTY_MODE_OFF;
59     }
60 }
61