-
-
Notifications
You must be signed in to change notification settings - Fork 175
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Try fix issue #47 - Put permissions android.permission.WRITE_EXTERNAL_STORAGE and android.permission.READ_EXTERNAL_STORAGE - Rewrite BroadcastReceivers responsible to Intent.ACTION_BOOT_COMPLETED and Intent.ACTION_SHUTDOWN on DeviceEvents.kt
- Loading branch information
Showing
6 changed files
with
55 additions
and
51 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package juniojsv.mtk.easy.su | ||
|
||
import android.content.BroadcastReceiver | ||
import android.content.Context | ||
import android.content.Intent | ||
import android.os.Looper | ||
|
||
/* d88b db db d8b db d888888b .d88b. d88b .d8888. db db | ||
`8P' 88 88 888o 88 `88' .8P Y8. `8P' 88' YP 88 88 | ||
88 88 88 88V8o 88 88 88 88 88 `8bo. Y8 8P | ||
88 88 88 88 V8o88 88 88 88 88 `Y8b. `8b d8' | ||
db. 88 88b d88 88 V888 .88. `8b d8' db. 88 db 8D `8bd8' | ||
Y8888P ~Y8888P' VP V8P Y888888P `Y88P' Y8888P `8888Y' YP */ | ||
|
||
class DeviceEvents : BroadcastReceiver() { | ||
|
||
override fun onReceive(context: Context?, intent: Intent?) { | ||
context?.apply { | ||
when (intent!!.action) { | ||
Intent.ACTION_BOOT_COMPLETED -> { | ||
if (getSharedPreferences("preferences", Context.MODE_PRIVATE).getBoolean( | ||
"run_on_boot", | ||
false | ||
) | ||
) { | ||
"Trying to ensure root access".toast(context) | ||
if (context.getSharedPreferences("preferences", Context.MODE_PRIVATE) | ||
.getString("asset_tag", "null") != "null" | ||
) AssetsManager.tryRoot(context) { success, _ -> | ||
android.os.Handler(Looper.getMainLooper()).post { | ||
if (success) "Success".toast(this) else "Fail try again".toast(this) | ||
} | ||
} | ||
} | ||
} | ||
Intent.ACTION_SHUTDOWN -> getSharedPreferences("preferences", Context.MODE_PRIVATE) | ||
.edit().putBoolean("need_reset", false).apply() | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.