Felipe Leme | 1dfa9a0 | 2018-10-17 17:24:37 -0700 | [diff] [blame^] | 1 | /* |
| 2 | * Copyright (C) 2018 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 | package android.view.intelligence; |
| 17 | |
| 18 | import android.annotation.NonNull; |
| 19 | import android.annotation.Nullable; |
| 20 | import android.annotation.SystemApi; |
| 21 | import android.content.ComponentName; |
| 22 | import android.content.Context; |
| 23 | |
| 24 | import com.android.internal.util.Preconditions; |
| 25 | |
| 26 | import java.util.Set; |
| 27 | |
| 28 | /** |
| 29 | * TODO(b/111276913): add javadocs / implement / add SystemService / PackageFeature |
| 30 | */ |
| 31 | public final class IntelligenceManager { |
| 32 | |
| 33 | /** |
| 34 | * Used to indicate that a text change was caused by user input (for example, through IME). |
| 35 | */ |
| 36 | //TODO(b/111276913): link to notifyTextChanged() method once available |
| 37 | public static final int FLAG_USER_INPUT = 0x1; |
| 38 | |
| 39 | private final Context mContext; |
| 40 | |
| 41 | /** @hide */ |
| 42 | public IntelligenceManager(@NonNull Context context) { |
| 43 | mContext = Preconditions.checkNotNull(context, "context cannot be null"); |
| 44 | } |
| 45 | |
| 46 | /** |
| 47 | * Returns the component name of the {@link android.service.intelligence.IntelligenceService} |
| 48 | * that is enabled for the current user. |
| 49 | */ |
| 50 | @Nullable |
| 51 | public ComponentName getIntelligenceServiceComponentName() { |
| 52 | //TODO(b/111276913): implement |
| 53 | return null; |
| 54 | } |
| 55 | |
| 56 | /** |
| 57 | * Checks whether contents capture is enabled for this activity. |
| 58 | */ |
| 59 | public boolean isContentCaptureEnabled() { |
| 60 | //TODO(b/111276913): implement |
| 61 | return false; |
| 62 | } |
| 63 | |
| 64 | /** |
| 65 | * Called by apps to disable content capture. |
| 66 | * |
| 67 | * <p><b>Note: </b> this call is not persisted accross reboots, so apps should typically call |
| 68 | * it on {@link android.app.Activity#onCreate(android.os.Bundle, android.os.PersistableBundle)}. |
| 69 | */ |
| 70 | public void disableContentCapture() { |
| 71 | } |
| 72 | |
| 73 | /** |
| 74 | * Called by the the service {@link android.service.intelligence.IntelligenceService} |
| 75 | * to define whether content capture should be enabled for activities with such |
| 76 | * {@link android.content.ComponentName}. |
| 77 | * |
| 78 | * <p>Useful to blacklist a particular activity. |
| 79 | * |
| 80 | * @throws UnsupportedOperationException if not called by the UID that owns the |
| 81 | * {@link android.service.intelligence.IntelligenceService} associated with the |
| 82 | * current user. |
| 83 | * |
| 84 | * @hide |
| 85 | */ |
| 86 | @SystemApi |
| 87 | public void setActivityContentCaptureEnabled(@NonNull ComponentName activity, |
| 88 | boolean enabled) { |
| 89 | //TODO(b/111276913): implement |
| 90 | } |
| 91 | |
| 92 | /** |
| 93 | * Called by the the service {@link android.service.intelligence.IntelligenceService} |
| 94 | * to define whether content capture should be enabled for activities of the app with such |
| 95 | * {@code packageName}. |
| 96 | * |
| 97 | * <p>Useful to blacklist any activity from a particular app. |
| 98 | * |
| 99 | * @throws UnsupportedOperationException if not called by the UID that owns the |
| 100 | * {@link android.service.intelligence.IntelligenceService} associated with the |
| 101 | * current user. |
| 102 | * |
| 103 | * @hide |
| 104 | */ |
| 105 | @SystemApi |
| 106 | public void setPackageContentCaptureEnabled(@NonNull String packageName, boolean enabled) { |
| 107 | //TODO(b/111276913): implement |
| 108 | } |
| 109 | |
| 110 | /** |
| 111 | * Gets the activities where content capture was disabled by |
| 112 | * {@link #setActivityContentCaptureEnabled(ComponentName, boolean)}. |
| 113 | * |
| 114 | * @throws UnsupportedOperationException if not called by the UID that owns the |
| 115 | * {@link android.service.intelligence.IntelligenceService} associated with the |
| 116 | * current user. |
| 117 | * |
| 118 | * @hide |
| 119 | */ |
| 120 | @SystemApi |
| 121 | @NonNull |
| 122 | public Set<ComponentName> getContentCaptureDisabledActivities() { |
| 123 | //TODO(b/111276913): implement |
| 124 | return null; |
| 125 | } |
| 126 | |
| 127 | /** |
| 128 | * Gets the apps where content capture was disabled by |
| 129 | * {@link #setPackageContentCaptureEnabled(String, boolean)}. |
| 130 | * |
| 131 | * @throws UnsupportedOperationException if not called by the UID that owns the |
| 132 | * {@link android.service.intelligence.IntelligenceService} associated with the |
| 133 | * current user. |
| 134 | * |
| 135 | * @hide |
| 136 | */ |
| 137 | @SystemApi |
| 138 | @NonNull |
| 139 | public Set<String> getContentCaptureDisabledPackages() { |
| 140 | //TODO(b/111276913): implement |
| 141 | return null; |
| 142 | } |
| 143 | } |