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

Commit 854082bd authored by Lee Shombert's avatar Lee Shombert
Browse files

APIs should not throw SQLiteException

Android API rules state that APIs should not include a 'throws X' clause
if X is a RuntimeException.  SQLiteException is a RuntimeException, so
it not be part of the API signature.

This removes the 'throws' clauses, updates the API tables, and removes
the corresponding lint exceptions.

Test: atest
 * FrameworksCoreTests:android.database.sqlite
 * CtsDatabaseTestCases

Bug: 310004191
Change-Id: I6a725609f3cb05eb88a0cb66281001e289929b38
parent 942ae37a
Loading
Loading
Loading
Loading
+17 −17
Original line number Diff line number Diff line
@@ -14699,31 +14699,31 @@ package android.database.sqlite {
  }
  @FlaggedApi("android.database.sqlite.sqlite_apis_35") public final class SQLiteRawStatement implements java.io.Closeable {
    method public void bindBlob(int, @NonNull byte[]) throws android.database.sqlite.SQLiteException;
    method public void bindBlob(int, @NonNull byte[], int, int) throws android.database.sqlite.SQLiteException;
    method public void bindDouble(int, double) throws android.database.sqlite.SQLiteException;
    method public void bindInt(int, int) throws android.database.sqlite.SQLiteException;
    method public void bindLong(int, long) throws android.database.sqlite.SQLiteException;
    method public void bindNull(int) throws android.database.sqlite.SQLiteException;
    method public void bindText(int, @NonNull String) throws android.database.sqlite.SQLiteException;
    method public void bindBlob(int, @NonNull byte[]);
    method public void bindBlob(int, @NonNull byte[], int, int);
    method public void bindDouble(int, double);
    method public void bindInt(int, int);
    method public void bindLong(int, long);
    method public void bindNull(int);
    method public void bindText(int, @NonNull String);
    method public void clearBindings();
    method public void close();
    method @Nullable public byte[] getColumnBlob(int) throws android.database.sqlite.SQLiteException;
    method public double getColumnDouble(int) throws android.database.sqlite.SQLiteException;
    method public int getColumnInt(int) throws android.database.sqlite.SQLiteException;
    method public int getColumnLength(int) throws android.database.sqlite.SQLiteException;
    method public long getColumnLong(int) throws android.database.sqlite.SQLiteException;
    method @NonNull public String getColumnName(int) throws android.database.sqlite.SQLiteException;
    method @NonNull public String getColumnText(int) throws android.database.sqlite.SQLiteException;
    method public int getColumnType(int) throws android.database.sqlite.SQLiteException;
    method @Nullable public byte[] getColumnBlob(int);
    method public double getColumnDouble(int);
    method public int getColumnInt(int);
    method public int getColumnLength(int);
    method public long getColumnLong(int);
    method @NonNull public String getColumnName(int);
    method @NonNull public String getColumnText(int);
    method public int getColumnType(int);
    method public int getParameterCount();
    method public int getParameterIndex(@NonNull String);
    method @Nullable public String getParameterName(int);
    method public int getResultColumnCount();
    method public boolean isOpen();
    method public int readColumnBlob(int, @NonNull byte[], int, int, int) throws android.database.sqlite.SQLiteException;
    method public int readColumnBlob(int, @NonNull byte[], int, int, int);
    method public void reset();
    method public boolean step() throws android.database.sqlite.SQLiteException;
    method public boolean step();
    field public static final int SQLITE_DATA_TYPE_BLOB = 4; // 0x4
    field public static final int SQLITE_DATA_TYPE_FLOAT = 2; // 0x2
    field public static final int SQLITE_DATA_TYPE_INTEGER = 1; // 0x1
+0 −36
Original line number Diff line number Diff line
// Baseline format: 1.0
BannedThrow: android.database.sqlite.SQLiteRawStatement#bindBlob(int, byte[]):
    Methods must not throw unchecked exceptions
BannedThrow: android.database.sqlite.SQLiteRawStatement#bindBlob(int, byte[], int, int):
    Methods must not throw unchecked exceptions
BannedThrow: android.database.sqlite.SQLiteRawStatement#bindDouble(int, double):
    Methods must not throw unchecked exceptions
BannedThrow: android.database.sqlite.SQLiteRawStatement#bindInt(int, int):
    Methods must not throw unchecked exceptions
BannedThrow: android.database.sqlite.SQLiteRawStatement#bindLong(int, long):
    Methods must not throw unchecked exceptions
BannedThrow: android.database.sqlite.SQLiteRawStatement#bindNull(int):
    Methods must not throw unchecked exceptions
BannedThrow: android.database.sqlite.SQLiteRawStatement#bindText(int, String):
    Methods must not throw unchecked exceptions
BannedThrow: android.database.sqlite.SQLiteRawStatement#getColumnBlob(int):
    Methods must not throw unchecked exceptions
BannedThrow: android.database.sqlite.SQLiteRawStatement#getColumnDouble(int):
    Methods must not throw unchecked exceptions
BannedThrow: android.database.sqlite.SQLiteRawStatement#getColumnInt(int):
    Methods must not throw unchecked exceptions
BannedThrow: android.database.sqlite.SQLiteRawStatement#getColumnLength(int):
    Methods must not throw unchecked exceptions
BannedThrow: android.database.sqlite.SQLiteRawStatement#getColumnLong(int):
    Methods must not throw unchecked exceptions
BannedThrow: android.database.sqlite.SQLiteRawStatement#getColumnName(int):
    Methods must not throw unchecked exceptions
BannedThrow: android.database.sqlite.SQLiteRawStatement#getColumnText(int):
    Methods must not throw unchecked exceptions
BannedThrow: android.database.sqlite.SQLiteRawStatement#getColumnType(int):
    Methods must not throw unchecked exceptions
BannedThrow: android.database.sqlite.SQLiteRawStatement#readColumnBlob(int, byte[], int, int, int):
    Methods must not throw unchecked exceptions
BannedThrow: android.database.sqlite.SQLiteRawStatement#step():
    Methods must not throw unchecked exceptions


BroadcastBehavior: android.app.AlarmManager#ACTION_NEXT_ALARM_CLOCK_CHANGED:
    Field 'ACTION_NEXT_ALARM_CLOCK_CHANGED' is missing @BroadcastBehavior
BroadcastBehavior: android.app.AlarmManager#ACTION_SCHEDULE_EXACT_ALARM_PERMISSION_STATE_CHANGED:
+18 −20
Original line number Diff line number Diff line
@@ -163,7 +163,7 @@ public final class SQLiteRawStatement implements Closeable {
     * {@link IllegalStateException} if a transaction is not in progress. Clients should call
     * {@link SQLiteDatabase.createRawStatement} to create a new instance.
     */
    SQLiteRawStatement(@NonNull SQLiteDatabase db, @NonNull String sql) throws SQLiteException {
    SQLiteRawStatement(@NonNull SQLiteDatabase db, @NonNull String sql) {
        mThread = Thread.currentThread();
        mDatabase = db;
        mSession = mDatabase.getThreadSession();
@@ -245,7 +245,7 @@ public final class SQLiteRawStatement implements Closeable {
     * @throws SQLiteDatabaseLockedException if the database is locked or busy.
     * @throws SQLiteException if a native error occurs.
     */
    public boolean step() throws SQLiteException {
    public boolean step() {
        throwIfInvalid();
        try {
            int err = nativeStep(mStatement, true);
@@ -392,7 +392,7 @@ public final class SQLiteRawStatement implements Closeable {
     * @throws SQLiteBindOrColumnIndexOutOfRangeException if the parameter is out of range.
     * @throws SQLiteException if a native error occurs.
     */
    public void bindBlob(int parameterIndex, @NonNull byte[] value) throws SQLiteException {
    public void bindBlob(int parameterIndex, @NonNull byte[] value) {
        Objects.requireNonNull(value);
        throwIfInvalid();
        try {
@@ -418,8 +418,7 @@ public final class SQLiteRawStatement implements Closeable {
     * @throws SQLiteBindOrColumnIndexOutOfRangeException if the parameter is out of range.
     * @throws SQLiteException if a native error occurs.
     */
    public void bindBlob(int parameterIndex, @NonNull byte[] value, int offset, int length)
            throws SQLiteException {
    public void bindBlob(int parameterIndex, @NonNull byte[] value, int offset, int length) {
        Objects.requireNonNull(value);
        throwIfInvalid();
        throwIfInvalidBounds(value.length, offset, length);
@@ -442,7 +441,7 @@ public final class SQLiteRawStatement implements Closeable {
     * @throws SQLiteBindOrColumnIndexOutOfRangeException if the parameter is out of range.
     * @throws SQLiteException if a native error occurs.
     */
    public void bindDouble(int parameterIndex, double value) throws SQLiteException {
    public void bindDouble(int parameterIndex, double value) {
        throwIfInvalid();
        try {
            nativeBindDouble(mStatement, parameterIndex, value);
@@ -462,7 +461,7 @@ public final class SQLiteRawStatement implements Closeable {
     * @throws SQLiteBindOrColumnIndexOutOfRangeException if the parameter is out of range.
     * @throws SQLiteException if a native error occurs.
     */
    public void bindInt(int parameterIndex, int value) throws SQLiteException {
    public void bindInt(int parameterIndex, int value) {
        throwIfInvalid();
        try {
            nativeBindInt(mStatement, parameterIndex, value);
@@ -482,7 +481,7 @@ public final class SQLiteRawStatement implements Closeable {
     * @throws SQLiteBindOrColumnIndexOutOfRangeException if the parameter is out of range.
     * @throws SQLiteException if a native error occurs.
     */
    public void bindLong(int parameterIndex, long value) throws SQLiteException {
    public void bindLong(int parameterIndex, long value) {
        throwIfInvalid();
        try {
            nativeBindLong(mStatement, parameterIndex, value);
@@ -502,7 +501,7 @@ public final class SQLiteRawStatement implements Closeable {
     * @throws SQLiteBindOrColumnIndexOutOfRangeException if the parameter is out of range.
     * @throws SQLiteException if a native error occurs.
     */
    public void bindNull(int parameterIndex) throws SQLiteException {
    public void bindNull(int parameterIndex) {
        throwIfInvalid();
        try {
            nativeBindNull(mStatement, parameterIndex);
@@ -523,7 +522,7 @@ public final class SQLiteRawStatement implements Closeable {
     * @throws SQLiteBindOrColumnIndexOutOfRangeException if the parameter is out of range.
     * @throws SQLiteException if a native error occurs.
     */
    public void bindText(int parameterIndex, @NonNull String value) throws SQLiteException {
    public void bindText(int parameterIndex, @NonNull String value) {
        Objects.requireNonNull(value);
        throwIfInvalid();
        try {
@@ -562,7 +561,7 @@ public final class SQLiteRawStatement implements Closeable {
     * @throws SQLiteException if a native error occurs.
     */
    @SQLiteDataType
    public int getColumnType(int columnIndex) throws SQLiteException {
    public int getColumnType(int columnIndex) {
        throwIfInvalid();
        try {
            return nativeColumnType(mStatement, columnIndex);
@@ -584,7 +583,7 @@ public final class SQLiteRawStatement implements Closeable {
     * @throws SQLiteOutOfMemoryException if the database cannot allocate memory for the name.
     */
    @NonNull
    public String getColumnName(int columnIndex) throws SQLiteException {
    public String getColumnName(int columnIndex) {
        throwIfInvalid();
        try {
            return nativeColumnName(mStatement, columnIndex);
@@ -609,7 +608,7 @@ public final class SQLiteRawStatement implements Closeable {
     * @throws SQLiteBindOrColumnIndexOutOfRangeException if the column is out of range.
     * @throws SQLiteException if a native error occurs.
     */
    public int getColumnLength(int columnIndex) throws SQLiteException {
    public int getColumnLength(int columnIndex) {
        throwIfInvalid();
        try {
            return nativeColumnBytes(mStatement, columnIndex);
@@ -635,7 +634,7 @@ public final class SQLiteRawStatement implements Closeable {
     * @throws SQLiteException if a native error occurs.
     */
    @Nullable
    public byte[] getColumnBlob(int columnIndex) throws SQLiteException {
    public byte[] getColumnBlob(int columnIndex) {
        throwIfInvalid();
        try {
            return nativeColumnBlob(mStatement, columnIndex);
@@ -668,8 +667,7 @@ public final class SQLiteRawStatement implements Closeable {
     * @throws SQLiteException if a native error occurs.
     */
    public int readColumnBlob(int columnIndex, @NonNull byte[] buffer, int offset,
            int length, int srcOffset)
            throws SQLiteException {
            int length, int srcOffset) {
        Objects.requireNonNull(buffer);
        throwIfInvalid();
        throwIfInvalidBounds(buffer.length, offset, length);
@@ -695,7 +693,7 @@ public final class SQLiteRawStatement implements Closeable {
     * @throws SQLiteBindOrColumnIndexOutOfRangeException if the column is out of range.
     * @throws SQLiteException if a native error occurs.
     */
    public double getColumnDouble(int columnIndex) throws SQLiteException {
    public double getColumnDouble(int columnIndex) {
        throwIfInvalid();
        try {
            return nativeColumnDouble(mStatement, columnIndex);
@@ -719,7 +717,7 @@ public final class SQLiteRawStatement implements Closeable {
     * @throws SQLiteBindOrColumnIndexOutOfRangeException if the column is out of range.
     * @throws SQLiteException if a native error occurs.
     */
    public int getColumnInt(int columnIndex) throws SQLiteException {
    public int getColumnInt(int columnIndex) {
        throwIfInvalid();
        try {
            return nativeColumnInt(mStatement, columnIndex);
@@ -743,7 +741,7 @@ public final class SQLiteRawStatement implements Closeable {
     * @throws SQLiteBindOrColumnIndexOutOfRangeException if the column is out of range.
     * @throws SQLiteException if a native error occurs.
     */
    public long getColumnLong(int columnIndex) throws SQLiteException {
    public long getColumnLong(int columnIndex) {
        throwIfInvalid();
        try {
            return nativeColumnLong(mStatement, columnIndex);
@@ -768,7 +766,7 @@ public final class SQLiteRawStatement implements Closeable {
     * @throws SQLiteException if a native error occurs.
     */
    @NonNull
    public String getColumnText(int columnIndex) throws SQLiteException {
    public String getColumnText(int columnIndex) {
        throwIfInvalid();
        try {
            return nativeColumnText(mStatement, columnIndex);