Java Code Examples for com.android.prefs.AndroidLocation#getFolder()

The following examples show how to use com.android.prefs.AndroidLocation#getFolder() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SettingsController.java    From java-n-IDE-for-Android with Apache License 2.0 6 votes vote down vote up
/**
 * Load settings from the settings file.
 */
public void loadSettings() {

    String path = null;
    try {
        String folder = AndroidLocation.getFolder();
        File f = new File(folder, SETTINGS_FILENAME);
        path = f.getPath();

        Properties props = mFileOp.loadProperties(f);
        mSettings.mProperties.clear();
        mSettings.mProperties.putAll(props);

        // Properly reformat some settings to enforce their default value when missing.
        setShowUpdateOnly(mSettings.getShowUpdateOnly());
        setSetting(ISettingsPage.KEY_ASK_ADB_RESTART, mSettings.getAskBeforeAdbRestart());
        setSetting(ISettingsPage.KEY_USE_DOWNLOAD_CACHE, mSettings.getUseDownloadCache());

    } catch (Exception e) {
        if (mSdkLog != null) {
            mSdkLog.error(e,
                    "Failed to load settings from .android folder. Path is '%1$s'.",
                    path);
        }
    }
}
 
Example 2
Source File: SettingsController.java    From javaide with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Load settings from the settings file.
 */
public void loadSettings() {

    String path = null;
    try {
        String folder = AndroidLocation.getFolder();
        File f = new File(folder, SETTINGS_FILENAME);
        path = f.getPath();

        Properties props = mFileOp.loadProperties(f);
        mSettings.mProperties.clear();
        mSettings.mProperties.putAll(props);

        // Properly reformat some settings to enforce their default value when missing.
        setShowUpdateOnly(mSettings.getShowUpdateOnly());
        setSetting(ISettingsPage.KEY_USE_DOWNLOAD_CACHE, mSettings.getUseDownloadCache());
        setSetting(ISettingsPage.KEY_ENABLE_PREVIEWS, mSettings.getEnablePreviews());

    } catch (Exception e) {
        if (mSdkLog != null) {
            mSdkLog.error(e,
                    "Failed to load settings from .android folder. Path is '%1$s'.",
                    path);
        }
    }
}
 
Example 3
Source File: SettingsController.java    From java-n-IDE-for-Android with Apache License 2.0 5 votes vote down vote up
/**
 * Saves settings to the settings file.
 */
public void saveSettings() {

    String path = null;
    try {
        String folder = AndroidLocation.getFolder();
        File f = new File(folder, SETTINGS_FILENAME);
        path = f.getPath();
        mFileOp.saveProperties(f, mSettings.mProperties, "## Settings for Android Tool");  //$NON-NLS-1$

    } catch (Exception e) {
        if (mSdkLog != null) {
            // This is important enough that we want to really nag the user about it
            String reason = null;

            if (e instanceof FileNotFoundException) {
                reason = "File not found";
            } else if (e instanceof AndroidLocationException) {
                reason = ".android folder not found, please define ANDROID_SDK_HOME";
            } else if (e.getMessage() != null) {
                reason = String.format("%1$s: %2$s",
                        e.getClass().getSimpleName(),
                        e.getMessage());
            } else {
                reason = e.getClass().getName();
            }

            mSdkLog.error(e, "Failed to save settings file '%1$s': %2$s", path, reason);
        }
    }
}
 
Example 4
Source File: DebugKeyProvider.java    From java-n-IDE-for-Android with Apache License 2.0 5 votes vote down vote up
/**
 * Returns the OS path to the default debug keystore.
 *
 * @return The OS path to the default debug keystore.
 * @throws KeytoolException
 * @throws AndroidLocationException
 */
public static String getDefaultKeyStoreOsPath()
        throws KeytoolException, AndroidLocationException {
    String folder = AndroidLocation.getFolder();
    if (folder == null) {
        throw new KeytoolException("Failed to get HOME directory!\n");
    }
    String osKeyStorePath = folder + "debug.keystore";

    return osKeyStorePath;
}
 
Example 5
Source File: KeystoreHelper.java    From java-n-IDE-for-Android with Apache License 2.0 5 votes vote down vote up
/**
 * Returns the location of the default debug keystore.
 *
 * @return The location of the default debug keystore.
 * @throws AndroidLocationException if the location cannot be computed
 */
@NonNull
public static String defaultDebugKeystoreLocation() throws AndroidLocationException {
    //this is guaranteed to either return a non null value (terminated with a platform
    // specific separator), or throw.
    String folder = AndroidLocation.getFolder();
    return folder + "debug.keystore";
}
 
Example 6
Source File: SettingsController.java    From javaide with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Saves settings to the settings file.
 */
public void saveSettings() {

    String path = null;
    try {
        String folder = AndroidLocation.getFolder();
        File f = new File(folder, SETTINGS_FILENAME);
        path = f.getPath();
        mFileOp.saveProperties(f, mSettings.mProperties, "## Settings for Android Tool");  //$NON-NLS-1$

    } catch (Exception e) {
        if (mSdkLog != null) {
            // This is important enough that we want to really nag the user about it
            String reason = null;

            if (e instanceof FileNotFoundException) {
                reason = "File not found";
            } else if (e instanceof AndroidLocationException) {
                reason = ".android folder not found, please define ANDROID_SDK_HOME";
            } else if (e.getMessage() != null) {
                reason = String.format("%1$s: %2$s",
                        e.getClass().getSimpleName(),
                        e.getMessage());
            } else {
                reason = e.getClass().getName();
            }

            mSdkLog.error(e, "Failed to save settings file '%1$s': %2$s", path, reason);
        }
    }
}
 
Example 7
Source File: DebugKeyProvider.java    From javaide with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Returns the OS path to the default debug keystore.
 *
 * @return The OS path to the default debug keystore.
 * @throws KeytoolException
 * @throws AndroidLocationException
 */
public static String getDefaultKeyStoreOsPath()
        throws KeytoolException, AndroidLocationException {
    String folder = AndroidLocation.getFolder();
    if (folder == null) {
        throw new KeytoolException("Failed to get HOME directory!\n");
    }
    String osKeyStorePath = folder + "debug.keystore";

    return osKeyStorePath;
}
 
Example 8
Source File: KeystoreHelper.java    From javaide with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Returns the location of the default debug keystore.
 *
 * @return The location of the default debug keystore.
 * @throws AndroidLocationException if the location cannot be computed
 */
@NonNull
public static String defaultDebugKeystoreLocation() throws AndroidLocationException {
    //this is guaranteed to either return a non null value (terminated with a platform
    // specific separator), or throw.
    String folder = AndroidLocation.getFolder();
    return folder + "debug.keystore";
}