Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 7a3c9f53 authored by Felipe Leme's avatar Felipe Leme
Browse files

Changed ContentCaptureService.setContentCaptureWhitelist() to use Set instead of List.

(Same for Augmented Autofill)

Bug: 122595322
Test: m update-api

Change-Id: I6753ce2567801da148682c0ccbad7f6abc4d1ecc
parent b45f78f1
Loading
Loading
Loading
Loading
+4 −2
Original line number Diff line number Diff line
@@ -6346,7 +6346,8 @@ package android.service.contentcapture {
    method public void onDestroyContentCaptureSession(@NonNull android.view.contentcapture.ContentCaptureSessionId);
    method public void onDisconnected();
    method public void onUserDataRemovalRequest(@NonNull android.view.contentcapture.UserDataRemovalRequest);
    method public final void setContentCaptureWhitelist(@Nullable java.util.List<java.lang.String>, @Nullable java.util.List<android.content.ComponentName>);
    method @Deprecated public final void setContentCaptureWhitelist(@Nullable java.util.List<java.lang.String>, @Nullable java.util.List<android.content.ComponentName>);
    method public final void setContentCaptureWhitelist(@Nullable java.util.Set<java.lang.String>, @Nullable java.util.Set<android.content.ComponentName>);
    field public static final String SERVICE_INTERFACE = "android.service.contentcapture.ContentCaptureService";
  }
@@ -9303,7 +9304,8 @@ package android.view.accessibility {
package android.view.autofill {
  public final class AutofillManager {
    method public void setAugmentedAutofillWhitelist(@Nullable java.util.List<java.lang.String>, @Nullable java.util.List<android.content.ComponentName>);
    method @Deprecated public void setAugmentedAutofillWhitelist(@Nullable java.util.List<java.lang.String>, @Nullable java.util.List<android.content.ComponentName>);
    method public void setAugmentedAutofillWhitelist(@Nullable java.util.Set<java.lang.String>, @Nullable java.util.Set<android.content.ComponentName>);
  }
}
+4 −2
Original line number Diff line number Diff line
@@ -2103,7 +2103,8 @@ package android.service.contentcapture {
    method public void onDestroyContentCaptureSession(@NonNull android.view.contentcapture.ContentCaptureSessionId);
    method public void onDisconnected();
    method public void onUserDataRemovalRequest(@NonNull android.view.contentcapture.UserDataRemovalRequest);
    method public final void setContentCaptureWhitelist(@Nullable java.util.List<java.lang.String>, @Nullable java.util.List<android.content.ComponentName>);
    method @Deprecated public final void setContentCaptureWhitelist(@Nullable java.util.List<java.lang.String>, @Nullable java.util.List<android.content.ComponentName>);
    method public final void setContentCaptureWhitelist(@Nullable java.util.Set<java.lang.String>, @Nullable java.util.Set<android.content.ComponentName>);
    field public static final String SERVICE_INTERFACE = "android.service.contentcapture.ContentCaptureService";
  }

@@ -2692,7 +2693,8 @@ package android.view.autofill {
  }

  public final class AutofillManager {
    method public void setAugmentedAutofillWhitelist(@Nullable java.util.List<java.lang.String>, @Nullable java.util.List<android.content.ComponentName>);
    method @Deprecated public void setAugmentedAutofillWhitelist(@Nullable java.util.List<java.lang.String>, @Nullable java.util.List<android.content.ComponentName>);
    method public void setAugmentedAutofillWhitelist(@Nullable java.util.Set<java.lang.String>, @Nullable java.util.Set<android.content.ComponentName>);
    field public static final String DEVICE_CONFIG_AUTOFILL_SMART_SUGGESTION_SUPPORTED_MODES = "smart_suggestion_supported_modes";
    field public static final int FLAG_SMART_SUGGESTION_OFF = 0; // 0x0
    field public static final int FLAG_SMART_SUGGESTION_SYSTEM = 1; // 0x1
+25 −10
Original line number Diff line number Diff line
@@ -49,7 +49,9 @@ import com.android.internal.os.IResultReceiver;

import java.io.FileDescriptor;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;

/**
 * A service used to capture the content of the screen to provide contextual data in other areas of
@@ -164,17 +166,9 @@ public abstract class ContentCaptureService extends Service {
    }

    /**
     * Explicitly limits content capture to the given packages and activities.
     *
     * <p>To reset the whitelist, call it passing {@code null} to both arguments.
     *
     * <p>Useful when the service wants to restrict content capture to a category of apps, like
     * chat apps. For example, if the service wants to support view captures on all activities of
     * app {@code ChatApp1} and just activities {@code act1} and {@code act2} of {@code ChatApp2},
     * it would call: {@code setContentCaptureWhitelist(Arrays.asList("ChatApp1"),
     * Arrays.asList(new ComponentName("ChatApp2", "act1"),
     * new ComponentName("ChatApp2", "act2")));}
     * @deprecated use {@link #setContentCaptureWhitelist(Set, Set)} instead
     */
    @Deprecated
    public final void setContentCaptureWhitelist(@Nullable List<String> packages,
            @Nullable List<ComponentName> activities) {
        final IContentCaptureServiceCallback callback = mCallback;
@@ -189,6 +183,27 @@ public abstract class ContentCaptureService extends Service {
        }
    }

    /**
     * Explicitly limits content capture to the given packages and activities.
     *
     * <p>To reset the whitelist, call it passing {@code null} to both arguments.
     *
     * <p>Useful when the service wants to restrict content capture to a category of apps, like
     * chat apps. For example, if the service wants to support view captures on all activities of
     * app {@code ChatApp1} and just activities {@code act1} and {@code act2} of {@code ChatApp2},
     * it would call: {@code setContentCaptureWhitelist(Sets.newArraySet("ChatApp1"),
     * Sets.newArraySet(new ComponentName("ChatApp2", "act1"),
     * new ComponentName("ChatApp2", "act2")));}
     */
    public final void setContentCaptureWhitelist(@Nullable Set<String> packages,
            @Nullable Set<ComponentName> activities) {
        setContentCaptureWhitelist(toList(packages), toList(activities));
    }

    private <T> ArrayList<T> toList(@Nullable Set<T> set) {
        return set == null ? null : new ArrayList<T>(set);
    }

    /**
     * Called when the Android system connects to service.
     *
+15 −2
Original line number Diff line number Diff line
@@ -78,6 +78,7 @@ import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Objects;
import java.util.Set;

//TODO: use java.lang.ref.Cleaner once Android supports Java 9
import sun.misc.Cleaner;
@@ -1779,6 +1780,18 @@ public final class AutofillManager {
        }
    }

    /**
     * @deprecated use {@link #setAugmentedAutofillWhitelist(Set, Set)} instead.
     * @hide
     */
    @SystemApi
    @TestApi
    @Deprecated
    public void setAugmentedAutofillWhitelist(@Nullable List<String> packages,
            @Nullable List<ComponentName> activities) {
        // TODO(b/123100824): implement
    }

    /**
     * Explicitly limits augmented autofill to the given packages and activities.
     *
@@ -1799,8 +1812,8 @@ public final class AutofillManager {
     */
    @SystemApi
    @TestApi
    public void setAugmentedAutofillWhitelist(@Nullable List<String> packages,
            @Nullable List<ComponentName> activities) {
    public void setAugmentedAutofillWhitelist(@Nullable Set<String> packages,
            @Nullable Set<ComponentName> activities) {
        // TODO(b/123100824): implement
    }