• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2024 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.car.provider;
18 
19 import android.content.ContentResolver;
20 import android.net.Uri;
21 import android.provider.Settings.SettingNotFoundException;
22 
23 /**
24  * An interface to stub methods from {@link android.provider.Settings}.
25  */
26 public interface Settings {
27     /**
28      * @see android.provider.Settings.System#getInt
29      */
getIntSystem(ContentResolver cr, String name)30     int getIntSystem(ContentResolver cr, String name) throws SettingNotFoundException;
31 
32     /**
33      * @see android.provider.Settings.System#putInt
34      */
putIntSystem(ContentResolver cr, String name, int value)35     void putIntSystem(ContentResolver cr, String name, int value);
36 
37     /**
38      * @see android.provider.Settings.System#getUriFor
39      */
getUriForSystem(String name)40     Uri getUriForSystem(String name);
41 
42     /**
43      * @see android.provider.Settings.System#putString
44      */
putStringSystem(ContentResolver resolver, String name, String value)45     boolean putStringSystem(ContentResolver resolver, String name, String value);
46 
47     /**
48      * @see android.provider.Settings.Global.getString
49      */
getStringGlobal(ContentResolver resolver, String name)50     String getStringGlobal(ContentResolver resolver, String name);
51 
52     /**
53      * @see android.provider.Settings.Global.getInt
54      */
getIntGlobal(ContentResolver cr, String name, int def)55     int getIntGlobal(ContentResolver cr, String name, int def);
56 
57     /**
58      * @see android.provider.Settings.Global.putInt
59      */
putIntGlobal(ContentResolver cr, String name, int value)60     boolean putIntGlobal(ContentResolver cr, String name, int value);
61 
62     /**
63      * The default real implementation.
64      */
65     class DefaultImpl implements Settings {
66         @Override
getIntSystem(ContentResolver cr, String name)67         public int getIntSystem(ContentResolver cr, String name) throws SettingNotFoundException {
68             return android.provider.Settings.System.getInt(cr, name);
69         }
70 
71         @Override
putIntSystem(ContentResolver cr, String name, int value)72         public void putIntSystem(ContentResolver cr, String name, int value) {
73             android.provider.Settings.System.putInt(cr, name, value);
74         }
75 
76         @Override
getUriForSystem(String name)77         public Uri getUriForSystem(String name) {
78             return android.provider.Settings.System.getUriFor(name);
79         }
80 
81         @Override
putStringSystem(ContentResolver resolver, String name, String value)82         public boolean putStringSystem(ContentResolver resolver, String name, String value) {
83             return android.provider.Settings.System.putString(resolver, name, value);
84         }
85 
86         @Override
getStringGlobal(ContentResolver resolver, String name)87         public String getStringGlobal(ContentResolver resolver, String name) {
88             return android.provider.Settings.Global.getString(resolver, name);
89         }
90 
91         @Override
getIntGlobal(ContentResolver cr, String name, int def)92         public int getIntGlobal(ContentResolver cr, String name, int def) {
93             return android.provider.Settings.Global.getInt(cr, name, def);
94         }
95 
96         @Override
putIntGlobal(ContentResolver cr, String name, int value)97         public boolean putIntGlobal(ContentResolver cr, String name, int value) {
98             return android.provider.Settings.Global.putInt(cr, name, value);
99         }
100     }
101 }
102