Skip to content

Commit

Permalink
Add Cronet
Browse files Browse the repository at this point in the history
  • Loading branch information
mar-v-in committed Jun 26, 2021
1 parent 2e64427 commit a430489
Show file tree
Hide file tree
Showing 8 changed files with 109 additions and 11 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,7 @@ build/
user.gradle
local.properties
.directory

.settings
.classpath
.project
1 change: 1 addition & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
*/

buildscript {
ext.cronetVersion = '91.0.4472.120'

This comment has been minimized.

Copy link
@Vavun

Vavun Jun 30, 2021

Contributor

Hi @mar-v-in
Is this OK to have two different cronet libraries in the latest build ?
I see libcronet.91.0.4472.120.so and libcronet.92.0.4509.1.so inside microG apk.
Something wrong with build process ?

This comment has been minimized.

Copy link
@mar-v-in

mar-v-in Jun 30, 2021

Author Member

Not entirely sure how the libcronet.92.0.4509.1.so ended up in the release APK, something apparently wasn't properly cleaned up by Gradle. 91.0.4472.120 is the one being used (92 is a beta version).

This comment has been minimized.

Copy link
@mar-v-in

mar-v-in Jun 30, 2021

Author Member

Opened issue here: microg/cronet-build#1

ext.nlpVersion = '2.0-alpha6'
ext.remoteDroidGuardVersion = '0.1.2'
ext.safeParcelVersion = '1.7.0'
Expand Down
1 change: 1 addition & 0 deletions play-services-core/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ dependencies {
implementation project(':play-services-base-core')
implementation project(':play-services-base-core-ui')
implementation project(':play-services-conscrypt-provider-core')
implementation project(':play-services-cronet-core')
implementation project(':play-services-location-core')
implementation project(':play-services-vision-core')
withNearbyImplementation project(':play-services-nearby-core')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ public class DynamiteContext extends ContextWrapper {
private Context gmsContext;
private DynamiteContext appContext;

private ClassLoader classLoader;

public DynamiteContext(DynamiteModuleInfo moduleInfo, Context base, Context gmsContext, DynamiteContext appContext) {
super(base);
this.moduleInfo = moduleInfo;
Expand All @@ -38,19 +40,22 @@ public DynamiteContext(DynamiteModuleInfo moduleInfo, Context base, Context gmsC

@Override
public ClassLoader getClassLoader() {
StringBuilder nativeLoaderDirs = new StringBuilder(gmsContext.getApplicationInfo().nativeLibraryDir);
if (Build.VERSION.SDK_INT >= 23 && Process.is64Bit()) {
for (String abi : Build.SUPPORTED_64_BIT_ABIS) {
nativeLoaderDirs.append(File.pathSeparator).append(gmsContext.getApplicationInfo().sourceDir).append("!/lib/").append(abi);
}
} else if (Build.VERSION.SDK_INT >= 21) {
for (String abi : Build.SUPPORTED_32_BIT_ABIS) {
nativeLoaderDirs.append(File.pathSeparator).append(gmsContext.getApplicationInfo().sourceDir).append("!/lib/").append(abi);
if (classLoader == null) {
StringBuilder nativeLoaderDirs = new StringBuilder(gmsContext.getApplicationInfo().nativeLibraryDir);
if (Build.VERSION.SDK_INT >= 23 && Process.is64Bit()) {
for (String abi : Build.SUPPORTED_64_BIT_ABIS) {
nativeLoaderDirs.append(File.pathSeparator).append(gmsContext.getApplicationInfo().sourceDir).append("!/lib/").append(abi);
}
} else if (Build.VERSION.SDK_INT >= 21) {
for (String abi : Build.SUPPORTED_32_BIT_ABIS) {
nativeLoaderDirs.append(File.pathSeparator).append(gmsContext.getApplicationInfo().sourceDir).append("!/lib/").append(abi);
}
} else {
nativeLoaderDirs.append(File.pathSeparator).append(gmsContext.getApplicationInfo().sourceDir).append("!/lib/").append(Build.CPU_ABI);
}
} else {
nativeLoaderDirs.append(File.pathSeparator).append(gmsContext.getApplicationInfo().sourceDir).append("!/lib/").append(Build.CPU_ABI);
classLoader = new PathClassLoader(gmsContext.getApplicationInfo().sourceDir, nativeLoaderDirs.toString(), new FilteredClassLoader(originalContext.getClassLoader(), moduleInfo.getMergedClasses(), moduleInfo.getMergedPackages()));
}
return new PathClassLoader(gmsContext.getApplicationInfo().sourceDir, nativeLoaderDirs.toString(), new FilteredClassLoader(originalContext.getClassLoader(), moduleInfo.getMergedClasses(), moduleInfo.getMergedPackages()));
return classLoader;
}

@Override
Expand Down
38 changes: 38 additions & 0 deletions play-services-cronet-core/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/*
* SPDX-FileCopyrightText: 2021, microG Project Team
* SPDX-License-Identifier: Apache-2.0
*/

apply plugin: 'com.android.library'
apply plugin: 'maven-publish'
apply plugin: 'signing'

dependencies {
implementation("org.microg:cronet-api:$cronetVersion")
implementation("org.microg:cronet-common:$cronetVersion")
implementation("org.microg:cronet-native:$cronetVersion")
}

android {
compileSdkVersion androidCompileSdk
buildToolsVersion "$androidBuildVersionTools"

defaultConfig {
versionName version
minSdkVersion androidMinSdk
targetSdkVersion androidTargetSdk
}

lintOptions {
disable 'MissingTranslation'
}

compileOptions {
sourceCompatibility = 1.8
targetCompatibility = 1.8
}
}

apply from: '../gradle/publish-android.gradle'

description = 'microG service implementation for play-services-cronet'
11 changes: 11 additions & 0 deletions play-services-cronet-core/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
~ SPDX-FileCopyrightText: 2021, microG Project Team
~ SPDX-License-Identifier: Apache-2.0
-->
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.microg.gms.net.core">

<application>
</application>
</manifest>
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/*
* SPDX-FileCopyrightText: 2021, microG Project Team
* SPDX-License-Identifier: Apache-2.0
*/

package com.google.android.gms.dynamite.descriptors.com.google.android.gms.cronet_dynamite;

import java.util.Arrays;
import java.util.List;

public class ModuleDescriptor {
public static final String MODULE_ID = "com.google.android.gms.cronet_dynamite";
public static final int MODULE_VERSION = 2;
public static final List<String> MERGED_CLASSES = Arrays.asList(
"org.chromium.net.ApiVersion",
"org.chromium.net.BidirectionalStream",
"org.chromium.net.CallbackException",
"org.chromium.net.CronetEngine",
"org.chromium.net.CronetException",
"org.chromium.net.CronetProvider",
"org.chromium.net.ExperimentalBidirectionalStream",
"org.chromium.net.ExperimentalCronetEngine",
"org.chromium.net.ExperimentalUrlRequest",
"org.chromium.net.ICronetEngineBuilder",
"org.chromium.net.InlineExecutionProhibitedException",
"org.chromium.net.NetworkException",
"org.chromium.net.NetworkQualityRttListener",
"org.chromium.net.NetworkQualityThroughputListener",
"org.chromium.net.QuicException",
"org.chromium.net.RequestFinishedInfo",
"org.chromium.net.UploadDataProvider",
"org.chromium.net.UploadDataProviders",
"org.chromium.net.UploadDataSink",
"org.chromium.net.UrlRequest",
"org.chromium.net.UrlResponseInfo"
);
}
1 change: 1 addition & 0 deletions settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ include ':play-services-wearable-proto'

include ':play-services-base-core'
include ':play-services-conscrypt-provider-core'
include ':play-services-cronet-core'
include ':play-services-location-core'
include ':play-services-maps-core-mapbox'
include ':play-services-maps-core-vtm'
Expand Down

0 comments on commit a430489

Please sign in to comment.