Fix: Android 15: Fixed the set default launcher.

Signed-off-by: HeCodes2Much <wayne6324@gmail.com>
This commit is contained in:
HeCodes2Much
2024-07-25 19:23:27 +01:00
parent 9b7d6822d2
commit 3fd3dc49d9
5 changed files with 8 additions and 73 deletions

View File

@@ -69,20 +69,6 @@
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".ui.activities.FakeHomeActivity"
android:enabled="false"
android:launchMode="singleTask"
android:windowSoftInputMode="stateHidden"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.HOME" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<receiver
android:name=".listener.DeviceAdmin"

View File

@@ -3,7 +3,6 @@ package com.github.droidworksstudio.common
import android.Manifest
import android.app.SearchManager
import android.content.ActivityNotFoundException
import android.content.ComponentName
import android.content.Context
import android.content.Intent
import android.content.pm.LauncherApps
@@ -37,7 +36,6 @@ import androidx.lifecycle.LifecycleOwner
import com.github.droidworksstudio.launcher.utils.Constants
import com.github.droidworksstudio.launcher.data.entities.AppInfo
import com.github.droidworksstudio.launcher.helper.PreferenceHelper
import com.github.droidworksstudio.launcher.ui.activities.FakeHomeActivity
import java.util.Calendar
import java.util.Date
import kotlin.math.pow
@@ -153,39 +151,6 @@ fun Context.openUrl(url: String) {
}
fun Context.resetDefaultLauncher() {
val manufacturer = Build.MANUFACTURER.lowercase()
when (manufacturer) {
"google", "essential" -> runningStockAndroid()
else -> notRunningStockAndroid()
}
}
fun Context.runningStockAndroid() {
try {
val packageManager = this.packageManager
val componentName = ComponentName(this, FakeHomeActivity::class.java)
packageManager.setComponentEnabledSetting(
componentName,
PackageManager.COMPONENT_ENABLED_STATE_ENABLED,
PackageManager.DONT_KILL_APP
)
val selector = Intent(Intent.ACTION_MAIN)
selector.addCategory(Intent.CATEGORY_HOME)
this.startActivity(selector)
packageManager.setComponentEnabledSetting(
componentName,
PackageManager.COMPONENT_ENABLED_STATE_DISABLED,
PackageManager.DONT_KILL_APP
)
} catch (e: Exception) {
e.printStackTrace()
}
}
fun Context.notRunningStockAndroid() {
try {
val intent = Intent("android.settings.HOME_SETTINGS")
this.startActivity(intent)

View File

@@ -1,12 +0,0 @@
package com.github.droidworksstudio.launcher.ui.activities
import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import com.github.droidworksstudio.launcher.R
class FakeHomeActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_fake_home)
}
}

View File

@@ -1,7 +0,0 @@
<merge xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".ui.activities.FakeHomeActivity">
</merge>