I've been trying to obtain a unique ID (a GUID, or account name, or
SID, etc...) for the user of the phone.
I immediately spotted the "android.permission.GET_ACCOUNTS" and it
seemed like a good place to start.
The documentation for that permission is the start and end of that
path.
So I started looking at the codebase for GET_ACCOUNTS and how its
used.
Is there a System Service I can use? Nope. None defined in Context
class.
Is there a Accounts service running?
$ adb shell ps
nope.
Is there any hint of an accounts package?
$ adb shell pm list packages
nope.
OK, lets dump the information out of all of the packages, with regards
to services, using the android.content.pm.PackageManager.
Ah, there's a "com.google.android.googleapps.GoogleLoginService" as
part of the "com.google.android.googleapps" package.
I should look at how the Calendar / Contacts / IM apps find out the
account.
Looking at the source repository for /packages/providers/ I see that
there are 3 apps that use the GET_ACCOUNTS permission! Yes, example
code!
/packages/providers/CalendarProvider
/packages/providers/ConteactsProvider
/packages/providers/GoogleContactsProvider
I see in the example code the snippet I need ...
/packages/providers/CalendarProvider/src/com/android/providers/
calendar/CalendarProvider.java
/* -- cut -- */
GoogleLoginServiceBlockingHelper loginHelper = null;
String username = null;
try {
loginHelper = new GoogleLoginServiceBlockingHelper
(getContext());
username = loginHelper.getAccount(false);
if (TextUtils.isEmpty(username)) {
Log.w(TAG, "Unable to update calendars from server --
"
+ "no users configured.");
return;
}
} catch (GoogleLoginServiceNotFoundException e) {
Log.e(TAG, "Could not find Google login service", e);
return;
} finally {
if (loginHelper != null) {
loginHelper.close();
}
}
/* -- cut -- */
OK, that uses a class called
com.google.android.googlelogin.GoogleLoginServiceBlockingHelper, which
isn't part of the SDK. OK. lets find it in our android repository.
There it is -> frameworks/opt/com.google.android.googlelogin/
client.jar
OK. lets load that into our project, setup all of the permissions and
try that code on the emulator.
Crash. the Verifier either doesn't like having the class in the APK if
I let it go into the APK.
Or the Verifier doesn't like having the class referenced, as its not
present in APK.
Sounds like I need to add a <use-library> entry in my
AndroidManifest.xml
But which one?
Dumping the PackageInfo on the shared library stuff from the
ApplicationInfo proves pointless.
And is this path even a viable solution?
A bug found on http://code.google.com/p/android/issues/detail?id=1073
seems to indicate that it is not possible.
But there's been no word from google confirming or denying that bug.
Any help would be greatly appreciated.
- Joakim Erdfelt
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---