| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2015 The Android Open Source Project | 2 * Copyright (C) 2015 The Android Open Source Project |
| 3 * | 3 * |
| 4 * Licensed under the Apache License, Version 2.0 (the "License"); | 4 * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 * you may not use this file except in compliance with 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 | 6 * You may obtain a copy of the License at |
| 7 * | 7 * |
| 8 * http://www.apache.org/licenses/LICENSE-2.0 | 8 * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 * | 9 * |
| 10 * Unless required by applicable law or agreed to in writing, software | 10 * Unless required by applicable law or agreed to in writing, software |
| 11 * distributed under the License is distributed on an "AS IS" BASIS, | 11 * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 * See the License for the specific language governing permissions and | 13 * See the License for the specific language governing permissions and |
| 14 * limitations under the License. | 14 * limitations under the License. |
| 15 */ | 15 */ |
| 16 | 16 |
| 17 package android.support.customtabs; | 17 package android.support.customtabs; |
| 18 | 18 |
| 19 import android.app.Service; | 19 import android.app.Service; |
| 20 import android.content.Intent; | 20 import android.content.Intent; |
| 21 import android.net.Uri; | 21 import android.net.Uri; |
| 22 import android.os.Bundle; | 22 import android.os.Bundle; |
| 23 import android.os.IBinder; | 23 import android.os.IBinder; |
| 24 import android.os.IBinder.DeathRecipient; | 24 import android.os.IBinder.DeathRecipient; |
| 25 import android.os.RemoteException; | 25 import android.os.RemoteException; |
| 26 import android.util.ArrayMap; | 26 import android.support.v4.util.ArrayMap; |
| 27 | 27 |
| 28 import java.util.List; | 28 import java.util.List; |
| 29 import java.util.Map; | 29 import java.util.Map; |
| 30 import java.util.NoSuchElementException; | 30 import java.util.NoSuchElementException; |
| 31 | 31 |
| 32 /** | 32 /** |
| 33 * Abstract service class for implementing Custom Tabs related functionality. Th
e service should | 33 * Abstract service class for implementing Custom Tabs related functionality. Th
e service should |
| 34 * be responding to the action ACTION_CUSTOM_TABS_CONNECTION. This class should
be used by | 34 * be responding to the action ACTION_CUSTOM_TABS_CONNECTION. This class should
be used by |
| 35 * implementers that want to provide Custom Tabs functionality, not by clients t
hat want to launch | 35 * implementers that want to provide Custom Tabs functionality, not by clients t
hat want to launch |
| 36 * Custom Tabs. | 36 * Custom Tabs. |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 83 public boolean mayLaunchUrl(ICustomTabsCallback callback, Uri url, | 83 public boolean mayLaunchUrl(ICustomTabsCallback callback, Uri url, |
| 84 Bundle extras, List<Bundle> otherLikelyBundles) { | 84 Bundle extras, List<Bundle> otherLikelyBundles) { |
| 85 return CustomTabsService.this.mayLaunchUrl( | 85 return CustomTabsService.this.mayLaunchUrl( |
| 86 new CustomTabsSessionToken(callback), url, extras, otherLik
elyBundles); | 86 new CustomTabsSessionToken(callback), url, extras, otherLik
elyBundles); |
| 87 } | 87 } |
| 88 | 88 |
| 89 @Override | 89 @Override |
| 90 public Bundle extraCommand(String commandName, Bundle args) { | 90 public Bundle extraCommand(String commandName, Bundle args) { |
| 91 return CustomTabsService.this.extraCommand(commandName, args); | 91 return CustomTabsService.this.extraCommand(commandName, args); |
| 92 } | 92 } |
| 93 |
| 94 @Override |
| 95 public boolean updateVisuals(ICustomTabsCallback callback, Bundle bundl
e) { |
| 96 return CustomTabsService.this.updateVisuals( |
| 97 new CustomTabsSessionToken(callback), bundle); |
| 98 } |
| 93 }; | 99 }; |
| 94 | 100 |
| 95 @Override | 101 @Override |
| 96 public IBinder onBind(Intent intent) { | 102 public IBinder onBind(Intent intent) { |
| 97 return mBinder; | 103 return mBinder; |
| 98 } | 104 } |
| 99 | 105 |
| 100 /** | 106 /** |
| 101 * Called when the client side {@link IBinder} for this {@link CustomTabsSe
ssionToken} is dead. | 107 * Called when the client side {@link IBinder} for this {@link CustomTabsSe
ssionToken} is dead. |
| 102 * Can also be used to clean up {@link DeathRecipient} instances allocated
for the given token. | 108 * Can also be used to clean up {@link DeathRecipient} instances allocated
for the given token. |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 169 * defined behavior, as it is entirely implementation-defined and not suppo
rted. | 175 * defined behavior, as it is entirely implementation-defined and not suppo
rted. |
| 170 * | 176 * |
| 171 * <p> This call can be used by implementations to add extra commands, for
testing or | 177 * <p> This call can be used by implementations to add extra commands, for
testing or |
| 172 * experimental purposes. | 178 * experimental purposes. |
| 173 * | 179 * |
| 174 * @param commandName Name of the extra command to execute. | 180 * @param commandName Name of the extra command to execute. |
| 175 * @param args Arguments for the command | 181 * @param args Arguments for the command |
| 176 * @return The result {@link Bundle}, or null. | 182 * @return The result {@link Bundle}, or null. |
| 177 */ | 183 */ |
| 178 protected abstract Bundle extraCommand(String commandName, Bundle args); | 184 protected abstract Bundle extraCommand(String commandName, Bundle args); |
| 185 |
| 186 /** |
| 187 * Updates the visuals of custom tabs for the given session. Will only succe
ed if the given |
| 188 * session matches the currently active one. |
| 189 * @param sessionToken The currently active session that the custom tab belo
ngs to. |
| 190 * @param bundle The action button configuration bundle. This bundle s
hould be constructed |
| 191 * with the same structure in {@link CustomTabsIntent.Bu
ilder}. |
| 192 * @return Whether the operation was successful. |
| 193 */ |
| 194 protected abstract boolean updateVisuals(CustomTabsSessionToken sessionToke
n, |
| 195 Bundle bundle); |
| 179 } | 196 } |
| OLD | NEW |