Skip to content

Commit

Permalink
Revert "Decrease RAM used for the android build"
Browse files Browse the repository at this point in the history
  • Loading branch information
Bioblaze authored Oct 13, 2024
1 parent 864c2cc commit 6bf5613
Show file tree
Hide file tree
Showing 6 changed files with 56 additions and 114 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -128,10 +128,7 @@ public static boolean isFilenameValid(String filename) {
File file = new File(path);
file.delete();
} catch (Exception e) {
StringBuilder logData = new StringBuilder("file: '");
logData.append(path);
logData.append("' couldn't be deleted");
Log.w(Constants.TAG, logData.toString(), e);
Log.w(Constants.TAG, "file: '" + path + "' couldn't be deleted", e);
}
}

Expand Down Expand Up @@ -223,11 +220,9 @@ public static String getExpansionAPKFileName(Context c, boolean mainFile, int ve
* Returns the filename (where the file should be saved) from info about a download
*/
static public String generateSaveFileName(Context c, String fileName) {
StringBuilder path = new StringBuilder();
path.append(getSaveFilePath(c));
path.append(File.separator);
path.append(fileName);
return path.toString();
String path = getSaveFilePath(c)
+ File.separator + fileName;
return path;
}

@TargetApi(Build.VERSION_CODES.HONEYCOMB)
Expand All @@ -239,11 +234,8 @@ static public String getSaveFilePath(Context c) {
return c.getObbDir().toString();
} else {
File root = Environment.getExternalStorageDirectory();
StringBuilder path = new StringBuilder();
path.append(root.toString());
path.append(Constants.EXP_PATH);
path.append(c.getPackageName());
return path.toString();
String path = root.toString() + Constants.EXP_PATH + c.getPackageName();
return path;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,10 @@ public DownloadThread(DownloadInfo info, DownloaderService service,
mService = service;
mNotification = notification;
mDB = DownloadsDB.getDB(service);
StringBuffer mUserAgentBuffer = new StringBuffer("APKXDL (Linux; U; Android ");
mUserAgentBuffer.append(android.os.Build.VERSION.RELEASE).append(";");
mUserAgentBuffer.append(Locale.getDefault().toString());
mUserAgentBuffer.append("; ").append(android.os.Build.DEVICE).append("/");
mUserAgentBuffer.append(android.os.Build.ID).append(")");
mUserAgentBuffer.append(service.getPackageName());
mUserAgent = mUserAgentBuffer.toString();
mUserAgent = "APKXDL (Linux; U; Android " + android.os.Build.VERSION.RELEASE + ";"
+ Locale.getDefault().toString() + "; " + android.os.Build.DEVICE + "/"
+ android.os.Build.ID + ")" +
service.getPackageName();
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -809,10 +809,8 @@ public void allow(int reason) {
// was delivered by Market or
// through
// another mechanism
StringBuffer logData = new StringBuffer("file ");
logData.append(di.mFileName);
logData.append(" found. Not downloading.");
Log.d(LOG_TAG, logData.toString());
Log.d(LOG_TAG, "file " + di.mFileName
+ " found. Not downloading.");
di.mStatus = STATUS_SUCCESS;
di.mTotalBytes = fileSize;
di.mCurrentBytes = fileSize;
Expand Down Expand Up @@ -954,10 +952,7 @@ private void scheduleAlarm(long wakeUp) {
}

if (Constants.LOGV) {
StringBuffer logData = new StringBuffer("scheduling retry in ");
logData.append(wakeUp);
logData.append("ms");
Log.v(Constants.TAG, logData.toString());
Log.v(Constants.TAG, "scheduling retry in " + wakeUp + "ms");
}

String className = getAlarmReceiverClassName();
Expand Down Expand Up @@ -1226,11 +1221,8 @@ public GenerateSaveFileError(int status, String message) {
* download
*/
public String generateTempSaveFileName(String fileName) {
StringBuffer pathBuffer = new StringBuffer(Helpers.getSaveFilePath(this));
pathBuffer.append(File.separator);
pathBuffer.append(fileName);
pathBuffer.append(TEMP_EXT);
String path = pathBuffer.toString();
String path = Helpers.getSaveFilePath(this)
+ File.separator + fileName + TEMP_EXT;
return path;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,31 +48,20 @@ static public synchronized DownloadsDB getDB(Context paramContext) {

private SQLiteStatement getDownloadByIndexStatement() {
if (null == mGetDownloadByIndex) {
StringBuilder sqlBuffer = new StringBuilder("SELECT ");
sqlBuffer.append(BaseColumns._ID);
sqlBuffer.append(" FROM ");
sqlBuffer.append(DownloadColumns.TABLE_NAME);
sqlBuffer.append(" WHERE ");
sqlBuffer.append(DownloadColumns.INDEX );
sqlBuffer.append(" = ?");
mGetDownloadByIndex = mHelper.getReadableDatabase().compileStatement(
sqlBuffer.toString());
"SELECT " + BaseColumns._ID + " FROM "
+ DownloadColumns.TABLE_NAME + " WHERE "
+ DownloadColumns.INDEX + " = ?");
}
return mGetDownloadByIndex;
}

private SQLiteStatement getUpdateCurrentBytesStatement() {
if (null == mUpdateCurrentBytes) {
StringBuffer sqlBuffer = new StringBuffer("UPDATE ");
sqlBuffer.append(DownloadColumns.TABLE_NAME);
sqlBuffer.append(" SET ");
sqlBuffer.append(DownloadColumns.CURRENTBYTES);
sqlBuffer.append(" = ?" );
sqlBuffer.append(" WHERE ");
sqlBuffer.append(DownloadColumns.INDEX);
sqlBuffer.append(" = ?");
mUpdateCurrentBytes = mHelper.getReadableDatabase().compileStatement(
sqlBuffer.toString());
"UPDATE " + DownloadColumns.TABLE_NAME + " SET " + DownloadColumns.CURRENTBYTES
+ " = ?" +
" WHERE " + DownloadColumns.INDEX + " = ?");
}
return mUpdateCurrentBytes;
}
Expand All @@ -82,19 +71,13 @@ private DownloadsDB(Context paramContext) {
final SQLiteDatabase sqldb = mHelper.getReadableDatabase();
// Query for the version code, the row ID of the metadata (for future
// updating) the status and the flags
StringBuffer sqlBuffer = new StringBuffer("SELECT ");
sqlBuffer.append(MetadataColumns.APKVERSION);
sqlBuffer.append(",");
sqlBuffer.append(BaseColumns._ID);
sqlBuffer.append(",");
sqlBuffer.append(MetadataColumns.DOWNLOAD_STATUS);
sqlBuffer.append(",");
sqlBuffer.append(MetadataColumns.FLAGS);
sqlBuffer.append(" FROM ");
sqlBuffer.append(MetadataColumns.TABLE_NAME);
sqlBuffer.append(" LIMIT 1");
Cursor cur = sqldb.rawQuery(
sqlBuffer.toString() , null);
Cursor cur = sqldb.rawQuery("SELECT " +
MetadataColumns.APKVERSION + "," +
BaseColumns._ID + "," +
MetadataColumns.DOWNLOAD_STATUS + "," +
MetadataColumns.FLAGS +
" FROM "
+ MetadataColumns.TABLE_NAME + " LIMIT 1", null);
if (null != cur && cur.moveToFirst()) {
mVersionCode = cur.getInt(0);
mMetadataRowID = cur.getLong(1);
Expand Down Expand Up @@ -158,24 +141,24 @@ protected static class DownloadsContentDBHelper extends SQLiteOpenHelper {

private String createTableQueryFromArray(String paramString,
String[][] paramArrayOfString) {
StringBuilder sqlBuilder = new StringBuilder();
sqlBuilder.append("CREATE TABLE ");
sqlBuilder.append(paramString);
sqlBuilder.append(" (");
StringBuilder localStringBuilder = new StringBuilder();
localStringBuilder.append("CREATE TABLE ");
localStringBuilder.append(paramString);
localStringBuilder.append(" (");
int i = paramArrayOfString.length;
for (int j = 0;; j++) {
if (j >= i) {
sqlBuilder
.setLength(sqlBuilder.length() - 1);
sqlBuilder.append(");");
return sqlBuilder.toString();
localStringBuilder
.setLength(localStringBuilder.length() - 1);
localStringBuilder.append(");");
return localStringBuilder.toString();
}
String[] arrayOfString = paramArrayOfString[j];
sqlBuilder.append(' ');
sqlBuilder.append(arrayOfString[0]);
sqlBuilder.append(' ');
sqlBuilder.append(arrayOfString[1]);
sqlBuilder.append(',');
localStringBuilder.append(' ');
localStringBuilder.append(arrayOfString[0]);
localStringBuilder.append(' ');
localStringBuilder.append(arrayOfString[1]);
localStringBuilder.append(',');
}
}

Expand Down Expand Up @@ -226,13 +209,9 @@ public void onCreate(SQLiteDatabase paramSQLiteDatabase) {

public void onUpgrade(SQLiteDatabase paramSQLiteDatabase,
int paramInt1, int paramInt2) {
StringBuffer sqlBuffer = new StringBuffer("Upgrading database from version ");
sqlBuffer.append(paramInt1);
sqlBuffer.append(" to ");
sqlBuffer.append(paramInt2);
sqlBuffer.append(", which will destroy all old data");
Log.w(DownloadsContentDBHelper.class.getName(),
sqlBuffer.toString());
"Upgrading database from version " + paramInt1 + " to "
+ paramInt2 + ", which will destroy all old data");
dropTables(paramSQLiteDatabase);
onCreate(paramSQLiteDatabase);
}
Expand Down Expand Up @@ -386,13 +365,9 @@ public int getLastCheckedVersionCode() {

public boolean isDownloadRequired() {
final SQLiteDatabase sqldb = mHelper.getReadableDatabase();
StringBuffer sqlBuffer = new StringBuffer("SELECT Count(*) FROM ");
sqlBuffer.append(DownloadColumns.TABLE_NAME);
sqlBuffer.append(" WHERE ");
sqlBuffer.append(DownloadColumns.STATUS);
sqlBuffer.append(" <> 0");
Cursor cur = sqldb.rawQuery(
sqlBuffer.toString(), null);
Cursor cur = sqldb.rawQuery("SELECT Count(*) FROM "
+ DownloadColumns.TABLE_NAME + " WHERE "
+ DownloadColumns.STATUS + " <> 0", null);
try {
if (null != cur && cur.moveToFirst()) {
return 0 == cur.getInt(0);
Expand Down Expand Up @@ -447,11 +422,8 @@ public boolean updateMetadata(ContentValues cv) {
return false;
mMetadataRowID = newID;
} else {
StringBuffer metaData = new StringBuffer(BaseColumns._ID);
metaData.append(" = ");
metaData.append(mMetadataRowID);
if (0 == sqldb.update(MetadataColumns.TABLE_NAME, cv,
metaData.toString(), null))
BaseColumns._ID + " = " + mMetadataRowID, null))
return false;
}
return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -534,12 +534,9 @@ public static byte[] decode(byte[] source, int off, int len, byte[] decodabet)
"invalid padding byte '=' at byte offset " + i);
} else if ((b4Posn == 3 && bytesLeft > 2)
|| (b4Posn == 4 && bytesLeft > 1)) {
StringBuilder exceptionData = new StringBuilder("padding byte '=' falsely signals end of encoded value ");
exceptionData.append("at offset ");
exceptionData.append(i);
throw new Base64DecoderException(
exceptionData.toString()
);
"padding byte '=' falsely signals end of encoded value "
+ "at offset " + i);
} else if (lastByte != EQUALS_SIGN && lastByte != NEW_LINE) {
throw new Base64DecoderException(
"encoded value has invalid trailing byte");
Expand All @@ -554,13 +551,8 @@ public static byte[] decode(byte[] source, int off, int len, byte[] decodabet)
}
}
} else {
StringBuilder exceptionData = new StringBuilder("Bad Base64 input character at ");
exceptionData.append(i);
exceptionData.append(": " );
exceptionData.append(source[i + off]);
exceptionData.append("(decimal)");
throw new Base64DecoderException(
exceptionData.toString() );
throw new Base64DecoderException("Bad Base64 input character at " + i
+ ": " + source[i + off] + "(decimal)");
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,14 +71,11 @@ String[] getParamTypesNames() {

@Override
public String toString() {
StringBuilder object = new StringBuilder("SignalInfo{");
object.append("name='");
object.append(name);
object.append('\'');
object.append(", paramsTypes=");
object.append(Arrays.toString(paramTypes));
object.append('}');
return object.toString();
return "SignalInfo{"
+
"name='" + name + '\'' +
", paramsTypes=" + Arrays.toString(paramTypes) +
'}';
}

@Override
Expand Down

0 comments on commit 6bf5613

Please sign in to comment.