Skip to content

Commit 26df563

Browse files
committed
0.2.0-rc7
* Bug fixes & improvements * Added Backup & Restore tool
1 parent 3c6960b commit 26df563

File tree

6 files changed

+126
-27
lines changed

6 files changed

+126
-27
lines changed

.idea/modules/app/AndroidBootManager.app.iml

Lines changed: 12 additions & 13 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/build.gradle

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ android {
1111
// we're not going to google play
1212
//noinspection OldTargetApi
1313
targetSdkVersion 27
14-
versionCode 2060
15-
versionName "0.2.0-rc6"
14+
versionCode 2070
15+
versionName "0.2.0-rc7"
1616
}
1717
signingConfigs {
1818
release {
@@ -55,7 +55,6 @@ dependencies {
5555
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
5656
implementation 'com.google.android.material:material:1.3.0'
5757
implementation 'androidx.cardview:cardview:1.0.0'
58-
implementation 'com.github.hedzr:android-file-chooser:v1.2.0-final'
5958
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
6059
implementation 'androidx.navigation:navigation-fragment:2.3.3'
6160
implementation 'androidx.navigation:navigation-ui:2.3.3'

app/src/main/assets/Toolkit

app/src/main/java/org/androidbootmanager/app/ui/addrom/DeviceROMInstallerWizardPageFragment.java

Lines changed: 50 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import android.content.Intent;
66
import android.net.Uri;
77
import android.os.Bundle;
8+
import android.util.Log;
89
import android.view.LayoutInflater;
910
import android.view.View;
1011
import android.view.ViewGroup;
@@ -20,6 +21,8 @@
2021
import androidx.fragment.app.Fragment;
2122
import androidx.lifecycle.ViewModelProvider;
2223

24+
import com.topjohnwu.superuser.Shell;
25+
import com.topjohnwu.superuser.io.SuFile;
2326
import com.topjohnwu.superuser.io.SuFileOutputStream;
2427

2528
import org.androidbootmanager.app.R;
@@ -94,7 +97,7 @@ public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup c
9497
Intent intent = new Intent();
9598
intent.setType("*/*");
9699
intent.setAction(Intent.ACTION_GET_CONTENT);
97-
startActivityForResult(intent, 5210);
100+
startActivityForResult(intent, 5299);
98101
});
99102
imodel.getROM().getValue().flashes.remove(key);
100103
imodel.addPart(meta.dumpPartition(dd.getSelectedItemPosition()).id);
@@ -150,6 +153,7 @@ public void onActivityCreated(@Nullable Bundle savedInstanceState) {
150153
super.onActivityCreated(savedInstanceState);
151154
}
152155

156+
@SuppressLint("SdCardPath")
153157
@Override
154158
public void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
155159
if (requestCode == 5210) {
@@ -169,17 +173,61 @@ public void onActivityResult(int requestCode, int resultCode, @Nullable Intent d
169173
ok.setVisibility(View.INVISIBLE);
170174
new Thread(() -> {
171175
try {
172-
@SuppressLint("SdCardPath") File targetFile = new File(pdump);
176+
File targetFile = new File(pdump);
177+
assert initialStream != null;
178+
OutputStream outStream = SuFileOutputStream.open(targetFile);
179+
SplashActivity.copyFile(initialStream, outStream);
180+
initialStream.close();
181+
outStream.close();
182+
requireActivity().runOnUiThread(() -> {
183+
model.setPositiveText(getString(R.string.next));
184+
model.setPositiveFragment(DeviceROMInstallerWizardPageFragment.class);
185+
txt.setText(getString(R.string.selected));
186+
});
187+
} catch (IOException e) {
188+
requireActivity().runOnUiThread(() -> Toast.makeText(requireContext(), R.string.failure, Toast.LENGTH_LONG).show());
189+
e.printStackTrace();
190+
}
191+
}).start();
192+
} catch (IOException e) {
193+
Toast.makeText(requireContext(), R.string.failure, Toast.LENGTH_LONG).show();
194+
e.printStackTrace();
195+
}
196+
} else {
197+
Toast.makeText(requireContext(), R.string.failure, Toast.LENGTH_LONG).show();
198+
new IllegalStateException("Result not OK but " + resultCode).printStackTrace();
199+
}
200+
} else if (requestCode == 5299) {
201+
if (resultCode == Activity.RESULT_OK) {
202+
assert data != null;
203+
Uri selectedUri = data.getData();
204+
try {
205+
InputStream initialStream;
206+
if (selectedUri != null) {
207+
initialStream = requireActivity().getContentResolver().openInputStream(selectedUri);
208+
} else {
209+
Toast.makeText(requireContext(), R.string.failure, Toast.LENGTH_LONG).show();
210+
new IllegalStateException("null selected").printStackTrace();
211+
return;
212+
}
213+
txt.setText(R.string.copy_file);
214+
ok.setVisibility(View.INVISIBLE);
215+
new Thread(() -> {
216+
try {
217+
File targetFile = new File("/data/data/org.androidbootmanager.app/cache/unsparse.img");
173218
assert initialStream != null;
174219
OutputStream outStream = SuFileOutputStream.open(targetFile);
175220
SplashActivity.copyFile(initialStream, outStream);
176221
initialStream.close();
177222
outStream.close();
223+
Log.i("ABM","copy done");
224+
Shell.su("/data/data/org.androidbootmanager.app/assets/Toolkit/simg2img /data/data/org.androidbootmanager.app/cache/unsparse.img " + pdump).exec();
178225
requireActivity().runOnUiThread(() -> {
179226
model.setPositiveText(getString(R.string.next));
180227
model.setPositiveFragment(DeviceROMInstallerWizardPageFragment.class);
181228
txt.setText(getString(R.string.selected));
182229
});
230+
Log.i("ABM","Result of delete: " + SuFile.open(targetFile.getAbsolutePath()).delete());
183231
} catch (IOException e) {
184232
requireActivity().runOnUiThread(() -> Toast.makeText(requireContext(), R.string.failure, Toast.LENGTH_LONG).show());
185233
e.printStackTrace();

0 commit comments

Comments
 (0)