Merge change 21432 into eclair

* changes:
  do not merge: cherrypicked 3710f39096 from master branch
This commit is contained in:
Android (Google) Code Review
2009-08-16 17:14:20 -07:00
26 changed files with 872 additions and 1286 deletions

View File

@@ -13463,6 +13463,23 @@
<parameter name="accountType" type="java.lang.String"> <parameter name="accountType" type="java.lang.String">
</parameter> </parameter>
</method> </method>
<method name="getAccountRemovalAllowed"
return="android.os.Bundle"
abstract="false"
native="false"
synchronized="false"
static="false"
final="false"
deprecated="not deprecated"
visibility="public"
>
<parameter name="response" type="android.accounts.AccountAuthenticatorResponse">
</parameter>
<parameter name="account" type="android.accounts.Account">
</parameter>
<exception name="NetworkErrorException" type="android.accounts.NetworkErrorException">
</exception>
</method>
<method name="getAuthToken" <method name="getAuthToken"
return="android.os.Bundle" return="android.os.Bundle"
abstract="true" abstract="true"
@@ -13615,7 +13632,7 @@
visibility="public" visibility="public"
> >
</field> </field>
<field name="mName" <field name="name"
type="java.lang.String" type="java.lang.String"
transient="false" transient="false"
volatile="false" volatile="false"
@@ -13625,7 +13642,7 @@
visibility="public" visibility="public"
> >
</field> </field>
<field name="mType" <field name="type"
type="java.lang.String" type="java.lang.String"
transient="false" transient="false"
volatile="false" volatile="false"
@@ -13781,7 +13798,7 @@
visibility="public" visibility="public"
> >
<method name="addAccount" <method name="addAccount"
return="android.accounts.Future2" return="android.accounts.AccountManagerFuture&lt;android.os.Bundle&gt;"
abstract="false" abstract="false"
native="false" native="false"
synchronized="false" synchronized="false"
@@ -13800,13 +13817,13 @@
</parameter> </parameter>
<parameter name="activity" type="android.app.Activity"> <parameter name="activity" type="android.app.Activity">
</parameter> </parameter>
<parameter name="callback" type="android.accounts.Future2Callback"> <parameter name="callback" type="android.accounts.AccountManagerCallback&lt;android.os.Bundle&gt;">
</parameter> </parameter>
<parameter name="handler" type="android.os.Handler"> <parameter name="handler" type="android.os.Handler">
</parameter> </parameter>
</method> </method>
<method name="addAccountExplicitly" <method name="addAccountExplicitly"
return="android.accounts.Future1&lt;java.lang.Boolean&gt;" return="boolean"
abstract="false" abstract="false"
native="false" native="false"
synchronized="false" synchronized="false"
@@ -13815,16 +13832,12 @@
deprecated="not deprecated" deprecated="not deprecated"
visibility="public" visibility="public"
> >
<parameter name="callback" type="android.accounts.Future1Callback&lt;java.lang.Boolean&gt;">
</parameter>
<parameter name="account" type="android.accounts.Account"> <parameter name="account" type="android.accounts.Account">
</parameter> </parameter>
<parameter name="password" type="java.lang.String"> <parameter name="password" type="java.lang.String">
</parameter> </parameter>
<parameter name="extras" type="android.os.Bundle"> <parameter name="extras" type="android.os.Bundle">
</parameter> </parameter>
<parameter name="handler" type="android.os.Handler">
</parameter>
</method> </method>
<method name="addOnAccountsUpdatedListener" <method name="addOnAccountsUpdatedListener"
return="void" return="void"
@@ -13843,81 +13856,6 @@
<parameter name="updateImmediately" type="boolean"> <parameter name="updateImmediately" type="boolean">
</parameter> </parameter>
</method> </method>
<method name="blockingAddAccountExplicitly"
return="boolean"
abstract="false"
native="false"
synchronized="false"
static="false"
final="false"
deprecated="not deprecated"
visibility="public"
>
<parameter name="account" type="android.accounts.Account">
</parameter>
<parameter name="password" type="java.lang.String">
</parameter>
<parameter name="extras" type="android.os.Bundle">
</parameter>
</method>
<method name="blockingClearPassword"
return="void"
abstract="false"
native="false"
synchronized="false"
static="false"
final="false"
deprecated="not deprecated"
visibility="public"
>
<parameter name="account" type="android.accounts.Account">
</parameter>
</method>
<method name="blockingGetAccounts"
return="android.accounts.Account[]"
abstract="false"
native="false"
synchronized="false"
static="false"
final="false"
deprecated="not deprecated"
visibility="public"
>
</method>
<method name="blockingGetAccountsByType"
return="android.accounts.Account[]"
abstract="false"
native="false"
synchronized="false"
static="false"
final="false"
deprecated="not deprecated"
visibility="public"
>
<parameter name="accountType" type="java.lang.String">
</parameter>
</method>
<method name="blockingGetAccountsWithTypeAndFeatures"
return="android.accounts.Account[]"
abstract="false"
native="false"
synchronized="false"
static="false"
final="false"
deprecated="not deprecated"
visibility="public"
>
<parameter name="type" type="java.lang.String">
</parameter>
<parameter name="features" type="java.lang.String[]">
</parameter>
<exception name="AuthenticatorException" type="android.accounts.AuthenticatorException">
</exception>
<exception name="IOException" type="java.io.IOException">
</exception>
<exception name="OperationCanceledException" type="android.accounts.OperationCanceledException">
</exception>
</method>
<method name="blockingGetAuthToken" <method name="blockingGetAuthToken"
return="java.lang.String" return="java.lang.String"
abstract="false" abstract="false"
@@ -13941,139 +13879,8 @@
<exception name="OperationCanceledException" type="android.accounts.OperationCanceledException"> <exception name="OperationCanceledException" type="android.accounts.OperationCanceledException">
</exception> </exception>
</method> </method>
<method name="blockingGetAuthenticatorTypes"
return="android.accounts.AuthenticatorDescription[]"
abstract="false"
native="false"
synchronized="false"
static="false"
final="false"
deprecated="not deprecated"
visibility="public"
>
</method>
<method name="blockingGetPassword"
return="java.lang.String"
abstract="false"
native="false"
synchronized="false"
static="false"
final="false"
deprecated="not deprecated"
visibility="public"
>
<parameter name="account" type="android.accounts.Account">
</parameter>
</method>
<method name="blockingGetUserData"
return="java.lang.String"
abstract="false"
native="false"
synchronized="false"
static="false"
final="false"
deprecated="not deprecated"
visibility="public"
>
<parameter name="account" type="android.accounts.Account">
</parameter>
<parameter name="key" type="java.lang.String">
</parameter>
</method>
<method name="blockingInvalidateAuthToken"
return="void"
abstract="false"
native="false"
synchronized="false"
static="false"
final="false"
deprecated="not deprecated"
visibility="public"
>
<parameter name="accountType" type="java.lang.String">
</parameter>
<parameter name="authToken" type="java.lang.String">
</parameter>
</method>
<method name="blockingPeekAuthToken"
return="java.lang.String"
abstract="false"
native="false"
synchronized="false"
static="false"
final="false"
deprecated="not deprecated"
visibility="public"
>
<parameter name="account" type="android.accounts.Account">
</parameter>
<parameter name="authTokenType" type="java.lang.String">
</parameter>
</method>
<method name="blockingRemoveAccount"
return="void"
abstract="false"
native="false"
synchronized="false"
static="false"
final="false"
deprecated="not deprecated"
visibility="public"
>
<parameter name="account" type="android.accounts.Account">
</parameter>
</method>
<method name="blockingSetAuthToken"
return="void"
abstract="false"
native="false"
synchronized="false"
static="false"
final="false"
deprecated="not deprecated"
visibility="public"
>
<parameter name="account" type="android.accounts.Account">
</parameter>
<parameter name="authTokenType" type="java.lang.String">
</parameter>
<parameter name="authToken" type="java.lang.String">
</parameter>
</method>
<method name="blockingSetPassword"
return="void"
abstract="false"
native="false"
synchronized="false"
static="false"
final="false"
deprecated="not deprecated"
visibility="public"
>
<parameter name="account" type="android.accounts.Account">
</parameter>
<parameter name="password" type="java.lang.String">
</parameter>
</method>
<method name="blockingSetUserData"
return="void"
abstract="false"
native="false"
synchronized="false"
static="false"
final="false"
deprecated="not deprecated"
visibility="public"
>
<parameter name="account" type="android.accounts.Account">
</parameter>
<parameter name="key" type="java.lang.String">
</parameter>
<parameter name="value" type="java.lang.String">
</parameter>
</method>
<method name="clearPassword" <method name="clearPassword"
return="android.accounts.Future1&lt;java.lang.Void&gt;" return="void"
abstract="false" abstract="false"
native="false" native="false"
synchronized="false" synchronized="false"
@@ -14082,15 +13889,11 @@
deprecated="not deprecated" deprecated="not deprecated"
visibility="public" visibility="public"
> >
<parameter name="callback" type="android.accounts.Future1Callback&lt;java.lang.Void&gt;">
</parameter>
<parameter name="account" type="android.accounts.Account"> <parameter name="account" type="android.accounts.Account">
</parameter> </parameter>
<parameter name="handler" type="android.os.Handler">
</parameter>
</method> </method>
<method name="confirmCredentials" <method name="confirmCredentials"
return="android.accounts.Future2" return="android.accounts.AccountManagerFuture&lt;android.os.Bundle&gt;"
abstract="false" abstract="false"
native="false" native="false"
synchronized="false" synchronized="false"
@@ -14103,13 +13906,13 @@
</parameter> </parameter>
<parameter name="activity" type="android.app.Activity"> <parameter name="activity" type="android.app.Activity">
</parameter> </parameter>
<parameter name="callback" type="android.accounts.Future2Callback"> <parameter name="callback" type="android.accounts.AccountManagerCallback&lt;android.os.Bundle&gt;">
</parameter> </parameter>
<parameter name="handler" type="android.os.Handler"> <parameter name="handler" type="android.os.Handler">
</parameter> </parameter>
</method> </method>
<method name="confirmPassword" <method name="confirmPassword"
return="android.accounts.Future1&lt;java.lang.Boolean&gt;" return="android.accounts.AccountManagerFuture&lt;java.lang.Boolean&gt;"
abstract="false" abstract="false"
native="false" native="false"
synchronized="false" synchronized="false"
@@ -14122,13 +13925,13 @@
</parameter> </parameter>
<parameter name="password" type="java.lang.String"> <parameter name="password" type="java.lang.String">
</parameter> </parameter>
<parameter name="callback" type="android.accounts.Future1Callback&lt;java.lang.Boolean&gt;"> <parameter name="callback" type="android.accounts.AccountManagerCallback&lt;java.lang.Boolean&gt;">
</parameter> </parameter>
<parameter name="handler" type="android.os.Handler"> <parameter name="handler" type="android.os.Handler">
</parameter> </parameter>
</method> </method>
<method name="editProperties" <method name="editProperties"
return="android.accounts.Future2" return="android.accounts.AccountManagerFuture&lt;android.os.Bundle&gt;"
abstract="false" abstract="false"
native="false" native="false"
synchronized="false" synchronized="false"
@@ -14141,7 +13944,7 @@
</parameter> </parameter>
<parameter name="activity" type="android.app.Activity"> <parameter name="activity" type="android.app.Activity">
</parameter> </parameter>
<parameter name="callback" type="android.accounts.Future2Callback"> <parameter name="callback" type="android.accounts.AccountManagerCallback&lt;android.os.Bundle&gt;">
</parameter> </parameter>
<parameter name="handler" type="android.os.Handler"> <parameter name="handler" type="android.os.Handler">
</parameter> </parameter>
@@ -14160,7 +13963,7 @@
</parameter> </parameter>
</method> </method>
<method name="getAccounts" <method name="getAccounts"
return="android.accounts.Future1&lt;android.accounts.Account[]&gt;" return="android.accounts.Account[]"
abstract="false" abstract="false"
native="false" native="false"
synchronized="false" synchronized="false"
@@ -14169,13 +13972,9 @@
deprecated="not deprecated" deprecated="not deprecated"
visibility="public" visibility="public"
> >
<parameter name="callback" type="android.accounts.Future1Callback&lt;android.accounts.Account[]&gt;">
</parameter>
<parameter name="handler" type="android.os.Handler">
</parameter>
</method> </method>
<method name="getAccountsByType" <method name="getAccountsByType"
return="android.accounts.Future1&lt;android.accounts.Account[]&gt;" return="android.accounts.Account[]"
abstract="false" abstract="false"
native="false" native="false"
synchronized="false" synchronized="false"
@@ -14184,15 +13983,11 @@
deprecated="not deprecated" deprecated="not deprecated"
visibility="public" visibility="public"
> >
<parameter name="callback" type="android.accounts.Future1Callback&lt;android.accounts.Account[]&gt;">
</parameter>
<parameter name="type" type="java.lang.String"> <parameter name="type" type="java.lang.String">
</parameter> </parameter>
<parameter name="handler" type="android.os.Handler">
</parameter>
</method> </method>
<method name="getAccountsWithTypeAndFeatures" <method name="getAccountsByTypeAndFeatures"
return="android.accounts.Future2" return="android.accounts.AccountManagerFuture&lt;android.accounts.Account[]&gt;"
abstract="false" abstract="false"
native="false" native="false"
synchronized="false" synchronized="false"
@@ -14205,13 +14000,13 @@
</parameter> </parameter>
<parameter name="features" type="java.lang.String[]"> <parameter name="features" type="java.lang.String[]">
</parameter> </parameter>
<parameter name="callback" type="android.accounts.Future2Callback"> <parameter name="callback" type="android.accounts.AccountManagerCallback&lt;android.accounts.Account[]&gt;">
</parameter> </parameter>
<parameter name="handler" type="android.os.Handler"> <parameter name="handler" type="android.os.Handler">
</parameter> </parameter>
</method> </method>
<method name="getAuthToken" <method name="getAuthToken"
return="android.accounts.Future2" return="android.accounts.AccountManagerFuture&lt;android.os.Bundle&gt;"
abstract="false" abstract="false"
native="false" native="false"
synchronized="false" synchronized="false"
@@ -14228,13 +14023,13 @@
</parameter> </parameter>
<parameter name="activity" type="android.app.Activity"> <parameter name="activity" type="android.app.Activity">
</parameter> </parameter>
<parameter name="callback" type="android.accounts.Future2Callback"> <parameter name="callback" type="android.accounts.AccountManagerCallback&lt;android.os.Bundle&gt;">
</parameter> </parameter>
<parameter name="handler" type="android.os.Handler"> <parameter name="handler" type="android.os.Handler">
</parameter> </parameter>
</method> </method>
<method name="getAuthToken" <method name="getAuthToken"
return="android.accounts.Future2" return="android.accounts.AccountManagerFuture&lt;android.os.Bundle&gt;"
abstract="false" abstract="false"
native="false" native="false"
synchronized="false" synchronized="false"
@@ -14249,7 +14044,7 @@
</parameter> </parameter>
<parameter name="notifyAuthFailure" type="boolean"> <parameter name="notifyAuthFailure" type="boolean">
</parameter> </parameter>
<parameter name="callback" type="android.accounts.Future2Callback"> <parameter name="callback" type="android.accounts.AccountManagerCallback&lt;android.os.Bundle&gt;">
</parameter> </parameter>
<parameter name="handler" type="android.os.Handler"> <parameter name="handler" type="android.os.Handler">
</parameter> </parameter>
@@ -14276,13 +14071,13 @@
</parameter> </parameter>
<parameter name="loginOptions" type="android.os.Bundle"> <parameter name="loginOptions" type="android.os.Bundle">
</parameter> </parameter>
<parameter name="callback" type="android.accounts.Future2Callback"> <parameter name="callback" type="android.accounts.AccountManagerCallback&lt;android.os.Bundle&gt;">
</parameter> </parameter>
<parameter name="handler" type="android.os.Handler"> <parameter name="handler" type="android.os.Handler">
</parameter> </parameter>
</method> </method>
<method name="getAuthenticatorTypes" <method name="getAuthenticatorTypes"
return="android.accounts.Future1&lt;android.accounts.AuthenticatorDescription[]&gt;" return="android.accounts.AuthenticatorDescription[]"
abstract="false" abstract="false"
native="false" native="false"
synchronized="false" synchronized="false"
@@ -14291,13 +14086,9 @@
deprecated="not deprecated" deprecated="not deprecated"
visibility="public" visibility="public"
> >
<parameter name="callback" type="android.accounts.Future1Callback&lt;android.accounts.AuthenticatorDescription[]&gt;">
</parameter>
<parameter name="handler" type="android.os.Handler">
</parameter>
</method> </method>
<method name="getPassword" <method name="getPassword"
return="android.accounts.Future1&lt;java.lang.String&gt;" return="java.lang.String"
abstract="false" abstract="false"
native="false" native="false"
synchronized="false" synchronized="false"
@@ -14306,15 +14097,11 @@
deprecated="not deprecated" deprecated="not deprecated"
visibility="public" visibility="public"
> >
<parameter name="callback" type="android.accounts.Future1Callback&lt;java.lang.String&gt;">
</parameter>
<parameter name="account" type="android.accounts.Account"> <parameter name="account" type="android.accounts.Account">
</parameter> </parameter>
<parameter name="handler" type="android.os.Handler">
</parameter>
</method> </method>
<method name="getUserData" <method name="getUserData"
return="android.accounts.Future1&lt;java.lang.String&gt;" return="java.lang.String"
abstract="false" abstract="false"
native="false" native="false"
synchronized="false" synchronized="false"
@@ -14323,17 +14110,13 @@
deprecated="not deprecated" deprecated="not deprecated"
visibility="public" visibility="public"
> >
<parameter name="callback" type="android.accounts.Future1Callback&lt;java.lang.String&gt;">
</parameter>
<parameter name="account" type="android.accounts.Account"> <parameter name="account" type="android.accounts.Account">
</parameter> </parameter>
<parameter name="key" type="java.lang.String"> <parameter name="key" type="java.lang.String">
</parameter> </parameter>
<parameter name="handler" type="android.os.Handler">
</parameter>
</method> </method>
<method name="invalidateAuthToken" <method name="invalidateAuthToken"
return="android.accounts.Future1&lt;java.lang.Void&gt;" return="void"
abstract="false" abstract="false"
native="false" native="false"
synchronized="false" synchronized="false"
@@ -14342,17 +14125,13 @@
deprecated="not deprecated" deprecated="not deprecated"
visibility="public" visibility="public"
> >
<parameter name="callback" type="android.accounts.Future1Callback&lt;java.lang.Void&gt;">
</parameter>
<parameter name="accountType" type="java.lang.String"> <parameter name="accountType" type="java.lang.String">
</parameter> </parameter>
<parameter name="authToken" type="java.lang.String"> <parameter name="authToken" type="java.lang.String">
</parameter> </parameter>
<parameter name="handler" type="android.os.Handler">
</parameter>
</method> </method>
<method name="peekAuthToken" <method name="peekAuthToken"
return="android.accounts.Future1&lt;java.lang.String&gt;" return="java.lang.String"
abstract="false" abstract="false"
native="false" native="false"
synchronized="false" synchronized="false"
@@ -14361,17 +14140,13 @@
deprecated="not deprecated" deprecated="not deprecated"
visibility="public" visibility="public"
> >
<parameter name="callback" type="android.accounts.Future1Callback&lt;java.lang.String&gt;">
</parameter>
<parameter name="account" type="android.accounts.Account"> <parameter name="account" type="android.accounts.Account">
</parameter> </parameter>
<parameter name="authTokenType" type="java.lang.String"> <parameter name="authTokenType" type="java.lang.String">
</parameter> </parameter>
<parameter name="handler" type="android.os.Handler">
</parameter>
</method> </method>
<method name="removeAccount" <method name="removeAccount"
return="android.accounts.Future1&lt;java.lang.Void&gt;" return="android.accounts.AccountManagerFuture&lt;java.lang.Boolean&gt;"
abstract="false" abstract="false"
native="false" native="false"
synchronized="false" synchronized="false"
@@ -14380,10 +14155,10 @@
deprecated="not deprecated" deprecated="not deprecated"
visibility="public" visibility="public"
> >
<parameter name="callback" type="android.accounts.Future1Callback&lt;java.lang.Void&gt;">
</parameter>
<parameter name="account" type="android.accounts.Account"> <parameter name="account" type="android.accounts.Account">
</parameter> </parameter>
<parameter name="callback" type="android.accounts.AccountManagerCallback&lt;java.lang.Boolean&gt;">
</parameter>
<parameter name="handler" type="android.os.Handler"> <parameter name="handler" type="android.os.Handler">
</parameter> </parameter>
</method> </method>
@@ -14401,7 +14176,7 @@
</parameter> </parameter>
</method> </method>
<method name="setAuthToken" <method name="setAuthToken"
return="android.accounts.Future1&lt;java.lang.Void&gt;" return="void"
abstract="false" abstract="false"
native="false" native="false"
synchronized="false" synchronized="false"
@@ -14410,19 +14185,15 @@
deprecated="not deprecated" deprecated="not deprecated"
visibility="public" visibility="public"
> >
<parameter name="callback" type="android.accounts.Future1Callback&lt;java.lang.Void&gt;">
</parameter>
<parameter name="account" type="android.accounts.Account"> <parameter name="account" type="android.accounts.Account">
</parameter> </parameter>
<parameter name="authTokenType" type="java.lang.String"> <parameter name="authTokenType" type="java.lang.String">
</parameter> </parameter>
<parameter name="authToken" type="java.lang.String"> <parameter name="authToken" type="java.lang.String">
</parameter> </parameter>
<parameter name="handler" type="android.os.Handler">
</parameter>
</method> </method>
<method name="setPassword" <method name="setPassword"
return="android.accounts.Future1&lt;java.lang.Void&gt;" return="void"
abstract="false" abstract="false"
native="false" native="false"
synchronized="false" synchronized="false"
@@ -14431,17 +14202,13 @@
deprecated="not deprecated" deprecated="not deprecated"
visibility="public" visibility="public"
> >
<parameter name="callback" type="android.accounts.Future1Callback&lt;java.lang.Void&gt;">
</parameter>
<parameter name="account" type="android.accounts.Account"> <parameter name="account" type="android.accounts.Account">
</parameter> </parameter>
<parameter name="password" type="java.lang.String"> <parameter name="password" type="java.lang.String">
</parameter> </parameter>
<parameter name="handler" type="android.os.Handler">
</parameter>
</method> </method>
<method name="setUserData" <method name="setUserData"
return="android.accounts.Future1&lt;java.lang.Void&gt;" return="void"
abstract="false" abstract="false"
native="false" native="false"
synchronized="false" synchronized="false"
@@ -14450,19 +14217,15 @@
deprecated="not deprecated" deprecated="not deprecated"
visibility="public" visibility="public"
> >
<parameter name="callback" type="android.accounts.Future1Callback&lt;java.lang.Void&gt;">
</parameter>
<parameter name="account" type="android.accounts.Account"> <parameter name="account" type="android.accounts.Account">
</parameter> </parameter>
<parameter name="key" type="java.lang.String"> <parameter name="key" type="java.lang.String">
</parameter> </parameter>
<parameter name="value" type="java.lang.String"> <parameter name="value" type="java.lang.String">
</parameter> </parameter>
<parameter name="handler" type="android.os.Handler">
</parameter>
</method> </method>
<method name="updateCredentials" <method name="updateCredentials"
return="android.accounts.Future2" return="android.accounts.AccountManagerFuture&lt;android.os.Bundle&gt;"
abstract="false" abstract="false"
native="false" native="false"
synchronized="false" synchronized="false"
@@ -14479,12 +14242,117 @@
</parameter> </parameter>
<parameter name="activity" type="android.app.Activity"> <parameter name="activity" type="android.app.Activity">
</parameter> </parameter>
<parameter name="callback" type="android.accounts.Future2Callback"> <parameter name="callback" type="android.accounts.AccountManagerCallback&lt;android.os.Bundle&gt;">
</parameter> </parameter>
<parameter name="handler" type="android.os.Handler"> <parameter name="handler" type="android.os.Handler">
</parameter> </parameter>
</method> </method>
</class> </class>
<interface name="AccountManagerCallback"
abstract="true"
static="false"
final="false"
deprecated="not deprecated"
visibility="public"
>
<method name="run"
return="void"
abstract="true"
native="false"
synchronized="false"
static="false"
final="false"
deprecated="not deprecated"
visibility="public"
>
<parameter name="future" type="android.accounts.AccountManagerFuture&lt;V&gt;">
</parameter>
</method>
</interface>
<interface name="AccountManagerFuture"
abstract="true"
static="false"
final="false"
deprecated="not deprecated"
visibility="public"
>
<implements name="java.util.concurrent.Future">
</implements>
<method name="get"
return="V"
abstract="true"
native="false"
synchronized="false"
static="false"
final="false"
deprecated="deprecated"
visibility="public"
>
<exception name="ExecutionException" type="java.util.concurrent.ExecutionException">
</exception>
<exception name="InterruptedException" type="java.lang.InterruptedException">
</exception>
</method>
<method name="get"
return="V"
abstract="true"
native="false"
synchronized="false"
static="false"
final="false"
deprecated="deprecated"
visibility="public"
>
<parameter name="timeout" type="long">
</parameter>
<parameter name="unit" type="java.util.concurrent.TimeUnit">
</parameter>
<exception name="ExecutionException" type="java.util.concurrent.ExecutionException">
</exception>
<exception name="InterruptedException" type="java.lang.InterruptedException">
</exception>
<exception name="TimeoutException" type="java.util.concurrent.TimeoutException">
</exception>
</method>
<method name="getResult"
return="V"
abstract="true"
native="false"
synchronized="false"
static="false"
final="false"
deprecated="not deprecated"
visibility="public"
>
<exception name="AuthenticatorException" type="android.accounts.AuthenticatorException">
</exception>
<exception name="IOException" type="java.io.IOException">
</exception>
<exception name="OperationCanceledException" type="android.accounts.OperationCanceledException">
</exception>
</method>
<method name="getResult"
return="V"
abstract="true"
native="false"
synchronized="false"
static="false"
final="false"
deprecated="not deprecated"
visibility="public"
>
<parameter name="timeout" type="long">
</parameter>
<parameter name="unit" type="java.util.concurrent.TimeUnit">
</parameter>
<exception name="AuthenticatorException" type="android.accounts.AuthenticatorException">
</exception>
<exception name="IOException" type="java.io.IOException">
</exception>
<exception name="OperationCanceledException" type="android.accounts.OperationCanceledException">
</exception>
</method>
</interface>
<class name="AuthenticatorDescription" <class name="AuthenticatorDescription"
extends="java.lang.Object" extends="java.lang.Object"
abstract="false" abstract="false"
@@ -14952,6 +14820,17 @@
visibility="public" visibility="public"
> >
</field> </field>
<field name="PASSWORD_KEY"
type="java.lang.String"
transient="false"
volatile="false"
value="&quot;password&quot;"
static="true"
final="true"
deprecated="not deprecated"
visibility="public"
>
</field>
<field name="USERDATA_KEY" <field name="USERDATA_KEY"
type="java.lang.String" type="java.lang.String"
transient="false" transient="false"
@@ -14964,136 +14843,6 @@
> >
</field> </field>
</class> </class>
<interface name="Future1"
abstract="true"
static="false"
final="false"
deprecated="not deprecated"
visibility="public"
>
<implements name="java.util.concurrent.Future">
</implements>
<method name="getResult"
return="V"
abstract="true"
native="false"
synchronized="false"
static="false"
final="false"
deprecated="not deprecated"
visibility="public"
>
<exception name="OperationCanceledException" type="android.accounts.OperationCanceledException">
</exception>
</method>
<method name="getResult"
return="V"
abstract="true"
native="false"
synchronized="false"
static="false"
final="false"
deprecated="not deprecated"
visibility="public"
>
<parameter name="timeout" type="long">
</parameter>
<parameter name="unit" type="java.util.concurrent.TimeUnit">
</parameter>
<exception name="OperationCanceledException" type="android.accounts.OperationCanceledException">
</exception>
</method>
</interface>
<interface name="Future1Callback"
abstract="true"
static="false"
final="false"
deprecated="not deprecated"
visibility="public"
>
<method name="run"
return="void"
abstract="true"
native="false"
synchronized="false"
static="false"
final="false"
deprecated="not deprecated"
visibility="public"
>
<parameter name="future" type="android.accounts.Future1&lt;V&gt;">
</parameter>
</method>
</interface>
<interface name="Future2"
abstract="true"
static="false"
final="false"
deprecated="not deprecated"
visibility="public"
>
<implements name="java.util.concurrent.Future">
</implements>
<method name="getResult"
return="android.os.Bundle"
abstract="true"
native="false"
synchronized="false"
static="false"
final="false"
deprecated="not deprecated"
visibility="public"
>
<exception name="AuthenticatorException" type="android.accounts.AuthenticatorException">
</exception>
<exception name="IOException" type="java.io.IOException">
</exception>
<exception name="OperationCanceledException" type="android.accounts.OperationCanceledException">
</exception>
</method>
<method name="getResult"
return="android.os.Bundle"
abstract="true"
native="false"
synchronized="false"
static="false"
final="false"
deprecated="not deprecated"
visibility="public"
>
<parameter name="timeout" type="long">
</parameter>
<parameter name="unit" type="java.util.concurrent.TimeUnit">
</parameter>
<exception name="AuthenticatorException" type="android.accounts.AuthenticatorException">
</exception>
<exception name="IOException" type="java.io.IOException">
</exception>
<exception name="OperationCanceledException" type="android.accounts.OperationCanceledException">
</exception>
</method>
</interface>
<interface name="Future2Callback"
abstract="true"
static="false"
final="false"
deprecated="not deprecated"
visibility="public"
>
<method name="run"
return="void"
abstract="true"
native="false"
synchronized="false"
static="false"
final="false"
deprecated="not deprecated"
visibility="public"
>
<parameter name="future" type="android.accounts.Future2">
</parameter>
</method>
</interface>
<interface name="IAccountAuthenticator" <interface name="IAccountAuthenticator"
abstract="true" abstract="true"
static="false" static="false"
@@ -15179,6 +14928,23 @@
<exception name="RemoteException" type="android.os.RemoteException"> <exception name="RemoteException" type="android.os.RemoteException">
</exception> </exception>
</method> </method>
<method name="getAccountRemovalAllowed"
return="void"
abstract="true"
native="false"
synchronized="false"
static="false"
final="false"
deprecated="not deprecated"
visibility="public"
>
<parameter name="response" type="android.accounts.IAccountAuthenticatorResponse">
</parameter>
<parameter name="account" type="android.accounts.Account">
</parameter>
<exception name="RemoteException" type="android.os.RemoteException">
</exception>
</method>
<method name="getAuthToken" <method name="getAuthToken"
return="void" return="void"
abstract="true" abstract="true"

