Example usage for android.os SystemProperties get

List of usage examples for android.os SystemProperties get

Introduction

In this page you can find the example usage for android.os SystemProperties get.

Prototype

@NonNull
@SystemApi
public static String get(@NonNull String key) 

Source Link

Document

Get the String value for the given key .

Usage

From source file:com.google.android.net.NetworkStatsEntity.java

public static boolean shouldLogNetworkStats() {
    return "1".equals(SystemProperties.get("googlehttpclient.logstats"));
}

From source file:com.bluros.updater.service.DownloadService.java

private String getServerUri() {
    String propertyUri = SystemProperties.get("bluros.updater.uri");
    if (!TextUtils.isEmpty(propertyUri)) {
        return propertyUri;
    }/*from  w w w . ja  v a 2s .co  m*/

    return getString(R.string.conf_update_server_url_def);
}

From source file:com.cyanogenmod.updater.service.DownloadService.java

private String getServerUri() {
    String propertyUri = SystemProperties.get("cm.updater.uri");
    if (!TextUtils.isEmpty(propertyUri)) {
        return propertyUri;
    }//  w w  w .j  a  va2 s . c om

    return getString(R.string.conf_update_server_url_def);
}

From source file:com.android.shell.BugreportReceiver.java

/**
 * Build {@link Intent} that can be used to share the given bugreport.
 */// w w w.  ja va  2 s  .co m
private static Intent buildSendIntent(Context context, Uri bugreportUri, Uri screenshotUri) {
    final Intent intent = new Intent(Intent.ACTION_SEND_MULTIPLE);
    intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
    intent.addCategory(Intent.CATEGORY_DEFAULT);
    intent.setType("application/vnd.android.bugreport");

    intent.putExtra(Intent.EXTRA_SUBJECT, bugreportUri.getLastPathSegment());
    intent.putExtra(Intent.EXTRA_TEXT, SystemProperties.get("ro.build.description"));

    final ArrayList<Uri> attachments = Lists.newArrayList(bugreportUri, screenshotUri);
    intent.putParcelableArrayListExtra(Intent.EXTRA_STREAM, attachments);

    final Account sendToAccount = findSendToAccount(context);
    if (sendToAccount != null) {
        intent.putExtra(Intent.EXTRA_EMAIL, new String[] { sendToAccount.name });
    }

    return intent;
}

From source file:com.android.shell.BugreportReceiver.java

/**
 * Find the best matching {@link Account} based on build properties.
 *//*  w  w  w  . java 2s.c om*/
private static Account findSendToAccount(Context context) {
    final AccountManager am = (AccountManager) context.getSystemService(Context.ACCOUNT_SERVICE);

    String preferredDomain = SystemProperties.get("sendbug.preferred.domain");
    if (!preferredDomain.startsWith("@")) {
        preferredDomain = "@" + preferredDomain;
    }

    final Account[] accounts = am.getAccounts();
    Account foundAccount = null;
    for (Account account : accounts) {
        if (Patterns.EMAIL_ADDRESS.matcher(account.name).matches()) {
            if (!preferredDomain.isEmpty()) {
                // if we have a preferred domain and it matches, return; otherwise keep
                // looking
                if (account.name.endsWith(preferredDomain)) {
                    return account;
                } else {
                    foundAccount = account;
                }
                // if we don't have a preferred domain, just return since it looks like
                // an email address
            } else {
                return account;
            }
        }
    }
    return foundAccount;
}

From source file:com.android.tv.settings.about.AboutFragment.java

