Search in sources :

Example 66 with AsyncTask

use of android.os.AsyncTask in project android_packages_apps_Settings by crdroidandroid.

the class CryptKeeper method setupUi.

/**
 * Initializes the UI based on the current state of encryption.
 * This is idempotent - calling repeatedly will simply re-initialize the UI.
 */
private void setupUi() {
    if (mEncryptionGoneBad || isDebugView(FORCE_VIEW_ERROR)) {
        setContentView(R.layout.crypt_keeper_progress);
        showFactoryReset(mCorrupt);
        return;
    }
    final String progress = SystemProperties.get("vold.encrypt_progress");
    if (!"".equals(progress) || isDebugView(FORCE_VIEW_PROGRESS)) {
        setContentView(R.layout.crypt_keeper_progress);
        encryptionProgressInit();
    } else if (mValidationComplete || isDebugView(FORCE_VIEW_PASSWORD)) {
        new AsyncTask<Void, Void, Void>() {

            int passwordType = StorageManager.CRYPT_TYPE_PASSWORD;

            String owner_info;

            boolean pattern_visible;

            boolean password_visible;

            @Override
            public Void doInBackground(Void... v) {
                try {
                    final IStorageManager service = getStorageManager();
                    passwordType = service.getPasswordType();
                    owner_info = service.getField(StorageManager.OWNER_INFO_KEY);
                    pattern_visible = !("0".equals(service.getField(StorageManager.PATTERN_VISIBLE_KEY)));
                    password_visible = !("0".equals(service.getField(StorageManager.PASSWORD_VISIBLE_KEY)));
                } catch (Exception e) {
                    Log.e(TAG, "Error calling mount service " + e);
                }
                return null;
            }

            @Override
            public void onPostExecute(java.lang.Void v) {
                Settings.System.putInt(getContentResolver(), Settings.System.TEXT_SHOW_PASSWORD, password_visible ? 1 : 0);
                if (passwordType == StorageManager.CRYPT_TYPE_PIN) {
                    setContentView(R.layout.crypt_keeper_pin_entry);
                    mStatusString = R.string.enter_pin;
                } else if (passwordType == StorageManager.CRYPT_TYPE_PATTERN) {
                    setContentView(R.layout.crypt_keeper_pattern_entry);
                    setBackFunctionality(false);
                    mStatusString = R.string.enter_pattern;
                } else {
                    setContentView(R.layout.crypt_keeper_password_entry);
                    mStatusString = R.string.enter_password;
                }
                mStatusText.setText(mStatusString);
                final TextView ownerInfo = (TextView) findViewById(R.id.owner_info);
                ownerInfo.setText(owner_info);
                // Required for marquee'ing to work
                ownerInfo.setSelected(true);
                passwordEntryInit();
                findViewById(android.R.id.content).setSystemUiVisibility(View.STATUS_BAR_DISABLE_BACK);
                if (mLockPatternView != null) {
                    mLockPatternView.setInStealthMode(!pattern_visible);
                }
                if (mCooldown) {
                    // in case we are cooling down and coming back from emergency dialler
                    setBackFunctionality(false);
                    cooldown();
                }
            }
        }.execute();
    } else if (!mValidationRequested) {
        // We're supposed to be encrypted, but no validation has been done.
        new ValidationTask().execute((Void[]) null);
        mValidationRequested = true;
    }
}
Also used : IStorageManager(android.os.storage.IStorageManager) AsyncTask(android.os.AsyncTask) TextView(android.widget.TextView) NotFoundException(android.content.res.Resources.NotFoundException) RemoteException(android.os.RemoteException)

Example 67 with AsyncTask

use of android.os.AsyncTask in project android_packages_apps_Settings by crdroidandroid.

the class NotificationSoundPreference method updateRingtoneName.

private void updateRingtoneName(final Uri uri) {
    AsyncTask ringtoneNameTask = new AsyncTask<Object, Void, CharSequence>() {

        @Override
        protected CharSequence doInBackground(Object... params) {
            if (uri == null) {
                return getContext().getString(com.android.internal.R.string.ringtone_silent);
            } else if (RingtoneManager.isDefault(uri)) {
                return getContext().getString(R.string.notification_sound_default);
            } else if (ContentResolver.SCHEME_ANDROID_RESOURCE.equals(uri.getScheme())) {
                return getContext().getString(R.string.notification_unknown_sound_title);
            } else {
                return Ringtone.getTitle(getContext(), uri, false, /* followSettingsUri */
                true);
            }
        }

        @Override
        protected void onPostExecute(CharSequence name) {
            setSummary(name);
        }
    };
    ringtoneNameTask.execute();
}
Also used : AsyncTask(android.os.AsyncTask)

Example 68 with AsyncTask

use of android.os.AsyncTask in project android_packages_apps_Settings by crdroidandroid.

the class DefaultNotificationTonePreference method updateRingtoneName.

private void updateRingtoneName(final Uri uri) {
    AsyncTask ringtoneNameTask = new AsyncTask<Object, Void, CharSequence>() {

        @Override
        protected CharSequence doInBackground(Object... params) {
            return Ringtone.getTitle(mUserContext, uri, false, /* followSettingsUri */
            true);
        }

        @Override
        protected void onPostExecute(CharSequence name) {
            setSummary(name);
        }
    };
    ringtoneNameTask.execute();
}
Also used : AsyncTask(android.os.AsyncTask)

