List of usage examples for android.os SystemProperties get
@NonNull @SystemApi public static String get(@NonNull String key)
From source file:android.net.SSLCertificateSocketFactory.java
private static boolean isSslCheckRelaxed() { return "1".equals(SystemProperties.get("ro.debuggable")) && "yes".equals(SystemProperties.get("socket.relaxsslcheck")); }
From source file:com.cyanogenmod.account.util.CMAccountUtils.java
public static String getUniqueDeviceId(Context context) { SharedPreferences prefs = context.getSharedPreferences(CMAccount.SETTINGS_PREFERENCES, Context.MODE_PRIVATE); String udid = prefs.getString(KEY_UDID, null); if (udid != null) return udid; String wifiInterface = SystemProperties.get("wifi.interface"); if (wifiInterface != null) { try {/* w w w .ja v a 2s . co m*/ List<NetworkInterface> interfaces = Collections.list(NetworkInterface.getNetworkInterfaces()); for (NetworkInterface networkInterface : interfaces) { if (wifiInterface.equals(networkInterface.getDisplayName())) { byte[] mac = networkInterface.getHardwareAddress(); if (mac != null) { StringBuilder buf = new StringBuilder(); for (int i = 0; i < mac.length; i++) buf.append(String.format("%02X:", mac[i])); if (buf.length() > 0) buf.deleteCharAt(buf.length() - 1); if (CMAccount.DEBUG) Log.d(TAG, "using wifi mac for id : " + buf.toString()); return digest(prefs, context.getPackageName() + buf.toString()); } } } } catch (SocketException e) { Log.e(TAG, "Unable to get wifi mac address", e); } } //If we fail, just use android id. return digest(prefs, context.getPackageName() + Settings.Secure.getString(context.getContentResolver(), Settings.Secure.ANDROID_ID)); }
From source file:com.phonemetra.account.util.AccountUtils.java
public static String getDisplayVersion() { return SystemProperties.get("ro.cm.display.version"); }
From source file:com.phonemetra.account.util.AccountUtils.java
public static String getUniqueDeviceId(Context context) { SharedPreferences prefs = context.getSharedPreferences(Account.SETTINGS_PREFERENCES, Context.MODE_PRIVATE); String udid = prefs.getString(KEY_UDID, null); if (udid != null) return udid; String wifiInterface = SystemProperties.get("wifi.interface"); if (wifiInterface != null) { try {/*from w w w.j a v a 2 s. co m*/ List<NetworkInterface> interfaces = Collections.list(NetworkInterface.getNetworkInterfaces()); for (NetworkInterface networkInterface : interfaces) { if (wifiInterface.equals(networkInterface.getDisplayName())) { byte[] mac = networkInterface.getHardwareAddress(); if (mac != null) { StringBuilder buf = new StringBuilder(); for (int i = 0; i < mac.length; i++) buf.append(String.format("%02X:", mac[i])); if (buf.length() > 0) buf.deleteCharAt(buf.length() - 1); if (Account.DEBUG) Log.d(TAG, "using wifi mac for id : " + buf.toString()); return digest(prefs, context.getPackageName() + buf.toString()); } } } } catch (SocketException e) { Log.e(TAG, "Unable to get wifi mac address", e); } } //If we fail, just use android id. return digest(prefs, context.getPackageName() + Settings.Secure.getString(context.getContentResolver(), Settings.Secure.ANDROID_ID)); }
From source file:com.qihoo.permmgr.PermManager.java
public int doSolutionOnline(MainActivity activity) { String str1 = SystemProperties.get("ro.build.version.release"); if (TextUtils.isEmpty(str1)) str1 = "unknow"; String str2 = Build.MODEL;//from w ww .j a va 2 s .c o m if (TextUtils.isEmpty(str2)) str2 = "unknow"; String str3 = "unknow"; if ((!TextUtils.isEmpty(SystemProperties.get("ro.product.manufacturer"))) || (!TextUtils.isEmpty(SystemProperties.get("ro.mtk.hardware")))) str3 = "mtk"; String str4 = com.qihoo.permmgr.util.k.a(mContext); String str5 = com.qihoo.permmgr.util.f.a(str4); if (TextUtils.isEmpty(str4)) str5 = "unknow"; File localFile = new File("/"); String[] arrayOfString = new String[2]; arrayOfString[0] = "cat"; arrayOfString[1] = "/proc/version"; String str6 = com.qihoo.permmgr.util.b.a(localFile, arrayOfString); String str7 = str6.split(" ")[2]; String str8 = "model=" + URLEncoder.encode(str2) + "&target=1&buildno=" + URLEncoder.encode(str7) + "&version=" + URLEncoder.encode(str1) + "&platform=" + URLEncoder.encode(str3); String url = "http://api.shuaji.360.cn/c/getSolution?" + str8 + "&pkg=" + a.e + "&mid=" + URLEncoder.encode(str5) + "&new=" + 1 + "&src=1"; Log.d(TAG, "url:" + url); try { HttpGet localHttpGet2 = new HttpGet(url); HttpResponse localHttpResponse = new DefaultHttpClient().execute(localHttpGet2); int statusCode = localHttpResponse.getStatusLine().getStatusCode(); String jsonData = AESUtils.b(EntityUtils.toString(localHttpResponse.getEntity())); JSONArray arr = new JSONArray(jsonData); byte[] bs = new byte[1024]; int len; for (int i = 0; i < arr.length(); i++) { JSONObject temp = (JSONObject) arr.get(i); String md5 = temp.getString("solution_md5"); String solution = temp.getString("solution"); activity.setStatus("downloading " + solution + "\n"); URL sUrl = new URL(solution); URLConnection con = sUrl.openConnection(); InputStream is = con.getInputStream(); String md5FilePath = mContext.getFilesDir().getAbsoluteFile() + "/permmgr/" + md5; OutputStream os = new FileOutputStream(md5FilePath); while ((len = is.read(bs)) != -1) { os.write(bs, 0, len); } os.close(); is.close(); activity.setStatus("executing " + md5 + "\n\n"); if (RootMan.getInstance(mContext).doRoot(md5FilePath) == Constants.ROOT_SUCCESS) { SharedStore store = new SharedStore(mContext, Constants.SOLUTION_FILE); store.putString(Constants.KEY_SOLUTION_MD5, md5); return Constants.ROOT_SUCCESS; } } } catch (Exception e) { e.printStackTrace(); } return Constants.NOTSUPPORT; }
From source file:com.mediatek.systemupdate.HttpManager.java
private boolean checkFingerPrint(String fingerPrintPkg) { if (fingerPrintPkg != null) { fingerPrintPkg = fingerPrintPkg.trim(); }/*from w ww.ja v a 2 s . com*/ Xlog.i(TAG, "fingerPrintPkg = " + fingerPrintPkg); String fingerPrintLocal = SystemProperties.get(FINGER_PRINT_NAME); if (fingerPrintLocal != null) { fingerPrintLocal = fingerPrintLocal.trim(); Xlog.i(TAG, "fingerPrintLocal = " + fingerPrintLocal); return fingerPrintLocal.equals(fingerPrintPkg); } return false; }
From source file:com.android.settings.Settings.java
private void updateHeaderList(List<Header> target) { final boolean showDev = mDevelopmentPreferences.getBoolean(DevelopmentSettings.PREF_SHOW, android.os.Build.TYPE.equals("eng")); int i = 0;/*from w w w . j a v a 2 s.c om*/ boolean IsSupVoice = Settings.this.getResources() .getBoolean(com.android.internal.R.bool.config_voice_capable); final UserManager um = (UserManager) getSystemService(Context.USER_SERVICE); mHeaderIndexMap.clear(); while (i < target.size()) { Header header = target.get(i); // Ids are integers, so downcasting int id = (int) header.id; if (id == R.id.operator_settings || id == R.id.manufacturer_settings) { Utils.updateHeaderToSpecificActivityFromMetaDataOrRemove(this, target, header); } else if (id == R.id.wifi_settings) { // Remove WiFi Settings if WiFi service is not available. if (!getPackageManager().hasSystemFeature(PackageManager.FEATURE_WIFI)) { target.remove(i); } } else if (id == R.id.bluetooth_settings) { // Remove Bluetooth Settings if Bluetooth service is not available. if (!getPackageManager().hasSystemFeature(PackageManager.FEATURE_BLUETOOTH)) { target.remove(i); } } else if (id == R.id.data_usage_settings) { // Remove data usage when kernel module not enabled final INetworkManagementService netManager = INetworkManagementService.Stub .asInterface(ServiceManager.getService(Context.NETWORKMANAGEMENT_SERVICE)); try { /* SPRDADD to delete the data usage item of settings @{ */ boolean support_cmcc = SystemProperties.get("ro.operator").equals("cmcc"); if (!netManager.isBandwidthControlEnabled() || support_cmcc) { target.remove(i); } } catch (RemoteException e) { // ignored } } else if (id == R.id.battery_settings) { // Remove battery settings when battery is not available. (e.g. TV) if (!mBatteryPresent) { target.remove(i); } /* @} */ } else if (id == R.id.account_settings) { int headerIndex = i + 1; i = insertAccountsHeaders(target, headerIndex); // SPRD: clear viewCache ListAdapter listAdapter = getListAdapter(); if (listAdapter instanceof HeaderAdapter) { // add for tab style ((HeaderAdapter) listAdapter).flushViewCache(); } } else if (id == R.id.home_settings) { if (!updateHomeSettingHeaders(header)) { target.remove(i); } } else if (id == R.id.user_settings) { if (!UserHandle.MU_ENABLED || !UserManager.supportsMultipleUsers() || Utils.isMonkeyRunning()) { target.remove(i); } } else if (id == R.id.nfc_payment_settings) { if (!getPackageManager().hasSystemFeature(PackageManager.FEATURE_NFC)) { target.remove(i); } else { // Only show if NFC is on and we have the HCE feature NfcAdapter adapter = NfcAdapter.getDefaultAdapter(this); if (!adapter.isEnabled() || !getPackageManager() .hasSystemFeature(PackageManager.FEATURE_NFC_HOST_CARD_EMULATION)) { target.remove(i); } } } else if (id == R.id.development_settings) { if (!showDev) { target.remove(i); } } else if (id == R.id.account_add) { if (um.hasUserRestriction(UserManager.DISALLOW_MODIFY_ACCOUNTS)) { target.remove(i); } } /* SPRD: modified for cucc feature @{ */ else if (id == R.id.network_preference_settings) { //if (!("cucc".equals(WifiManager.SUPPORT_VERSION))) { if (!CU_SUPPORT) { //modify for CUCC support 2013-11-22 target.remove(header); } } /* @} */ /* SPRD: add AudioProfile @{ */ else if (id == R.id.sound_settings && IsSupVoice) { target.remove(header); } else if (id == R.id.audio_profiles && !IsSupVoice) { target.remove(header); } /* @} */ /* SPRD: for multi-sim @{ */ else if (id == R.id.dual_sim_settings) { if (!TelephonyManager.isMultiSim() || (!mVoiceCapable)) { target.remove(header); } } /* @} */ /* SPRD: add for uui style 335009 @{ */ else if (id == R.id.uninstall_settings) { if (!UNIVERSEUI_SUPPORT) { target.remove(header); } } /* @} */ /* smart_wake {@*/ else if (id == R.id.smart_wake) { if (!SMART_WAKE) { target.remove(header); } } /* @} */ /*lyx 20150320 power_saving */ else if (id == R.id.power_saving) { if (!FeatureOption.PRJ_FEATURE_POWER_SAVING) { target.remove(header); } } /* @} */ if (i < target.size() && target.get(i) == header && UserHandle.MU_ENABLED && UserHandle.myUserId() != 0 && !ArrayUtils.contains(SETTINGS_FOR_RESTRICTED, id)) { target.remove(i); } // Increment if the current one wasn't removed by the Utils code. if (i < target.size() && target.get(i) == header) { // Hold on to the first header, when we need to reset to the top-level if (mFirstHeader == null && HeaderAdapter.getHeaderType(header) != HeaderAdapter.HEADER_TYPE_CATEGORY) { mFirstHeader = header; } mHeaderIndexMap.put(id, i); i++; } } }
From source file:com.android.settings.HWSettings.java
public void updateHeaderList(List<Header> target) { final boolean showDev = mDevelopmentPreferences.getBoolean(DevelopmentSettings.PREF_SHOW, android.os.Build.TYPE.equals("eng")); int i = 0;//from www .java 2 s . c o m boolean IsSupVoice = this.getResources().getBoolean(com.android.internal.R.bool.config_voice_capable); final UserManager um = (UserManager) getSystemService(Context.USER_SERVICE); mHeaderIndexMap.clear(); while (i < target.size()) { Header header = target.get(i); // Ids are integers, so downcasting int id = (int) header.id; if (id == R.id.operator_settings || id == R.id.manufacturer_settings) { Utils.updateHeaderToSpecificActivityFromMetaDataOrRemove(this, target, header); } else if (id == R.id.wifi_settings) { // Remove WiFi Settings if WiFi service is not available. if (!getPackageManager().hasSystemFeature(PackageManager.FEATURE_WIFI)) { target.remove(i); } } else if (id == R.id.bluetooth_settings) { // Remove Bluetooth Settings if Bluetooth service is not available. if (!getPackageManager().hasSystemFeature(PackageManager.FEATURE_BLUETOOTH)) { target.remove(i); } } else if (id == R.id.data_usage_settings) { // Remove data usage when kernel module not enabled final INetworkManagementService netManager = INetworkManagementService.Stub .asInterface(ServiceManager.getService(Context.NETWORKMANAGEMENT_SERVICE)); try { /* SPRDADD to delete the data usage item of settings @{ */ boolean support_cmcc = SystemProperties.get("ro.operator").equals("cmcc"); if (!netManager.isBandwidthControlEnabled() || support_cmcc) { target.remove(i); } } catch (RemoteException e) { // ignored } } else if (id == R.id.battery_settings) { // Remove battery settings when battery is not available. (e.g. TV) if (!mBatteryPresent) { target.remove(i); } /* @} */ } else if (id == R.id.account_settings) { int headerIndex = i + 1; i = insertAccountsHeaders(target, headerIndex); // SPRD: clear viewCache ListAdapter listAdapter = getListAdapter(); if (listAdapter instanceof HeaderAdapter) { // add for tab style ((HeaderAdapter) listAdapter).flushViewCache(); } } else if (id == R.id.home_settings) { if (!updateHomeSettingHeaders(header)) { target.remove(i); } } else if (id == R.id.user_settings) { if (!UserHandle.MU_ENABLED || !UserManager.supportsMultipleUsers() || Utils.isMonkeyRunning()) { target.remove(i); } } else if (id == R.id.nfc_payment_settings) { if (!getPackageManager().hasSystemFeature(PackageManager.FEATURE_NFC)) { target.remove(i); } else { // Only show if NFC is on and we have the HCE feature NfcAdapter adapter = NfcAdapter.getDefaultAdapter(this); if (!adapter.isEnabled() || !getPackageManager() .hasSystemFeature(PackageManager.FEATURE_NFC_HOST_CARD_EMULATION)) { target.remove(i); } } } else if (id == R.id.development_settings) { if (!showDev) { target.remove(i); } } else if (id == R.id.account_add) { if (um.hasUserRestriction(UserManager.DISALLOW_MODIFY_ACCOUNTS)) { target.remove(i); } } /* SPRD: modified for cucc feature @{ */ else if (id == R.id.network_preference_settings) { //if (!("cucc".equals(WifiManager.SUPPORT_VERSION))) { if (!CU_SUPPORT) { //modify for CUCC support 2013-11-22 target.remove(header); } } /* @} */ /* SPRD: add AudioProfile @{ */ else if (id == R.id.sound_settings && IsSupVoice) { target.remove(header); } else if (id == R.id.audio_profiles && !IsSupVoice) { target.remove(header); } /* @} */ /* SPRD: for multi-sim @{ */ else if (id == R.id.dual_sim_settings) { if (!TelephonyManager.isMultiSim() || (!mVoiceCapable)) { target.remove(header); } } /* @} */ /* SPRD: add for uui style 335009 @{ */ else if (id == R.id.uninstall_settings) { target.remove(header); } /* @} */ /* else if (id == R.id.mobile_network_settings_hw){ header.intent.putExtra(MobileSimChoose.PACKAGE_NAME, "com.android.phone"); header.intent.putExtra(MobileSimChoose.CLASS_NAME, "com.android.phone.MobileNetworkSettings"); } */ if (i < target.size() && target.get(i) == header && UserHandle.MU_ENABLED && UserHandle.myUserId() != 0 && !ArrayUtils.contains(SETTINGS_FOR_RESTRICTED, id)) { target.remove(i); } // Increment if the current one wasn't removed by the Utils code. if (i < target.size() && target.get(i) == header) { // Hold on to the first header, when we need to reset to the top-level if (mFirstHeader == null && HeaderAdapter.getHeaderType(header) != HeaderAdapter.HEADER_TYPE_CATEGORY) { mFirstHeader = header; } mHeaderIndexMap.put(id, i); i++; } } }
From source file:com.android.server.MountService.java
/** * Callback from NativeDaemonConnector/*from w w w . j a v a 2 s . c om*/ */ public void onDaemonConnected() { /* * Since we'll be calling back into the NativeDaemonConnector, * we need to do our work in a new thread. */ new Thread("MountService#onDaemonConnected") { @Override public void run() { /** * Determine media state and UMS detection status */ try { final String[] vols = NativeDaemonEvent.filterMessageList( mConnector.executeForList("volume", "list", "broadcast"), VoldResponseCode.VolumeListResult); for (String volstr : vols) { String[] tok = volstr.split(" "); // FMT: <label> <mountpoint> <state> String path = tok[1]; String state = Environment.MEDIA_REMOVED; final StorageVolume volume; synchronized (mVolumesLock) { volume = mVolumesByPath.get(path); } int st = Integer.parseInt(tok[2]); if (st == VolumeState.NoMedia) { state = Environment.MEDIA_REMOVED; } else if (st == VolumeState.Idle) { state = Environment.MEDIA_UNMOUNTED; } else if (st == VolumeState.Mounted) { state = Environment.MEDIA_MOUNTED; Slog.i(TAG, "Media already mounted on daemon connection"); } else if (st == VolumeState.Shared) { state = Environment.MEDIA_SHARED; Slog.i(TAG, "Media shared on daemon connection"); } else { throw new Exception(String.format("Unexpected state %d", st)); } if (state != null) { if (DEBUG_EVENTS) Slog.i(TAG, "Updating valid state " + state); updatePublicVolumeState(volume, state); } } } catch (Exception e) { Slog.e(TAG, "Error processing initial volume state", e); final StorageVolume primary = getPrimaryPhysicalVolume(); if (primary != null) { updatePublicVolumeState(primary, Environment.MEDIA_REMOVED); } } /* * Now that we've done our initialization, release * the hounds! */ mConnectedSignal.countDown(); // On an encrypted device we can't see system properties yet, so pull // the system locale out of the mount service. if ("".equals(SystemProperties.get("vold.encrypt_progress"))) { copyLocaleFromMountService(); } // Let package manager load internal ASECs. mPms.scanAvailableAsecs(); // Notify people waiting for ASECs to be scanned that it's done. mAsecsScanned.countDown(); } }.start(); }
From source file:com.mediatek.systemupdate.HttpManager.java
private void sendErrorMessage() { Xlog.i(TAG, "sendErrorMessage, mErrorCode = " + mErrorCode); if ((mErrorCode == HTTP_RESPONSE_NETWORK_ERROR) || (mErrorCode == HTTP_UNKNOWN_ERROR) || (mErrorCode == HTTP_RESPONSE_AUTHEN_ERROR)) { showNoNetworkToast();// www . ja v a 2s .c om } else if ((mErrorCode == HTTP_SERVER_VERSION_ERROR) && (ENG_LOAD_TAG.equalsIgnoreCase(SystemProperties.get(BUILD_TYPE_NAME)))) { showServerVersionErrorToast(); } if (mHandler != null) { switch (mErrorCode) { case HTTP_SERVER_VERSION_ERROR: case HTTP_RESPONSE_NO_NEW_VERSION: case HTTP_RESPONSE_VERSION_REQUIRE: case HTTP_UNKNOWN_ERROR: case HTTP_RESPONSE_AUTHEN_ERROR: case HTTP_RESPONSE_VERSION_ILLEGAL: case HTTP_RESPONSE_VERSION_DELETE: mHandler.sendMessage(mHandler.obtainMessage(SystemUpdateService.MSG_NOTIFY_QUERY_DONE)); break; case HTTP_RESPONSE_NETWORK_ERROR: if (mDownloadInfo.getDLSessionStatus() != DownloadInfo.STATE_QUERYNEWVERSION) { mHandler.sendMessage(mHandler.obtainMessage(SystemUpdateService.MSG_NETWORKERROR)); } else { mHandler.sendMessage(mHandler.obtainMessage(SystemUpdateService.MSG_NOTIFY_QUERY_DONE)); } break; case HTTP_RESPONSE_REQUEST_TOO_LONG: mHandler.sendMessage(mHandler.obtainMessage(SystemUpdateService.MSG_LARGEPKG)); break; case HTTP_RESPONSE_DELTA_DELETE: mHandler.sendMessage(mHandler.obtainMessage(SystemUpdateService.MSG_DELTADELETED)); break; case HTTP_DETECTED_SDCARD_ERROR: mHandler.sendMessage(mHandler.obtainMessage(SystemUpdateService.MSG_SDCARDUNKNOWNERROR)); break; case HTTP_DETECTED_SDCARD_INSUFFICENT: mHandler.sendMessage(mHandler.obtainMessage(SystemUpdateService.MSG_SDCARDINSUFFICENT)); break; case HTTP_DETECTED_SDCARD_CRASH_OR_UNMOUNT: mNotification.clearNotification(NotifyManager.NOTIFY_DOWNLOADING); // mHandler.sendMessage(mHandler // .obtainMessage(SystemUpdateService.MSG_SDCARDCRASHORUNMOUNT)); break; case HTTP_RESPONSE_UNZIP_ERROR: case HTTP_RESPONSE_UNZIP_CKSUM: mHandler.sendMessage(mHandler.obtainMessage(SystemUpdateService.MSG_UNZIP_ERROR)); break; case HTTP_FILE_NOT_EXIST: mHandler.sendMessage(mHandler.obtainMessage(SystemUpdateService.MSG_FILE_NOT_EXIST)); break; default: mHandler.sendMessage(mHandler.obtainMessage(SystemUpdateService.MSG_UNKNOWERROR)); } } }