Java Code Examples for android.os.SystemProperties#set()
The following examples show how to use
android.os.SystemProperties#set() .
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: DisplayTransformManager.java From android_9.0.0_r45 with Apache License 2.0 | 6 votes |
/** * Toggles native mode on/off in SurfaceFlinger. */ private void setDisplayColor(int color) { SystemProperties.set(PERSISTENT_PROPERTY_DISPLAY_COLOR, Integer.toString(color)); final IBinder flinger = ServiceManager.getService(SURFACE_FLINGER); if (flinger != null) { final Parcel data = Parcel.obtain(); data.writeInterfaceToken("android.ui.ISurfaceComposer"); data.writeInt(color); try { flinger.transact(SURFACE_FLINGER_TRANSACTION_DISPLAY_COLOR, data, null, 0); } catch (RemoteException ex) { Log.e(TAG, "Failed to set display color", ex); } finally { data.recycle(); } } }
Example 2
Source File: StorageManagerService.java From android_9.0.0_r45 with Apache License 2.0 | 6 votes |
/** * Update the zram_enabled system property (which init reads to * decide whether to enable zram) to reflect the zram_enabled * preference (which we can change for experimentation purposes). */ private void refreshZramSettings() { String propertyValue = SystemProperties.get(ZRAM_ENABLED_PROPERTY); if ("".equals(propertyValue)) { return; // System doesn't have zram toggling support } String desiredPropertyValue = Settings.Global.getInt(mContext.getContentResolver(), Settings.Global.ZRAM_ENABLED, 1) != 0 ? "1" : "0"; if (!desiredPropertyValue.equals(propertyValue)) { // Avoid redundant disk writes by setting only if we're // changing the property value. There's no race: we're the // sole writer. SystemProperties.set(ZRAM_ENABLED_PROPERTY, desiredPropertyValue); } }
Example 3
Source File: DisplayTransformManager.java From android_9.0.0_r45 with Apache License 2.0 | 6 votes |
/** * Propagates the provided saturation to the SurfaceFlinger. */ private void applySaturation(float saturation) { SystemProperties.set(PERSISTENT_PROPERTY_SATURATION, Float.toString(saturation)); final IBinder flinger = ServiceManager.getService(SURFACE_FLINGER); if (flinger != null) { final Parcel data = Parcel.obtain(); data.writeInterfaceToken("android.ui.ISurfaceComposer"); data.writeFloat(saturation); try { flinger.transact(SURFACE_FLINGER_TRANSACTION_SATURATION, data, null, 0); } catch (RemoteException ex) { Log.e(TAG, "Failed to set saturation", ex); } finally { data.recycle(); } } }
Example 4
Source File: PowerManagerService.java From android_9.0.0_r45 with Apache License 2.0 | 5 votes |
/** * Low-level function to reboot the device. On success, this * function doesn't return. If more than 20 seconds passes from * the time a reboot is requested, this method returns. * * @param reason code to pass to the kernel (e.g. "recovery"), or null. */ public static void lowLevelReboot(String reason) { if (reason == null) { reason = ""; } // If the reason is "quiescent", it means that the boot process should proceed // without turning on the screen/lights. // The "quiescent" property is sticky, meaning that any number // of subsequent reboots should honor the property until it is reset. if (reason.equals(PowerManager.REBOOT_QUIESCENT)) { sQuiescent = true; reason = ""; } else if (reason.endsWith("," + PowerManager.REBOOT_QUIESCENT)) { sQuiescent = true; reason = reason.substring(0, reason.length() - PowerManager.REBOOT_QUIESCENT.length() - 1); } if (reason.equals(PowerManager.REBOOT_RECOVERY) || reason.equals(PowerManager.REBOOT_RECOVERY_UPDATE)) { reason = "recovery"; } if (sQuiescent) { // Pass the optional "quiescent" argument to the bootloader to let it know // that it should not turn the screen/lights on. reason = reason + ",quiescent"; } SystemProperties.set("sys.powerctl", "reboot," + reason); try { Thread.sleep(20 * 1000L); } catch (InterruptedException e) { Thread.currentThread().interrupt(); } Slog.wtf(TAG, "Unexpected return from lowLevelReboot!"); }
Example 5
Source File: ActivityManagerShellCommand.java From android_9.0.0_r45 with Apache License 2.0 | 5 votes |
static void removeWallOption() { String props = SystemProperties.get("dalvik.vm.extra-opts"); if (props != null && props.contains("-Xprofile:wallclock")) { props = props.replace("-Xprofile:wallclock", ""); props = props.trim(); SystemProperties.set("dalvik.vm.extra-opts", props); } }
Example 6
Source File: BinderCallsStatsService.java From android_9.0.0_r45 with Apache License 2.0 | 5 votes |
@Override protected void dump(FileDescriptor fd, PrintWriter pw, String[] args) { if (args != null) { for (final String arg : args) { if ("-a".equals(arg)) { // We currently dump all information by default continue; } else if ("--reset".equals(arg)) { reset(); pw.println("binder_calls_stats reset."); return; } else if ("--enable-detailed-tracking".equals(arg)) { SystemProperties.set(PERSIST_SYS_BINDER_CALLS_DETAILED_TRACKING, "1"); BinderCallsStats.getInstance().setDetailedTracking(true); pw.println("Detailed tracking enabled"); return; } else if ("--disable-detailed-tracking".equals(arg)) { SystemProperties.set(PERSIST_SYS_BINDER_CALLS_DETAILED_TRACKING, ""); BinderCallsStats.getInstance().setDetailedTracking(false); pw.println("Detailed tracking disabled"); return; } else if ("-h".equals(arg)) { pw.println("binder_calls_stats commands:"); pw.println(" --reset: Reset stats"); pw.println(" --enable-detailed-tracking: Enables detailed tracking"); pw.println(" --disable-detailed-tracking: Disables detailed tracking"); return; } else { pw.println("Unknown option: " + arg); } } } BinderCallsStats.getInstance().dump(pw); }
Example 7
Source File: GnssLocationProvider.java From android_9.0.0_r45 with Apache License 2.0 | 5 votes |
private void subscriptionOrSimChanged(Context context) { if (DEBUG) Log.d(TAG, "received SIM related action: "); TelephonyManager phone = (TelephonyManager) mContext.getSystemService(Context.TELEPHONY_SERVICE); CarrierConfigManager configManager = (CarrierConfigManager) mContext.getSystemService(Context.CARRIER_CONFIG_SERVICE); String mccMnc = phone.getSimOperator(); boolean isKeepLppProfile = false; if (!TextUtils.isEmpty(mccMnc)) { if (DEBUG) Log.d(TAG, "SIM MCC/MNC is available: " + mccMnc); synchronized (mLock) { if (configManager != null) { PersistableBundle b = configManager.getConfig(); if (b != null) { isKeepLppProfile = b.getBoolean(CarrierConfigManager.KEY_PERSIST_LPP_MODE_BOOL); } } if (isKeepLppProfile) { // load current properties for the carrier loadPropertiesFromResource(context, mProperties); String lpp_profile = mProperties.getProperty("LPP_PROFILE"); // set the persist property LPP_PROFILE for the value if (lpp_profile != null) { SystemProperties.set(LPP_PROFILE, lpp_profile); } } else { // reset the persist property SystemProperties.set(LPP_PROFILE, ""); } reloadGpsProperties(context, mProperties); mNIHandler.setSuplEsEnabled(mSuplEsEnabled); } } else { if (DEBUG) Log.d(TAG, "SIM MCC/MNC is still not available"); } }
Example 8
Source File: PersistentDataBlockService.java From android_9.0.0_r45 with Apache License 2.0 | 5 votes |
private void formatIfOemUnlockEnabled() { boolean enabled = doGetOemUnlockEnabled(); if (enabled) { synchronized (mLock) { formatPartitionLocked(true); } } SystemProperties.set(OEM_UNLOCK_PROP, enabled ? "1" : "0"); }
Example 9
Source File: PowerManagerService.java From android_9.0.0_r45 with Apache License 2.0 | 5 votes |
/** * Low-level function turn the device off immediately, without trying * to be clean. Most people should use {@link ShutdownThread} for a clean shutdown. * * @param reason code to pass to android_reboot() (e.g. "userrequested"), or null. */ public static void lowLevelShutdown(String reason) { if (reason == null) { reason = ""; } SystemProperties.set("sys.powerctl", "shutdown," + reason); }
Example 10
Source File: RescueParty.java From android_9.0.0_r45 with Apache License 2.0 | 5 votes |
/** * Escalate to the next rescue level. After incrementing the level you'll * probably want to call {@link #executeRescueLevel(Context)}. */ private static void incrementRescueLevel(int triggerUid) { final int level = MathUtils.constrain( SystemProperties.getInt(PROP_RESCUE_LEVEL, LEVEL_NONE) + 1, LEVEL_NONE, LEVEL_FACTORY_RESET); SystemProperties.set(PROP_RESCUE_LEVEL, Integer.toString(level)); EventLogTags.writeRescueLevel(level, triggerUid); logCriticalInfo(Log.WARN, "Incremented rescue level to " + levelToString(level) + " triggered by UID " + triggerUid); }
Example 11
Source File: DisplayManagerService.java From android_9.0.0_r45 with Apache License 2.0 | 5 votes |
private void recordTopInsetLocked(@Nullable LogicalDisplay d) { // We must only persist the inset after boot has completed, otherwise we will end up // overwriting the persisted value before the masking flag has been loaded from the // resource overlay. if (!mSystemReady || d == null) { return; } int topInset = d.getInsets().top; if (topInset == mDefaultDisplayTopInset) { return; } mDefaultDisplayTopInset = topInset; SystemProperties.set(PROP_DEFAULT_DISPLAY_TOP_INSET, Integer.toString(topInset)); }
Example 12
Source File: PowerManagerService.java From android_9.0.0_r45 with Apache License 2.0 | 4 votes |
private void updateSettingsLocked() { final ContentResolver resolver = mContext.getContentResolver(); mDreamsEnabledSetting = (Settings.Secure.getIntForUser(resolver, Settings.Secure.SCREENSAVER_ENABLED, mDreamsEnabledByDefaultConfig ? 1 : 0, UserHandle.USER_CURRENT) != 0); mDreamsActivateOnSleepSetting = (Settings.Secure.getIntForUser(resolver, Settings.Secure.SCREENSAVER_ACTIVATE_ON_SLEEP, mDreamsActivatedOnSleepByDefaultConfig ? 1 : 0, UserHandle.USER_CURRENT) != 0); mDreamsActivateOnDockSetting = (Settings.Secure.getIntForUser(resolver, Settings.Secure.SCREENSAVER_ACTIVATE_ON_DOCK, mDreamsActivatedOnDockByDefaultConfig ? 1 : 0, UserHandle.USER_CURRENT) != 0); mScreenOffTimeoutSetting = Settings.System.getIntForUser(resolver, Settings.System.SCREEN_OFF_TIMEOUT, DEFAULT_SCREEN_OFF_TIMEOUT, UserHandle.USER_CURRENT); mSleepTimeoutSetting = Settings.Secure.getIntForUser(resolver, Settings.Secure.SLEEP_TIMEOUT, DEFAULT_SLEEP_TIMEOUT, UserHandle.USER_CURRENT); mStayOnWhilePluggedInSetting = Settings.Global.getInt(resolver, Settings.Global.STAY_ON_WHILE_PLUGGED_IN, BatteryManager.BATTERY_PLUGGED_AC); mTheaterModeEnabled = Settings.Global.getInt(mContext.getContentResolver(), Settings.Global.THEATER_MODE_ON, 0) == 1; mAlwaysOnEnabled = mAmbientDisplayConfiguration.alwaysOnEnabled(UserHandle.USER_CURRENT); if (mSupportsDoubleTapWakeConfig) { boolean doubleTapWakeEnabled = Settings.Secure.getIntForUser(resolver, Settings.Secure.DOUBLE_TAP_TO_WAKE, DEFAULT_DOUBLE_TAP_TO_WAKE, UserHandle.USER_CURRENT) != 0; if (doubleTapWakeEnabled != mDoubleTapWakeEnabled) { mDoubleTapWakeEnabled = doubleTapWakeEnabled; nativeSetFeature(POWER_FEATURE_DOUBLE_TAP_TO_WAKE, mDoubleTapWakeEnabled ? 1 : 0); } } final String retailDemoValue = UserManager.isDeviceInDemoMode(mContext) ? "1" : "0"; if (!retailDemoValue.equals(SystemProperties.get(SYSTEM_PROPERTY_RETAIL_DEMO_ENABLED))) { SystemProperties.set(SYSTEM_PROPERTY_RETAIL_DEMO_ENABLED, retailDemoValue); } mScreenBrightnessModeSetting = Settings.System.getIntForUser(resolver, Settings.System.SCREEN_BRIGHTNESS_MODE, Settings.System.SCREEN_BRIGHTNESS_MODE_MANUAL, UserHandle.USER_CURRENT); mDirty |= DIRTY_SETTINGS; }
Example 13
Source File: SettingsProvider.java From Study_Android_Demo with Apache License 2.0 | 4 votes |
/** * Send a notification when a particular content URI changes. * Modify the system property used to communicate the version of * this table, for tables which have such a property. (The Settings * contract class uses these to provide client-side caches.) * @param uri to send notifications for */ private void sendNotify(Uri uri, int userHandle) { // Update the system property *first*, so if someone is listening for // a notification and then using the contract class to get their data, // the system property will be updated and they'll get the new data. boolean backedUpDataChanged = false; String property = null, table = uri.getPathSegments().get(0); final boolean isGlobal = table.equals(TABLE_GLOBAL); if (table.equals(TABLE_SYSTEM)) { property = Settings.System.SYS_PROP_SETTING_VERSION; backedUpDataChanged = true; } else if (table.equals(TABLE_SECURE)) { property = Settings.Secure.SYS_PROP_SETTING_VERSION; backedUpDataChanged = true; } else if (isGlobal) { property = Settings.Global.SYS_PROP_SETTING_VERSION; // this one is global backedUpDataChanged = true; } if (property != null) { long version = SystemProperties.getLong(property, 0) + 1; if (LOCAL_LOGV) Log.v(TAG, "property: " + property + "=" + version); SystemProperties.set(property, Long.toString(version)); } // Inform the backup manager about a data change if (backedUpDataChanged) { mBackupManager.dataChanged(); } // Now send the notification through the content framework. String notify = uri.getQueryParameter("notify"); if (notify == null || "true".equals(notify)) { final int notifyTarget = isGlobal ? UserHandle.USER_ALL : userHandle; final long oldId = Binder.clearCallingIdentity(); try { getContext().getContentResolver().notifyChange(uri, null, true, notifyTarget); } finally { Binder.restoreCallingIdentity(oldId); } if (LOCAL_LOGV) Log.v(TAG, "notifying for " + notifyTarget + ": " + uri); } else { if (LOCAL_LOGV) Log.v(TAG, "notification suppressed: " + uri); } }
Example 14
Source File: RescueParty.java From android_9.0.0_r45 with Apache License 2.0 | 4 votes |
@Override public void setStart(long start) { SystemProperties.set(PROP_RESCUE_BOOT_START, Long.toString(start)); }
Example 15
Source File: UserDataPreparer.java From android_9.0.0_r45 with Apache License 2.0 | 4 votes |
private void prepareUserDataLI(String volumeUuid, int userId, int userSerial, int flags, boolean allowRecover) { // Prepare storage and verify that serial numbers are consistent; if // there's a mismatch we need to destroy to avoid leaking data final StorageManager storage = mContext.getSystemService(StorageManager.class); try { storage.prepareUserStorage(volumeUuid, userId, userSerial, flags); if ((flags & StorageManager.FLAG_STORAGE_DE) != 0 && !mOnlyCore) { enforceSerialNumber(getDataUserDeDirectory(volumeUuid, userId), userSerial); if (Objects.equals(volumeUuid, StorageManager.UUID_PRIVATE_INTERNAL)) { enforceSerialNumber(getDataSystemDeDirectory(userId), userSerial); } } if ((flags & StorageManager.FLAG_STORAGE_CE) != 0 && !mOnlyCore) { enforceSerialNumber(getDataUserCeDirectory(volumeUuid, userId), userSerial); if (Objects.equals(volumeUuid, StorageManager.UUID_PRIVATE_INTERNAL)) { enforceSerialNumber(getDataSystemCeDirectory(userId), userSerial); } } mInstaller.createUserData(volumeUuid, userId, userSerial, flags); // CE storage is available after they are prepared. if ((flags & StorageManager.FLAG_STORAGE_CE) != 0 && (userId == UserHandle.USER_SYSTEM)) { String propertyName = "sys.user." + userId + ".ce_available"; Slog.d(TAG, "Setting property: " + propertyName + "=true"); SystemProperties.set(propertyName, "true"); } } catch (Exception e) { logCriticalInfo(Log.WARN, "Destroying user " + userId + " on volume " + volumeUuid + " because we failed to prepare: " + e); destroyUserDataLI(volumeUuid, userId, flags); if (allowRecover) { // Try one last time; if we fail again we're really in trouble prepareUserDataLI(volumeUuid, userId, userSerial, flags | StorageManager.FLAG_STORAGE_DE, false); } } }
Example 16
Source File: SecurityLog.java From android_9.0.0_r45 with Apache License 2.0 | 4 votes |
/** * @hide */ public static void setLoggingEnabledProperty(boolean enabled) { SystemProperties.set(PROPERTY_LOGGING_ENABLED, enabled ? "true" : "false"); }
Example 17
Source File: RescueParty.java From android_9.0.0_r45 with Apache License 2.0 | 4 votes |
@Override public void setCount(int count) { SystemProperties.set(PROP_RESCUE_BOOT_COUNT, Integer.toString(count)); }
Example 18
Source File: PreloadsFileCacheExpirationJobService.java From android_9.0.0_r45 with Apache License 2.0 | 4 votes |
@Override public boolean onStartJob(JobParameters params) { SystemProperties.set(PERSIST_SYS_PRELOADS_FILE_CACHE_EXPIRED, "1"); Slog.i(TAG, "Set " + PERSIST_SYS_PRELOADS_FILE_CACHE_EXPIRED + "=1"); return false; }
Example 19
Source File: MockableSystemProperties.java From android_9.0.0_r45 with Apache License 2.0 | 4 votes |
public void set(String key, String value) { SystemProperties.set(key, value); }
Example 20
Source File: ProcessList.java From android_9.0.0_r45 with Apache License 2.0 | 4 votes |
private void updateOomLevels(int displayWidth, int displayHeight, boolean write) { // Scale buckets from avail memory: at 300MB we use the lowest values to // 700MB or more for the top values. float scaleMem = ((float)(mTotalMemMb-350))/(700-350); // Scale buckets from screen size. int minSize = 480*800; // 384000 int maxSize = 1280*800; // 1024000 230400 870400 .264 float scaleDisp = ((float)(displayWidth*displayHeight)-minSize)/(maxSize-minSize); if (false) { Slog.i("XXXXXX", "scaleMem=" + scaleMem); Slog.i("XXXXXX", "scaleDisp=" + scaleDisp + " dw=" + displayWidth + " dh=" + displayHeight); } float scale = scaleMem > scaleDisp ? scaleMem : scaleDisp; if (scale < 0) scale = 0; else if (scale > 1) scale = 1; int minfree_adj = Resources.getSystem().getInteger( com.android.internal.R.integer.config_lowMemoryKillerMinFreeKbytesAdjust); int minfree_abs = Resources.getSystem().getInteger( com.android.internal.R.integer.config_lowMemoryKillerMinFreeKbytesAbsolute); if (false) { Slog.i("XXXXXX", "minfree_adj=" + minfree_adj + " minfree_abs=" + minfree_abs); } final boolean is64bit = Build.SUPPORTED_64_BIT_ABIS.length > 0; for (int i=0; i<mOomAdj.length; i++) { int low = mOomMinFreeLow[i]; int high = mOomMinFreeHigh[i]; if (is64bit) { // Increase the high min-free levels for cached processes for 64-bit if (i == 4) high = (high*3)/2; else if (i == 5) high = (high*7)/4; } mOomMinFree[i] = (int)(low + ((high-low)*scale)); } if (minfree_abs >= 0) { for (int i=0; i<mOomAdj.length; i++) { mOomMinFree[i] = (int)((float)minfree_abs * mOomMinFree[i] / mOomMinFree[mOomAdj.length - 1]); } } if (minfree_adj != 0) { for (int i=0; i<mOomAdj.length; i++) { mOomMinFree[i] += (int)((float)minfree_adj * mOomMinFree[i] / mOomMinFree[mOomAdj.length - 1]); if (mOomMinFree[i] < 0) { mOomMinFree[i] = 0; } } } // The maximum size we will restore a process from cached to background, when under // memory duress, is 1/3 the size we have reserved for kernel caches and other overhead // before killing background processes. mCachedRestoreLevel = (getMemLevel(ProcessList.CACHED_APP_MAX_ADJ)/1024) / 3; // Ask the kernel to try to keep enough memory free to allocate 3 full // screen 32bpp buffers without entering direct reclaim. int reserve = displayWidth * displayHeight * 4 * 3 / 1024; int reserve_adj = Resources.getSystem().getInteger(com.android.internal.R.integer.config_extraFreeKbytesAdjust); int reserve_abs = Resources.getSystem().getInteger(com.android.internal.R.integer.config_extraFreeKbytesAbsolute); if (reserve_abs >= 0) { reserve = reserve_abs; } if (reserve_adj != 0) { reserve += reserve_adj; if (reserve < 0) { reserve = 0; } } if (write) { ByteBuffer buf = ByteBuffer.allocate(4 * (2*mOomAdj.length + 1)); buf.putInt(LMK_TARGET); for (int i=0; i<mOomAdj.length; i++) { buf.putInt((mOomMinFree[i]*1024)/PAGE_SIZE); buf.putInt(mOomAdj[i]); } writeLmkd(buf); SystemProperties.set("sys.sysctl.extra_free_kbytes", Integer.toString(reserve)); } // GB: 2048,3072,4096,6144,7168,8192 // HC: 8192,10240,12288,14336,16384,20480 }