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 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
223 | 223 |
224 synchronized (mUi) { | 224 synchronized (mUi) { |
225 mAccount = new Account(accountName, accountType); | 225 mAccount = new Account(accountName, accountType); |
226 mToken = authToken; | 226 mToken = authToken; |
227 getPreferences(MODE_PRIVATE).edit().putString("account_name"
, accountName). | 227 getPreferences(MODE_PRIVATE).edit().putString("account_name"
, accountName). |
228 putString("account_type", accountType).apply(); | 228 putString("account_type", accountType).apply(); |
229 } | 229 } |
230 | 230 |
231 // Send our HTTP request to the directory server. | 231 // Send our HTTP request to the directory server. |
232 URLConnection link = | 232 URLConnection link = |
233 new URL(HOST_LIST_PATH + JniInterface.getApiKey()).openC
onnection(); | 233 new URL(HOST_LIST_PATH + JniInterface.nativeGetApiKey())
.openConnection(); |
234 link.addRequestProperty("client_id", JniInterface.getClientId())
; | 234 link.addRequestProperty("client_id", JniInterface.nativeGetClien
tId()); |
235 link.addRequestProperty("client_secret", JniInterface.getClientS
ecret()); | 235 link.addRequestProperty("client_secret", JniInterface.nativeGetC
lientSecret()); |
236 link.setRequestProperty("Authorization", "OAuth " + authToken); | 236 link.setRequestProperty("Authorization", "OAuth " + authToken); |
237 | 237 |
238 // Listen for the server to respond. | 238 // Listen for the server to respond. |
239 StringBuilder response = new StringBuilder(); | 239 StringBuilder response = new StringBuilder(); |
240 Scanner incoming = new Scanner(link.getInputStream()); | 240 Scanner incoming = new Scanner(link.getInputStream()); |
241 Log.i("auth", "Successfully authenticated to directory server"); | 241 Log.i("auth", "Successfully authenticated to directory server"); |
242 while (incoming.hasNext()) { | 242 while (incoming.hasNext()) { |
243 response.append(incoming.nextLine()); | 243 response.append(incoming.nextLine()); |
244 } | 244 } |
245 incoming.close(); | 245 incoming.close(); |
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
414 Toast.LENGTH_LONG).show(); | 414 Toast.LENGTH_LONG).show(); |
415 | 415 |
416 // Close the application. | 416 // Close the application. |
417 finish(); | 417 finish(); |
418 } | 418 } |
419 | 419 |
420 return target; | 420 return target; |
421 } | 421 } |
422 } | 422 } |
423 } | 423 } |
OLD | NEW |