-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement SplitInstallService #2500
Open
DaVinci9196
wants to merge
12
commits into
microg:master
Choose a base branch
from
DaVinci9196:split_install_service
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 10 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
34ccbe2
SplitInstallService Additions
DaVinci9196 5e6f01e
add permission
DaVinci9196 1962f33
ISplitInstallServiceCallback added
DaVinci9196 c9bfbc0
remove Phenotype / Experiment
DaVinci9196 796c3ab
Merge branch 'microg:master' into split_install_service
DaVinci9196 e8a0058
Optimizing the code
DaVinci9196 b8d2b20
SplitInstallService add call super.onBind
DaVinci9196 6cdd488
Fixed the issue that multiple versions of language packs could not be…
DaVinci9196 36651db
Formatting Code
DaVinci9196 ff837d9
Formatting Code
DaVinci9196 8a68044
Execute processing suggestions
DaVinci9196 5a9f1b3
cleanup
DaVinci9196 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
22 changes: 22 additions & 0 deletions
22
...rc/main/aidl/com/google/android/play/core/splitinstall/protocol/ISplitInstallService.aidl
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,22 @@ | ||
/** | ||
* SPDX-FileCopyrightText: 2024 microG Project Team | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
package com.google.android.play.core.splitinstall.protocol; | ||
import com.google.android.play.core.splitinstall.protocol.ISplitInstallServiceCallback; | ||
|
||
interface ISplitInstallService { | ||
void startInstall(String pkg,in List<Bundle> splits,in Bundle bundle, ISplitInstallServiceCallback callback) = 1; | ||
void completeInstalls(String pkg, int sessionId,in Bundle bundle, ISplitInstallServiceCallback callback) = 2; | ||
void cancelInstall(String pkg, int sessionId, ISplitInstallServiceCallback callback) = 3; | ||
void getSessionState(String pkg, int sessionId, ISplitInstallServiceCallback callback) = 4; | ||
void getSessionStates(String pkg, ISplitInstallServiceCallback callback) = 5; | ||
void splitRemoval(String pkg,in List<Bundle> splits, ISplitInstallServiceCallback callback) = 6; | ||
void splitDeferred(String pkg,in List<Bundle> splits,in Bundle bundle, ISplitInstallServiceCallback callback) = 7; | ||
void getSessionState2(String pkg, int sessionId, ISplitInstallServiceCallback callback) = 8; | ||
void getSessionStates2(String pkg, ISplitInstallServiceCallback callback) = 9; | ||
void getSplitsAppUpdate(String pkg, ISplitInstallServiceCallback callback) = 10; | ||
void completeInstallAppUpdate(String pkg, ISplitInstallServiceCallback callback) = 11; | ||
void languageSplitInstall(String pkg,in List<Bundle> splits,in Bundle bundle, ISplitInstallServiceCallback callback) = 12; | ||
void languageSplitUninstall(String pkg,in List<Bundle> splits, ISplitInstallServiceCallback callback) =13; | ||
} |
19 changes: 19 additions & 0 deletions
19
...aidl/com/google/android/play/core/splitinstall/protocol/ISplitInstallServiceCallback.aidl
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,19 @@ | ||
/** | ||
* SPDX-FileCopyrightText: 2024 microG Project Team | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
package com.google.android.play.core.splitinstall.protocol; | ||
|
||
|
||
interface ISplitInstallServiceCallback { | ||
oneway void onStartInstall(int status, in Bundle bundle) = 1; | ||
oneway void onInstallCompleted(int status, in Bundle bundle) = 2; | ||
oneway void onCancelInstall(int status, in Bundle bundle) = 3; | ||
oneway void onGetSessionState(int status, in Bundle bundle) = 4; | ||
oneway void onError(in Bundle bundle) = 5; | ||
oneway void onGetSessionStates(in List<Bundle> list) = 6; | ||
oneway void onDeferredUninstall(in Bundle bundle) = 7; | ||
oneway void onDeferredInstall(in Bundle bundle) = 8; | ||
oneway void onDeferredLanguageInstall(in Bundle bundle) = 11; | ||
oneway void onDeferredLanguageUninstall(in Bundle bundle) = 12; | ||
} |
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
109 changes: 109 additions & 0 deletions
109
...-app/src/main/kotlin/com/google/android/finsky/splitinstallservice/SplitInstallService.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,109 @@ | ||
/** | ||
* SPDX-FileCopyrightText: 2024 microG Project Team | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package com.google.android.finsky.splitinstallservice | ||
|
||
import android.content.Context | ||
import android.content.Intent | ||
import android.os.Bundle | ||
import android.os.IBinder | ||
import android.util.Log | ||
import androidx.lifecycle.Lifecycle | ||
import androidx.lifecycle.LifecycleOwner | ||
import androidx.lifecycle.LifecycleService | ||
import androidx.lifecycle.lifecycleScope | ||
import com.google.android.gms.common.api.CommonStatusCodes | ||
import com.google.android.play.core.splitinstall.protocol.ISplitInstallService | ||
import com.google.android.play.core.splitinstall.protocol.ISplitInstallServiceCallback | ||
import kotlinx.coroutines.launch | ||
import org.microg.gms.profile.ProfileManager | ||
import org.microg.vending.billing.core.HttpClient | ||
|
||
private const val TAG = "SplitInstallServiceImpl" | ||
|
||
class SplitInstallService : LifecycleService() { | ||
|
||
private lateinit var httpClient: HttpClient | ||
|
||
override fun onBind(intent: Intent): IBinder? { | ||
super.onBind(intent) | ||
Log.d(TAG, "onBind: ") | ||
ProfileManager.ensureInitialized(this) | ||
httpClient = HttpClient(this) | ||
return SplitInstallServiceImpl(this.applicationContext, httpClient, lifecycle).asBinder() | ||
} | ||
|
||
override fun onUnbind(intent: Intent?): Boolean { | ||
Log.d(TAG, "onUnbind: ") | ||
httpClient.requestQueue.cancelAll(SPLIT_INSTALL_REQUEST_TAG) | ||
return super.onUnbind(intent) | ||
} | ||
} | ||
|
||
class SplitInstallServiceImpl(private val context: Context, private val httpClient: HttpClient, override val lifecycle: Lifecycle) : ISplitInstallService.Stub(), LifecycleOwner { | ||
|
||
override fun startInstall(pkg: String, splits: List<Bundle>, bundle0: Bundle, callback: ISplitInstallServiceCallback) { | ||
Log.d(TAG, "Method <startInstall> Called by package: $pkg") | ||
lifecycleScope.launch { | ||
trySplitInstall(context, httpClient, pkg, splits) | ||
Log.d(TAG, "onStartInstall SUCCESS") | ||
callback.onStartInstall(CommonStatusCodes.SUCCESS, Bundle()) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It seems to me like the identity of the caller is not verified. I would expect packages are only allowed to request split installs for themselves, right? We should ensure that |
||
} | ||
} | ||
|
||
override fun completeInstalls(pkg: String, sessionId: Int, bundle0: Bundle, callback: ISplitInstallServiceCallback) { | ||
Log.d(TAG, "Method (completeInstalls) called but not implement by package -> $pkg") | ||
} | ||
|
||
override fun cancelInstall(pkg: String, sessionId: Int, callback: ISplitInstallServiceCallback) { | ||
Log.d(TAG, "Method (cancelInstall) called but not implement by package -> $pkg") | ||
} | ||
|
||
override fun getSessionState(pkg: String, sessionId: Int, callback: ISplitInstallServiceCallback) { | ||
Log.d(TAG, "Method (getSessionState) called but not implement by package -> $pkg") | ||
} | ||
|
||
override fun getSessionStates(pkg: String, callback: ISplitInstallServiceCallback) { | ||
Log.d(TAG, "Method (getSessionStates) called but not implement by package -> $pkg") | ||
callback.onGetSessionStates(ArrayList<Bundle>(1)) | ||
} | ||
|
||
override fun splitRemoval(pkg: String, splits: List<Bundle>, callback: ISplitInstallServiceCallback) { | ||
Log.d(TAG, "Method (splitRemoval) called but not implement by package -> $pkg") | ||
} | ||
|
||
override fun splitDeferred(pkg: String, splits: List<Bundle>, bundle0: Bundle, callback: ISplitInstallServiceCallback) { | ||
Log.d(TAG, "Method (splitDeferred) called but not implement by package -> $pkg") | ||
callback.onDeferredInstall(Bundle()) | ||
} | ||
|
||
override fun getSessionState2(pkg: String, sessionId: Int, callback: ISplitInstallServiceCallback) { | ||
Log.d(TAG, "Method (getSessionState2) called but not implement by package -> $pkg") | ||
} | ||
|
||
override fun getSessionStates2(pkg: String, callback: ISplitInstallServiceCallback) { | ||
Log.d(TAG, "Method (getSessionStates2) called but not implement by package -> $pkg") | ||
} | ||
|
||
override fun getSplitsAppUpdate(pkg: String, callback: ISplitInstallServiceCallback) { | ||
Log.d(TAG, "Method (getSplitsAppUpdate) called but not implement by package -> $pkg") | ||
} | ||
|
||
override fun completeInstallAppUpdate(pkg: String, callback: ISplitInstallServiceCallback) { | ||
Log.d(TAG, "Method (completeInstallAppUpdate) called but not implement by package -> $pkg") | ||
} | ||
|
||
override fun languageSplitInstall(pkg: String, splits: List<Bundle>, bundle0: Bundle, callback: ISplitInstallServiceCallback) { | ||
Log.d(TAG, "Method <languageSplitInstall> Called by package: $pkg") | ||
lifecycleScope.launch { | ||
trySplitInstall(context, httpClient, pkg, splits) | ||
} | ||
} | ||
|
||
override fun languageSplitUninstall(pkg: String, splits: List<Bundle>, callback: ISplitInstallServiceCallback) { | ||
Log.d(TAG, "Method (languageSplitUninstall) called but not implement by package -> $pkg") | ||
} | ||
|
||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Volley loads the entire response into memory. This is a problem for large downloads, as it will consume a lot of RAM (temporarily – or even fail the download if not enough memory is available). The data from the network stream should be written to disk immediately instead.
Per homepage: