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

Unified Diff: chrome/android/java/src/org/chromium/chrome/browser/gsa/GSAServiceClient.java

Issue 2431223004: android: Don't keep GSA alive if it supports account change broadcasts. (Closed)
Patch Set: Address comments. 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 side-by-side diff with in-line comments
Download patch
Index: chrome/android/java/src/org/chromium/chrome/browser/gsa/GSAServiceClient.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/gsa/GSAServiceClient.java b/chrome/android/java/src/org/chromium/chrome/browser/gsa/GSAServiceClient.java
index 0524399e54361e0d0835fcf8bcf1905795cb0421..90a28e4cf0fa8e749f70be15605ba784b53738a1 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/gsa/GSAServiceClient.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/gsa/GSAServiceClient.java
@@ -17,6 +17,7 @@ import android.os.Messenger;
import android.os.RemoteException;
import android.util.Log;
+import org.chromium.base.Callback;
import org.chromium.base.annotations.SuppressFBWarnings;
import org.chromium.chrome.browser.ChromeApplication;
@@ -45,6 +46,7 @@ public class GSAServiceClient {
private final GSAServiceConnection mConnection;
private final GSAHelper mGsaHelper;
private Context mContext;
+ private Callback<Bundle> mOnMessageReceived;
/** Messenger for communicating with service. */
private Messenger mService;
@@ -64,6 +66,7 @@ public class GSAServiceClient {
String account =
mGsaHelper.getGSAAccountFromState(bundle.getByteArray(KEY_GSA_STATE));
GSAState.getInstance(mContext.getApplicationContext()).setGsaAccount(account);
+ if (mOnMessageReceived != null) mOnMessageReceived.onResult(bundle);
} else {
super.handleMessage(msg);
}
@@ -72,11 +75,15 @@ public class GSAServiceClient {
/**
* Constructs an instance of this class.
+ *
+ * @param context Appliation context.
+ * @param onMessageReceived optional callback when a message is received.
*/
- public GSAServiceClient(Context context) {
+ GSAServiceClient(Context context, Callback<Bundle> onMessageReceived) {
+ mContext = context;
+ mOnMessageReceived = onMessageReceived;
mHandler = new IncomingHandler();
mMessenger = new Messenger(mHandler);
- mContext = context;
mConnection = new GSAServiceConnection();
mGsaHelper = ((ChromeApplication) mContext.getApplicationContext())
.createGsaHelper();
@@ -89,7 +96,7 @@ public class GSAServiceClient {
* established.
* @return Whether or not the connection to the service was established successfully.
*/
- public boolean connect() {
+ boolean connect() {
if (mService != null) Log.e(TAG, "Already connected.");
Intent intent = new Intent(GSA_SERVICE).setPackage(GSAState.SEARCH_INTENT_PACKAGE);
return mContext.bindService(
@@ -99,7 +106,7 @@ public class GSAServiceClient {
/**
* Disconnects from the service and resets the client's state.
*/
- public void disconnect() {
+ void disconnect() {
if (mService == null) return;
mContext.unbindService(mConnection);
@@ -114,7 +121,7 @@ public class GSAServiceClient {
* Indicates whether or not the client is currently connected to the service.
* @return true if connected, false otherwise.
*/
- public boolean isConnected() {
+ boolean isConnected() {
return mService != null;
}

Powered by Google App Engine
This is Rietveld 408576698