View File

@@ -188,6 +188,25 @@ public abstract class AbstractAccountAuthenticator {
response.onResult(result); response.onResult(result);
} }
} }
public void getAccountRemovalAllowed(IAccountAuthenticatorResponse response,
Account account) throws RemoteException {
checkBinderPermission();
try {
final Bundle result = AbstractAccountAuthenticator.this.getAccountRemovalAllowed(
new AccountAuthenticatorResponse(response), account);
if (result != null) {
response.onResult(result);
}
} catch (UnsupportedOperationException e) {
response.onError(Constants.ERROR_CODE_UNSUPPORTED_OPERATION,
"getAccountRemovalAllowed not supported");
return;
} catch (NetworkErrorException e) {
response.onError(Constants.ERROR_CODE_NETWORK_ERROR, e.getMessage());
return;
}
}
} }
private void checkBinderPermission() { private void checkBinderPermission() {
@@ -238,4 +257,10 @@ public abstract class AbstractAccountAuthenticator {
Account account, String authTokenType, Bundle loginOptions); Account account, String authTokenType, Bundle loginOptions);
public abstract Bundle hasFeatures(AccountAuthenticatorResponse response, public abstract Bundle hasFeatures(AccountAuthenticatorResponse response,
Account account, String[] features) throws NetworkErrorException; Account account, String[] features) throws NetworkErrorException;
public Bundle getAccountRemovalAllowed(AccountAuthenticatorResponse response,
Account account) throws NetworkErrorException {
final Bundle result = new Bundle();
result.putBoolean(Constants.BOOLEAN_RESULT_KEY, true);
return result;
}
} }

View File

