Skip to content

Commit

Permalink
FIX: Besides persistent service for shortcut synchronization, also up…
Browse files Browse the repository at this point in the history
…date shortcuts upon device start-up and Island app update.

Rename ShortcutsRepairer to ShortcutsUpdater as the former is most probably disabled in previous version of Island.
  • Loading branch information
oasisfeng committed Apr 6, 2021
1 parent ea9e1dc commit aedfef6
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
4 changes: 2 additions & 2 deletions mobile/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -62,14 +62,14 @@

<!--<activity android:name="android.__dummy__" android:exported="true" android:icon="@mipmap/ic_dummy" />-->

<service android:name="com.oasisfeng.island.shortcut.IslandAppShortcut$ShortcutUpdater"
<service android:name="com.oasisfeng.island.shortcut.IslandAppShortcut$ShortcutSyncService"
android:exported="false" android:enabled="@bool/since_api_26">
<intent-filter>
<action android:name="com.oasisfeng.island.PersistentService" />
</intent-filter>
</service>

<receiver android:name="com.oasisfeng.island.shortcut.ShortcutsRepairer">
<receiver android:name="com.oasisfeng.island.shortcut.ShortcutsUpdater">
<intent-filter>
<action android:name="android.intent.action.MY_PACKAGE_REPLACED" />
<action android:name="android.intent.action.BOOT_COMPLETED" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ object IslandAppShortcut {
private fun isCrossProfile(userId: Int) = userId != Users.current().toId()
private val ApplicationInfo.userId; get() = UserHandles.getUserId(uid)

@ProfileUser @RequiresApi(O) class ShortcutUpdater: Service() {
@ProfileUser @RequiresApi(O) class ShortcutSyncService: Service() {

private val mPackageObserver = object: BroadcastReceiver() { override fun onReceive(context: Context, intent: Intent) {
val pkg = intent.data?.schemeSpecificPart ?: return
Expand Down Expand Up @@ -247,15 +247,13 @@ object IslandAppShortcut {
}
}

class ShortcutsRepairer: BroadcastReceiver() {
class ShortcutsUpdater: BroadcastReceiver() {

override fun onReceive(context: Context, intent: Intent?) {
if (SDK_INT < O || intent?.action != ACTION_MY_PACKAGE_REPLACED && intent?.action != ACTION_BOOT_COMPLETED) return
try {
IslandAppShortcut.updateAllPinned(context)
} catch (e: IllegalStateException) { return } // User is locked
context.packageManager.setComponentEnabledSetting(ComponentName(context, javaClass),
PackageManager.COMPONENT_ENABLED_STATE_DISABLED, PackageManager.DONT_KILL_APP)
}
}

Expand Down

0 comments on commit aedfef6

Please sign in to comment.