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

Commit 6a8d5332 authored by Fred Quintana's avatar Fred Quintana
Browse files

content provider entities

parent 7dfc85f1
Loading
Loading
Loading
Loading
+503 −0
Original line number Diff line number Diff line
@@ -24074,6 +24074,75 @@
</package>
<package name="android.content"
>
<class name="AbstractCursorEntityIterator"
 extends="java.lang.Object"
 abstract="true"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
<implements name="android.content.EntityIterator">
</implements>
<constructor name="AbstractCursorEntityIterator"
 type="android.content.AbstractCursorEntityIterator"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
<parameter name="db" type="android.database.sqlite.SQLiteDatabase">
</parameter>
<parameter name="entityCursor" type="android.database.Cursor">
</parameter>
</constructor>
<method name="close"
 return="void"
 abstract="false"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
</method>
<method name="hasNext"
 return="boolean"
 abstract="false"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
</method>
<method name="newEntityFromCursorLocked"
 return="android.content.Entity"
 abstract="true"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
<parameter name="cursor" type="android.database.Cursor">
</parameter>
</method>
<method name="next"
 return="android.content.Entity"
 abstract="false"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
</method>
</class>
<class name="ActivityNotFoundException"
 extends="java.lang.RuntimeException"
 abstract="false"
@@ -24933,6 +25002,36 @@
<parameter name="values" type="android.content.ContentValues[]">
</parameter>
</method>
<method name="bulkInsertEntities"
 return="android.net.Uri[]"
 abstract="false"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
<parameter name="uri" type="android.net.Uri">
</parameter>
<parameter name="entities" type="android.content.Entity[]">
</parameter>
</method>
<method name="bulkUpdateEntities"
 return="int[]"
 abstract="false"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
<parameter name="uri" type="android.net.Uri">
</parameter>
<parameter name="entities" type="android.content.Entity[]">
</parameter>
</method>
<method name="delete"
 return="int"
 abstract="true"
@@ -25011,6 +25110,21 @@
<parameter name="values" type="android.content.ContentValues">
</parameter>
</method>
<method name="insertEntity"
 return="android.net.Uri"
 abstract="false"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
<parameter name="uri" type="android.net.Uri">
</parameter>
<parameter name="entity" type="android.content.Entity">
</parameter>
</method>
<method name="isTemporary"
 return="boolean"
 abstract="false"
@@ -25129,6 +25243,25 @@
<parameter name="sortOrder" type="java.lang.String">
</parameter>
</method>
<method name="queryEntities"
 return="android.content.EntityIterator"
 abstract="false"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
<parameter name="uri" type="android.net.Uri">
</parameter>
<parameter name="selection" type="java.lang.String">
</parameter>
<parameter name="selectionArgs" type="java.lang.String[]">
</parameter>
<parameter name="sortOrder" type="java.lang.String">
</parameter>
</method>
<method name="setReadPermission"
 return="void"
 abstract="false"
@@ -25174,6 +25307,21 @@
<parameter name="selectionArgs" type="java.lang.String[]">
</parameter>
</method>
<method name="updateEntity"
 return="int"
 abstract="false"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
<parameter name="uri" type="android.net.Uri">
</parameter>
<parameter name="entity" type="android.content.Entity">
</parameter>
</method>
</class>
<class name="ContentProviderClient"
 extends="java.lang.Object"
@@ -25200,6 +25348,40 @@
<exception name="RemoteException" type="android.os.RemoteException">
</exception>
</method>
<method name="bulkInsertEntities"
 return="android.net.Uri[]"
 abstract="false"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
<parameter name="uri" type="android.net.Uri">
</parameter>
<parameter name="entities" type="android.content.Entity[]">
</parameter>
<exception name="RemoteException" type="android.os.RemoteException">
</exception>
</method>
<method name="bulkUpdateEntities"
 return="int[]"
 abstract="false"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
<parameter name="uri" type="android.net.Uri">
</parameter>
<parameter name="entities" type="android.content.Entity[]">
</parameter>
<exception name="RemoteException" type="android.os.RemoteException">
</exception>
</method>
<method name="delete"
 return="int"
 abstract="false"
@@ -25262,6 +25444,23 @@
<exception name="RemoteException" type="android.os.RemoteException">
</exception>
</method>
<method name="insertEntity"
 return="android.net.Uri"
 abstract="false"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
<parameter name="uri" type="android.net.Uri">
</parameter>
<parameter name="entity" type="android.content.Entity">
</parameter>
<exception name="RemoteException" type="android.os.RemoteException">
</exception>
</method>
<method name="openAssetFile"
 return="android.content.res.AssetFileDescriptor"
 abstract="false"
