Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
M
Magisk
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
Magisk
Commits
8fe4cfec
Commit
8fe4cfec
authored
Dec 25, 2016
by
topjohnwu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add Install UI
parent
a5a2df49
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
231 additions
and
35 deletions
+231
-35
InstallFragment.java
app/src/main/java/com/topjohnwu/magisk/InstallFragment.java
+85
-33
Utils.java
app/src/main/java/com/topjohnwu/magisk/utils/Utils.java
+20
-1
install_fragment.xml
app/src/main/res/layout/install_fragment.xml
+126
-1
No files found.
app/src/main/java/com/topjohnwu/magisk/InstallFragment.java
View file @
8fe4cfec
...
@@ -8,6 +8,10 @@ import android.support.v7.app.AlertDialog;
...
@@ -8,6 +8,10 @@ import android.support.v7.app.AlertDialog;
import
android.view.LayoutInflater
;
import
android.view.LayoutInflater
;
import
android.view.View
;
import
android.view.View
;
import
android.view.ViewGroup
;
import
android.view.ViewGroup
;
import
android.widget.ArrayAdapter
;
import
android.widget.Button
;
import
android.widget.Spinner
;
import
android.widget.TextView
;
import
com.topjohnwu.magisk.receivers.DownloadReceiver
;
import
com.topjohnwu.magisk.receivers.DownloadReceiver
;
import
com.topjohnwu.magisk.utils.Async
;
import
com.topjohnwu.magisk.utils.Async
;
...
@@ -16,56 +20,104 @@ import com.topjohnwu.magisk.utils.Utils;
...
@@ -16,56 +20,104 @@ import com.topjohnwu.magisk.utils.Utils;
import
com.topjohnwu.magisk.utils.ZipUtils
;
import
com.topjohnwu.magisk.utils.ZipUtils
;
import
java.io.File
;
import
java.io.File
;
import
java.util.List
;
import
butterknife.BindView
;
import
butterknife.ButterKnife
;
import
butterknife.ButterKnife
;
// Currently empty, placing some code that we be used in the future
public
class
InstallFragment
extends
Fragment
{
public
class
InstallFragment
extends
Fragment
{
private
List
<
String
>
blockList
;
@BindView
(
R
.
id
.
block_spinner
)
Spinner
spinner
;
@BindView
(
R
.
id
.
detect_bootimage
)
Button
detectButton
;
@Nullable
@Nullable
@Override
@Override
public
View
onCreateView
(
LayoutInflater
inflater
,
ViewGroup
container
,
Bundle
savedInstanceState
)
{
public
View
onCreateView
(
LayoutInflater
inflater
,
ViewGroup
container
,
Bundle
savedInstanceState
)
{
View
v
=
inflater
.
inflate
(
R
.
layout
.
install_fragment
,
container
,
false
);
View
v
=
inflater
.
inflate
(
R
.
layout
.
install_fragment
,
container
,
false
);
ButterKnife
.
bind
(
this
,
v
);
ButterKnife
.
bind
(
this
,
v
);
detectButton
.
setOnClickListener
(
v1
->
detectBootImage
());
getBlockList
();
return
v
;
return
v
;
}
}
private
void
getBlockList
()
{
new
Async
.
RootTask
<
Void
,
Void
,
Void
>()
{
@Override
protected
Void
doInBackground
(
Void
...
params
)
{
blockList
=
Utils
.
getBlockList
();
return
null
;
}
@Override
protected
void
onPostExecute
(
Void
aVoid
)
{
ArrayAdapter
<
String
>
adapter
=
new
ArrayAdapter
<>(
getActivity
(),
android
.
R
.
layout
.
simple_spinner_item
,
blockList
);
adapter
.
setDropDownViewResource
(
android
.
R
.
layout
.
simple_spinner_dropdown_item
);
spinner
.
setAdapter
(
adapter
);
detectBootImage
();
}
}.
exec
();
}
private
void
detectBootImage
()
{
new
Async
.
RootTask
<
Void
,
Void
,
Void
>()
{
String
boot
;
@Override
protected
Void
doInBackground
(
Void
...
params
)
{
boot
=
Utils
.
detectBootImage
();
return
null
;
}
@Override
protected
void
onPostExecute
(
Void
aVoid
)
{
if
(
boot
!=
null
)
{
int
idx
=
blockList
.
indexOf
(
boot
);
if
(
idx
!=
-
1
)
{
spinner
.
setSelection
(
idx
);
}
}
}
}.
exec
();
}
@Override
@Override
public
void
onResume
()
{
public
void
onResume
()
{
super
.
onResume
();
super
.
onResume
();
getActivity
().
setTitle
(
R
.
string
.
install
);
getActivity
().
setTitle
(
R
.
string
.
install
);
}
}
private
AlertDialog
.
OnClickListener
flashMagisk
=
(
dialogInterface
,
i
)
->
Utils
.
dlAndReceive
(
getActivity
(),
new
DownloadReceiver
()
{
@Override
public
void
task
(
Uri
uri
)
{
new
Async
.
FlashZIP
(
mContext
,
uri
,
mFilename
)
{
@Override
protected
boolean
unzipAndCheck
()
{
publishProgress
(
mContext
.
getString
(
R
.
string
.
zip_install_unzip_zip_msg
));
if
(
Shell
.
rootAccess
())
{
// We might not have busybox yet, unzip with Java
// We will have complete busybox after Magisk installation
ZipUtils
.
unzip
(
mCachedFile
,
new
File
(
mCachedFile
.
getParent
(),
"magisk"
));
Shell
.
su
(
"mkdir -p "
+
Async
.
TMP_FOLDER_PATH
+
"/magisk"
,
"cp -af "
+
mCachedFile
.
getParent
()
+
"/magisk/. "
+
Async
.
TMP_FOLDER_PATH
+
"/magisk"
);
}
super
.
unzipAndCheck
();
return
true
;
}
@Override
protected
void
done
()
{
Shell
.
su
(
"setprop magisk.version "
+
String
.
valueOf
(
StatusFragment
.
remoteMagiskVersion
));
super
.
done
();
}
}.
exec
();
}
},
StatusFragment
.
magiskLink
,
"Magisk-v"
+
String
.
valueOf
(
StatusFragment
.
remoteMagiskVersion
)
+
".zip"
);
}
}
// private AlertDialog.OnClickListener flashMagisk = (dialogInterface, i) -> Utils.dlAndReceive(
// getActivity(),
// new DownloadReceiver() {
// @Override
// public void task(Uri uri) {
// new Async.FlashZIP(mContext, uri, mFilename) {
// @Override
// protected boolean unzipAndCheck() {
// publishProgress(mContext.getString(R.string.zip_install_unzip_zip_msg));
// if (Shell.rootAccess()) {
// // We might not have busybox yet, unzip with Java
// // We will have complete busybox after Magisk installation
// ZipUtils.unzip(mCachedFile, new File(mCachedFile.getParent(), "magisk"));
// Shell.su(
// "mkdir -p " + Async.TMP_FOLDER_PATH + "/magisk",
// "cp -af " + mCachedFile.getParent() + "/magisk/. " + Async.TMP_FOLDER_PATH + "/magisk"
// );
// }
// super.unzipAndCheck();
// return true;
// }
//
// @Override
// protected void done() {
// Shell.su("setprop magisk.version " + String.valueOf(StatusFragment.remoteMagiskVersion));
// super.done();
// }
// }.exec();
// }
// },
// StatusFragment.magiskLink,
// "Magisk-v" + String.valueOf(StatusFragment.remoteMagiskVersion) + ".zip");
app/src/main/java/com/topjohnwu/magisk/utils/Utils.java
View file @
8fe4cfec
...
@@ -67,7 +67,7 @@ public class Utils {
...
@@ -67,7 +67,7 @@ public class Utils {
return
Shell
.
rootAccess
()
&&
Boolean
.
parseBoolean
(
Shell
.
su
(
command
).
get
(
0
));
return
Shell
.
rootAccess
()
&&
Boolean
.
parseBoolean
(
Shell
.
su
(
command
).
get
(
0
));
}
}
static
List
<
String
>
getModList
(
String
path
)
{
public
static
List
<
String
>
getModList
(
String
path
)
{
List
<
String
>
ret
;
List
<
String
>
ret
;
String
command
=
"find "
+
path
+
" -type d -maxdepth 1 ! -name \"*.core\" ! -name \"*lost+found\" ! -name \"*magisk\""
;
String
command
=
"find "
+
path
+
" -type d -maxdepth 1 ! -name \"*.core\" ! -name \"*lost+found\" ! -name \"*magisk\""
;
if
(
Shell
.
rootAccess
())
{
if
(
Shell
.
rootAccess
())
{
...
@@ -138,6 +138,25 @@ public class Utils {
...
@@ -138,6 +138,25 @@ public class Utils {
.
replace
(
"#"
,
""
).
replace
(
"@"
,
""
).
replace
(
"*"
,
""
);
.
replace
(
"#"
,
""
).
replace
(
"@"
,
""
).
replace
(
"*"
,
""
);
}
}
public
static
List
<
String
>
getBlockList
()
{
return
Shell
.
su
(
"ls /dev/block | grep mmc"
);
}
public
static
String
detectBootImage
()
{
String
[]
commands
=
{
"for PARTITION in kern-a KERN-A android_boot ANDROID_BOOT kernel KERNEL boot BOOT lnx LNX; do"
,
"BOOTIMAGE=`readlink /dev/block/by-name/$PARTITION || readlink /dev/block/platform/*/by-name/$PARTITION || readlink /dev/block/platform/*/*/by-name/$PARTITION`"
,
"if [ ! -z \"$BOOTIMAGE\" ]; then break; fi"
,
"done"
,
"echo \"${BOOTIMAGE##*/}\""
};
List
<
String
>
ret
=
Shell
.
su
(
commands
);
if
(!
ret
.
isEmpty
())
{
return
ret
.
get
(
0
);
}
return
null
;
}
public
static
class
ByteArrayInOutStream
extends
ByteArrayOutputStream
{
public
static
class
ByteArrayInOutStream
extends
ByteArrayOutputStream
{
public
ByteArrayInputStream
getInputStream
()
{
public
ByteArrayInputStream
getInputStream
()
{
ByteArrayInputStream
in
=
new
ByteArrayInputStream
(
buf
,
0
,
count
);
ByteArrayInputStream
in
=
new
ByteArrayInputStream
(
buf
,
0
,
count
);
...
...
app/src/main/res/layout/install_fragment.xml
View file @
8fe4cfec
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android=
"http://schemas.android.com/apk/res/android"
<LinearLayout
xmlns:android=
"http://schemas.android.com/apk/res/android"
android:layout_width=
"match_parent"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
>
android:layout_height=
"match_parent"
xmlns:app=
"http://schemas.android.com/apk/res-auto"
android:layout_marginTop=
"?attr/actionBarSize"
android:orientation=
"vertical"
>
<android.support.v7.widget.CardView
android:id=
"@+id/install_info_card"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:layout_marginBottom=
"4dp"
android:layout_marginLeft=
"5dp"
android:layout_marginRight=
"5dp"
android:layout_marginTop=
"6dp"
style=
"?attr/cardStyle"
app:cardUseCompatPadding=
"true"
>
<TextView
android:id=
"@+id/install_info"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:layout_gravity=
"center"
android:gravity=
"center"
android:padding=
"15dp"
android:textStyle=
"bold"
android:text=
"Install Magisk Version: v10"
/>
</android.support.v7.widget.CardView>
<android.support.v7.widget.CardView
android:id=
"@+id/bootimage_card"
android:layout_gravity=
"center"
android:layout_width=
"350dp"
android:layout_height=
"wrap_content"
android:layout_marginBottom=
"4dp"
android:layout_marginLeft=
"5dp"
android:layout_marginRight=
"5dp"
android:layout_marginTop=
"6dp"
style=
"?attr/cardStyle"
app:cardUseCompatPadding=
"true"
>
<LinearLayout
android:orientation=
"vertical"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
android:layout_marginTop=
"15dp"
android:layout_marginBottom=
"15dp"
>
<TextView
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:layout_gravity=
"center"
android:gravity=
"center"
android:paddingBottom=
"10dp"
android:text=
"Boot Image Location"
android:textStyle=
"bold"
/>
<LinearLayout
android:orientation=
"horizontal"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
>
<Spinner
android:layout_width=
"0dp"
android:layout_height=
"match_parent"
android:id=
"@+id/block_spinner"
android:layout_weight=
"1"
/>
<Button
android:text=
"Detect"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:id=
"@+id/detect_bootimage"
/>
</LinearLayout>
</LinearLayout>
</android.support.v7.widget.CardView>
<android.support.v7.widget.CardView
android:id=
"@+id/install_option_card"
android:layout_gravity=
"center"
android:layout_width=
"350dp"
android:layout_height=
"wrap_content"
android:layout_marginBottom=
"4dp"
android:layout_marginLeft=
"5dp"
android:layout_marginRight=
"5dp"
android:layout_marginTop=
"6dp"
style=
"?attr/cardStyle"
app:cardUseCompatPadding=
"true"
>
<LinearLayout
android:orientation=
"vertical"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
android:layout_marginTop=
"15dp"
android:layout_marginBottom=
"15dp"
>
<TextView
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:layout_gravity=
"center"
android:gravity=
"center"
android:paddingBottom=
"10dp"
android:text=
"Advanced Settings"
android:textStyle=
"bold"
/>
<CheckBox
android:text=
"Keep force encryption"
android:id=
"@+id/keep_force_enc"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:layout_marginEnd=
"25dp"
android:layout_marginStart=
"25dp"
/>
<CheckBox
android:text=
"Keep dm-verity"
android:id=
"@+id/keep_verity"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:layout_marginEnd=
"25dp"
android:layout_marginStart=
"25dp"
/>
</LinearLayout>
</android.support.v7.widget.CardView>
</LinearLayout>
</LinearLayout>
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment