下面列出了android.telephony.CarrierConfigManager#android.os.SystemProperties 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
private static ApplicationInfo maybeAdjustApplicationInfo(ApplicationInfo info) {
// If we're dealing with a multi-arch application that has both
// 32 and 64 bit shared libraries, we might need to choose the secondary
// depending on what the current runtime's instruction set is.
if (info.primaryCpuAbi != null && info.secondaryCpuAbi != null) {
final String runtimeIsa = VMRuntime.getRuntime().vmInstructionSet();
// Get the instruction set that the libraries of secondary Abi is supported.
// In presence of a native bridge this might be different than the one secondary Abi used.
String secondaryIsa = VMRuntime.getInstructionSet(info.secondaryCpuAbi);
final String secondaryDexCodeIsa = SystemProperties.get("ro.dalvik.vm.isa." + secondaryIsa);
secondaryIsa = secondaryDexCodeIsa.isEmpty() ? secondaryIsa : secondaryDexCodeIsa;
// If the runtimeIsa is the same as the primary isa, then we do nothing.
// Everything will be set up correctly because info.nativeLibraryDir will
// correspond to the right ISA.
if (runtimeIsa.equals(secondaryIsa)) {
ApplicationInfo modified = new ApplicationInfo(info);
modified.nativeLibraryDir = info.secondaryNativeLibraryDir;
return modified;
}
}
return info;
}
/**
* Reserve space for the native library to be loaded into.
*/
static void reserveAddressSpaceInZygote() {
System.loadLibrary("webviewchromium_loader");
long addressSpaceToReserve =
SystemProperties.getLong(WebViewFactory.CHROMIUM_WEBVIEW_VMSIZE_SIZE_PROPERTY,
CHROMIUM_WEBVIEW_DEFAULT_VMSIZE_BYTES);
sAddressSpaceReserved = nativeReserveAddressSpace(addressSpaceToReserve);
if (sAddressSpaceReserved) {
if (DEBUG) {
Log.v(LOGTAG, "address space reserved: " + addressSpaceToReserve + " bytes");
}
} else {
Log.e(LOGTAG, "reserving " + addressSpaceToReserve + " bytes of address space failed");
}
}
private static void maybeAdjustApplicationInfo(ApplicationInfo info) {
// If we're dealing with a multi-arch application that has both
// 32 and 64 bit shared libraries, we might need to choose the secondary
// depending on what the current runtime's instruction set is.
if (info.primaryCpuAbi != null && info.secondaryCpuAbi != null) {
final String runtimeIsa = VMRuntime.getRuntime().vmInstructionSet();
// Get the instruction set that the libraries of secondary Abi is supported.
// In presence of a native bridge this might be different than the one secondary Abi used.
String secondaryIsa = VMRuntime.getInstructionSet(info.secondaryCpuAbi);
final String secondaryDexCodeIsa = SystemProperties.get("ro.dalvik.vm.isa." + secondaryIsa);
secondaryIsa = secondaryDexCodeIsa.isEmpty() ? secondaryIsa : secondaryDexCodeIsa;
// If the runtimeIsa is the same as the primary isa, then we do nothing.
// Everything will be set up correctly because info.nativeLibraryDir will
// correspond to the right ISA.
if (runtimeIsa.equals(secondaryIsa)) {
info.nativeLibraryDir = info.secondaryNativeLibraryDir;
}
}
}
private static ApplicationInfo maybeAdjustApplicationInfo(ApplicationInfo info) {
// If we're dealing with a multi-arch application that has both
// 32 and 64 bit shared libraries, we might need to choose the secondary
// depending on what the current runtime's instruction set is.
if (info.primaryCpuAbi != null && info.secondaryCpuAbi != null) {
final String runtimeIsa = VMRuntime.getRuntime().vmInstructionSet();
// Get the instruction set that the libraries of secondary Abi is supported.
// In presence of a native bridge this might be different than the one secondary Abi used.
String secondaryIsa = VMRuntime.getInstructionSet(info.secondaryCpuAbi);
final String secondaryDexCodeIsa = SystemProperties.get("ro.dalvik.vm.isa." + secondaryIsa);
secondaryIsa = secondaryDexCodeIsa.isEmpty() ? secondaryIsa : secondaryDexCodeIsa;
// If the runtimeIsa is the same as the primary isa, then we do nothing.
// Everything will be set up correctly because info.nativeLibraryDir will
// correspond to the right ISA.
if (runtimeIsa.equals(secondaryIsa)) {
ApplicationInfo modified = new ApplicationInfo(info);
modified.nativeLibraryDir = info.secondaryNativeLibraryDir;
return modified;
}
}
return info;
}
@Override
public void onBootPhase(int phase) {
if (phase == SystemService.PHASE_THIRD_PARTY_APPS_CAN_START) {
if (Build.IS_DEBUGGABLE) {
SystemProperties.addChangeCallback(mSystemPropertiesChanged);
}
mContext.registerReceiver(new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
writePulseGestureEnabled();
synchronized (mLock) {
stopDreamLocked(false /*immediate*/);
}
}
}, new IntentFilter(Intent.ACTION_USER_SWITCHED), null, mHandler);
mContext.getContentResolver().registerContentObserver(
Settings.Secure.getUriFor(Settings.Secure.DOZE_PULSE_ON_DOUBLE_TAP), false,
mDozeEnabledObserver, UserHandle.USER_ALL);
writePulseGestureEnabled();
}
}
private static ApplicationInfo maybeAdjustApplicationInfo(ApplicationInfo info) {
// If we're dealing with a multi-arch application that has both
// 32 and 64 bit shared libraries, we might need to choose the secondary
// depending on what the current runtime's instruction set is.
if (info.primaryCpuAbi != null && info.secondaryCpuAbi != null) {
final String runtimeIsa = VMRuntime.getRuntime().vmInstructionSet();
// Get the instruction set that the libraries of secondary Abi is supported.
// In presence of a native bridge this might be different than the one secondary Abi used.
String secondaryIsa = VMRuntime.getInstructionSet(info.secondaryCpuAbi);
final String secondaryDexCodeIsa = SystemProperties.get("ro.dalvik.vm.isa." + secondaryIsa);
secondaryIsa = secondaryDexCodeIsa.isEmpty() ? secondaryIsa : secondaryDexCodeIsa;
// If the runtimeIsa is the same as the primary isa, then we do nothing.
// Everything will be set up correctly because info.nativeLibraryDir will
// correspond to the right ISA.
if (runtimeIsa.equals(secondaryIsa)) {
ApplicationInfo modified = new ApplicationInfo(info);
modified.nativeLibraryDir = info.secondaryNativeLibraryDir;
return modified;
}
}
return info;
}
private static ApplicationInfo maybeAdjustApplicationInfo(ApplicationInfo info) {
// If we're dealing with a multi-arch application that has both
// 32 and 64 bit shared libraries, we might need to choose the secondary
// depending on what the current runtime's instruction set is.
if (info.primaryCpuAbi != null && info.secondaryCpuAbi != null) {
final String runtimeIsa = VMRuntime.getRuntime().vmInstructionSet();
// Get the instruction set that the libraries of secondary Abi is supported.
// In presence of a native bridge this might be different than the one secondary Abi used.
String secondaryIsa = VMRuntime.getInstructionSet(info.secondaryCpuAbi);
final String secondaryDexCodeIsa = SystemProperties.get("ro.dalvik.vm.isa." + secondaryIsa);
secondaryIsa = secondaryDexCodeIsa.isEmpty() ? secondaryIsa : secondaryDexCodeIsa;
// If the runtimeIsa is the same as the primary isa, then we do nothing.
// Everything will be set up correctly because info.nativeLibraryDir will
// correspond to the right ISA.
if (runtimeIsa.equals(secondaryIsa)) {
ApplicationInfo modified = new ApplicationInfo(info);
modified.nativeLibraryDir = info.secondaryNativeLibraryDir;
return modified;
}
}
return info;
}
/**
* 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();
}
}
}
@TargetApi(M)
@Override
public void safeMode() {
preliminaryPreparation("safeMode");
injectSystemThread(() -> {
if (SDK_INT < N) {
//ShutdownThread.java
// Indicates whether we are rebooting into safe mode
//public static final String REBOOT_SAFEMODE_PROPERTY = "persist.sys.safemode";
SystemProperties.set("persist.sys.safemode", "1");
mPowerManager.reboot(null);
return;
}
invokeNoThrowAndReturn(rebootSafeMode, mPowerManager);
});
}
public ProcessStatsService(ActivityManagerService am, File file) {
mAm = am;
mBaseDir = file;
mBaseDir.mkdirs();
mProcessStats = new ProcessStats(true);
updateFile();
SystemProperties.addChangeCallback(new Runnable() {
@Override public void run() {
synchronized (mAm) {
if (mProcessStats.evaluateSystemProperties(false)) {
mProcessStats.mFlags |= ProcessStats.FLAG_SYSPROPS;
writeStateLocked(true, true);
mProcessStats.evaluateSystemProperties(true);
}
}
}
});
}
private void determineVerifiedBootState(View v) {
try {
String propSystemVerified = SystemProperties.get("partition.system.verified", "0");
String propState = SystemProperties.get("ro.boot.verifiedbootstate", "");
File fileDmVerityModule = new File("/sys/module/dm_verity");
boolean verified = !propSystemVerified.equals("0");
boolean detected = !propState.isEmpty() || fileDmVerityModule.exists();
TextView tv = v.findViewById(R.id.dmverity);
if (verified) {
tv.setText(R.string.verified_boot_active);
tv.setTextColor(getResources().getColor(R.color.warning, null));
} else if (detected) {
tv.setText(R.string.verified_boot_deactivated);
v.findViewById(R.id.dmverity_explanation).setVisibility(View.GONE);
} else {
tv.setText(R.string.verified_boot_none);
tv.setTextColor(getResources().getColor(R.color.warning, null));
v.findViewById(R.id.dmverity_explanation).setVisibility(View.GONE);
}
} catch (Exception e) {
Log.e(TAG, "Could not detect Verified Boot state", e);
}
}
private Choreographer(Looper looper, int vsyncSource) {
mLooper = looper;
mHandler = new FrameHandler(looper);
mDisplayEventReceiver = USE_VSYNC
? new FrameDisplayEventReceiver(looper, vsyncSource)
: null;
mLastFrameTimeNanos = Long.MIN_VALUE;
mFrameIntervalNanos = (long)(1000000000 / getRefreshRate());
mCallbackQueues = new CallbackQueue[CALLBACK_LAST + 1];
for (int i = 0; i <= CALLBACK_LAST; i++) {
mCallbackQueues[i] = new CallbackQueue();
}
// b/68769804: For low FPS experiments.
setFPSDivisor(SystemProperties.getInt(ThreadedRenderer.DEBUG_FPS_DIVISOR, 1));
}
/**
* Indicates whether threaded rendering is available under any form for
* the view hierarchy.
*
* @return True if the view hierarchy can potentially be defer rendered,
* false otherwise
*/
public static boolean isAvailable() {
if (sSupportsOpenGL != null) {
return sSupportsOpenGL.booleanValue();
}
if (SystemProperties.getInt("ro.kernel.qemu", 0) == 0) {
// Device is not an emulator.
sSupportsOpenGL = true;
return true;
}
int qemu_gles = SystemProperties.getInt("qemu.gles", -1);
if (qemu_gles == -1) {
// In this case, the value of the qemu.gles property is not ready
// because the SurfaceFlinger service may not start at this point.
return false;
}
// In the emulator this property will be set > 0 when OpenGL ES 2.0 is
// enabled, 0 otherwise. On old emulator versions it will be undefined.
sSupportsOpenGL = qemu_gles > 0;
return sSupportsOpenGL.booleanValue();
}
private boolean isBuggy() {
// STOPSHIP: fix buggy apps
if (SystemProperties.getBoolean("fw.ignore_buggy", false)) return false;
if ("com.google.android.tts".equals(getApplicationInfo().packageName)) return true;
if ("com.breel.geswallpapers".equals(getApplicationInfo().packageName)) return true;
return false;
}
private SyncManager getSyncManager() {
if (SystemProperties.getBoolean("config.disable_network", false)) {
return null;
}
synchronized(mSyncManagerLock) {
try {
// Try to create the SyncManager, return null if it fails (e.g. the disk is full).
if (mSyncManager == null) mSyncManager = new SyncManager(mContext, mFactoryTest);
} catch (SQLiteException e) {
Log.e(TAG, "Can't create SyncManager", e);
}
return mSyncManager;
}
}
public static String getProductVariant() {
String result = "";
try {
result = SystemProperties.get(PROPERTY_PRODUCT_VARIANT, null).toUpperCase();
} catch (Exception e) {
} catch (Error e2) {
}
return result;
}
private void setupJitProfileSupport() {
if (!SystemProperties.getBoolean("dalvik.vm.usejitprofiles", false)) {
return;
}
// Only set up profile support if the loaded apk has the same uid as the
// current process.
// Currently, we do not support profiling across different apps.
// (e.g. application's uid might be different when the code is
// loaded by another app via createApplicationContext)
if (mApplicationInfo.uid != Process.myUid()) {
return;
}
final List<String> codePaths = new ArrayList<>();
if ((mApplicationInfo.flags & ApplicationInfo.FLAG_HAS_CODE) != 0) {
codePaths.add(mApplicationInfo.sourceDir);
}
if (mApplicationInfo.splitSourceDirs != null) {
Collections.addAll(codePaths, mApplicationInfo.splitSourceDirs);
}
if (codePaths.isEmpty()) {
// If there are no code paths there's no need to setup a profile file and register with
// the runtime,
return;
}
final File profileFile = getPrimaryProfileFile(mPackageName);
VMRuntime.registerAppInfo(profileFile.getPath(),
codePaths.toArray(new String[codePaths.size()]));
// Register the app data directory with the reporter. It will
// help deciding whether or not a dex file is the primary apk or a
// secondary dex.
DexLoadReporter.getInstance().registerAppDataDir(mPackageName, mDataDir);
}
/** @hide */
static public int staticGetMemoryClass() {
// Really brain dead right now -- just take this from the configured
// vm heap size, and assume it is in megabytes and thus ends with "m".
String vmHeapSize = SystemProperties.get("dalvik.vm.heapgrowthlimit", "");
if (vmHeapSize != null && !"".equals(vmHeapSize)) {
return Integer.parseInt(vmHeapSize.substring(0, vmHeapSize.length()-1));
}
return staticGetLargeMemoryClass();
}
public SystemServer() {
// Check for factory test mode.
mFactoryTestMode = FactoryTest.getMode();
// Remember if it's runtime restart(when sys.boot_completed is already set) or reboot
mRuntimeRestart = "1".equals(SystemProperties.get("sys.boot_completed"));
mRuntimeStartElapsedTime = SystemClock.elapsedRealtime();
mRuntimeStartUptime = SystemClock.uptimeMillis();
}
/**
* Applies invoke-with system properties to the zygote arguments.
*
* @param args non-null; zygote args
*/
public static void applyInvokeWithSystemProperty(Arguments args) {
if (args.invokeWith == null && args.niceName != null) {
String property = "wrap." + args.niceName;
args.invokeWith = SystemProperties.get(property);
if (args.invokeWith != null && args.invokeWith.length() == 0) {
args.invokeWith = null;
}
}
}
private void registerWifiDisplayAdapterLocked() {
if (mContext.getResources().getBoolean(
com.android.internal.R.bool.config_enableWifiDisplay)
|| SystemProperties.getInt(FORCE_WIFI_DISPLAY_ENABLE, -1) == 1) {
mWifiDisplayAdapter = new WifiDisplayAdapter(
mSyncRoot, mContext, mHandler, mDisplayAdapterListener,
mPersistentDataStore);
registerDisplayAdapterLocked(mWifiDisplayAdapter);
}
}
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));
}
/**
* Gets the default page size to use when creating a database.
*/
public static int getDefaultPageSize() {
synchronized (sLock) {
if (sDefaultPageSize == 0) {
// If there is an issue accessing /data, something is so seriously
// wrong that we just let the IllegalArgumentException propagate.
sDefaultPageSize = new StatFs("/data").getBlockSize();
}
return SystemProperties.getInt("debug.sqlite.pagesize", sDefaultPageSize);
}
}
/**
* Set the window manager for use by this Window to, for example,
* display panels. This is <em>not</em> used for displaying the
* Window itself -- that must be done by the client.
*
* @param wm The window manager for adding new windows.
*/
public void setWindowManager(WindowManager wm, IBinder appToken, String appName,
boolean hardwareAccelerated) {
mAppToken = appToken;
mAppName = appName;
mHardwareAccelerated = hardwareAccelerated
|| SystemProperties.getBoolean(PROPERTY_HARDWARE_UI, false);
if (wm == null) {
wm = (WindowManager)mContext.getSystemService(Context.WINDOW_SERVICE);
}
mWindowManager = ((WindowManagerImpl)wm).createLocalWindowManager(this);
}
/**
* When opening a database, if the WAL file is larger than this size, we'll truncate it.
*
* (If it's 0, we do not truncate.)
*
* @hide
*/
public static long getWALTruncateSize() {
final long setting = SQLiteCompatibilityWalFlags.getTruncateSize();
if (setting >= 0) {
return setting;
}
return SystemProperties.getInt("debug.sqlite.wal.truncatesize",
Resources.getSystem().getInteger(
com.android.internal.R.integer.db_wal_truncate_size));
}
/**
* Factory reset bluetooth settings.
*
* <p>Requires the {@link android.Manifest.permission#BLUETOOTH_PRIVILEGED}
* permission
*
* @return true to indicate that the config file was successfully cleared
* @hide
*/
public boolean factoryReset() {
try {
mServiceLock.readLock().lock();
if (mService != null) {
return mService.factoryReset();
}
SystemProperties.set("persist.bluetooth.factoryreset", "true");
} catch (RemoteException e) {
Log.e(TAG, "", e);
} finally {
mServiceLock.readLock().unlock();
}
return false;
}
private static int getDeviceDensity() {
// qemu.sf.lcd_density can be used to override ro.sf.lcd_density
// when running in the emulator, allowing for dynamic configurations.
// The reason for this is that ro.sf.lcd_density is write-once and is
// set by the init process when it parses build.prop before anything else.
return SystemProperties.getInt("qemu.sf.lcd_density",
SystemProperties.getInt("ro.sf.lcd_density", DENSITY_DEFAULT));
}
@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);
}
/**
* Gets the WAL auto-checkpoint integer in database pages.
*/
public static int getWALAutoCheckpoint() {
int value = SystemProperties.getInt("debug.sqlite.wal.autocheckpoint",
Resources.getSystem().getInteger(
com.android.internal.R.integer.db_wal_autocheckpoint));
return Math.max(1, value);
}
void setTimeZoneImpl(String tz) {
if (TextUtils.isEmpty(tz)) {
return;
}
TimeZone zone = TimeZone.getTimeZone(tz);
// Prevent reentrant calls from stepping on each other when writing
// the time zone property
boolean timeZoneWasChanged = false;
synchronized (this) {
String current = SystemProperties.get(TIMEZONE_PROPERTY);
if (current == null || !current.equals(zone.getID())) {
if (localLOGV) {
Slog.v(TAG, "timezone changed: " + current + ", new=" + zone.getID());
}
timeZoneWasChanged = true;
SystemProperties.set(TIMEZONE_PROPERTY, zone.getID());
}
// Update the kernel timezone information
// Kernel tracks time offsets as 'minutes west of GMT'
int gmtOffset = zone.getOffset(System.currentTimeMillis());
setKernelTimezone(mNativeData, -(gmtOffset / 60000));
}
TimeZone.setDefault(null);
if (timeZoneWasChanged) {
Intent intent = new Intent(Intent.ACTION_TIMEZONE_CHANGED);
intent.addFlags(Intent.FLAG_RECEIVER_REPLACE_PENDING
| Intent.FLAG_RECEIVER_INCLUDE_BACKGROUND
| Intent.FLAG_RECEIVER_VISIBLE_TO_INSTANT_APPS);
intent.putExtra("time-zone", zone.getID());
getContext().sendBroadcastAsUser(intent, UserHandle.ALL);
}
}