title: User data in account manager is accessible by other applications
body: <p>I am trying to utilize Android's Account Manager to store user's app credentials.
  Although I am not saving the user's password, I wanted to save other security keys to the account's UserData. According to the documentation quoted below, this should NOT be accessible by applications with different UID.</p>
  
  <blockquote>
    <p>public String getUserData (Account account, String key)</p>
    
    <blockquote>
      <p>Gets the user data named by "key" associated with the account. This is intended for authenticators and related code to store arbitrary metadata along with accounts. The meaning of the keys and values is up to the authenticator for the account.</p>
      
      <p>It is safe to call this method from the main thread.</p>
      
      <p>This method requires the caller to hold the permission AUTHENTICATE_ACCOUNTS and to have the same UID as the account's authenticator.</p>
      
      <p>Parameters
      account - The account to query for user data
      Returns
      The user data, null if the account or key doesn't exist</p>
    </blockquote>
  </blockquote>
  
  <p>To test this, I created an application that creates an account and saves some contents to UserData. I also created another application that accesses the accounts of the first app. Below are the snippets:</p>
  
  <p>First app:</p>
  
  <pre><code>AccountManager am = (AccountManager) context.getSystemService(Context.ACCOUNT_SERVICE);
  final Account account = new Account("Account Name", "my.account.type");
  am.addAccountExplicitly(account, null, null);
  am.setAuthToken(account, "my.account.type", "some auth token");
  am.setUserData(account, "key.for.secure.user.data", "some secure data");
  </code></pre>
  
  <p>Second app:</p>
  
  <pre><code>AccountManager am =  (AccountManager)context.getSystemService(Context.ACCOUNT_SERVICE);
  Account[] accountsFromFirstApp = am.getAccountsByType("my.account.type");
  for(Account acct: accountsFromFirstApp){
      printToLogs(acct.name);
      printToLogs(am.getUserData(acct, "key.for.secure.user.data"));
  }
  </code></pre>
  
  <p>Based on the documentation above, I expected the second app's getUserData() to return an exception for not having the same UID as the owner app. Surprisingly, I was able to access the user data of the first app with no errors.</p>
  
  <p>But when I tried to access accounts from google by using "com.google" as the accountType, I got the expected exception.</p>
  
  <p>What was wrong with my implementation? Did I miss some configuration that was not stated in Android's documentation? Any help will be very much appreciated.</p>
  
  <p>On the second thought, If these user data can just be accessed that easily (assuming that the other applications know my app's account type), then what's the difference of storing strings in UserData from storing them in SharedPreferences instead?</p>