Skip to content

Commit

Permalink
merge upstream
Browse files Browse the repository at this point in the history
  • Loading branch information
whp98 committed Oct 8, 2023
2 parents cda71bc + 365c2e0 commit 67df29a
Show file tree
Hide file tree
Showing 53 changed files with 613 additions and 213 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@
/app/signing.properties
*.iml
*.jks
*.keystore
*.keystore
androidSign
39 changes: 21 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,9 @@
[![Downloads](https://img.shields.io/github/downloads/aistra0528/Hail/total.svg)](https://github.com/aistra0528/Hail/releases)
[![License](https://img.shields.io/github/license/aistra0528/Hail)](LICENSE)

雹是一款用于冻结 Android 应用的自由软件,您可自由享用所有功能。
雹是一款用于冻结 Android 应用的自由软件[GitHub Releases](https://github.com/aistra0528/Hail/releases)

[<img src="coolapk-badge.png" alt="Get it on CoolApk" height="80">](https://www.coolapk.com/apk/com.aistra.hail)
[<img src="https://fdroid.gitlab.io/artwork/badge/get-it-on.png" alt="Get it on F-Droid" height="80">](https://f-droid.org/packages/com.aistra.hail/)
[<img src="https://play.google.com/intl/en_us/badges/images/generic/en-play-badge.png" alt="Get it on Google Play" height="80">](https://play.google.com/store/apps/details?id=com.aistra.hail)

酷安版签名与 [GitHub Releases](https://github.com/aistra0528/Hail/releases) 一致,F-Droid 版由 F-Droid 签名。

Google Play 版为 [@purofle](https://github.com/purofle)[Fork](https://github.com/purofle/Hail),由
Google 签名。

<img src="fastlane/metadata/android/zh-CN/images/phoneScreenshots/1.png" width="32%" /> <img src="fastlane/metadata/android/zh-CN/images/phoneScreenshots/2.png" width="32%" /> <img src="fastlane/metadata/android/zh-CN/images/phoneScreenshots/3.png" width="32%" />

Expand Down Expand Up @@ -45,15 +38,15 @@ Google 签名。
## 工作模式

雹支持以`设备所有者``超级用户` (Root) 和`Shizuku` (含 Sui) 模式工作。
雹支持以`设备所有者``Dhizuku``超级用户` (Root) 和`Shizuku` (含 Sui) 模式工作。

**冻结的应用需要通过相同工作模式解冻。**

1. 如果您的设备支持无线调试或已 root,推荐选择`Shizuku`[关于 Shizuku](https://github.com/RikkaApps/Shizuku)
1. 如果您的设备支持无线调试或已 root,推荐选择`Shizuku`

2. 如果您的设备已 root,可选择`超级用户`**此模式速度相对较慢。**

3. 如果您的设备不支持无线调试且未 root,可选择`设备所有者`**此模式设置较为繁琐**
3. 如果您的设备不支持无线调试且未 root,可选择`设备所有者``Dhizuku`**这些模式设置较为繁琐**

### 设备所有者 - 隐藏 / 暂停

Expand Down Expand Up @@ -88,37 +81,47 @@ Active admin set to component {com.aistra.hail/com.aistra.hail.receiver.DeviceAd

#### 移除雹的设备所有者

在雹的应用界面长按雹,在弹出的选项中选择卸载。
设置 > 移除设备所有者

### Dhizuku - 隐藏 / 暂停

### 超级用户 - 停用 / 暂停
此模式通过将 [Dhizuku](https://github.com/iamr0s/Dhizuku) 设置为设备所有者 (Device Owner),调用:

- `DevicePolicyManager.setApplicationHidden`方法隐藏应用。

- `DevicePolicyManager.setPackagesSuspended`方法暂停应用。

### 超级用户 - 停用 / 隐藏 / 暂停

此模式通过授予雹超级用户 (Superuser) 权限,执行:

- `pm disable`命令停用应用。

- `pm hide`命令隐藏应用。

- `pm suspend`命令暂停应用。

### Shizuku - 停用 / 隐藏 / 暂停

此模式通过 Shizuku 调用非 SDK 接口:
此模式通过 [Shizuku](https://github.com/RikkaApps/Shizuku) 调用非 SDK 接口:

- `IPackageManager.setApplicationEnabledSetting`方法停用应用。

- `IPackageManager.setApplicationHiddenSettingAsUser`方法隐藏应用。 (可能需要 root)
- `IPackageManager.setApplicationHiddenSettingAsUser`方法隐藏应用。 (需要 root)

- `IPackageManager.setPackagesSuspendedAsUser`方法暂停应用。

## 恢复

### 通过 adb (可能需要 root)
### 通过 adb

替换 com.package.name 为目标应用的包名。

```shell
# 启用应用
adb shell pm enable com.package.name
# 取消隐藏应用
adb shell pm unhide com.package.name
# 取消隐藏应用 (需要 root)
adb shell su -c pm unhide com.package.name
# 取消暂停应用
adb shell pm unsuspend com.package.name
```
Expand Down
42 changes: 21 additions & 21 deletions README_EN.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,9 @@
[![Downloads](https://img.shields.io/github/downloads/aistra0528/Hail/total.svg)](https://github.com/aistra0528/Hail/releases)
[![License](https://img.shields.io/github/license/aistra0528/Hail)](LICENSE)

Hail is a free-as-in-freedom software to freeze Android apps. Enjoy all features freely!
Hail is a free-as-in-freedom software to freeze Android apps. [GitHub Releases](https://github.com/aistra0528/Hail/releases)

[<img src="coolapk-badge.png" alt="Get it on CoolApk" height="80">](https://www.coolapk.com/apk/com.aistra.hail)
[<img src="https://fdroid.gitlab.io/artwork/badge/get-it-on.png" alt="Get it on F-Droid" height="80">](https://f-droid.org/packages/com.aistra.hail/)
[<img src="https://play.google.com/intl/en_us/badges/images/generic/en-play-badge.png" alt="Get it on Google Play" height="80">](https://play.google.com/store/apps/details?id=com.aistra.hail)

CoolApk releases are signed the same
as [GitHub Releases](https://github.com/aistra0528/Hail/releases), and F-Droid releases are signed
by F-Droid.

Google Play releases are the [Fork](https://github.com/purofle/Hail)
by [@purofle](https://github.com/purofle), signed by Google.

<img src="fastlane/metadata/android/en-US/images/phoneScreenshots/1.png" width="32%" /> <img src="fastlane/metadata/android/en-US/images/phoneScreenshots/2.png" width="32%" /> <img src="fastlane/metadata/android/en-US/images/phoneScreenshots/3.png" width="32%" />

Expand Down Expand Up @@ -55,16 +46,15 @@ Suspended apps will be shown as grayscale icons in the launcher. Unsuspend them
## Working mode

Hail can work with `Device Owner`, `Superuser` (Root) and `Shizuku` (including Sui).
Hail can work with `Device Owner`, `Dhizuku`, `Superuser` (Root) and `Shizuku` (including Sui).

**Frozen app need to be unfrozen by the same working mode.**

1. For devices support wifi adb or rooted, `Shizuku` is
recommend. [About Shizuku](https://github.com/RikkaApps/Shizuku)
1. For devices support wifi adb or rooted, `Shizuku` is recommend.

2. For rooted devices, `Superuser` is alternative. **It is slower.**

3. Select `Device Owner` otherwise. **It's a pain to set up.**
3. Select `Device Owner` or `Dhizuku` otherwise. **These are a pain to set up.**

### Device Owner - Hide / Suspend

Expand Down Expand Up @@ -99,37 +89,47 @@ Search the message by search engine otherwise.

#### Remove device owner

Long press Hail at Apps, then select Uninstall in options.
Settings > Remove Device Owner

### [Dhizuku](https://github.com/iamr0s/Dhizuku) - Hide / Suspend

This mode invoke:

- `DevicePolicyManager.setApplicationHidden` to hide apps.

### Superuser - Disable / Suspend
- `DevicePolicyManager.setPackagesSuspended` to suspend apps.

### Superuser - Disable / Hide / Suspend

This mode execute:

- `pm disable` to disable apps.

- `pm hide` to hide apps.

- `pm suspend` to suspend apps.

### Shizuku - Disable / Hide / Suspend
### [Shizuku](https://github.com/RikkaApps/Shizuku) - Disable / Hide / Suspend

This mode invoke non-SDK interface:

- `IPackageManager.setApplicationEnabledSetting` to disable apps.

- `IPackageManager.setApplicationHiddenSettingAsUser` to hide apps. (root may be required)
- `IPackageManager.setApplicationHiddenSettingAsUser` to hide apps. (root required)

- `IPackageManager.setPackagesSuspendedAsUser` to suspend apps.

## Revert

### By adb (root may be required)
### By adb

Replace com.package.name to the package name of target app.

```shell
# Enable app
adb shell pm enable com.package.name
# Unhide app
adb shell pm unhide com.package.name
# Unhide app (root required)
adb shell su -c pm unhide com.package.name
# Unsuspend app
adb shell pm unsuspend com.package.name
```
Expand Down
1 change: 0 additions & 1 deletion androidSign
Submodule androidSign deleted from 886223
2 changes: 1 addition & 1 deletion app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ android {
}

dependencies {
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-android:1.7.2")
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-android:1.7.3")
implementation("androidx.core:core-ktx:1.9.0")
implementation("androidx.appcompat:appcompat:1.6.1")
implementation("androidx.biometric:biometric:1.1.0")
Expand Down
26 changes: 16 additions & 10 deletions app/src/main/kotlin/com/aistra/hail/HailApp.kt
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import com.aistra.hail.app.AppManager
import com.aistra.hail.app.HailData
import com.aistra.hail.services.AutoFreezeService
import com.aistra.hail.utils.HDhizuku
import com.google.android.material.color.DynamicColors

class HailApp : Application() {
override fun onCreate() {
Expand All @@ -22,23 +21,30 @@ class HailApp : Application() {

fun setAutoFreezeService(enabled: Boolean? = null) {
if (HailData.autoFreezeAfterLock.not()) return
val start = enabled
?: HailData.checkedList.any { !AppManager.isAppFrozen(it.packageName) && !it.whitelisted }
val start = enabled ?: HailData.checkedList.any {
it.packageName != packageName
&& it.applicationInfo != null
&& !AppManager.isAppFrozen(it.packageName)
&& !it.whitelisted
}
val intent = Intent(app, AutoFreezeService::class.java)
val name = ComponentName(app, AutoFreezeService::class.java)
if (start) {
packageManager.setComponentEnabledSetting(
name, PackageManager.COMPONENT_ENABLED_STATE_ENABLED, PackageManager.DONT_KILL_APP
)
setAutoFreezeServiceEnabled(true)
ContextCompat.startForegroundService(app, intent)
} else {
stopService(intent)
packageManager.setComponentEnabledSetting(
name, PackageManager.COMPONENT_ENABLED_STATE_DISABLED, PackageManager.DONT_KILL_APP
)
setAutoFreezeServiceEnabled(false)
}
}

fun setAutoFreezeServiceEnabled(enabled: Boolean) {
packageManager.setComponentEnabledSetting(
ComponentName(app, AutoFreezeService::class.java),
if (enabled) PackageManager.COMPONENT_ENABLED_STATE_ENABLED else PackageManager.COMPONENT_ENABLED_STATE_DISABLED,
PackageManager.DONT_KILL_APP
)
}

companion object {
lateinit var app: HailApp private set
}
Expand Down
32 changes: 13 additions & 19 deletions app/src/main/kotlin/com/aistra/hail/app/AppManager.kt
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,12 @@ object AppManager {
}

fun isAppFrozen(packageName: String): Boolean = when {
HailData.workingMode == HailData.MODE_OWNER_HIDE -> HPolicy.isAppHidden(packageName)
HailData.workingMode == HailData.MODE_DHIZUKU_HIDE -> HDhizuku.isAppHidden(packageName)
HailData.workingMode == HailData.MODE_SHIZUKU_HIDE -> HShizuku.isAppHidden(packageName)
HailData.workingMode.endsWith(HailData.DISABLE) -> HPackages.isAppDisabled(packageName)
HailData.workingMode.endsWith(HailData.HIDE) -> HPackages.isAppHidden(packageName)
HailData.workingMode.endsWith(HailData.SUSPEND) -> HPackages.isAppSuspended(packageName)
else -> HPackages.isAppDisabled(packageName)
|| HPackages.isAppHidden(packageName)
|| HPackages.isAppSuspended(packageName)
}

fun setAppFrozen(packageName: String, frozen: Boolean): Boolean =
Expand All @@ -36,6 +37,7 @@ object AppManager {
HailData.MODE_DHIZUKU_HIDE -> HDhizuku.setAppHidden(packageName, frozen)
HailData.MODE_DHIZUKU_SUSPEND -> HDhizuku.setAppSuspended(packageName, frozen)
HailData.MODE_SU_DISABLE -> HShell.setAppDisabled(packageName, frozen)
HailData.MODE_SU_HIDE -> HShell.setAppHidden(packageName, frozen)
HailData.MODE_SU_SUSPEND -> HShell.setAppSuspended(packageName, frozen)
HailData.MODE_SHIZUKU_DISABLE -> HShizuku.setAppDisabled(packageName, frozen)
HailData.MODE_SHIZUKU_HIDE -> HShizuku.setAppHidden(packageName, frozen)
Expand All @@ -45,25 +47,17 @@ object AppManager {

fun uninstallApp(packageName: String): Boolean {
when {
HailData.workingMode.startsWith(HailData.OWNER) -> if (HPolicy.uninstallApp(
packageName
)
) return true
HailData.workingMode.startsWith(HailData.OWNER) ->
if (HPolicy.uninstallApp(packageName)) return true

HailData.workingMode.startsWith(HailData.DHIZUKU) -> if (HDhizuku.uninstallApp(
packageName
)
) return true
HailData.workingMode.startsWith(HailData.DHIZUKU) ->
if (HDhizuku.uninstallApp(packageName)) return true

HailData.workingMode.startsWith(HailData.SU) -> if (HShell.uninstallApp(
packageName
)
) return true
HailData.workingMode.startsWith(HailData.SU) ->
if (HShell.uninstallApp(packageName)) return true

HailData.workingMode.startsWith(HailData.SHIZUKU) -> if (HShizuku.uninstallApp(
packageName
)
) return true
HailData.workingMode.startsWith(HailData.SHIZUKU) ->
if (HShizuku.uninstallApp(packageName)) return true
}
HUI.startActivity(Intent.ACTION_DELETE, HPackages.packageUri(packageName))
return false
Expand Down
7 changes: 4 additions & 3 deletions app/src/main/kotlin/com/aistra/hail/app/HailData.kt
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ object HailData {
const val URL_RELEASES = "$URL_GITHUB/releases"
const val URL_TELEGRAM = "https://t.me/+yvRXYTounDIxODFl"
const val URL_QQ = "http://qm.qq.com/cgi-bin/qm/qr?k=I2g_Ymanc6bQMo4cVKTG0knARE0twtSG"
const val URL_COOLAPK = "https://www.coolapk.com/apk/${BuildConfig.APPLICATION_ID}"
const val URL_FDROID = "https://f-droid.org/packages/${BuildConfig.APPLICATION_ID}"
const val URL_ALIPAY = "https://qr.alipay.com/tsx02922ajwj6xekqyd1rbf"
const val URL_ALIPAY_API = "alipays://platformapi/startapp?saId=10000007&qrcode=$URL_ALIPAY"
const val URL_BILIBILI = "https://space.bilibili.com/9261272"
Expand All @@ -34,14 +34,15 @@ object HailData {
const val DHIZUKU = "dhizuku_"
const val SU = "su_"
const val SHIZUKU = "shizuku_"
private const val DISABLE = "disable"
private const val HIDE = "hide"
const val DISABLE = "disable"
const val HIDE = "hide"
const val SUSPEND = "suspend"
const val MODE_OWNER_HIDE = OWNER + HIDE
const val MODE_OWNER_SUSPEND = OWNER + SUSPEND
const val MODE_DHIZUKU_HIDE = DHIZUKU + HIDE
const val MODE_DHIZUKU_SUSPEND = DHIZUKU + SUSPEND
const val MODE_SU_DISABLE = SU + DISABLE
const val MODE_SU_HIDE = SU + HIDE
const val MODE_SU_SUSPEND = SU + SUSPEND
const val MODE_SHIZUKU_DISABLE = SHIZUKU + DISABLE
const val MODE_SHIZUKU_HIDE = SHIZUKU + HIDE
Expand Down
6 changes: 4 additions & 2 deletions app/src/main/kotlin/com/aistra/hail/ui/about/AboutFragment.kt
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ class AboutFragment : MainFragment(), View.OnClickListener {
inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?
): View {
_binding = FragmentAboutBinding.inflate(inflater, container, false)
activity.appbar.setLiftOnScrollTargetView(binding.root)

binding.descVersion.text = HailData.VERSION
aboutViewModel = ViewModelProvider(this)[AboutViewModel::class.java]
aboutViewModel.time.observe(viewLifecycleOwner) {
Expand All @@ -45,7 +47,7 @@ class AboutFragment : MainFragment(), View.OnClickListener {
binding.actionTime.setOnClickListener(this)
binding.actionTelegram.setOnClickListener(this)
binding.actionQq.setOnClickListener(this)
binding.actionCoolapk.setOnClickListener(this)
binding.actionFdroid.setOnClickListener(this)
binding.actionDonate.setOnClickListener(this)
binding.actionGithub.setOnClickListener(this)
binding.actionTranslate.setOnClickListener(this)
Expand All @@ -60,7 +62,7 @@ class AboutFragment : MainFragment(), View.OnClickListener {
binding.actionTime -> onRedeem()
binding.actionTelegram -> HUI.openLink(HailData.URL_TELEGRAM)
binding.actionQq -> HUI.openLink(HailData.URL_QQ)
binding.actionCoolapk -> HUI.openLink(HailData.URL_COOLAPK)
binding.actionFdroid -> HUI.openLink(HailData.URL_FDROID)
binding.actionDonate -> onDonate()
binding.actionGithub -> HUI.openLink(HailData.URL_GITHUB)
binding.actionTranslate -> HUI.openLink(HailData.URL_TRANSLATE)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import java.text.SimpleDateFormat
class AboutViewModel(val app: Application) : AndroidViewModel(app) {
val time = MutableLiveData<String>().apply {
value = SimpleDateFormat.getDateInstance()
.format(HPackages.getPackageInfoOrNull(app.packageName)!!.firstInstallTime)
.format(HPackages.getUnhiddenPackageInfoOrNull(app.packageName)!!.firstInstallTime)
}

val snack = MutableLiveData<Int>()
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/kotlin/com/aistra/hail/ui/api/ApiActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ class ApiActivity : AppCompatActivity() {

private fun requirePackage(extraName: String = HailData.KEY_PACKAGE): String =
intent?.getStringExtra(extraName)?.also {
HPackages.getPackageInfoOrNull(it)
HPackages.getApplicationInfoOrNull(it)
?: throw NameNotFoundException(getString(R.string.app_not_installed))
} ?: throw IllegalArgumentException("package must not be null")

Expand Down
Loading

0 comments on commit 67df29a

Please sign in to comment.