cleanup
This commit is contained in:
parent
d9db4e3667
commit
da40c3c5d6
29 changed files with 238 additions and 502 deletions
|
|
@ -17,12 +17,13 @@
|
|||
package com.google.android.gms.common.data;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.ContentValues;
|
||||
import android.database.Cursor;
|
||||
import android.database.CursorWindow;
|
||||
import android.os.Bundle;
|
||||
import android.os.Parcel;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import org.microg.gms.common.PublicApi;
|
||||
import org.microg.safeparcel.AutoSafeParcelable;
|
||||
import org.microg.safeparcel.SafeParceled;
|
||||
|
|
@ -93,24 +94,12 @@ public class DataHolder extends AutoSafeParcelable implements Closeable {
|
|||
* Get a {@link DataHolder.Builder} to create a new {@link DataHolder} manually.
|
||||
*
|
||||
* @param columns The array of column names that the object supports.
|
||||
* @param uniqueColumn The non-null column name that must contain unique values. New rows added to the builder with the same value in this column will replace any older rows.
|
||||
* @return {@link DataHolder.Builder} object to work with.
|
||||
*/
|
||||
public static Builder builder(String[] columns, String uniqueColumn) {
|
||||
return new Builder(columns, uniqueColumn);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a {@link DataHolder.Builder} to create a new {@link DataHolder} manually.
|
||||
*
|
||||
* @param columns The array of column names that the object supports.
|
||||
* @return {@link DataHolder.Builder} object to work with.
|
||||
*/
|
||||
public static Builder builder(String[] columns) {
|
||||
return builder(columns, null);
|
||||
return new Builder(columns);
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
@SuppressLint({"NewApi", "ObsoleteSdkInt"})
|
||||
static int getCursorType(Cursor cursor, int i) {
|
||||
return cursor.getType(i);
|
||||
|
|
@ -252,6 +241,7 @@ public class DataHolder extends AutoSafeParcelable implements Closeable {
|
|||
return windows[windowIndex].getString(row, columnIndices.get(column));
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public String toString() {
|
||||
return "DataHolder{" +
|
||||
|
|
@ -277,14 +267,10 @@ public class DataHolder extends AutoSafeParcelable implements Closeable {
|
|||
public static class Builder {
|
||||
private final String[] columns;
|
||||
private final ArrayList<Map<String, Object>> rows;
|
||||
private final String uniqueColumn;
|
||||
private final Map<Object, Integer> uniqueIndizes;
|
||||
|
||||
private Builder(String[] columns, String uniqueColumn) {
|
||||
private Builder(String[] columns) {
|
||||
this.columns = columns;
|
||||
this.rows = new ArrayList<>();
|
||||
this.uniqueColumn = uniqueColumn;
|
||||
this.uniqueIndizes = new HashMap<>();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -315,46 +301,6 @@ public class DataHolder extends AutoSafeParcelable implements Closeable {
|
|||
return rows.size();
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a new row of data to the {@link DataHolder} this {@link DataHolder.Builder} will create. Note that the data must contain an entry for all columns
|
||||
* <p/>
|
||||
* Currently the only supported value types that are supported are String, Long, and Boolean (Integer is also accepted and will be stored as a Long).
|
||||
*
|
||||
* @param values {@link ContentValues} containing row data.
|
||||
* @return {@link DataHolder.Builder} to continue construction.
|
||||
*/
|
||||
public Builder withRow(ContentValues values) {
|
||||
HashMap<String, Object> row = new HashMap<>();
|
||||
for (Map.Entry<String, Object> entry : values.valueSet()) {
|
||||
row.put(entry.getKey(), entry.getValue());
|
||||
}
|
||||
return withRow(row);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a new row of data to the {@link DataHolder} this {@link DataHolder.Builder} will create. Note that the data must contain an entry for all columns
|
||||
* <p/>
|
||||
* Currently the only supported value types that are supported are String, Long, and Boolean (Integer is also accepted and will be stored as a Long).
|
||||
*
|
||||
* @param row Map containing row data.
|
||||
* @return {@link DataHolder.Builder} to continue construction.
|
||||
*/
|
||||
public Builder withRow(HashMap<String, Object> row) {
|
||||
if (uniqueColumn != null) {
|
||||
Object val = row.get(uniqueColumn);
|
||||
if (val != null) {
|
||||
Integer old = uniqueIndizes.get(val);
|
||||
if (old != null) {
|
||||
rows.set(old, row);
|
||||
return this;
|
||||
} else {
|
||||
uniqueIndizes.put(val, rows.size());
|
||||
}
|
||||
}
|
||||
}
|
||||
rows.add(row);
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
public static final Creator<DataHolder> CREATOR = new AutoCreator<DataHolder>(DataHolder.class) {
|
||||
|
|
|
|||
|
|
@ -1,39 +0,0 @@
|
|||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package com.google.android.gms.common.data;
|
||||
|
||||
public interface Freezable<T> {
|
||||
/**
|
||||
* Freeze a volatile representation into an immutable representation. Objects returned from
|
||||
* this call are safe to cache.
|
||||
* <p/>
|
||||
* Note that the output of {@link #freeze} may not be identical to the parent object, but
|
||||
* should be equal.
|
||||
*
|
||||
* @return A concrete implementation of the data object.
|
||||
*/
|
||||
T freeze();
|
||||
|
||||
/**
|
||||
* Check to see if this object is valid for use. If the object is still volatile, this method
|
||||
* will indicate whether or not the object can be safely used.
|
||||
* The output of a call to {@link #freeze()} will always be valid.
|
||||
*
|
||||
* @return whether or not the object is valid for use.
|
||||
*/
|
||||
boolean isDataValid();
|
||||
}
|
||||
|
|
@ -18,6 +18,8 @@ package com.google.android.gms.common.images;
|
|||
|
||||
import android.net.Uri;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import org.microg.safeparcel.AutoSafeParcelable;
|
||||
import org.microg.safeparcel.SafeParceled;
|
||||
|
||||
|
|
@ -58,7 +60,9 @@ public class WebImage extends AutoSafeParcelable {
|
|||
return height;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
public String toString() {
|
||||
return String.format(Locale.getDefault(), "Image %dx%d %s", width, height, uri.toString());
|
||||
assert uri != null;
|
||||
return String.format(Locale.getDefault(), "Image %dx%d %s", width, height, uri);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,14 +16,11 @@
|
|||
|
||||
package org.microg.gms;
|
||||
|
||||
import android.accounts.Account;
|
||||
import android.os.Bundle;
|
||||
import android.os.IBinder;
|
||||
import android.os.Parcel;
|
||||
import android.os.RemoteException;
|
||||
import android.util.Log;
|
||||
|
||||
import com.google.android.gms.common.api.Scope;
|
||||
import com.google.android.gms.common.internal.GetServiceRequest;
|
||||
import com.google.android.gms.common.internal.IGmsCallbacks;
|
||||
import com.google.android.gms.common.internal.IGmsServiceBroker;
|
||||
|
|
@ -59,37 +56,24 @@ public abstract class AbstractGmsServiceBroker extends IGmsServiceBroker.Stub {
|
|||
@Override
|
||||
public void getAddressService(IGmsCallbacks callback, int versionCode, String packageName)
|
||||
throws RemoteException {
|
||||
callGetService(GmsService.ADDRESS, callback, versionCode, packageName);
|
||||
callGetService(callback, versionCode, packageName);
|
||||
}
|
||||
|
||||
private void callGetService(GmsService service, IGmsCallbacks callback, int gmsVersion,
|
||||
private void callGetService(IGmsCallbacks callback, int gmsVersion,
|
||||
String packageName) throws RemoteException {
|
||||
callGetService(service, callback, gmsVersion, packageName, null);
|
||||
callGetService(GmsService.ADDRESS, callback, gmsVersion, packageName, null);
|
||||
}
|
||||
|
||||
private void callGetService(GmsService service, IGmsCallbacks callback, int gmsVersion,
|
||||
String packageName, Bundle extras) throws RemoteException {
|
||||
callGetService(service, callback, gmsVersion, packageName, extras, null, null);
|
||||
}
|
||||
|
||||
private void callGetService(GmsService service, IGmsCallbacks callback, int gmsVersion, String packageName, Bundle extras, String accountName, String[] scopes) throws RemoteException {
|
||||
private void callGetService(GmsService service, IGmsCallbacks callback, int gmsVersion, String packageName, Bundle extras) throws RemoteException {
|
||||
GetServiceRequest request = new GetServiceRequest(service.SERVICE_ID);
|
||||
request.gmsVersion = gmsVersion;
|
||||
request.packageName = packageName;
|
||||
request.extras = extras;
|
||||
request.account = accountName == null ? null : new Account(accountName, "com.mgoogle");
|
||||
request.scopes = scopes == null ? null : scopesFromStringArray(scopes);
|
||||
request.account = null;
|
||||
request.scopes = null;
|
||||
getService(callback, request);
|
||||
}
|
||||
|
||||
private Scope[] scopesFromStringArray(String[] arr) {
|
||||
Scope[] scopes = new Scope[arr.length];
|
||||
for (int i = 0; i < arr.length; i++) {
|
||||
scopes[i] = new Scope(arr[i]);
|
||||
}
|
||||
return scopes;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getService(IGmsCallbacks callback, GetServiceRequest request) throws RemoteException {
|
||||
GmsService gmsService = GmsService.byServiceId(request.serviceId);
|
||||
|
|
@ -104,7 +88,7 @@ public abstract class AbstractGmsServiceBroker extends IGmsServiceBroker.Stub {
|
|||
public abstract void handleServiceRequest(IGmsCallbacks callback, GetServiceRequest request, GmsService service) throws RemoteException;
|
||||
|
||||
@Override
|
||||
public void validateAccount(IGmsCallbacks callback, ValidateAccountRequest request) throws RemoteException {
|
||||
public void validateAccount(IGmsCallbacks callback, ValidateAccountRequest request) {
|
||||
throw new IllegalArgumentException("ValidateAccountRequest not supported");
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@ import android.os.IBinder;
|
|||
import android.os.RemoteException;
|
||||
import android.util.Log;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.lifecycle.LifecycleService;
|
||||
|
||||
import com.google.android.gms.common.internal.GetServiceRequest;
|
||||
|
|
@ -58,7 +59,7 @@ public abstract class BaseService extends LifecycleService {
|
|||
}
|
||||
|
||||
@Override
|
||||
public IBinder onBind(Intent intent) {
|
||||
public IBinder onBind(@NonNull Intent intent) {
|
||||
super.onBind(intent);
|
||||
Log.d(TAG, "onBind: " + intent);
|
||||
return broker.asBinder();
|
||||
|
|
|
|||
|
|
@ -5,8 +5,6 @@
|
|||
|
||||
package org.microg.gms.profile
|
||||
|
||||
import android.annotation.TargetApi
|
||||
|
||||
object Build {
|
||||
@JvmField
|
||||
var BOARD: String? = null
|
||||
|
|
@ -24,7 +22,6 @@ object Build {
|
|||
var CPU_ABI2: String? = null
|
||||
|
||||
@JvmField
|
||||
@TargetApi(21)
|
||||
var SUPPORTED_ABIS: Array<String> = emptyArray()
|
||||
|
||||
@JvmField
|
||||
|
|
|
|||
|
|
@ -32,7 +32,11 @@ object ProfileManager {
|
|||
private fun getSystemProfileFile(): File = File("/system/etc/microg_device_profile.xml")
|
||||
private fun getProfileResId(context: Context, profile: String) = context.resources.getIdentifier("${context.packageName}:xml/profile_$profile".lowercase(Locale.US), null, null)
|
||||
|
||||
fun getConfiguredProfile(context: Context): String = SettingsContract.getSettings(context, Profile.getContentUri(context), arrayOf(Profile.PROFILE)) { it.getString(0) } ?: PROFILE_AUTO
|
||||
fun getConfiguredProfile(context: Context): String = Profile.getContentUri(context)?.let {
|
||||
SettingsContract.getSettings(context,
|
||||
it, arrayOf(Profile.PROFILE)) { it.getString(0) }
|
||||
}
|
||||
?: PROFILE_AUTO
|
||||
|
||||
fun getAutoProfile(context: Context): String {
|
||||
if (hasProfile(context, PROFILE_SYSTEM) && isAutoProfile(context, PROFILE_SYSTEM)) return PROFILE_SYSTEM
|
||||
|
|
@ -115,8 +119,14 @@ object ProfileManager {
|
|||
}
|
||||
|
||||
private fun getProfile(context: Context) = getConfiguredProfile(context).let { if (it != PROFILE_AUTO) it else getAutoProfile(context) }
|
||||
private fun getSerialFromSettings(context: Context): String? = SettingsContract.getSettings(context, Profile.getContentUri(context), arrayOf(Profile.SERIAL)) { it.getString(0) }
|
||||
private fun saveSerial(context: Context, serial: String) = SettingsContract.setSettings(context, Profile.getContentUri(context)) { put(Profile.SERIAL, serial) }
|
||||
private fun getSerialFromSettings(context: Context): String? =
|
||||
Profile.getContentUri(context)?.let {
|
||||
SettingsContract.getSettings(context,
|
||||
it, arrayOf(Profile.SERIAL)) { it.getString(0) }
|
||||
}
|
||||
private fun saveSerial(context: Context, serial: String) =
|
||||
Profile.getContentUri(context)
|
||||
?.let { SettingsContract.setSettings(context, it) { put(Profile.SERIAL, serial) } }
|
||||
|
||||
private fun randomSerial(template: String, prefixLength: Int = (template.length / 2).coerceAtMost(6)): String {
|
||||
val serial = StringBuilder()
|
||||
|
|
@ -294,9 +304,11 @@ object ProfileManager {
|
|||
val changed = getProfile(context) != profile
|
||||
val newProfile = profile ?: PROFILE_AUTO
|
||||
val newSerial = if (changed) getSerial(context, newProfile, true) else getSerial(context)
|
||||
SettingsContract.setSettings(context, Profile.getContentUri(context)) {
|
||||
put(Profile.PROFILE, newProfile)
|
||||
if (changed) put(Profile.SERIAL, newSerial)
|
||||
Profile.getContentUri(context)?.let {
|
||||
SettingsContract.setSettings(context, it) {
|
||||
put(Profile.PROFILE, newProfile)
|
||||
if (changed) put(Profile.SERIAL, newSerial)
|
||||
}
|
||||
}
|
||||
if (changed && activeProfile != null) applyProfile(context, newProfile, newSerial)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,8 +12,7 @@ object SettingsContract {
|
|||
|
||||
object CheckIn {
|
||||
private const val id = "check-in"
|
||||
fun getContentUri(context: Context) = Uri.withAppendedPath(getAuthorityUri(context), id)
|
||||
fun getContentType(context: Context) = "vnd.android.cursor.item/vnd.${getAuthority(context)}.$id"
|
||||
fun getContentUri(context: Context): Uri? = Uri.withAppendedPath(getAuthorityUri(context), id)
|
||||
|
||||
const val ENABLED = "checkin_enable_service"
|
||||
const val ANDROID_ID = "androidId"
|
||||
|
|
@ -44,8 +43,7 @@ object SettingsContract {
|
|||
|
||||
object Gcm {
|
||||
private const val id = "gcm"
|
||||
fun getContentUri(context: Context) = Uri.withAppendedPath(getAuthorityUri(context), id)
|
||||
fun getContentType(context: Context) = "vnd.android.cursor.item/vnd.${getAuthority(context)}.$id"
|
||||
fun getContentUri(context: Context): Uri? = Uri.withAppendedPath(getAuthorityUri(context), id)
|
||||
|
||||
const val FULL_LOG = "gcm_full_log"
|
||||
const val LAST_PERSISTENT_ID = "gcm_last_persistent_id"
|
||||
|
|
@ -76,8 +74,7 @@ object SettingsContract {
|
|||
|
||||
object Auth {
|
||||
private const val id = "auth"
|
||||
fun getContentUri(context: Context) = Uri.withAppendedPath(getAuthorityUri(context), id)
|
||||
fun getContentType(context: Context) = "vnd.android.cursor.item/vnd.${getAuthority(context)}.$id"
|
||||
fun getContentUri(context: Context): Uri? = Uri.withAppendedPath(getAuthorityUri(context), id)
|
||||
|
||||
const val TRUST_GOOGLE = "auth_manager_trust_google"
|
||||
const val VISIBLE = "auth_manager_visible"
|
||||
|
|
@ -90,8 +87,7 @@ object SettingsContract {
|
|||
|
||||
object Profile {
|
||||
private const val id = "profile"
|
||||
fun getContentUri(context: Context) = Uri.withAppendedPath(getAuthorityUri(context), id)
|
||||
fun getContentType(context: Context) = "vnd.android.cursor.item/vnd.${getAuthority(context)}.$id"
|
||||
fun getContentUri(context: Context): Uri? = Uri.withAppendedPath(getAuthorityUri(context), id)
|
||||
|
||||
const val PROFILE = "device_profile"
|
||||
const val SERIAL = "device_profile_serial"
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@
|
|||
|
||||
package org.microg.mgms.settings
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.content.ContentProvider
|
||||
import android.content.ContentValues
|
||||
import android.content.Context
|
||||
|
|
@ -27,6 +28,7 @@ import java.io.File
|
|||
* All settings access should go through this [ContentProvider],
|
||||
* because it provides safe access from different processes which normal [SharedPreferences] don't.
|
||||
*/
|
||||
@SuppressLint("DiscouragedPrivateApi")
|
||||
class SettingsProvider : ContentProvider() {
|
||||
companion object {
|
||||
const val INTERVAL = 1 * 60 * 1000 // 1 minute
|
||||
|
|
@ -165,9 +167,9 @@ class SettingsProvider : ContentProvider() {
|
|||
Gcm.NETWORK_ROAMING -> Integer.parseInt(preferences.getString(key, "0") ?: "0")
|
||||
Gcm.NETWORK_OTHER -> Integer.parseInt(preferences.getString(key, "0") ?: "0")
|
||||
|
||||
Gcm.LEARNT_MOBILE -> preferences.getInt(key, Companion.INTERVAL)
|
||||
Gcm.LEARNT_WIFI -> preferences.getInt(key, Companion.INTERVAL)
|
||||
Gcm.LEARNT_OTHER -> preferences.getInt(key, Companion.INTERVAL)
|
||||
Gcm.LEARNT_MOBILE -> preferences.getInt(key, INTERVAL)
|
||||
Gcm.LEARNT_WIFI -> preferences.getInt(key, INTERVAL)
|
||||
Gcm.LEARNT_OTHER -> preferences.getInt(key, INTERVAL)
|
||||
|
||||
else -> throw IllegalArgumentException("Unknown key: $key")
|
||||
}
|
||||
|
|
@ -271,12 +273,8 @@ class SettingsProvider : ContentProvider() {
|
|||
}
|
||||
|
||||
private fun getSettingsString(key: String, def: String? = null): String? = listOf(preferences, systemDefaultPreferences).getString(key, def)
|
||||
private fun getSettingsInt(key: String, def: Int): Int = listOf(preferences, systemDefaultPreferences).getInt(key, def)
|
||||
private fun getSettingsLong(key: String, def: Long): Long = listOf(preferences, systemDefaultPreferences).getLong(key, def)
|
||||
|
||||
private fun List<SharedPreferences?>.getString(key: String, def: String?): String? = foldRight(def) { preferences, defValue -> preferences?.getString(key, defValue) ?: defValue }
|
||||
private fun List<SharedPreferences?>.getInt(key: String, def: Int): Int = foldRight(def) { preferences, defValue -> preferences?.getInt(key, defValue) ?: defValue }
|
||||
private fun List<SharedPreferences?>.getLong(key: String, def: Long): Long = foldRight(def) { preferences, defValue -> preferences?.getLong(key, defValue) ?: defValue }
|
||||
private fun List<SharedPreferences?>.getBoolean(key: String, def: Boolean): Boolean = foldRight(def) { preferences, defValue -> preferences?.getBoolean(key, defValue) ?: defValue }
|
||||
private fun List<SharedPreferences?>.getBooleanAsInt(key: String, def: Boolean): Int = if (getBoolean(key, def)) 1 else 0
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,7 +18,6 @@ package com.google.android.gms.common;
|
|||
|
||||
import android.app.Activity;
|
||||
import android.app.PendingIntent;
|
||||
import android.content.Intent;
|
||||
import android.content.IntentSender;
|
||||
import android.text.TextUtils;
|
||||
|
||||
|
|
@ -239,35 +238,6 @@ public class ConnectionResult {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicates the type of error that interrupted connection.
|
||||
*
|
||||
* @return the error code, or {@link #SUCCESS} if no error occurred.
|
||||
*/
|
||||
public int getErrorCode() {
|
||||
return statusCode;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an error message for connection result.
|
||||
*
|
||||
* @return the message
|
||||
*/
|
||||
public String getErrorMessage() {
|
||||
return message;
|
||||
}
|
||||
|
||||
/**
|
||||
* A pending intent to resolve the connection failure. This intent can be started with
|
||||
* {@link Activity#startIntentSenderForResult(IntentSender, int, Intent, int, int, int)} to
|
||||
* present UI to solve the issue.
|
||||
*
|
||||
* @return The pending intent to resolve the connection failure.
|
||||
*/
|
||||
public PendingIntent getResolution() {
|
||||
return pendingIntent;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Arrays.hashCode(new Object[]{statusCode, pendingIntent, message});
|
||||
|
|
@ -283,15 +253,6 @@ public class ConnectionResult {
|
|||
return statusCode != 0 && pendingIntent != null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns {@code true} if the connection was successful.
|
||||
*
|
||||
* @return {@code true} if the connection was successful, {@code false} if there was an error.
|
||||
*/
|
||||
public boolean isSuccess() {
|
||||
return statusCode == 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Resolves an error by starting any intents requiring user interaction. See
|
||||
* {@link #SIGN_IN_REQUIRED}, and {@link #RESOLUTION_REQUIRED}.
|
||||
|
|
|
|||
|
|
@ -1,22 +0,0 @@
|
|||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package com.google.android.gms.common;
|
||||
|
||||
public class Scopes {
|
||||
public static final String PROFILE = "profile";
|
||||
public static final String APP_STATE = "https://www.googleapis.com/auth/appstate";
|
||||
}
|
||||
|
|
@ -16,13 +16,10 @@
|
|||
|
||||
package com.google.android.gms.common.api;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import org.microg.gms.common.PublicApi;
|
||||
|
||||
@PublicApi
|
||||
public class CommonStatusCodes {
|
||||
public static final int SUCCESS_CACHE = -1;
|
||||
public static final int SUCCESS = 0;
|
||||
@Deprecated
|
||||
public static final int SERVICE_MISSING = 1;
|
||||
|
|
@ -31,61 +28,10 @@ public class CommonStatusCodes {
|
|||
@Deprecated
|
||||
public static final int SERVICE_DISABLED = 3;
|
||||
public static final int SIGN_IN_REQUIRED = 4;
|
||||
public static final int INVALID_ACCOUNT = 5;
|
||||
public static final int RESOLUTION_REQUIRED = 6;
|
||||
public static final int NETWORK_ERROR = 7;
|
||||
public static final int INTERNAL_ERROR = 8;
|
||||
public static final int SERVICE_INVALID = 9;
|
||||
public static final int DEVELOPER_ERROR = 10;
|
||||
public static final int LICENSE_CHECK_FAILED = 11;
|
||||
public static final int ERROR = 13;
|
||||
public static final int INTERRUPTED = 14;
|
||||
public static final int TIMEOUT = 15;
|
||||
public static final int CANCELED = 16;
|
||||
public static final int API_NOT_CONNECTED = 17;
|
||||
public static final int DEAD_CLIENT = 18;
|
||||
|
||||
@NonNull
|
||||
public static String getStatusCodeString(int statusCode) {
|
||||
switch (statusCode) {
|
||||
case SUCCESS_CACHE:
|
||||
return "SUCCESS_CACHE";
|
||||
case SUCCESS:
|
||||
return "SUCCESS";
|
||||
case SERVICE_VERSION_UPDATE_REQUIRED:
|
||||
return "SERVICE_VERSION_UPDATE_REQUIRED";
|
||||
case SERVICE_DISABLED:
|
||||
return "SERVICE_DISABLED";
|
||||
case SIGN_IN_REQUIRED:
|
||||
return "SIGN_IN_REQUIRED";
|
||||
case INVALID_ACCOUNT:
|
||||
return "INVALID_ACCOUNT";
|
||||
case RESOLUTION_REQUIRED:
|
||||
return "RESOLUTION_REQUIRED";
|
||||
case NETWORK_ERROR:
|
||||
return "NETWORK_ERROR";
|
||||
case INTERNAL_ERROR:
|
||||
return "INTERNAL_ERROR";
|
||||
case SERVICE_INVALID:
|
||||
return "SERVICE_INVALID";
|
||||
case DEVELOPER_ERROR:
|
||||
return "DEVELOPER_ERROR";
|
||||
case LICENSE_CHECK_FAILED:
|
||||
return "LICENSE_CHECK_FAILED";
|
||||
case ERROR:
|
||||
return "ERROR";
|
||||
case INTERRUPTED:
|
||||
return "INTERRUPTED";
|
||||
case TIMEOUT:
|
||||
return "TIMEOUT";
|
||||
case CANCELED:
|
||||
return "CANCELED";
|
||||
case API_NOT_CONNECTED:
|
||||
return "API_NOT_CONNECTED";
|
||||
case DEAD_CLIENT:
|
||||
return "DEAD_CLIENT";
|
||||
default:
|
||||
return "unknown status code: " + statusCode;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,6 +16,8 @@
|
|||
|
||||
package com.google.android.gms.common.api;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import org.microg.gms.common.PublicApi;
|
||||
import org.microg.safeparcel.AutoSafeParcelable;
|
||||
import org.microg.safeparcel.SafeParceled;
|
||||
|
|
@ -44,20 +46,22 @@ public class Scope extends AutoSafeParcelable {
|
|||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
return this == o || o instanceof Scope && scopeUri.equals(((Scope) o).scopeUri);
|
||||
}
|
||||
|
||||
public String getScopeUri() {
|
||||
return scopeUri;
|
||||
if (this == o) return true;
|
||||
if (!(o instanceof Scope)) return false;
|
||||
assert scopeUri != null;
|
||||
return scopeUri.equals(((Scope) o).scopeUri);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
assert scopeUri != null;
|
||||
return scopeUri.hashCode();
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public String toString() {
|
||||
assert scopeUri != null;
|
||||
return scopeUri;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -16,11 +16,7 @@
|
|||
|
||||
package com.google.android.gms.common.api;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.PendingIntent;
|
||||
import android.content.Intent;
|
||||
import android.content.IntentSender;
|
||||
import android.content.IntentSender.SendIntentException;
|
||||
|
||||
import org.microg.gms.common.PublicApi;
|
||||
import org.microg.safeparcel.AutoSafeParcelable;
|
||||
|
|
@ -44,16 +40,8 @@ public final class Status extends AutoSafeParcelable implements Result {
|
|||
@SafeParceled(1)
|
||||
private final int statusCode;
|
||||
|
||||
@SafeParceled(2)
|
||||
private final String statusMessage;
|
||||
|
||||
@SafeParceled(3)
|
||||
private final PendingIntent resolution;
|
||||
|
||||
private Status() {
|
||||
statusCode = 0;
|
||||
statusMessage = null;
|
||||
resolution = null;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -84,19 +72,6 @@ public final class Status extends AutoSafeParcelable implements Result {
|
|||
*/
|
||||
public Status(int statusCode, String statusMessage, PendingIntent resolution) {
|
||||
this.statusCode = statusCode;
|
||||
this.statusMessage = statusMessage;
|
||||
this.resolution = resolution;
|
||||
}
|
||||
|
||||
/**
|
||||
* A pending intent to resolve the failure. This intent can be started with
|
||||
* {@link Activity#startIntentSenderForResult(IntentSender, int, Intent, int, int, int)} to
|
||||
* present UI to solve the issue.
|
||||
*
|
||||
* @return The pending intent to resolve the failure.
|
||||
*/
|
||||
public PendingIntent getResolution() {
|
||||
return resolution;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -111,30 +86,6 @@ public final class Status extends AutoSafeParcelable implements Result {
|
|||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicates the status of the operation.
|
||||
*
|
||||
* @return Status code resulting from the operation. The value is one of the constants in
|
||||
* {@link CommonStatusCodes} or specific to the APIs added to the GoogleApiClient.
|
||||
*/
|
||||
public int getStatusCode() {
|
||||
return statusCode;
|
||||
}
|
||||
|
||||
public String getStatusMessage() {
|
||||
return statusMessage;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if calling {@link #startResolutionForResult(Activity, int)} will start any
|
||||
* intents requiring user interaction.
|
||||
*
|
||||
* @return true if there is a resolution that can be started.
|
||||
*/
|
||||
public boolean hasResolution() {
|
||||
return resolution != null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the operation was canceled.
|
||||
*/
|
||||
|
|
@ -142,39 +93,5 @@ public final class Status extends AutoSafeParcelable implements Result {
|
|||
return statusCode == CommonStatusCodes.CANCELED;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the operation was interrupted.
|
||||
*/
|
||||
public boolean isInterrupted() {
|
||||
return statusCode == CommonStatusCodes.INTERRUPTED;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the operation was successful.
|
||||
*
|
||||
* @return true if the operation was successful, false if there was an error.
|
||||
*/
|
||||
public boolean isSuccess() {
|
||||
return statusCode <= 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Resolves an error by starting any intents requiring user interaction. See
|
||||
* {@link CommonStatusCodes#SIGN_IN_REQUIRED}, and {@link CommonStatusCodes#RESOLUTION_REQUIRED}.
|
||||
*
|
||||
* @param activity An Activity context to use to resolve the issue. The activity's
|
||||
* onActivityResult method will be invoked after the user is done. If the
|
||||
* resultCode is {@link Activity#RESULT_OK}, the application should try to
|
||||
* connect again.
|
||||
* @param requestCode The request code to pass to onActivityResult.
|
||||
* @throws SendIntentException If the resolution intent has been canceled or is no longer able
|
||||
* to execute the request.
|
||||
*/
|
||||
public void startResolutionForResult(Activity activity, int requestCode) throws SendIntentException {
|
||||
if (hasResolution()) {
|
||||
activity.startIntentSenderForResult(resolution.getIntentSender(), requestCode, null, 0, 0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
public static final Creator<Status> CREATOR = new AutoCreator<>(Status.class);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ public class ObjectWrapper<T> extends IObjectWrapper.Stub {
|
|||
return null;
|
||||
}
|
||||
if (obj instanceof ObjectWrapper) {
|
||||
return ((ObjectWrapper) obj).t;
|
||||
return ((ObjectWrapper<?>) obj).t;
|
||||
}
|
||||
IBinder binder = obj.asBinder();
|
||||
Field[] fields = binder.getClass().getDeclaredFields();
|
||||
|
|
@ -95,6 +95,6 @@ public class ObjectWrapper<T> extends IObjectWrapper.Stub {
|
|||
}
|
||||
|
||||
public static <T> ObjectWrapper<T> wrap(T t) {
|
||||
return new ObjectWrapper<T>(t);
|
||||
return new ObjectWrapper<>(t);
|
||||
}
|
||||
}
|
||||
|
|
@ -17,7 +17,6 @@
|
|||
package org.microg.gms.auth;
|
||||
|
||||
public class AuthConstants {
|
||||
public static final String DEFAULT_ACCOUNT = "<<default account>>";
|
||||
public static final String SCOPE_GET_ACCOUNT_ID = "^^_account_id_^^";
|
||||
public static final String PROVIDER_METHOD_GET_ACCOUNTS = "get_accounts";
|
||||
public static final String PROVIDER_METHOD_CLEAR_PASSWORD = "clear_password";
|
||||
|
|
|
|||
|
|
@ -21,7 +21,6 @@ import org.microg.gms.basement.BuildConfig;
|
|||
public class Constants {
|
||||
public static final int GMS_VERSION_CODE = (BuildConfig.VERSION_CODE / 1000) * 1000;
|
||||
public static final String GMS_PACKAGE_NAME = "com.google.android.gms";
|
||||
public static final String GSF_PACKAGE_NAME = "com.mgoogle.android.gsf";
|
||||
public static final String GMS_PACKAGE_SIGNATURE_SHA1 = "38918a453d07199354f8b19af05ec6562ced5788";
|
||||
public static final String GMS_SECONDARY_PACKAGE_SIGNATURE_SHA1 = "bd32424203e0fb25f36b57e5aa356f9bdd1da998";
|
||||
|
||||
|
|
|
|||
|
|
@ -30,9 +30,9 @@ public enum GmsService {
|
|||
IDENTITY_SIGN_IN(212, "com.google.android.gms.auth.api.identity.service.signin.START"),
|
||||
;
|
||||
|
||||
public int SERVICE_ID;
|
||||
public String ACTION;
|
||||
public String[] SECONDARY_ACTIONS;
|
||||
public final int SERVICE_ID;
|
||||
public final String ACTION;
|
||||
public final String[] SECONDARY_ACTIONS;
|
||||
|
||||
GmsService(int serviceId, String... actions) {
|
||||
this.SERVICE_ID = serviceId;
|
||||
|
|
@ -40,11 +40,6 @@ public enum GmsService {
|
|||
this.SECONDARY_ACTIONS = actions;
|
||||
}
|
||||
|
||||
public interface ADVERTISING_ID {
|
||||
// Has no service id
|
||||
String ACTION = "com.google.android.gms.ads.identifier.service.START";
|
||||
}
|
||||
|
||||
public static GmsService byServiceId(int serviceId) {
|
||||
for (GmsService service : values()) {
|
||||
if (service.SERVICE_ID == serviceId) return service;
|
||||
|
|
@ -52,15 +47,6 @@ public enum GmsService {
|
|||
return UNKNOWN;
|
||||
}
|
||||
|
||||
public static GmsService byAction(String action) {
|
||||
for (GmsService service : values()) {
|
||||
for (String serviceAction : service.SECONDARY_ACTIONS) {
|
||||
if (serviceAction.equals(action)) return service;
|
||||
}
|
||||
}
|
||||
return UNKNOWN;
|
||||
}
|
||||
|
||||
public static String nameFromServiceId(int serviceId) {
|
||||
return byServiceId(serviceId).toString(serviceId);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,9 +14,5 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.microg.gms.kotlin
|
||||
package com.google.android.gms.dynamic
|
||||
|
||||
import com.google.android.gms.dynamic.IObjectWrapper
|
||||
import com.google.android.gms.dynamic.ObjectWrapper
|
||||
|
||||
inline fun <reified T> IObjectWrapper?.unwrap(): T? = ObjectWrapper.unwrapTyped(this, T::class.java)
|
||||
|
|
|
|||
|
|
@ -7,16 +7,20 @@ import org.microg.mgms.settings.SettingsContract.Auth
|
|||
object AuthPrefs {
|
||||
|
||||
@JvmStatic
|
||||
fun isTrustGooglePermitted(context: Context): Boolean {
|
||||
return SettingsContract.getSettings(context, Auth.getContentUri(context), arrayOf(Auth.TRUST_GOOGLE)) { c ->
|
||||
c.getInt(0) != 0
|
||||
fun isTrustGooglePermitted(context: Context): Boolean? {
|
||||
return Auth.getContentUri(context)?.let {
|
||||
SettingsContract.getSettings(context, it, arrayOf(Auth.TRUST_GOOGLE)) { c ->
|
||||
c.getInt(0) != 0
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun isAuthVisible(context: Context): Boolean {
|
||||
return SettingsContract.getSettings(context, Auth.getContentUri(context), arrayOf(Auth.VISIBLE)) { c ->
|
||||
c.getInt(0) != 0
|
||||
fun isAuthVisible(context: Context): Boolean? {
|
||||
return Auth.getContentUri(context)?.let {
|
||||
SettingsContract.getSettings(context, it, arrayOf(Auth.VISIBLE)) { c ->
|
||||
c.getInt(0) != 0
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue