Search in sources :

Example 16 with SettingNotFoundException

use of android.provider.Settings.SettingNotFoundException in project platform_frameworks_base by android.

the class VibratorService method updateInputDeviceVibrators.

private void updateInputDeviceVibrators() {
    synchronized (mVibrations) {
        doCancelVibrateLocked();
        synchronized (mInputDeviceVibrators) {
            mVibrateInputDevicesSetting = false;
            try {
                mVibrateInputDevicesSetting = Settings.System.getIntForUser(mContext.getContentResolver(), Settings.System.VIBRATE_INPUT_DEVICES, UserHandle.USER_CURRENT) > 0;
            } catch (SettingNotFoundException snfe) {
            }
            mLowPowerMode = mPowerManagerInternal.getLowPowerModeEnabled();
            if (mVibrateInputDevicesSetting) {
                if (!mInputDeviceListenerRegistered) {
                    mInputDeviceListenerRegistered = true;
                    mIm.registerInputDeviceListener(this, mH);
                }
            } else {
                if (mInputDeviceListenerRegistered) {
                    mInputDeviceListenerRegistered = false;
                    mIm.unregisterInputDeviceListener(this);
                }
            }
            mInputDeviceVibrators.clear();
            if (mVibrateInputDevicesSetting) {
                int[] ids = mIm.getInputDeviceIds();
                for (int i = 0; i < ids.length; i++) {
                    InputDevice device = mIm.getInputDevice(ids[i]);
                    Vibrator vibrator = device.getVibrator();
                    if (vibrator.hasVibrator()) {
                        mInputDeviceVibrators.add(vibrator);
                    }
                }
            }
        }
        startNextVibrationLocked();
    }
}
Also used : InputDevice(android.view.InputDevice) Vibrator(android.os.Vibrator) SettingNotFoundException(android.provider.Settings.SettingNotFoundException)

Example 17 with SettingNotFoundException

use of android.provider.Settings.SettingNotFoundException in project android_frameworks_base by ParanoidAndroid.

the class LockSettingsService method migrateOldData.

private void migrateOldData() {
    try {
        // root user.
        if (getString("migrated", null, 0) == null) {
            final ContentResolver cr = mContext.getContentResolver();
            for (String validSetting : VALID_SETTINGS) {
                String value = Settings.Secure.getString(cr, validSetting);
                if (value != null) {
                    setString(validSetting, value, 0);
                }
            }
            // No need to move the password / pattern files. They're already in the right place.
            setString("migrated", "true", 0);
            Slog.i(TAG, "Migrated lock settings to new location");
        }
        // These Settings changed after multi-user was enabled, hence need to be moved per user.
        if (getString("migrated_user_specific", null, 0) == null) {
            final UserManager um = (UserManager) mContext.getSystemService(USER_SERVICE);
            final ContentResolver cr = mContext.getContentResolver();
            List<UserInfo> users = um.getUsers();
            for (int user = 0; user < users.size(); user++) {
                // Migrate owner info
                final int userId = users.get(user).id;
                final String OWNER_INFO = Secure.LOCK_SCREEN_OWNER_INFO;
                String ownerInfo = Settings.Secure.getStringForUser(cr, OWNER_INFO, userId);
                if (ownerInfo != null) {
                    setString(OWNER_INFO, ownerInfo, userId);
                    Settings.Secure.putStringForUser(cr, ownerInfo, "", userId);
                }
                // Migrate owner info enabled.  Note there was a bug where older platforms only
                // stored this value if the checkbox was toggled at least once. The code detects
                // this case by handling the exception.
                final String OWNER_INFO_ENABLED = Secure.LOCK_SCREEN_OWNER_INFO_ENABLED;
                boolean enabled;
                try {
                    int ivalue = Settings.Secure.getIntForUser(cr, OWNER_INFO_ENABLED, userId);
                    enabled = ivalue != 0;
                    setLong(OWNER_INFO_ENABLED, enabled ? 1 : 0, userId);
                } catch (SettingNotFoundException e) {
                    // Setting was never stored. Store it if the string is not empty.
                    if (!TextUtils.isEmpty(ownerInfo)) {
                        setLong(OWNER_INFO_ENABLED, 1, userId);
                    }
                }
                Settings.Secure.putIntForUser(cr, OWNER_INFO_ENABLED, 0, userId);
            }
            // No need to move the password / pattern files. They're already in the right place.
            setString("migrated_user_specific", "true", 0);
            Slog.i(TAG, "Migrated per-user lock settings to new location");
        }
    } catch (RemoteException re) {
        Slog.e(TAG, "Unable to migrate old data", re);
    }
}
Also used : UserManager(android.os.UserManager) UserInfo(android.content.pm.UserInfo) SettingNotFoundException(android.provider.Settings.SettingNotFoundException) RemoteException(android.os.RemoteException) ContentResolver(android.content.ContentResolver)

