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

Commit 61f794a7 authored by Chirag Shah's avatar Chirag Shah
Browse files

Allow 3P apps to provide structured data within AssistContent.

For providing structured metadata to the assistant, we've decided to
standardize on JSON-LD (met with Paige/Ulas/Fabian), and decided the
data to be specified via:

AssistContent.setStructuredData(String structuredDataJson)

This method can be documented for 3P developers as allowing developers
to provide metadata to the assistant with the JSON-LD standard.

This would be centered more about content displayed on the screen,
rather than actions based, so we added it to the AssistContent class

Updated doc: go/setStructuredData

Change-Id: I816f69fd6896df822e30d6c71d840bd01f47e544
parent 2d4dc8db
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -4019,10 +4019,12 @@ package android.app {
    ctor public AssistContent();
    method public android.content.ClipData getClipData();
    method public android.os.Bundle getExtras();
    method public java.lang.String getStructuredData();
    method public android.net.Uri getWebUri();
    method public boolean isAppProvidedIntent();
    method public void setClipData(android.content.ClipData);
    method public void setIntent(android.content.Intent);
    method public void setStructuredData(java.lang.String);
    method public void setWebUri(android.net.Uri);
  }
+2 −0
Original line number Diff line number Diff line
@@ -4114,10 +4114,12 @@ package android.app {
    ctor public AssistContent();
    method public android.content.ClipData getClipData();
    method public android.os.Bundle getExtras();
    method public java.lang.String getStructuredData();
    method public android.net.Uri getWebUri();
    method public boolean isAppProvidedIntent();
    method public void setClipData(android.content.ClipData);
    method public void setIntent(android.content.Intent);
    method public void setStructuredData(java.lang.String);
    method public void setWebUri(android.net.Uri);
  }
+26 −0
Original line number Diff line number Diff line
@@ -33,6 +33,7 @@ import android.os.Parcelable;
public class AssistContent {
    private boolean mIsAppProvidedIntent = false;
    private Intent mIntent;
    private String mStructuredData;
    private ClipData mClipData;
    private Uri mUri;
    private final Bundle mExtras;
@@ -124,6 +125,22 @@ public class AssistContent {
        return mClipData;
    }

    /**
     * Sets optional structured data regarding the content being viewed. The provided data
     * must be a string represented with <a href="http://json-ld.org/">JSON-LD</a> using the
     * <a href="http://schema.org/">schema.org</a> vocabulary.
     */
    public void setStructuredData(String structuredData) {
        mStructuredData = structuredData;
    }

    /**
     * Returns the current {@link #setStructuredData}.
     */
    public String getStructuredData() {
        return mStructuredData;
    }

    /**
     * Set a web URI associated with the current data being shown to the user.
     * This URI could be opened in a web browser, or in the app as an
@@ -163,6 +180,9 @@ public class AssistContent {
        if (in.readInt() != 0) {
            mUri = Uri.CREATOR.createFromParcel(in);
        }
        if (in.readInt() != 0) {
            mStructuredData = in.readString();
        }
        mIsAppProvidedIntent = in.readInt() == 1;
        mExtras = in.readBundle();
    }
@@ -187,6 +207,12 @@ public class AssistContent {
        } else {
            dest.writeInt(0);
        }
        if (mStructuredData != null) {
            dest.writeInt(1);
            dest.writeString(mStructuredData);
        } else {
            dest.writeInt(0);
        }
        dest.writeInt(mIsAppProvidedIntent ? 1 : 0);
        dest.writeBundle(mExtras);
    }