add (unused) method to copy apk to Downloads/

This commit is contained in:
Eric House 2020-04-11 21:18:20 -07:00
parent 9fd4bb2a11
commit c3b1423c36

View file

@ -22,13 +22,15 @@ package org.eehouse.android.xw4;
import android.content.ContentValues;
import android.content.Context;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
import android.database.Cursor;
import android.database.sqlite.SQLiteConstraintException;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import android.database.sqlite.SQLiteStatement;
import android.graphics.Bitmap;
import android.graphics.Bitmap.CompressFormat;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.os.Environment;
import android.text.TextUtils;
@ -2563,6 +2565,32 @@ public class DBUtils {
}
}
// Copy my .apk to the Downloads directory, from which a user could more
// easily share it with somebody else. Should be blocked for apks
// installed from the Play store since viral distribution isn't allowed,
// but might be helpful in other cases. Need to figure out how to expose
// it, and how to recommend transmissions. E.g. gmail doesn't let me
// attach an .apk even if I rename it.
static void copyApkToDownloads( Context context )
{
try {
String myName = context.getPackageName();
PackageManager pm = context.getPackageManager();
ApplicationInfo appInfo = pm.getApplicationInfo( myName, 0 );
File srcPath = new File( appInfo.publicSourceDir );
File destPath = Environment
.getExternalStoragePublicDirectory( Environment.DIRECTORY_DOWNLOADS );
destPath = new File( destPath, context.getString(R.string.app_name) + ".apk" );
FileInputStream src = new FileInputStream( srcPath );
FileOutputStream dest = new FileOutputStream( destPath );
copyFileStream( dest, src );
} catch ( Exception ex ) {
Log.e( TAG, "copyApkToDownloads(): got ex: %s", ex );
}
}
private static String getVariantDBName()
{
return String.format( "%s_%s", DBHelper.getDBName(),