diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index a4b52dbb..397b84ee 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -24,6 +24,16 @@
android:minSdkVersion="16"
android:targetSdkVersion="21" />
+
+
+
+
@@ -71,6 +81,12 @@
android:value="com.google.android.location.internal.GMS_NLP" />
+
+
+
authToken = AccountManager.get(context).getAuthToken(new Account(accountName, GOOGLE_ACCOUNT_TYPE), scope, extras, notify, null, new Handler(Looper.getMainLooper()));
+ if (!AuthManager.isPermitted(context, account, packageName, sig, scope)) {
+ Bundle result = new Bundle();
+ result.putString(KEY_ERROR, "Unknown");
+ Intent i = new Intent(context, AskPermissionActivity.class);
+ i.putExtras(extras);
+ i.putExtra(AccountManager.KEY_ANDROID_PACKAGE_NAME, packageName);
+ i.putExtra(AccountManager.KEY_ACCOUNT_TYPE, account.type);
+ i.putExtra(AccountManager.KEY_ACCOUNT_NAME, account.name);
+ i.putExtra(AccountManager.KEY_AUTHTOKEN, scope);
+ result.putParcelable(KEY_USER_RECOVERY_INTENT, i);
+ return result;
+ }
try {
- Account account = new Account(accountName, GOOGLE_ACCOUNT_TYPE);
- String sig = Utils.getFirstPackageSignatureDigest(context, packageName);
AuthResponse response = new AuthRequest().fromContext(context)
.app(packageName, sig)
.callerIsApp()
@@ -80,17 +91,10 @@ public class AuthManagerServiceImpl extends IAuthManagerService.Stub {
.service(scope)
.getResponse();
AuthManager.storeResponse(context, account, packageName, sig, scope, response);
- //Bundle requestResult = authToken.getResult();
- /*if (!requestResult.containsKey(AccountManager.KEY_AUTHTOKEN) && requestResult.containsKey(AccountManager.KEY_INTENT)) {
- Intent intent = requestResult.getParcelable(AccountManager.KEY_INTENT);
- intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
- context.startActivity(intent);
- }*/
Log.d("getToken", response.auth);
Bundle result = new Bundle();
result.putString(KEY_AUTH_TOKEN, response.auth);
result.putString(KEY_ERROR, "Unknown");
- //result.putParcelable(KEY_USER_RECOVERY_INTENT, requestResult.getParcelable(AccountManager.KEY_INTENT));
return result;
} catch (Exception e) {
Log.w("AuthManagerService", e);
@@ -98,6 +102,11 @@ public class AuthManagerServiceImpl extends IAuthManagerService.Stub {
}
}
+ @Override
+ public AccountChangeEventsResponse getChangeEvents(AccountChangeEventsRequest request) {
+ return new AccountChangeEventsResponse();
+ }
+
@Override
public Bundle clearToken(String token, Bundle extras) throws RemoteException {
return null;
diff --git a/src/org/microg/gms/auth/loginservice/GoogleLoginService.java b/src/org/microg/gms/auth/loginservice/GoogleLoginService.java
index 25777068..bfaddde6 100644
--- a/src/org/microg/gms/auth/loginservice/GoogleLoginService.java
+++ b/src/org/microg/gms/auth/loginservice/GoogleLoginService.java
@@ -29,7 +29,7 @@ import android.util.Log;
import com.google.android.gms.R;
-import org.microg.gms.auth.AuthClient;
+import org.microg.gms.auth.AskPermissionActivity;
import org.microg.gms.auth.AuthManager;
import org.microg.gms.auth.AuthRequest;
import org.microg.gms.auth.AuthResponse;
@@ -93,9 +93,9 @@ public class GoogleLoginService extends Service {
@Override
public Bundle hasFeatures(AccountAuthenticatorResponse response, Account account, String[] features) throws NetworkErrorException {
Log.d(TAG, "hasFeatures: " + account + ", " + Arrays.toString(features));
- Bundle b = new Bundle();
- b.putBoolean(AccountManager.KEY_BOOLEAN_RESULT, true);
- return b;
+ Bundle result = new Bundle();
+ result.putBoolean(AccountManager.KEY_BOOLEAN_RESULT, true);
+ return result;
}
}.getIBinder();
}
@@ -108,30 +108,41 @@ public class GoogleLoginService extends Service {
String app = options.getString(AccountManager.KEY_ANDROID_PACKAGE_NAME);
Utils.checkPackage(this, app, options.getInt(AccountManager.KEY_CALLER_UID), options.getInt(AccountManager.KEY_CALLER_UID));
String appSignature = Utils.getFirstPackageSignatureDigest(this, app);
- try {
- AuthRequest request = new AuthRequest().fromContext(this)
- .email(account.name)
- .token(AccountManager.get(this).getPassword(account))
- .service(authTokenType)
- .app(app, appSignature)
- .callerIsGms()
- .calledFromAccountManager();
- if (AuthManager.isPermitted(this, account, app, appSignature, authTokenType)) {
- request.hasPermission();
- }
- AuthResponse r = request.getResponse();
- AuthManager.storeResponse(this, account, app, appSignature, authTokenType, r);
- if (r.expiry == 0)
- Log.d(TAG, "Auth: " + r.auth);
- Bundle bundle = new Bundle();
- bundle.putString(AccountManager.KEY_ACCOUNT_TYPE, account.type);
- bundle.putString(AccountManager.KEY_ACCOUNT_NAME, account.name);
- bundle.putString(AccountManager.KEY_AUTHTOKEN, r.auth);
- return bundle;
- } catch (IOException e) {
- Log.w(TAG, e);
+ if (!AuthManager.isPermitted(this, account, app, appSignature, authTokenType)) {
+ Bundle result = new Bundle();
+ Intent i = new Intent(this, AskPermissionActivity.class);
+ i.putExtras(options);
+ i.putExtra(AccountManager.KEY_ACCOUNT_AUTHENTICATOR_RESPONSE, response);
+ i.putExtra(AccountManager.KEY_ANDROID_PACKAGE_NAME, app);
+ i.putExtra(AccountManager.KEY_ACCOUNT_TYPE, account.type);
+ i.putExtra(AccountManager.KEY_ACCOUNT_NAME, account.name);
+ i.putExtra(AccountManager.KEY_AUTHTOKEN, authTokenType);
+ result.putParcelable(AccountManager.KEY_INTENT, i);
+ return result;
}
- return null;
+ String token = AuthManager.getToken(this, account, app, appSignature, authTokenType);
+ if (token == null) {
+ try {
+ AuthRequest request = new AuthRequest().fromContext(this)
+ .email(account.name)
+ .token(AccountManager.get(this).getPassword(account))
+ .service(authTokenType)
+ .app(app, appSignature)
+ .callerIsGms()
+ .calledFromAccountManager()
+ .hasPermission();
+ AuthResponse r = request.getResponse();
+ AuthManager.storeResponse(this, account, app, appSignature, authTokenType, r);
+ token = r.auth;
+ } catch (IOException e) {
+ Log.w(TAG, e);
+ }
+ }
+ Bundle result = new Bundle();
+ result.putString(AccountManager.KEY_ACCOUNT_TYPE, account.type);
+ result.putString(AccountManager.KEY_ACCOUNT_NAME, account.name);
+ result.putString(AccountManager.KEY_AUTHTOKEN, token);
+ return result;
}
private Bundle addAccount(AccountAuthenticatorResponse response, String authTokenType, String[] requiredFeatures, Bundle options) {
diff --git a/src/org/microg/gms/gservices/GServicesProvider.java b/src/org/microg/gms/gservices/GServicesProvider.java
new file mode 100644
index 00000000..d36fbb33
--- /dev/null
+++ b/src/org/microg/gms/gservices/GServicesProvider.java
@@ -0,0 +1,54 @@
+/*
+ * Copyright 2013-2015 µg 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 org.microg.gms.gservices;
+
+import android.content.ContentProvider;
+import android.content.ContentValues;
+import android.database.Cursor;
+import android.net.Uri;
+
+public class GServicesProvider extends ContentProvider{
+ @Override
+ public boolean onCreate() {
+ return false;
+ }
+
+ @Override
+ public Cursor query(Uri uri, String[] projection, String selection, String[] selectionArgs, String sortOrder) {
+ return null;
+ }
+
+ @Override
+ public String getType(Uri uri) {
+ return null;
+ }
+
+ @Override
+ public Uri insert(Uri uri, ContentValues values) {
+ return null;
+ }
+
+ @Override
+ public int delete(Uri uri, String selection, String[] selectionArgs) {
+ return 0;
+ }
+
+ @Override
+ public int update(Uri uri, ContentValues values, String selection, String[] selectionArgs) {
+ return 0;
+ }
+}