@@ -25323,6 +25522,27 @@
<exception name="RemoteException" type="android.os.RemoteException">
</exception>
</method>
<method name="queryEntities"
 return="android.content.EntityIterator"
 abstract="false"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
<parameter name="uri" type="android.net.Uri">
</parameter>
<parameter name="selection" type="java.lang.String">
</parameter>
<parameter name="selectionArgs" type="java.lang.String[]">
</parameter>
<parameter name="sortOrder" type="java.lang.String">
</parameter>
<exception name="RemoteException" type="android.os.RemoteException">
</exception>
</method>
<method name="release"
 return="boolean"
 abstract="false"
@@ -25355,6 +25575,23 @@
<exception name="RemoteException" type="android.os.RemoteException">
</exception>
</method>
<method name="updateEntity"
 return="int"
 abstract="false"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
<parameter name="uri" type="android.net.Uri">
</parameter>
<parameter name="entity" type="android.content.Entity">
</parameter>
<exception name="RemoteException" type="android.os.RemoteException">
</exception>
</method>
</class>
<class name="ContentQueryMap"
 extends="java.util.Observable"
@@ -25499,6 +25736,40 @@
<parameter name="values" type="android.content.ContentValues[]">
</parameter>
</method>
<method name="bulkInsertEntities"
 return="android.net.Uri[]"
 abstract="false"
 native="false"
 synchronized="false"
 static="false"
 final="true"
 deprecated="not deprecated"
 visibility="public"
>
<parameter name="uri" type="android.net.Uri">
</parameter>
<parameter name="entities" type="android.content.Entity[]">
</parameter>
<exception name="RemoteException" type="android.os.RemoteException">
</exception>
</method>
<method name="bulkUpdateEntities"
 return="int[]"
 abstract="false"
 native="false"
 synchronized="false"
 static="false"
 final="true"
 deprecated="not deprecated"
 visibility="public"
>
<parameter name="uri" type="android.net.Uri">
</parameter>
<parameter name="entities" type="android.content.Entity[]">
</parameter>
<exception name="RemoteException" type="android.os.RemoteException">
</exception>
</method>
<method name="cancelSync"
 return="void"
 abstract="false"
@@ -25557,6 +25828,23 @@
<parameter name="values" type="android.content.ContentValues">
</parameter>
</method>
<method name="insertEntity"
 return="android.net.Uri"
 abstract="false"
 native="false"
 synchronized="false"
 static="false"
 final="true"
 deprecated="not deprecated"
 visibility="public"
>
<parameter name="uri" type="android.net.Uri">
</parameter>
<parameter name="entity" type="android.content.Entity">
</parameter>
<exception name="RemoteException" type="android.os.RemoteException">
</exception>
</method>
<method name="notifyChange"
 return="void"
 abstract="false"
@@ -25691,6 +25979,27 @@
<parameter name="sortOrder" type="java.lang.String">
</parameter>
</method>
<method name="queryEntity"
 return="android.content.EntityIterator"
 abstract="false"
 native="false"
 synchronized="false"
 static="false"
 final="true"
 deprecated="not deprecated"
 visibility="public"
>
<parameter name="uri" type="android.net.Uri">
</parameter>
<parameter name="selection" type="java.lang.String">
</parameter>
<parameter name="selectionArgs" type="java.lang.String[]">
</parameter>
<parameter name="sortOrder" type="java.lang.String">
</parameter>
<exception name="RemoteException" type="android.os.RemoteException">
</exception>
</method>
<method name="registerContentObserver"
 return="void"
 abstract="false"
@@ -25755,6 +26064,23 @@
<parameter name="selectionArgs" type="java.lang.String[]">
</parameter>
</method>
<method name="updateEntity"
 return="int"
 abstract="false"
 native="false"
 synchronized="false"
 static="false"
 final="true"
 deprecated="not deprecated"
 visibility="public"
>
<parameter name="uri" type="android.net.Uri">
</parameter>
<parameter name="entity" type="android.content.Entity">
</parameter>
<exception name="RemoteException" type="android.os.RemoteException">
</exception>
</method>
<method name="validateSyncExtrasBundle"
 return="void"
 abstract="false"
@@ -28906,6 +29232,183 @@
</parameter>
</method>
</interface>
<class name="Entity"
 extends="java.lang.Object"
 abstract="true"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
<implements name="android.os.Parcelable">
</implements>
<constructor name="Entity"
 type="android.content.Entity"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
</constructor>
</class>
<interface name="EntityIterator"
 abstract="true"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
<method name="close"
 return="void"
 abstract="true"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
