private List<String> loadTileSpecs() { final Resources res = mContext.getResources(); final String defaultTileList = res.getString(R.string.quick_settings_tiles_default); String tileList = Settings.Secure.getStringForUser( mContext.getContentResolver(), Settings.Secure.QS_TILES, UserHandle.USER_CURRENT); if (DEBUG) Log.d(TAG, "Config string: " + tileList); if (tileList == null) { tileList = res.getString(R.string.quick_settings_tiles); if (DEBUG) Log.d(TAG, "Loaded tile specs from config: " + tileList); } else { if (DEBUG) Log.d(TAG, "Loaded tile specs from setting: " + tileList); } final ArrayList<String> tiles = new ArrayList<String>(); boolean addedDefault = false; for (String tile : tileList.split(",")) { tile = tile.trim(); if (tile.isEmpty()) continue; if (tile.equals("default")) { if (!addedDefault) { tiles.addAll(Arrays.asList(defaultTileList.split(","))); addedDefault = true; } } else { tiles.add(tile); } } return tiles; }
String getOwnerInfo() { ContentResolver res = getContext().getContentResolver(); final boolean ownerInfoEnabled = Settings.Secure.getIntForUser( res, Settings.Secure.LOCK_SCREEN_OWNER_INFO_ENABLED, 1, UserHandle.USER_CURRENT) != 0; return ownerInfoEnabled && !mShowingMessage ? Settings.Secure.getStringForUser( res, Settings.Secure.LOCK_SCREEN_OWNER_INFO, UserHandle.USER_CURRENT) : null; }
private void disableNonexistentServices(int userId) { String flatIn = Settings.Secure.getStringForUser( mContext.getContentResolver(), mConfig.secureSettingName, userId); if (!TextUtils.isEmpty(flatIn)) { if (DEBUG) Slog.v(TAG, "flat before: " + flatIn); PackageManager pm = mContext.getPackageManager(); List<ResolveInfo> installedServices = pm.queryIntentServicesAsUser( new Intent(mConfig.serviceInterface), PackageManager.GET_SERVICES | PackageManager.GET_META_DATA, userId); if (DEBUG) Slog.v(TAG, mConfig.serviceInterface + " services: " + installedServices); Set<ComponentName> installed = new ArraySet<ComponentName>(); for (int i = 0, count = installedServices.size(); i < count; i++) { ResolveInfo resolveInfo = installedServices.get(i); ServiceInfo info = resolveInfo.serviceInfo; if (!mConfig.bindPermission.equals(info.permission)) { Slog.w( TAG, "Skipping " + getCaption() + " service " + info.packageName + "/" + info.name + ": it does not require the permission " + mConfig.bindPermission); continue; } installed.add(new ComponentName(info.packageName, info.name)); } String flatOut = ""; if (!installed.isEmpty()) { String[] enabled = flatIn.split(ENABLED_SERVICES_SEPARATOR); ArrayList<String> remaining = new ArrayList<String>(enabled.length); for (int i = 0; i < enabled.length; i++) { ComponentName enabledComponent = ComponentName.unflattenFromString(enabled[i]); if (installed.contains(enabledComponent)) { remaining.add(enabled[i]); } } flatOut = TextUtils.join(ENABLED_SERVICES_SEPARATOR, remaining); } if (DEBUG) Slog.v(TAG, "flat after: " + flatOut); if (!flatIn.equals(flatOut)) { Settings.Secure.putStringForUser( mContext.getContentResolver(), mConfig.secureSettingName, flatOut, userId); } } }
/** * Called whenever packages change, the user switches, or the secure setting is altered. (For * example in response to USER_SWITCHED in our broadcast receiver) */ private void rebindServices() { if (DEBUG) Slog.d(TAG, "rebindServices"); final int[] userIds = mUserProfiles.getCurrentProfileIds(); final int nUserIds = userIds.length; final SparseArray<String> flat = new SparseArray<String>(); for (int i = 0; i < nUserIds; ++i) { flat.put( userIds[i], Settings.Secure.getStringForUser( mContext.getContentResolver(), mConfig.secureSettingName, userIds[i])); } ArrayList<ManagedServiceInfo> toRemove = new ArrayList<ManagedServiceInfo>(); final SparseArray<ArrayList<ComponentName>> toAdd = new SparseArray<ArrayList<ComponentName>>(); synchronized (mMutex) { // Unbind automatically bound services, retain system services. for (ManagedServiceInfo service : mServices) { if (!service.isSystem) { toRemove.add(service); } } final ArraySet<ComponentName> newEnabled = new ArraySet<ComponentName>(); final ArraySet<String> newPackages = new ArraySet<String>(); for (int i = 0; i < nUserIds; ++i) { final ArrayList<ComponentName> add = new ArrayList<ComponentName>(); toAdd.put(userIds[i], add); // decode the list of components String toDecode = flat.get(userIds[i]); if (toDecode != null) { String[] components = toDecode.split(ENABLED_SERVICES_SEPARATOR); for (int j = 0; j < components.length; j++) { final ComponentName component = ComponentName.unflattenFromString(components[j]); if (component != null) { newEnabled.add(component); add.add(component); newPackages.add(component.getPackageName()); } } } } mEnabledServicesForCurrentProfiles = newEnabled; mEnabledServicesPackageNames = newPackages; } for (ManagedServiceInfo info : toRemove) { final ComponentName component = info.component; final int oldUser = info.userid; Slog.v(TAG, "disabling " + getCaption() + " for user " + oldUser + ": " + component); unregisterService(component, info.userid); } for (int i = 0; i < nUserIds; ++i) { final ArrayList<ComponentName> add = toAdd.get(userIds[i]); final int N = add.size(); for (int j = 0; j < N; j++) { final ComponentName component = add.get(j); Slog.v(TAG, "enabling " + getCaption() + " for user " + userIds[i] + ": " + component); registerService(component, userIds[i]); } } mLastSeenProfileIds = mUserProfiles.getCurrentProfileIds(); }