-
-
Notifications
You must be signed in to change notification settings - Fork 268
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
148 additions
and
91 deletions.
There are no files selected for viewing
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
28 changes: 28 additions & 0 deletions
28
app/src/main/java/icu/nullptr/hidemyapplist/service/ServiceProvider.kt
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,28 @@ | ||
package icu.nullptr.hidemyapplist.service | ||
|
||
import android.content.ContentProvider | ||
import android.content.ContentValues | ||
import android.net.Uri | ||
import android.os.Bundle | ||
|
||
class ServiceProvider : ContentProvider() { | ||
|
||
override fun onCreate() = false | ||
|
||
override fun query(p0: Uri, p1: Array<out String>?, p2: String?, p3: Array<out String>?, p4: String?) = null | ||
|
||
override fun getType(p0: Uri) = null | ||
|
||
override fun insert(p0: Uri, p1: ContentValues?) = null | ||
|
||
override fun delete(p0: Uri, p1: String?, p2: Array<out String>?) = 0 | ||
|
||
override fun update(p0: Uri, p1: ContentValues?, p2: String?, p3: Array<out String>?) = 0 | ||
|
||
override fun call(method: String, arg: String?, extras: Bundle?): Bundle? { | ||
if (callingPackage != "android" || extras == null) return null | ||
val binder = extras.getBinder("binder") ?: return null | ||
ServiceClient.linkService(binder) | ||
return Bundle() | ||
} | ||
} |
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
63 changes: 0 additions & 63 deletions
63
xposed/src/main/java/icu/nullptr/hidemyapplist/xposed/BridgeService.kt
This file was deleted.
Oops, something went wrong.
78 changes: 78 additions & 0 deletions
78
xposed/src/main/java/icu/nullptr/hidemyapplist/xposed/UserService.kt
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,78 @@ | ||
package icu.nullptr.hidemyapplist.xposed | ||
|
||
import android.app.ActivityManagerHidden | ||
import android.content.AttributionSource | ||
import android.content.pm.IPackageManager | ||
import android.os.Build | ||
import android.os.Bundle | ||
import android.os.ServiceManager | ||
import icu.nullptr.hidemyapplist.common.BuildConfig | ||
import icu.nullptr.hidemyapplist.common.Constants | ||
import rikka.hidden.compat.ActivityManagerApis | ||
import rikka.hidden.compat.adapter.UidObserverAdapter | ||
|
||
object UserService { | ||
|
||
private const val TAG = "HMA-UserService" | ||
|
||
private var appUid = 0 | ||
|
||
private val uidObserver = object : UidObserverAdapter() { | ||
override fun onUidActive(uid: Int) { | ||
if (uid != appUid) return | ||
try { | ||
val provider = ActivityManagerApis.getContentProviderExternal(Constants.PROVIDER_AUTHORITY, 0, null, null) | ||
if (provider == null) { | ||
logE(TAG, "Failed to get provider") | ||
return | ||
} | ||
val extras = Bundle() | ||
extras.putBinder("binder", HMAService.instance) | ||
val reply = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) { | ||
val attr = AttributionSource.Builder(1000).setPackageName("android").build() | ||
provider.call(attr, Constants.PROVIDER_AUTHORITY, "", null, extras) | ||
} else if (Build.VERSION.SDK_INT == Build.VERSION_CODES.R) { | ||
provider.call("android", null, Constants.PROVIDER_AUTHORITY, "", null, extras) | ||
} else if (Build.VERSION.SDK_INT == Build.VERSION_CODES.Q) { | ||
provider.call("android", Constants.PROVIDER_AUTHORITY, "", null, extras) | ||
} else { | ||
provider.call("android", "", null, extras) | ||
} | ||
if (reply == null) { | ||
logE(TAG, "Failed to send binder to app") | ||
return | ||
} | ||
logI(TAG, "Send binder to app") | ||
} catch (e: Throwable) { | ||
logE(TAG, "onUidActive", e) | ||
} | ||
} | ||
} | ||
|
||
fun register(pms: IPackageManager) { | ||
logI(TAG, "Initialize HMAService - Version ${BuildConfig.SERVICE_VERSION}") | ||
val service = HMAService(pms) | ||
appUid = Utils.getPackageUidCompat(service.pms, Constants.APP_PACKAGE_NAME, 0, 0) | ||
val appPackage = Utils.getPackageInfoCompat(service.pms, Constants.APP_PACKAGE_NAME, 0, 0) | ||
if (!Utils.verifyAppSignature(appPackage.applicationInfo.sourceDir)) { | ||
logE(TAG, "Fatal: App signature mismatch") | ||
return | ||
} | ||
logD(TAG, "Client uid: $appUid") | ||
logI(TAG, "Register observer") | ||
|
||
waitSystemService("activity") | ||
ActivityManagerApis.registerUidObserver( | ||
uidObserver, | ||
ActivityManagerHidden.UID_OBSERVER_ACTIVE, | ||
ActivityManagerHidden.PROCESS_STATE_UNKNOWN, | ||
null | ||
) | ||
} | ||
|
||
private fun waitSystemService(name: String) { | ||
while (ServiceManager.getService(name) == null) { | ||
Thread.sleep(1000) | ||
} | ||
} | ||
} |
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