Enable pak in apk and fix server build
This commit is contained in:
parent
3860e36660
commit
24c8205ded
@ -1,5 +1,13 @@
|
||||
#!/bin/sh
|
||||
|
||||
mkdir -p pak/
|
||||
mkdir -p assets/
|
||||
cp -vr extras_src/CS16client_extrass/* pak/
|
||||
cp -vr extras_src/CS16Client_vgui_buy_classic/touch/* pak/touch/
|
||||
cp -vr extras_src/CS16client_vgui_radio/touch/* pak/touch/
|
||||
cp -vr extras_src/CS16Client_vgui_team_classic/touch/* pak/touch/
|
||||
python2 makepak.py pak/ assets/extras.pak
|
||||
|
||||
ndk-build NDK_TOOLCHAIN_VERSION=4.8 NDK_DEBUG=0 V=0 -j2
|
||||
ant debug
|
||||
#jarsigner -verbose -sigalg SHA1withRSA -digestalg SHA1 -keystore ../../myks.keystore bin/cs16-client-release-unsigned.apk xashdroid -tsa https://timestamp.geotrust.com/tsa
|
||||
|
45
android/makepak.py
Normal file
45
android/makepak.py
Normal file
@ -0,0 +1,45 @@
|
||||
import sys
|
||||
import struct
|
||||
import os
|
||||
|
||||
#dummy class for stuffing the file headers into
|
||||
class FileEntry:
|
||||
pass
|
||||
|
||||
#arguments are source directory, then target filename e.g. "pak1.pak"
|
||||
rootdir = sys.argv[1]
|
||||
pakfilename = sys.argv[2]
|
||||
|
||||
pakfile = open(pakfilename,"wb")
|
||||
|
||||
#write a dummy header to start with
|
||||
pakfile.write(struct.Struct("<4s2l").pack(b"PACK",0,0))
|
||||
|
||||
#walk the directory recursively, add the files and record the file entries
|
||||
offset = 12
|
||||
fileentries = []
|
||||
for root, subFolders, files in os.walk(rootdir):
|
||||
for file in files:
|
||||
entry = FileEntry()
|
||||
impfilename = os.path.join(root,file)
|
||||
entry.filename = os.path.relpath(impfilename,rootdir).replace("\\","/")
|
||||
if(entry.filename.startswith(".git")):continue
|
||||
print "pak: "+entry.filename
|
||||
with open(impfilename, "rb") as importfile:
|
||||
pakfile.write(importfile.read())
|
||||
entry.offset = offset
|
||||
entry.length = importfile.tell()
|
||||
offset = offset + entry.length
|
||||
fileentries.append(entry)
|
||||
tablesize = 0
|
||||
|
||||
#after all the file data, write the list of entries
|
||||
for entry in fileentries:
|
||||
pakfile.write(struct.Struct("<56s").pack(entry.filename.encode("ascii")))
|
||||
pakfile.write(struct.Struct("<l").pack(entry.offset))
|
||||
pakfile.write(struct.Struct("<l").pack(entry.length))
|
||||
tablesize = tablesize + 64
|
||||
|
||||
#return to the header and write the values correctly
|
||||
pakfile.seek(0)
|
||||
pakfile.write(struct.Struct("<4s2l").pack(b"PACK",offset,tablesize))
|
14
android/src/in/celest/xash3d/cs16client/InstallReceiver.java
Normal file
14
android/src/in/celest/xash3d/cs16client/InstallReceiver.java
Normal file
@ -0,0 +1,14 @@
|
||||
package in.celest.xash3d.cs16client;
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.util.Log;
|
||||
|
||||
public class InstallReceiver extends BroadcastReceiver {
|
||||
private static final String TAG = "CSDM_LAUNCHER";
|
||||
@Override
|
||||
public void onReceive(Context context, Intent arg1) {
|
||||
Log.d( TAG, "Install received, extracting PAK" );
|
||||
LauncherActivity.extractPAK( context, true );
|
||||
}
|
||||
}
|
@ -29,27 +29,32 @@ package in.celest.xash3d.cs16client;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.AlertDialog;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.ComponentName;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.content.SharedPreferences;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.content.Intent;
|
||||
import android.widget.EditText;
|
||||
import android.widget.Spinner;
|
||||
import android.widget.CompoundButton;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.content.ComponentName;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.content.SharedPreferences;
|
||||
import android.util.Log;
|
||||
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.InputStream;
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
import com.google.android.gms.ads.*;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import in.celest.xash3d.cs16client.R;
|
||||
|
||||
public class LauncherActivity extends Activity {
|
||||
private static final int PAK_VERSION = 1;
|
||||
public final static String TAG = "LauncherActivity";
|
||||
|
||||
static EditText cmdArgs;
|
||||
@ -57,6 +62,8 @@ public class LauncherActivity extends Activity {
|
||||
static Spinner mServerSpinner;
|
||||
static AdView mAdView;
|
||||
|
||||
static Boolean isExtracting = false;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
@ -133,6 +140,7 @@ public class LauncherActivity extends Activity {
|
||||
intent.putExtra("argv", argv);
|
||||
intent.putExtra("gamedir", "cstrike");
|
||||
intent.putExtra("gamelibdir", getFilesDir().getAbsolutePath().replace("/files","/lib"));
|
||||
intent.putExtra("pakfile", getFilesDir().getAbsolutePath() + "/extras.pak" );
|
||||
startActivity(intent);
|
||||
}
|
||||
|
||||
@ -158,4 +166,84 @@ public class LauncherActivity extends Activity {
|
||||
|
||||
super.onPause();
|
||||
}
|
||||
|
||||
private static int chmod(String path, int mode) {
|
||||
int ret = -1;
|
||||
try
|
||||
{
|
||||
ret = Runtime.getRuntime().exec("chmod " + Integer.toOctalString(mode) + " " + path).waitFor();
|
||||
Log.d(TAG, "chmod " + Integer.toOctalString(mode) + " " + path + ": " + ret );
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
ret = -1;
|
||||
Log.d(TAG, "chmod: Runtime not worked: " + e.toString() );
|
||||
}
|
||||
try
|
||||
{
|
||||
Class fileUtils = Class.forName("android.os.FileUtils");
|
||||
Method setPermissions = fileUtils.getMethod("setPermissions",
|
||||
String.class, int.class, int.class, int.class);
|
||||
ret = (Integer) setPermissions.invoke(null, path,
|
||||
mode, -1, -1);
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
ret = -1;
|
||||
Log.d(TAG, "chmod: FileUtils not worked: " + e.toString() );
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
private static void extractFile(Context context, String path) {
|
||||
try
|
||||
{
|
||||
InputStream is = null;
|
||||
FileOutputStream os = null;
|
||||
is = context.getAssets().open(path);
|
||||
File out = new File(context.getFilesDir().getPath()+'/'+path);
|
||||
out.getParentFile().mkdirs();
|
||||
chmod( out.getParent(), 0777 );
|
||||
os = new FileOutputStream(out);
|
||||
byte[] buffer = new byte[1024];
|
||||
int length;
|
||||
while ((length = is.read(buffer)) > 0) {
|
||||
os.write(buffer, 0, length);
|
||||
}
|
||||
os.close();
|
||||
is.close();
|
||||
chmod( context.getFilesDir().getPath()+'/'+path, 0777 );
|
||||
}
|
||||
catch( Exception e )
|
||||
{
|
||||
Log.e( TAG, "Failed to extract file:" + e.toString() );
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
public static void extractPAK(Context context, Boolean force) {
|
||||
if(isExtracting)
|
||||
return;
|
||||
isExtracting = true;
|
||||
try {
|
||||
if( mPref == null )
|
||||
mPref = context.getSharedPreferences("mod", 0);
|
||||
|
||||
if( mPref.getInt( "pakversion", 0 ) == PAK_VERSION && !force )
|
||||
return;
|
||||
|
||||
extractFile(context, "extras.pak");
|
||||
|
||||
SharedPreferences.Editor editor = mPref.edit();
|
||||
editor.putInt( "pakversion", PAK_VERSION );
|
||||
editor.commit();
|
||||
editor.apply();
|
||||
}
|
||||
catch( Exception e )
|
||||
{
|
||||
Log.e( TAG, "Failed to extract PAK:" + e.toString() );
|
||||
}
|
||||
isExtracting = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -23,6 +23,7 @@
|
||||
#define FCAP_DIRECTIONAL_USE 0x00000040
|
||||
#define FCAP_MASTER 0x00000080
|
||||
#define FCAP_FORCE_TRANSITION 0x00000080
|
||||
#include "port.h"
|
||||
|
||||
#include "saverestore.h"
|
||||
#include "schedule.h"
|
||||
|
@ -16,6 +16,7 @@
|
||||
*
|
||||
****/
|
||||
|
||||
#include "port.h"
|
||||
#include <string.h>
|
||||
#ifndef ACTIVITY_H
|
||||
#include "activity.h"
|
||||
|
Loading…
x
Reference in New Issue
Block a user