The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2008 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.accounts; |
| 18 | |
| 19 | import android.content.Intent; |
| 20 | |
| 21 | /** |
| 22 | * Miscellaneous constants used by the AccountsService and its |
| 23 | * clients. |
| 24 | */ |
| 25 | // TODO: These constants *could* come directly from the |
| 26 | // IAccountsService interface, but that's not possible since the |
| 27 | // aidl compiler doesn't let you define constants (yet.) |
| 28 | public class AccountsServiceConstants { |
| 29 | /** This class is never instantiated. */ |
| 30 | private AccountsServiceConstants() { |
| 31 | } |
| 32 | |
| 33 | /** |
| 34 | * Action sent as a broadcast Intent by the AccountsService |
| 35 | * when accounts are added to and/or removed from the device's |
| 36 | * database, or when the primary account is changed. |
| 37 | */ |
| 38 | public static final String LOGIN_ACCOUNTS_CHANGED_ACTION = |
| 39 | "android.accounts.LOGIN_ACCOUNTS_CHANGED"; |
| 40 | |
| 41 | /** |
| 42 | * Action sent as a broadcast Intent by the AccountsService |
| 43 | * when it starts up and no accounts are available (so some should be added). |
| 44 | */ |
| 45 | public static final String LOGIN_ACCOUNTS_MISSING_ACTION = |
| 46 | "android.accounts.LOGIN_ACCOUNTS_MISSING"; |
| 47 | |
| 48 | /** |
| 49 | * Action on the intent used to bind to the IAccountsService interface. This |
| 50 | * is used for services that have multiple interfaces (allowing |
| 51 | * them to differentiate the interface intended, and return the proper |
| 52 | * Binder.) |
| 53 | */ |
| 54 | private static final String ACCOUNTS_SERVICE_ACTION = "android.accounts.IAccountsService"; |
| 55 | |
| 56 | /* |
| 57 | * The intent uses a component in addition to the action to ensure the actual |
| 58 | * accounts service is bound to (a malicious third-party app could |
| 59 | * theoretically have a service with the same action). |
| 60 | */ |
| 61 | /** The intent used to bind to the accounts service. */ |
| 62 | public static final Intent SERVICE_INTENT = |
| 63 | new Intent() |
| 64 | .setClassName("com.google.android.googleapps", |
| 65 | "com.google.android.googleapps.GoogleLoginService") |
| 66 | .setAction(ACCOUNTS_SERVICE_ACTION); |
| 67 | |
| 68 | /** |
| 69 | * Checks whether the intent is to bind to the accounts service. |
| 70 | * |
| 71 | * @param bindIntent The Intent used to bind to the service. |
| 72 | * @return Whether the intent is to bind to the accounts service. |
| 73 | */ |
| 74 | public static final boolean isForAccountsService(Intent bindIntent) { |
| 75 | String otherAction = bindIntent.getAction(); |
| 76 | return otherAction != null && otherAction.equals(ACCOUNTS_SERVICE_ACTION); |
| 77 | } |
| 78 | } |