@Override
public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
    setPreferencesFromResource(R.xml.device_info_settings, null);
    final PreferenceScreen screen = getPreferenceScreen();

    refreshDeviceName();/*ww w .j a v a 2 s  .  c o m*/
    final Preference deviceNamePref = findPreference(KEY_DEVICE_NAME);
    PreferenceUtils.resolveSystemActivityOrRemove(getActivity(), screen, deviceNamePref, 0);

    final Preference firmwareVersionPref = findPreference(KEY_FIRMWARE_VERSION);
    firmwareVersionPref.setSummary(Build.VERSION.RELEASE);
    firmwareVersionPref.setEnabled(true);

    final Preference securityPatchPref = findPreference(KEY_SECURITY_PATCH);
    final String patch = DeviceInfoUtils.getSecurityPatch();
    if (!TextUtils.isEmpty(patch)) {
        securityPatchPref.setSummary(patch);
    } else {
        removePreference(securityPatchPref);
    }

    final LongClickPreference restartPref = (LongClickPreference) findPreference(KEY_RESTART);
    restartPref.setLongClickListener(this);

    findPreference(KEY_BASEBAND_VERSION)
            .setSummary(getSystemPropertySummary(TelephonyProperties.PROPERTY_BASEBAND_VERSION));
    findPreference(KEY_DEVICE_MODEL).setSummary(Build.MODEL + DeviceInfoUtils.getMsvSuffix());
    findPreference(KEY_EQUIPMENT_ID).setSummary(getSystemPropertySummary(PROPERTY_EQUIPMENT_ID));

    final Preference buildNumberPref = findPreference(KEY_BUILD_NUMBER);
    buildNumberPref.setSummary(Build.DISPLAY);
    buildNumberPref.setEnabled(true);
    findPreference(KEY_KERNEL_VERSION).setSummary(DeviceInfoUtils.getFormattedKernelVersion());

    final Preference selinuxPref = findPreference(KEY_SELINUX_STATUS);
    if (!SELinux.isSELinuxEnabled()) {
        selinuxPref.setSummary(R.string.selinux_status_disabled);
    } else if (!SELinux.isSELinuxEnforced()) {
        selinuxPref.setSummary(R.string.selinux_status_permissive);
    }

    // Remove selinux information if property is not present
    if (TextUtils.isEmpty(SystemProperties.get(PROPERTY_SELINUX_STATUS))) {
        removePreference(selinuxPref);
    }

    // Remove Safety information preference if PROPERTY_URL_SAFETYLEGAL is not set
    if (TextUtils.isEmpty(SystemProperties.get(PROPERTY_URL_SAFETYLEGAL))) {
        removePreference(findPreference(KEY_SAFETY_LEGAL));
    }

    // Remove Equipment id preference if FCC ID is not set by RIL
    if (TextUtils.isEmpty(SystemProperties.get(PROPERTY_EQUIPMENT_ID))) {
        removePreference(findPreference(KEY_EQUIPMENT_ID));
    }

    // Remove Baseband version if wifi-only device
    if (isWifiOnly(getActivity())) {
        removePreference(findPreference(KEY_BASEBAND_VERSION));
    }

    // Dont show feedback option if there is no reporter.
    if (TextUtils.isEmpty(DeviceInfoUtils.getFeedbackReporterPackage(getActivity()))) {
        removePreference(findPreference(KEY_DEVICE_FEEDBACK));
    }

    final Preference updateSettingsPref = findPreference(KEY_SYSTEM_UPDATE_SETTINGS);
    if (mUm.isAdminUser()) {
        PreferenceUtils.resolveSystemActivityOrRemove(getActivity(), screen, updateSettingsPref,
                PreferenceUtils.FLAG_SET_TITLE);
    } else if (updateSettingsPref != null) {
        // Remove for secondary users
        removePreference(updateSettingsPref);
    }

    // Read platform settings for additional system update setting
    if (!getResources().getBoolean(R.bool.config_additional_system_update_setting_enable)) {
        removePreference(findPreference(KEY_UPDATE_SETTING));
    }

    // Remove manual entry if none present.
    if (!getResources().getBoolean(R.bool.config_show_manual)) {
        removePreference(findPreference(KEY_MANUAL));
    }

    // Remove regulatory information if none present.
    final Preference regulatoryPref = findPreference(KEY_REGULATORY_INFO);
    PreferenceUtils.resolveSystemActivityOrRemove(getActivity(), screen, regulatoryPref, 0);
}

From source file:org.wso2.emm.system.service.api.OTAServerManager.java

/**
 * Compares device firmware version with the latest upgrade file from the server.
 *
 * @return - Returns true if the firmware needs to be upgraded.
 *///w  w w .  ja va  2s .  c o m
public boolean compareLocalVersionToServer(BuildPropParser parser) {
    if (parser == null) {
        Log.d(TAG, "compareLocalVersion Without fetch remote prop list.");
        return false;
    }

    Long buildTime = Long.parseLong(SystemProperties.get(BUILD_DATE_UTC_PROPERTY));
    String buildTimeUTC = parser.getProp(BUILD_DATE_UTC_PROPERTY);
    Long remoteBuildUTC;
    if ((buildTimeUTC != null) && (!(buildTimeUTC.equals("null")))) {
        remoteBuildUTC = Long.parseLong(buildTimeUTC);
    } else {
        remoteBuildUTC = Long.MIN_VALUE;
        Log.e(TAG, "UTC date not found in config file, config may be corrupted or missing");
    }

    Log.d(TAG, "Local Version:" + Build.VERSION.INCREMENTAL + " Server Version:" + parser.getNumRelease());
    boolean upgrade = remoteBuildUTC > buildTime;
    Log.d(TAG, "Remote build time : " + remoteBuildUTC + " Local build time : " + buildTime);
    return upgrade;
}

From source file:com.bluros.updater.service.UpdateCheckService.java

private URI getServerURI() {
    String propertyUpdateUri = SystemProperties.get("bluros.updater.uri");
    if (!TextUtils.isEmpty(propertyUpdateUri)) {
        return URI.create(propertyUpdateUri);
    }//from   w w w .  j a v  a 2  s  .  c  om

    String configUpdateUri = getString(R.string.conf_update_server_url_def);
    return URI.create(configUpdateUri);
}

From source file:com.cyanogenmod.updater.service.UpdateCheckService.java

private URI getServerURI() {
    String propertyUpdateUri = SystemProperties.get("cm.updater.uri");
    if (!TextUtils.isEmpty(propertyUpdateUri)) {
        return URI.create(propertyUpdateUri);
    }/*from w  w w.j av  a 2 s . co m*/

    String configUpdateUri = getString(R.string.conf_update_server_url_def);
    return URI.create(configUpdateUri);
}

From source file:com.cyanogenmod.account.util.CMAccountUtils.java

public static String getModVersion() {
    return SystemProperties.get("ro.cm.version");
}