forked from microg/GmsCore
-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
When a 3rd party app wants to install a split APK, the application tries to bind to a SplitInstallService through the SplitInstallManager part of the Google Play Feature Delivery Library. The implementation of SplitInstallService allows us to catch the install requests coming from the 3rd party app and handle them. As an example, DummyStoreSplitInstaller binds to an external com.dummy.store.splitinstall.SplitInstallService service which is able to retrieve the split APKs from the com.dummy.store.
- Loading branch information
1 parent
048a6e5
commit e41e442
Showing
9 changed files
with
407 additions
and
0 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
21 changes: 21 additions & 0 deletions
21
vending-app/src/main/aidl/com/dummy/store/IDummyStoreSplitInstallService.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,21 @@ | ||
/* | ||
* Copyright 2013-2022 microG Project Team | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package com.dummy.store; | ||
|
||
interface IDummyStoreSplitInstallService { | ||
void installSplitModule(String packageName, String moduleName); | ||
} |
59 changes: 59 additions & 0 deletions
59
...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,59 @@ | ||
/* | ||
* Copyright 2013-2022 microG Project Team | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package com.google.android.play.core.splitinstall.protocol; | ||
|
||
import com.google.android.play.core.splitinstall.protocol.ISplitInstallServiceCallback; | ||
|
||
interface ISplitInstallService { | ||
|
||
// Method not identified yet | ||
void a(); | ||
|
||
void startInstall(String str, in List<Bundle> list, in Bundle bundle, in ISplitInstallServiceCallback callback); | ||
|
||
// Method not identified yet | ||
void c(String str); | ||
|
||
// Method not identified yet | ||
void d(String str); | ||
|
||
// Method not identified yet | ||
void e(String str); | ||
|
||
void getSessionStates(String str, in ISplitInstallServiceCallback callback); | ||
|
||
// Method not identified yet | ||
void g(String str); | ||
|
||
// Method not identified yet | ||
void h(String str, in ISplitInstallServiceCallback callback); | ||
|
||
// Method not identified yet | ||
void i(String str); | ||
|
||
// Method not identified yet | ||
void j(String str); | ||
|
||
// Method not identified yet | ||
void k(String str); | ||
|
||
// Method not identified yet | ||
void l(String str); | ||
|
||
// Method not identified yet | ||
void m(String str); | ||
} |
47 changes: 47 additions & 0 deletions
47
...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,47 @@ | ||
/* | ||
* Copyright 2013-2022 microG Project Team | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package com.google.android.play.core.splitinstall.protocol; | ||
|
||
import android.os.Bundle; | ||
|
||
interface ISplitInstallServiceCallback { | ||
|
||
void onStartInstall(int i, in Bundle bundle); | ||
|
||
// Method not identified yet | ||
void b(); | ||
|
||
void onCompleteInstall(int i); | ||
|
||
void onCancelInstall(int i, in Bundle bundle); | ||
|
||
void onGetSession(int i, in Bundle bundle); | ||
|
||
void onError(in Bundle bundle); | ||
|
||
void onGetSessionStates(in List<Bundle> list); | ||
|
||
void onDeferredUninstall(in Bundle bundle); | ||
|
||
void onDeferredInstall(in Bundle bundle); | ||
|
||
void onGetSplitsForAppUpdate(); | ||
|
||
void onCompleteInstallForAppUpdate(); | ||
|
||
void onDeferredLanguageInstall(); | ||
} |
120 changes: 120 additions & 0 deletions
120
vending-app/src/main/java/com/android/vending/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,120 @@ | ||
/* | ||
* Copyright 2013-2022 microG Project Team | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package com.android.vending | ||
|
||
import android.app.Service | ||
import android.content.Intent | ||
import android.os.Bundle | ||
import android.os.IBinder | ||
import android.util.Log | ||
import com.android.vending.splitinstall.SplitInstaller | ||
import com.android.vending.splitinstall.SplitInstallerFactory | ||
import com.android.vending.splitinstall.SplitInstallerType | ||
import com.google.android.play.core.splitinstall.protocol.ISplitInstallService | ||
import com.google.android.play.core.splitinstall.protocol.ISplitInstallServiceCallback | ||
|
||
class SplitInstallService : Service() { | ||
|
||
companion object { | ||
const val TAG = "SplitInstallService" | ||
} | ||
|
||
private lateinit var mSplitInstaller: SplitInstaller | ||
|
||
override fun onCreate() { | ||
super.onCreate() | ||
|
||
mSplitInstaller = SplitInstallerFactory.createSplitInstaller( | ||
applicationContext, | ||
SplitInstallerType.DummyStoreSplitInstaller | ||
) | ||
|
||
mSplitInstaller.initialize() | ||
} | ||
|
||
override fun onBind(p0: Intent?): IBinder { | ||
return mServiceInterface | ||
} | ||
|
||
override fun onDestroy() { | ||
super.onDestroy() | ||
mSplitInstaller.destroy() | ||
} | ||
|
||
private var mServiceInterface = object : ISplitInstallService.Stub() { | ||
|
||
override fun a() { | ||
Log.d(TAG, "a") | ||
} | ||
|
||
override fun startInstall( | ||
packageName: String, | ||
list: List<Bundle>, | ||
bundle: Bundle, | ||
callback: ISplitInstallServiceCallback | ||
) { | ||
for (element in list) { | ||
mSplitInstaller.install(packageName, element.get("module_name").toString()) | ||
} | ||
} | ||
|
||
override fun c(str: String?) { | ||
Log.d(TAG, "c") | ||
} | ||
|
||
override fun d(str: String?) { | ||
Log.d(TAG, "d") | ||
} | ||
|
||
override fun e(str: String?) { | ||
Log.d(TAG, "e") | ||
} | ||
|
||
override fun getSessionStates(str: String, callback: ISplitInstallServiceCallback) { | ||
Log.d(TAG, "onGetSessionStates") | ||
callback.onGetSessionStates(arrayListOf<Bundle>()) | ||
} | ||
|
||
override fun g(str: String?) { | ||
Log.d(TAG, "g") | ||
} | ||
|
||
override fun h(str: String?, callback: ISplitInstallServiceCallback?) { | ||
Log.d(TAG, "h $str $callback") | ||
} | ||
|
||
override fun i(str: String?) { | ||
Log.d(TAG, "i") | ||
} | ||
|
||
override fun j(str: String?) { | ||
Log.d(TAG, "j") | ||
} | ||
|
||
override fun k(str: String?) { | ||
Log.d(TAG, "k") | ||
} | ||
|
||
override fun l(str: String?) { | ||
Log.d(TAG, "l") | ||
} | ||
|
||
override fun m(str: String?) { | ||
Log.d(TAG, "m") | ||
} | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
vending-app/src/main/java/com/android/vending/splitinstall/SplitInstallErrorCode.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,23 @@ | ||
/* | ||
* Copyright 2013-2022 microG Project Team | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package com.android.vending.splitinstall | ||
|
||
interface SplitInstallErrorCode { | ||
companion object { | ||
const val API_NOT_AVAILABLE = -5 | ||
} | ||
} |
38 changes: 38 additions & 0 deletions
38
vending-app/src/main/java/com/android/vending/splitinstall/SplitInstaller.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,38 @@ | ||
/* | ||
* Copyright 2013-2022 microG Project Team | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package com.android.vending.splitinstall | ||
|
||
import android.content.Context | ||
import com.android.vending.splitinstall.installer.DummyStoreSplitInstaller | ||
|
||
interface SplitInstaller { | ||
fun initialize() | ||
fun install(packageName: String, moduleName: String) | ||
fun destroy() | ||
} | ||
|
||
enum class SplitInstallerType { DummyStoreSplitInstaller } | ||
|
||
object SplitInstallerFactory { | ||
fun createSplitInstaller(context: Context, type: SplitInstallerType): SplitInstaller { | ||
when (type) { | ||
SplitInstallerType.DummyStoreSplitInstaller -> | ||
return DummyStoreSplitInstaller(context) | ||
else -> throw IllegalArgumentException("Unknown SplitInstallerType") | ||
} | ||
} | ||
} |
Oops, something went wrong.