</method>
<method name="hasNext"
 return="boolean"
 abstract="true"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
<exception name="RemoteException" type="android.os.RemoteException">
</exception>
</method>
<method name="next"
 return="android.content.Entity"
 abstract="true"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
<exception name="RemoteException" type="android.os.RemoteException">
</exception>
</method>
</interface>
<interface name="IEntityIterator"
 abstract="true"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
<implements name="android.os.IInterface">
</implements>
<method name="close"
 return="void"
 abstract="true"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
<exception name="RemoteException" type="android.os.RemoteException">
</exception>
</method>
<method name="hasNext"
 return="boolean"
 abstract="true"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
<exception name="RemoteException" type="android.os.RemoteException">
</exception>
</method>
<method name="next"
 return="android.content.Entity"
 abstract="true"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
<exception name="RemoteException" type="android.os.RemoteException">
</exception>
</method>
</interface>
<class name="IEntityIterator.Stub"
 extends="android.os.Binder"
 abstract="true"
 static="true"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
<implements name="android.content.IEntityIterator">
</implements>
<constructor name="IEntityIterator.Stub"
 type="android.content.IEntityIterator.Stub"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
</constructor>
<method name="asBinder"
 return="android.os.IBinder"
 abstract="false"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
</method>
<method name="asInterface"
 return="android.content.IEntityIterator"
 abstract="false"
 native="false"
 synchronized="false"
 static="true"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
<parameter name="obj" type="android.os.IBinder">
</parameter>
</method>
<method name="onTransact"
 return="boolean"
 abstract="false"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
<parameter name="code" type="int">
</parameter>
<parameter name="data" type="android.os.Parcel">
</parameter>
<parameter name="reply" type="android.os.Parcel">
</parameter>
<parameter name="flags" type="int">
</parameter>
<exception name="RemoteException" type="android.os.RemoteException">
</exception>
</method>
</class>
<class name="Intent"
 extends="java.lang.Object"
 abstract="false"
+112 −0
Original line number Diff line number Diff line
package android.content;

import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.os.RemoteException;

/**
 * An abstract class that makes it easy to implement an EntityIterator over a cursor.
 * The user must implement {@link #newEntityFromCursorLocked}, which runs inside of a
 * database transaction.
 */
public abstract class AbstractCursorEntityIterator implements EntityIterator {
    private final Cursor mEntityCursor;
    private final SQLiteDatabase mDb;
    private volatile Entity mNextEntity;
    private volatile boolean mIsClosed;

    public AbstractCursorEntityIterator(SQLiteDatabase db, Cursor entityCursor) {
        mEntityCursor = entityCursor;
        mDb = db;
        mNextEntity = null;
        mIsClosed = false;
    }

    /**
     * If there are entries left in the cursor then advance the cursor and use the new row to
     * populate mNextEntity. If the cursor is at the end or if advancing it causes the cursor
     * to become at the end then set mEntityCursor to null. If newEntityFromCursor returns null
     * then continue advancing until it either returns a non-null Entity or the cursor reaches
     * the end.
     */
    private void fillEntityIfAvailable() {
        while (mNextEntity == null) {
            if (!mEntityCursor.moveToNext()) {
                // the cursor is at then end, bail out
                return;
            }
            // This may return null if newEntityFromCursor is not able to create an entity
            // from the current cursor position. In that case this method will loop and try
            // the next cursor position
            mNextEntity = newEntityFromCursorLocked(mEntityCursor);
        }
        mDb.beginTransaction();
        try {
            int position = mEntityCursor.getPosition();
            mNextEntity = newEntityFromCursorLocked(mEntityCursor);
            int newPosition = mEntityCursor.getPosition();
            if (newPosition != position) {
                throw new IllegalStateException("the cursor position changed during the call to"
                        + "newEntityFromCursorLocked, from " + position + " to " + newPosition);
            }
        } finally {
            mDb.endTransaction();
        }
    }

    /**
     * Checks if there are more Entities accessible via this iterator. This may not be called
     * if the iterator is already closed.
     * @return true if the call to next() will return an Entity.
     */
    public boolean hasNext() {
        if (mIsClosed) {
            throw new IllegalStateException("calling hasNext() when the iterator is closed");
        }
        fillEntityIfAvailable();
        return mNextEntity != null;
    }

    /**
     * Returns the next Entity that is accessible via this iterator. This may not be called
     * if the iterator is already closed.
     * @return the next Entity that is accessible via this iterator
     */
    public Entity next() {
        if (mIsClosed) {
            throw new IllegalStateException("calling next() when the iterator is closed");
        }
        if (!hasNext()) {
            throw new IllegalStateException("you may only call next() if hasNext() is true");
        }

        try {
            return mNextEntity;
        } finally {
            mNextEntity = null;
        }
    }

