| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 package org.chromium.chromoting; | 5 package org.chromium.chromoting; |
| 6 | 6 |
| 7 import android.accounts.Account; | 7 import android.accounts.Account; |
| 8 import android.accounts.AccountManager; | 8 import android.accounts.AccountManager; |
| 9 import android.accounts.AccountManagerCallback; | 9 import android.accounts.AccountManagerCallback; |
| 10 import android.accounts.AccountManagerFuture; | 10 import android.accounts.AccountManagerFuture; |
| (...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 194 Bundle result = future.getResult(); | 194 Bundle result = future.getResult(); |
| 195 String accountName = result.getString(AccountManager.KEY_ACCOUNT
_NAME); | 195 String accountName = result.getString(AccountManager.KEY_ACCOUNT
_NAME); |
| 196 String accountType = result.getString(AccountManager.KEY_ACCOUNT
_TYPE); | 196 String accountType = result.getString(AccountManager.KEY_ACCOUNT
_TYPE); |
| 197 String authToken = result.getString(AccountManager.KEY_AUTHTOKEN
); | 197 String authToken = result.getString(AccountManager.KEY_AUTHTOKEN
); |
| 198 Log.i("auth", "Received an auth token from system"); | 198 Log.i("auth", "Received an auth token from system"); |
| 199 | 199 |
| 200 synchronized (mUi) { | 200 synchronized (mUi) { |
| 201 mAccount = new Account(accountName, accountType); | 201 mAccount = new Account(accountName, accountType); |
| 202 mToken = authToken; | 202 mToken = authToken; |
| 203 getPreferences(MODE_PRIVATE).edit().putString("account_name"
, accountName). | 203 getPreferences(MODE_PRIVATE).edit().putString("account_name"
, accountName). |
| 204 putString("account_type", accountType).commit(); | 204 putString("account_type", accountType).apply(); |
| 205 } | 205 } |
| 206 | 206 |
| 207 // Send our HTTP request to the directory server. | 207 // Send our HTTP request to the directory server. |
| 208 URLConnection link = | 208 URLConnection link = |
| 209 new URL(HOST_LIST_PATH + JniInterface.getApiKey()).openC
onnection(); | 209 new URL(HOST_LIST_PATH + JniInterface.getApiKey()).openC
onnection(); |
| 210 link.addRequestProperty("client_id", JniInterface.getClientId())
; | 210 link.addRequestProperty("client_id", JniInterface.getClientId())
; |
| 211 link.addRequestProperty("client_secret", JniInterface.getClientS
ecret()); | 211 link.addRequestProperty("client_secret", JniInterface.getClientS
ecret()); |
| 212 link.setRequestProperty("Authorization", "OAuth " + authToken); | 212 link.setRequestProperty("Authorization", "OAuth " + authToken); |
| 213 | 213 |
| 214 // Listen for the server to respond. | 214 // Listen for the server to respond. |
| (...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 379 Toast.LENGTH_LONG).show(); | 379 Toast.LENGTH_LONG).show(); |
| 380 | 380 |
| 381 // Close the application. | 381 // Close the application. |
| 382 finish(); | 382 finish(); |
| 383 } | 383 } |
| 384 | 384 |
| 385 return target; | 385 return target; |
| 386 } | 386 } |
| 387 } | 387 } |
| 388 } | 388 } |
| OLD | NEW |