Commit 7cfd3ca0 authored by Romain Hunault's avatar Romain Hunault

Merge branch 'merge-v0.2.16.204713'

parents 33646c38 45d4dffb
......@@ -4,9 +4,9 @@
*/
buildscript {
ext.nlpVersion = '2.0-alpha5'
ext.nlpVersion = '2.0-alpha6'
ext.remoteDroidGuardVersion = '0.1.2'
ext.safeParcelVersion = '1.6.0'
ext.safeParcelVersion = '1.7.0'
ext.wearableVersion = '0.1.1'
ext.kotlinVersion = '1.4.10'
......@@ -57,7 +57,7 @@ def execResult(...args) {
return stdout.toString().trim()
}
def gmsVersion = "20.42.15"
def gmsVersion = "20.47.13"
def gmsVersionCode = Integer.parseInt(gmsVersion.replaceAll('\\.', ''))
def gitVersionBase = execResult('git', 'describe', '--tags', '--abbrev=0', '--match=v[0-9]*').substring(1)
def gitCommitCount = Integer.parseInt(execResult('git', 'rev-list', '--count', "v$gitVersionBase..HEAD"))
......
......@@ -74,7 +74,7 @@ class FirebaseAuthService : BaseService(TAG, GmsService.FIREBASE_AUTH) {
PackageUtils.getAndCheckCallingPackage(this, request.packageName)
val apiKey = request.extras?.getString(Constants.EXTRA_API_KEY)
val libraryVersion = request.extras?.getString(Constants.EXTRA_LIBRARY_VERSION)
if (apiKey == null || libraryVersion == null) {
if (apiKey == null) {
callback.onPostInitComplete(CommonStatusCodes.DEVELOPER_ERROR, null, null)
} else {
callback.onPostInitComplete(0, FirebaseAuthServiceImpl(this, lifecycle, request.packageName, libraryVersion, apiKey).asBinder(), null)
......@@ -82,7 +82,7 @@ class FirebaseAuthService : BaseService(TAG, GmsService.FIREBASE_AUTH) {
}
}
class FirebaseAuthServiceImpl(private val context: Context, private val lifecycle: Lifecycle, private val packageName: String, private val libraryVersion: String, private val apiKey: String) : IFirebaseAuthService.Stub(), LifecycleOwner {
class FirebaseAuthServiceImpl(private val context: Context, private val lifecycle: Lifecycle, private val packageName: String, private val libraryVersion: String?, private val apiKey: String) : IFirebaseAuthService.Stub(), LifecycleOwner {
private val client = IdentityToolkitClient(context, apiKey)
private var authorizedDomain: String? = null
......
<?xml version="1.0" encoding="utf-8"?>
<!--
~ SPDX-FileCopyrightText: 2020, microG Project Team
~ SPDX-License-Identifier: Apache-2.0
-->
<resources>
<string name="menu_advanced">Дадаткова</string>
<string name="list_no_item_none">Пуста</string>
<string name="list_item_see_all">Паказаць усё</string>
<string name="open_app">адкрыць</string>
</resources>
<?xml version="1.0" encoding="utf-8"?>
<!--
~ SPDX-FileCopyrightText: 2020, microG Project Team
~ SPDX-License-Identifier: Apache-2.0
-->
<resources>
<string name="menu_advanced">詳細設定</string>
<string name="list_no_item_none">アイテムがありません</string>
<string name="list_item_see_all">全て表示</string>
<string name="open_app">開く</string>
</resources>
......@@ -8,4 +8,7 @@
<string name="menu_advanced">Дополнительно</string>
<string name="list_no_item_none">Пусто</string>
<string name="list_item_see_all">Показать всё</string>
<string name="open_app">открыть</string>
</resources>
package org.microg.gms.common;
import android.app.ActivityManager;
import android.app.Notification;
import android.app.NotificationChannel;
import android.app.NotificationManager;
......@@ -15,7 +14,7 @@ import android.util.Log;
import androidx.annotation.RequiresApi;
import java.util.List;
import org.microg.gms.base.core.R;
public class ForegroundServiceContext extends ContextWrapper {
private static final String TAG = "ForegroundService";
......@@ -27,7 +26,7 @@ public class ForegroundServiceContext extends ContextWrapper {
@Override
public ComponentName startService(Intent service) {
if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.O && !isIgnoringBatteryOptimizations() && !isAppOnForeground()) {
if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.O && !isIgnoringBatteryOptimizations()) {
Log.d(TAG, "Starting in foreground mode.");
service.putExtra(EXTRA_FOREGROUND, true);
return super.startForegroundService(service);
......@@ -41,39 +40,62 @@ public class ForegroundServiceContext extends ContextWrapper {
return powerManager.isIgnoringBatteryOptimizations(getPackageName());
}
private boolean isAppOnForeground() {
ActivityManager activityManager = (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE);
List<ActivityManager.RunningAppProcessInfo> appProcesses = activityManager.getRunningAppProcesses();
if (appProcesses == null) {
return false;
}
final String packageName = getPackageName();
for (ActivityManager.RunningAppProcessInfo appProcess : appProcesses) {
if (appProcess.importance == ActivityManager.RunningAppProcessInfo.IMPORTANCE_FOREGROUND && appProcess.processName.equals(packageName)) {
return true;
private static String getServiceName(Service service) {
String serviceName = null;
try {
ForegroundServiceInfo annotation = service.getClass().getAnnotation(ForegroundServiceInfo.class);
if (annotation != null) {
if (annotation.res() != 0) {
try {
serviceName = service.getString(annotation.res());
} catch (Exception ignored) {
}
}
if (serviceName == null) {
serviceName = annotation.value();
}
}
} catch (Exception ignored) {
}
if (serviceName == null) {
serviceName = service.getClass().getSimpleName();
}
return false;
return serviceName;
}
public static void completeForegroundService(Service service, Intent intent, String tag) {
if (intent != null && intent.getBooleanExtra(EXTRA_FOREGROUND, false) && Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
Log.d(tag, "Started in foreground mode.");
service.startForeground(tag.hashCode(), buildForegroundNotification(service));
String serviceName = getServiceName(service);
Log.d(tag, "Started " + serviceName + " in foreground mode.");
try {
Notification notification = buildForegroundNotification(service, serviceName);
service.startForeground(serviceName.hashCode(), notification);
Log.d(tag, "Notification: " + notification.toString());
} catch (Exception e) {
Log.w(tag, e);
}
}
}
@RequiresApi(api = Build.VERSION_CODES.O)
private static Notification buildForegroundNotification(Context context) {
private static Notification buildForegroundNotification(Context context, String serviceName) {
NotificationChannel channel = new NotificationChannel("foreground-service", "Foreground Service", NotificationManager.IMPORTANCE_NONE);
channel.setLockscreenVisibility(Notification.VISIBILITY_SECRET);
channel.setShowBadge(false);
channel.setVibrationPattern(new long[0]);
channel.setVibrationPattern(new long[]{0});
context.getSystemService(NotificationManager.class).createNotificationChannel(channel);
String appTitle = context.getApplicationInfo().loadLabel(context.getPackageManager()).toString();
String notifyTitle = context.getString(R.string.foreground_service_notification_title);
String firstLine = context.getString(R.string.foreground_service_notification_text, serviceName);
String secondLine = context.getString(R.string.foreground_service_notification_big_text, appTitle);
Log.d(TAG, notifyTitle + " // " + firstLine + " // " + secondLine);
return new Notification.Builder(context, channel.getId())
.setOngoing(true)
.setContentTitle("Running in background")
//.setSmallIcon(R.drawable.ic_cloud_bell)
.setSmallIcon(R.drawable.ic_background_notify)
.setContentTitle(notifyTitle)
.setContentText(firstLine)
.setStyle(new Notification.BigTextStyle().bigText(firstLine + "\n" + secondLine))
.build();
}
}
/*
* SPDX-FileCopyrightText: 2020, microG Project Team
* SPDX-License-Identifier: Apache-2.0
*/
package org.microg.gms.common;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.TYPE)
public @interface ForegroundServiceInfo {
String value();
int res() default 0;
}
......@@ -24,6 +24,7 @@ import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.content.pm.Signature;
import android.os.Binder;
import android.util.Log;
import androidx.annotation.Nullable;
......@@ -245,6 +246,36 @@ public class PackageUtils {
}
}
public static boolean isPersistentProcess() {
String processName = getProcessName();
if (processName == null) {
Log.w("GmsPackageUtils", "Can't determine process name of current process");
return false;
}
return processName.endsWith(":persistent");
}
public static boolean isMainProcess(Context context) {
String processName = getProcessName();
if (processName == null) {
Log.w("GmsPackageUtils", "Can't determine process name of current process");
return false;
}
return processName.equals(context.getPackageName());
}
public static void warnIfNotPersistentProcess(Class<?> clazz) {
if (!isPersistentProcess()) {
Log.w("GmsPackageUtils", clazz.getSimpleName() + " initialized outside persistent process", new RuntimeException());
}
}
public static void warnIfNotMainProcess(Context context, Class<?> clazz) {
if (!isMainProcess(context)) {
Log.w("GmsPackageUtils", clazz.getSimpleName() + " initialized outside main process", new RuntimeException());
}
}
public static String sha1sum(byte[] bytes) {
MessageDigest md;
try {
......
<!--
~ SPDX-FileCopyrightText: 2020, microG Project Team
~ SPDX-License-Identifier: Apache-2.0
-->
<vector android:height="24dp" android:viewportHeight="24"
android:viewportWidth="24" android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="#000000" android:pathData="M19.51,3.08L3.08,19.51c0.09,0.34 0.27,0.65 0.51,0.9 0.25,0.24 0.56,0.42 0.9,0.51L20.93,4.49c-0.19,-0.69 -0.73,-1.23 -1.42,-1.41zM11.88,3L3,11.88v2.83L14.71,3h-2.83zM5,3c-1.1,0 -2,0.9 -2,2v2l4,-4L5,3zM19,21c0.55,0 1.05,-0.22 1.41,-0.59 0.37,-0.36 0.59,-0.86 0.59,-1.41v-2l-4,4h2zM9.29,21h2.83L21,12.12L21,9.29L9.29,21z"/>
</vector>
<?xml version="1.0" encoding="utf-8"?>
<!--
~ SPDX-FileCopyrightText: 2020, microG Project Team
~ SPDX-License-Identifier: Apache-2.0
-->
<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
<string name="foreground_service_notification_title">Im Hintergrund aktiv</string>
<string name="foreground_service_notification_text"><xliff:g example="Exposure Notification">%1$s</xliff:g> läuft im Hintergrund weiter.</string>
<string name="foreground_service_notification_big_text">Füge <xliff:g example="microG Services Core">%1$s</xliff:g> als Ausnahme zur Batterie-Optimierung hinzu oder verstecke diese Benachrichtigung in den Systemeinstelleungen.</string>
</resources>
<?xml version="1.0" encoding="utf-8"?>
<!--
~ SPDX-FileCopyrightText: 2020, microG Project Team
~ SPDX-License-Identifier: Apache-2.0
-->
<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
<string name="foreground_service_notification_title">Active in background</string>
<string name="foreground_service_notification_text"><xliff:g example="Exposure Notification">%1$s</xliff:g> is running in background.</string>
<string name="foreground_service_notification_big_text">Exclude <xliff:g example="microG Services Core">%1$s</xliff:g> from battery optimizations or change notification settings to hide this notification.</string>
</resources>
/*
* SPDX-FileCopyrightText: 2020, microG Project Team
* SPDX-License-Identifier: Apache-2.0
*/
package com.google.android.gms.common.images;
import org.microg.gms.common.PublicApi;
/**
* Immutable class for describing width and height dimensions in pixels.
*/
@PublicApi
public class Size {
private int width;
private int height;
/**
* Create a new immutable Size instance.
*
* @param width The width of the size, in pixels
* @param height The height of the size, in pixels
*/
public Size(int width, int height) {
this.width = width;
this.height = height;
}
/**
* Check if this size is equal to another size.
* <p>
* Two sizes are equal if and only if both their widths and heights are equal.
* <p>
* A size object is never equal to any other type of object.
*
* @return {@code true} if the objects were equal, {@code false} otherwise
*/
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (!(o instanceof Size)) return false;
Size size = (Size) o;
if (width != size.width) return false;
return height == size.height;
}
/**
* Get the height of the size (in pixels).
*
* @return height
*/
public int getHeight() {
return height;
}
/**
* Get the width of the size (in pixels).
*
* @return width
*/
public int getWidth() {
return width;
}
@Override
public int hashCode() {
int result = width;
result = 31 * result + height;
return result;
}
/**
* Parses the specified string as a size value.
* <p>
* The ASCII characters {@code \}{@code u002a} ('*') and {@code \}{@code u0078} ('x') are recognized as separators between the width and height.
* <p>
* For any {@code Size s}: {@code Size.parseSize(s.toString()).equals(s)}. However, the method also handles sizes expressed in the following forms:
* <p>
* "width{@code x}height" or "width{@code *}height" => new Size(width, height), where width and height are string integers potentially containing a sign, such as "-10", "+7" or "5".
*
* @param string the string representation of a size value.
* @return the size value represented by {@code string}.
* @throws NumberFormatException if {@code string} cannot be parsed as a size value.
* @throws NullPointerException if {@code string} was null
*/
public static Size parseSize(String string) {
if (string == null) throw new NullPointerException("string must not be null");
int split = string.indexOf('*');
if (split < 0) split = string.indexOf('x');
if (split < 0) throw new NumberFormatException("Invalid Size: \"" + string + "\"");
return new Size(Integer.parseInt(string.substring(0, split)), Integer.parseInt(string.substring(split + 1)));
}
/**
* Return the size represented as a string with the format {@code "WxH"}
* @return string representation of the size
*/
@Override
public String toString() {
return width + "x" + height;
}
}
......@@ -17,7 +17,7 @@
package org.microg.gms.common;
public class Constants {
public static final int MAX_REFERENCE_VERSION = 204215 * 1000;
public static final int MAX_REFERENCE_VERSION = 204713 * 1000;
public static final String GMS_PACKAGE_NAME = "com.google.android.gms";
public static final String GSF_PACKAGE_NAME = "com.google.android.gsf";
public static final String GMS_PACKAGE_SIGNATURE_SHA1 = "38918a453d07199354f8b19af05ec6562ced5788";
......
......@@ -101,6 +101,7 @@ public enum GmsService {
WORK_ACCOUNT(120),
AD_CACHE(123, "com.google.android.gms.ads.service.CACHE"),
DYNAMIC_LINKS(131, "com.google.firebase.dynamiclinks.service.START"),
IDENTITY_SIGN_IN(212, "com.google.android.gms.auth.api.identity.service.signin.START"),
NEARBY_EXPOSURE(236, "com.google.android.gms.nearby.exposurenotification.START"),
;
......
......@@ -14,9 +14,6 @@
* limitations under the License.
*/
package org.microg.gms.kotlin
import com.google.android.gms.dynamic.IObjectWrapper
import com.google.android.gms.dynamic.ObjectWrapper
package com.google.android.gms.dynamic
inline fun <reified T> IObjectWrapper?.unwrap(): T? = ObjectWrapper.unwrapTyped(this, T::class.java)
......@@ -131,7 +131,7 @@ public class ProviderInstallerImpl {
// TODO: Move manual loading into helper function (as it is also used in both maps implementations)
String primaryCpuAbi = (String) ApplicationInfo.class.getField("primaryCpuAbi").get(otherAppInfo);
if (primaryCpuAbi != null) {
String path = "lib/" + primaryCpuAbi + "/libconscrypt_jni.so";
String path = "lib/" + primaryCpuAbi + "/libconscrypt_gmscore_jni.so";
File cacheFile = new File(context.createPackageContext(packageName, 0).getCacheDir().getAbsolutePath() + "/.gmscore/" + path);
cacheFile.getParentFile().mkdirs();
File apkFile = new File(context.getPackageCodePath());
......@@ -144,7 +144,7 @@ public class ProviderInstallerImpl {
Log.d(TAG, "Can't load native library: " + path + " does not exist in " + apkFile);
}
}
Log.d(TAG, "Loading conscrypt_jni from " + cacheFile.getPath());
Log.d(TAG, "Loading conscrypt_gmscore_jni from " + cacheFile.getPath());
System.load(cacheFile.getAbsolutePath());
Class<NativeCrypto> clazz = NativeCrypto.class;
......
......@@ -45,6 +45,7 @@ dependencies {
implementation project(':play-services-base-core-ui')
implementation project(':play-services-conscrypt-provider-core')
implementation project(':play-services-location-core')
implementation project(':play-services-vision-core')
withNearbyImplementation project(':play-services-nearby-core')
withNearbyImplementation project(':play-services-nearby-core-ui')
implementation project(':play-services-core-proto')
......
<?xml version="1.0" encoding="utf-8"?>
<!--
~ Copyright (C) 2020 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.
-->
<resources>
<string name="lib_name">microG UI Tools</string>
<string name="lib_license">Apache License 2.0, microG Team</string>
<string name="about_version_str">Версія %1$s</string>
<string name="about_name_version_str">%1$s %2$s</string>
<string name="about_default_license">Ўсе правы абаронены.</string>
<string name="prefcat_setup">Ўсталяваць</string>
<string name="self_check_title">Праверка працаздольнасці</string>
<string name="self_check_desc">Праверце, ці правільна настроена сістэма для выкарыстання microG.</string>
<string name="self_check_cat_permissions">Правы доступу прадастаўленыя</string>
<string name="self_check_name_permission">%1$s:</string>
<string name="self_check_resolution_permission">Націсніце тут, каб даць дазвол. Непрадастаўленне дазволу можа прывесці да некарэктнай працы прыкладання.</string>
<string name="about_root_title">microG UI Demo</string>
<string name="about_root_summary">Падрабязнасці</string>
<string name="about_root_version">Версія v0.1.0</string>
<string name="about_root_libraries">Выкарыстоўваемыя бібліятэкі</string>
<string name="about_android_support_v4">v4 Support Library</string>
<string name="about_android_support_v7_appcompat">v7 appcompat Support Library</string>
<string name="about_android_support_v7_preference">v7 preference Support Library</string>
<string name="about_android_support_license">Apache License 2.0, The Android Open Source Project</string>
</resources>
<?xml version="1.0" encoding="utf-8"?>
<!--
~ Copyright (C) 2013-2017 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.
-->
<resources>
<string name="lib_name">microG UIツール</string>