1 /* 2 * Copyright (C) 2021 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 android.app.smartspace; 18 19 import android.annotation.NonNull; 20 import android.annotation.SystemApi; 21 import android.content.Context; 22 23 import java.util.Objects; 24 25 /** 26 * Smartspace is a container in Android which is used to show contextual content powered by the 27 * intelligence service running on the device. A smartspace container can be on AoD, lockscreen or 28 * on the homescreen and can show personalized cards which are either derived from on device or 29 * online signals. 30 * 31 * {@link SmartspaceManager} is a system service that provides methods to create Smartspace session 32 * clients. An instance of this class is returned when a client calls 33 * <code> context.getSystemService("smartspace"); </code>. 34 * 35 * After receiving the service, a client must call 36 * {@link SmartspaceManager#createSmartspaceSession(SmartspaceConfig)} with a corresponding 37 * {@link SmartspaceConfig} to get an instance of {@link SmartspaceSession}. 38 * This session is then a client's point of contact with the api. They can send events, request for 39 * updates using the session. It is client's duty to call {@link SmartspaceSession#destroy()} to 40 * destroy the session once they no longer need it. 41 * 42 * @hide 43 */ 44 @SystemApi 45 public final class SmartspaceManager { 46 47 private final Context mContext; 48 49 /** 50 * @hide 51 */ SmartspaceManager(Context context)52 public SmartspaceManager(Context context) { 53 mContext = Objects.requireNonNull(context); 54 } 55 56 /** 57 * Creates a new Smartspace session. 58 */ 59 @NonNull createSmartspaceSession( @onNull SmartspaceConfig smartspaceConfig)60 public SmartspaceSession createSmartspaceSession( 61 @NonNull SmartspaceConfig smartspaceConfig) { 62 return new SmartspaceSession(mContext, smartspaceConfig); 63 } 64 } 65