mirror of
https://github.com/TeamVanced/VancedMicroG
synced 2024-11-19 02:29:25 +01:00
Use Cursor.getColumnIndexOrThrow()
This commit is contained in:
parent
1516af4395
commit
c9e09e9714
@ -1,17 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2013-2017 microG Project Team
|
* SPDX-FileCopyrightText: 2016, microG Project Team
|
||||||
*
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.microg.gms.gcm;
|
package org.microg.gms.gcm;
|
||||||
@ -81,13 +70,13 @@ public class GcmDatabase extends SQLiteOpenHelper {
|
|||||||
public final boolean wakeForDelivery;
|
public final boolean wakeForDelivery;
|
||||||
|
|
||||||
private App(Cursor cursor) {
|
private App(Cursor cursor) {
|
||||||
packageName = cursor.getString(cursor.getColumnIndex(FIELD_PACKAGE_NAME));
|
packageName = cursor.getString(cursor.getColumnIndexOrThrow(FIELD_PACKAGE_NAME));
|
||||||
lastError = cursor.getString(cursor.getColumnIndex(FIELD_LAST_ERROR));
|
lastError = cursor.getString(cursor.getColumnIndexOrThrow(FIELD_LAST_ERROR));
|
||||||
lastMessageTimestamp = cursor.getLong(cursor.getColumnIndex(FIELD_LAST_MESSAGE_TIMESTAMP));
|
lastMessageTimestamp = cursor.getLong(cursor.getColumnIndexOrThrow(FIELD_LAST_MESSAGE_TIMESTAMP));
|
||||||
totalMessageCount = cursor.getLong(cursor.getColumnIndex(FIELD_TOTAL_MESSAGE_COUNT));
|
totalMessageCount = cursor.getLong(cursor.getColumnIndexOrThrow(FIELD_TOTAL_MESSAGE_COUNT));
|
||||||
totalMessageBytes = cursor.getLong(cursor.getColumnIndex(FIELD_TOTAL_MESSAGE_BYTES));
|
totalMessageBytes = cursor.getLong(cursor.getColumnIndexOrThrow(FIELD_TOTAL_MESSAGE_BYTES));
|
||||||
allowRegister = cursor.getLong(cursor.getColumnIndex(FIELD_ALLOW_REGISTER)) == 1;
|
allowRegister = cursor.getLong(cursor.getColumnIndexOrThrow(FIELD_ALLOW_REGISTER)) == 1;
|
||||||
wakeForDelivery = cursor.getLong(cursor.getColumnIndex(FIELD_WAKE_FOR_DELIVERY)) == 1;
|
wakeForDelivery = cursor.getLong(cursor.getColumnIndexOrThrow(FIELD_WAKE_FOR_DELIVERY)) == 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasError() {
|
public boolean hasError() {
|
||||||
@ -102,10 +91,10 @@ public class GcmDatabase extends SQLiteOpenHelper {
|
|||||||
public final String registerId;
|
public final String registerId;
|
||||||
|
|
||||||
public Registration(Cursor cursor) {
|
public Registration(Cursor cursor) {
|
||||||
packageName = cursor.getString(cursor.getColumnIndex(FIELD_PACKAGE_NAME));
|
packageName = cursor.getString(cursor.getColumnIndexOrThrow(FIELD_PACKAGE_NAME));
|
||||||
signature = cursor.getString(cursor.getColumnIndex(FIELD_SIGNATURE));
|
signature = cursor.getString(cursor.getColumnIndexOrThrow(FIELD_SIGNATURE));
|
||||||
timestamp = cursor.getLong(cursor.getColumnIndex(FIELD_TIMESTAMP));
|
timestamp = cursor.getLong(cursor.getColumnIndexOrThrow(FIELD_TIMESTAMP));
|
||||||
registerId = cursor.getString(cursor.getColumnIndex(FIELD_REGISTER_ID));
|
registerId = cursor.getString(cursor.getColumnIndexOrThrow(FIELD_REGISTER_ID));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -51,7 +51,7 @@ public class PeopleManager {
|
|||||||
String url = null;
|
String url = null;
|
||||||
if (cursor.moveToNext()) {
|
if (cursor.moveToNext()) {
|
||||||
int idx = cursor.getColumnIndex("avatar");
|
int idx = cursor.getColumnIndex("avatar");
|
||||||
if (!cursor.isNull(idx)) url = cursor.getString(idx);
|
if (idx >= 0 && !cursor.isNull(idx)) url = cursor.getString(idx);
|
||||||
}
|
}
|
||||||
cursor.close();
|
cursor.close();
|
||||||
databaseHelper.close();
|
databaseHelper.close();
|
||||||
|
@ -49,12 +49,12 @@ public class ConfigurationDatabaseHelper extends SQLiteOpenHelper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static ConnectionConfiguration configFromCursor(final Cursor cursor) {
|
private static ConnectionConfiguration configFromCursor(final Cursor cursor) {
|
||||||
String name = cursor.getString(cursor.getColumnIndex("name"));
|
String name = cursor.getString(cursor.getColumnIndexOrThrow("name"));
|
||||||
String pairedBtAddress = cursor.getString(cursor.getColumnIndex("pairedBtAddress"));
|
String pairedBtAddress = cursor.getString(cursor.getColumnIndexOrThrow("pairedBtAddress"));
|
||||||
int connectionType = cursor.getInt(cursor.getColumnIndex("connectionType"));
|
int connectionType = cursor.getInt(cursor.getColumnIndexOrThrow("connectionType"));
|
||||||
int role = cursor.getInt(cursor.getColumnIndex("role"));
|
int role = cursor.getInt(cursor.getColumnIndexOrThrow("role"));
|
||||||
int enabled = cursor.getInt(cursor.getColumnIndex("connectionEnabled"));
|
int enabled = cursor.getInt(cursor.getColumnIndexOrThrow("connectionEnabled"));
|
||||||
String nodeId = cursor.getString(cursor.getColumnIndex("nodeId"));
|
String nodeId = cursor.getString(cursor.getColumnIndexOrThrow("nodeId"));
|
||||||
if (NULL_STRING.equals(name)) name = null;
|
if (NULL_STRING.equals(name)) name = null;
|
||||||
if (NULL_STRING.equals(pairedBtAddress)) pairedBtAddress = null;
|
if (NULL_STRING.equals(pairedBtAddress)) pairedBtAddress = null;
|
||||||
return new ConnectionConfiguration(name, pairedBtAddress, connectionType, role, enabled > 0, nodeId);
|
return new ConnectionConfiguration(name, pairedBtAddress, connectionType, role, enabled > 0, nodeId);
|
||||||
|
@ -289,8 +289,8 @@ public class NodeDatabaseHelper extends SQLiteOpenHelper {
|
|||||||
Cursor status = db.query("assetsReadyStatus", null, "nowReady != markedReady", null, null, null, null);
|
Cursor status = db.query("assetsReadyStatus", null, "nowReady != markedReady", null, null, null, null);
|
||||||
while (status.moveToNext()) {
|
while (status.moveToNext()) {
|
||||||
cv = new ContentValues();
|
cv = new ContentValues();
|
||||||
cv.put("assetsPresent", status.getInt(status.getColumnIndex("nowReady")));
|
cv.put("assetsPresent", status.getInt(status.getColumnIndexOrThrow("nowReady")));
|
||||||
db.update("dataitems", cv, "_id=?", new String[]{Integer.toString(status.getInt(status.getColumnIndex("dataitems_id")))});
|
db.update("dataitems", cv, "_id=?", new String[]{Integer.toString(status.getInt(status.getColumnIndexOrThrow("dataitems_id")))});
|
||||||
}
|
}
|
||||||
status.close();
|
status.close();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user