@@ -26,20 +26,20 @@ import android.text.TextUtils;
* suitable for use as the key of a {@link java.util.Map} * suitable for use as the key of a {@link java.util.Map}
*/ */
public class Account implements Parcelable { public class Account implements Parcelable {
public final String mName; public final String name;
public final String mType; public final String type;
public boolean equals(Object o) { public boolean equals(Object o) {
if (o == this) return true; if (o == this) return true;
if (!(o instanceof Account)) return false; if (!(o instanceof Account)) return false;
final Account other = (Account)o; final Account other = (Account)o;
return mName.equals(other.mName) && mType.equals(other.mType); return name.equals(other.name) && type.equals(other.type);
} }
public int hashCode() { public int hashCode() {
int result = 17; int result = 17;
result = 31 * result + mName.hashCode(); result = 31 * result + name.hashCode();
result = 31 * result + mType.hashCode(); result = 31 * result + type.hashCode();
return result; return result;
} }
@@ -50,13 +50,13 @@ public class Account implements Parcelable {
if (TextUtils.isEmpty(type)) { if (TextUtils.isEmpty(type)) {
throw new IllegalArgumentException("the type must not be empty: " + type); throw new IllegalArgumentException("the type must not be empty: " + type);
} }
mName = name; this.name = name;
mType = type; this.type = type;
} }
public Account(Parcel in) { public Account(Parcel in) {
mName = in.readString(); this.name = in.readString();
mType = in.readString(); this.type = in.readString();
} }
public int describeContents() { public int describeContents() {
@@ -64,8 +64,8 @@ public class Account implements Parcelable {
} }
public void writeToParcel(Parcel dest, int flags) { public void writeToParcel(Parcel dest, int flags) {
dest.writeString(mName); dest.writeString(name);
dest.writeString(mType); dest.writeString(type);
} }
public static final Creator<Account> CREATOR = new Creator<Account>() { public static final Creator<Account> CREATOR = new Creator<Account>() {
@@ -79,6 +79,6 @@ public class Account implements Parcelable {
}; };
public String toString() { public String toString() {
return "Account {name=" + mName + ", type=" + mType + "}"; return "Account {name=" + name + ", type=" + type + "}";
} }
} }

View File

@@ -26,8 +26,6 @@ import android.os.Handler;
import android.os.Looper; import android.os.Looper;
import android.os.RemoteException; import android.os.RemoteException;
import android.os.Parcelable; import android.os.Parcelable;
import android.util.Config;
import android.util.Log;
import java.io.IOException; import java.io.IOException;
import java.util.concurrent.Callable; import java.util.concurrent.Callable;
@@ -80,258 +78,132 @@ public class AccountManager {
return (AccountManager) context.getSystemService(Context.ACCOUNT_SERVICE); return (AccountManager) context.getSystemService(Context.ACCOUNT_SERVICE);
} }
public String blockingGetPassword(Account account) { public String getPassword(final Account account) {
ensureNotOnMainThread();
try { try {
return mService.getPassword(account); return mService.getPassword(account);
} catch (RemoteException e) { } catch (RemoteException e) {
// if this happens the entire runtime will restart // will never happen
throw new RuntimeException(e); throw new RuntimeException(e);
} }
} }
public Future1<String> getPassword(final Future1Callback<String> callback, public String getUserData(final Account account, final String key) {
final Account account, final Handler handler) {
return startAsFuture(callback, handler, new Callable<String>() {
public String call() throws Exception {
return blockingGetPassword(account);
}
});
}
public String blockingGetUserData(Account account, String key) {
ensureNotOnMainThread();
try { try {
return mService.getUserData(account, key); return mService.getUserData(account, key);
} catch (RemoteException e) { } catch (RemoteException e) {
// if this happens the entire runtime will restart // will never happen
throw new RuntimeException(e); throw new RuntimeException(e);
} }
} }
public Future1<String> getUserData(Future1Callback<String> callback, public AuthenticatorDescription[] getAuthenticatorTypes() {
final Account account, final String key, Handler handler) {
return startAsFuture(callback, handler, new Callable<String>() {
public String call() throws Exception {
return blockingGetUserData(account, key);
}
});
}
public AuthenticatorDescription[] blockingGetAuthenticatorTypes() {
ensureNotOnMainThread();
try { try {
return mService.getAuthenticatorTypes(); return mService.getAuthenticatorTypes();
} catch (RemoteException e) { } catch (RemoteException e) {
// if this happens the entire runtime will restart // will never happen
throw new RuntimeException(e); throw new RuntimeException(e);
} }
} }
public Future1<AuthenticatorDescription[]> getAuthenticatorTypes( public Account[] getAccounts() {
Future1Callback<AuthenticatorDescription[]> callback, Handler handler) {
return startAsFuture(callback, handler, new Callable<AuthenticatorDescription[]>() {
public AuthenticatorDescription[] call() throws Exception {
return blockingGetAuthenticatorTypes();
}
});
}
public Account[] blockingGetAccounts() {
ensureNotOnMainThread();
try { try {
return mService.getAccounts(); return mService.getAccounts(null);
} catch (RemoteException e) { } catch (RemoteException e) {
// if this happens the entire runtime will restart // won't ever happen
throw new RuntimeException(e); throw new RuntimeException(e);
} }
} }
public Account[] blockingGetAccountsByType(String accountType) { public Account[] getAccountsByType(String type) {
ensureNotOnMainThread();
try { try {
return mService.getAccountsByType(accountType); return mService.getAccounts(type);
} catch (RemoteException e) { } catch (RemoteException e) {
// if this happens the entire runtime will restart // won't ever happen
throw new RuntimeException(e); throw new RuntimeException(e);
} }
} }
public Future1<Account[]> getAccounts(Future1Callback<Account[]> callback, Handler handler) { public boolean addAccountExplicitly(Account account, String password, Bundle extras) {
return startAsFuture(callback, handler, new Callable<Account[]>() {
public Account[] call() throws Exception {
return blockingGetAccounts();
}
});
}
public Future1<Account[]> getAccountsByType(Future1Callback<Account[]> callback,
final String type, Handler handler) {
return startAsFuture(callback, handler, new Callable<Account[]>() {
public Account[] call() throws Exception {
return blockingGetAccountsByType(type);
}
});
}
public boolean blockingAddAccountExplicitly(Account account, String password, Bundle extras) {
ensureNotOnMainThread();
try { try {
return mService.addAccount(account, password, extras); return mService.addAccount(account, password, extras);
} catch (RemoteException e) { } catch (RemoteException e) {
// if this happens the entire runtime will restart // won't ever happen
throw new RuntimeException(e); throw new RuntimeException(e);
} }
} }
public Future1<Boolean> addAccountExplicitly(final Future1Callback<Boolean> callback, public AccountManagerFuture<Boolean> removeAccount(final Account account,
final Account account, final String password, final Bundle extras, AccountManagerCallback<Boolean> callback, Handler handler) {
final Handler handler) { return new Future2Task<Boolean>(handler, callback) {
return startAsFuture(callback, handler, new Callable<Boolean>() { public void doWork() throws RemoteException {
public Boolean call() throws Exception { mService.removeAccount(mResponse, account);
return blockingAddAccountExplicitly(account, password, extras);
} }
}); public Boolean bundleToResult(Bundle bundle) throws AuthenticatorException {
if (!bundle.containsKey(Constants.BOOLEAN_RESULT_KEY)) {
throw new AuthenticatorException("no result in response");
}
return bundle.getBoolean(Constants.BOOLEAN_RESULT_KEY);
}
}.start();
} }
public void blockingRemoveAccount(Account account) { public void invalidateAuthToken(final String accountType, final String authToken) {
ensureNotOnMainThread();
try {
mService.removeAccount(account);
} catch (RemoteException e) {
// if this happens the entire runtime will restart
}
}
public Future1<Void> removeAccount(Future1Callback<Void> callback, final Account account,
final Handler handler) {
return startAsFuture(callback, handler, new Callable<Void>() {
public Void call() throws Exception {
blockingRemoveAccount(account);
return null;
}
});
}
public void blockingInvalidateAuthToken(String accountType, String authToken) {
ensureNotOnMainThread();
try { try {
mService.invalidateAuthToken(accountType, authToken); mService.invalidateAuthToken(accountType, authToken);
} catch (RemoteException e) { } catch (RemoteException e) {
// if this happens the entire runtime will restart // won't ever happen
}
}
public Future1<Void> invalidateAuthToken(Future1Callback<Void> callback,
final String accountType, final String authToken, final Handler handler) {
return startAsFuture(callback, handler, new Callable<Void>() {
public Void call() throws Exception {
blockingInvalidateAuthToken(accountType, authToken);
return null;
}
});
}
public String blockingPeekAuthToken(Account account, String authTokenType) {
ensureNotOnMainThread();
try {
return mService.peekAuthToken(account, authTokenType);
} catch (RemoteException e) {
// if this happens the entire runtime will restart
throw new RuntimeException(e); throw new RuntimeException(e);
} }
} }
public Future1<String> peekAuthToken(Future1Callback<String> callback, public String peekAuthToken(final Account account, final String authTokenType) {
final Account account, final String authTokenType, final Handler handler) { try {
return startAsFuture(callback, handler, new Callable<String>() { return mService.peekAuthToken(account, authTokenType);
public String call() throws Exception { } catch (RemoteException e) {
return blockingPeekAuthToken(account, authTokenType); // won't ever happen
throw new RuntimeException(e);
} }
});
} }
public void blockingSetPassword(Account account, String password) { public void setPassword(final Account account, final String password) {
ensureNotOnMainThread();
try { try {
mService.setPassword(account, password); mService.setPassword(account, password);
} catch (RemoteException e) { } catch (RemoteException e) {
// if this happens the entire runtime will restart // won't ever happen
throw new RuntimeException(e);
} }
} }
public Future1<Void> setPassword(Future1Callback<Void> callback, public void clearPassword(final Account account) {
final Account account, final String password, final Handler handler) {
return startAsFuture(callback, handler, new Callable<Void>() {
public Void call() throws Exception {
blockingSetPassword(account, password);
return null;
}
});
}
public void blockingClearPassword(Account account) {
ensureNotOnMainThread();
try { try {
mService.clearPassword(account); mService.clearPassword(account);
} catch (RemoteException e) { } catch (RemoteException e) {
// if this happens the entire runtime will restart // won't ever happen
throw new RuntimeException(e);
} }
} }
public Future1<Void> clearPassword(final Future1Callback<Void> callback, final Account account, public void setUserData(final Account account, final String key, final String value) {
final Handler handler) {
return startAsFuture(callback, handler, new Callable<Void>() {
public Void call() throws Exception {
blockingClearPassword(account);
return null;
}
});
}
public void blockingSetUserData(Account account, String key, String value) {
ensureNotOnMainThread();
try { try {
mService.setUserData(account, key, value); mService.setUserData(account, key, value);
} catch (RemoteException e) { } catch (RemoteException e) {
// if this happens the entire runtime will restart // won't ever happen
throw new RuntimeException(e);
} }
} }
public Future1<Void> setUserData(Future1Callback<Void> callback, public void setAuthToken(Account account, final String authTokenType, final String authToken) {
final Account account, final String key, final String value, final Handler handler) {
return startAsFuture(callback, handler, new Callable<Void>() {
public Void call() throws Exception {
blockingSetUserData(account, key, value);
return null;
}
});
}
public void blockingSetAuthToken(Account account, String authTokenType, String authToken) {
ensureNotOnMainThread();
try { try {
mService.setAuthToken(account, authTokenType, authToken); mService.setAuthToken(account, authTokenType, authToken);
} catch (RemoteException e) { } catch (RemoteException e) {
// if this happens the entire runtime will restart // won't ever happen
throw new RuntimeException(e);
} }
} }
public Future1<Void> setAuthToken(Future1Callback<Void> callback,
final Account account, final String authTokenType, final String authToken,
final Handler handler) {
return startAsFuture(callback, handler, new Callable<Void>() {
public Void call() throws Exception {
blockingSetAuthToken(account, authTokenType, authToken);
return null;
}
});
}
public String blockingGetAuthToken(Account account, String authTokenType, public String blockingGetAuthToken(Account account, String authTokenType,
boolean notifyAuthFailure) boolean notifyAuthFailure)
throws OperationCanceledException, IOException, AuthenticatorException { throws OperationCanceledException, IOException, AuthenticatorException {
ensureNotOnMainThread();
Bundle bundle = getAuthToken(account, authTokenType, notifyAuthFailure, null /* callback */, Bundle bundle = getAuthToken(account, authTokenType, notifyAuthFailure, null /* callback */,
null /* handler */).getResult(); null /* handler */).getResult();
return bundle.getString(Constants.AUTHTOKEN_KEY); return bundle.getString(Constants.AUTHTOKEN_KEY);
@@ -349,9 +221,9 @@ public class AccountManager {
* @param loginOptions * @param loginOptions
* @param activity the activity to launch the login intent, if necessary, and to which * @param activity the activity to launch the login intent, if necessary, and to which
*/ */
public Future2 getAuthToken( public AccountManagerFuture<Bundle> getAuthToken(
final Account account, final String authTokenType, final Bundle loginOptions, final Account account, final String authTokenType, final Bundle loginOptions,
final Activity activity, Future2Callback callback, Handler handler) { final Activity activity, AccountManagerCallback<Bundle> callback, Handler handler) {
if (activity == null) throw new IllegalArgumentException("activity is null"); if (activity == null) throw new IllegalArgumentException("activity is null");
if (authTokenType == null) throw new IllegalArgumentException("authTokenType is null"); if (authTokenType == null) throw new IllegalArgumentException("authTokenType is null");
return new AmsTask(activity, handler, callback) { return new AmsTask(activity, handler, callback) {
@@ -363,9 +235,9 @@ public class AccountManager {
}.start(); }.start();
} }
public Future2 getAuthToken( public AccountManagerFuture<Bundle> getAuthToken(
final Account account, final String authTokenType, final boolean notifyAuthFailure, final Account account, final String authTokenType, final boolean notifyAuthFailure,
Future2Callback callback, Handler handler) { AccountManagerCallback<Bundle> callback, Handler handler) {
if (account == null) throw new IllegalArgumentException("account is null"); if (account == null) throw new IllegalArgumentException("account is null");
if (authTokenType == null) throw new IllegalArgumentException("authTokenType is null"); if (authTokenType == null) throw new IllegalArgumentException("authTokenType is null");
return new AmsTask(null, handler, callback) { return new AmsTask(null, handler, callback) {
@@ -376,10 +248,10 @@ public class AccountManager {
}.start(); }.start();
} }
public Future2 addAccount(final String accountType, public AccountManagerFuture<Bundle> addAccount(final String accountType,
final String authTokenType, final String[] requiredFeatures, final String authTokenType, final String[] requiredFeatures,
final Bundle addAccountOptions, final Bundle addAccountOptions,
final Activity activity, Future2Callback callback, Handler handler) { final Activity activity, AccountManagerCallback<Bundle> callback, Handler handler) {
return new AmsTask(activity, handler, callback) { return new AmsTask(activity, handler, callback) {
public void doWork() throws RemoteException { public void doWork() throws RemoteException {
mService.addAcount(mResponse, accountType, authTokenType, mService.addAcount(mResponse, accountType, authTokenType,
@@ -389,44 +261,45 @@ public class AccountManager {
} }
/** @deprecated use {@link #confirmCredentials} instead */ /** @deprecated use {@link #confirmCredentials} instead */
public Future1<Boolean> confirmPassword(final Account account, final String password, public AccountManagerFuture<Boolean> confirmPassword(final Account account, final String password,
Future1Callback<Boolean> callback, Handler handler) { AccountManagerCallback<Boolean> callback, Handler handler) {
return new AMSTaskBoolean(handler, callback) { return new Future2Task<Boolean>(handler, callback) {
public void doWork() throws RemoteException { public void doWork() throws RemoteException {
mService.confirmPassword(response, account, password); mService.confirmPassword(mResponse, account, password);
} }
}; public Boolean bundleToResult(Bundle bundle) throws AuthenticatorException {
if (!bundle.containsKey(Constants.BOOLEAN_RESULT_KEY)) {
throw new AuthenticatorException("no result in response");
} }
return bundle.getBoolean(Constants.BOOLEAN_RESULT_KEY);
public Account[] blockingGetAccountsWithTypeAndFeatures(String type, String[] features)
throws AuthenticatorException, IOException, OperationCanceledException {
Future2 future = getAccountsWithTypeAndFeatures(type, features,
null /* callback */, null /* handler */);
Bundle result = future.getResult();
Parcelable[] accountsTemp = result.getParcelableArray(Constants.ACCOUNTS_KEY);
if (accountsTemp == null) {
throw new AuthenticatorException("accounts should not be null");
}
Account[] accounts = new Account[accountsTemp.length];
for (int i = 0; i < accountsTemp.length; i++) {
accounts[i] = (Account) accountsTemp[i];
}
return accounts;
}
public Future2 getAccountsWithTypeAndFeatures(
final String type, final String[] features,
Future2Callback callback, Handler handler) {
if (type == null) throw new IllegalArgumentException("type is null");
return new AmsTask(null /* activity */, handler, callback) {
public void doWork() throws RemoteException {
mService.getAccountsByTypeAndFeatures(mResponse, type, features);
} }
}.start(); }.start();
} }
public Future2 confirmCredentials(final Account account, final Activity activity, public AccountManagerFuture<Account[]> getAccountsByTypeAndFeatures(
final Future2Callback callback, final String type, final String[] features,
AccountManagerCallback<Account[]> callback, Handler handler) {
if (type == null) throw new IllegalArgumentException("type is null");
return new Future2Task<Account[]>(handler, callback) {
public void doWork() throws RemoteException {
mService.getAccountsByFeatures(mResponse, type, features);
}
public Account[] bundleToResult(Bundle bundle) throws AuthenticatorException {
if (!bundle.containsKey(Constants.ACCOUNTS_KEY)) {
throw new AuthenticatorException("no result in response");
}
final Parcelable[] parcelables = bundle.getParcelableArray(Constants.ACCOUNTS_KEY);
Account[] descs = new Account[parcelables.length];
for (int i = 0; i < parcelables.length; i++) {
descs[i] = (Account) parcelables[i];
}
return descs;
}
}.start();
}
public AccountManagerFuture<Bundle> confirmCredentials(final Account account, final Activity activity,
final AccountManagerCallback<Bundle> callback,
final Handler handler) { final Handler handler) {
return new AmsTask(activity, handler, callback) { return new AmsTask(activity, handler, callback) {
public void doWork() throws RemoteException { public void doWork() throws RemoteException {
@@ -435,9 +308,9 @@ public class AccountManager {
}.start(); }.start();
} }
public Future2 updateCredentials(final Account account, final String authTokenType, public AccountManagerFuture<Bundle> updateCredentials(final Account account, final String authTokenType,
final Bundle loginOptions, final Activity activity, final Bundle loginOptions, final Activity activity,
final Future2Callback callback, final AccountManagerCallback<Bundle> callback,
final Handler handler) { final Handler handler) {
return new AmsTask(activity, handler, callback) { return new AmsTask(activity, handler, callback) {
public void doWork() throws RemoteException { public void doWork() throws RemoteException {
@@ -447,8 +320,8 @@ public class AccountManager {
}.start(); }.start();
} }
public Future2 editProperties(final String accountType, final Activity activity, public AccountManagerFuture<Bundle> editProperties(final String accountType, final Activity activity,
final Future2Callback callback, final AccountManagerCallback<Bundle> callback,
final Handler handler) { final Handler handler) {
return new AmsTask(activity, handler, callback) { return new AmsTask(activity, handler, callback) {
public void doWork() throws RemoteException { public void doWork() throws RemoteException {
@@ -471,8 +344,8 @@ public class AccountManager {
} }
} }
private void postToHandler(Handler handler, final Future2Callback callback, private void postToHandler(Handler handler, final AccountManagerCallback<Bundle> callback,
final Future2 future) { final AccountManagerFuture<Bundle> future) {
handler = handler == null ? mMainHandler : handler; handler = handler == null ? mMainHandler : handler;
handler.post(new Runnable() { handler.post(new Runnable() {
public void run() { public void run() {
@@ -483,87 +356,24 @@ public class AccountManager {
private void postToHandler(Handler handler, final OnAccountsUpdatedListener listener, private void postToHandler(Handler handler, final OnAccountsUpdatedListener listener,
final Account[] accounts) { final Account[] accounts) {
handler = handler == null ? mMainHandler : handler; final Account[] accountsCopy = new Account[accounts.length];
// send a copy to make sure that one doesn't
// change what another sees
System.arraycopy(accounts, 0, accountsCopy, 0, accountsCopy.length);
handler = (handler == null) ? mMainHandler : handler;
handler.post(new Runnable() { handler.post(new Runnable() {
public void run() { public void run() {
listener.onAccountsUpdated(accounts); listener.onAccountsUpdated(accountsCopy);
} }
}); });
} }
private <V> void postToHandler(Handler handler, final Future1Callback<V> callback, private abstract class AmsTask extends FutureTask<Bundle> implements AccountManagerFuture<Bundle> {
final Future1<V> future) {
handler = handler == null ? mMainHandler : handler;
handler.post(new Runnable() {
public void run() {
callback.run(future);
}
});
}
private <V> Future1<V> startAsFuture(Future1Callback<V> callback, Handler handler,
Callable<V> callable) {
final FutureTaskWithCallback<V> task =
new FutureTaskWithCallback<V>(callback, callable, handler);
new Thread(task).start();
return task;
}
private class FutureTaskWithCallback<V> extends FutureTask<V> implements Future1<V> {
final Future1Callback<V> mCallback;
final Handler mHandler;
public FutureTaskWithCallback(Future1Callback<V> callback, Callable<V> callable,
Handler handler) {
super(callable);
mCallback = callback;
mHandler = handler;
}
protected void done() {
if (mCallback != null) {
postToHandler(mHandler, mCallback, this);
}
}
public V internalGetResult(Long timeout, TimeUnit unit) throws OperationCanceledException {
try {
if (timeout == null) {
return get();
} else {
return get(timeout, unit);
}
} catch (InterruptedException e) {
// we will cancel the task below
} catch (CancellationException e) {
// we will cancel the task below
} catch (TimeoutException e) {
// we will cancel the task below
} catch (ExecutionException e) {
// this should never happen
throw new IllegalStateException(e.getCause());
} finally {
cancel(true /* interruptIfRunning */);
}
throw new OperationCanceledException();
}
public V getResult() throws OperationCanceledException {
return internalGetResult(null, null);
}
public V getResult(long timeout, TimeUnit unit) throws OperationCanceledException {
return internalGetResult(null, null);
}
}
private abstract class AmsTask extends FutureTask<Bundle> implements Future2 {
final IAccountManagerResponse mResponse; final IAccountManagerResponse mResponse;
final Handler mHandler; final Handler mHandler;
final Future2Callback mCallback; final AccountManagerCallback<Bundle> mCallback;
final Activity mActivity; final Activity mActivity;
final Thread mThread; public AmsTask(Activity activity, Handler handler, AccountManagerCallback<Bundle> callback) {
public AmsTask(Activity activity, Handler handler, Future2Callback callback) {
super(new Callable<Bundle>() { super(new Callable<Bundle>() {
public Bundle call() throws Exception { public Bundle call() throws Exception {
throw new IllegalStateException("this should never be called"); throw new IllegalStateException("this should never be called");
@@ -574,19 +384,14 @@ public class AccountManager {
mCallback = callback; mCallback = callback;
mActivity = activity; mActivity = activity;
mResponse = new Response(); mResponse = new Response();
mThread = new Thread(new Runnable() { }
public void run() {
public final AccountManagerFuture<Bundle> start() {
try { try {
doWork(); doWork();
} catch (RemoteException e) { } catch (RemoteException e) {
// never happens setException(e);
} }
}
}, "AmsTask");
}
public final Future2 start() {
mThread.start();
return this; return this;
} }
@@ -594,6 +399,7 @@ public class AccountManager {
private Bundle internalGetResult(Long timeout, TimeUnit unit) private Bundle internalGetResult(Long timeout, TimeUnit unit)
throws OperationCanceledException, IOException, AuthenticatorException { throws OperationCanceledException, IOException, AuthenticatorException {
ensureNotOnMainThread();
try { try {
if (timeout == null) { if (timeout == null) {
return get(); return get();
@@ -676,92 +482,50 @@ public class AccountManager {
} }
private abstract class AMSTaskBoolean extends FutureTask<Boolean> implements Future1<Boolean> { private abstract class BaseFutureTask<T> extends FutureTask<T> {
final IAccountManagerResponse response; final public IAccountManagerResponse mResponse;
final Handler mHandler; final Handler mHandler;
final Future1Callback<Boolean> mCallback;
public AMSTaskBoolean(Handler handler, Future1Callback<Boolean> callback) { public BaseFutureTask(Handler handler) {
super(new Callable<Boolean>() { super(new Callable<T>() {
public Boolean call() throws Exception { public T call() throws Exception {
throw new IllegalStateException("this should never be called"); throw new IllegalStateException("this should never be called");
} }
}); });
mHandler = handler; mHandler = handler;
mCallback = callback; mResponse = new Response();
response = new Response();
new Thread(new Runnable() {
public void run() {
try {
doWork();
} catch (RemoteException e) {
// never happens
}
}
}).start();
} }
public abstract void doWork() throws RemoteException; public abstract void doWork() throws RemoteException;
public abstract T bundleToResult(Bundle bundle) throws AuthenticatorException;
protected void done() { protected void postRunnableToHandler(Runnable runnable) {
if (mCallback != null) { Handler handler = (mHandler == null) ? mMainHandler : mHandler;
postToHandler(mHandler, mCallback, this); handler.post(runnable);
}
} }
private Boolean internalGetResult(Long timeout, TimeUnit unit) { protected void startTask() {
try { try {
if (timeout == null) { doWork();
return get(); } catch (RemoteException e) {
} else { setException(e);
return get(timeout, unit);
} }
} catch (InterruptedException e) {
// fall through and cancel
} catch (TimeoutException e) {
// fall through and cancel
} catch (CancellationException e) {
return false;
} catch (ExecutionException e) {
final Throwable cause = e.getCause();
if (cause instanceof IOException) {
return false;
} else if (cause instanceof UnsupportedOperationException) {
return false;
} else if (cause instanceof AuthenticatorException) {
return false;
} else if (cause instanceof RuntimeException) {
throw (RuntimeException) cause;
} else if (cause instanceof Error) {
throw (Error) cause;
} else {
throw new IllegalStateException(cause);
}
} finally {
cancel(true /* interrupt if running */);
}
return false;
} }
public Boolean getResult() throws OperationCanceledException { protected class Response extends IAccountManagerResponse.Stub {
return internalGetResult(null, null);
}
public Boolean getResult(long timeout, TimeUnit unit) throws OperationCanceledException {
return internalGetResult(timeout, unit);
}
private class Response extends IAccountManagerResponse.Stub {
public void onResult(Bundle bundle) { public void onResult(Bundle bundle) {
try { try {
if (bundle.containsKey(Constants.BOOLEAN_RESULT_KEY)) { T result = bundleToResult(bundle);
set(bundle.getBoolean(Constants.BOOLEAN_RESULT_KEY)); if (result == null) {
return; return;
} }
set(result);
return;
} catch (ClassCastException e) { } catch (ClassCastException e) {
// we will set the exception below // we will set the exception below
} catch (AuthenticatorException e) {
// we will set the exception below
} }
onError(Constants.ERROR_CODE_INVALID_RESPONSE, "no result in response"); onError(Constants.ERROR_CODE_INVALID_RESPONSE, "no result in response");
} }
@@ -774,6 +538,76 @@ public class AccountManager {
setException(convertErrorToException(code, message)); setException(convertErrorToException(code, message));
} }
} }
}
private abstract class Future2Task<T>
extends BaseFutureTask<T> implements AccountManagerFuture<T> {
final AccountManagerCallback<T> mCallback;
public Future2Task(Handler handler, AccountManagerCallback<T> callback) {
super(handler);
mCallback = callback;
}
protected void done() {
if (mCallback != null) {
postRunnableToHandler(new Runnable() {
public void run() {
mCallback.run(Future2Task.this);
}
});
}
}
public Future2Task<T> start() {
startTask();
return this;
}
private T internalGetResult(Long timeout, TimeUnit unit)
throws OperationCanceledException, IOException, AuthenticatorException {
ensureNotOnMainThread();
try {
if (timeout == null) {
return get();
} else {
return get(timeout, unit);
}
} catch (InterruptedException e) {
// fall through and cancel
} catch (TimeoutException e) {
// fall through and cancel
} catch (CancellationException e) {
// fall through and cancel
} catch (ExecutionException e) {
final Throwable cause = e.getCause();
if (cause instanceof IOException) {
throw (IOException) cause;
} else if (cause instanceof UnsupportedOperationException) {
throw new AuthenticatorException(cause);
} else if (cause instanceof AuthenticatorException) {
throw (AuthenticatorException) cause;
} else if (cause instanceof RuntimeException) {
throw (RuntimeException) cause;
} else if (cause instanceof Error) {
throw (Error) cause;
} else {
throw new IllegalStateException(cause);
}
} finally {
cancel(true /* interrupt if running */);
}
throw new OperationCanceledException();
}
public T getResult()
throws OperationCanceledException, IOException, AuthenticatorException {
return internalGetResult(null, null);
}
public T getResult(long timeout, TimeUnit unit)
throws OperationCanceledException, IOException, AuthenticatorException {
return internalGetResult(timeout, unit);
}
} }
@@ -797,11 +631,12 @@ public class AccountManager {
return new AuthenticatorException(message); return new AuthenticatorException(message);
} }
private class GetAuthTokenByTypeAndFeaturesTask extends AmsTask implements Future2Callback { private class GetAuthTokenByTypeAndFeaturesTask
extends AmsTask implements AccountManagerCallback<Bundle> {
GetAuthTokenByTypeAndFeaturesTask(final String accountType, final String authTokenType, GetAuthTokenByTypeAndFeaturesTask(final String accountType, final String authTokenType,
final String[] features, Activity activityForPrompting, final String[] features, Activity activityForPrompting,
final Bundle addAccountOptions, final Bundle loginOptions, final Bundle addAccountOptions, final Bundle loginOptions,
Future2Callback callback, Handler handler) { AccountManagerCallback<Bundle> callback, Handler handler) {
super(activityForPrompting, handler, callback); super(activityForPrompting, handler, callback);
if (accountType == null) throw new IllegalArgumentException("account type is null"); if (accountType == null) throw new IllegalArgumentException("account type is null");
mAccountType = accountType; mAccountType = accountType;
@@ -811,20 +646,21 @@ public class AccountManager {
mLoginOptions = loginOptions; mLoginOptions = loginOptions;
mMyCallback = this; mMyCallback = this;
} }
volatile Future2 mFuture = null; volatile AccountManagerFuture<Bundle> mFuture = null;
final String mAccountType; final String mAccountType;
final String mAuthTokenType; final String mAuthTokenType;
final String[] mFeatures; final String[] mFeatures;
final Bundle mAddAccountOptions; final Bundle mAddAccountOptions;
final Bundle mLoginOptions; final Bundle mLoginOptions;
final Future2Callback mMyCallback; final AccountManagerCallback<Bundle> mMyCallback;
public void doWork() throws RemoteException { public void doWork() throws RemoteException {
getAccountsWithTypeAndFeatures(mAccountType, mFeatures, new Future2Callback() { getAccountsByTypeAndFeatures(mAccountType, mFeatures,
public void run(Future2 future) { new AccountManagerCallback<Account[]>() {
Bundle getAccountsResult; public void run(AccountManagerFuture<Account[]> future) {
Account[] accounts;
try { try {
getAccountsResult = future.getResult(); accounts = future.getResult();
} catch (OperationCanceledException e) { } catch (OperationCanceledException e) {
setException(e); setException(e);
return; return;
@@ -836,8 +672,6 @@ public class AccountManager {
return; return;
} }
Parcelable[] accounts =
getAccountsResult.getParcelableArray(Constants.ACCOUNTS_KEY);
if (accounts.length == 0) { if (accounts.length == 0) {
if (mActivity != null) { if (mActivity != null) {
// no accounts, add one now. pretend that the user directly // no accounts, add one now. pretend that the user directly
@@ -860,10 +694,10 @@ public class AccountManager {
} else if (accounts.length == 1) { } else if (accounts.length == 1) {
// have a single account, return an authtoken for it // have a single account, return an authtoken for it
if (mActivity == null) { if (mActivity == null) {
mFuture = getAuthToken((Account) accounts[0], mAuthTokenType, mFuture = getAuthToken(accounts[0], mAuthTokenType,
false /* notifyAuthFailure */, mMyCallback, mHandler); false /* notifyAuthFailure */, mMyCallback, mHandler);
} else { } else {
mFuture = getAuthToken((Account) accounts[0], mFuture = getAuthToken(accounts[0],
mAuthTokenType, mLoginOptions, mAuthTokenType, mLoginOptions,
mActivity, mMyCallback, mHandler); mActivity, mMyCallback, mHandler);
} }
@@ -915,7 +749,7 @@ public class AccountManager {
// or to cause this to be canceled if mFuture isn't set. // or to cause this to be canceled if mFuture isn't set.
// Once this is done then getAuthTokenByFeatures can be changed to return a Future2. // Once this is done then getAuthTokenByFeatures can be changed to return a Future2.
public void run(Future2 future) { public void run(AccountManagerFuture<Bundle> future) {
try { try {
set(future.get()); set(future.get());
} catch (InterruptedException e) { } catch (InterruptedException e) {
@@ -932,7 +766,7 @@ public class AccountManager {
final String accountType, final String authTokenType, final String[] features, final String accountType, final String authTokenType, final String[] features,
final Activity activityForPrompting, final Bundle addAccountOptions, final Activity activityForPrompting, final Bundle addAccountOptions,
final Bundle loginOptions, final Bundle loginOptions,
final Future2Callback callback, final Handler handler) { final AccountManagerCallback<Bundle> callback, final Handler handler) {
if (accountType == null) throw new IllegalArgumentException("account type is null"); if (accountType == null) throw new IllegalArgumentException("account type is null");
if (authTokenType == null) throw new IllegalArgumentException("authTokenType is null"); if (authTokenType == null) throw new IllegalArgumentException("authTokenType is null");
new GetAuthTokenByTypeAndFeaturesTask(accountType, authTokenType, features, new GetAuthTokenByTypeAndFeaturesTask(accountType, authTokenType, features,
@@ -942,13 +776,6 @@ public class AccountManager {
private final HashMap<OnAccountsUpdatedListener, Handler> mAccountsUpdatedListeners = private final HashMap<OnAccountsUpdatedListener, Handler> mAccountsUpdatedListeners =
Maps.newHashMap(); Maps.newHashMap();
// These variable are only used from the LOGIN_ACCOUNTS_CHANGED_ACTION BroadcastReceiver
// and its getAccounts() callback which are both invoked only on the main thread. As a
// result we don't need to protect against concurrent accesses and any changes are guaranteed
// to be visible when used. Basically, these two variables are thread-confined.
private Future1<Account[]> mAccountsLookupFuture = null;
private boolean mAccountLookupPending = false;
/** /**
* BroadcastReceiver that listens for the LOGIN_ACCOUNTS_CHANGED_ACTION intent * BroadcastReceiver that listens for the LOGIN_ACCOUNTS_CHANGED_ACTION intent
* so that it can read the updated list of accounts and send them to the listener * so that it can read the updated list of accounts and send them to the listener
@@ -956,58 +783,14 @@ public class AccountManager {
*/ */
private final BroadcastReceiver mAccountsChangedBroadcastReceiver = new BroadcastReceiver() { private final BroadcastReceiver mAccountsChangedBroadcastReceiver = new BroadcastReceiver() {
public void onReceive(final Context context, final Intent intent) { public void onReceive(final Context context, final Intent intent) {
if (mAccountsLookupFuture != null) { final Account[] accounts = getAccounts();
// an accounts lookup is already in progress,
// don't bother starting another request
mAccountLookupPending = true;
return;
}
// initiate a read of the accounts
mAccountsLookupFuture = getAccounts(new Future1Callback<Account[]>() {
public void run(Future1<Account[]> future) {
// clear the future so that future receives will try the lookup again
mAccountsLookupFuture = null;
// get the accounts array
Account[] accounts;
try {
accounts = future.getResult();
} catch (OperationCanceledException e) {
// this should never happen, but if it does pretend we got another
// accounts changed broadcast
if (Config.LOGD) {
Log.d(TAG, "the accounts lookup for listener notifications was "
+ "canceled, try again by simulating the receipt of "
+ "a LOGIN_ACCOUNTS_CHANGED_ACTION broadcast");
}
onReceive(context, intent);
return;
}
// send the result to the listeners // send the result to the listeners
synchronized (mAccountsUpdatedListeners) { synchronized (mAccountsUpdatedListeners) {
for (Map.Entry<OnAccountsUpdatedListener, Handler> entry : for (Map.Entry<OnAccountsUpdatedListener, Handler> entry :
mAccountsUpdatedListeners.entrySet()) { mAccountsUpdatedListeners.entrySet()) {
Account[] accountsCopy = new Account[accounts.length]; postToHandler(entry.getValue(), entry.getKey(), accounts);
// send the listeners a copy to make sure that one doesn't
// change what another sees
System.arraycopy(accounts, 0, accountsCopy, 0, accountsCopy.length);
postToHandler(entry.getValue(), entry.getKey(), accountsCopy);
} }
} }
// If mAccountLookupPending was set when the account lookup finished it
// means that we had previously ignored a LOGIN_ACCOUNTS_CHANGED_ACTION
// intent because a lookup was already in progress. Now that we are done
// with this lookup and notification pretend that another intent
// was received by calling onReceive() directly.
if (mAccountLookupPending) {
mAccountLookupPending = false;
onReceive(context, intent);
return;
}
}
}, mMainHandler);
} }
}; };
@@ -1045,15 +828,7 @@ public class AccountManager {
} }
if (updateImmediately) { if (updateImmediately) {
getAccounts(new Future1Callback<Account[]>() { postToHandler(handler, listener, getAccounts());
public void run(Future1<Account[]> future) {
try {
listener.onAccountsUpdated(future.getResult());
} catch (OperationCanceledException e) {
// ignore
}
}
}, handler);
} }
} }

View File

@@ -15,6 +15,6 @@
*/ */
package android.accounts; package android.accounts;
public interface Future1Callback<V> { public interface AccountManagerCallback<V> {
void run(Future1<V> future); void run(AccountManagerFuture<V> future);
} }

View File

@@ -0,0 +1,65 @@
/*
* Copyright (C) 2009 The Android Open Source Project
*
* 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 android.accounts;
import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeoutException;
import java.io.IOException;
/**
* An extension of {@link java.util.concurrent.Future} that provides wrappers for {@link #get()}
* that handle the various
* exceptions that {@link #get()} may return and rethrows them as exceptions specific to
* {@link android.accounts.AccountManager}.
*/
public interface AccountManagerFuture<V> extends Future<V> {
/**
* Wrapper for {@link java.util.concurrent.Future#get()}. If the get() throws
* {@link InterruptedException} then the
* {@link AccountManagerFuture} is canceled and
* {@link android.accounts.OperationCanceledException} is thrown.
* @return the {@link android.os.Bundle} that is returned by get()
* @throws android.accounts.OperationCanceledException if get() throws the unchecked
* CancellationException
* or if the Future was interrupted.
*/
V getResult() throws OperationCanceledException, IOException, AuthenticatorException;
/**
* Wrapper for {@link java.util.concurrent.Future#get()}. If the get() throws
* {@link InterruptedException} then the
* {@link AccountManagerFuture} is canceled and
* {@link android.accounts.OperationCanceledException} is thrown.
* @param timeout the maximum time to wait
* @param unit the time unit of the timeout argument
* @return the {@link android.os.Bundle} that is returned by
* {@link java.util.concurrent.Future#get()}
* @throws android.accounts.OperationCanceledException if get() throws the unchecked
* {@link java.util.concurrent.CancellationException} or if the {@link AccountManagerFuture}
* was interrupted.
*/
V getResult(long timeout, TimeUnit unit)
throws OperationCanceledException, IOException, AuthenticatorException;
@Deprecated
V get() throws InterruptedException, ExecutionException;
@Deprecated
V get(long timeout, TimeUnit unit)
throws InterruptedException, ExecutionException, TimeoutException;
}

View File

@@ -214,10 +214,17 @@ public class AccountManagerService extends IAccountManager.Stub {
long identityToken = clearCallingIdentity(); long identityToken = clearCallingIdentity();
try { try {
return readPasswordFromDatabase(account);
} finally {
restoreCallingIdentity(identityToken);
}
}
private String readPasswordFromDatabase(Account account) {
SQLiteDatabase db = mOpenHelper.getReadableDatabase(); SQLiteDatabase db = mOpenHelper.getReadableDatabase();
Cursor cursor = db.query(TABLE_ACCOUNTS, new String[]{ACCOUNTS_PASSWORD}, Cursor cursor = db.query(TABLE_ACCOUNTS, new String[]{ACCOUNTS_PASSWORD},
ACCOUNTS_NAME + "=? AND " + ACCOUNTS_TYPE+ "=?", ACCOUNTS_NAME + "=? AND " + ACCOUNTS_TYPE+ "=?",
new String[]{account.mName, account.mType}, null, null, null); new String[]{account.name, account.type}, null, null, null);
try { try {
if (cursor.moveToNext()) { if (cursor.moveToNext()) {
return cursor.getString(0); return cursor.getString(0);
@@ -226,15 +233,19 @@ public class AccountManagerService extends IAccountManager.Stub {
} finally { } finally {
cursor.close(); cursor.close();
} }
} finally {
restoreCallingIdentity(identityToken);
}
} }
public String getUserData(Account account, String key) { public String getUserData(Account account, String key) {
checkAuthenticateAccountsPermission(account); checkAuthenticateAccountsPermission(account);
long identityToken = clearCallingIdentity(); long identityToken = clearCallingIdentity();
try { try {
return readUserDataFromDatabase(account, key);
} finally {
restoreCallingIdentity(identityToken);
}
}
private String readUserDataFromDatabase(Account account, String key) {
SQLiteDatabase db = mOpenHelper.getReadableDatabase(); SQLiteDatabase db = mOpenHelper.getReadableDatabase();
db.beginTransaction(); db.beginTransaction();
try { try {
@@ -256,9 +267,6 @@ public class AccountManagerService extends IAccountManager.Stub {
} finally { } finally {
db.endTransaction(); db.endTransaction();
} }
} finally {
restoreCallingIdentity(identityToken);
}
} }
public AuthenticatorDescription[] getAuthenticatorTypes() { public AuthenticatorDescription[] getAuthenticatorTypes() {
@@ -280,20 +288,7 @@ public class AccountManagerService extends IAccountManager.Stub {
} }
} }
public Account[] getAccounts() {
checkReadAccountsPermission();
long identityToken = clearCallingIdentity();
try {
return getAccountsByType(null);
} finally {
restoreCallingIdentity(identityToken);
}
}
public Account[] getAccountsByType(String accountType) { public Account[] getAccountsByType(String accountType) {
checkReadAccountsPermission();
long identityToken = clearCallingIdentity();
try {
SQLiteDatabase db = mOpenHelper.getReadableDatabase(); SQLiteDatabase db = mOpenHelper.getReadableDatabase();
final String selection = accountType == null ? null : (ACCOUNTS_TYPE + "=?"); final String selection = accountType == null ? null : (ACCOUNTS_TYPE + "=?");
@@ -311,9 +306,6 @@ public class AccountManagerService extends IAccountManager.Stub {
} finally { } finally {
cursor.close(); cursor.close();
} }
} finally {
restoreCallingIdentity(identityToken);
}
} }
public boolean addAccount(Account account, String password, Bundle extras) { public boolean addAccount(Account account, String password, Bundle extras) {
@@ -322,19 +314,26 @@ public class AccountManagerService extends IAccountManager.Stub {
// fails if the account already exists // fails if the account already exists
long identityToken = clearCallingIdentity(); long identityToken = clearCallingIdentity();
try { try {
return insertAccountIntoDatabase(account, password, extras);
} finally {
restoreCallingIdentity(identityToken);
}
}
private boolean insertAccountIntoDatabase(Account account, String password, Bundle extras) {
SQLiteDatabase db = mOpenHelper.getWritableDatabase(); SQLiteDatabase db = mOpenHelper.getWritableDatabase();
db.beginTransaction(); db.beginTransaction();
try { try {
long numMatches = DatabaseUtils.longForQuery(db, long numMatches = DatabaseUtils.longForQuery(db,
"select count(*) from " + TABLE_ACCOUNTS "select count(*) from " + TABLE_ACCOUNTS
+ " WHERE " + ACCOUNTS_NAME + "=? AND " + ACCOUNTS_TYPE+ "=?", + " WHERE " + ACCOUNTS_NAME + "=? AND " + ACCOUNTS_TYPE+ "=?",
new String[]{account.mName, account.mType}); new String[]{account.name, account.type});
if (numMatches > 0) { if (numMatches > 0) {
return false; return false;
} }
ContentValues values = new ContentValues(); ContentValues values = new ContentValues();
values.put(ACCOUNTS_NAME, account.mName); values.put(ACCOUNTS_NAME, account.name);
values.put(ACCOUNTS_TYPE, account.mType); values.put(ACCOUNTS_TYPE, account.type);
values.put(ACCOUNTS_PASSWORD, password); values.put(ACCOUNTS_PASSWORD, password);
long accountId = db.insert(TABLE_ACCOUNTS, ACCOUNTS_NAME, values); long accountId = db.insert(TABLE_ACCOUNTS, ACCOUNTS_NAME, values);
if (accountId < 0) { if (accountId < 0) {
@@ -354,9 +353,6 @@ public class AccountManagerService extends IAccountManager.Stub {
} finally { } finally {
db.endTransaction(); db.endTransaction();
} }
} finally {
restoreCallingIdentity(identityToken);
}
} }
private long insertExtra(SQLiteDatabase db, long accountId, String key, String value) { private long insertExtra(SQLiteDatabase db, long accountId, String key, String value) {
@@ -367,19 +363,61 @@ public class AccountManagerService extends IAccountManager.Stub {
return db.insert(TABLE_EXTRAS, EXTRAS_KEY, values); return db.insert(TABLE_EXTRAS, EXTRAS_KEY, values);
} }
public void removeAccount(Account account) { public void removeAccount(IAccountManagerResponse response, Account account) {
checkManageAccountsPermission(); checkManageAccountsPermission();
long identityToken = clearCallingIdentity(); long identityToken = clearCallingIdentity();
try { try {
final SQLiteDatabase db = mOpenHelper.getWritableDatabase(); new RemoveAccountSession(response, account).bind();
db.delete(TABLE_ACCOUNTS, ACCOUNTS_NAME + "=? AND " + ACCOUNTS_TYPE+ "=?",
new String[]{account.mName, account.mType});
sendAccountsChangedBroadcast();
} finally { } finally {
restoreCallingIdentity(identityToken); restoreCallingIdentity(identityToken);
} }
} }
private class RemoveAccountSession extends Session {
final Account mAccount;
public RemoveAccountSession(IAccountManagerResponse response, Account account) {
super(response, account.type, false /* expectActivityLaunch */);
mAccount = account;
}
protected String toDebugString(long now) {
return super.toDebugString(now) + ", removeAccount"
+ ", account " + mAccount;
}
public void run() throws RemoteException {
mAuthenticator.getAccountRemovalAllowed(this, mAccount);
}
public void onResult(Bundle result) {
if (result != null && result.containsKey(Constants.BOOLEAN_RESULT_KEY)
&& !result.containsKey(Constants.INTENT_KEY)) {
final boolean removalAllowed = result.getBoolean(Constants.BOOLEAN_RESULT_KEY);
if (removalAllowed) {
removeAccount(mAccount);
}
IAccountManagerResponse response = getResponseAndClose();
if (response != null) {
Bundle result2 = new Bundle();
result2.putBoolean(Constants.BOOLEAN_RESULT_KEY, removalAllowed);
try {
response.onResult(result2);
} catch (RemoteException e) {
// ignore
}
}
}
super.onResult(result);
}
}
private void removeAccount(Account account) {
final SQLiteDatabase db = mOpenHelper.getWritableDatabase();
db.delete(TABLE_ACCOUNTS, ACCOUNTS_NAME + "=? AND " + ACCOUNTS_TYPE+ "=?",
new String[]{account.name, account.type});
sendAccountsChangedBroadcast();
}
public void invalidateAuthToken(String accountType, String authToken) { public void invalidateAuthToken(String accountType, String authToken) {
checkManageAccountsPermission(); checkManageAccountsPermission();
long identityToken = clearCallingIdentity(); long identityToken = clearCallingIdentity();
@@ -398,6 +436,9 @@ public class AccountManagerService extends IAccountManager.Stub {
} }
private void invalidateAuthToken(SQLiteDatabase db, String accountType, String authToken) { private void invalidateAuthToken(SQLiteDatabase db, String accountType, String authToken) {
if (authToken == null || accountType == null) {
return;
}
Cursor cursor = db.rawQuery( Cursor cursor = db.rawQuery(
"SELECT " + TABLE_AUTHTOKENS + "." + AUTHTOKENS_ID "SELECT " + TABLE_AUTHTOKENS + "." + AUTHTOKENS_ID
+ ", " + TABLE_ACCOUNTS + "." + ACCOUNTS_NAME + ", " + TABLE_ACCOUNTS + "." + ACCOUNTS_NAME
@@ -488,7 +529,7 @@ public class AccountManagerService extends IAccountManager.Stub {
values.put(ACCOUNTS_PASSWORD, password); values.put(ACCOUNTS_PASSWORD, password);
mOpenHelper.getWritableDatabase().update(TABLE_ACCOUNTS, values, mOpenHelper.getWritableDatabase().update(TABLE_ACCOUNTS, values,
ACCOUNTS_NAME + "=? AND " + ACCOUNTS_TYPE+ "=?", ACCOUNTS_NAME + "=? AND " + ACCOUNTS_TYPE+ "=?",
new String[]{account.mName, account.mType}); new String[]{account.name, account.type});
sendAccountsChangedBroadcast(); sendAccountsChangedBroadcast();
} finally { } finally {
restoreCallingIdentity(identityToken); restoreCallingIdentity(identityToken);
@@ -509,10 +550,31 @@ public class AccountManagerService extends IAccountManager.Stub {
} }
} }
private void sendResult(IAccountManagerResponse response, Bundle bundle) {
if (response != null) {
try {
response.onResult(bundle);
} catch (RemoteException e) {
// if the caller is dead then there is no one to care about remote
// exceptions
if (Log.isLoggable(TAG, Log.VERBOSE)) {
Log.v(TAG, "failure while notifying response", e);
}
}
}
}
public void setUserData(Account account, String key, String value) { public void setUserData(Account account, String key, String value) {
checkAuthenticateAccountsPermission(account); checkAuthenticateAccountsPermission(account);
long identityToken = clearCallingIdentity(); long identityToken = clearCallingIdentity();
try { try {
writeUserdataIntoDatabase(account, key, value);
} finally {
restoreCallingIdentity(identityToken);
}
}
private void writeUserdataIntoDatabase(Account account, String key, String value) {
SQLiteDatabase db = mOpenHelper.getWritableDatabase(); SQLiteDatabase db = mOpenHelper.getWritableDatabase();
db.beginTransaction(); db.beginTransaction();
try { try {
@@ -538,9 +600,6 @@ public class AccountManagerService extends IAccountManager.Stub {
} finally { } finally {
db.endTransaction(); db.endTransaction();
} }
} finally {
restoreCallingIdentity(identityToken);
}
} }
private void onResult(IAccountManagerResponse response, Bundle result) { private void onResult(IAccountManagerResponse response, Bundle result) {
@@ -571,14 +630,14 @@ public class AccountManagerService extends IAccountManager.Stub {
if (authToken != null) { if (authToken != null) {
Bundle result = new Bundle(); Bundle result = new Bundle();
result.putString(Constants.AUTHTOKEN_KEY, authToken); result.putString(Constants.AUTHTOKEN_KEY, authToken);
result.putString(Constants.ACCOUNT_NAME_KEY, account.mName); result.putString(Constants.ACCOUNT_NAME_KEY, account.name);
result.putString(Constants.ACCOUNT_TYPE_KEY, account.mType); result.putString(Constants.ACCOUNT_TYPE_KEY, account.type);
onResult(response, result); onResult(response, result);
return; return;
} }
} }
new Session(response, account.mType, expectActivityLaunch) { new Session(response, account.type, expectActivityLaunch) {
protected String toDebugString(long now) { protected String toDebugString(long now) {
if (loginOptions != null) loginOptions.keySet(); if (loginOptions != null) loginOptions.keySet();
return super.toDebugString(now) + ", getAuthToken" return super.toDebugString(now) + ", getAuthToken"
@@ -651,7 +710,7 @@ public class AccountManagerService extends IAccountManager.Stub {
mContext.getText(R.string.permission_request_notification_subtitle); mContext.getText(R.string.permission_request_notification_subtitle);
n.setLatestEventInfo(mContext, n.setLatestEventInfo(mContext,
mContext.getText(R.string.permission_request_notification_title), mContext.getText(R.string.permission_request_notification_title),
String.format(subtitleFormatString.toString(), account.mName), String.format(subtitleFormatString.toString(), account.name),
PendingIntent.getActivity(mContext, 0, intent, PendingIntent.FLAG_CANCEL_CURRENT)); PendingIntent.getActivity(mContext, 0, intent, PendingIntent.FLAG_CANCEL_CURRENT));
((NotificationManager) mContext.getSystemService(Context.NOTIFICATION_SERVICE)) ((NotificationManager) mContext.getSystemService(Context.NOTIFICATION_SERVICE))
.notify(getCredentialPermissionNotificationId(account, authTokenType, uid), n); .notify(getCredentialPermissionNotificationId(account, authTokenType, uid), n);
@@ -661,9 +720,9 @@ public class AccountManagerService extends IAccountManager.Stub {
AccountAuthenticatorResponse response, String authTokenType, String authTokenLabel) { AccountAuthenticatorResponse response, String authTokenType, String authTokenLabel) {
RegisteredServicesCache.ServiceInfo<AuthenticatorDescription> serviceInfo = RegisteredServicesCache.ServiceInfo<AuthenticatorDescription> serviceInfo =
mAuthenticatorCache.getServiceInfo( mAuthenticatorCache.getServiceInfo(
AuthenticatorDescription.newKey(account.mType)); AuthenticatorDescription.newKey(account.type));
if (serviceInfo == null) { if (serviceInfo == null) {
throw new IllegalArgumentException("unknown account type: " + account.mType); throw new IllegalArgumentException("unknown account type: " + account.type);
} }
final Context authContext; final Context authContext;
@@ -671,7 +730,7 @@ public class AccountManagerService extends IAccountManager.Stub {
authContext = mContext.createPackageContext( authContext = mContext.createPackageContext(
serviceInfo.type.packageName, 0); serviceInfo.type.packageName, 0);
} catch (PackageManager.NameNotFoundException e) { } catch (PackageManager.NameNotFoundException e) {
throw new IllegalArgumentException("unknown account type: " + account.mType); throw new IllegalArgumentException("unknown account type: " + account.type);
} }
Intent intent = new Intent(mContext, GrantCredentialsPermissionActivity.class); Intent intent = new Intent(mContext, GrantCredentialsPermissionActivity.class);
@@ -750,7 +809,7 @@ public class AccountManagerService extends IAccountManager.Stub {
checkManageAccountsPermission(); checkManageAccountsPermission();
long identityToken = clearCallingIdentity(); long identityToken = clearCallingIdentity();
try { try {
new Session(response, account.mType, expectActivityLaunch) { new Session(response, account.type, expectActivityLaunch) {
public void run() throws RemoteException { public void run() throws RemoteException {
mAuthenticator.confirmCredentials(this, account); mAuthenticator.confirmCredentials(this, account);
} }
@@ -769,7 +828,7 @@ public class AccountManagerService extends IAccountManager.Stub {
checkManageAccountsPermission(); checkManageAccountsPermission();
long identityToken = clearCallingIdentity(); long identityToken = clearCallingIdentity();
try { try {
new Session(response, account.mType, false /* expectActivityLaunch */) { new Session(response, account.type, false /* expectActivityLaunch */) {
public void run() throws RemoteException { public void run() throws RemoteException {
mAuthenticator.confirmPassword(this, account, password); mAuthenticator.confirmPassword(this, account, password);
} }
@@ -789,7 +848,7 @@ public class AccountManagerService extends IAccountManager.Stub {
checkManageAccountsPermission(); checkManageAccountsPermission();
long identityToken = clearCallingIdentity(); long identityToken = clearCallingIdentity();
try { try {
new Session(response, account.mType, expectActivityLaunch) { new Session(response, account.type, expectActivityLaunch) {
public void run() throws RemoteException { public void run() throws RemoteException {
mAuthenticator.updateCredentials(this, account, authTokenType, loginOptions); mAuthenticator.updateCredentials(this, account, authTokenType, loginOptions);
} }
@@ -898,10 +957,21 @@ public class AccountManagerService extends IAccountManager.Stub {
+ ", " + (mFeatures != null ? TextUtils.join(",", mFeatures) : null); + ", " + (mFeatures != null ? TextUtils.join(",", mFeatures) : null);
} }
} }
public void getAccountsByTypeAndFeatures(IAccountManagerResponse response,
public Account[] getAccounts(String type) {
checkReadAccountsPermission();
long identityToken = clearCallingIdentity();
try {
return getAccountsByType(type);
} finally {
restoreCallingIdentity(identityToken);
}
}
public void getAccountsByFeatures(IAccountManagerResponse response,
String type, String[] features) { String type, String[] features) {
checkReadAccountsPermission(); checkReadAccountsPermission();
if (type == null) { if (features != null && type == null) {
if (response != null) { if (response != null) {
try { try {
response.onError(Constants.ERROR_CODE_BAD_ARGUMENTS, "type is null"); response.onError(Constants.ERROR_CODE_BAD_ARGUMENTS, "type is null");
@@ -913,6 +983,10 @@ public class AccountManagerService extends IAccountManager.Stub {
} }
long identityToken = clearCallingIdentity(); long identityToken = clearCallingIdentity();
try { try {
if (features == null || features.length == 0) {
getAccountsByType(type);
return;
}
new GetAccountsByTypeAndFeatureSession(response, type, features).bind(); new GetAccountsByTypeAndFeatureSession(response, type, features).bind();
} finally { } finally {
restoreCallingIdentity(identityToken); restoreCallingIdentity(identityToken);
@@ -925,7 +999,7 @@ public class AccountManagerService extends IAccountManager.Stub {
private long getAccountId(SQLiteDatabase db, Account account) { private long getAccountId(SQLiteDatabase db, Account account) {
Cursor cursor = db.query(TABLE_ACCOUNTS, new String[]{ACCOUNTS_ID}, Cursor cursor = db.query(TABLE_ACCOUNTS, new String[]{ACCOUNTS_ID},
"name=? AND type=?", new String[]{account.mName, account.mType}, null, null, null); "name=? AND type=?", new String[]{account.name, account.type}, null, null, null);
try { try {
if (cursor.moveToNext()) { if (cursor.moveToNext()) {
return cursor.getLong(0); return cursor.getLong(0);
@@ -1401,7 +1475,7 @@ public class AccountManagerService extends IAccountManager.Stub {
} }
private boolean permissionIsGranted(Account account, String authTokenType, int callerUid) { private boolean permissionIsGranted(Account account, String authTokenType, int callerUid) {
final boolean fromAuthenticator = hasAuthenticatorUid(account.mType, callerUid); final boolean fromAuthenticator = hasAuthenticatorUid(account.type, callerUid);
final boolean hasExplicitGrants = hasExplicitlyGrantedPermission(account, authTokenType); final boolean hasExplicitGrants = hasExplicitlyGrantedPermission(account, authTokenType);
if (Log.isLoggable(TAG, Log.VERBOSE)) { if (Log.isLoggable(TAG, Log.VERBOSE)) {
Log.v(TAG, "checkGrantsOrCallingUidAgainstAuthenticator: caller uid " Log.v(TAG, "checkGrantsOrCallingUidAgainstAuthenticator: caller uid "
@@ -1416,7 +1490,9 @@ public class AccountManagerService extends IAccountManager.Stub {
for (RegisteredServicesCache.ServiceInfo<AuthenticatorDescription> serviceInfo : for (RegisteredServicesCache.ServiceInfo<AuthenticatorDescription> serviceInfo :
mAuthenticatorCache.getAllServices()) { mAuthenticatorCache.getAllServices()) {
if (serviceInfo.type.type.equals(accountType)) { if (serviceInfo.type.type.equals(accountType)) {
return serviceInfo.uid == callingUid; return (serviceInfo.uid == callingUid) ||
(mContext.getPackageManager().checkSignatures(serviceInfo.uid, callingUid)
== PackageManager.SIGNATURE_MATCH);
} }
} }
return false; return false;
@@ -1428,7 +1504,7 @@ public class AccountManagerService extends IAccountManager.Stub {
} }
SQLiteDatabase db = mOpenHelper.getReadableDatabase(); SQLiteDatabase db = mOpenHelper.getReadableDatabase();
String[] args = {String.valueOf(Binder.getCallingUid()), authTokenType, String[] args = {String.valueOf(Binder.getCallingUid()), authTokenType,
account.mName, account.mType}; account.name, account.type};
final boolean permissionGranted = final boolean permissionGranted =
DatabaseUtils.longForQuery(db, COUNT_OF_MATCHING_GRANTS, args) != 0; DatabaseUtils.longForQuery(db, COUNT_OF_MATCHING_GRANTS, args) != 0;
if (!permissionGranted && isDebuggableMonkeyBuild) { if (!permissionGranted && isDebuggableMonkeyBuild) {
@@ -1444,7 +1520,7 @@ public class AccountManagerService extends IAccountManager.Stub {
private void checkCallingUidAgainstAuthenticator(Account account) { private void checkCallingUidAgainstAuthenticator(Account account) {
final int uid = Binder.getCallingUid(); final int uid = Binder.getCallingUid();
if (!hasAuthenticatorUid(account.mType, uid)) { if (!hasAuthenticatorUid(account.type, uid)) {
String msg = "caller uid " + uid + " is different than the authenticator's uid"; String msg = "caller uid " + uid + " is different than the authenticator's uid";
Log.w(TAG, msg); Log.w(TAG, msg);
throw new SecurityException(msg); throw new SecurityException(msg);

View File

@@ -45,7 +45,7 @@ public class ChooseAccountActivity extends ListActivity {
String[] mAccountNames = new String[mAccounts.length]; String[] mAccountNames = new String[mAccounts.length];
for (int i = 0; i < mAccounts.length; i++) { for (int i = 0; i < mAccounts.length; i++) {
mAccountNames[i] = ((Account) mAccounts[i]).mName; mAccountNames[i] = ((Account) mAccounts[i]).name;
} }
// Use an existing ListAdapter that will map an array // Use an existing ListAdapter that will map an array
@@ -59,8 +59,8 @@ public class ChooseAccountActivity extends ListActivity {
Account account = (Account) mAccounts[position]; Account account = (Account) mAccounts[position];
Log.d(TAG, "selected account " + account); Log.d(TAG, "selected account " + account);
Bundle bundle = new Bundle(); Bundle bundle = new Bundle();
bundle.putString(Constants.ACCOUNT_NAME_KEY, account.mName); bundle.putString(Constants.ACCOUNT_NAME_KEY, account.name);
bundle.putString(Constants.ACCOUNT_TYPE_KEY, account.mType); bundle.putString(Constants.ACCOUNT_TYPE_KEY, account.type);
mResult = bundle; mResult = bundle;
finish(); finish();
} }

View File

@@ -31,6 +31,7 @@ public class Constants {
public static final String AUTHENTICATOR_TYPES_KEY = "authenticator_types"; public static final String AUTHENTICATOR_TYPES_KEY = "authenticator_types";
public static final String USERDATA_KEY = "userdata"; public static final String USERDATA_KEY = "userdata";
public static final String AUTHTOKEN_KEY = "authtoken"; public static final String AUTHTOKEN_KEY = "authtoken";
public static final String PASSWORD_KEY = "password";
public static final String ACCOUNT_NAME_KEY = "authAccount"; public static final String ACCOUNT_NAME_KEY = "authAccount";
public static final String ACCOUNT_TYPE_KEY = "accountType"; public static final String ACCOUNT_TYPE_KEY = "accountType";
public static final String ERROR_CODE_KEY = "errorCode"; public static final String ERROR_CODE_KEY = "errorCode";

View File

@@ -1,46 +0,0 @@
/*
* Copyright (C) 2009 The Android Open Source Project
*
* 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 android.accounts;
import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;
/**
* An extension of {@link Future} that provides wrappers for {@link #get()} that handle the various
* exceptions that {@link #get()} may return and rethrows them as exceptions specific to
* {@link AccountManager}.
*/
public interface Future1<V> extends Future<V> {
/**
* Wrapper for {@link Future#get()}. If the get() throws {@link InterruptedException} then the
* {@link Future1} is canceled and {@link OperationCanceledException} is thrown.
* @return the {@link android.os.Bundle} that is returned by get()
* @throws OperationCanceledException if get() throws the unchecked CancellationException
* or if the Future was interrupted.
*/
V getResult() throws OperationCanceledException;
/**
* Wrapper for {@link Future#get()}. If the get() throws {@link InterruptedException} then the
* {@link Future1} is canceled and {@link OperationCanceledException} is thrown.
* @param timeout the maximum time to wait
* @param unit the time unit of the timeout argument
* @return the {@link android.os.Bundle} that is returned by {@link Future#get()}
* @throws OperationCanceledException if get() throws the unchecked
* {@link java.util.concurrent.CancellationException} or if the {@link Future1} was interrupted.
*/
V getResult(long timeout, TimeUnit unit) throws OperationCanceledException;
}

View File

@@ -1,57 +0,0 @@
/*
* Copyright (C) 2009 The Android Open Source Project
*
* 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 android.accounts;
import android.os.Bundle;
import java.io.IOException;
import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;
/**
* An extension of {@link Future} that provides wrappers for {@link #get()} that handle the various
* exceptions that {@link #get()} may return and rethrows them as exceptions specific to
* {@link AccountManager}.
*/
public interface Future2 extends Future<Bundle> {
/**
* Wrapper for {@link Future#get()}. If the get() throws {@link InterruptedException} then the
* {@link Future2} is canceled and {@link OperationCanceledException} is thrown.
* @return the {@link android.os.Bundle} that is returned by {@link Future#get()}
* @throws OperationCanceledException if get() throws the unchecked
* {@link java.util.concurrent.CancellationException} or if the {@link Future2} was interrupted.
* @throws IOException if the request was unable to complete due to a network error
* @throws AuthenticatorException if there was an error communicating with the
* {@link AbstractAccountAuthenticator}.
*/
Bundle getResult()
throws OperationCanceledException, IOException, AuthenticatorException;
/**
* Wrapper for {@link Future#get()}. If the get() throws {@link InterruptedException} then the
* {@link Future2} is canceled and {@link OperationCanceledException} is thrown.
* @param timeout the maximum time to wait
* @param unit the time unit of the timeout argument
* @return the {@link android.os.Bundle} that is returned by {@link Future#get()}
* @throws OperationCanceledException if get() throws the unchecked
* {@link java.util.concurrent.CancellationException} or if the {@link Future2} was interrupted.
* @throws IOException if the request was unable to complete due to a network error
* @throws AuthenticatorException if there was an error communicating with the
* {@link AbstractAccountAuthenticator}.
*/
Bundle getResult(long timeout, TimeUnit unit)
throws OperationCanceledException, IOException, AuthenticatorException;
}

View File

@@ -1,20 +0,0 @@
/*
* Copyright (C) 2009 The Android Open Source Project
*
* 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 android.accounts;
public interface Future2Callback {
void run(Future2 future);
}

View File

@@ -63,12 +63,12 @@ public class GrantCredentialsPermissionActivity extends Activity implements View
CharSequence grantCredentialsPermissionFormat = getResources().getText( CharSequence grantCredentialsPermissionFormat = getResources().getText(
R.string.grant_credentials_permission_message_desc); R.string.grant_credentials_permission_message_desc);
messageView.setText(String.format(grantCredentialsPermissionFormat.toString(), messageView.setText(String.format(grantCredentialsPermissionFormat.toString(),
mAccount.mName, accountTypeLabel)); mAccount.name, accountTypeLabel));
} else { } else {
CharSequence grantCredentialsPermissionFormat = getResources().getText( CharSequence grantCredentialsPermissionFormat = getResources().getText(
R.string.grant_credentials_permission_message_with_authtokenlabel_desc); R.string.grant_credentials_permission_message_with_authtokenlabel_desc);
messageView.setText(String.format(grantCredentialsPermissionFormat.toString(), messageView.setText(String.format(grantCredentialsPermissionFormat.toString(),
authTokenLabel, mAccount.mName, accountTypeLabel)); authTokenLabel, mAccount.name, accountTypeLabel));
} }
String[] packageLabels = new String[packages.length]; String[] packageLabels = new String[packages.length];

View File

@@ -70,4 +70,9 @@ oneway interface IAccountAuthenticator {
*/ */
void hasFeatures(in IAccountAuthenticatorResponse response, in Account account, void hasFeatures(in IAccountAuthenticatorResponse response, in Account account,
in String[] features); in String[] features);
/**
* Gets whether or not the account is allowed to be removed.
*/
void getAccountRemovalAllowed(in IAccountAuthenticatorResponse response, in Account account);
} }

View File

@@ -21,6 +21,7 @@ import android.accounts.Account;
import android.accounts.AuthenticatorDescription; import android.accounts.AuthenticatorDescription;
import android.os.Bundle; import android.os.Bundle;
/** /**
* Central application service that provides account management. * Central application service that provides account management.
* @hide * @hide
@@ -29,10 +30,10 @@ interface IAccountManager {
String getPassword(in Account account); String getPassword(in Account account);
String getUserData(in Account account, String key); String getUserData(in Account account, String key);
AuthenticatorDescription[] getAuthenticatorTypes(); AuthenticatorDescription[] getAuthenticatorTypes();
Account[] getAccounts(); Account[] getAccounts(String accountType);
Account[] getAccountsByType(String accountType); void getAccountsByFeatures(in IAccountManagerResponse response, String accountType, in String[] features);
boolean addAccount(in Account account, String password, in Bundle extras); boolean addAccount(in Account account, String password, in Bundle extras);
void removeAccount(in Account account); void removeAccount(in IAccountManagerResponse response, in Account account);
void invalidateAuthToken(String accountType, String authToken); void invalidateAuthToken(String accountType, String authToken);
String peekAuthToken(in Account account, String authTokenType); String peekAuthToken(in Account account, String authTokenType);
void setAuthToken(in Account account, String authTokenType, String authToken); void setAuthToken(in Account account, String authTokenType, String authToken);
@@ -52,8 +53,6 @@ interface IAccountManager {
boolean expectActivityLaunch); boolean expectActivityLaunch);
void confirmCredentials(in IAccountManagerResponse response, in Account account, void confirmCredentials(in IAccountManagerResponse response, in Account account,
boolean expectActivityLaunch); boolean expectActivityLaunch);
void getAccountsByTypeAndFeatures(in IAccountManagerResponse response, String accountType,
in String[] features);
/* /*
* @deprecated * @deprecated

View File

@@ -170,7 +170,7 @@ public abstract class AbstractSyncableContentProvider extends SyncableContentPro
// AbstractGDataSyncAdapter, which will put acore into a crash loop // AbstractGDataSyncAdapter, which will put acore into a crash loop
ArrayList<Account> gaiaAccounts = new ArrayList<Account>(); ArrayList<Account> gaiaAccounts = new ArrayList<Account>();
for (Account acct: accounts) { for (Account acct: accounts) {
if (acct.mType.equals("com.google.GAIA")) { if (acct.type.equals("com.google.GAIA")) {
gaiaAccounts.add(acct); gaiaAccounts.add(acct);
} }
} }
@@ -693,7 +693,7 @@ public abstract class AbstractSyncableContentProvider extends SyncableContentPro
if (!accounts.containsKey(account)) { if (!accounts.containsKey(account)) {
int numDeleted; int numDeleted;
numDeleted = db.delete(table, "_sync_account=? AND _sync_account_type=?", numDeleted = db.delete(table, "_sync_account=? AND _sync_account_type=?",
new String[]{account.mName, account.mType}); new String[]{account.name, account.type});
if (Config.LOGV) { if (Config.LOGV) {
Log.v(TAG, "deleted " + numDeleted Log.v(TAG, "deleted " + numDeleted
+ " records from table " + table + " records from table " + table
@@ -726,7 +726,7 @@ public abstract class AbstractSyncableContentProvider extends SyncableContentPro
// remove the data in the synced tables // remove the data in the synced tables
for (String table : tables) { for (String table : tables) {
db.delete(table, SYNC_ACCOUNT_WHERE_CLAUSE, db.delete(table, SYNC_ACCOUNT_WHERE_CLAUSE,
new String[]{account.mName, account.mType}); new String[]{account.name, account.type});
} }
db.setTransactionSuccessful(); db.setTransactionSuccessful();
} finally { } finally {

View File

@@ -174,7 +174,7 @@ public abstract class AbstractTableMerger
Cursor diffsCursor = null; Cursor diffsCursor = null;
try { try {
// load the local database entries, so we can merge them with the server // load the local database entries, so we can merge them with the server
final String[] accountSelectionArgs = new String[]{account.mName, account.mType}; final String[] accountSelectionArgs = new String[]{account.name, account.type};
localCursor = mDb.query(mTable, syncDirtyProjection, localCursor = mDb.query(mTable, syncDirtyProjection,
SELECT_MARKED, accountSelectionArgs, null, null, SELECT_MARKED, accountSelectionArgs, null, null,
mTable + "." + _SYNC_ID); mTable + "." + _SYNC_ID);
@@ -487,7 +487,7 @@ public abstract class AbstractTableMerger
try { try {
if (deleteBySyncId) { if (deleteBySyncId) {
selectionArgs = new String[]{diffsCursor.getString(serverSyncIdColumn), selectionArgs = new String[]{diffsCursor.getString(serverSyncIdColumn),
account.mName, account.mType}; account.name, account.type};
c = mDb.query(mTable, new String[]{BaseColumns._ID}, SELECT_BY_SYNC_ID_AND_ACCOUNT, c = mDb.query(mTable, new String[]{BaseColumns._ID}, SELECT_BY_SYNC_ID_AND_ACCOUNT,
selectionArgs, null, null, null); selectionArgs, null, null, null);
} else { } else {
@@ -534,7 +534,7 @@ public abstract class AbstractTableMerger
SyncableContentProvider clientDiffs = mergeResult.tempContentProvider; SyncableContentProvider clientDiffs = mergeResult.tempContentProvider;
if (Log.isLoggable(TAG, Log.VERBOSE)) Log.v(TAG, "generating client updates"); if (Log.isLoggable(TAG, Log.VERBOSE)) Log.v(TAG, "generating client updates");
final String[] accountSelectionArgs = new String[]{account.mName, account.mType}; final String[] accountSelectionArgs = new String[]{account.name, account.type};
// Generate the client updates and insertions // Generate the client updates and insertions
// Create a cursor for dirty records // Create a cursor for dirty records

View File

@@ -596,7 +596,7 @@ class SyncManager implements OnAccountsUpdatedListener {
for (String authority : syncableAuthorities) { for (String authority : syncableAuthorities) {
for (Account account : accounts) { for (Account account : accounts) {
if (mSyncAdapters.getServiceInfo(new SyncAdapterType(authority, account.mType)) if (mSyncAdapters.getServiceInfo(new SyncAdapterType(authority, account.type))
!= null) { != null) {
scheduleSyncOperation( scheduleSyncOperation(
new SyncOperation(account, source, authority, extras, delay)); new SyncOperation(account, source, authority, extras, delay));
@@ -1094,8 +1094,8 @@ class SyncManager implements OnAccountsUpdatedListener {
for (int i=0; i<N; i++) { for (int i=0; i<N; i++) {
SyncStorageEngine.PendingOperation op = ops.get(i); SyncStorageEngine.PendingOperation op = ops.get(i);
pw.print(" #"); pw.print(i); pw.print(": account="); pw.print(" #"); pw.print(i); pw.print(": account=");
pw.print(op.account.mName); pw.print(":"); pw.print(op.account.name); pw.print(":");
pw.print(op.account.mType); pw.print(" authority="); pw.print(op.account.type); pw.print(" authority=");
pw.println(op.authority); pw.println(op.authority);
if (op.extras != null && op.extras.size() > 0) { if (op.extras != null && op.extras.size() > 0) {
sb.setLength(0); sb.setLength(0);
@@ -1125,8 +1125,8 @@ class SyncManager implements OnAccountsUpdatedListener {
processedAccounts.add(curAccount); processedAccounts.add(curAccount);
pw.print(" Account "); pw.print(authority.account.mName); pw.print(" Account "); pw.print(authority.account.name);
pw.print(" "); pw.print(authority.account.mType); pw.print(" "); pw.print(authority.account.type);
pw.println(":"); pw.println(":");
for (int j=i; j<N; j++) { for (int j=i; j<N; j++) {
status = statuses.get(j); status = statuses.get(j);
@@ -1248,9 +1248,9 @@ class SyncManager implements OnAccountsUpdatedListener {
= mSyncStorageEngine.getAuthority(item.authorityId); = mSyncStorageEngine.getAuthority(item.authorityId);
pw.print(" #"); pw.print(i+1); pw.print(": "); pw.print(" #"); pw.print(i+1); pw.print(": ");
if (authority != null) { if (authority != null) {
pw.print(authority.account.mName); pw.print(authority.account.name);
pw.print(":"); pw.print(":");
pw.print(authority.account.mType); pw.print(authority.account.type);
pw.print(" "); pw.print(" ");
pw.print(authority.authority); pw.print(authority.authority);
} else { } else {
@@ -1636,7 +1636,7 @@ class SyncManager implements OnAccountsUpdatedListener {
// connect to the sync adapter // connect to the sync adapter
SyncAdapterType syncAdapterType = new SyncAdapterType(op.authority, SyncAdapterType syncAdapterType = new SyncAdapterType(op.authority,
op.account.mType); op.account.type);
RegisteredServicesCache.ServiceInfo<SyncAdapterType> syncAdapterInfo = RegisteredServicesCache.ServiceInfo<SyncAdapterType> syncAdapterInfo =
mSyncAdapters.getServiceInfo(syncAdapterType); mSyncAdapters.getServiceInfo(syncAdapterType);
if (syncAdapterInfo == null) { if (syncAdapterInfo == null) {

View File

@@ -172,7 +172,7 @@ public class SyncStateContentProviderHelper {
*/ */
public void copySyncState(SQLiteDatabase dbSrc, SQLiteDatabase dbDest, public void copySyncState(SQLiteDatabase dbSrc, SQLiteDatabase dbDest,
Account account) { Account account) {
final String[] whereArgs = new String[]{account.mName, account.mType}; final String[] whereArgs = new String[]{account.name, account.type};
Cursor c = dbSrc.query(SYNC_STATE_TABLE, Cursor c = dbSrc.query(SYNC_STATE_TABLE,
new String[]{"_sync_account", "_sync_account_type", "data"}, new String[]{"_sync_account", "_sync_account_type", "data"},
ACCOUNT_WHERE, whereArgs, null, null, null); ACCOUNT_WHERE, whereArgs, null, null, null);
@@ -209,7 +209,7 @@ public class SyncStateContentProviderHelper {
public void discardSyncData(SQLiteDatabase db, Account account) { public void discardSyncData(SQLiteDatabase db, Account account) {
if (account != null) { if (account != null) {
db.delete(SYNC_STATE_TABLE, ACCOUNT_WHERE, new String[]{account.mName, account.mType}); db.delete(SYNC_STATE_TABLE, ACCOUNT_WHERE, new String[]{account.name, account.type});
} else { } else {
db.delete(SYNC_STATE_TABLE, null, null); db.delete(SYNC_STATE_TABLE, null, null);
} }
@@ -220,7 +220,7 @@ public class SyncStateContentProviderHelper {
*/ */
public byte[] readSyncDataBytes(SQLiteDatabase db, Account account) { public byte[] readSyncDataBytes(SQLiteDatabase db, Account account) {
Cursor c = db.query(SYNC_STATE_TABLE, null, ACCOUNT_WHERE, Cursor c = db.query(SYNC_STATE_TABLE, null, ACCOUNT_WHERE,
new String[]{account.mName, account.mType}, null, null, null); new String[]{account.name, account.type}, null, null, null);
try { try {
if (c.moveToFirst()) { if (c.moveToFirst()) {
return c.getBlob(c.getColumnIndexOrThrow("data")); return c.getBlob(c.getColumnIndexOrThrow("data"));
@@ -238,6 +238,6 @@ public class SyncStateContentProviderHelper {
ContentValues values = new ContentValues(); ContentValues values = new ContentValues();
values.put("data", data); values.put("data", data);
db.update(SYNC_STATE_TABLE, values, ACCOUNT_WHERE, db.update(SYNC_STATE_TABLE, values, ACCOUNT_WHERE,
new String[]{account.mName, account.mType}); new String[]{account.name, account.type});
} }
} }

View File

@@ -1127,8 +1127,8 @@ public class SyncStorageEngine extends Handler {
AuthorityInfo authority = mAuthorities.get(i); AuthorityInfo authority = mAuthorities.get(i);
out.startTag(null, "authority"); out.startTag(null, "authority");
out.attribute(null, "id", Integer.toString(authority.ident)); out.attribute(null, "id", Integer.toString(authority.ident));
out.attribute(null, "account", authority.account.mName); out.attribute(null, "account", authority.account.name);
out.attribute(null, "type", authority.account.mType); out.attribute(null, "type", authority.account.type);
out.attribute(null, "authority", authority.authority); out.attribute(null, "authority", authority.authority);
if (!authority.enabled) { if (!authority.enabled) {
out.attribute(null, "enabled", "false"); out.attribute(null, "enabled", "false");

View File

@@ -174,7 +174,7 @@ public final class Calendar {
return Calendar.Calendars.delete(cr, return Calendar.Calendars.delete(cr,
Calendar.Calendars._SYNC_ACCOUNT + "=? AND " Calendar.Calendars._SYNC_ACCOUNT + "=? AND "
+ Calendar.Calendars._SYNC_ACCOUNT_TYPE + "=?", + Calendar.Calendars._SYNC_ACCOUNT_TYPE + "=?",
new String[] {account.mName, account.mType}); new String[] {account.name, account.type});
} }
/** /**

View File

@@ -119,8 +119,8 @@ public class SubscribedFeeds {
String authority, String service) { String authority, String service) {
ContentValues values = new ContentValues(); ContentValues values = new ContentValues();
values.put(SubscribedFeeds.Feeds.FEED, feed); values.put(SubscribedFeeds.Feeds.FEED, feed);
values.put(SubscribedFeeds.Feeds._SYNC_ACCOUNT, account.mName); values.put(SubscribedFeeds.Feeds._SYNC_ACCOUNT, account.name);
values.put(SubscribedFeeds.Feeds._SYNC_ACCOUNT_TYPE, account.mType); values.put(SubscribedFeeds.Feeds._SYNC_ACCOUNT_TYPE, account.type);
values.put(SubscribedFeeds.Feeds.AUTHORITY, authority); values.put(SubscribedFeeds.Feeds.AUTHORITY, authority);
values.put(SubscribedFeeds.Feeds.SERVICE, service); values.put(SubscribedFeeds.Feeds.SERVICE, service);
return resolver.insert(SubscribedFeeds.Feeds.CONTENT_URI, values); return resolver.insert(SubscribedFeeds.Feeds.CONTENT_URI, values);
@@ -134,7 +134,7 @@ public class SubscribedFeeds {
where.append(" AND " + SubscribedFeeds.Feeds.FEED + "=?"); where.append(" AND " + SubscribedFeeds.Feeds.FEED + "=?");
where.append(" AND " + SubscribedFeeds.Feeds.AUTHORITY + "=?"); where.append(" AND " + SubscribedFeeds.Feeds.AUTHORITY + "=?");
return resolver.delete(SubscribedFeeds.Feeds.CONTENT_URI, return resolver.delete(SubscribedFeeds.Feeds.CONTENT_URI,
where.toString(), new String[] {account.mName, account.mType, feed, authority}); where.toString(), new String[] {account.name, account.type, feed, authority});
} }
public static int deleteFeeds(ContentResolver resolver, public static int deleteFeeds(ContentResolver resolver,
@@ -144,7 +144,7 @@ public class SubscribedFeeds {
where.append(" AND " + SubscribedFeeds.Feeds._SYNC_ACCOUNT_TYPE + "=?"); where.append(" AND " + SubscribedFeeds.Feeds._SYNC_ACCOUNT_TYPE + "=?");
where.append(" AND " + SubscribedFeeds.Feeds.AUTHORITY + "=?"); where.append(" AND " + SubscribedFeeds.Feeds.AUTHORITY + "=?");
return resolver.delete(SubscribedFeeds.Feeds.CONTENT_URI, return resolver.delete(SubscribedFeeds.Feeds.CONTENT_URI,
where.toString(), new String[] {account.mName, account.mType, authority}); where.toString(), new String[] {account.name, account.type, authority});
} }
/** /**

View File

@@ -71,7 +71,7 @@ public class SyncStateContract {
public static byte[] get(ContentProviderClient provider, Uri uri, public static byte[] get(ContentProviderClient provider, Uri uri,
Account account) throws RemoteException { Account account) throws RemoteException {
Cursor c = provider.query(uri, DATA_PROJECTION, SELECT_BY_ACCOUNT, Cursor c = provider.query(uri, DATA_PROJECTION, SELECT_BY_ACCOUNT,
new String[]{account.mName, account.mType}, null); new String[]{account.name, account.type}, null);
try { try {
if (c.moveToNext()) { if (c.moveToNext()) {
return c.getBlob(c.getColumnIndexOrThrow(Columns.DATA)); return c.getBlob(c.getColumnIndexOrThrow(Columns.DATA));
@@ -96,8 +96,8 @@ public class SyncStateContract {
Account account, byte[] data) throws RemoteException { Account account, byte[] data) throws RemoteException {
ContentValues values = new ContentValues(); ContentValues values = new ContentValues();
values.put(Columns.DATA, data); values.put(Columns.DATA, data);
values.put(Columns.ACCOUNT_NAME, account.mName); values.put(Columns.ACCOUNT_NAME, account.name);
values.put(Columns.ACCOUNT_TYPE, account.mType); values.put(Columns.ACCOUNT_TYPE, account.type);
provider.insert(uri, values); provider.insert(uri, values);
} }
@@ -116,8 +116,8 @@ public class SyncStateContract {
values.put(Columns.DATA, data); values.put(Columns.DATA, data);
return ContentProviderOperation return ContentProviderOperation
.newInsert(uri) .newInsert(uri)
.withValue(Columns.ACCOUNT_NAME, account.mName) .withValue(Columns.ACCOUNT_NAME, account.name)
.withValue(Columns.ACCOUNT_TYPE, account.mType) .withValue(Columns.ACCOUNT_TYPE, account.type)
.withValues(values) .withValues(values)
.build(); .build();
} }

View File

@@ -113,7 +113,7 @@ public class SubscribedFeedsIntentService extends IntentService {
// TODO(fredq) fix the hardcoded type // TODO(fredq) fix the hardcoded type
final Account account = new Account(accountName, "com.google.GAIA"); final Account account = new Account(accountName, "com.google.GAIA");
c = context.getContentResolver().query(SubscribedFeeds.Feeds.CONTENT_URI, c = context.getContentResolver().query(SubscribedFeeds.Feeds.CONTENT_URI,
null, where, new String[]{account.mName, account.mType, feed}, null); null, where, new String[]{account.name, account.type, feed}, null);
if (c.getCount() == 0) { if (c.getCount() == 0) {
Log.w(TAG, "received tickle for non-existent feed: " Log.w(TAG, "received tickle for non-existent feed: "
+ "account " + accountName + ", feed " + feed); + "account " + accountName + ", feed " + feed);
@@ -171,12 +171,12 @@ public class SubscribedFeedsIntentService extends IntentService {
try { try {
ContentValues values = new ContentValues(); ContentValues values = new ContentValues();
for (Account account : accounts) { for (Account account : accounts) {
values.put(SyncConstValue._SYNC_ACCOUNT, account.mName); values.put(SyncConstValue._SYNC_ACCOUNT, account.name);
values.put(SyncConstValue._SYNC_ACCOUNT_TYPE, account.mType); values.put(SyncConstValue._SYNC_ACCOUNT_TYPE, account.type);
contentResolver.update(SubscribedFeeds.Feeds.CONTENT_URI, values, contentResolver.update(SubscribedFeeds.Feeds.CONTENT_URI, values,
SubscribedFeeds.Feeds._SYNC_ACCOUNT + "=? AND " SubscribedFeeds.Feeds._SYNC_ACCOUNT + "=? AND "
+ SubscribedFeeds.Feeds._SYNC_ACCOUNT_TYPE + "=?", + SubscribedFeeds.Feeds._SYNC_ACCOUNT_TYPE + "=?",
new String[] {account.mName, account.mType}); new String[] {account.name, account.type});
} }
} catch (SQLiteFullException e) { } catch (SQLiteFullException e) {
Log.w(TAG, "disk full while trying to mark the feeds as dirty, skipping"); Log.w(TAG, "disk full while trying to mark the feeds as dirty, skipping");

View File

@@ -28,7 +28,6 @@ import android.os.Bundle;
import java.util.Arrays; import java.util.Arrays;
import java.util.Comparator; import java.util.Comparator;
import java.util.Map;
public class AccountManagerServiceTest extends AndroidTestCase { public class AccountManagerServiceTest extends AndroidTestCase {
@Override @Override
@@ -48,9 +47,9 @@ public class AccountManagerServiceTest extends AndroidTestCase {
if (object1 == object2) return 0; if (object1 == object2) return 0;
if (object1 == null) return 1; if (object1 == null) return 1;
if (object2 == null) return -1; if (object2 == null) return -1;
int result = object1.mType.compareTo(object2.mType); int result = object1.type.compareTo(object2.type);
if (result != 0) return result; if (result != 0) return result;
return object1.mName.compareTo(object2.mName); return object1.name.compareTo(object2.name);
} }
} }
@@ -62,16 +61,14 @@ public class AccountManagerServiceTest extends AndroidTestCase {
Account a12 = new Account("account1", "type2"); Account a12 = new Account("account1", "type2");
Account a22 = new Account("account2", "type2"); Account a22 = new Account("account2", "type2");
Account a32 = new Account("account3", "type2"); Account a32 = new Account("account3", "type2");
assertTrue(ams.addAccount(a11, "p11", null)); ams.addAccount(a11, "p11", null);
assertTrue(ams.addAccount(a12, "p12", null)); ams.addAccount(a12, "p12", null);
assertTrue(ams.addAccount(a21, "p21", null)); ams.addAccount(a21, "p21", null);
assertTrue(ams.addAccount(a22, "p22", null)); ams.addAccount(a22, "p22", null);
assertTrue(ams.addAccount(a31, "p31", null)); ams.addAccount(a31, "p31", null);
assertTrue(ams.addAccount(a32, "p32", null)); ams.addAccount(a32, "p32", null);
assertFalse("duplicate account insertion should fail", ams.addAccount(a32, "p", null)); Account[] accounts = ams.getAccounts(null);
Account[] accounts = ams.getAccounts();
Arrays.sort(accounts, new AccountSorter()); Arrays.sort(accounts, new AccountSorter());
assertEquals(6, accounts.length); assertEquals(6, accounts.length);
assertEquals(a11, accounts[0]); assertEquals(a11, accounts[0]);
@@ -88,7 +85,7 @@ public class AccountManagerServiceTest extends AndroidTestCase {
assertEquals(a21, accounts[1]); assertEquals(a21, accounts[1]);
assertEquals(a31, accounts[2]); assertEquals(a31, accounts[2]);
ams.removeAccount(a21); ams.removeAccount(null, a21);
accounts = ams.getAccountsByType("type1" ); accounts = ams.getAccountsByType("type1" );
Arrays.sort(accounts, new AccountSorter()); Arrays.sort(accounts, new AccountSorter());
@@ -101,8 +98,8 @@ public class AccountManagerServiceTest extends AndroidTestCase {
AccountManagerService ams = new AccountManagerService(getContext()); AccountManagerService ams = new AccountManagerService(getContext());
Account a11 = new Account("account1", "type1"); Account a11 = new Account("account1", "type1");
Account a12 = new Account("account1", "type2"); Account a12 = new Account("account1", "type2");
assertTrue(ams.addAccount(a11, "p11", null)); ams.addAccount(a11, "p11", null);
assertTrue(ams.addAccount(a12, "p12", null)); ams.addAccount(a12, "p12", null);
assertEquals("p11", ams.getPassword(a11)); assertEquals("p11", ams.getPassword(a11));
assertEquals("p12", ams.getPassword(a12)); assertEquals("p12", ams.getPassword(a12));
@@ -125,8 +122,8 @@ public class AccountManagerServiceTest extends AndroidTestCase {
u12.putString("a", "a_a12"); u12.putString("a", "a_a12");
u12.putString("b", "b_a12"); u12.putString("b", "b_a12");
u12.putString("c", "c_a12"); u12.putString("c", "c_a12");
assertTrue(ams.addAccount(a11, "p11", u11)); ams.addAccount(a11, "p11", u11);
assertTrue(ams.addAccount(a12, "p12", u12)); ams.addAccount(a12, "p12", u12);
assertEquals("a_a11", ams.getUserData(a11, "a")); assertEquals("a_a11", ams.getUserData(a11, "a"));
assertEquals("b_a11", ams.getUserData(a11, "b")); assertEquals("b_a11", ams.getUserData(a11, "b"));
@@ -149,8 +146,8 @@ public class AccountManagerServiceTest extends AndroidTestCase {
AccountManagerService ams = new AccountManagerService(getContext()); AccountManagerService ams = new AccountManagerService(getContext());
Account a11 = new Account("account1", "type1"); Account a11 = new Account("account1", "type1");
Account a12 = new Account("account1", "type2"); Account a12 = new Account("account1", "type2");
assertTrue(ams.addAccount(a11, "p11", null)); ams.addAccount(a11, "p11", null);
assertTrue(ams.addAccount(a12, "p12", null)); ams.addAccount(a12, "p12", null);
ams.setAuthToken(a11, "att1", "a11_att1"); ams.setAuthToken(a11, "att1", "a11_att1");
ams.setAuthToken(a11, "att2", "a11_att2"); ams.setAuthToken(a11, "att2", "a11_att2");
@@ -167,7 +164,7 @@ public class AccountManagerServiceTest extends AndroidTestCase {
assertEquals("a12_att3", ams.peekAuthToken(a12, "att3")); assertEquals("a12_att3", ams.peekAuthToken(a12, "att3"));
ams.setAuthToken(a11, "att3", "a11_att3b"); ams.setAuthToken(a11, "att3", "a11_att3b");
ams.invalidateAuthToken(a12.mType, "a12_att2"); ams.invalidateAuthToken(a12.type, "a12_att2");
assertEquals("a11_att1", ams.peekAuthToken(a11, "att1")); assertEquals("a11_att1", ams.peekAuthToken(a11, "att1"));
assertEquals("a11_att2", ams.peekAuthToken(a11, "att2")); assertEquals("a11_att2", ams.peekAuthToken(a11, "att2"));

View File

@@ -74,8 +74,8 @@ public class AbstractTableMergerTest extends AndroidTestCase {
if (syncVersion != null) values.put("_sync_version", syncVersion); if (syncVersion != null) values.put("_sync_version", syncVersion);
if (syncId != null) values.put("_sync_id", syncId); if (syncId != null) values.put("_sync_id", syncId);
if (syncAccount != null) { if (syncAccount != null) {
values.put("_sync_account", syncAccount.mName); values.put("_sync_account", syncAccount.name);
values.put("_sync_account_type", syncAccount.mType); values.put("_sync_account_type", syncAccount.type);
} }
values.put("_sync_local_id", syncLocalId); values.put("_sync_local_id", syncLocalId);
values.put("_sync_dirty", 0); values.put("_sync_dirty", 0);
@@ -88,8 +88,8 @@ public class AbstractTableMergerTest extends AndroidTestCase {
if (syncVersion != null) values.put("_sync_version", syncVersion); if (syncVersion != null) values.put("_sync_version", syncVersion);
if (syncId != null) values.put("_sync_id", syncId); if (syncId != null) values.put("_sync_id", syncId);
if (syncAccount != null) { if (syncAccount != null) {
values.put("_sync_account", syncAccount.mName); values.put("_sync_account", syncAccount.name);
values.put("_sync_account_type", syncAccount.mType); values.put("_sync_account_type", syncAccount.type);
} }
if (syncLocalId != null) values.put("_sync_local_id", syncLocalId); if (syncLocalId != null) values.put("_sync_local_id", syncLocalId);
return values; return values;