Example 69 with AsyncTask

use of android.os.AsyncTask in project android_packages_apps_Settings by SudaMod.

the class DefaultNotificationTonePreference method updateRingtoneName.

private void updateRingtoneName(final Uri uri) {
    AsyncTask ringtoneNameTask = new AsyncTask<Object, Void, CharSequence>() {

        @Override
        protected CharSequence doInBackground(Object... params) {
            return Ringtone.getTitle(mUserContext, uri, false, /* followSettingsUri */
            true);
        }

        @Override
        protected void onPostExecute(CharSequence name) {
            setSummary(name);
        }
    };
    ringtoneNameTask.execute();
}
Also used : AsyncTask(android.os.AsyncTask)

Example 70 with AsyncTask

use of android.os.AsyncTask in project android_packages_apps_Settings by SudaMod.

the class CryptKeeper method setupUi.

/**
 * Initializes the UI based on the current state of encryption.
 * This is idempotent - calling repeatedly will simply re-initialize the UI.
 */
private void setupUi() {
    if (mEncryptionGoneBad || isDebugView(FORCE_VIEW_ERROR)) {
        setContentView(R.layout.crypt_keeper_progress);
        showFactoryReset(mCorrupt);
        return;
    }
    final String progress = SystemProperties.get("vold.encrypt_progress");
    if (!"".equals(progress) || isDebugView(FORCE_VIEW_PROGRESS)) {
        setContentView(R.layout.crypt_keeper_progress);
        encryptionProgressInit();
    } else if (mValidationComplete || isDebugView(FORCE_VIEW_PASSWORD)) {
        new AsyncTask<Void, Void, Void>() {

            int passwordType = StorageManager.CRYPT_TYPE_PASSWORD;

            String owner_info;

            boolean pattern_visible;

            boolean password_visible;

            @Override
            public Void doInBackground(Void... v) {
                try {
                    final IStorageManager service = getStorageManager();
                    passwordType = service.getPasswordType();
                    owner_info = service.getField(StorageManager.OWNER_INFO_KEY);
                    pattern_visible = !("0".equals(service.getField(StorageManager.PATTERN_VISIBLE_KEY)));
                    password_visible = !("0".equals(service.getField(StorageManager.PASSWORD_VISIBLE_KEY)));
                } catch (Exception e) {
                    Log.e(TAG, "Error calling mount service " + e);
                }
                return null;
            }

            @Override
            public void onPostExecute(java.lang.Void v) {
                Settings.System.putInt(getContentResolver(), Settings.System.TEXT_SHOW_PASSWORD, password_visible ? 1 : 0);
                if (passwordType == StorageManager.CRYPT_TYPE_PIN) {
                    setContentView(R.layout.crypt_keeper_pin_entry);
                    mStatusString = R.string.enter_pin;
                } else if (passwordType == StorageManager.CRYPT_TYPE_PATTERN) {
                    setContentView(R.layout.crypt_keeper_pattern_entry);
                    setBackFunctionality(false);
                    mStatusString = R.string.enter_pattern;
                } else {
                    setContentView(R.layout.crypt_keeper_password_entry);
                    mStatusString = R.string.enter_password;
                }
                mStatusText.setText(mStatusString);
                final TextView ownerInfo = (TextView) findViewById(R.id.owner_info);
                ownerInfo.setText(owner_info);
                // Required for marquee'ing to work
                ownerInfo.setSelected(true);
                passwordEntryInit();
                findViewById(android.R.id.content).setSystemUiVisibility(View.STATUS_BAR_DISABLE_BACK);
                if (mLockPatternView != null) {
                    mLockPatternView.setInStealthMode(!pattern_visible);
                }
                if (mCooldown) {
                    // in case we are cooling down and coming back from emergency dialler
                    setBackFunctionality(false);
                    cooldown();
                }
            }
        }.execute();
    } else if (!mValidationRequested) {
        // We're supposed to be encrypted, but no validation has been done.
        new ValidationTask().execute((Void[]) null);
        mValidationRequested = true;
    }
}
Also used : IStorageManager(android.os.storage.IStorageManager) AsyncTask(android.os.AsyncTask) TextView(android.widget.TextView) NotFoundException(android.content.res.Resources.NotFoundException) RemoteException(android.os.RemoteException)

Aggregations

AsyncTask (android.os.AsyncTask)394 IOException (java.io.IOException)188 InputStream (java.io.InputStream)159 URL (java.net.URL)159 HttpURLConnection (java.net.HttpURLConnection)158 ExecutionException (java.util.concurrent.ExecutionException)158 Gson (com.google.gson.Gson)155 Message (com.remswork.project.alice.model.support.Message)153 GradingFactorException (com.remswork.project.alice.exception.GradingFactorException)102 ArrayList (java.util.ArrayList)93 View (android.view.View)54 Intent (android.content.Intent)52 TextView (android.widget.TextView)52 JSONException (org.json.JSONException)51 JSONArray (org.json.JSONArray)50 DialogInterface (android.content.DialogInterface)40 OutputStream (java.io.OutputStream)37 BufferedWriter (java.io.BufferedWriter)35 OutputStreamWriter (java.io.OutputStreamWriter)35 ImageView (android.widget.ImageView)33