Skip to content

Commit

Permalink
Support baseline profiles
Browse files Browse the repository at this point in the history
  • Loading branch information
topjohnwu committed Oct 26, 2023
1 parent 9f92e1b commit 28770b9
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 5 deletions.
2 changes: 1 addition & 1 deletion app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ setupApp()
configurations.all {
exclude("org.jetbrains.kotlin", "kotlin-stdlib-jdk7")
exclude("org.jetbrains.kotlin", "kotlin-stdlib-jdk8")
exclude("androidx.profileinstaller", "profileinstaller")
}

dependencies {
Expand Down Expand Up @@ -117,5 +116,6 @@ dependencies {
implementation("androidx.transition:transition:1.4.1")
implementation("androidx.core:core-ktx:1.12.0")
implementation("androidx.core:core-splashscreen:1.0.1")
implementation("androidx.profileinstaller:profileinstaller:1.3.1")
implementation("com.google.android.material:material:1.10.0")
}
8 changes: 6 additions & 2 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,15 @@
android:name="androidx.room.MultiInstanceInvalidationService"
tools:node="remove" />

<!-- We don't need emoji compat -->
<!-- We handle initialization ourselves -->
<provider
android:name="androidx.startup.InitializationProvider"
android:authorities="${applicationId}.androidx-startup"
android:exported="false"
tools:node="remove" />

<!-- We handle profile installation ourselves -->
<receiver
android:name="androidx.profileinstaller.ProfileInstallReceiver"
tools:node="remove" />

</application>
Expand Down
9 changes: 9 additions & 0 deletions app/src/main/java/com/topjohnwu/magisk/core/App.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import android.app.Application
import android.content.Context
import android.content.res.Configuration
import android.os.Bundle
import androidx.profileinstaller.ProfileInstaller
import com.topjohnwu.magisk.BuildConfig
import com.topjohnwu.magisk.StubApk
import com.topjohnwu.magisk.core.di.ServiceLocator
import com.topjohnwu.magisk.core.utils.DispatcherExecutor
Expand All @@ -20,6 +22,8 @@ import com.topjohnwu.superuser.Shell
import com.topjohnwu.superuser.internal.UiThreadHandler
import com.topjohnwu.superuser.ipc.RootService
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.launch
import timber.log.Timber
import java.lang.ref.WeakReference
import kotlin.system.exitProcess
Expand Down Expand Up @@ -84,6 +88,11 @@ open class App() : Application() {
super.onCreate()
ProcessLifecycle.init(this)
NetworkObserver.init(this)
if (!BuildConfig.DEBUG && !isRunningAsStub) {
GlobalScope.launch(Dispatchers.IO) {
ProfileInstaller.writeProfile(this@App)
}
}
}

override fun onConfigurationChanged(newConfig: Configuration) {
Expand Down
2 changes: 0 additions & 2 deletions buildSrc/src/main/java/Setup.kt
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,6 @@ abstract class AddCommentTask: DefaultTask() {
it.eocdComment = comment.get().toByteArray()
it.get(IncrementalPackager.APP_METADATA_ENTRY_PATH)?.delete()
it.get(JarFile.MANIFEST_NAME)?.delete()
it.get("assets/dexopt/baseline.prof")?.delete()
it.get("assets/dexopt/baseline.profm")?.delete()
}

outFile
Expand Down

0 comments on commit 28770b9

Please sign in to comment.