Merge pull request #10560 from JosJuice/android-wii-disc-update
Android: Implement installing system update from disc image
This commit is contained in:
commit
a8654e2c69
|
@ -21,6 +21,7 @@ import org.dolphinemu.dolphinemu.features.settings.model.StringSetting;
|
|||
import org.dolphinemu.dolphinemu.features.settings.ui.MenuTag;
|
||||
import org.dolphinemu.dolphinemu.features.settings.ui.SettingsActivity;
|
||||
import org.dolphinemu.dolphinemu.model.GameFile;
|
||||
import org.dolphinemu.dolphinemu.ui.main.MainPresenter;
|
||||
import org.dolphinemu.dolphinemu.ui.platform.Platform;
|
||||
import org.dolphinemu.dolphinemu.utils.AlertDialogItemsBuilder;
|
||||
import org.dolphinemu.dolphinemu.utils.DirectoryInitialization;
|
||||
|
@ -101,6 +102,12 @@ public class GamePropertiesDialog extends DialogFragment
|
|||
ConvertActivity.launch(getContext(), path));
|
||||
}
|
||||
|
||||
if (isDisc && isWii)
|
||||
{
|
||||
itemsBuilder.add(R.string.properties_system_update, (dialog, i) ->
|
||||
MainPresenter.launchDiscUpdate(path, requireActivity()));
|
||||
}
|
||||
|
||||
itemsBuilder.add(R.string.properties_edit_game_settings, (dialog, i) ->
|
||||
SettingsActivity.launch(getContext(), MenuTag.SETTINGS, gameId, revision, isWii));
|
||||
|
||||
|
|
|
@ -31,8 +31,8 @@ public class OnlineUpdateRegionSelectDialogFragment extends DialogFragment
|
|||
new ViewModelProvider(requireActivity()).get(SystemUpdateViewModel.class);
|
||||
viewModel.setRegion(which);
|
||||
|
||||
OnlineUpdateProgressBarDialogFragment progressBarFragment =
|
||||
new OnlineUpdateProgressBarDialogFragment();
|
||||
SystemUpdateProgressBarDialogFragment progressBarFragment =
|
||||
new SystemUpdateProgressBarDialogFragment();
|
||||
progressBarFragment
|
||||
.show(getParentFragmentManager(), "OnlineUpdateProgressBarDialogFragment");
|
||||
progressBarFragment.setCancelable(false);
|
||||
|
|
|
@ -14,7 +14,7 @@ import androidx.lifecycle.ViewModelProvider;
|
|||
|
||||
import org.dolphinemu.dolphinemu.R;
|
||||
|
||||
public class OnlineUpdateProgressBarDialogFragment extends DialogFragment
|
||||
public class SystemUpdateProgressBarDialogFragment extends DialogFragment
|
||||
{
|
||||
@NonNull
|
||||
@Override
|
||||
|
@ -74,7 +74,7 @@ public class OnlineUpdateProgressBarDialogFragment extends DialogFragment
|
|||
return;
|
||||
}
|
||||
|
||||
OnlineUpdateResultFragment progressBarFragment = new OnlineUpdateResultFragment();
|
||||
SystemUpdateResultFragment progressBarFragment = new SystemUpdateResultFragment();
|
||||
progressBarFragment.show(getParentFragmentManager(), "OnlineUpdateResultFragment");
|
||||
|
||||
getActivity().setRequestedOrientation(orientation);
|
||||
|
@ -84,28 +84,7 @@ public class OnlineUpdateProgressBarDialogFragment extends DialogFragment
|
|||
|
||||
if (savedInstanceState == null)
|
||||
{
|
||||
final String region;
|
||||
int selectedItem = viewModel.getRegion();
|
||||
|
||||
switch (selectedItem)
|
||||
{
|
||||
case 0:
|
||||
region = "EUR";
|
||||
break;
|
||||
case 1:
|
||||
region = "JPN";
|
||||
break;
|
||||
case 2:
|
||||
region = "KOR";
|
||||
break;
|
||||
case 3:
|
||||
region = "USA";
|
||||
break;
|
||||
default:
|
||||
region = "";
|
||||
break;
|
||||
}
|
||||
viewModel.startUpdate(region);
|
||||
viewModel.startUpdate();
|
||||
}
|
||||
return progressDialog;
|
||||
}
|
|
@ -13,7 +13,7 @@ import androidx.lifecycle.ViewModelProvider;
|
|||
import org.dolphinemu.dolphinemu.R;
|
||||
import org.dolphinemu.dolphinemu.utils.WiiUtils;
|
||||
|
||||
public class OnlineUpdateResultFragment extends DialogFragment
|
||||
public class SystemUpdateResultFragment extends DialogFragment
|
||||
{
|
||||
private int mResult;
|
||||
|
|
@ -5,6 +5,7 @@ package org.dolphinemu.dolphinemu.features.sysupdate.ui;
|
|||
import androidx.lifecycle.MutableLiveData;
|
||||
import androidx.lifecycle.ViewModel;
|
||||
|
||||
import org.dolphinemu.dolphinemu.utils.WiiUpdateCallback;
|
||||
import org.dolphinemu.dolphinemu.utils.WiiUtils;
|
||||
|
||||
import java.util.concurrent.ExecutorService;
|
||||
|
@ -21,6 +22,7 @@ public class SystemUpdateViewModel extends ViewModel
|
|||
|
||||
private boolean mCanceled = false;
|
||||
private int mRegion;
|
||||
private String mDiscPath;
|
||||
|
||||
public SystemUpdateViewModel()
|
||||
{
|
||||
|
@ -37,6 +39,16 @@ public class SystemUpdateViewModel extends ViewModel
|
|||
return mRegion;
|
||||
}
|
||||
|
||||
public void setDiscPath(String discPath)
|
||||
{
|
||||
mDiscPath = discPath;
|
||||
}
|
||||
|
||||
public String getDiscPath()
|
||||
{
|
||||
return mDiscPath;
|
||||
}
|
||||
|
||||
public MutableLiveData<Integer> getProgressData()
|
||||
{
|
||||
return mProgressData;
|
||||
|
@ -62,21 +74,55 @@ public class SystemUpdateViewModel extends ViewModel
|
|||
mCanceled = true;
|
||||
}
|
||||
|
||||
public void startUpdate(String region)
|
||||
public void startUpdate()
|
||||
{
|
||||
if (!mDiscPath.isEmpty())
|
||||
{
|
||||
startDiscUpdate(mDiscPath);
|
||||
}
|
||||
else
|
||||
{
|
||||
final String region;
|
||||
switch (mRegion)
|
||||
{
|
||||
case 0:
|
||||
region = "EUR";
|
||||
break;
|
||||
case 1:
|
||||
region = "JPN";
|
||||
break;
|
||||
case 2:
|
||||
region = "KOR";
|
||||
break;
|
||||
case 3:
|
||||
region = "USA";
|
||||
break;
|
||||
default:
|
||||
region = "";
|
||||
break;
|
||||
}
|
||||
startOnlineUpdate(region);
|
||||
}
|
||||
}
|
||||
|
||||
public void startOnlineUpdate(String region)
|
||||
{
|
||||
mCanceled = false;
|
||||
|
||||
executor.execute(() ->
|
||||
{
|
||||
int result = WiiUtils.doOnlineUpdate(region, ((processed, total, titleId) ->
|
||||
{
|
||||
mProgressData.postValue(processed);
|
||||
mTotalData.postValue(total);
|
||||
mTitleIdData.postValue(titleId);
|
||||
int result = WiiUtils.doOnlineUpdate(region, constructCallback());
|
||||
mResultData.postValue(result);
|
||||
});
|
||||
}
|
||||
|
||||
return !mCanceled;
|
||||
}));
|
||||
public void startDiscUpdate(String path)
|
||||
{
|
||||
mCanceled = false;
|
||||
|
||||
executor.execute(() ->
|
||||
{
|
||||
int result = WiiUtils.doDiscUpdate(path, constructCallback());
|
||||
mResultData.postValue(result);
|
||||
});
|
||||
}
|
||||
|
@ -88,5 +134,19 @@ public class SystemUpdateViewModel extends ViewModel
|
|||
mTitleIdData.setValue(0l);
|
||||
mResultData.setValue(-1);
|
||||
mCanceled = false;
|
||||
mRegion = -1;
|
||||
mDiscPath = "";
|
||||
}
|
||||
|
||||
private WiiUpdateCallback constructCallback()
|
||||
{
|
||||
return (processed, total, titleId) ->
|
||||
{
|
||||
mProgressData.postValue(processed);
|
||||
mTotalData.postValue(total);
|
||||
mTitleIdData.postValue(titleId);
|
||||
|
||||
return !mCanceled;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,7 +17,7 @@ import org.dolphinemu.dolphinemu.R;
|
|||
import org.dolphinemu.dolphinemu.activities.EmulationActivity;
|
||||
import org.dolphinemu.dolphinemu.features.settings.model.BooleanSetting;
|
||||
import org.dolphinemu.dolphinemu.features.settings.ui.MenuTag;
|
||||
import org.dolphinemu.dolphinemu.features.sysupdate.ui.OnlineUpdateProgressBarDialogFragment;
|
||||
import org.dolphinemu.dolphinemu.features.sysupdate.ui.SystemUpdateProgressBarDialogFragment;
|
||||
import org.dolphinemu.dolphinemu.features.sysupdate.ui.SystemMenuNotInstalledDialogFragment;
|
||||
import org.dolphinemu.dolphinemu.features.sysupdate.ui.SystemUpdateViewModel;
|
||||
import org.dolphinemu.dolphinemu.model.GameFileCache;
|
||||
|
@ -280,11 +280,7 @@ public final class MainPresenter
|
|||
SystemUpdateViewModel viewModel =
|
||||
new ViewModelProvider(mActivity).get(SystemUpdateViewModel.class);
|
||||
viewModel.setRegion(-1);
|
||||
OnlineUpdateProgressBarDialogFragment progressBarFragment =
|
||||
new OnlineUpdateProgressBarDialogFragment();
|
||||
progressBarFragment
|
||||
.show(mActivity.getSupportFragmentManager(), "OnlineUpdateProgressBarDialogFragment");
|
||||
progressBarFragment.setCancelable(false);
|
||||
launchUpdateProgressBarFragment(mActivity);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -295,6 +291,23 @@ public final class MainPresenter
|
|||
}
|
||||
}
|
||||
|
||||
public static void launchDiscUpdate(String path, FragmentActivity activity)
|
||||
{
|
||||
SystemUpdateViewModel viewModel =
|
||||
new ViewModelProvider(activity).get(SystemUpdateViewModel.class);
|
||||
viewModel.setDiscPath(path);
|
||||
launchUpdateProgressBarFragment(activity);
|
||||
}
|
||||
|
||||
private static void launchUpdateProgressBarFragment(FragmentActivity activity)
|
||||
{
|
||||
SystemUpdateProgressBarDialogFragment progressBarFragment =
|
||||
new SystemUpdateProgressBarDialogFragment();
|
||||
progressBarFragment
|
||||
.show(activity.getSupportFragmentManager(), "SystemUpdateProgressBarDialogFragment");
|
||||
progressBarFragment.setCancelable(false);
|
||||
}
|
||||
|
||||
private void launchWiiSystemMenu()
|
||||
{
|
||||
WiiUtils.isSystemMenuInstalled();
|
||||
|
|
|
@ -28,6 +28,8 @@ public final class WiiUtils
|
|||
|
||||
public static native int doOnlineUpdate(String region, WiiUpdateCallback callback);
|
||||
|
||||
public static native int doDiscUpdate(String path, WiiUpdateCallback callback);
|
||||
|
||||
public static native boolean isSystemMenuInstalled();
|
||||
|
||||
public static native String getSystemMenuVersion();
|
||||
|
|
|
@ -433,6 +433,7 @@
|
|||
<string name="properties_start_with_riivolution">Start with Riivolution Patches</string>
|
||||
<string name="properties_set_default_iso">Set as Default ISO</string>
|
||||
<string name="properties_convert">Convert File</string>
|
||||
<string name="properties_system_update">Perform System Update</string>
|
||||
<string name="properties_edit_game_settings">Edit Game Settings</string>
|
||||
<string name="properties_edit_cheats">Edit Cheats</string>
|
||||
<string name="properties_clear_game_settings">Clear Game Settings and Cheats</string>
|
||||
|
|
|
@ -63,7 +63,7 @@ static jint ConvertUpdateResult(WiiUtils::UpdateResult result)
|
|||
return 8;
|
||||
default:
|
||||
ASSERT(false);
|
||||
return 1;
|
||||
return 7;
|
||||
}
|
||||
|
||||
static_assert(static_cast<int>(WiiUtils::UpdateResult::NumberOfEntries) == 9);
|
||||
|
@ -132,6 +132,27 @@ JNIEXPORT jint JNICALL Java_org_dolphinemu_dolphinemu_utils_WiiUtils_doOnlineUpd
|
|||
return ConvertUpdateResult(result);
|
||||
}
|
||||
|
||||
JNIEXPORT jint JNICALL Java_org_dolphinemu_dolphinemu_utils_WiiUtils_doDiscUpdate(JNIEnv* env,
|
||||
jclass,
|
||||
jstring jPath,
|
||||
jobject jCallback)
|
||||
{
|
||||
const std::string path = GetJString(env, jPath);
|
||||
|
||||
jobject jCallbackGlobal = env->NewGlobalRef(jCallback);
|
||||
Common::ScopeGuard scope_guard([jCallbackGlobal, env] { env->DeleteGlobalRef(jCallbackGlobal); });
|
||||
|
||||
const auto callback = [&jCallbackGlobal](int processed, int total, u64 title_id) {
|
||||
JNIEnv* env = IDCache::GetEnvForThread();
|
||||
return static_cast<bool>(env->CallBooleanMethod(
|
||||
jCallbackGlobal, IDCache::GetWiiUpdateCallbackFunction(), processed, total, title_id));
|
||||
};
|
||||
|
||||
WiiUtils::UpdateResult result = WiiUtils::DoDiscUpdate(callback, path);
|
||||
|
||||
return ConvertUpdateResult(result);
|
||||
}
|
||||
|
||||
JNIEXPORT jboolean JNICALL
|
||||
Java_org_dolphinemu_dolphinemu_utils_WiiUtils_isSystemMenuInstalled(JNIEnv* env, jclass)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue