0
0
Fork 0
mirror of https://github.com/YTVanced/VancedMicroG synced 2024-11-28 06:03:00 +00:00

Update for new auth manager

This commit is contained in:
mar-v-in 2015-03-10 00:07:50 +01:00
parent cef1ce27a2
commit 354bdb3173
6 changed files with 268 additions and 21 deletions

View file

@ -18,7 +18,7 @@
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
package="com.google.android.gms" package="com.google.android.gms"
android:versionName="1.0" android:versionName="1.0"
android:versionCode="6599436"> android:versionCode="6772000">
<uses-sdk <uses-sdk
android:minSdkVersion="16" android:minSdkVersion="16"

17
protos-repo/auth.proto Normal file
View file

@ -0,0 +1,17 @@
option java_package = "org.microg.gms.auth";
option java_outer_classname = "AuthProto";
message ConsentData {
message AppDetails {
optional string title = 1;
optional string email = 3;
}
optional AppDetails app = 1;
message ScopeDetails {
optional string title = 1;
optional string description = 2;
optional string id = 6;
}
repeated ScopeDetails scopes = 2;
}

View file

@ -0,0 +1,243 @@
// Code generated by Wire protocol buffer compiler, do not edit.
// Source file: protos-repo/auth.proto
package org.microg.gms.auth;
import com.squareup.wire.Message;
import com.squareup.wire.ProtoField;
import java.util.Collections;
import java.util.List;
import static com.squareup.wire.Message.Datatype.STRING;
import static com.squareup.wire.Message.Label.REPEATED;
public final class ConsentData extends Message {
public static final List<ScopeDetails> DEFAULT_SCOPES = Collections.emptyList();
@ProtoField(tag = 1)
public final AppDetails app;
@ProtoField(tag = 2, label = REPEATED, messageType = ScopeDetails.class)
public final List<ScopeDetails> scopes;
public ConsentData(AppDetails app, List<ScopeDetails> scopes) {
this.app = app;
this.scopes = immutableCopyOf(scopes);
}
private ConsentData(Builder builder) {
this(builder.app, builder.scopes);
setBuilder(builder);
}
@Override
public boolean equals(Object other) {
if (other == this) return true;
if (!(other instanceof ConsentData)) return false;
ConsentData o = (ConsentData) other;
return equals(app, o.app)
&& equals(scopes, o.scopes);
}
@Override
public int hashCode() {
int result = hashCode;
if (result == 0) {
result = app != null ? app.hashCode() : 0;
result = result * 37 + (scopes != null ? scopes.hashCode() : 1);
hashCode = result;
}
return result;
}
public static final class Builder extends Message.Builder<ConsentData> {
public AppDetails app;
public List<ScopeDetails> scopes;
public Builder() {
}
public Builder(ConsentData message) {
super(message);
if (message == null) return;
this.app = message.app;
this.scopes = copyOf(message.scopes);
}
public Builder app(AppDetails app) {
this.app = app;
return this;
}
public Builder scopes(List<ScopeDetails> scopes) {
this.scopes = checkForNulls(scopes);
return this;
}
@Override
public ConsentData build() {
return new ConsentData(this);
}
}
public static final class AppDetails extends Message {
public static final String DEFAULT_TITLE = "";
public static final String DEFAULT_EMAIL = "";
@ProtoField(tag = 1, type = STRING)
public final String title;
@ProtoField(tag = 3, type = STRING)
public final String email;
public AppDetails(String title, String email) {
this.title = title;
this.email = email;
}
private AppDetails(Builder builder) {
this(builder.title, builder.email);
setBuilder(builder);
}
@Override
public boolean equals(Object other) {
if (other == this) return true;
if (!(other instanceof AppDetails)) return false;
AppDetails o = (AppDetails) other;
return equals(title, o.title)
&& equals(email, o.email);
}
@Override
public int hashCode() {
int result = hashCode;
if (result == 0) {
result = title != null ? title.hashCode() : 0;
result = result * 37 + (email != null ? email.hashCode() : 0);
hashCode = result;
}
return result;
}
public static final class Builder extends Message.Builder<AppDetails> {
public String title;
public String email;
public Builder() {
}
public Builder(AppDetails message) {
super(message);
if (message == null) return;
this.title = message.title;
this.email = message.email;
}
public Builder title(String title) {
this.title = title;
return this;
}
public Builder email(String email) {
this.email = email;
return this;
}
@Override
public AppDetails build() {
return new AppDetails(this);
}
}
}
public static final class ScopeDetails extends Message {
public static final String DEFAULT_TITLE = "";
public static final String DEFAULT_DESCRIPTION = "";
public static final String DEFAULT_ID = "";
@ProtoField(tag = 1, type = STRING)
public final String title;
@ProtoField(tag = 2, type = STRING)
public final String description;
@ProtoField(tag = 6, type = STRING)
public final String id;
public ScopeDetails(String title, String description, String id) {
this.title = title;
this.description = description;
this.id = id;
}
private ScopeDetails(Builder builder) {
this(builder.title, builder.description, builder.id);
setBuilder(builder);
}
@Override
public boolean equals(Object other) {
if (other == this) return true;
if (!(other instanceof ScopeDetails)) return false;
ScopeDetails o = (ScopeDetails) other;
return equals(title, o.title)
&& equals(description, o.description)
&& equals(id, o.id);
}
@Override
public int hashCode() {
int result = hashCode;
if (result == 0) {
result = title != null ? title.hashCode() : 0;
result = result * 37 + (description != null ? description.hashCode() : 0);
result = result * 37 + (id != null ? id.hashCode() : 0);
hashCode = result;
}
return result;
}
public static final class Builder extends Message.Builder<ScopeDetails> {
public String title;
public String description;
public String id;
public Builder() {
}
public Builder(ScopeDetails message) {
super(message);
if (message == null) return;
this.title = message.title;
this.description = message.description;
this.id = message.id;
}
public Builder title(String title) {
this.title = title;
return this;
}
public Builder description(String description) {
this.description = description;
return this;
}
public Builder id(String id) {
this.id = id;
return this;
}
@Override
public ScopeDetails build() {
return new ScopeDetails(this);
}
}
}
}

