Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(597)

Side by Side Diff: remoting/android/java/src/org/chromium/chromoting/base/OAuthTokenFetcher.java

Issue 2391633003: [Remoting Android] Fix Deprecated API Warnings (Closed)
Patch Set: Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « remoting/android/java/src/org/chromium/chromoting/Chromoting.java ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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.base; 5 package org.chromium.chromoting.base;
6 6
7 import android.accounts.Account;
7 import android.app.Activity; 8 import android.app.Activity;
8 import android.content.Context; 9 import android.content.Context;
9 import android.os.AsyncTask; 10 import android.os.AsyncTask;
10 import android.os.Handler; 11 import android.os.Handler;
11 import android.os.Looper; 12 import android.os.Looper;
12 13
13 import com.google.android.gms.auth.GoogleAuthException; 14 import com.google.android.gms.auth.GoogleAuthException;
14 import com.google.android.gms.auth.GoogleAuthUtil; 15 import com.google.android.gms.auth.GoogleAuthUtil;
15 import com.google.android.gms.auth.UserRecoverableAuthException; 16 import com.google.android.gms.auth.UserRecoverableAuthException;
16 17
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 94
94 private void fetchImpl(final String expiredToken) { 95 private void fetchImpl(final String expiredToken) {
95 new AsyncTask<Void, Void, Void>() { 96 new AsyncTask<Void, Void, Void>() {
96 @Override 97 @Override
97 protected Void doInBackground(Void... params) { 98 protected Void doInBackground(Void... params) {
98 try { 99 try {
99 if (expiredToken != null) { 100 if (expiredToken != null) {
100 GoogleAuthUtil.clearToken(mContext, expiredToken); 101 GoogleAuthUtil.clearToken(mContext, expiredToken);
101 } 102 }
102 103
103 // This method is deprecated but its replacement is not yet available. 104 Account account = new Account(mAccountName, GoogleAuthUtil.G OOGLE_ACCOUNT_TYPE);
104 // TODO(lambroslambrou): Fix this by replacing |mAccountName | with an instance 105 String token = GoogleAuthUtil.getToken(mContext, account, mT okenScope);
105 // of android.accounts.Account.
106 String token = GoogleAuthUtil.getToken(mContext, mAccountNam e, mTokenScope);
107 handleTokenReceived(token); 106 handleTokenReceived(token);
108 } catch (IOException ioException) { 107 } catch (IOException ioException) {
109 handleError(Error.NETWORK); 108 handleError(Error.NETWORK);
110 } catch (UserRecoverableAuthException recoverableException) { 109 } catch (UserRecoverableAuthException recoverableException) {
111 handleRecoverableException(recoverableException); 110 handleRecoverableException(recoverableException);
112 } catch (GoogleAuthException fatalException) { 111 } catch (GoogleAuthException fatalException) {
113 handleError(Error.UNEXPECTED); 112 handleError(Error.UNEXPECTED);
114 } 113 }
115 return null; 114 return null;
116 } 115 }
(...skipping 27 matching lines...) Expand all
144 final Activity activity = (Activity) mContext; 143 final Activity activity = (Activity) mContext;
145 activity.runOnUiThread(new Runnable() { 144 activity.runOnUiThread(new Runnable() {
146 @Override 145 @Override
147 public void run() { 146 public void run() {
148 activity.startActivityForResult(exception.getIntent(), 147 activity.startActivityForResult(exception.getIntent(),
149 REQUEST_CODE_RECOVER_FROM_OAUTH_ERROR); 148 REQUEST_CODE_RECOVER_FROM_OAUTH_ERROR);
150 } 149 }
151 }); 150 });
152 } 151 }
153 } 152 }
OLDNEW
« no previous file with comments | « remoting/android/java/src/org/chromium/chromoting/Chromoting.java ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698