Heroes III HD v1.1.6版本的 MD5 值为:99ed52e2d6b85487933b8dc8c0440b36
以下内容为反编译后的 LaunchActivity.java 源代码,内容仅作参考
package com.ubisoft.mightandmagic.heroesiii;
import android.app.Activity;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
import android.net.wifi.WifiInfo;
import android.net.wifi.WifiManager;
import android.os.Bundle;
import android.os.Environment;
import android.util.DisplayMetrics;
import android.view.KeyEvent;
import android.view.MotionEvent;
import android.view.WindowManager;
import android.widget.ImageView;
import android.widget.ProgressBar;
import android.widget.TextView;
import com.dotemu.homm3.installer.GameInstaller;
import com.dotemu.homm3.installer.GameInstallerProgressListener;
import com.dotemu.homm3.installer.GamePackage;
import obfuse.NPStringFog;
public class LaunchActivity extends Activity implements GameInstallerProgressListener {
public static final String DOWNLOAD_URL = "http://corporate.dotemu.com/homm3/%s";
public static final boolean GOOGLE_LICENSING_BUILD = false;
private static final int MAIN_FILE_SIZE = 436954878;
public static final String PACKAGE_MAIN_FILE = "homm3_main%d.zip";
public static final String PACKAGE_TEXTURES_FILE = "homm3_%s%d.zip";
public static final int PACKAGE_VERSION = 83;
public static final boolean STAND_ALONE_BUILD = false;
protected String gameDirectory;
AlertDialog packageErrorAlert;
AlertDialog.Builder packageErrorBuilder;
protected static GameInstaller gameInstaller = null;
private static final String[] TXT_FILE_TYPES = {NPStringFog.decode("0B040E")};
private static final int[] TXT_FILE_SIZES = {550437557};
private TextView packageText = null;
private TextView progressText = null;
private ProgressBar progressBar = null;
private boolean bInstallerRunning = false;
private boolean bFirstResume = true;
private boolean bErrorOccured = false;
private int packageSize = 0;
protected void createGameInstaller(String apkPath) {
gameInstaller = new GameInstaller(this, this);
GamePackage[] txtPackages = new GamePackage[TXT_FILE_TYPES.length];
GamePackage mainPackage = new GamePackage(String.format(NPStringFog.decode("061F000C5D3E0A041B0055094F140817"), 83), String.format(NPStringFog.decode("06041911544E48061D1C0002130F15024B160104080C1B4F040A1F4118020C0352484001"), String.format(NPStringFog.decode("061F000C5D3E0A041B0055094F140817"), 83)), NPStringFog.decode("061F000C5D3E0A041B0055094F140817"), MAIN_FILE_SIZE, null);
mainPackage.setUnpack(true);
gameInstaller.addPackage(mainPackage);
for (int i = 0; i < TXT_FILE_TYPES.length; i++) {
String packageName = String.format(NPStringFog.decode("061F000C5D3E4216570A5E17081E"), TXT_FILE_TYPES[i], 83);
txtPackages[i] = new GamePackage(packageName, String.format(NPStringFog.decode("06041911544E48061D1C0002130F15024B160104080C1B4F040A1F4118020C0352484001"), packageName), packageName, TXT_FILE_SIZES[i], null);
txtPackages[i].setUnpack(true);
gameInstaller.addPackage(txtPackages[i]);
}
GamePackage apkPackage = new GamePackage(NPStringFog.decode("2F2026"), "APK", apkPath, 0, null);
gameInstaller.addPackage(apkPackage);
}
protected Intent prepareNextActivity() {
return new Intent(this, MainActivity.class);
}
protected void setImageLogo(ImageView iv) {
iv.setImageResource(R.drawable.h3_logo);
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
WindowManager.LayoutParams layoutParams = super.getWindow().getAttributes();
layoutParams.flags |= 2097280;
getWindow().setAttributes(layoutParams);
PackageManager packageManager = getApplication().getPackageManager();
try {
ApplicationInfo applicationInfo = packageManager.getApplicationInfo(getApplication().getPackageName(), 0);
String apkPath = applicationInfo.sourceDir;
createGameInstaller(apkPath);
this.bInstallerRunning = false;
this.gameDirectory = Environment.getExternalStorageDirectory() + NPStringFog.decode("413103051C0E0E015D0A11190041") + getPackageName() + NPStringFog.decode("4116040D0B12");
String message = getString(R.string.install_error_download);
this.packageErrorBuilder = new AlertDialog.Builder(this);
this.packageErrorBuilder.setMessage(message).setCancelable(false).setNeutralButton(R.string.okay, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int id) {
LaunchActivity.this.bErrorOccured = true;
}
});
this.packageErrorAlert = this.packageErrorBuilder.create();
} catch (PackageManager.NameNotFoundException e) {
e.printStackTrace();
throw new RuntimeException(NPStringFog.decode("3B1E0C03020447111D4E1C02020F150245131D0308151D4D470410010219080006494B5C"));
}
}
@Override
public void onWindowFocusChanged(boolean hasFocus) {
if (hasFocus && this.bErrorOccured) {
System.exit(0);
}
super.onWindowFocusChanged(hasFocus);
}
@Override
public void onResume() {
super.onResume();
if (this.bFirstResume) {
this.bFirstResume = false;
if (gameInstaller != null && !this.bInstallerRunning) {
runOnUiThread(new AnonymousClass2());
}
}
}
class AnonymousClass2 implements Runnable {
AnonymousClass2() {
}
@Override
public final void run() {
LaunchActivity.gameInstaller.checkSdCard();
if (!LaunchActivity.gameInstaller.checkGameInstallation()) {
LaunchActivity.this.setContentView(R.layout.launch);
LaunchActivity.this.packageText = (TextView) LaunchActivity.this.findViewById(R.id.txtPackageName);
LaunchActivity.this.progressText = (TextView) LaunchActivity.this.findViewById(R.id.txtProgress);
LaunchActivity.this.progressBar = (ProgressBar) LaunchActivity.this.findViewById(R.id.progressBar1);
ImageView iv = (ImageView) LaunchActivity.this.findViewById(R.id.logoView);
LaunchActivity.this.setImageLogo(iv);
WifiManager wfm = (WifiManager) LaunchActivity.this.getSystemService(NPStringFog.decode("19190B08"));
WifiInfo wfi = null;
String ssid = null;
boolean bWifi = wfm.isWifiEnabled();
if (bWifi && (wfi = wfm.getConnectionInfo()) != null) {
ssid = wfi.getSSID();
}
if (bWifi && wfi != null && ssid != null) {
LaunchActivity.this.bInstallerRunning = true;
LaunchActivity.gameInstaller.execute((Object[]) null);
return;
}
try {
LaunchActivity.this.runOnUiThread(new Runnable() {
@Override
public final void run() {
AlertDialog.Builder builder = new AlertDialog.Builder(LaunchActivity.this);
builder.setMessage(R.string.install_msg_download).setCancelable(false).setPositiveButton(R.string.yes, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int id) {
LaunchActivity.this.bInstallerRunning = true;
LaunchActivity.gameInstaller.execute((Object[]) null);
}
}).setNegativeButton(R.string.no, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int id) {
LaunchActivity.this.finish();
}
});
AlertDialog alert = builder.create();
alert.show();
}
});
return;
} catch (Exception e) {
return;
}
}
LaunchActivity.this.launchNextActivity();
}
}
@Override
protected void onPause() {
super.onPause();
if (isFinishing() && gameInstaller != null && this.bInstallerRunning) {
gameInstaller.cancel(true);
this.bInstallerRunning = false;
}
}
@Override
public void onStop() {
super.onStop();
System.gc();
}
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
if (keyCode == 4) {
finish();
}
return true;
}
@Override
public boolean onKeyUp(int keyCode, KeyEvent event) {
return true;
}
@Override
public boolean onTrackballEvent(MotionEvent event) {
return true;
}
public void updateProgressBar(final int percent) {
runOnUiThread(new Runnable() {
@Override
public final void run() {
int p = percent;
if (p > 100) {
p = 100;
} else if (p < 0) {
p = 0;
}
if (p != LaunchActivity.this.progressBar.getProgress()) {
LaunchActivity.this.progressBar.setProgress(p);
}
}
});
}
public void updatePackageName(final String text) {
runOnUiThread(new Runnable() {
@Override
public final void run() {
LaunchActivity.this.packageText.setText(text);
}
});
}
public void updateProgressText(int resId) {
final String text = getString(resId);
runOnUiThread(new Runnable() {
@Override
public final void run() {
LaunchActivity.this.progressText.setText(text);
}
});
}
public void updateProgressText(final String text) {
runOnUiThread(new Runnable() {
@Override
public final void run() {
LaunchActivity.this.progressText.setText(text);
}
});
}
public void launchNextActivity() {
DisplayMetrics metrics = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(metrics);
runOnUiThread(new Runnable() {
@Override
public final void run() {
if (!LaunchActivity.this.bErrorOccured) {
Intent i = LaunchActivity.this.prepareNextActivity();
LaunchActivity.this.startActivity(i);
}
LaunchActivity.this.finish();
}
});
}
@Override
public void onPackageBegin(String name, int size) {
String currentPackage = getString(R.string.install_current_package);
updatePackageName(String.format(NPStringFog.decode("4B0357414B12474D5740410B4123234E"), currentPackage, name, Float.valueOf(size / 1048576.0f)));
this.packageSize = size;
}
@Override
public void onPackageDownload(int bytes) {
String downloading = getString(R.string.install_status);
updateProgressText(String.format(NPStringFog.decode("4B036744405001453F2C"), downloading, Float.valueOf(bytes / 1048576.0f)));
if (this.packageSize > 0) {
updateProgressBar((int) ((bytes * 100) / this.packageSize));
}
}
@Override
public void onPackageVerify() {
String verifyPackage = getString(R.string.install_pkg_verify);
updateProgressText(verifyPackage);
}
@Override
public void onPackageUnpack(String file, int percent) {
String unpacking = getString(R.string.install_pkg_unpack);
updateProgressText(String.valueOf(unpacking) + '\n' + file);
updateProgressBar(percent);
}
@Override
public void onPackageError(String name, int errorNumber) {
try {
runOnUiThread(new Runnable() {
@Override
public final void run() {
if (!LaunchActivity.this.isFinishing()) {
LaunchActivity.this.packageErrorAlert.show();
}
}
});
} catch (Exception e) {
}
try {
gameInstaller.cancel(true);
} catch (Exception e2) {
e2.printStackTrace();
}
}
@Override
public void onPackageDone(String name) {
String finishing = getString(R.string.install_pkg_finish);
updateProgressText(String.valueOf(finishing) + '\n' + name);
}
@Override
public void onNoFreeSpaceError(int mb) {
try {
runOnUiThread(new Runnable() {
@Override
public final void run() {
AlertDialog.Builder builder = new AlertDialog.Builder(LaunchActivity.this);
builder.setMessage(R.string.install_no_space).setCancelable(false).setNeutralButton(R.string.okay, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int id) {
LaunchActivity.this.bErrorOccured = true;
}
});
AlertDialog alert = builder.create();
alert.show();
}
});
} catch (Exception e) {
}
try {
if (gameInstaller != null) {
gameInstaller.cancel(true);
}
} catch (Exception e2) {
e2.printStackTrace();
}
}
@Override
public void onSdCardError(String errorState) {
try {
runOnUiThread(new Runnable() {
@Override
public final void run() {
AlertDialog.Builder builder = new AlertDialog.Builder(LaunchActivity.this);
builder.setMessage(R.string.install_unmount_media).setCancelable(false).setNeutralButton(R.string.okay, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int id) {
LaunchActivity.this.bErrorOccured = true;
}
});
AlertDialog alert = builder.create();
alert.show();
}
});
} catch (Exception e) {
}
try {
if (gameInstaller != null) {
gameInstaller.cancel(true);
}
} catch (Exception e2) {
e2.printStackTrace();
}
}
@Override
public void onNoInternetError() {
try {
runOnUiThread(new Runnable() {
@Override
public final void run() {
AlertDialog.Builder builder = new AlertDialog.Builder(LaunchActivity.this);
builder.setMessage(R.string.install_no_connection).setCancelable(false).setNeutralButton(R.string.okay, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int id) {
LaunchActivity.this.bErrorOccured = true;
}
});
AlertDialog alert = builder.create();
alert.show();
}
});
} catch (Exception e) {
e.printStackTrace();
}
try {
gameInstaller.cancel(false);
} catch (Exception e2) {
e2.printStackTrace();
}
}
@Override
public void onInstallFinished(boolean bInstallOccured) {
boolean installed = gameInstaller.checkGameInstallation();
if (gameInstaller != null) {
gameInstaller = null;
System.gc();
}
if (installed) {
launchNextActivity();
}
}
@Override
public void onDestroy() {
super.onDestroy();
if (this.packageErrorAlert != null) {
this.packageErrorAlert.dismiss();
}
}
}