Skip to content

Commit

Permalink
添加readme
Browse files Browse the repository at this point in the history
  • Loading branch information
StArrayJaN committed Oct 24, 2023
1 parent 8662dc6 commit d02ef67
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 16 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Where's My Water Decompile Project (WMWD or WMWDP)

You can download the built APK from the [Actions](https://github.com/TherCN/Where-is-My-Water/actions) tab, and you can also use [AIDE](https://android-ide.com) to clone this repository and manually compile it
If you have any features you would like to add, please explain them in the [Issues](https://github.com/TherCN/Where-is-My-Water/issues) section or submit the code in the [Pull Request](https://github.com/TherCN/Where-is-My-Water/pulls) section and explain the specific purpose of the code
2 changes: 1 addition & 1 deletion app/src/main/java/com/disney/WMW/WMWActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -556,7 +556,7 @@ public void setDataFromManifest() {
StringBuilder stringbuilder1 = new StringBuilder();
Log.d("WMWActivity", stringbuilder1.append("SAMSUNG_DRM_ENABLED=").append(SAMSUNG_DRM_ENABLED).toString());
} catch (Exception exception) {
Log.wtf("WMWJava", "Package manager get FAILED!");
Log.e("WMWJava", "Package manager get FAILED!",exception);
}
}

Expand Down
38 changes: 23 additions & 15 deletions app/src/main/java/thercn/wmw/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import android.app.Activity;
import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.pm.PackageInfo;
Expand All @@ -18,6 +19,7 @@
import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.Date;
import android.widget.Toast;

public class MainActivity extends Activity {

Expand All @@ -28,40 +30,46 @@ public class MainActivity extends Activity {
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
//申请权限
Permission.申请(this);
Log.e("WMW","安装包目录:" + getPackageResourcePath());

File libDir = new File(new File(getPackageResourcePath()).getParentFile().getAbsolutePath() + "/lib");
Log.e("WMW","二进制库目录:" + libDir.getAbsolutePath());

//添加数据目录的File对象
File obbdir = getObbDir();
File dataDir = new File(appDataDir);
File extraDataFile = new File(appDataDir + "/wmw-extra.zip");

//检测是否存在,不存在则创建,存在则用文本显示更新时间
if (!obbdir.exists() || !dataDir.exists()) {
obbdir.mkdirs();
dataDir.mkdirs();
} else{
TextView checkObb = findViewById(R.id.checkObb);

//设置时间格式
long lastModifiedTime = extraDataFile.lastModified();
Date lastModifiedDate = new Date(lastModifiedTime);
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String formattedDate = dateFormat.format(lastModifiedDate);

//显示更新时间
checkObb.setText(getString(R.string.have_obb) + formattedDate);
}

String obbPath = getObbPath();
//将安装包内的wmw-extra.zip解压并复制到obb目录
String obbPath = getObbPath(this);
if (!extraDataFile.exists()) {
AppUtils.ExportAssets(this, appDataDir, "wmw-extra.zip");
}

Process process = null;
try {
Runtime.getRuntime().exec("cp " + extraDataFile.toString() + " " + obbPath);
//Runtime.getRuntime().exec("logcat -c");
process = Runtime.getRuntime().exec("cp " + extraDataFile.toString() + " " + obbPath);
if (process.waitFor() != 0)
{
Toast.makeText(this,"OBB replication failed",0).show();
}
//记录日志
Runtime.getRuntime().exec("logcat >" + appDataDir + "/wmw.log");
} catch (IOException e) {
} catch (IOException|InterruptedException e) {
Log.e("WMW","",e);
}

Expand All @@ -78,6 +86,7 @@ public void onBackPressed() {
.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dia, int which) {
onDestroy();
System.exit(0);
}
})
Expand All @@ -86,16 +95,15 @@ public void onClick(DialogInterface dia, int which) {
dialog.show();
}

public String getObbPath() {
PackageManager packageManager = getPackageManager();
public static String getObbPath(Context context) {
PackageManager packageManager = context.getPackageManager();
PackageInfo packageInfo = null;
try {
packageInfo = packageManager.getPackageInfo(getPackageName(), 0);
packageInfo = packageManager.getPackageInfo(context.getPackageName(), 0);
} catch (PackageManager.NameNotFoundException e) {}
String pn = getPackageName();
String pn = context.getPackageName();
if (Environment.getExternalStorageState().equals("mounted")) {
File file = Environment.getExternalStorageDirectory();
file = new File(getObbDir().toString());
File file = new File(context.getObbDir().toString());
if (packageInfo.versionCode > 0) {
String str = file + File.separator + "main." + packageInfo.versionCode + "." + pn + ".obb";
Log.e("WMW", "obbFilePath: " + str);
Expand Down

0 comments on commit d02ef67

Please sign in to comment.