• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2015 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 package android.support.customtabs;
18 
19 import android.content.ComponentName;
20 import android.content.ServiceConnection;
21 import android.os.IBinder;
22 
23 /**
24  * Abstract {@link ServiceConnection} to use while binding to a {@link CustomTabsService}. Any
25  * client implementing this is responsible for handling changes related with the lifetime of the
26  * connection like rebinding on disconnect.
27  */
28 public abstract class CustomTabsServiceConnection implements ServiceConnection {
29 
30     @Override
onServiceConnected(ComponentName name, IBinder service)31     public final void onServiceConnected(ComponentName name, IBinder service) {
32         onCustomTabsServiceConnected(name, new CustomTabsClient(
33                 ICustomTabsService.Stub.asInterface(service), name) {
34         });
35     }
36 
37     /**
38      * Called when a connection to the {@link CustomTabsService} has been established.
39      * @param name   The concrete component name of the service that has been connected.
40      * @param client {@link CustomTabsClient} that contains the {@link IBinder} with which the
41      *               connection have been established. All further communication should be initiated
42      *               using this client.
43      */
onCustomTabsServiceConnected(ComponentName name, CustomTabsClient client)44     public abstract void onCustomTabsServiceConnected(ComponentName name, CustomTabsClient client);
45 }
46