John Spurlock | 7340fc8 | 2014-04-24 18:50:12 -0400 | [diff] [blame] | 1 | /** |
| 2 | * Copyright (c) 2014, 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 com.android.server.notification; |
| 18 | |
Ruben Brunk | e24b9a6 | 2016-02-16 21:38:24 -0800 | [diff] [blame] | 19 | import android.annotation.NonNull; |
John Spurlock | 7340fc8 | 2014-04-24 18:50:12 -0400 | [diff] [blame] | 20 | import android.app.ActivityManager; |
| 21 | import android.app.PendingIntent; |
Christopher Tate | 6597e34 | 2015-02-17 12:15:25 -0800 | [diff] [blame] | 22 | import android.content.BroadcastReceiver; |
John Spurlock | 7340fc8 | 2014-04-24 18:50:12 -0400 | [diff] [blame] | 23 | import android.content.ComponentName; |
| 24 | import android.content.ContentResolver; |
| 25 | import android.content.Context; |
| 26 | import android.content.Intent; |
Christopher Tate | 6597e34 | 2015-02-17 12:15:25 -0800 | [diff] [blame] | 27 | import android.content.IntentFilter; |
John Spurlock | 7340fc8 | 2014-04-24 18:50:12 -0400 | [diff] [blame] | 28 | import android.content.ServiceConnection; |
| 29 | import android.content.pm.ApplicationInfo; |
| 30 | import android.content.pm.PackageManager; |
| 31 | import android.content.pm.PackageManager.NameNotFoundException; |
| 32 | import android.content.pm.ResolveInfo; |
| 33 | import android.content.pm.ServiceInfo; |
| 34 | import android.content.pm.UserInfo; |
| 35 | import android.database.ContentObserver; |
| 36 | import android.net.Uri; |
| 37 | import android.os.Build; |
| 38 | import android.os.Handler; |
| 39 | import android.os.IBinder; |
| 40 | import android.os.IInterface; |
| 41 | import android.os.RemoteException; |
| 42 | import android.os.UserHandle; |
| 43 | import android.os.UserManager; |
| 44 | import android.provider.Settings; |
| 45 | import android.text.TextUtils; |
Ruben Brunk | dd18a0b | 2015-12-04 16:16:31 -0800 | [diff] [blame] | 46 | import android.util.ArrayMap; |
John Spurlock | 7340fc8 | 2014-04-24 18:50:12 -0400 | [diff] [blame] | 47 | import android.util.ArraySet; |
John Spurlock | 4db0d98 | 2014-08-13 09:19:03 -0400 | [diff] [blame] | 48 | import android.util.Log; |
John Spurlock | 7340fc8 | 2014-04-24 18:50:12 -0400 | [diff] [blame] | 49 | import android.util.Slog; |
| 50 | import android.util.SparseArray; |
| 51 | |
John Spurlock | 25e2d24 | 2014-06-27 13:58:23 -0400 | [diff] [blame] | 52 | import com.android.server.notification.NotificationManagerService.DumpFilter; |
| 53 | |
John Spurlock | 7340fc8 | 2014-04-24 18:50:12 -0400 | [diff] [blame] | 54 | import java.io.PrintWriter; |
| 55 | import java.util.ArrayList; |
John Spurlock | e77bb36 | 2014-04-26 10:24:59 -0400 | [diff] [blame] | 56 | import java.util.Arrays; |
Julia Reynolds | 9a86cc0 | 2016-02-10 15:38:15 -0500 | [diff] [blame] | 57 | import java.util.HashSet; |
John Spurlock | 7340fc8 | 2014-04-24 18:50:12 -0400 | [diff] [blame] | 58 | import java.util.List; |
Ruben Brunk | dd18a0b | 2015-12-04 16:16:31 -0800 | [diff] [blame] | 59 | import java.util.Map.Entry; |
Christopher Tate | 6597e34 | 2015-02-17 12:15:25 -0800 | [diff] [blame] | 60 | import java.util.Objects; |
John Spurlock | 7340fc8 | 2014-04-24 18:50:12 -0400 | [diff] [blame] | 61 | import java.util.Set; |
| 62 | |
| 63 | /** |
| 64 | * Manages the lifecycle of application-provided services bound by system server. |
| 65 | * |
| 66 | * Services managed by this helper must have: |
| 67 | * - An associated system settings value with a list of enabled component names. |
| 68 | * - A well-known action for services to use in their intent-filter. |
| 69 | * - A system permission for services to require in order to ensure system has exclusive binding. |
| 70 | * - A settings page for user configuration of enabled services, and associated intent action. |
| 71 | * - A remote interface definition (aidl) provided by the service used for communication. |
| 72 | */ |
| 73 | abstract public class ManagedServices { |
| 74 | protected final String TAG = getClass().getSimpleName(); |
John Spurlock | 4db0d98 | 2014-08-13 09:19:03 -0400 | [diff] [blame] | 75 | protected final boolean DEBUG = Log.isLoggable(TAG, Log.DEBUG); |
John Spurlock | 7340fc8 | 2014-04-24 18:50:12 -0400 | [diff] [blame] | 76 | |
Julia Reynolds | c279b99 | 2015-10-30 08:23:51 -0400 | [diff] [blame] | 77 | protected static final String ENABLED_SERVICES_SEPARATOR = ":"; |
John Spurlock | 7340fc8 | 2014-04-24 18:50:12 -0400 | [diff] [blame] | 78 | |
John Spurlock | af8d6c4 | 2014-05-07 17:49:08 -0400 | [diff] [blame] | 79 | protected final Context mContext; |
John Spurlock | e77bb36 | 2014-04-26 10:24:59 -0400 | [diff] [blame] | 80 | protected final Object mMutex; |
John Spurlock | 7340fc8 | 2014-04-24 18:50:12 -0400 | [diff] [blame] | 81 | private final UserProfiles mUserProfiles; |
| 82 | private final SettingsObserver mSettingsObserver; |
| 83 | private final Config mConfig; |
Christopher Tate | 6597e34 | 2015-02-17 12:15:25 -0800 | [diff] [blame] | 84 | private ArraySet<String> mRestored; |
John Spurlock | 7340fc8 | 2014-04-24 18:50:12 -0400 | [diff] [blame] | 85 | |
| 86 | // contains connections to all connected services, including app services |
| 87 | // and system services |
| 88 | protected final ArrayList<ManagedServiceInfo> mServices = new ArrayList<ManagedServiceInfo>(); |
| 89 | // things that will be put into mServices as soon as they're ready |
| 90 | private final ArrayList<String> mServicesBinding = new ArrayList<String>(); |
Chris Wren | ab41eec | 2016-01-04 18:01:27 -0500 | [diff] [blame] | 91 | // lists the component names of all enabled (and therefore potentially connected) |
John Spurlock | 7340fc8 | 2014-04-24 18:50:12 -0400 | [diff] [blame] | 92 | // app services for current profiles. |
| 93 | private ArraySet<ComponentName> mEnabledServicesForCurrentProfiles |
| 94 | = new ArraySet<ComponentName>(); |
| 95 | // Just the packages from mEnabledServicesForCurrentProfiles |
| 96 | private ArraySet<String> mEnabledServicesPackageNames = new ArraySet<String>(); |
Denis Kuznetsov | 76c0268 | 2015-09-17 19:57:00 +0200 | [diff] [blame] | 97 | // List of packages in restored setting across all mUserProfiles, for quick |
| 98 | // filtering upon package updates. |
| 99 | private ArraySet<String> mRestoredPackages = new ArraySet<>(); |
Chris Wren | ab41eec | 2016-01-04 18:01:27 -0500 | [diff] [blame] | 100 | // List of enabled packages that have nevertheless asked not to be run |
| 101 | private ArraySet<ComponentName> mSnoozingForCurrentProfiles = new ArraySet<>(); |
Denis Kuznetsov | 76c0268 | 2015-09-17 19:57:00 +0200 | [diff] [blame] | 102 | |
John Spurlock | 7340fc8 | 2014-04-24 18:50:12 -0400 | [diff] [blame] | 103 | |
Christoph Studer | b53dfd4 | 2014-09-12 14:45:59 +0200 | [diff] [blame] | 104 | // Kept to de-dupe user change events (experienced after boot, when we receive a settings and a |
| 105 | // user change). |
| 106 | private int[] mLastSeenProfileIds; |
| 107 | |
Christopher Tate | 6597e34 | 2015-02-17 12:15:25 -0800 | [diff] [blame] | 108 | private final BroadcastReceiver mRestoreReceiver; |
| 109 | |
John Spurlock | 7340fc8 | 2014-04-24 18:50:12 -0400 | [diff] [blame] | 110 | public ManagedServices(Context context, Handler handler, Object mutex, |
| 111 | UserProfiles userProfiles) { |
| 112 | mContext = context; |
| 113 | mMutex = mutex; |
| 114 | mUserProfiles = userProfiles; |
| 115 | mConfig = getConfig(); |
| 116 | mSettingsObserver = new SettingsObserver(handler); |
Christopher Tate | 6597e34 | 2015-02-17 12:15:25 -0800 | [diff] [blame] | 117 | |
| 118 | mRestoreReceiver = new SettingRestoredReceiver(); |
| 119 | IntentFilter filter = new IntentFilter(Intent.ACTION_SETTING_RESTORED); |
| 120 | context.registerReceiver(mRestoreReceiver, filter); |
Denis Kuznetsov | 76c0268 | 2015-09-17 19:57:00 +0200 | [diff] [blame] | 121 | rebuildRestoredPackages(); |
Christopher Tate | 6597e34 | 2015-02-17 12:15:25 -0800 | [diff] [blame] | 122 | } |
| 123 | |
| 124 | class SettingRestoredReceiver extends BroadcastReceiver { |
| 125 | @Override |
| 126 | public void onReceive(Context context, Intent intent) { |
| 127 | if (Intent.ACTION_SETTING_RESTORED.equals(intent.getAction())) { |
| 128 | String element = intent.getStringExtra(Intent.EXTRA_SETTING_NAME); |
Julia Reynolds | 6e839b0 | 2016-04-13 10:01:17 -0400 | [diff] [blame^] | 129 | if (Objects.equals(element, mConfig.secureSettingName) |
| 130 | || Objects.equals(element, mConfig.secondarySettingName)) { |
Christopher Tate | 6597e34 | 2015-02-17 12:15:25 -0800 | [diff] [blame] | 131 | String prevValue = intent.getStringExtra(Intent.EXTRA_SETTING_PREVIOUS_VALUE); |
| 132 | String newValue = intent.getStringExtra(Intent.EXTRA_SETTING_NEW_VALUE); |
| 133 | settingRestored(element, prevValue, newValue, getSendingUserId()); |
| 134 | } |
| 135 | } |
| 136 | } |
John Spurlock | 7340fc8 | 2014-04-24 18:50:12 -0400 | [diff] [blame] | 137 | } |
| 138 | |
| 139 | abstract protected Config getConfig(); |
| 140 | |
| 141 | private String getCaption() { |
| 142 | return mConfig.caption; |
| 143 | } |
| 144 | |
| 145 | abstract protected IInterface asInterface(IBinder binder); |
| 146 | |
Chris Wren | 51017d0 | 2015-12-15 15:34:46 -0500 | [diff] [blame] | 147 | abstract protected boolean checkType(IInterface service); |
| 148 | |
John Spurlock | 3b98b3f | 2014-05-01 09:08:48 -0400 | [diff] [blame] | 149 | abstract protected void onServiceAdded(ManagedServiceInfo info); |
John Spurlock | 7340fc8 | 2014-04-24 18:50:12 -0400 | [diff] [blame] | 150 | |
John Spurlock | e77bb36 | 2014-04-26 10:24:59 -0400 | [diff] [blame] | 151 | protected void onServiceRemovedLocked(ManagedServiceInfo removed) { } |
| 152 | |
John Spurlock | 7340fc8 | 2014-04-24 18:50:12 -0400 | [diff] [blame] | 153 | private ManagedServiceInfo newServiceInfo(IInterface service, |
| 154 | ComponentName component, int userid, boolean isSystem, ServiceConnection connection, |
| 155 | int targetSdkVersion) { |
| 156 | return new ManagedServiceInfo(service, component, userid, isSystem, connection, |
| 157 | targetSdkVersion); |
| 158 | } |
| 159 | |
| 160 | public void onBootPhaseAppsCanStart() { |
| 161 | mSettingsObserver.observe(); |
| 162 | } |
| 163 | |
John Spurlock | 25e2d24 | 2014-06-27 13:58:23 -0400 | [diff] [blame] | 164 | public void dump(PrintWriter pw, DumpFilter filter) { |
John Spurlock | e77bb36 | 2014-04-26 10:24:59 -0400 | [diff] [blame] | 165 | pw.println(" All " + getCaption() + "s (" + mEnabledServicesForCurrentProfiles.size() |
John Spurlock | 7340fc8 | 2014-04-24 18:50:12 -0400 | [diff] [blame] | 166 | + ") enabled for current profiles:"); |
| 167 | for (ComponentName cmpt : mEnabledServicesForCurrentProfiles) { |
John Spurlock | 25e2d24 | 2014-06-27 13:58:23 -0400 | [diff] [blame] | 168 | if (filter != null && !filter.matches(cmpt)) continue; |
John Spurlock | e77bb36 | 2014-04-26 10:24:59 -0400 | [diff] [blame] | 169 | pw.println(" " + cmpt); |
John Spurlock | 7340fc8 | 2014-04-24 18:50:12 -0400 | [diff] [blame] | 170 | } |
| 171 | |
John Spurlock | e77bb36 | 2014-04-26 10:24:59 -0400 | [diff] [blame] | 172 | pw.println(" Live " + getCaption() + "s (" + mServices.size() + "):"); |
John Spurlock | 7340fc8 | 2014-04-24 18:50:12 -0400 | [diff] [blame] | 173 | for (ManagedServiceInfo info : mServices) { |
John Spurlock | 25e2d24 | 2014-06-27 13:58:23 -0400 | [diff] [blame] | 174 | if (filter != null && !filter.matches(info.component)) continue; |
John Spurlock | e77bb36 | 2014-04-26 10:24:59 -0400 | [diff] [blame] | 175 | pw.println(" " + info.component |
John Spurlock | 7340fc8 | 2014-04-24 18:50:12 -0400 | [diff] [blame] | 176 | + " (user " + info.userid + "): " + info.service |
Chris Wren | 51017d0 | 2015-12-15 15:34:46 -0500 | [diff] [blame] | 177 | + (info.isSystem?" SYSTEM":"") |
| 178 | + (info.isGuest(this)?" GUEST":"")); |
John Spurlock | 7340fc8 | 2014-04-24 18:50:12 -0400 | [diff] [blame] | 179 | } |
Chris Wren | ab41eec | 2016-01-04 18:01:27 -0500 | [diff] [blame] | 180 | |
| 181 | pw.println(" Snoozed " + getCaption() + "s (" + |
| 182 | mSnoozingForCurrentProfiles.size() + "):"); |
| 183 | for (ComponentName name : mSnoozingForCurrentProfiles) { |
| 184 | pw.println(" " + name.flattenToShortString()); |
| 185 | } |
John Spurlock | 7340fc8 | 2014-04-24 18:50:12 -0400 | [diff] [blame] | 186 | } |
| 187 | |
Christopher Tate | 6597e34 | 2015-02-17 12:15:25 -0800 | [diff] [blame] | 188 | // By convention, restored settings are replicated to another settings |
| 189 | // entry, named similarly but with a disambiguation suffix. |
Julia Reynolds | 6e839b0 | 2016-04-13 10:01:17 -0400 | [diff] [blame^] | 190 | public static String restoredSettingName(String setting) { |
| 191 | return setting + ":restored"; |
Christopher Tate | 6597e34 | 2015-02-17 12:15:25 -0800 | [diff] [blame] | 192 | } |
| 193 | |
| 194 | // The OS has done a restore of this service's saved state. We clone it to the |
| 195 | // 'restored' reserve, and then once we return and the actual write to settings is |
| 196 | // performed, our observer will do the work of maintaining the restored vs live |
| 197 | // settings data. |
| 198 | public void settingRestored(String element, String oldValue, String newValue, int userid) { |
| 199 | if (DEBUG) Slog.d(TAG, "Restored managed service setting: " + element |
| 200 | + " ovalue=" + oldValue + " nvalue=" + newValue); |
Julia Reynolds | 6e839b0 | 2016-04-13 10:01:17 -0400 | [diff] [blame^] | 201 | if (mConfig.secureSettingName.equals(element) || |
| 202 | mConfig.secondarySettingName.equals(element)) { |
Christopher Tate | 6597e34 | 2015-02-17 12:15:25 -0800 | [diff] [blame] | 203 | if (element != null) { |
Christopher Tate | 6597e34 | 2015-02-17 12:15:25 -0800 | [diff] [blame] | 204 | Settings.Secure.putStringForUser(mContext.getContentResolver(), |
Julia Reynolds | 6e839b0 | 2016-04-13 10:01:17 -0400 | [diff] [blame^] | 205 | restoredSettingName(element), |
Christopher Tate | 6597e34 | 2015-02-17 12:15:25 -0800 | [diff] [blame] | 206 | newValue, |
| 207 | userid); |
Julia Reynolds | 6e839b0 | 2016-04-13 10:01:17 -0400 | [diff] [blame^] | 208 | updateSettingsAccordingToInstalledServices(element, userid); |
Denis Kuznetsov | 76c0268 | 2015-09-17 19:57:00 +0200 | [diff] [blame] | 209 | rebuildRestoredPackages(); |
Christopher Tate | 6597e34 | 2015-02-17 12:15:25 -0800 | [diff] [blame] | 210 | } |
| 211 | } |
| 212 | } |
| 213 | |
John Spurlock | 8077493 | 2015-05-07 17:38:50 -0400 | [diff] [blame] | 214 | public boolean isComponentEnabledForPackage(String pkg) { |
| 215 | return mEnabledServicesPackageNames.contains(pkg); |
| 216 | } |
| 217 | |
John Spurlock | 7340fc8 | 2014-04-24 18:50:12 -0400 | [diff] [blame] | 218 | public void onPackagesChanged(boolean queryReplace, String[] pkgList) { |
John Spurlock | e77bb36 | 2014-04-26 10:24:59 -0400 | [diff] [blame] | 219 | if (DEBUG) Slog.d(TAG, "onPackagesChanged queryReplace=" + queryReplace |
| 220 | + " pkgList=" + (pkgList == null ? null : Arrays.asList(pkgList)) |
| 221 | + " mEnabledServicesPackageNames=" + mEnabledServicesPackageNames); |
John Spurlock | 7340fc8 | 2014-04-24 18:50:12 -0400 | [diff] [blame] | 222 | boolean anyServicesInvolved = false; |
Denis Kuznetsov | 76c0268 | 2015-09-17 19:57:00 +0200 | [diff] [blame] | 223 | |
John Spurlock | 7340fc8 | 2014-04-24 18:50:12 -0400 | [diff] [blame] | 224 | if (pkgList != null && (pkgList.length > 0)) { |
| 225 | for (String pkgName : pkgList) { |
Denis Kuznetsov | 76c0268 | 2015-09-17 19:57:00 +0200 | [diff] [blame] | 226 | if (mEnabledServicesPackageNames.contains(pkgName) || |
| 227 | mRestoredPackages.contains(pkgName)) { |
John Spurlock | 7340fc8 | 2014-04-24 18:50:12 -0400 | [diff] [blame] | 228 | anyServicesInvolved = true; |
| 229 | } |
| 230 | } |
| 231 | } |
| 232 | |
| 233 | if (anyServicesInvolved) { |
| 234 | // if we're not replacing a package, clean up orphaned bits |
| 235 | if (!queryReplace) { |
Denis Kuznetsov | 76c0268 | 2015-09-17 19:57:00 +0200 | [diff] [blame] | 236 | updateSettingsAccordingToInstalledServices(); |
| 237 | rebuildRestoredPackages(); |
John Spurlock | 7340fc8 | 2014-04-24 18:50:12 -0400 | [diff] [blame] | 238 | } |
| 239 | // make sure we're still bound to any of our services who may have just upgraded |
Julia Reynolds | 1c9bd42 | 2016-03-15 09:25:56 -0400 | [diff] [blame] | 240 | rebindServices(false); |
John Spurlock | 7340fc8 | 2014-04-24 18:50:12 -0400 | [diff] [blame] | 241 | } |
| 242 | } |
| 243 | |
John Spurlock | 1b8b22b | 2015-05-20 09:47:13 -0400 | [diff] [blame] | 244 | public void onUserSwitched(int user) { |
| 245 | if (DEBUG) Slog.d(TAG, "onUserSwitched u=" + user); |
Denis Kuznetsov | 76c0268 | 2015-09-17 19:57:00 +0200 | [diff] [blame] | 246 | rebuildRestoredPackages(); |
Christoph Studer | b53dfd4 | 2014-09-12 14:45:59 +0200 | [diff] [blame] | 247 | if (Arrays.equals(mLastSeenProfileIds, mUserProfiles.getCurrentProfileIds())) { |
| 248 | if (DEBUG) Slog.d(TAG, "Current profile IDs didn't change, skipping rebindServices()."); |
| 249 | return; |
| 250 | } |
Julia Reynolds | 1c9bd42 | 2016-03-15 09:25:56 -0400 | [diff] [blame] | 251 | rebindServices(true); |
Christoph Studer | b53dfd4 | 2014-09-12 14:45:59 +0200 | [diff] [blame] | 252 | } |
| 253 | |
Julia Reynolds | a3dcaff | 2016-02-03 15:04:05 -0500 | [diff] [blame] | 254 | public void onUserUnlocked(int user) { |
| 255 | if (DEBUG) Slog.d(TAG, "onUserUnlocked u=" + user); |
| 256 | rebuildRestoredPackages(); |
Julia Reynolds | 1c9bd42 | 2016-03-15 09:25:56 -0400 | [diff] [blame] | 257 | rebindServices(false); |
Julia Reynolds | a3dcaff | 2016-02-03 15:04:05 -0500 | [diff] [blame] | 258 | } |
| 259 | |
Chris Wren | ab41eec | 2016-01-04 18:01:27 -0500 | [diff] [blame] | 260 | public ManagedServiceInfo getServiceFromTokenLocked(IInterface service) { |
| 261 | if (service == null) { |
| 262 | return null; |
| 263 | } |
John Spurlock | 7340fc8 | 2014-04-24 18:50:12 -0400 | [diff] [blame] | 264 | final IBinder token = service.asBinder(); |
| 265 | final int N = mServices.size(); |
Denis Kuznetsov | 76c0268 | 2015-09-17 19:57:00 +0200 | [diff] [blame] | 266 | for (int i = 0; i < N; i++) { |
John Spurlock | 7340fc8 | 2014-04-24 18:50:12 -0400 | [diff] [blame] | 267 | final ManagedServiceInfo info = mServices.get(i); |
| 268 | if (info.service.asBinder() == token) return info; |
| 269 | } |
Chris Wren | ab41eec | 2016-01-04 18:01:27 -0500 | [diff] [blame] | 270 | return null; |
| 271 | } |
| 272 | |
| 273 | public ManagedServiceInfo checkServiceTokenLocked(IInterface service) { |
| 274 | checkNotNull(service); |
| 275 | ManagedServiceInfo info = getServiceFromTokenLocked(service); |
| 276 | if (info != null) { |
| 277 | return info; |
| 278 | } |
John Spurlock | 7340fc8 | 2014-04-24 18:50:12 -0400 | [diff] [blame] | 279 | throw new SecurityException("Disallowed call from unknown " + getCaption() + ": " |
| 280 | + service); |
| 281 | } |
| 282 | |
| 283 | public void unregisterService(IInterface service, int userid) { |
| 284 | checkNotNull(service); |
| 285 | // no need to check permissions; if your service binder is in the list, |
| 286 | // that's proof that you had permission to add it in the first place |
| 287 | unregisterServiceImpl(service, userid); |
| 288 | } |
| 289 | |
| 290 | public void registerService(IInterface service, ComponentName component, int userid) { |
| 291 | checkNotNull(service); |
Christoph Studer | 3e144d3 | 2014-05-22 16:48:40 +0200 | [diff] [blame] | 292 | ManagedServiceInfo info = registerServiceImpl(service, component, userid); |
| 293 | if (info != null) { |
| 294 | onServiceAdded(info); |
| 295 | } |
John Spurlock | 7340fc8 | 2014-04-24 18:50:12 -0400 | [diff] [blame] | 296 | } |
| 297 | |
Chris Wren | 51017d0 | 2015-12-15 15:34:46 -0500 | [diff] [blame] | 298 | /** |
| 299 | * Add a service to our callbacks. The lifecycle of this service is managed externally, |
| 300 | * but unlike a system service, it should not be considered privledged. |
| 301 | * */ |
| 302 | public void registerGuestService(ManagedServiceInfo guest) { |
| 303 | checkNotNull(guest.service); |
Ruben Brunk | e24b9a6 | 2016-02-16 21:38:24 -0800 | [diff] [blame] | 304 | if (!checkType(guest.service)) { |
| 305 | throw new IllegalArgumentException(); |
| 306 | } |
Chris Wren | 51017d0 | 2015-12-15 15:34:46 -0500 | [diff] [blame] | 307 | if (registerServiceImpl(guest) != null) { |
| 308 | onServiceAdded(guest); |
Chris Wren | ab41eec | 2016-01-04 18:01:27 -0500 | [diff] [blame] | 309 | } |
| 310 | } |
| 311 | |
| 312 | public void setComponentState(ComponentName component, boolean enabled) { |
| 313 | boolean previous = !mSnoozingForCurrentProfiles.contains(component); |
| 314 | if (previous == enabled) { |
| 315 | return; |
| 316 | } |
| 317 | |
| 318 | if (enabled) { |
| 319 | mSnoozingForCurrentProfiles.remove(component); |
| 320 | } else { |
| 321 | mSnoozingForCurrentProfiles.add(component); |
| 322 | } |
| 323 | |
| 324 | // State changed |
| 325 | if (DEBUG) { |
| 326 | Slog.d(TAG, ((enabled) ? "Enabling " : "Disabling ") + "component " + |
| 327 | component.flattenToShortString()); |
| 328 | } |
| 329 | |
Chris Wren | 0efdb88 | 2016-03-01 17:17:47 -0500 | [diff] [blame] | 330 | |
| 331 | synchronized (mMutex) { |
| 332 | final int[] userIds = mUserProfiles.getCurrentProfileIds(); |
| 333 | |
| 334 | for (int userId : userIds) { |
| 335 | if (enabled) { |
| 336 | registerServiceLocked(component, userId); |
| 337 | } else { |
| 338 | unregisterServiceLocked(component, userId); |
| 339 | } |
Chris Wren | ab41eec | 2016-01-04 18:01:27 -0500 | [diff] [blame] | 340 | } |
Chris Wren | 51017d0 | 2015-12-15 15:34:46 -0500 | [diff] [blame] | 341 | } |
| 342 | } |
| 343 | |
Denis Kuznetsov | 76c0268 | 2015-09-17 19:57:00 +0200 | [diff] [blame] | 344 | private void rebuildRestoredPackages() { |
| 345 | mRestoredPackages.clear(); |
Chris Wren | ab41eec | 2016-01-04 18:01:27 -0500 | [diff] [blame] | 346 | mSnoozingForCurrentProfiles.clear(); |
Julia Reynolds | 6e839b0 | 2016-04-13 10:01:17 -0400 | [diff] [blame^] | 347 | String secureSettingName = restoredSettingName(mConfig.secureSettingName); |
| 348 | String secondarySettingName = mConfig.secondarySettingName == null |
| 349 | ? null : restoredSettingName(mConfig.secondarySettingName); |
John Spurlock | 7340fc8 | 2014-04-24 18:50:12 -0400 | [diff] [blame] | 350 | int[] userIds = mUserProfiles.getCurrentProfileIds(); |
| 351 | final int N = userIds.length; |
Denis Kuznetsov | 76c0268 | 2015-09-17 19:57:00 +0200 | [diff] [blame] | 352 | for (int i = 0; i < N; ++i) { |
Julia Reynolds | 6e839b0 | 2016-04-13 10:01:17 -0400 | [diff] [blame^] | 353 | ArraySet<ComponentName> names = |
| 354 | loadComponentNamesFromSetting(secureSettingName, userIds[i]); |
| 355 | if (secondarySettingName != null) { |
| 356 | names.addAll(loadComponentNamesFromSetting(secondarySettingName, userIds[i])); |
| 357 | } |
| 358 | for (ComponentName name : names) { |
Denis Kuznetsov | 76c0268 | 2015-09-17 19:57:00 +0200 | [diff] [blame] | 359 | mRestoredPackages.add(name.getPackageName()); |
| 360 | } |
John Spurlock | 7340fc8 | 2014-04-24 18:50:12 -0400 | [diff] [blame] | 361 | } |
| 362 | } |
| 363 | |
Denis Kuznetsov | 76c0268 | 2015-09-17 19:57:00 +0200 | [diff] [blame] | 364 | |
Julia Reynolds | 6e839b0 | 2016-04-13 10:01:17 -0400 | [diff] [blame^] | 365 | protected @NonNull ArraySet<ComponentName> loadComponentNamesFromSetting(String settingName, |
Julia Reynolds | c279b99 | 2015-10-30 08:23:51 -0400 | [diff] [blame] | 366 | int userId) { |
Christopher Tate | 6597e34 | 2015-02-17 12:15:25 -0800 | [diff] [blame] | 367 | final ContentResolver cr = mContext.getContentResolver(); |
Denis Kuznetsov | 76c0268 | 2015-09-17 19:57:00 +0200 | [diff] [blame] | 368 | String settingValue = Settings.Secure.getStringForUser( |
Ruben Brunk | dd18a0b | 2015-12-04 16:16:31 -0800 | [diff] [blame] | 369 | cr, |
| 370 | settingName, |
| 371 | userId); |
Denis Kuznetsov | 76c0268 | 2015-09-17 19:57:00 +0200 | [diff] [blame] | 372 | if (TextUtils.isEmpty(settingValue)) |
Julia Reynolds | 6e839b0 | 2016-04-13 10:01:17 -0400 | [diff] [blame^] | 373 | return new ArraySet<>(); |
Denis Kuznetsov | 76c0268 | 2015-09-17 19:57:00 +0200 | [diff] [blame] | 374 | String[] restored = settingValue.split(ENABLED_SERVICES_SEPARATOR); |
| 375 | ArraySet<ComponentName> result = new ArraySet<>(restored.length); |
| 376 | for (int i = 0; i < restored.length; i++) { |
| 377 | ComponentName value = ComponentName.unflattenFromString(restored[i]); |
| 378 | if (null != value) { |
| 379 | result.add(value); |
Christopher Tate | 6597e34 | 2015-02-17 12:15:25 -0800 | [diff] [blame] | 380 | } |
| 381 | } |
Denis Kuznetsov | 76c0268 | 2015-09-17 19:57:00 +0200 | [diff] [blame] | 382 | return result; |
| 383 | } |
John Spurlock | 7340fc8 | 2014-04-24 18:50:12 -0400 | [diff] [blame] | 384 | |
Denis Kuznetsov | 76c0268 | 2015-09-17 19:57:00 +0200 | [diff] [blame] | 385 | private void storeComponentsToSetting(Set<ComponentName> components, |
| 386 | String settingName, |
| 387 | int userId) { |
| 388 | String[] componentNames = null; |
| 389 | if (null != components) { |
| 390 | componentNames = new String[components.size()]; |
| 391 | int index = 0; |
| 392 | for (ComponentName c: components) { |
| 393 | componentNames[index++] = c.flattenToString(); |
| 394 | } |
| 395 | } |
| 396 | final String value = (componentNames == null) ? "" : |
| 397 | TextUtils.join(ENABLED_SERVICES_SEPARATOR, componentNames); |
| 398 | final ContentResolver cr = mContext.getContentResolver(); |
| 399 | Settings.Secure.putStringForUser( |
Ruben Brunk | dd18a0b | 2015-12-04 16:16:31 -0800 | [diff] [blame] | 400 | cr, |
| 401 | settingName, |
| 402 | value, |
| 403 | userId); |
Denis Kuznetsov | 76c0268 | 2015-09-17 19:57:00 +0200 | [diff] [blame] | 404 | } |
| 405 | |
Denis Kuznetsov | 76c0268 | 2015-09-17 19:57:00 +0200 | [diff] [blame] | 406 | /** |
| 407 | * Remove access for any services that no longer exist. |
| 408 | */ |
| 409 | private void updateSettingsAccordingToInstalledServices() { |
| 410 | int[] userIds = mUserProfiles.getCurrentProfileIds(); |
| 411 | final int N = userIds.length; |
| 412 | for (int i = 0; i < N; ++i) { |
Julia Reynolds | 6e839b0 | 2016-04-13 10:01:17 -0400 | [diff] [blame^] | 413 | updateSettingsAccordingToInstalledServices(mConfig.secureSettingName, userIds[i]); |
| 414 | if (mConfig.secondarySettingName != null) { |
| 415 | updateSettingsAccordingToInstalledServices( |
| 416 | mConfig.secondarySettingName, userIds[i]); |
| 417 | } |
Denis Kuznetsov | 76c0268 | 2015-09-17 19:57:00 +0200 | [diff] [blame] | 418 | } |
| 419 | rebuildRestoredPackages(); |
| 420 | } |
| 421 | |
Julia Reynolds | c279b99 | 2015-10-30 08:23:51 -0400 | [diff] [blame] | 422 | protected Set<ComponentName> queryPackageForServices(String packageName, int userId) { |
Denis Kuznetsov | 76c0268 | 2015-09-17 19:57:00 +0200 | [diff] [blame] | 423 | Set<ComponentName> installed = new ArraySet<>(); |
Denis Kuznetsov | 76c0268 | 2015-09-17 19:57:00 +0200 | [diff] [blame] | 424 | final PackageManager pm = mContext.getPackageManager(); |
Julia Reynolds | c279b99 | 2015-10-30 08:23:51 -0400 | [diff] [blame] | 425 | Intent queryIntent = new Intent(mConfig.serviceInterface); |
| 426 | if (!TextUtils.isEmpty(packageName)) { |
| 427 | queryIntent.setPackage(packageName); |
| 428 | } |
Denis Kuznetsov | 76c0268 | 2015-09-17 19:57:00 +0200 | [diff] [blame] | 429 | List<ResolveInfo> installedServices = pm.queryIntentServicesAsUser( |
Julia Reynolds | c279b99 | 2015-10-30 08:23:51 -0400 | [diff] [blame] | 430 | queryIntent, |
Denis Kuznetsov | 76c0268 | 2015-09-17 19:57:00 +0200 | [diff] [blame] | 431 | PackageManager.GET_SERVICES | PackageManager.GET_META_DATA, |
| 432 | userId); |
| 433 | if (DEBUG) |
| 434 | Slog.v(TAG, mConfig.serviceInterface + " services: " + installedServices); |
Julia Reynolds | 50f0514 | 2015-10-30 17:03:59 -0400 | [diff] [blame] | 435 | if (installedServices != null) { |
| 436 | for (int i = 0, count = installedServices.size(); i < count; i++) { |
| 437 | ResolveInfo resolveInfo = installedServices.get(i); |
| 438 | ServiceInfo info = resolveInfo.serviceInfo; |
Denis Kuznetsov | 76c0268 | 2015-09-17 19:57:00 +0200 | [diff] [blame] | 439 | |
Julia Reynolds | 50f0514 | 2015-10-30 17:03:59 -0400 | [diff] [blame] | 440 | ComponentName component = new ComponentName(info.packageName, info.name); |
| 441 | if (!mConfig.bindPermission.equals(info.permission)) { |
| 442 | Slog.w(TAG, "Skipping " + getCaption() + " service " |
Ruben Brunk | dd18a0b | 2015-12-04 16:16:31 -0800 | [diff] [blame] | 443 | + info.packageName + "/" + info.name |
| 444 | + ": it does not require the permission " |
| 445 | + mConfig.bindPermission); |
Julia Reynolds | 50f0514 | 2015-10-30 17:03:59 -0400 | [diff] [blame] | 446 | continue; |
| 447 | } |
| 448 | installed.add(component); |
Denis Kuznetsov | 76c0268 | 2015-09-17 19:57:00 +0200 | [diff] [blame] | 449 | } |
Denis Kuznetsov | 76c0268 | 2015-09-17 19:57:00 +0200 | [diff] [blame] | 450 | } |
Julia Reynolds | c279b99 | 2015-10-30 08:23:51 -0400 | [diff] [blame] | 451 | return installed; |
| 452 | } |
| 453 | |
Julia Reynolds | 6e839b0 | 2016-04-13 10:01:17 -0400 | [diff] [blame^] | 454 | private void updateSettingsAccordingToInstalledServices(String setting, int userId) { |
Julia Reynolds | c279b99 | 2015-10-30 08:23:51 -0400 | [diff] [blame] | 455 | boolean restoredChanged = false; |
| 456 | boolean currentChanged = false; |
| 457 | Set<ComponentName> restored = |
Julia Reynolds | 6e839b0 | 2016-04-13 10:01:17 -0400 | [diff] [blame^] | 458 | loadComponentNamesFromSetting(restoredSettingName(setting), userId); |
Julia Reynolds | c279b99 | 2015-10-30 08:23:51 -0400 | [diff] [blame] | 459 | Set<ComponentName> current = |
Julia Reynolds | 6e839b0 | 2016-04-13 10:01:17 -0400 | [diff] [blame^] | 460 | loadComponentNamesFromSetting(setting, userId); |
Julia Reynolds | c279b99 | 2015-10-30 08:23:51 -0400 | [diff] [blame] | 461 | // Load all services for all packages. |
| 462 | Set<ComponentName> installed = queryPackageForServices(null, userId); |
Denis Kuznetsov | 76c0268 | 2015-09-17 19:57:00 +0200 | [diff] [blame] | 463 | |
| 464 | ArraySet<ComponentName> retained = new ArraySet<>(); |
| 465 | |
| 466 | for (ComponentName component : installed) { |
| 467 | if (null != restored) { |
| 468 | boolean wasRestored = restored.remove(component); |
| 469 | if (wasRestored) { |
| 470 | // Freshly installed package has service that was mentioned in restored setting. |
| 471 | if (DEBUG) |
| 472 | Slog.v(TAG, "Restoring " + component + " for user " + userId); |
| 473 | restoredChanged = true; |
| 474 | currentChanged = true; |
| 475 | retained.add(component); |
John Spurlock | 7340fc8 | 2014-04-24 18:50:12 -0400 | [diff] [blame] | 476 | continue; |
| 477 | } |
John Spurlock | 7340fc8 | 2014-04-24 18:50:12 -0400 | [diff] [blame] | 478 | } |
| 479 | |
Denis Kuznetsov | 76c0268 | 2015-09-17 19:57:00 +0200 | [diff] [blame] | 480 | if (null != current) { |
| 481 | if (current.contains(component)) |
| 482 | retained.add(component); |
John Spurlock | 7340fc8 | 2014-04-24 18:50:12 -0400 | [diff] [blame] | 483 | } |
Denis Kuznetsov | 76c0268 | 2015-09-17 19:57:00 +0200 | [diff] [blame] | 484 | } |
| 485 | |
| 486 | currentChanged |= ((current == null ? 0 : current.size()) != retained.size()); |
| 487 | |
| 488 | if (currentChanged) { |
| 489 | if (DEBUG) Slog.v(TAG, "List of " + getCaption() + " services was updated " + current); |
Julia Reynolds | 6e839b0 | 2016-04-13 10:01:17 -0400 | [diff] [blame^] | 490 | storeComponentsToSetting(retained, setting, userId); |
Denis Kuznetsov | 76c0268 | 2015-09-17 19:57:00 +0200 | [diff] [blame] | 491 | } |
| 492 | |
| 493 | if (restoredChanged) { |
| 494 | if (DEBUG) Slog.v(TAG, |
| 495 | "List of " + getCaption() + " restored services was updated " + restored); |
Julia Reynolds | 6e839b0 | 2016-04-13 10:01:17 -0400 | [diff] [blame^] | 496 | storeComponentsToSetting(restored, restoredSettingName(setting), userId); |
John Spurlock | 7340fc8 | 2014-04-24 18:50:12 -0400 | [diff] [blame] | 497 | } |
| 498 | } |
| 499 | |
| 500 | /** |
| 501 | * Called whenever packages change, the user switches, or the secure setting |
| 502 | * is altered. (For example in response to USER_SWITCHED in our broadcast receiver) |
| 503 | */ |
Julia Reynolds | 1c9bd42 | 2016-03-15 09:25:56 -0400 | [diff] [blame] | 504 | private void rebindServices(boolean forceRebind) { |
John Spurlock | 7340fc8 | 2014-04-24 18:50:12 -0400 | [diff] [blame] | 505 | if (DEBUG) Slog.d(TAG, "rebindServices"); |
| 506 | final int[] userIds = mUserProfiles.getCurrentProfileIds(); |
| 507 | final int nUserIds = userIds.length; |
| 508 | |
Denis Kuznetsov | 76c0268 | 2015-09-17 19:57:00 +0200 | [diff] [blame] | 509 | final SparseArray<ArraySet<ComponentName>> componentsByUser = new SparseArray<>(); |
John Spurlock | 7340fc8 | 2014-04-24 18:50:12 -0400 | [diff] [blame] | 510 | |
| 511 | for (int i = 0; i < nUserIds; ++i) { |
Denis Kuznetsov | 76c0268 | 2015-09-17 19:57:00 +0200 | [diff] [blame] | 512 | componentsByUser.put(userIds[i], |
| 513 | loadComponentNamesFromSetting(mConfig.secureSettingName, userIds[i])); |
Julia Reynolds | 6e839b0 | 2016-04-13 10:01:17 -0400 | [diff] [blame^] | 514 | if (mConfig.secondarySettingName != null) { |
| 515 | componentsByUser.get(userIds[i]).addAll( |
| 516 | loadComponentNamesFromSetting(mConfig.secondarySettingName, userIds[i])); |
| 517 | } |
John Spurlock | 7340fc8 | 2014-04-24 18:50:12 -0400 | [diff] [blame] | 518 | } |
| 519 | |
Julia Reynolds | 9a86cc0 | 2016-02-10 15:38:15 -0500 | [diff] [blame] | 520 | final ArrayList<ManagedServiceInfo> removableBoundServices = new ArrayList<>(); |
| 521 | final SparseArray<Set<ComponentName>> toAdd = new SparseArray<>(); |
John Spurlock | 7340fc8 | 2014-04-24 18:50:12 -0400 | [diff] [blame] | 522 | |
| 523 | synchronized (mMutex) { |
Julia Reynolds | 1c9bd42 | 2016-03-15 09:25:56 -0400 | [diff] [blame] | 524 | // Rebind to non-system services if user switched |
Christoph Studer | 5d42384 | 2014-05-23 13:15:54 +0200 | [diff] [blame] | 525 | for (ManagedServiceInfo service : mServices) { |
Chris Wren | 51017d0 | 2015-12-15 15:34:46 -0500 | [diff] [blame] | 526 | if (!service.isSystem && !service.isGuest(this)) { |
Julia Reynolds | 9a86cc0 | 2016-02-10 15:38:15 -0500 | [diff] [blame] | 527 | removableBoundServices.add(service); |
Christoph Studer | 5d42384 | 2014-05-23 13:15:54 +0200 | [diff] [blame] | 528 | } |
| 529 | } |
John Spurlock | 7340fc8 | 2014-04-24 18:50:12 -0400 | [diff] [blame] | 530 | |
Julia Reynolds | 1c9bd42 | 2016-03-15 09:25:56 -0400 | [diff] [blame] | 531 | mEnabledServicesForCurrentProfiles.clear(); |
| 532 | mEnabledServicesPackageNames.clear(); |
John Spurlock | 7340fc8 | 2014-04-24 18:50:12 -0400 | [diff] [blame] | 533 | |
| 534 | for (int i = 0; i < nUserIds; ++i) { |
Denis Kuznetsov | 76c0268 | 2015-09-17 19:57:00 +0200 | [diff] [blame] | 535 | // decode the list of components |
| 536 | final ArraySet<ComponentName> userComponents = componentsByUser.get(userIds[i]); |
| 537 | if (null == userComponents) { |
Julia Reynolds | 6e839b0 | 2016-04-13 10:01:17 -0400 | [diff] [blame^] | 538 | toAdd.put(userIds[i], new ArraySet<ComponentName>()); |
Denis Kuznetsov | 76c0268 | 2015-09-17 19:57:00 +0200 | [diff] [blame] | 539 | continue; |
| 540 | } |
| 541 | |
Julia Reynolds | 9a86cc0 | 2016-02-10 15:38:15 -0500 | [diff] [blame] | 542 | final Set<ComponentName> add = new HashSet<>(userComponents); |
Chris Wren | ab41eec | 2016-01-04 18:01:27 -0500 | [diff] [blame] | 543 | add.removeAll(mSnoozingForCurrentProfiles); |
Ruben Brunk | dd18a0b | 2015-12-04 16:16:31 -0800 | [diff] [blame] | 544 | |
John Spurlock | 7340fc8 | 2014-04-24 18:50:12 -0400 | [diff] [blame] | 545 | toAdd.put(userIds[i], add); |
| 546 | |
Julia Reynolds | 1c9bd42 | 2016-03-15 09:25:56 -0400 | [diff] [blame] | 547 | mEnabledServicesForCurrentProfiles.addAll(userComponents); |
John Spurlock | 7340fc8 | 2014-04-24 18:50:12 -0400 | [diff] [blame] | 548 | |
Denis Kuznetsov | 76c0268 | 2015-09-17 19:57:00 +0200 | [diff] [blame] | 549 | for (int j = 0; j < userComponents.size(); j++) { |
Chris Wren | 083094c | 2015-12-15 16:25:07 -0500 | [diff] [blame] | 550 | final ComponentName component = userComponents.valueAt(j); |
Julia Reynolds | 1c9bd42 | 2016-03-15 09:25:56 -0400 | [diff] [blame] | 551 | mEnabledServicesPackageNames.add(component.getPackageName()); |
John Spurlock | 7340fc8 | 2014-04-24 18:50:12 -0400 | [diff] [blame] | 552 | } |
| 553 | } |
John Spurlock | 7340fc8 | 2014-04-24 18:50:12 -0400 | [diff] [blame] | 554 | } |
| 555 | |
Julia Reynolds | 9a86cc0 | 2016-02-10 15:38:15 -0500 | [diff] [blame] | 556 | for (ManagedServiceInfo info : removableBoundServices) { |
John Spurlock | 7340fc8 | 2014-04-24 18:50:12 -0400 | [diff] [blame] | 557 | final ComponentName component = info.component; |
| 558 | final int oldUser = info.userid; |
Julia Reynolds | 9a86cc0 | 2016-02-10 15:38:15 -0500 | [diff] [blame] | 559 | final Set<ComponentName> allowedComponents = toAdd.get(info.userid); |
| 560 | if (allowedComponents != null) { |
Julia Reynolds | 1c9bd42 | 2016-03-15 09:25:56 -0400 | [diff] [blame] | 561 | if (allowedComponents.contains(component) && !forceRebind) { |
Julia Reynolds | 9a86cc0 | 2016-02-10 15:38:15 -0500 | [diff] [blame] | 562 | // Already bound, don't need to bind again. |
| 563 | allowedComponents.remove(component); |
| 564 | } else { |
Julia Reynolds | 1c9bd42 | 2016-03-15 09:25:56 -0400 | [diff] [blame] | 565 | // No longer allowed to be bound, or must rebind. |
Julia Reynolds | 9a86cc0 | 2016-02-10 15:38:15 -0500 | [diff] [blame] | 566 | Slog.v(TAG, "disabling " + getCaption() + " for user " |
| 567 | + oldUser + ": " + component); |
| 568 | unregisterService(component, oldUser); |
| 569 | } |
| 570 | } |
John Spurlock | 7340fc8 | 2014-04-24 18:50:12 -0400 | [diff] [blame] | 571 | } |
| 572 | |
| 573 | for (int i = 0; i < nUserIds; ++i) { |
Julia Reynolds | 9a86cc0 | 2016-02-10 15:38:15 -0500 | [diff] [blame] | 574 | final Set<ComponentName> add = toAdd.get(userIds[i]); |
| 575 | for (ComponentName component : add) { |
Julia Reynolds | 1c9bd42 | 2016-03-15 09:25:56 -0400 | [diff] [blame] | 576 | Slog.v(TAG, "enabling " + getCaption() + " for " + userIds[i] + ": " + component); |
John Spurlock | 7340fc8 | 2014-04-24 18:50:12 -0400 | [diff] [blame] | 577 | registerService(component, userIds[i]); |
| 578 | } |
| 579 | } |
Christoph Studer | b53dfd4 | 2014-09-12 14:45:59 +0200 | [diff] [blame] | 580 | |
Denis Kuznetsov | 76c0268 | 2015-09-17 19:57:00 +0200 | [diff] [blame] | 581 | mLastSeenProfileIds = userIds; |
John Spurlock | 7340fc8 | 2014-04-24 18:50:12 -0400 | [diff] [blame] | 582 | } |
| 583 | |
| 584 | /** |
| 585 | * Version of registerService that takes the name of a service component to bind to. |
| 586 | */ |
| 587 | private void registerService(final ComponentName name, final int userid) { |
Ruben Brunk | dd18a0b | 2015-12-04 16:16:31 -0800 | [diff] [blame] | 588 | synchronized (mMutex) { |
| 589 | registerServiceLocked(name, userid); |
| 590 | } |
| 591 | } |
| 592 | |
Chris Wren | 0efdb88 | 2016-03-01 17:17:47 -0500 | [diff] [blame] | 593 | /** |
| 594 | * Inject a system service into the management list. |
| 595 | */ |
| 596 | public void registerSystemService(final ComponentName name, final int userid) { |
| 597 | synchronized (mMutex) { |
| 598 | registerServiceLocked(name, userid, true /* isSystem */); |
| 599 | } |
| 600 | } |
| 601 | |
Ruben Brunk | dd18a0b | 2015-12-04 16:16:31 -0800 | [diff] [blame] | 602 | private void registerServiceLocked(final ComponentName name, final int userid) { |
Chris Wren | 0efdb88 | 2016-03-01 17:17:47 -0500 | [diff] [blame] | 603 | registerServiceLocked(name, userid, false /* isSystem */); |
| 604 | } |
| 605 | |
| 606 | private void registerServiceLocked(final ComponentName name, final int userid, |
| 607 | final boolean isSystem) { |
John Spurlock | 7340fc8 | 2014-04-24 18:50:12 -0400 | [diff] [blame] | 608 | if (DEBUG) Slog.v(TAG, "registerService: " + name + " u=" + userid); |
| 609 | |
Ruben Brunk | dd18a0b | 2015-12-04 16:16:31 -0800 | [diff] [blame] | 610 | final String servicesBindingTag = name.toString() + "/" + userid; |
| 611 | if (mServicesBinding.contains(servicesBindingTag)) { |
| 612 | // stop registering this thing already! we're working on it |
| 613 | return; |
| 614 | } |
| 615 | mServicesBinding.add(servicesBindingTag); |
John Spurlock | 7340fc8 | 2014-04-24 18:50:12 -0400 | [diff] [blame] | 616 | |
Ruben Brunk | dd18a0b | 2015-12-04 16:16:31 -0800 | [diff] [blame] | 617 | final int N = mServices.size(); |
| 618 | for (int i = N - 1; i >= 0; i--) { |
| 619 | final ManagedServiceInfo info = mServices.get(i); |
| 620 | if (name.equals(info.component) |
| 621 | && info.userid == userid) { |
| 622 | // cut old connections |
| 623 | if (DEBUG) Slog.v(TAG, " disconnecting old " + getCaption() + ": " |
| 624 | + info.service); |
| 625 | removeServiceLocked(i); |
| 626 | if (info.connection != null) { |
| 627 | mContext.unbindService(info.connection); |
John Spurlock | 7340fc8 | 2014-04-24 18:50:12 -0400 | [diff] [blame] | 628 | } |
| 629 | } |
Ruben Brunk | dd18a0b | 2015-12-04 16:16:31 -0800 | [diff] [blame] | 630 | } |
John Spurlock | 7340fc8 | 2014-04-24 18:50:12 -0400 | [diff] [blame] | 631 | |
Ruben Brunk | dd18a0b | 2015-12-04 16:16:31 -0800 | [diff] [blame] | 632 | Intent intent = new Intent(mConfig.serviceInterface); |
| 633 | intent.setComponent(name); |
John Spurlock | 7340fc8 | 2014-04-24 18:50:12 -0400 | [diff] [blame] | 634 | |
Ruben Brunk | dd18a0b | 2015-12-04 16:16:31 -0800 | [diff] [blame] | 635 | intent.putExtra(Intent.EXTRA_CLIENT_LABEL, mConfig.clientLabel); |
John Spurlock | 7340fc8 | 2014-04-24 18:50:12 -0400 | [diff] [blame] | 636 | |
Ruben Brunk | dd18a0b | 2015-12-04 16:16:31 -0800 | [diff] [blame] | 637 | final PendingIntent pendingIntent = PendingIntent.getActivity( |
| 638 | mContext, 0, new Intent(mConfig.settingsAction), 0); |
| 639 | intent.putExtra(Intent.EXTRA_CLIENT_INTENT, pendingIntent); |
John Spurlock | 7340fc8 | 2014-04-24 18:50:12 -0400 | [diff] [blame] | 640 | |
Ruben Brunk | dd18a0b | 2015-12-04 16:16:31 -0800 | [diff] [blame] | 641 | ApplicationInfo appInfo = null; |
| 642 | try { |
| 643 | appInfo = mContext.getPackageManager().getApplicationInfo( |
| 644 | name.getPackageName(), 0); |
| 645 | } catch (NameNotFoundException e) { |
| 646 | // Ignore if the package doesn't exist we won't be able to bind to the service. |
| 647 | } |
| 648 | final int targetSdkVersion = |
| 649 | appInfo != null ? appInfo.targetSdkVersion : Build.VERSION_CODES.BASE; |
John Spurlock | 7340fc8 | 2014-04-24 18:50:12 -0400 | [diff] [blame] | 650 | |
Ruben Brunk | dd18a0b | 2015-12-04 16:16:31 -0800 | [diff] [blame] | 651 | try { |
| 652 | if (DEBUG) Slog.v(TAG, "binding: " + intent); |
| 653 | ServiceConnection serviceConnection = new ServiceConnection() { |
| 654 | IInterface mService; |
Denis Kuznetsov | 76c0268 | 2015-09-17 19:57:00 +0200 | [diff] [blame] | 655 | |
Ruben Brunk | dd18a0b | 2015-12-04 16:16:31 -0800 | [diff] [blame] | 656 | @Override |
| 657 | public void onServiceConnected(ComponentName name, IBinder binder) { |
| 658 | boolean added = false; |
| 659 | ManagedServiceInfo info = null; |
| 660 | synchronized (mMutex) { |
| 661 | mServicesBinding.remove(servicesBindingTag); |
| 662 | try { |
| 663 | mService = asInterface(binder); |
| 664 | info = newServiceInfo(mService, name, |
Chris Wren | 0efdb88 | 2016-03-01 17:17:47 -0500 | [diff] [blame] | 665 | userid, isSystem, this, targetSdkVersion); |
Ruben Brunk | dd18a0b | 2015-12-04 16:16:31 -0800 | [diff] [blame] | 666 | binder.linkToDeath(info, 0); |
| 667 | added = mServices.add(info); |
| 668 | } catch (RemoteException e) { |
| 669 | // already dead |
Denis Kuznetsov | 76c0268 | 2015-09-17 19:57:00 +0200 | [diff] [blame] | 670 | } |
| 671 | } |
Ruben Brunk | dd18a0b | 2015-12-04 16:16:31 -0800 | [diff] [blame] | 672 | if (added) { |
| 673 | onServiceAdded(info); |
Denis Kuznetsov | 76c0268 | 2015-09-17 19:57:00 +0200 | [diff] [blame] | 674 | } |
John Spurlock | 7340fc8 | 2014-04-24 18:50:12 -0400 | [diff] [blame] | 675 | } |
Ruben Brunk | dd18a0b | 2015-12-04 16:16:31 -0800 | [diff] [blame] | 676 | |
| 677 | @Override |
| 678 | public void onServiceDisconnected(ComponentName name) { |
| 679 | Slog.v(TAG, getCaption() + " connection lost: " + name); |
| 680 | } |
| 681 | }; |
| 682 | if (!mContext.bindServiceAsUser(intent, |
| 683 | serviceConnection, |
| 684 | Context.BIND_AUTO_CREATE | Context.BIND_FOREGROUND_SERVICE, |
| 685 | new UserHandle(userid))) { |
| 686 | mServicesBinding.remove(servicesBindingTag); |
| 687 | Slog.w(TAG, "Unable to bind " + getCaption() + " service: " + intent); |
John Spurlock | 7340fc8 | 2014-04-24 18:50:12 -0400 | [diff] [blame] | 688 | return; |
| 689 | } |
Ruben Brunk | dd18a0b | 2015-12-04 16:16:31 -0800 | [diff] [blame] | 690 | } catch (SecurityException ex) { |
| 691 | Slog.e(TAG, "Unable to bind " + getCaption() + " service: " + intent, ex); |
| 692 | return; |
John Spurlock | 7340fc8 | 2014-04-24 18:50:12 -0400 | [diff] [blame] | 693 | } |
| 694 | } |
| 695 | |
| 696 | /** |
| 697 | * Remove a service for the given user by ComponentName |
| 698 | */ |
| 699 | private void unregisterService(ComponentName name, int userid) { |
| 700 | synchronized (mMutex) { |
Ruben Brunk | dd18a0b | 2015-12-04 16:16:31 -0800 | [diff] [blame] | 701 | unregisterServiceLocked(name, userid); |
| 702 | } |
| 703 | } |
| 704 | |
| 705 | private void unregisterServiceLocked(ComponentName name, int userid) { |
| 706 | final int N = mServices.size(); |
| 707 | for (int i = N - 1; i >= 0; i--) { |
| 708 | final ManagedServiceInfo info = mServices.get(i); |
| 709 | if (name.equals(info.component) |
| 710 | && info.userid == userid) { |
| 711 | removeServiceLocked(i); |
| 712 | if (info.connection != null) { |
| 713 | try { |
| 714 | mContext.unbindService(info.connection); |
| 715 | } catch (IllegalArgumentException ex) { |
| 716 | // something happened to the service: we think we have a connection |
| 717 | // but it's bogus. |
| 718 | Slog.e(TAG, getCaption() + " " + name + " could not be unbound: " + ex); |
John Spurlock | 7340fc8 | 2014-04-24 18:50:12 -0400 | [diff] [blame] | 719 | } |
| 720 | } |
| 721 | } |
| 722 | } |
| 723 | } |
| 724 | |
| 725 | /** |
| 726 | * Removes a service from the list but does not unbind |
| 727 | * |
| 728 | * @return the removed service. |
| 729 | */ |
| 730 | private ManagedServiceInfo removeServiceImpl(IInterface service, final int userid) { |
John Spurlock | e77bb36 | 2014-04-26 10:24:59 -0400 | [diff] [blame] | 731 | if (DEBUG) Slog.d(TAG, "removeServiceImpl service=" + service + " u=" + userid); |
John Spurlock | 7340fc8 | 2014-04-24 18:50:12 -0400 | [diff] [blame] | 732 | ManagedServiceInfo serviceInfo = null; |
| 733 | synchronized (mMutex) { |
| 734 | final int N = mServices.size(); |
Denis Kuznetsov | 76c0268 | 2015-09-17 19:57:00 +0200 | [diff] [blame] | 735 | for (int i = N - 1; i >= 0; i--) { |
John Spurlock | 7340fc8 | 2014-04-24 18:50:12 -0400 | [diff] [blame] | 736 | final ManagedServiceInfo info = mServices.get(i); |
| 737 | if (info.service.asBinder() == service.asBinder() |
| 738 | && info.userid == userid) { |
John Spurlock | e77bb36 | 2014-04-26 10:24:59 -0400 | [diff] [blame] | 739 | if (DEBUG) Slog.d(TAG, "Removing active service " + info.component); |
| 740 | serviceInfo = removeServiceLocked(i); |
John Spurlock | 7340fc8 | 2014-04-24 18:50:12 -0400 | [diff] [blame] | 741 | } |
| 742 | } |
| 743 | } |
| 744 | return serviceInfo; |
| 745 | } |
| 746 | |
John Spurlock | e77bb36 | 2014-04-26 10:24:59 -0400 | [diff] [blame] | 747 | private ManagedServiceInfo removeServiceLocked(int i) { |
| 748 | final ManagedServiceInfo info = mServices.remove(i); |
| 749 | onServiceRemovedLocked(info); |
| 750 | return info; |
| 751 | } |
| 752 | |
John Spurlock | 7340fc8 | 2014-04-24 18:50:12 -0400 | [diff] [blame] | 753 | private void checkNotNull(IInterface service) { |
| 754 | if (service == null) { |
| 755 | throw new IllegalArgumentException(getCaption() + " must not be null"); |
| 756 | } |
| 757 | } |
| 758 | |
Christoph Studer | 3e144d3 | 2014-05-22 16:48:40 +0200 | [diff] [blame] | 759 | private ManagedServiceInfo registerServiceImpl(final IInterface service, |
John Spurlock | 7340fc8 | 2014-04-24 18:50:12 -0400 | [diff] [blame] | 760 | final ComponentName component, final int userid) { |
Chris Wren | 51017d0 | 2015-12-15 15:34:46 -0500 | [diff] [blame] | 761 | ManagedServiceInfo info = newServiceInfo(service, component, userid, |
| 762 | true /*isSystem*/, null /*connection*/, Build.VERSION_CODES.LOLLIPOP); |
| 763 | return registerServiceImpl(info); |
| 764 | } |
| 765 | |
| 766 | private ManagedServiceInfo registerServiceImpl(ManagedServiceInfo info) { |
John Spurlock | 7340fc8 | 2014-04-24 18:50:12 -0400 | [diff] [blame] | 767 | synchronized (mMutex) { |
| 768 | try { |
Chris Wren | 51017d0 | 2015-12-15 15:34:46 -0500 | [diff] [blame] | 769 | info.service.asBinder().linkToDeath(info, 0); |
John Spurlock | 7340fc8 | 2014-04-24 18:50:12 -0400 | [diff] [blame] | 770 | mServices.add(info); |
Christoph Studer | 3e144d3 | 2014-05-22 16:48:40 +0200 | [diff] [blame] | 771 | return info; |
John Spurlock | 7340fc8 | 2014-04-24 18:50:12 -0400 | [diff] [blame] | 772 | } catch (RemoteException e) { |
| 773 | // already dead |
| 774 | } |
| 775 | } |
Christoph Studer | 3e144d3 | 2014-05-22 16:48:40 +0200 | [diff] [blame] | 776 | return null; |
John Spurlock | 7340fc8 | 2014-04-24 18:50:12 -0400 | [diff] [blame] | 777 | } |
| 778 | |
| 779 | /** |
| 780 | * Removes a service from the list and unbinds. |
| 781 | */ |
| 782 | private void unregisterServiceImpl(IInterface service, int userid) { |
| 783 | ManagedServiceInfo info = removeServiceImpl(service, userid); |
Chris Wren | 51017d0 | 2015-12-15 15:34:46 -0500 | [diff] [blame] | 784 | if (info != null && info.connection != null && !info.isGuest(this)) { |
John Spurlock | 7340fc8 | 2014-04-24 18:50:12 -0400 | [diff] [blame] | 785 | mContext.unbindService(info.connection); |
| 786 | } |
| 787 | } |
| 788 | |
| 789 | private class SettingsObserver extends ContentObserver { |
| 790 | private final Uri mSecureSettingsUri = Settings.Secure.getUriFor(mConfig.secureSettingName); |
Julia Reynolds | 6e839b0 | 2016-04-13 10:01:17 -0400 | [diff] [blame^] | 791 | private final Uri mSecondarySettingsUri; |
John Spurlock | 7340fc8 | 2014-04-24 18:50:12 -0400 | [diff] [blame] | 792 | |
| 793 | private SettingsObserver(Handler handler) { |
| 794 | super(handler); |
Julia Reynolds | 6e839b0 | 2016-04-13 10:01:17 -0400 | [diff] [blame^] | 795 | if (mConfig.secondarySettingName != null) { |
| 796 | mSecondarySettingsUri = Settings.Secure.getUriFor(mConfig.secondarySettingName); |
| 797 | } else { |
| 798 | mSecondarySettingsUri = null; |
| 799 | } |
John Spurlock | 7340fc8 | 2014-04-24 18:50:12 -0400 | [diff] [blame] | 800 | } |
| 801 | |
| 802 | private void observe() { |
| 803 | ContentResolver resolver = mContext.getContentResolver(); |
| 804 | resolver.registerContentObserver(mSecureSettingsUri, |
| 805 | false, this, UserHandle.USER_ALL); |
Julia Reynolds | 6e839b0 | 2016-04-13 10:01:17 -0400 | [diff] [blame^] | 806 | if (mSecondarySettingsUri != null) { |
| 807 | resolver.registerContentObserver(mSecondarySettingsUri, |
| 808 | false, this, UserHandle.USER_ALL); |
| 809 | } |
John Spurlock | 7340fc8 | 2014-04-24 18:50:12 -0400 | [diff] [blame] | 810 | update(null); |
| 811 | } |
| 812 | |
| 813 | @Override |
| 814 | public void onChange(boolean selfChange, Uri uri) { |
| 815 | update(uri); |
| 816 | } |
| 817 | |
| 818 | private void update(Uri uri) { |
Julia Reynolds | 6e839b0 | 2016-04-13 10:01:17 -0400 | [diff] [blame^] | 819 | if (uri == null || mSecureSettingsUri.equals(uri) |
| 820 | || uri.equals(mSecondarySettingsUri)) { |
| 821 | if (DEBUG) Slog.d(TAG, "Setting changed: uri=" + uri); |
Julia Reynolds | 1c9bd42 | 2016-03-15 09:25:56 -0400 | [diff] [blame] | 822 | rebindServices(false); |
Denis Kuznetsov | 76c0268 | 2015-09-17 19:57:00 +0200 | [diff] [blame] | 823 | rebuildRestoredPackages(); |
John Spurlock | 7340fc8 | 2014-04-24 18:50:12 -0400 | [diff] [blame] | 824 | } |
| 825 | } |
| 826 | } |
| 827 | |
| 828 | public class ManagedServiceInfo implements IBinder.DeathRecipient { |
| 829 | public IInterface service; |
| 830 | public ComponentName component; |
| 831 | public int userid; |
| 832 | public boolean isSystem; |
| 833 | public ServiceConnection connection; |
| 834 | public int targetSdkVersion; |
| 835 | |
| 836 | public ManagedServiceInfo(IInterface service, ComponentName component, |
| 837 | int userid, boolean isSystem, ServiceConnection connection, int targetSdkVersion) { |
| 838 | this.service = service; |
| 839 | this.component = component; |
| 840 | this.userid = userid; |
| 841 | this.isSystem = isSystem; |
| 842 | this.connection = connection; |
| 843 | this.targetSdkVersion = targetSdkVersion; |
| 844 | } |
| 845 | |
Chris Wren | 51017d0 | 2015-12-15 15:34:46 -0500 | [diff] [blame] | 846 | public boolean isGuest(ManagedServices host) { |
| 847 | return ManagedServices.this != host; |
| 848 | } |
| 849 | |
Chris Wren | ab41eec | 2016-01-04 18:01:27 -0500 | [diff] [blame] | 850 | public ManagedServices getOwner() { |
| 851 | return ManagedServices.this; |
| 852 | } |
| 853 | |
John Spurlock | e77bb36 | 2014-04-26 10:24:59 -0400 | [diff] [blame] | 854 | @Override |
| 855 | public String toString() { |
| 856 | return new StringBuilder("ManagedServiceInfo[") |
| 857 | .append("component=").append(component) |
| 858 | .append(",userid=").append(userid) |
| 859 | .append(",isSystem=").append(isSystem) |
| 860 | .append(",targetSdkVersion=").append(targetSdkVersion) |
| 861 | .append(",connection=").append(connection == null ? null : "<connection>") |
| 862 | .append(",service=").append(service) |
| 863 | .append(']').toString(); |
| 864 | } |
| 865 | |
John Spurlock | 7340fc8 | 2014-04-24 18:50:12 -0400 | [diff] [blame] | 866 | public boolean enabledAndUserMatches(int nid) { |
| 867 | if (!isEnabledForCurrentProfiles()) { |
| 868 | return false; |
| 869 | } |
| 870 | if (this.userid == UserHandle.USER_ALL) return true; |
Chris Wren | 0efdb88 | 2016-03-01 17:17:47 -0500 | [diff] [blame] | 871 | if (this.userid == UserHandle.USER_SYSTEM) return true; |
John Spurlock | 7340fc8 | 2014-04-24 18:50:12 -0400 | [diff] [blame] | 872 | if (nid == UserHandle.USER_ALL || nid == this.userid) return true; |
| 873 | return supportsProfiles() && mUserProfiles.isCurrentProfile(nid); |
| 874 | } |
| 875 | |
| 876 | public boolean supportsProfiles() { |
Dianne Hackborn | 955d8d6 | 2014-10-07 20:17:19 -0700 | [diff] [blame] | 877 | return targetSdkVersion >= Build.VERSION_CODES.LOLLIPOP; |
John Spurlock | 7340fc8 | 2014-04-24 18:50:12 -0400 | [diff] [blame] | 878 | } |
| 879 | |
| 880 | @Override |
| 881 | public void binderDied() { |
John Spurlock | e77bb36 | 2014-04-26 10:24:59 -0400 | [diff] [blame] | 882 | if (DEBUG) Slog.d(TAG, "binderDied"); |
John Spurlock | 7340fc8 | 2014-04-24 18:50:12 -0400 | [diff] [blame] | 883 | // Remove the service, but don't unbind from the service. The system will bring the |
| 884 | // service back up, and the onServiceConnected handler will readd the service with the |
| 885 | // new binding. If this isn't a bound service, and is just a registered |
| 886 | // service, just removing it from the list is all we need to do anyway. |
| 887 | removeServiceImpl(this.service, this.userid); |
| 888 | } |
| 889 | |
| 890 | /** convenience method for looking in mEnabledServicesForCurrentProfiles */ |
| 891 | public boolean isEnabledForCurrentProfiles() { |
| 892 | if (this.isSystem) return true; |
| 893 | if (this.connection == null) return false; |
| 894 | return mEnabledServicesForCurrentProfiles.contains(this.component); |
| 895 | } |
| 896 | } |
| 897 | |
Chris Wren | ab41eec | 2016-01-04 18:01:27 -0500 | [diff] [blame] | 898 | /** convenience method for looking in mEnabledServicesForCurrentProfiles */ |
| 899 | public boolean isComponentEnabledForCurrentProfiles(ComponentName component) { |
| 900 | return mEnabledServicesForCurrentProfiles.contains(component); |
| 901 | } |
| 902 | |
John Spurlock | 7340fc8 | 2014-04-24 18:50:12 -0400 | [diff] [blame] | 903 | public static class UserProfiles { |
| 904 | // Profiles of the current user. |
Ruben Brunk | e24b9a6 | 2016-02-16 21:38:24 -0800 | [diff] [blame] | 905 | private final SparseArray<UserInfo> mCurrentProfiles = new SparseArray<>(); |
John Spurlock | 7340fc8 | 2014-04-24 18:50:12 -0400 | [diff] [blame] | 906 | |
Ruben Brunk | e24b9a6 | 2016-02-16 21:38:24 -0800 | [diff] [blame] | 907 | public void updateCache(@NonNull Context context) { |
John Spurlock | 7340fc8 | 2014-04-24 18:50:12 -0400 | [diff] [blame] | 908 | UserManager userManager = (UserManager) context.getSystemService(Context.USER_SERVICE); |
| 909 | if (userManager != null) { |
| 910 | int currentUserId = ActivityManager.getCurrentUser(); |
| 911 | List<UserInfo> profiles = userManager.getProfiles(currentUserId); |
| 912 | synchronized (mCurrentProfiles) { |
| 913 | mCurrentProfiles.clear(); |
| 914 | for (UserInfo user : profiles) { |
| 915 | mCurrentProfiles.put(user.id, user); |
| 916 | } |
| 917 | } |
| 918 | } |
| 919 | } |
| 920 | |
| 921 | public int[] getCurrentProfileIds() { |
| 922 | synchronized (mCurrentProfiles) { |
| 923 | int[] users = new int[mCurrentProfiles.size()]; |
| 924 | final int N = mCurrentProfiles.size(); |
| 925 | for (int i = 0; i < N; ++i) { |
| 926 | users[i] = mCurrentProfiles.keyAt(i); |
| 927 | } |
| 928 | return users; |
| 929 | } |
| 930 | } |
| 931 | |
| 932 | public boolean isCurrentProfile(int userId) { |
| 933 | synchronized (mCurrentProfiles) { |
| 934 | return mCurrentProfiles.get(userId) != null; |
| 935 | } |
| 936 | } |
| 937 | } |
| 938 | |
Ruben Brunk | e24b9a6 | 2016-02-16 21:38:24 -0800 | [diff] [blame] | 939 | public static class Config { |
| 940 | public String caption; |
| 941 | public String serviceInterface; |
| 942 | public String secureSettingName; |
Julia Reynolds | 6e839b0 | 2016-04-13 10:01:17 -0400 | [diff] [blame^] | 943 | public String secondarySettingName; |
Ruben Brunk | e24b9a6 | 2016-02-16 21:38:24 -0800 | [diff] [blame] | 944 | public String bindPermission; |
| 945 | public String settingsAction; |
| 946 | public int clientLabel; |
John Spurlock | 7340fc8 | 2014-04-24 18:50:12 -0400 | [diff] [blame] | 947 | } |
| 948 | } |