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
f5bee7b6
Commit
f5bee7b6
authored
Nov 20, 2016
by
topjohnwu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Small refactor of download repo and FlashZip
parent
8c077a73
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
61 additions
and
58 deletions
+61
-58
MagiskFragment.java
app/src/main/java/com/topjohnwu/magisk/MagiskFragment.java
+5
-11
ModulesFragment.java
app/src/main/java/com/topjohnwu/magisk/ModulesFragment.java
+0
-1
ReposAdapter.java
...main/java/com/topjohnwu/magisk/adapters/ReposAdapter.java
+13
-10
DownloadReceiver.java
...java/com/topjohnwu/magisk/receivers/DownloadReceiver.java
+5
-5
Async.java
app/src/main/java/com/topjohnwu/magisk/utils/Async.java
+29
-29
Logger.java
app/src/main/java/com/topjohnwu/magisk/utils/Logger.java
+1
-1
Utils.java
app/src/main/java/com/topjohnwu/magisk/utils/Utils.java
+8
-1
No files found.
app/src/main/java/com/topjohnwu/magisk/MagiskFragment.java
View file @
f5bee7b6
...
@@ -71,18 +71,12 @@ public class MagiskFragment extends Fragment {
...
@@ -71,18 +71,12 @@ public class MagiskFragment extends Fragment {
private
SharedPreferences
prefs
;
private
SharedPreferences
prefs
;
private
SharedPreferences
.
OnSharedPreferenceChangeListener
listener
;
private
SharedPreferences
.
OnSharedPreferenceChangeListener
listener
;
private
AlertDialog
.
OnClickListener
flashMagisk
=
(
dialogInterface
,
i
)
->
Utils
.
d
ownload
AndReceive
(
private
AlertDialog
.
OnClickListener
flashMagisk
=
(
dialogInterface
,
i
)
->
Utils
.
d
l
AndReceive
(
getActivity
(),
getActivity
(),
new
DownloadReceiver
(
"Magisk-v"
+
String
.
valueOf
(
remoteMagiskVersion
)
)
{
new
DownloadReceiver
()
{
@Override
@Override
public
void
task
(
Uri
uri
)
{
public
void
task
(
Uri
uri
)
{
new
Async
.
FlashZIP
(
mContext
,
uri
,
mName
)
{
new
Async
.
FlashZIP
(
mContext
,
uri
,
mFilename
)
{
@Override
protected
void
preProcessing
()
throws
Throwable
{
super
.
preProcessing
();
new
File
(
mUri
.
getPath
()).
delete
();
}
@Override
@Override
protected
void
done
()
{
protected
void
done
()
{
Shell
.
su
(
"setprop magisk.version "
+
String
.
valueOf
(
remoteMagiskVersion
));
Shell
.
su
(
"setprop magisk.version "
+
String
.
valueOf
(
remoteMagiskVersion
));
...
@@ -92,9 +86,9 @@ public class MagiskFragment extends Fragment {
...
@@ -92,9 +86,9 @@ public class MagiskFragment extends Fragment {
}
}
},
},
magiskLink
,
magiskLink
,
"
latest_magisk
.zip"
);
"
Magisk-v"
+
String
.
valueOf
(
remoteMagiskVersion
)
+
"
.zip"
);
private
AlertDialog
.
OnClickListener
installMagiskApk
=
(
dialogInterface
,
i
)
->
Utils
.
d
ownload
AndReceive
(
private
AlertDialog
.
OnClickListener
installMagiskApk
=
(
dialogInterface
,
i
)
->
Utils
.
d
l
AndReceive
(
getActivity
(),
getActivity
(),
new
DownloadReceiver
()
{
new
DownloadReceiver
()
{
@Override
@Override
...
...
app/src/main/java/com/topjohnwu/magisk/ModulesFragment.java
View file @
f5bee7b6
...
@@ -83,7 +83,6 @@ public class ModulesFragment extends Fragment {
...
@@ -83,7 +83,6 @@ public class ModulesFragment extends Fragment {
if
(
data
!=
null
)
{
if
(
data
!=
null
)
{
// Get the URI of the selected file
// Get the URI of the selected file
final
Uri
uri
=
data
.
getData
();
final
Uri
uri
=
data
.
getData
();
// Get the file path from the URI
new
Async
.
FlashZIP
(
getActivity
(),
uri
).
exec
();
new
Async
.
FlashZIP
(
getActivity
(),
uri
).
exec
();
}
}
...
...
app/src/main/java/com/topjohnwu/magisk/adapters/ReposAdapter.java
View file @
f5bee7b6
...
@@ -92,26 +92,28 @@ public class ReposAdapter extends RecyclerView.Adapter<ReposAdapter.ViewHolder>
...
@@ -92,26 +92,28 @@ public class ReposAdapter extends RecyclerView.Adapter<ReposAdapter.ViewHolder>
View
.
OnClickListener
listener
=
view
->
{
View
.
OnClickListener
listener
=
view
->
{
if
(
view
.
getId
()
==
holder
.
updateImage
.
getId
())
{
if
(
view
.
getId
()
==
holder
.
updateImage
.
getId
())
{
String
f
ullname
=
repo
.
getName
()
+
"-"
+
repo
.
getVersion
()
;
String
f
ilename
=
repo
.
getName
()
+
"-"
+
repo
.
getVersion
()
+
".zip"
;
builder
builder
.
setTitle
(
context
.
getString
(
R
.
string
.
repo_install_title
,
repo
.
getName
()))
.
setTitle
(
context
.
getString
(
R
.
string
.
repo_install_title
,
repo
.
getName
()))
.
setMessage
(
context
.
getString
(
R
.
string
.
repo_install_msg
,
f
ull
name
))
.
setMessage
(
context
.
getString
(
R
.
string
.
repo_install_msg
,
f
ile
name
))
.
setCancelable
(
true
)
.
setCancelable
(
true
)
.
setPositiveButton
(
R
.
string
.
download_install
,
(
dialogInterface
,
i
)
->
Utils
.
d
ownload
AndReceive
(
.
setPositiveButton
(
R
.
string
.
download_install
,
(
dialogInterface
,
i
)
->
Utils
.
d
l
AndReceive
(
context
,
context
,
new
DownloadReceiver
(
fullname
)
{
new
DownloadReceiver
()
{
@Override
@Override
public
void
task
(
Uri
uri
)
{
public
void
task
(
Uri
uri
)
{
new
Async
.
FlashZIP
(
context
,
uri
,
mName
)
{
new
Async
.
FlashZIP
(
context
,
uri
,
mFilename
)
{
/*
* !!! This method is now depreciated, will be replaced with new method !!!
*/
@Override
@Override
protected
void
preProcessing
()
throws
Throwable
{
protected
void
preProcessing
()
throws
Throwable
{
super
.
preProcessing
();
File
file
=
new
File
(
mUri
.
getPath
());
new
File
(
mUri
.
getPath
()).
delete
();
Shell
.
sh
(
Shell
.
sh
(
"PATH="
+
context
.
getApplicationInfo
().
dataDir
+
"/tools:$PATH"
,
"PATH="
+
context
.
getApplicationInfo
().
dataDir
+
"/tools:$PATH"
,
"cd "
+
mF
ile
.
getParent
(),
"cd "
+
f
ile
.
getParent
(),
"mkdir git"
,
"mkdir git"
,
"unzip -o
install.zip
-d git"
,
"unzip -o
"
+
file
+
"
-d git"
,
"mv git/* install"
,
"mv git/* install"
,
"cd install"
,
"cd install"
,
"rm -rf system/placeholder"
,
"rm -rf system/placeholder"
,
...
@@ -121,12 +123,13 @@ public class ReposAdapter extends RecyclerView.Adapter<ReposAdapter.ViewHolder>
...
@@ -121,12 +123,13 @@ public class ReposAdapter extends RecyclerView.Adapter<ReposAdapter.ViewHolder>
"zip -r ../install.zip *"
,
"zip -r ../install.zip *"
,
"rm -rf ../install"
"rm -rf ../install"
);
);
mUri
=
Uri
.
fromFile
(
new
File
(
file
.
getParent
()
+
"/install.zip"
));
}
}
}.
exec
();
}.
exec
();
}
}
},
},
repo
.
getZipUrl
(),
repo
.
getZipUrl
(),
repo
.
getId
().
replace
(
" "
,
""
)
+
".zip"
))
Utils
.
getLegalFilename
(
filename
)
))
.
setNegativeButton
(
R
.
string
.
no_thanks
,
null
)
.
setNegativeButton
(
R
.
string
.
no_thanks
,
null
)
.
show
();
.
show
();
}
}
...
...
app/src/main/java/com/topjohnwu/magisk/receivers/DownloadReceiver.java
View file @
f5bee7b6
...
@@ -12,15 +12,11 @@ import com.topjohnwu.magisk.R;
...
@@ -12,15 +12,11 @@ import com.topjohnwu.magisk.R;
public
abstract
class
DownloadReceiver
extends
BroadcastReceiver
{
public
abstract
class
DownloadReceiver
extends
BroadcastReceiver
{
public
Context
mContext
;
public
Context
mContext
;
public
String
m
N
ame
;
public
String
m
Filen
ame
;
long
downloadID
;
long
downloadID
;
public
DownloadReceiver
()
{}
public
DownloadReceiver
()
{}
public
DownloadReceiver
(
String
name
)
{
mName
=
name
;
}
@Override
@Override
public
void
onReceive
(
Context
context
,
Intent
intent
)
{
public
void
onReceive
(
Context
context
,
Intent
intent
)
{
mContext
=
context
;
mContext
=
context
;
...
@@ -51,5 +47,9 @@ public abstract class DownloadReceiver extends BroadcastReceiver {
...
@@ -51,5 +47,9 @@ public abstract class DownloadReceiver extends BroadcastReceiver {
downloadID
=
id
;
downloadID
=
id
;
}
}
public
void
setFilename
(
String
filename
)
{
mFilename
=
filename
;
}
public
void
task
(
Uri
uri
)
{}
public
void
task
(
Uri
uri
)
{}
}
}
app/src/main/java/com/topjohnwu/magisk/utils/Async.java
View file @
f5bee7b6
...
@@ -172,16 +172,16 @@ public class Async {
...
@@ -172,16 +172,16 @@ public class Async {
public
static
class
FlashZIP
extends
RootTask
<
Void
,
Void
,
Integer
>
{
public
static
class
FlashZIP
extends
RootTask
<
Void
,
Void
,
Integer
>
{
protected
Uri
mUri
;
protected
Uri
mUri
;
protected
File
mFile
,
sdFile
;
protected
File
m
Cached
File
,
sdFile
;
private
String
m
N
ame
;
private
String
m
Filen
ame
;
private
ProgressDialog
progress
;
private
ProgressDialog
progress
;
private
Context
mContext
;
private
Context
mContext
;
private
boolean
copyToSD
;
private
boolean
copyToSD
;
public
FlashZIP
(
Context
context
,
Uri
uri
,
String
name
)
{
public
FlashZIP
(
Context
context
,
Uri
uri
,
String
file
name
)
{
mContext
=
context
;
mContext
=
context
;
mUri
=
uri
;
mUri
=
uri
;
m
Name
=
name
;
m
Filename
=
file
name
;
copyToSD
=
true
;
copyToSD
=
true
;
}
}
...
@@ -193,13 +193,13 @@ public class Async {
...
@@ -193,13 +193,13 @@ public class Async {
int
nameIndex
=
c
.
getColumnIndex
(
OpenableColumns
.
DISPLAY_NAME
);
int
nameIndex
=
c
.
getColumnIndex
(
OpenableColumns
.
DISPLAY_NAME
);
c
.
moveToFirst
();
c
.
moveToFirst
();
if
(
nameIndex
!=
-
1
)
{
if
(
nameIndex
!=
-
1
)
{
m
N
ame
=
c
.
getString
(
nameIndex
);
m
Filen
ame
=
c
.
getString
(
nameIndex
);
}
}
c
.
close
();
c
.
close
();
}
}
if
(
m
N
ame
==
null
)
{
if
(
m
Filen
ame
==
null
)
{
int
idx
=
uri
.
getPath
().
lastIndexOf
(
'/'
);
int
idx
=
uri
.
getPath
().
lastIndexOf
(
'/'
);
m
N
ame
=
uri
.
getPath
().
substring
(
idx
+
1
);
m
Filen
ame
=
uri
.
getPath
().
substring
(
idx
+
1
);
}
}
copyToSD
=
false
;
copyToSD
=
false
;
}
}
...
@@ -221,34 +221,37 @@ public class Async {
...
@@ -221,34 +221,37 @@ public class Async {
Logger
.
dev
(
"FlashZip: File created successfully - "
+
file
.
getPath
());
Logger
.
dev
(
"FlashZip: File created successfully - "
+
file
.
getPath
());
}
}
protected
void
preProcessing
()
throws
Throwable
{
protected
void
preProcessing
()
throws
Throwable
{}
protected
void
copyToCache
()
throws
Throwable
{
try
{
try
{
InputStream
in
=
mContext
.
getContentResolver
().
openInputStream
(
mUri
);
InputStream
in
=
mContext
.
getContentResolver
().
openInputStream
(
mUri
);
mFile
=
new
File
(
mContext
.
getCacheDir
().
getAbsolutePath
()
+
"/install.zip"
);
m
Cached
File
=
new
File
(
mContext
.
getCacheDir
().
getAbsolutePath
()
+
"/install.zip"
);
mFile
.
delete
();
m
Cached
File
.
delete
();
Utils
.
removeItem
(
mFile
.
getPath
());
Utils
.
removeItem
(
m
Cached
File
.
getPath
());
createFileFromInputStream
(
in
,
mFile
);
createFileFromInputStream
(
in
,
m
Cached
File
);
in
.
close
();
in
.
close
();
}
catch
(
FileNotFoundException
e
)
{
}
catch
(
FileNotFoundException
e
)
{
Log
.
e
(
"Magisk"
,
"FlashZip: Invalid Uri"
);
Log
.
e
(
Logger
.
LOG_TAG
,
"FlashZip: Invalid Uri"
);
throw
e
;
throw
e
;
}
catch
(
IOException
e
)
{
}
catch
(
IOException
e
)
{
Log
.
e
(
"Magisk"
,
"FlashZip: Error in creating file"
);
Log
.
e
(
Logger
.
LOG_TAG
,
"FlashZip: Error in creating file"
);
throw
e
;
throw
e
;
}
}
}
}
@Override
@Override
protected
void
onPreExecute
()
{
protected
void
onPreExecute
()
{
progress
=
ProgressDialog
.
show
(
mContext
,
mContext
.
getString
(
R
.
string
.
zip_install_progress_title
),
mContext
.
getString
(
R
.
string
.
zip_install_progress_msg
,
m
N
ame
));
progress
=
ProgressDialog
.
show
(
mContext
,
mContext
.
getString
(
R
.
string
.
zip_install_progress_title
),
mContext
.
getString
(
R
.
string
.
zip_install_progress_msg
,
m
Filen
ame
));
}
}
@Override
@Override
protected
Integer
doInBackground
(
Void
...
voids
)
{
protected
Integer
doInBackground
(
Void
...
voids
)
{
Logger
.
dev
(
"FlashZip Running... "
+
m
N
ame
);
Logger
.
dev
(
"FlashZip Running... "
+
m
Filen
ame
);
List
<
String
>
ret
=
null
;
List
<
String
>
ret
=
null
;
try
{
try
{
preProcessing
();
preProcessing
();
copyToCache
();
}
catch
(
Throwable
e
)
{
}
catch
(
Throwable
e
)
{
this
.
cancel
(
true
);
this
.
cancel
(
true
);
progress
.
cancel
();
progress
.
cancel
();
...
@@ -257,49 +260,46 @@ public class Async {
...
@@ -257,49 +260,46 @@ public class Async {
}
}
if
(
Shell
.
rootAccess
())
{
if
(
Shell
.
rootAccess
())
{
ret
=
Shell
.
su
(
ret
=
Shell
.
su
(
"unzip -o "
+
m
File
.
getPath
()
+
" META-INF/com/google/android/* -d "
+
m
File
.
getParent
(),
"unzip -o "
+
m
CachedFile
.
getPath
()
+
" META-INF/com/google/android/* -d "
+
mCached
File
.
getParent
(),
"if [ \"$(cat "
+
mFile
.
getParent
()
+
"/META-INF/com/google/android/updater-script)\" = \"#MAGISK\" ]; then echo true; else echo false; fi"
"if [ \"$(cat "
+
m
Cached
File
.
getParent
()
+
"/META-INF/com/google/android/updater-script)\" = \"#MAGISK\" ]; then echo true; else echo false; fi"
);
);
if
(!
Boolean
.
parseBoolean
(
ret
.
get
(
ret
.
size
()
-
1
)))
{
if
(!
Boolean
.
parseBoolean
(
ret
.
get
(
ret
.
size
()
-
1
)))
{
return
0
;
return
0
;
}
}
ret
=
Shell
.
su
(
ret
=
Shell
.
su
(
"BOOTMODE=true sh "
+
m
File
.
getParent
()
+
"/META-INF/com/google/android/update-binary dummy 1 "
+
m
File
.
getPath
(),
"BOOTMODE=true sh "
+
m
CachedFile
.
getParent
()
+
"/META-INF/com/google/android/update-binary dummy 1 "
+
mCached
File
.
getPath
(),
"if [ $? -eq 0 ]; then echo true; else echo false; fi"
"if [ $? -eq 0 ]; then echo true; else echo false; fi"
);
);
Shell
.
su
(
"rm -rf "
+
mFile
.
getParent
()
+
"/META-INF"
);
Shell
.
su
(
"rm -rf "
+
m
Cached
File
.
getParent
()
+
"/META-INF"
);
Logger
.
dev
(
"FlashZip: Console log:"
);
Logger
.
dev
(
"FlashZip: Console log:"
);
for
(
String
line
:
ret
)
{
for
(
String
line
:
ret
)
{
Logger
.
dev
(
line
);
Logger
.
dev
(
line
);
}
}
}
}
// Copy the file to sdcard
// Copy the file to sdcard
if
(
copyToSD
&&
mFile
!=
null
)
{
if
(
copyToSD
&&
mCachedFile
!=
null
)
{
String
filename
=
(
mName
.
contains
(
".zip"
)
?
mName
:
mName
+
".zip"
);
String
filename
=
Utils
.
getLegalFilename
(
mFilename
.
contains
(
".zip"
)
?
mFilename
:
mFilename
+
".zip"
);
filename
=
filename
.
replace
(
" "
,
"_"
).
replace
(
"'"
,
""
).
replace
(
"\""
,
""
)
.
replace
(
"$"
,
""
).
replace
(
"`"
,
""
).
replace
(
"("
,
""
).
replace
(
")"
,
""
)
.
replace
(
"#"
,
""
).
replace
(
"@"
,
""
).
replace
(
"*"
,
""
);
sdFile
=
new
File
(
Environment
.
getExternalStorageDirectory
()
+
"/MagiskManager/"
+
filename
);
sdFile
=
new
File
(
Environment
.
getExternalStorageDirectory
()
+
"/MagiskManager/"
+
filename
);
Logger
.
dev
(
"FlashZip: Copy zip back to "
+
sdFile
.
getPath
());
Logger
.
dev
(
"FlashZip: Copy zip back to "
+
sdFile
.
getPath
());
if
((!
sdFile
.
getParentFile
().
exists
()
&&
!
sdFile
.
getParentFile
().
mkdirs
())
||
(
sdFile
.
exists
()
&&
!
sdFile
.
delete
()))
{
if
((!
sdFile
.
getParentFile
().
exists
()
&&
!
sdFile
.
getParentFile
().
mkdirs
())
||
(
sdFile
.
exists
()
&&
!
sdFile
.
delete
()))
{
sdFile
=
null
;
sdFile
=
null
;
}
else
{
}
else
{
try
{
try
{
FileInputStream
in
=
new
FileInputStream
(
mFile
);
FileInputStream
in
=
new
FileInputStream
(
m
Cached
File
);
createFileFromInputStream
(
in
,
sdFile
);
createFileFromInputStream
(
in
,
sdFile
);
in
.
close
();
in
.
close
();
}
catch
(
IOException
e
)
{
}
catch
(
IOException
e
)
{
// Use the badass way :)
// Use the badass way :)
e
.
printStackTrace
();
e
.
printStackTrace
();
Shell
.
su
(
"cp -af "
+
mFile
.
getPath
()
+
" "
+
sdFile
.
getPath
());
Shell
.
su
(
"cp -af "
+
m
Cached
File
.
getPath
()
+
" "
+
sdFile
.
getPath
());
if
(!
sdFile
.
exists
())
{
if
(!
sdFile
.
exists
())
{
sdFile
=
null
;
sdFile
=
null
;
}
}
}
}
}
}
}
}
if
(
m
File
!=
null
&&
mFile
.
exists
()
&&
!
m
File
.
delete
())
{
if
(
m
CachedFile
!=
null
&&
mCachedFile
.
exists
()
&&
!
mCached
File
.
delete
())
{
Utils
.
removeItem
(
mFile
.
getPath
());
Utils
.
removeItem
(
m
Cached
File
.
getPath
());
}
}
if
(
ret
!=
null
&&
Boolean
.
parseBoolean
(
ret
.
get
(
ret
.
size
()
-
1
)))
{
if
(
ret
!=
null
&&
Boolean
.
parseBoolean
(
ret
.
get
(
ret
.
size
()
-
1
)))
{
return
1
;
return
1
;
...
...
app/src/main/java/com/topjohnwu/magisk/utils/Logger.java
View file @
f5bee7b6
...
@@ -4,7 +4,7 @@ import android.util.Log;
...
@@ -4,7 +4,7 @@ import android.util.Log;
public
class
Logger
{
public
class
Logger
{
p
rivate
static
final
String
LOG_TAG
=
"Magisk: DEV"
;
p
ublic
static
final
String
LOG_TAG
=
"Magisk: DEV"
;
public
static
boolean
logShell
,
devLog
;
public
static
boolean
logShell
,
devLog
;
...
...
app/src/main/java/com/topjohnwu/magisk/utils/Utils.java
View file @
f5bee7b6
...
@@ -87,7 +87,7 @@ public class Utils {
...
@@ -87,7 +87,7 @@ public class Utils {
return
ret
;
return
ret
;
}
}
public
static
void
d
ownload
AndReceive
(
Context
context
,
DownloadReceiver
receiver
,
String
link
,
String
filename
)
{
public
static
void
d
l
AndReceive
(
Context
context
,
DownloadReceiver
receiver
,
String
link
,
String
filename
)
{
File
file
=
new
File
(
Environment
.
getExternalStorageDirectory
()
+
"/MagiskManager/"
+
filename
);
File
file
=
new
File
(
Environment
.
getExternalStorageDirectory
()
+
"/MagiskManager/"
+
filename
);
if
(
ActivityCompat
.
checkSelfPermission
(
context
,
Manifest
.
permission
.
WRITE_EXTERNAL_STORAGE
)
!=
PackageManager
.
PERMISSION_GRANTED
)
{
if
(
ActivityCompat
.
checkSelfPermission
(
context
,
Manifest
.
permission
.
WRITE_EXTERNAL_STORAGE
)
!=
PackageManager
.
PERMISSION_GRANTED
)
{
Toast
.
makeText
(
context
,
R
.
string
.
permissionNotGranted
,
Toast
.
LENGTH_LONG
).
show
();
Toast
.
makeText
(
context
,
R
.
string
.
permissionNotGranted
,
Toast
.
LENGTH_LONG
).
show
();
...
@@ -103,6 +103,7 @@ public class Utils {
...
@@ -103,6 +103,7 @@ public class Utils {
request
.
setDestinationUri
(
Uri
.
fromFile
(
file
));
request
.
setDestinationUri
(
Uri
.
fromFile
(
file
));
receiver
.
setDownloadID
(
downloadManager
.
enqueue
(
request
));
receiver
.
setDownloadID
(
downloadManager
.
enqueue
(
request
));
receiver
.
setFilename
(
filename
);
context
.
registerReceiver
(
receiver
,
new
IntentFilter
(
DownloadManager
.
ACTION_DOWNLOAD_COMPLETE
));
context
.
registerReceiver
(
receiver
,
new
IntentFilter
(
DownloadManager
.
ACTION_DOWNLOAD_COMPLETE
));
}
}
...
@@ -129,4 +130,10 @@ public class Utils {
...
@@ -129,4 +130,10 @@ public class Utils {
return
secret
;
return
secret
;
}
}
public
static
String
getLegalFilename
(
CharSequence
filename
)
{
return
filename
.
toString
().
replace
(
" "
,
"_"
).
replace
(
"'"
,
""
).
replace
(
"\""
,
""
)
.
replace
(
"$"
,
""
).
replace
(
"`"
,
""
).
replace
(
"("
,
""
).
replace
(
")"
,
""
)
.
replace
(
"#"
,
""
).
replace
(
"@"
,
""
).
replace
(
"*"
,
""
);
}
}
}
\ No newline at end of file
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