1. Fix music problem for Android 11/12
This commit is contained in:
parent
2f0b41f39a
commit
1047ee46f4
|
@ -4,7 +4,7 @@
|
||||||
<component name="GradleSettings">
|
<component name="GradleSettings">
|
||||||
<option name="linkedExternalProjectsSettings">
|
<option name="linkedExternalProjectsSettings">
|
||||||
<GradleProjectSettings>
|
<GradleProjectSettings>
|
||||||
<option name="testRunner" value="PLATFORM" />
|
<option name="testRunner" value="GRADLE" />
|
||||||
<option name="distributionType" value="DEFAULT_WRAPPED" />
|
<option name="distributionType" value="DEFAULT_WRAPPED" />
|
||||||
<option name="externalProjectPath" value="$PROJECT_DIR$" />
|
<option name="externalProjectPath" value="$PROJECT_DIR$" />
|
||||||
<option name="modules">
|
<option name="modules">
|
||||||
|
@ -14,7 +14,6 @@
|
||||||
</set>
|
</set>
|
||||||
</option>
|
</option>
|
||||||
<option name="resolveModulePerSourceSet" value="false" />
|
<option name="resolveModulePerSourceSet" value="false" />
|
||||||
<option name="useQualifiedModuleNames" value="true" />
|
|
||||||
</GradleProjectSettings>
|
</GradleProjectSettings>
|
||||||
</option>
|
</option>
|
||||||
</component>
|
</component>
|
||||||
|
|
|
@ -2,5 +2,36 @@
|
||||||
<profile version="1.0">
|
<profile version="1.0">
|
||||||
<option name="myName" value="Project Default" />
|
<option name="myName" value="Project Default" />
|
||||||
<inspection_tool class="AlibabaAvoidManuallyCreateThread" enabled="false" level="CRITICAL" enabled_by_default="false" />
|
<inspection_tool class="AlibabaAvoidManuallyCreateThread" enabled="false" level="CRITICAL" enabled_by_default="false" />
|
||||||
|
<inspection_tool class="JavaDoc" enabled="true" level="WARNING" enabled_by_default="true">
|
||||||
|
<option name="TOP_LEVEL_CLASS_OPTIONS">
|
||||||
|
<value>
|
||||||
|
<option name="ACCESS_JAVADOC_REQUIRED_FOR" value="none" />
|
||||||
|
<option name="REQUIRED_TAGS" value="" />
|
||||||
|
</value>
|
||||||
|
</option>
|
||||||
|
<option name="INNER_CLASS_OPTIONS">
|
||||||
|
<value>
|
||||||
|
<option name="ACCESS_JAVADOC_REQUIRED_FOR" value="none" />
|
||||||
|
<option name="REQUIRED_TAGS" value="" />
|
||||||
|
</value>
|
||||||
|
</option>
|
||||||
|
<option name="METHOD_OPTIONS">
|
||||||
|
<value>
|
||||||
|
<option name="ACCESS_JAVADOC_REQUIRED_FOR" value="none" />
|
||||||
|
<option name="REQUIRED_TAGS" value="@return@param@throws or @exception" />
|
||||||
|
</value>
|
||||||
|
</option>
|
||||||
|
<option name="FIELD_OPTIONS">
|
||||||
|
<value>
|
||||||
|
<option name="ACCESS_JAVADOC_REQUIRED_FOR" value="none" />
|
||||||
|
<option name="REQUIRED_TAGS" value="" />
|
||||||
|
</value>
|
||||||
|
</option>
|
||||||
|
<option name="IGNORE_DEPRECATED" value="false" />
|
||||||
|
<option name="IGNORE_JAVADOC_PERIOD" value="true" />
|
||||||
|
<option name="IGNORE_DUPLICATED_THROWS" value="false" />
|
||||||
|
<option name="IGNORE_POINT_TO_ITSELF" value="false" />
|
||||||
|
<option name="myAdditionalJavadocTags" value="date" />
|
||||||
|
</inspection_tool>
|
||||||
</profile>
|
</profile>
|
||||||
</component>
|
</component>
|
|
@ -1,12 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project version="4">
|
|
||||||
<component name="RunConfigurationProducerService">
|
|
||||||
<option name="ignoredProducers">
|
|
||||||
<set>
|
|
||||||
<option value="org.jetbrains.plugins.gradle.execution.test.runner.AllInPackageGradleConfigurationProducer" />
|
|
||||||
<option value="org.jetbrains.plugins.gradle.execution.test.runner.TestClassGradleConfigurationProducer" />
|
|
||||||
<option value="org.jetbrains.plugins.gradle.execution.test.runner.TestMethodGradleConfigurationProducer" />
|
|
||||||
</set>
|
|
||||||
</option>
|
|
||||||
</component>
|
|
||||||
</project>
|
|
|
@ -12,8 +12,8 @@ android {
|
||||||
applicationId "com.zane.smapiinstaller"
|
applicationId "com.zane.smapiinstaller"
|
||||||
minSdkVersion 19
|
minSdkVersion 19
|
||||||
targetSdkVersion 30
|
targetSdkVersion 30
|
||||||
versionCode 71
|
versionCode 72
|
||||||
versionName "3.7.6.9"
|
versionName "3.7.6.10"
|
||||||
|
|
||||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||||
multiDexEnabled true
|
multiDexEnabled true
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
<uses-permission android:name="android.permission.REQUEST_DELETE_PACKAGES"/>
|
<uses-permission android:name="android.permission.REQUEST_DELETE_PACKAGES"/>
|
||||||
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
|
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
|
||||||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
|
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
|
||||||
<uses-permission android:name="android.permission.MANAGE_EXTERNAL_STORAGE" />
|
<uses-permission android:name="android.permission.MANAGE_EXTERNAL_STORAGE" tools:ignore="ScopedStorage" />
|
||||||
<queries>
|
<queries>
|
||||||
<package android:name="com.chucklefish.stardewvalley"/>
|
<package android:name="com.chucklefish.stardewvalley"/>
|
||||||
<package android:name="com.zane.stardewvalley"/>
|
<package android:name="com.zane.stardewvalley"/>
|
||||||
|
@ -30,6 +30,7 @@
|
||||||
android:configChanges="orientation|keyboard|screenSize"
|
android:configChanges="orientation|keyboard|screenSize"
|
||||||
android:networkSecurityConfig="@xml/network_security_config"
|
android:networkSecurityConfig="@xml/network_security_config"
|
||||||
android:theme="@style/AppTheme"
|
android:theme="@style/AppTheme"
|
||||||
|
android:preserveLegacyExternalStorage="true"
|
||||||
android:requestLegacyExternalStorage="true"
|
android:requestLegacyExternalStorage="true"
|
||||||
tools:ignore="UnusedAttribute"
|
tools:ignore="UnusedAttribute"
|
||||||
android:largeHeap="true">
|
android:largeHeap="true">
|
||||||
|
|
Binary file not shown.
|
@ -1,7 +1,6 @@
|
||||||
package com.zane.smapiinstaller;
|
package com.zane.smapiinstaller;
|
||||||
|
|
||||||
import android.Manifest;
|
import android.Manifest;
|
||||||
import android.content.ActivityNotFoundException;
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.pm.PackageManager;
|
import android.content.pm.PackageManager;
|
||||||
|
@ -95,13 +94,7 @@ public class MainActivity extends AppCompatActivity {
|
||||||
requestPermissions();
|
requestPermissions();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
try {
|
CommonLogic.openPermissionSetting(this);
|
||||||
Intent intent = new Intent(Settings.ACTION_MANAGE_ALL_FILES_ACCESS_PERMISSION);
|
|
||||||
intent.setData(Uri.parse("package:" + this.getPackageName()));
|
|
||||||
startActivityForResult(intent, ActivityResultHandler.REQUEST_CODE_ALL_FILES_ACCESS_PERMISSION);
|
|
||||||
} catch (ActivityNotFoundException ignored){
|
|
||||||
startActivityForResult(new Intent(Settings.ACTION_MANAGE_ALL_FILES_ACCESS_PERMISSION), ActivityResultHandler.REQUEST_CODE_ALL_FILES_ACCESS_PERMISSION);
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
this.finish();
|
this.finish();
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,6 +12,7 @@ import java.util.function.BiConsumer;
|
||||||
public class ActivityResultHandler {
|
public class ActivityResultHandler {
|
||||||
public static final int REQUEST_CODE_APP_INSTALL = 1001;
|
public static final int REQUEST_CODE_APP_INSTALL = 1001;
|
||||||
public static final int REQUEST_CODE_ALL_FILES_ACCESS_PERMISSION = 1002;
|
public static final int REQUEST_CODE_ALL_FILES_ACCESS_PERMISSION = 1002;
|
||||||
|
public static final int REQUEST_CODE_OBB_FILES_ACCESS_PERMISSION = 1003;
|
||||||
|
|
||||||
public static ConcurrentHashMap<Integer, BiConsumer<Integer, Intent>> listenerMap = new ConcurrentHashMap<>();
|
public static ConcurrentHashMap<Integer, BiConsumer<Integer, Intent>> listenerMap = new ConcurrentHashMap<>();
|
||||||
|
|
||||||
|
|
|
@ -11,6 +11,8 @@ import android.content.pm.PackageInfo;
|
||||||
import android.content.pm.PackageManager;
|
import android.content.pm.PackageManager;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
|
import android.provider.DocumentsContract;
|
||||||
|
import android.provider.Settings;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.animation.Animation;
|
import android.view.animation.Animation;
|
||||||
|
@ -55,6 +57,8 @@ import java.util.function.Consumer;
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
|
import androidx.annotation.RequiresApi;
|
||||||
|
import androidx.documentfile.provider.DocumentFile;
|
||||||
import pxb.android.axml.AxmlReader;
|
import pxb.android.axml.AxmlReader;
|
||||||
import pxb.android.axml.AxmlVisitor;
|
import pxb.android.axml.AxmlVisitor;
|
||||||
import pxb.android.axml.AxmlWriter;
|
import pxb.android.axml.AxmlWriter;
|
||||||
|
@ -210,7 +214,9 @@ public class CommonLogic {
|
||||||
* @return 操作是否成功
|
* @return 操作是否成功
|
||||||
*/
|
*/
|
||||||
public static boolean unpackSmapiFiles(Context context, String apkPath, boolean checkMode, String packageName, long versionCode) {
|
public static boolean unpackSmapiFiles(Context context, String apkPath, boolean checkMode, String packageName, long versionCode) {
|
||||||
checkMusic(packageName, checkMode);
|
if(!checkMusic(context)){
|
||||||
|
return false;
|
||||||
|
}
|
||||||
List<ApkFilesManifest> apkFilesManifests = CommonLogic.findAllApkFileManifest(context);
|
List<ApkFilesManifest> apkFilesManifests = CommonLogic.findAllApkFileManifest(context);
|
||||||
filterManifest(apkFilesManifests, packageName, versionCode);
|
filterManifest(apkFilesManifests, packageName, versionCode);
|
||||||
List<ManifestEntry> manifestEntries = null;
|
List<ManifestEntry> manifestEntries = null;
|
||||||
|
@ -268,11 +274,26 @@ public class CommonLogic {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void checkMusic(String packageName, boolean checkMode) {
|
private static boolean checkMusic(Context context) {
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R && StringUtils.equals(packageName, Constants.ORIGIN_PACKAGE_NAME_GOOGLE)) {
|
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.Q) {
|
||||||
File pathFrom = new File(FileUtils.getStadewValleyBasePath(), "Android/obb/" + packageName);
|
File pathFrom = new File(FileUtils.getStadewValleyBasePath(), "Android/obb/" + Constants.ORIGIN_PACKAGE_NAME_GOOGLE);
|
||||||
File pathTo = new File(FileUtils.getStadewValleyBasePath(), "Android/obb/" + Constants.TARGET_PACKAGE_NAME);
|
File pathTo = new File(FileUtils.getStadewValleyBasePath(), "StardewValley");
|
||||||
if (pathFrom.exists() && pathFrom.isDirectory()) {
|
if (pathFrom.exists() && pathFrom.isDirectory()) {
|
||||||
|
if (!pathFrom.canRead()) {
|
||||||
|
ActivityResultHandler.registerListener(ActivityResultHandler.REQUEST_CODE_ALL_FILES_ACCESS_PERMISSION, (resultCode, data) -> {
|
||||||
|
if (resultCode == Activity.RESULT_OK) {
|
||||||
|
if (data == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Uri uri = data.getData();
|
||||||
|
if (uri == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
context.getContentResolver().takePersistableUriPermission(uri, Intent.FLAG_GRANT_READ_URI_PERMISSION);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
openObbRootPermission((Activity) context, ActivityResultHandler.REQUEST_CODE_OBB_FILES_ACCESS_PERMISSION);
|
||||||
|
}
|
||||||
if (!pathTo.exists()) {
|
if (!pathTo.exists()) {
|
||||||
pathTo.mkdirs();
|
pathTo.mkdirs();
|
||||||
}
|
}
|
||||||
|
@ -291,6 +312,7 @@ public class CommonLogic {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void unpackFromApk(String apkPath, boolean checkMode, ManifestEntry entry, File targetFile) {
|
private static void unpackFromApk(String apkPath, boolean checkMode, ManifestEntry entry, File targetFile) {
|
||||||
|
@ -445,6 +467,41 @@ public class CommonLogic {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@RequiresApi(api = Build.VERSION_CODES.R)
|
||||||
|
public static void openPermissionSetting(Activity activity) {
|
||||||
|
try {
|
||||||
|
Intent intent = new Intent(Settings.ACTION_MANAGE_ALL_FILES_ACCESS_PERMISSION);
|
||||||
|
intent.addCategory("android.intent.category.DEFAULT");
|
||||||
|
intent.setData(Uri.parse("package:" + activity.getPackageName()));
|
||||||
|
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||||
|
activity.startActivityForResult(intent, ActivityResultHandler.REQUEST_CODE_ALL_FILES_ACCESS_PERMISSION);
|
||||||
|
} catch (ActivityNotFoundException ignored){
|
||||||
|
Intent intent = new Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
|
||||||
|
intent.setData(Uri.parse("package:" + activity.getPackageName()));
|
||||||
|
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||||
|
try {
|
||||||
|
activity.startActivityForResult(intent, ActivityResultHandler.REQUEST_CODE_ALL_FILES_ACCESS_PERMISSION);
|
||||||
|
}
|
||||||
|
catch (ActivityNotFoundException ignored2) {
|
||||||
|
intent = new Intent(Settings.ACTION_MANAGE_ALL_FILES_ACCESS_PERMISSION);
|
||||||
|
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||||
|
activity.startActivityForResult(intent, ActivityResultHandler.REQUEST_CODE_ALL_FILES_ACCESS_PERMISSION);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void openObbRootPermission(Activity context, int REQUEST_CODE_FOR_DIR) {
|
||||||
|
Uri uri1 = Uri.parse("content://com.android.externalstorage.documents/tree/primary%3AAndroid%2Fobb");
|
||||||
|
DocumentFile documentFile = DocumentFile.fromTreeUri(context, uri1);
|
||||||
|
Intent intent1 = new Intent(Intent.ACTION_OPEN_DOCUMENT_TREE);
|
||||||
|
intent1.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION
|
||||||
|
| Intent.FLAG_GRANT_WRITE_URI_PERMISSION
|
||||||
|
| Intent.FLAG_GRANT_PERSISTABLE_URI_PERMISSION
|
||||||
|
| Intent.FLAG_GRANT_PREFIX_URI_PERMISSION);
|
||||||
|
intent1.putExtra(DocumentsContract.EXTRA_INITIAL_URI, documentFile.getUri());
|
||||||
|
context.startActivityForResult(intent1, REQUEST_CODE_FOR_DIR);
|
||||||
|
}
|
||||||
|
|
||||||
public static void showPrivacyPolicy(View view, BiConsumer<MaterialDialog, DialogAction> callback) {
|
public static void showPrivacyPolicy(View view, BiConsumer<MaterialDialog, DialogAction> callback) {
|
||||||
Context context = view.getContext();
|
Context context = view.getContext();
|
||||||
String policy = FileUtils.getLocaledAssetText(context, "privacy_policy.txt");
|
String policy = FileUtils.getLocaledAssetText(context, "privacy_policy.txt");
|
||||||
|
|
|
@ -87,6 +87,6 @@
|
||||||
<string name="settings_rewrite_in_parallel">Перепишіть у Parallel</string>
|
<string name="settings_rewrite_in_parallel">Перепишіть у Parallel</string>
|
||||||
<string name="request_unknown_source_permission">Необхідно увімкнути дозвіл встановлення з невідомих джерел для встановлення фреймворку мода, відкрити налаштування?</string>
|
<string name="request_unknown_source_permission">Необхідно увімкнути дозвіл встановлення з невідомих джерел для встановлення фреймворку мода, відкрити налаштування?</string>
|
||||||
<string name="settings_rewrite_missing">Перепишіть загублене</string>
|
<string name="settings_rewrite_missing">Перепишіть загублене</string>
|
||||||
<string name="settings_set_app_name">Ім'я запатченого застосунка</string>
|
<string name="settings_set_app_name">Ім\'я запатченого застосунка</string>
|
||||||
<string name="request_all_files_access_permission">Потрібен дозвіл на доступ до всіх файлів на Android Q чи більш пізньої версії, щоб встановити модифікацію, продовжити?</string>
|
<string name="request_all_files_access_permission">Потрібен дозвіл на доступ до всіх файлів на Android Q чи більш пізньої версії, щоб встановити модифікацію, продовжити?</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|
Loading…
Reference in New Issue