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.settings.dashboard; 18 19 import static com.android.settingslib.drawer.TileUtils.META_DATA_PREFERENCE_SUMMARY; 20 21 import android.content.ContentProvider; 22 import android.content.ContentValues; 23 import android.content.Context; 24 import android.content.pm.UserInfo; 25 import android.database.Cursor; 26 import android.net.Uri; 27 import android.os.Bundle; 28 import android.os.UserHandle; 29 import android.os.UserManager; 30 31 import com.android.settings.R; 32 import com.android.settings.backup.BackupSettingsHelper; 33 34 /** Provide preference summary for injected items. */ 35 public class SummaryProvider extends ContentProvider { 36 private static final String BACKUP = "backup"; 37 private static final String USER = "user"; 38 39 @Override call(String method, String uri, Bundle extras)40 public Bundle call(String method, String uri, Bundle extras) { 41 final Bundle bundle = new Bundle(); 42 switch (method) { 43 case BACKUP: 44 bundle.putString(META_DATA_PREFERENCE_SUMMARY, 45 new BackupSettingsHelper(getContext()).getSummary()); 46 break; 47 case USER: 48 final Context context = getContext(); 49 final UserInfo info = context.getSystemService(UserManager.class).getUserInfo( 50 UserHandle.myUserId()); 51 bundle.putString(META_DATA_PREFERENCE_SUMMARY, 52 context.getString(R.string.users_summary, 53 info.name)); 54 break; 55 default: 56 throw new IllegalArgumentException("Unknown Uri format: " + uri); 57 } 58 return bundle; 59 } 60 61 @Override onCreate()62 public boolean onCreate() { 63 return true; 64 } 65 66 @Override query(Uri uri, String[] projection, String selection, String[] selectionArgs, String sortOrder)67 public Cursor query(Uri uri, String[] projection, String selection, String[] selectionArgs, 68 String sortOrder) { 69 throw new UnsupportedOperationException(); 70 } 71 72 @Override getType(Uri uri)73 public String getType(Uri uri) { 74 throw new UnsupportedOperationException(); 75 } 76 77 @Override insert(Uri uri, ContentValues values)78 public Uri insert(Uri uri, ContentValues values) { 79 throw new UnsupportedOperationException(); 80 } 81 82 @Override delete(Uri uri, String selection, String[] selectionArgs)83 public int delete(Uri uri, String selection, String[] selectionArgs) { 84 throw new UnsupportedOperationException(); 85 } 86 87 @Override update(Uri uri, ContentValues values, String selection, String[] selectionArgs)88 public int update(Uri uri, ContentValues values, String selection, String[] selectionArgs) { 89 throw new UnsupportedOperationException(); 90 } 91 } 92