    /**
     * Closes this iterator making it invalid. If is invalid for the user to call any public
     * method on the iterator once it has been closed.
     */
    public void close() {
        if (mIsClosed) {
            throw new IllegalStateException("closing when already closed");
        }
        mIsClosed = true;
        mEntityCursor.close();
    }

    /**
     * Returns a new Entity from the current cursor position. This is called from within a
     * database transaction. If a new entity cannot be created from this cursor position (e.g.
     * if the row that is referred to no longer exists) then this may return null. The cursor
     * is guaranteed to be pointing to a valid row when this call is made. The implementation
     * of newEntityFromCursorLocked is not allowed to change the position of the cursor.
     * @param cursor from where to read the data for the Entity
     * @return an Entity that corresponds to the current cursor position or null
     */
    public abstract Entity newEntityFromCursorLocked(Cursor cursor);
}
+45 −0
Original line number Diff line number Diff line
@@ -130,6 +130,12 @@ public abstract class ContentProvider implements ComponentCallbacks {
                    selectionArgs, sortOrder);
        }

        public EntityIterator queryEntities(Uri uri, String selection, String[] selectionArgs,
                String sortOrder) {
            checkReadPermission(uri);
            return ContentProvider.this.queryEntities(uri, selection, selectionArgs, sortOrder);
        }

        public String getType(Uri uri) {
            return ContentProvider.this.getType(uri);
        }
@@ -145,6 +151,11 @@ public abstract class ContentProvider implements ComponentCallbacks {
            return ContentProvider.this.bulkInsert(uri, initialValues);
        }

        public Uri[] bulkInsertEntities(Uri uri, Entity[] entities) {
            checkWritePermission(uri);
            return ContentProvider.this.bulkInsertEntities(uri, entities);
        }

        public int delete(Uri uri, String selection, String[] selectionArgs) {
            checkWritePermission(uri);
            return ContentProvider.this.delete(uri, selection, selectionArgs);
@@ -156,6 +167,11 @@ public abstract class ContentProvider implements ComponentCallbacks {
            return ContentProvider.this.update(uri, values, selection, selectionArgs);
        }

        public int[] bulkUpdateEntities(Uri uri, Entity[] entities) {
            checkWritePermission(uri);
            return ContentProvider.this.bulkUpdateEntities(uri, entities);
        }

        public ParcelFileDescriptor openFile(Uri uri, String mode)
                throws FileNotFoundException {
            if (mode != null && mode.startsWith("rw")) checkWritePermission(uri);
@@ -328,6 +344,11 @@ public abstract class ContentProvider implements ComponentCallbacks {
    public abstract Cursor query(Uri uri, String[] projection,
            String selection, String[] selectionArgs, String sortOrder);

    public EntityIterator queryEntities(Uri uri, String selection, String[] selectionArgs,
            String sortOrder) {
        throw new UnsupportedOperationException();
    }

    /**
     * Return the MIME type of the data at the given URI. This should start with
     * <code>vnd.android.cursor.item</code> for a single record,
@@ -378,6 +399,18 @@ public abstract class ContentProvider implements ComponentCallbacks {
        return numValues;
    }

    public Uri insertEntity(Uri uri, Entity entity) {
        throw new UnsupportedOperationException();
    }

    public Uri[] bulkInsertEntities(Uri uri, Entity[] entities) {
        Uri[] result = new Uri[entities.length];
        for (int i = 0; i < entities.length; i++) {
            result[i] = insertEntity(uri, entities[i]);
        }
        return result;
    }

    /**
     * A request to delete one or more rows. The selection clause is applied when performing
     * the deletion, allowing the operation to affect multiple rows in a
@@ -422,6 +455,18 @@ public abstract class ContentProvider implements ComponentCallbacks {
    public abstract int update(Uri uri, ContentValues values, String selection,
            String[] selectionArgs);

    public int updateEntity(Uri uri, Entity entity) {
        throw new UnsupportedOperationException();
    }

    public int[] bulkUpdateEntities(Uri uri, Entity[] entities) {
        int[] result = new int[entities.length];
        for (int i = 0; i < entities.length; i++) {
            result[i] = updateEntity(uri, entities[i]);
        }
        return result;
    }

    /**
     * Open a file blob associated with a content URI.
     * This method can be called from multiple
+50 −8

File changed.

Preview size limit exceeded, changes collapsed.

+164 −1

File changed.

Preview size limit exceeded, changes collapsed.

Loading