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.cts.devicepolicy.contentcaptureservice; 18 19 import android.content.ComponentName; 20 import android.service.contentcapture.ContentCaptureService; 21 import android.util.ArraySet; 22 import android.util.Log; 23 import android.view.contentcapture.ContentCaptureContext; 24 import android.view.contentcapture.ContentCaptureSessionId; 25 26 public class SimpleContentCaptureService extends ContentCaptureService { 27 28 private static final String TAG = SimpleContentCaptureService.class.getSimpleName(); 29 30 @Override onConnected()31 public void onConnected() { 32 Log.d(TAG, "onConnected()"); 33 final ArraySet<String> packages = new ArraySet<>(); 34 packages.add("com.android.cts.devicepolicy.contentcaptureapp"); 35 packages.add("com.android.cts.devicepolicy.contentcaptureservice"); 36 packages.add("com.android.cts.deviceandprofileowner"); 37 38 setContentCaptureWhitelist(packages, null); 39 } 40 41 @Override onDisconnected()42 public void onDisconnected() { 43 Log.d(TAG, "onDisconnected()"); 44 } 45 46 @Override onCreateContentCaptureSession(ContentCaptureContext context, ContentCaptureSessionId sessionId)47 public void onCreateContentCaptureSession(ContentCaptureContext context, 48 ContentCaptureSessionId sessionId) { 49 Log.d(TAG, "onCreateContentCaptureSession(): " + sessionId); 50 } 51 } 52