MicroG 0.2.12.203316

Thanks to xinto for kotlin fixes :D
This commit is contained in:
Oizaro 2020-09-23 22:40:22 +02:00
parent 1bf15a111a
commit 2fd19ada91
9 changed files with 82 additions and 42 deletions

View File

@ -45,6 +45,7 @@ public class CheckinClient {
private static final List<String> TODO_LIST_STRING = new ArrayList<>(); // TODO private static final List<String> TODO_LIST_STRING = new ArrayList<>(); // TODO
private static final List<CheckinRequest.Checkin.Statistic> TODO_LIST_CHECKIN = new ArrayList<CheckinRequest.Checkin.Statistic>(); // TODO private static final List<CheckinRequest.Checkin.Statistic> TODO_LIST_CHECKIN = new ArrayList<CheckinRequest.Checkin.Statistic>(); // TODO
private static final String SERVICE_URL = "https://android.clients.google.com/checkin"; private static final String SERVICE_URL = "https://android.clients.google.com/checkin";
public static boolean brandSpoof = false;
public static CheckinResponse request(CheckinRequest request) throws IOException { public static CheckinResponse request(CheckinRequest request) throws IOException {
HttpURLConnection connection = (HttpURLConnection) new URL(SERVICE_URL).openConnection(); HttpURLConnection connection = (HttpURLConnection) new URL(SERVICE_URL).openConnection();
@ -78,25 +79,24 @@ public class CheckinClient {
public static CheckinRequest makeRequest(Build build, DeviceConfiguration deviceConfiguration, public static CheckinRequest makeRequest(Build build, DeviceConfiguration deviceConfiguration,
DeviceIdentifier deviceIdent, PhoneInfo phoneInfo, DeviceIdentifier deviceIdent, PhoneInfo phoneInfo,
LastCheckinInfo checkinInfo, Locale locale, LastCheckinInfo checkinInfo, Locale locale,
List<Account> accounts, boolean hasGooglePlayServices) { List<Account> accounts) {
CheckinRequest.Builder builder = new CheckinRequest.Builder() CheckinRequest.Builder builder = new CheckinRequest.Builder()
.accountCookie(new ArrayList<String>()) .accountCookie(new ArrayList<String>())
.androidId(checkinInfo.androidId) .androidId(checkinInfo.androidId)
.checkin(new CheckinRequest.Checkin.Builder() .checkin(new CheckinRequest.Checkin.Builder()
.build(new CheckinRequest.Checkin.Build.Builder() .build(new CheckinRequest.Checkin.Build.Builder()
.bootloader(hasGooglePlayServices ? build.bootloader : "c2f2-0.2-5799621") .bootloader(!brandSpoof ? build.bootloader : "c2f2-0.2-5799621")
.brand(hasGooglePlayServices ? build.brand : "google") .brand(!brandSpoof ? build.brand : "google")
.clientId("android-google") .clientId("android-google")
.device(hasGooglePlayServices ? build.device : "generic") .device(!brandSpoof ? build.device : "generic")
.fingerprint(hasGooglePlayServices ? build.fingerprint : "google/coral/coral:10/QD1A.190821.007/5831595:user/release-keys") .fingerprint(!brandSpoof ? build.fingerprint : "google/coral/coral:10/QD1A.190821.007/5831595:user/release-keys")
.hardware(hasGooglePlayServices ? build.hardware : "coral") .hardware(!brandSpoof ? build.hardware : "coral")
.manufacturer(hasGooglePlayServices ? build.manufacturer : "Google") .manufacturer(!brandSpoof ? build.manufacturer : "Google")
.model(hasGooglePlayServices ? build.model : "mainline") .model(!brandSpoof ? build.model : "mainline")
.otaInstalled(false) // TODO? .otaInstalled(false) // TODO?
//.packageVersionCode(Constants.MAX_REFERENCE_VERSION) .product(!brandSpoof ? build.product : "coral")
.product(hasGooglePlayServices ? build.product : "coral") .radio(!brandSpoof ? build.radio : "")
.radio(build.radio) .sdkVersion(!brandSpoof ? build.sdk : 29)
.sdkVersion(build.sdk)
.time(build.time / 1000) .time(build.time / 1000)
.build()) .build())
.cellOperator(phoneInfo.cellOperator) .cellOperator(phoneInfo.cellOperator)

View File

@ -20,8 +20,6 @@ import android.accounts.Account;
import android.accounts.AccountManager; import android.accounts.AccountManager;
import android.content.ContentResolver; import android.content.ContentResolver;
import android.content.Context; import android.content.Context;
import android.content.pm.PackageManager;
import android.util.Log;
import org.microg.gms.auth.AuthConstants; import org.microg.gms.auth.AuthConstants;
import org.microg.gms.auth.AuthRequest; import org.microg.gms.auth.AuthRequest;
@ -60,7 +58,7 @@ public class CheckinManager {
} }
CheckinRequest request = CheckinClient.makeRequest(Utils.getBuild(context), CheckinRequest request = CheckinClient.makeRequest(Utils.getBuild(context),
new DeviceConfiguration(context), Utils.getDeviceIdentifier(context), new DeviceConfiguration(context), Utils.getDeviceIdentifier(context),
Utils.getPhoneInfo(context), info, Utils.getLocale(context), accounts, hasGooglePlayServices(context)); Utils.getPhoneInfo(context), info, Utils.getLocale(context), accounts);
return handleResponse(context, CheckinClient.request(request)); return handleResponse(context, CheckinClient.request(request));
} }
@ -81,18 +79,4 @@ public class CheckinManager {
return info; return info;
} }
private static boolean hasGooglePlayServices(Context context) {
boolean hasGooglePlayServices = false;
try {
// We will assume that the user has Google Play services installed if context is null
if (context == null || (context != null && context.getPackageManager().getApplicationInfo("com.google.android.gms", 0).enabled)) {
hasGooglePlayServices = true;
}
} catch (PackageManager.NameNotFoundException e) {}
Log.d(TAG, "checking - has google play services: " + (hasGooglePlayServices ? "yes" : "no"));
return hasGooglePlayServices;
}
} }

View File

@ -30,10 +30,11 @@ public class ForegroundServiceContext extends ContextWrapper {
super(base); super(base);
} }
@RequiresApi(api = Build.VERSION_CODES.M)
@Override @Override
public ComponentName startService(Intent service) { public ComponentName startService(Intent service) {
if (!isIgnoringBatteryOptimizations() && !isAppOnForeground()) { if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.M
&& !isIgnoringBatteryOptimizations()
&& !isAppOnForeground()) {
Log.d(TAG, "Starting in foreground mode."); Log.d(TAG, "Starting in foreground mode.");
service.putExtra(EXTRA_FOREGROUND, true); service.putExtra(EXTRA_FOREGROUND, true);
if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
@ -67,7 +68,9 @@ public class ForegroundServiceContext extends ContextWrapper {
} }
public static void completeForegroundService(Service service, Intent intent, String tag) { public static void completeForegroundService(Service service, Intent intent, String tag) {
if (intent != null && intent.getBooleanExtra(EXTRA_FOREGROUND, false)) { if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.M
&& intent != null
&& intent.getBooleanExtra(EXTRA_FOREGROUND, false)) {
Log.d(tag, "Started in foreground mode."); Log.d(tag, "Started in foreground mode.");
service.startForeground(tag.hashCode(), buildForegroundNotification(service)); service.startForeground(tag.hashCode(), buildForegroundNotification(service));
} }

View File

@ -5,34 +5,55 @@
package org.microg.gms.ui package org.microg.gms.ui
import android.os.Build import android.content.ComponentName
import android.content.pm.PackageManager
import android.os.Bundle import android.os.Bundle
import androidx.lifecycle.lifecycleScope import androidx.lifecycle.lifecycleScope
import androidx.navigation.fragment.findNavController import androidx.navigation.fragment.findNavController
import androidx.preference.Preference import androidx.preference.Preference
import androidx.preference.SwitchPreferenceCompat
import com.google.android.gms.cast.media.CastMediaRouteProviderService
import com.mgoogle.android.gms.R import com.mgoogle.android.gms.R
import org.microg.gms.checkin.CheckinClient
import org.microg.gms.checkin.getCheckinServiceInfo import org.microg.gms.checkin.getCheckinServiceInfo
import org.microg.gms.gcm.GcmDatabase import org.microg.gms.gcm.GcmDatabase
import org.microg.gms.gcm.getGcmServiceInfo import org.microg.gms.gcm.getGcmServiceInfo
import org.microg.tools.ui.ResourceSettingsFragment import org.microg.tools.ui.ResourceSettingsFragment
class SettingsFragment : ResourceSettingsFragment() { class SettingsFragment : ResourceSettingsFragment() {
override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) { override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) {
super.onCreatePreferences(savedInstanceState, rootKey) super.onCreatePreferences(savedInstanceState, rootKey)
findPreference<Preference>(PREF_CHECKIN)!!.onPreferenceClickListener = Preference.OnPreferenceClickListener { findPreference<Preference>(PREF_CHECKIN)?.setOnPreferenceClickListener {
findNavController().navigate(requireContext(), R.id.openCheckinSettings) findNavController().navigate(requireContext(), R.id.openCheckinSettings)
true true
} }
findPreference<Preference>(PREF_GCM)!!.onPreferenceClickListener = Preference.OnPreferenceClickListener { findPreference<Preference>(PREF_GCM)?.setOnPreferenceClickListener {
findNavController().navigate(requireContext(), R.id.openGcmSettings) findNavController().navigate(requireContext(), R.id.openGcmSettings)
true true
} }
findPreference<Preference>(PREF_ABOUT)!!.onPreferenceClickListener = Preference.OnPreferenceClickListener { findPreference<Preference>(PREF_ABOUT)?.setOnPreferenceClickListener {
findNavController().navigate(requireContext(), R.id.openAbout) findNavController().navigate(requireContext(), R.id.openAbout)
true true
} }
findPreference<Preference>(PREF_ABOUT)!!.summary = getString(R.string.about_version_str, AboutFragment.getSelfVersion(context)) findPreference<Preference>(PREF_ABOUT)?.summary = getString(R.string.about_version_str, AboutFragment.getSelfVersion(context))
findPreference<SwitchPreferenceCompat>(PREF_CAST_DOUBLE_FIX_ENABLED)?.setOnPreferenceChangeListener { _, newValue ->
context?.packageManager?.setComponentEnabledSetting(
ComponentName(requireActivity().applicationContext, CastMediaRouteProviderService::class.java),
when (newValue) {
true -> PackageManager.COMPONENT_ENABLED_STATE_DISABLED
else -> PackageManager.COMPONENT_ENABLED_STATE_ENABLED
},
PackageManager.DONT_KILL_APP)
true
}
findPreference<SwitchPreferenceCompat>(BRAND_SPOOF_FIX_ENABLED)!!.onPreferenceChangeListener = Preference.OnPreferenceChangeListener { _, newValue ->
CheckinClient.brandSpoof = newValue as Boolean
true
}
} }
override fun onResume() { override fun onResume() {
@ -43,22 +64,24 @@ class SettingsFragment : ResourceSettingsFragment() {
} }
private suspend fun updateDetails() { private suspend fun updateDetails() {
if (getGcmServiceInfo(requireContext()).configuration.enabled) { findPreference<Preference>(PREF_GCM)?.summary = if (getGcmServiceInfo(requireContext()).configuration.enabled) {
val database = GcmDatabase(context) val database = GcmDatabase(context)
val regCount = database.registrationList.size val regCount = database.registrationList.size
database.close() database.close()
findPreference<Preference>(PREF_GCM)!!.summary = getString(R.string.service_status_enabled_short) + " - " + resources.getQuantityString(R.plurals.gcm_registered_apps_counter, regCount, regCount) getString(R.string.service_status_enabled_short) + " - " + resources.getQuantityString(R.plurals.gcm_registered_apps_counter, regCount, regCount)
} else { } else {
findPreference<Preference>(PREF_GCM)!!.setSummary(R.string.service_status_disabled_short) getString(R.string.service_status_disabled_short)
} }
findPreference<Preference>(PREF_CHECKIN)!!.setSummary(if (getCheckinServiceInfo(requireContext()).configuration.enabled) R.string.service_status_enabled_short else R.string.service_status_disabled_short) findPreference<Preference>(PREF_CHECKIN)?.setSummary(if (getCheckinServiceInfo(requireContext()).configuration.enabled) R.string.service_status_enabled_short else R.string.service_status_disabled_short)
} }
companion object { companion object {
const val PREF_ABOUT = "pref_about" const val PREF_ABOUT = "pref_about"
const val PREF_GCM = "pref_gcm" const val PREF_GCM = "pref_gcm"
const val PREF_CHECKIN = "pref_checkin" const val PREF_CHECKIN = "pref_checkin"
const val PREF_CAST_DOUBLE_FIX_ENABLED = "pref_cast_double_fix_enabled"
const val BRAND_SPOOF_FIX_ENABLED = "brand_spoof_fix_enabled"
} }
init { init {

View File

@ -0,0 +1,15 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:tint="?attr/colorAccent"
android:viewportWidth="58.999"
android:viewportHeight="58.999">
<path android:fillColor="#FF000000" android:pathData="M29.083,26.038c-0.53,0.154 -0.836,0.708 -0.683,1.239c0.027,0.093 2.697,9.591 1.962,30.687c-0.02,0.553 0.412,1.016 0.964,1.034c0.012,0.001 0.024,0.001 0.036,0.001c0.536,0 0.979,-0.425 0.998,-0.965c0.747,-21.414 -1.925,-30.919 -2.038,-31.313C30.169,26.19 29.616,25.888 29.083,26.038z"/>
<path android:fillColor="#FF000000" android:pathData="M54.228,16.479C49.992,6.469 40.232,0 29.362,0c-3.587,0 -7.085,0.701 -10.396,2.083c-1.834,0.765 -3.567,1.675 -5.151,2.704c-0.463,0.302 -0.595,0.921 -0.294,1.384c0.302,0.463 0.922,0.595 1.384,0.294c1.483,-0.964 3.108,-1.817 4.831,-2.536C22.803,2.648 26.041,2 29.362,2c10.064,0 19.102,5.989 23.023,15.259c1.63,3.854 2.511,10.95 2.891,14.838c0.051,0.517 0.485,0.902 0.994,0.902c0.032,0 0.065,-0.002 0.099,-0.005c0.549,-0.054 0.951,-0.543 0.897,-1.093C56.789,27.015 55.875,20.372 54.228,16.479z"/>
<path android:fillColor="#FF000000" android:pathData="M10.851,9.711c0.394,-0.387 0.397,-1.021 0.01,-1.414c-0.387,-0.393 -1.02,-0.397 -1.414,-0.01C4.069,13.585 -1.288,23.438 3.73,40.284c0.129,0.435 0.526,0.715 0.958,0.715c0.094,0 0.19,-0.014 0.285,-0.042c0.529,-0.157 0.831,-0.714 0.673,-1.243C1.899,27.132 3.698,16.758 10.851,9.711z"/>
<path android:fillColor="#FF000000" android:pathData="M30.13,6.014c-3.06,-0.119 -6.038,0.432 -8.853,1.606C11.471,11.711 6.257,22.494 9.15,32.704c0.289,1.021 0.585,2.107 0.744,3.189c0.358,2.449 0.377,6.956 0.377,14.105c0,0.553 0.447,1 1,1s1,-0.447 1,-1c0,-7.458 -0.019,-11.804 -0.398,-14.396c-0.176,-1.202 -0.491,-2.36 -0.799,-3.444c-2.617,-9.236 2.1,-18.992 10.973,-22.693c2.548,-1.063 5.259,-1.546 8.012,-1.454C37.17,8.267 45.23,14.535 47.661,21.7c2.104,6.199 2.122,16.76 1.861,26.271c-0.015,0.552 0.421,1.012 0.973,1.027c0.542,-0.01 1.012,-0.419 1.027,-0.973c0.265,-9.689 0.238,-20.471 -1.967,-26.969C46.838,13.049 38.124,6.3 30.13,6.014z"/>
<path android:fillColor="#FF000000" android:pathData="M29.362,12c-1.087,0 -2.169,0.117 -3.218,0.349c-0.539,0.119 -0.88,0.652 -0.761,1.192c0.119,0.539 0.646,0.873 1.192,0.761c0.907,-0.2 1.845,-0.302 2.786,-0.302c5.233,0 9.933,3.114 11.972,7.935c2.43,5.74 2.589,14.953 2.028,31.029c-0.02,0.552 0.412,1.016 0.964,1.034c0.012,0.001 0.024,0.001 0.036,0.001c0.536,0 0.979,-0.425 0.998,-0.965c0.584,-16.723 0.406,-25.758 -2.185,-31.879C40.823,15.594 35.401,12 29.362,12z"/>
<path android:fillColor="#FF000000" android:pathData="M21.935,16.337c0.452,-0.317 0.562,-0.941 0.244,-1.393c-0.316,-0.452 -0.941,-0.563 -1.393,-0.244c-5.15,3.616 -7.388,10.563 -5.565,17.295c0.021,0.073 2.051,7.462 2.051,19.004c0,0.553 0.447,1 1,1s1,-0.447 1,-1c0,-11.813 -2.038,-19.232 -2.123,-19.535C15.548,25.55 17.472,19.471 21.935,16.337z"/>
<path android:fillColor="#FF000000" android:pathData="M39.272,48.006c0.004,-0.553 -0.44,-1.003 -0.993,-1.007c-0.002,0 -0.005,0 -0.007,0c-0.549,0 -0.996,0.443 -1,0.993c-0.005,0.752 0.02,1.85 0.047,3.036c0.039,1.725 0.083,3.68 0.04,4.937c-0.02,0.552 0.412,1.015 0.965,1.033c0.012,0.001 0.023,0.001 0.035,0.001c0.536,0 0.979,-0.425 0.998,-0.966c0.046,-1.313 0.001,-3.299 -0.039,-5.051C39.291,49.82 39.267,48.743 39.272,48.006z"/>
<path android:fillColor="#FF000000" android:pathData="M29.362,19c-1.062,0 -2.098,0.208 -3.081,0.618c-3.892,1.624 -5.783,6.015 -4.4,10.214c0.754,2.289 1.391,14.272 1.391,26.167c0,0.553 0.447,1 1,1s1,-0.447 1,-1c0,-10.707 -0.57,-23.995 -1.49,-26.792c-1.054,-3.197 0.353,-6.526 3.27,-7.743C27.789,21.156 28.566,21 29.362,21c2.415,0 4.584,1.438 5.529,3.67c1.867,4.419 2.422,12.419 2.558,18.353c0.013,0.544 0.458,0.977 1,0.977c0.007,0 0.016,0 0.023,0c0.552,-0.013 0.989,-0.471 0.977,-1.023c-0.141,-6.106 -0.726,-14.375 -2.72,-19.093C35.475,20.917 32.583,19 29.362,19z"/>
</vector>

View File

@ -88,7 +88,10 @@ Ini bisa berlangsung beberapa menit."</string>
<string name="pref_gcm_confirm_new_apps_summary">Tanya sebelum meregistrasi aplikasi baru untuk menerima notifikasi push</string> <string name="pref_gcm_confirm_new_apps_summary">Tanya sebelum meregistrasi aplikasi baru untuk menerima notifikasi push</string>
<string name="pref_about_title">Tentang Vanced microG</string> <string name="pref_about_title">Tentang Vanced microG</string>
<string name="pref_cast_double_fix"> Perbaikan Cast terduplikasi</string> <string name="pref_cast_double_fix">Perbaikan Cast terduplikasi</string>
<string name="brand_spoof_title">Model topeng</string>
<string name="brand_spoof_fix">Gunakan opsi ini pada perangkat yang tidak memasang layanan Google atau tidak dapat masuk</string>
<string name="pref_switcher_title">Registrasi perangkat</string> <string name="pref_switcher_title">Registrasi perangkat</string>
<string name="pref_checkin_enable_summary">Registrasi perangkat anda ke layanan Google dan buat pengenal perangkat unik. Vanced microG strips mengenal bits selain dari akun Google anda dari data registrasi.</string> <string name="pref_checkin_enable_summary">Registrasi perangkat anda ke layanan Google dan buat pengenal perangkat unik. Vanced microG strips mengenal bits selain dari akun Google anda dari data registrasi.</string>

View File

@ -90,6 +90,9 @@ Questo potrà richiedere un paio di minuti"</string>
<string name="pref_about_title">Informazioni su Vanced microG</string> <string name="pref_about_title">Informazioni su Vanced microG</string>
<string name="pref_cast_double_fix">Correzione cast duplicato</string> <string name="pref_cast_double_fix">Correzione cast duplicato</string>
<string name="brand_spoof_title">Maschera modello</string>
<string name="brand_spoof_fix">Utilizza questa opzione su dispositivi privi di servizi Google installati o non in grado di accedere</string>
<string name="pref_switcher_title">Registra dispositivo</string> <string name="pref_switcher_title">Registra dispositivo</string>
<string name="pref_checkin_enable_summary">Registra il tuo dispositivo sui servizi Google e crea un identificatore univoco del dispositivo. Verranno rimossi dai Servizi Vanced microG alcuni bit utili per identificare i dati di registrazione, oltre al nome dell\'account Google.</string> <string name="pref_checkin_enable_summary">Registra il tuo dispositivo sui servizi Google e crea un identificatore univoco del dispositivo. Verranno rimossi dai Servizi Vanced microG alcuni bit utili per identificare i dati di registrazione, oltre al nome dell\'account Google.</string>
<string name="pref_device_registration_android_id">ID Android</string> <string name="pref_device_registration_android_id">ID Android</string>

View File

@ -104,6 +104,9 @@ This can take a couple of minutes."</string>
<string name="pref_about_title">About Vanced microG</string> <string name="pref_about_title">About Vanced microG</string>
<string name="pref_cast_double_fix">Cast duplication fix</string> <string name="pref_cast_double_fix">Cast duplication fix</string>
<string name="brand_spoof_title">Brand spoofing</string>
<string name="brand_spoof_fix">Use this option on devices without Google services installed or unable to log in</string>
<string name="pref_switcher_title">Register device</string> <string name="pref_switcher_title">Register device</string>
<string name="pref_checkin_enable_summary">Registers your device to Google services and creates a unique device identifier. Vanced microG strips identifying bits other than your Google account name from registration data.</string> <string name="pref_checkin_enable_summary">Registers your device to Google services and creates a unique device identifier. Vanced microG strips identifying bits other than your Google account name from registration data.</string>
<string name="pref_device_registration_android_id">Android ID</string> <string name="pref_device_registration_android_id">Android ID</string>

View File

@ -48,6 +48,12 @@
android:icon="@drawable/ic_cast_black" android:icon="@drawable/ic_cast_black"
android:summary="@string/pref_cast_double_fix_summary" android:summary="@string/pref_cast_double_fix_summary"
android:defaultValue="false"/> android:defaultValue="false"/>
<SwitchPreferenceCompat
android:key="brand_spoof_fix_enabled"
android:title="@string/brand_spoof_title"
android:icon="@drawable/ic_brand_spoof"
android:summary="@string/brand_spoof_fix"
android:defaultValue="false"/>
</PreferenceCategory> </PreferenceCategory>
<PreferenceCategory android:layout="@layout/preference_category_no_label"> <PreferenceCategory android:layout="@layout/preference_category_no_label">
<Preference <Preference