Example 18 with SettingNotFoundException

use of android.provider.Settings.SettingNotFoundException in project android_frameworks_base by ParanoidAndroid.

the class CoreSettingsObserver method populateCoreSettings.

private void populateCoreSettings(Bundle snapshot) {
    Context context = mActivityManagerService.mContext;
    for (Map.Entry<String, Class<?>> entry : sCoreSettingToTypeMap.entrySet()) {
        String setting = entry.getKey();
        Class<?> type = entry.getValue();
        try {
            if (type == String.class) {
                String value = Settings.Secure.getString(context.getContentResolver(), setting);
                snapshot.putString(setting, value);
            } else if (type == int.class) {
                int value = Settings.Secure.getInt(context.getContentResolver(), setting);
                snapshot.putInt(setting, value);
            } else if (type == float.class) {
                float value = Settings.Secure.getFloat(context.getContentResolver(), setting);
                snapshot.putFloat(setting, value);
            } else if (type == long.class) {
                long value = Settings.Secure.getLong(context.getContentResolver(), setting);
                snapshot.putLong(setting, value);
            }
        } catch (SettingNotFoundException snfe) {
            Log.w(LOG_TAG, "Cannot find setting \"" + setting + "\"", snfe);
        }
    }
}
Also used : Context(android.content.Context) SettingNotFoundException(android.provider.Settings.SettingNotFoundException) Map(java.util.Map) HashMap(java.util.HashMap)

Example 19 with SettingNotFoundException

use of android.provider.Settings.SettingNotFoundException in project platform_frameworks_base by android.

the class MediaScanner method wasRingtoneAlreadySet.

private boolean wasRingtoneAlreadySet(String name) {
    ContentResolver cr = mContext.getContentResolver();
    String indicatorName = settingSetIndicatorName(name);
    try {
        return Settings.System.getInt(cr, indicatorName) != 0;
    } catch (SettingNotFoundException e) {
        return false;
    }
}
Also used : SettingNotFoundException(android.provider.Settings.SettingNotFoundException) ContentResolver(android.content.ContentResolver)

Example 20 with SettingNotFoundException

use of android.provider.Settings.SettingNotFoundException in project android_frameworks_base by DirtyUnicorns.

the class MediaScanner method wasRingtoneAlreadySet.

private boolean wasRingtoneAlreadySet(String name) {
    ContentResolver cr = mContext.getContentResolver();
    String indicatorName = settingSetIndicatorName(name);
    try {
        return Settings.System.getInt(cr, indicatorName) != 0;
    } catch (SettingNotFoundException e) {
        return false;
    }
}
Also used : SettingNotFoundException(android.provider.Settings.SettingNotFoundException) ContentResolver(android.content.ContentResolver)

Aggregations

SettingNotFoundException (android.provider.Settings.SettingNotFoundException)25 ContentResolver (android.content.ContentResolver)14 RemoteException (android.os.RemoteException)7 UserInfo (android.content.pm.UserInfo)6 Vibrator (android.os.Vibrator)6 InputDevice (android.view.InputDevice)6 IOException (java.io.IOException)5 KeyStoreException (java.security.KeyStoreException)5 NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)5 CertificateException (java.security.cert.CertificateException)5 SimpleHogBug (edu.berkeley.cs.amplab.carat.android.storage.SimpleHogBug)2 Context (android.content.Context)1 ApplicationInfo (android.content.pm.ApplicationInfo)1 UserManager (android.os.UserManager)1 Settings (android.provider.Settings)1 InputMethodInfo (android.view.inputmethod.InputMethodInfo)1 PrintWriter (java.io.PrintWriter)1 StringWriter (java.io.StringWriter)1 Field (java.lang.reflect.Field)1 HashMap (java.util.HashMap)1