Skip to content
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

5.5 #19

Merged
merged 7 commits into from
Jul 18, 2024
Merged

5.5 #19

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified Images/Dark.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Images/Light.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
18 changes: 9 additions & 9 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ buildscript {
ext.appcompatVersion = '1.7.0'
ext.biometricVersion = '1.1.0'
ext.coreVersion = '1.13.1'
ext.fragmentVersion = '1.7.1'
ext.lifecycleVersion = '2.8.1'
ext.fragmentVersion = '1.8.1'
ext.lifecycleVersion = '2.8.3'
ext.loaderVersion = '1.1.0'
ext.materialVersion = '1.12.0'
ext.mediarouterVersion = '1.7.0'
Expand All @@ -22,17 +22,17 @@ buildscript {
ext.recyclerviewVersion = '1.3.2'
ext.webkitVersion = '1.11.0'

ext.coroutineVersion = '1.7.3'
ext.coroutineVersion = '1.8.1'
ext.kotlinVersion = '2.0.0'

ext.cronetVersion = '102.5005.125'
ext.cronetVersion = '119.6045.31'
ext.okhttpVersion = '4.12.0'
ext.slf4jVersion = '1.7.36'
ext.slf4jVersion = '2.0.13'
ext.volleyVersion = '1.2.1'
ext.wearableVersion = '0.1.1'
ext.wireVersion = '4.9.9'
ext.wireVersion = '5.0.0'

ext.androidBuildGradleVersion = '8.3.2'
ext.androidBuildGradleVersion = '8.5.1'

ext.androidBuildVersionTools = '34.0.0'

Expand Down Expand Up @@ -82,8 +82,8 @@ allprojects {
apply plugin: 'idea'

group = 'org.microg.gms'
ext.appVersionName = 5.4
ext.appVersionCode = 242155000
ext.appVersionName = 5.5
ext.appVersionCode = 242632000
ext.baseVersion = ext.appVersionCode.toString()[0..1] + '.' + ext.appVersionCode.toString()[2..3] + '.' + ext.appVersionCode.toString()[4..5]
version = ext.appVersionName+" GMS-"+ext.baseVersion.replaceAll("\\.", "")
ext.isReleaseVersion = false
Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip
networkTimeout=10000
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ public class GoogleSignInOptions extends AutoSafeParcelable {
private String logSessionId;

private GoogleSignInOptions() {
this.scopes = new ArrayList<>();
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@

<!-- UpdateChecker tag controller-->

<string name="github_tag_version">5.4</string>
<string name="github_tag_version">5.5</string>

<!-- Updater strings-->

Expand Down
10 changes: 8 additions & 2 deletions play-services-core/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -449,9 +449,15 @@
android:process=":ui"
android:taskAffinity="org.microg.gms.settings" />

<activity
android:name="org.microg.gms.ui.AccountsFragment$AsActivity"
android:label="@string/pref_account_title"
android:process=":ui"
android:taskAffinity="org.microg.gms.settings" />

<activity
android:name="org.microg.gms.ui.LegacyAccountSettingsActivity"
android:label="@string/privacy_title"
android:label="@string/pref_privacy_title"
android:process=":ui"
android:taskAffinity="org.microg.gms.settings" />

Expand All @@ -476,7 +482,7 @@
android:process=":ui"
android:exported="true"
android:excludeFromRecents="true"
android:targetActivity="org.microg.gms.ui.MainSettingsActivity"
android:targetActivity="org.microg.gms.ui.AccountsFragment$AsActivity"
android:taskAffinity="org.microg.gms.settings">
<intent-filter>
<action android:name="com.google.android.gms.accountsettings.action.VIEW_SETTINGS" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,15 @@ import android.accounts.AccountManager
import android.content.ActivityNotFoundException
import android.content.Intent
import android.graphics.Bitmap
import android.net.Uri
import android.os.Bundle
import android.provider.Settings
import android.util.Log
import android.view.Menu
import android.view.MenuInflater
import android.view.MenuItem
import android.view.View
import android.widget.Toast
import androidx.appcompat.app.AlertDialog
import androidx.core.graphics.drawable.RoundedBitmapDrawableFactory
import androidx.lifecycle.lifecycleScope
import androidx.navigation.fragment.findNavController
import androidx.preference.Preference
import androidx.preference.PreferenceCategory
import androidx.preference.PreferenceFragmentCompat
Expand All @@ -30,6 +27,7 @@ import org.microg.gms.auth.AuthConstants
import org.microg.gms.auth.login.LoginActivity
import org.microg.gms.people.DatabaseHelper
import org.microg.gms.people.PeopleManager
import org.microg.tools.ui.AbstractSettingsActivity

class AccountsFragment : PreferenceFragmentCompat() {

Expand Down Expand Up @@ -82,13 +80,14 @@ class AccountsFragment : PreferenceFragmentCompat() {
}
}

if (photo == null) {
withContext(Dispatchers.IO) {
PeopleManager.getOwnerAvatarBitmap(context, account.name, true)
}?.let { newPreference.icon = getCircleBitmapDrawable(it) }
if (preferenceCategory?.findPreference<Preference>(newPreference.key) == null) {
if (photo == null) {
withContext(Dispatchers.IO) {
PeopleManager.getOwnerAvatarBitmap(context, account.name, true)
}?.let { newPreference.icon = getCircleBitmapDrawable(it) }
}
preferenceCategory?.addPreference(newPreference)
}

preferenceCategory?.addPreference(newPreference)
}
}
}
Expand Down Expand Up @@ -137,7 +136,7 @@ class AccountsFragment : PreferenceFragmentCompat() {
try {
startActivity(Intent(Settings.ACTION_SYNC_SETTINGS))
} catch (activityNotFoundException: ActivityNotFoundException) {
Log.e(TAG, "Failed to launch sync settings", activityNotFoundException)
Log.e(tag, "Failed to launch sync settings", activityNotFoundException)
}
true
}
Expand All @@ -146,29 +145,28 @@ class AccountsFragment : PreferenceFragmentCompat() {
try {
startActivity(Intent(requireContext(), LoginActivity::class.java))
} catch (activityNotFoundException: ActivityNotFoundException) {
Log.e(TAG, "Failed to launch login activity", activityNotFoundException)
Log.e(tag, "Failed to launch login activity", activityNotFoundException)
}
true
}
}

init {
setHasOptionsMenu(true)
}

override fun onCreateOptionsMenu(menu: Menu, inflater: MenuInflater) {
inflater.inflate(R.menu.accounts_menu_item, menu)
super.onCreateOptionsMenu(menu, inflater)
}

override fun onOptionsItemSelected(item: MenuItem): Boolean {
return when (item.itemId) {
R.id.privacy_settings -> {
findNavController().navigate(R.id.privacyFragment)
true
findPreference<Preference>("pref_privacy")?.setOnPreferenceClickListener {
try {
startActivity(Intent(requireContext(), LegacyAccountSettingsActivity::class.java))
} catch (activityNotFoundException: ActivityNotFoundException) {
Log.e(tag, "Failed to launch privacy activity", activityNotFoundException)
}
true
}

else -> super.onOptionsItemSelected(item)
findPreference<Preference>("pref_manage_history")?.setOnPreferenceClickListener {
startActivity(Intent(Intent.ACTION_VIEW, Uri.parse("https://myactivity.google.com/product/youtube")))
true
}

findPreference<Preference>("pref_your_data")?.setOnPreferenceClickListener {
startActivity(Intent(Intent.ACTION_VIEW, Uri.parse("https://myaccount.google.com/yourdata/youtube")))
true
}
}

Expand All @@ -193,4 +191,15 @@ class AccountsFragment : PreferenceFragmentCompat() {
private fun showToast(message: String) {
Toast.makeText(requireContext(), message, Toast.LENGTH_SHORT).show()
}

class AsActivity : AbstractSettingsActivity() {
override fun getFragment(): PreferenceFragmentCompat {
return AccountsFragment()
}

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
supportActionBar?.setDisplayHomeAsUpEnabled(true)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import android.os.Bundle;

import androidx.annotation.Nullable;
import androidx.appcompat.app.ActionBar;
import androidx.fragment.app.Fragment;
import androidx.preference.Preference;

Expand All @@ -38,14 +39,24 @@

public class LegacyAccountSettingsActivity extends AbstractSettingsActivity {

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

ActionBar actionBar = getSupportActionBar();
if (actionBar != null) {
actionBar.setDisplayHomeAsUpEnabled(true);
}
}

@Override
protected Fragment getFragment() {
return new AccountSettingsFragment();
}

public static class AccountSettingsFragment extends ResourceSettingsFragment {
public AccountSettingsFragment() {
preferencesResource = R.xml.preferences_account;
preferencesResource = R.xml.preferences_account;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,12 @@ class AuthSignInServiceImpl(
lifecycleScope.launchWhenStarted {
try {
val account = account ?: options?.account ?: SignInConfigurationService.getDefaultAccount(context, packageName)
if (account != null) performSignOut(context, packageName, options, account)
SignInConfigurationService.setDefaultAccount(context, packageName, null)
if (account != null) {
val defaultOptions = SignInConfigurationService.getDefaultOptions(context, packageName)
Log.d(TAG, "$packageName:signOut defaultOptions:($defaultOptions)")
performSignOut(context, packageName, defaultOptions ?: options, account)
}
SignInConfigurationService.setDefaultSignInInfo(context, packageName, null, null)
runCatching { callbacks.onSignOut(Status.SUCCESS) }
} catch (e: Exception) {
Log.w(TAG, e)
Expand Down Expand Up @@ -137,7 +141,7 @@ class AuthSignInServiceImpl(
authManager.invalidateAuthToken(token)
authManager.isPermitted = false
}
SignInConfigurationService.setDefaultAccount(context, packageName, account)
SignInConfigurationService.setDefaultSignInInfo(context, packageName, account, options?.toJson())
runCatching { callbacks.onRevokeAccess(Status.SUCCESS) }
} catch (e: Exception) {
Log.w(TAG, e)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import android.content.*
import android.os.*
import androidx.core.content.getSystemService
import androidx.core.os.bundleOf
import com.google.android.gms.auth.api.signin.GoogleSignInOptions
import org.microg.gms.auth.AuthConstants
import org.microg.gms.common.PackageUtils
import kotlin.coroutines.resume
Expand All @@ -20,12 +21,15 @@ import kotlin.coroutines.suspendCoroutine

private const val PREFERENCES_NAME = "google_account_cache"
private const val DEFAULT_ACCOUNT_PREFIX = "default_google_account_"
private const val DEFAULT_SIGN_IN_OPTIONS_PREFIX = "default_sign_in_options_"

private const val MSG_GET_DEFAULT_ACCOUNT = 1
private const val MSG_SET_DEFAULT_ACCOUNT = 2
private const val MSG_SET_DEFAULT_SIGN_IN_INFO = 2
private const val MSG_GET_DEFAULT_OPTIONS = 3

private const val MSG_DATA_PACKAGE_NAME = "package_name"
private const val MSG_DATA_ACCOUNT = "account"
private const val MSG_DATA_SIGN_IN_OPTIONS = "google_sign_in_options"

class SignInConfigurationService : Service() {
private val preferences: SharedPreferences
Expand All @@ -46,13 +50,24 @@ class SignInConfigurationService : Service() {
)
}

MSG_SET_DEFAULT_ACCOUNT -> {
MSG_SET_DEFAULT_SIGN_IN_INFO -> {
val packageName = msg.data?.getString(MSG_DATA_PACKAGE_NAME)
val account = msg.data?.getParcelable<Account>(MSG_DATA_ACCOUNT)
packageName?.let { setDefaultAccount(it, account) }
val googleSignInOptions = msg.data?.getString(MSG_DATA_SIGN_IN_OPTIONS)
packageName?.let { setDefaultSignInInfo(it, account, googleSignInOptions) }
bundleOf(
MSG_DATA_PACKAGE_NAME to packageName,
MSG_DATA_ACCOUNT to account
MSG_DATA_ACCOUNT to account,
MSG_DATA_SIGN_IN_OPTIONS to googleSignInOptions,
)
}

MSG_GET_DEFAULT_OPTIONS -> {
val packageName = msg.data?.getString(MSG_DATA_PACKAGE_NAME)
val googleSignInOptions = packageName?.let { getDefaultOptions(it) }
bundleOf(
MSG_DATA_PACKAGE_NAME to packageName,
MSG_DATA_SIGN_IN_OPTIONS to googleSignInOptions
)
}

Expand Down Expand Up @@ -80,13 +95,24 @@ class SignInConfigurationService : Service() {
return null
}

private fun setDefaultAccount(packageName: String, account: Account?) {
private fun getDefaultOptions(packageName: String): String? {
val data = preferences.getString(DEFAULT_SIGN_IN_OPTIONS_PREFIX + getPackageNameSuffix(packageName), null)
if (data.isNullOrBlank()) return null
return data
}

private fun setDefaultSignInInfo(packageName: String, account: Account?, optionsJson: String?) {
val editor: SharedPreferences.Editor = preferences.edit()
if (account == null || account.name == AuthConstants.DEFAULT_ACCOUNT) {
editor.remove(DEFAULT_ACCOUNT_PREFIX + getPackageNameSuffix(packageName))
} else {
editor.putString(DEFAULT_ACCOUNT_PREFIX + getPackageNameSuffix(packageName), account.name)
}
if (optionsJson == null) {
editor.remove(DEFAULT_SIGN_IN_OPTIONS_PREFIX + getPackageNameSuffix(packageName))
} else {
editor.putString(DEFAULT_SIGN_IN_OPTIONS_PREFIX + getPackageNameSuffix(packageName), optionsJson)
}
editor.apply()
}

Expand Down Expand Up @@ -130,12 +156,22 @@ class SignInConfigurationService : Service() {
}).data?.getParcelable(MSG_DATA_ACCOUNT)
}

suspend fun setDefaultAccount(context: Context, packageName: String, account: Account?) {
suspend fun getDefaultOptions(context: Context, packageName: String): GoogleSignInOptions? {
return singleRequest(context, Message.obtain().apply {
what = MSG_GET_DEFAULT_OPTIONS
data = bundleOf(
MSG_DATA_PACKAGE_NAME to packageName
)
}).data?.getString(MSG_DATA_SIGN_IN_OPTIONS)?.let { GoogleSignInOptions.fromJson(it) }
}

suspend fun setDefaultSignInInfo(context: Context, packageName: String, account: Account?, optionsJson: String?) {
singleRequest(context, Message.obtain().apply {
what = MSG_SET_DEFAULT_ACCOUNT
what = MSG_SET_DEFAULT_SIGN_IN_INFO
data = bundleOf(
MSG_DATA_PACKAGE_NAME to packageName,
MSG_DATA_ACCOUNT to account
MSG_DATA_ACCOUNT to account,
MSG_DATA_SIGN_IN_OPTIONS to optionsJson
)
})
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ suspend fun performSignIn(context: Context, packageName: String, options: Google
databaseHelper.close()
}
} else listOf(null, null, null, null)
SignInConfigurationService.setDefaultAccount(context, packageName, account)
SignInConfigurationService.setDefaultSignInInfo(context, packageName, account, options?.toJson())
return GoogleSignInAccount(
id,
tokenId,
Expand Down
Loading
Loading