Fix install
This commit is contained in:
parent
46a9d3fac6
commit
441beea431
1 changed files with 14 additions and 13 deletions
|
@ -8,23 +8,24 @@ import java.io.InputStream;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
|
|
||||||
public class InstallReceiver extends BroadcastReceiver {
|
public class InstallReceiver extends BroadcastReceiver {
|
||||||
private static final String TAG = "XASH3D";
|
private static final String TAG = "XASH3D";
|
||||||
@Override
|
@Override
|
||||||
public void onReceive(Context context, Intent arg1) {
|
public void onReceive(Context context, Intent arg1) {
|
||||||
Log.d( TAG, "Install received, extracting PAK" );
|
String pkgname = arg1.getData().getEncodedSchemeSpecificPart();
|
||||||
if( context.getPackageName() == arg1.getData().getEncodedSchemeSpecificPart() )
|
Log.d( TAG, "Install received, package " + pkgname );
|
||||||
extractPAK(context, true);
|
if( context.getPackageName().equals(pkgname) )
|
||||||
}
|
extractPAK(context, true);
|
||||||
public static SharedPreferences mPref = null;
|
}
|
||||||
private static final int PAK_VERSION = 5;
|
public static SharedPreferences mPref = null;
|
||||||
|
private static final int PAK_VERSION = 5;
|
||||||
public static void extractPAK(Context context, Boolean force) {
|
public static void extractPAK(Context context, Boolean force) {
|
||||||
InputStream is = null;
|
InputStream is = null;
|
||||||
FileOutputStream os = null;
|
FileOutputStream os = null;
|
||||||
try {
|
try {
|
||||||
if( mPref == null )
|
if( mPref == null )
|
||||||
mPref = context.getSharedPreferences("engine", 0);
|
mPref = context.getSharedPreferences("engine", 0);
|
||||||
if( mPref.getInt( "pakversion", 0 ) == PAK_VERSION && !force )
|
if( mPref.getInt( "pakversion", 0 ) == PAK_VERSION && !force )
|
||||||
return;
|
return;
|
||||||
String path = context.getFilesDir().getPath()+"/extras.pak";
|
String path = context.getFilesDir().getPath()+"/extras.pak";
|
||||||
|
|
||||||
is = context.getAssets().open("extras.pak");
|
is = context.getAssets().open("extras.pak");
|
||||||
|
|
Loading…
Add table
Reference in a new issue