View file

@ -150,7 +150,7 @@
<string name="permission_scope_www.googleapis.com_auth_latitude.current.city">Manage your city-level location</string> <string name="permission_scope_www.googleapis.com_auth_latitude.current.city">Manage your city-level location</string>
<string name="permission_scope_www.googleapis.com_auth_mapsengine">provides read and write access to the user\'s Maps Engine data from your application.</string> <string name="permission_scope_www.googleapis.com_auth_mapsengine">provides read and write access to the user\'s Maps Engine data from your application.</string>
<string name="permission_scope_www.googleapis.com_auth_mapsengine.readonly">provides read-only access to the user\'s Maps Engine data from your</string> <string name="permission_scope_www.googleapis.com_auth_mapsengine.readonly">provides read-only access to the user\'s Maps Engine data from your</string>
<string name="permission_scope_www.googleapis.com_auth_mobilemaps.firstparty">Full access to your Google Maps account</string> <string name="permission_scope_www.googleapis.com_auth_mobilemaps.firstparty">View and manage your Google Maps for mobile experience</string>
<string name="permission_scope_www.googleapis.com_auth_orkut">Manage your Orkut activity</string> <string name="permission_scope_www.googleapis.com_auth_orkut">Manage your Orkut activity</string>
<string name="permission_scope_www.googleapis.com_auth_orkut.readonly">View your Orkut data</string> <string name="permission_scope_www.googleapis.com_auth_orkut.readonly">View your Orkut data</string>
<string name="permission_scope_www.googleapis.com_auth_plus.login">Know your name, basic info, and list of people you\'re connected to on Google+</string> <string name="permission_scope_www.googleapis.com_auth_plus.login">Know your name, basic info, and list of people you\'re connected to on Google+</string>

View file

@ -43,8 +43,7 @@ public class CheckinManager {
List<CheckinClient.Account> accounts = new ArrayList<>(); List<CheckinClient.Account> accounts = new ArrayList<>();
AccountManager accountManager = AccountManager.get(context); AccountManager accountManager = AccountManager.get(context);
for (Account account : accountManager.getAccountsByType("com.google")) { for (Account account : accountManager.getAccountsByType("com.google")) {
String token = AuthManager.getToken(context, account, Constants.GMS_PACKAGE_NAME, String token = new AuthManager(context, account.name, Constants.GMS_PACKAGE_NAME, "ac2dm").getAuthToken();
Constants.GMS_PACKAGE_SIGNATURE_SHA1, "ac2dm");
accounts.add(new CheckinClient.Account(account.name, token)); accounts.add(new CheckinClient.Account(account.name, token));
} }
CheckinRequest request = CheckinRequest request =

View file

@ -91,28 +91,16 @@ public class PeopleManager {
} }
} }
public static AuthRequest getUserInfoAuthKeyRequest(Context context, Account account) {
return new AuthRequest().fromContext(context)
.appIsGms().callerIsGms()
.service(USERINFO_SCOPE)
.email(account.name)
.token(AccountManager.get(context).getPassword(account))
.systemPartition()
.hasPermission()
.getAccountId();
}
public static String getUserInfoAuthKey(Context context, Account account) { public static String getUserInfoAuthKey(Context context, Account account) {
String result = AuthManager.getToken(context, account, Constants.GMS_PACKAGE_NAME, Constants.GMS_PACKAGE_SIGNATURE_SHA1, AuthManager authManager = new AuthManager(context, account.name, Constants.GMS_PACKAGE_NAME, USERINFO_SCOPE);
USERINFO_SCOPE); authManager.setPermitted(true);
String result = authManager.getAuthToken();
if (result == null) { if (result == null) {
try { try {
AuthResponse response = getUserInfoAuthKeyRequest(context, account).getResponse(); AuthResponse response = authManager.requestAuth(false);
AuthManager.storeResponse(context, account,
Constants.GMS_PACKAGE_NAME, Constants.GMS_PACKAGE_SIGNATURE_SHA1,
USERINFO_SCOPE, response);
result = response.auth; result = response.auth;
} catch (IOException e) { } catch (IOException e) {
Log.w(TAG, e);
return null; return null;
} }
} }