• Home
  • History
  • Annotate
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2020 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.systemui.util.settings;
18 
19 import android.content.ContentResolver;
20 import android.net.Uri;
21 import android.provider.Settings;
22 
23 import androidx.annotation.NonNull;
24 
25 import com.android.systemui.settings.UserTracker;
26 
27 import javax.inject.Inject;
28 
29 class SystemSettingsImpl implements SystemSettings {
30     private final ContentResolver mContentResolver;
31     private final UserTracker mUserTracker;
32 
33     @Inject
SystemSettingsImpl(ContentResolver contentResolver, UserTracker userTracker)34     SystemSettingsImpl(ContentResolver contentResolver, UserTracker userTracker) {
35         mContentResolver = contentResolver;
36         mUserTracker = userTracker;
37     }
38 
39     @Override
getContentResolver()40     public ContentResolver getContentResolver() {
41         return mContentResolver;
42     }
43 
44     @Override
getUserTracker()45     public UserTracker getUserTracker() {
46         return mUserTracker;
47     }
48 
49     @Override
getUriFor(String name)50     public Uri getUriFor(String name) {
51         return Settings.System.getUriFor(name);
52     }
53 
54     @Override
getStringForUser(String name, int userHandle)55     public String getStringForUser(String name, int userHandle) {
56         return Settings.System.getStringForUser(mContentResolver, name,
57                 getRealUserHandle(userHandle));
58     }
59 
60     @Override
putString(String name, String value, boolean overrideableByRestore)61     public boolean putString(String name, String value, boolean overrideableByRestore) {
62         return Settings.System.putString(mContentResolver, name, value, overrideableByRestore);
63     }
64 
65     @Override
putStringForUser(String name, String value, int userHandle)66     public boolean putStringForUser(String name, String value, int userHandle) {
67         return Settings.System.putStringForUser(mContentResolver, name, value,
68                 getRealUserHandle(userHandle));
69     }
70 
71     @Override
putStringForUser(String name, String value, String tag, boolean makeDefault, int userHandle, boolean overrideableByRestore)72     public boolean putStringForUser(String name, String value, String tag, boolean makeDefault,
73             int userHandle, boolean overrideableByRestore) {
74         throw new UnsupportedOperationException(
75                 "This method only exists publicly for Settings.Secure and Settings.Global");
76     }
77 
78     @Override
putString(@onNull String name, String value, String tag, boolean makeDefault)79     public boolean putString(@NonNull String name, String value, String tag, boolean makeDefault) {
80         throw new UnsupportedOperationException(
81                 "This method only exists publicly for Settings.Secure and Settings.Global");
82     }
83 }
84