public static String getProductName() { if (!TextUtils.isEmpty(sProductName)) { return sProductName; } try { sProductName = SystemProperties.get(PROPERTY_PRODUCT_NAME, ""); if (TextUtils.isEmpty(sProductName)) { sProductName = SystemProperties.get("persist.product.letv.name", ""); } } catch (Exception e) { } catch (Error e2) { } if (TextUtils.isEmpty(sProductName)) { if (Build.MODEL.toUpperCase().contains(Build.BRAND.toUpperCase())) { sProductName = Build.MODEL; } else { sProductName = Build.BRAND + " " + Build.MODEL; } } else if (isLetv()) { sProductName = "LETV " + sProductName; } sProductName = sProductName.toUpperCase(); return sProductName; }
private void stopAdbIfNeededSync() { if ("1".equals(SystemProperties.get("service.adb.brevent.close", ""))) { boolean connected = checkPort(); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { SimpleSu.su("pbd=`pidof brevent_daemon`; " + "pbs=`pidof brevent_server`; " + "pin=`pidof installd`; " + "echo $pbd > /acct/uid_0/pid_$pin/tasks; " + "echo $pbd > /acct/uid_0/pid_$pin/cgroup.procs; " + "echo $pbs > /acct/uid_0/pid_$pin/tasks; " + "echo $pbs > /acct/uid_0/pid_$pin/cgroup.procs"); } String command = needStop ? "setprop ctl.stop adbd" : "setprop ctl.restart adbd"; SimpleSu.su("setprop service.adb.tcp.port -1; " + "setprop service.adb.brevent.close 0; " + command); BreventIntentService.sleep(1); if (connected && !checkPort()) { setRootAdb(false); } } }
@Override public void onClick(View v) { boolean isChecked = !v.isSelected(); switch (v.getId()) { case R.id.poweron_recording_switch: SystemProperties.set(Settings.KEY_POWERON_RECORD, isChecked ? "1" : "0"); break; case R.id.watermark_switch: mRecServ.setWatermarkEnable(isChecked); Settings.set(Settings.KEY_WATERMARK_ENABLE, isChecked ? 1 : 0); break; case R.id.flip_switcher: break; } v.setSelected(isChecked); }
@Override public void onDestroy() { Log.d(TAG, "onDestroy"); // unbind record service unbindService(mRecServiceConn); // stop record service Intent i = new Intent(CameraActivity.this, RecordService.class); stopService(i); // remove all messages mHandler.removeMessages(0); SystemProperties.set("sys.dvr.run.state", "0"); super.onDestroy(); }
@Override public void onResume() { super.onResume(); updateButtonsState(); updateImpactLockView(); if (mRecServ != null) { mRecServ.onResume(); } showUIControls(true ); showUIControls(false); SystemProperties.set("sys.dvr.run.state", "3"); }
/** * 打开MIUI权限管理界面(MIUI v5, v6) * @param context */ public static void openMiuiPermissionActivity(Context context) { Intent intent = new Intent("miui.intent.action.APP_PERM_EDITOR"); String rom = SystemProperties.get("ro.miui.ui.version.name", "unkonw"); if ("V5".equals(rom)) { openAppDetailActivity(context, context.getPackageName()); } else if ("V6".equals(rom)) { intent.setClassName("com.miui.securitycenter", "com.miui.permcenter.permissions.AppPermissionsEditorActivity"); intent.putExtra("extra_pkgname", context.getPackageName()); } if (isIntentAvailable(context, intent)) { if (context instanceof Activity) { Activity a = (Activity) context; a.startActivityForResult(intent, 2); } } else { } }
private void publishFirmwareBuildDate() { String buildDate; JSONObject result = new JSONObject(); buildDate = SystemProperties.get(BUILD_DATE_UTC_PROPERTY); try { result.put("buildDate", buildDate); CommonUtils.sendBroadcast(context, Constants.Operation.GET_FIRMWARE_BUILD_DATE, Constants.Code.SUCCESS, Constants.Status.SUCCESSFUL, result.toString()); } catch (JSONException e) { String error = "Failed to create JSON object when publishing OTA progress."; Log.e(TAG, error, e); CommonUtils.sendBroadcast(context, Constants.Operation.GET_FIRMWARE_BUILD_DATE, Constants.Code.FAILURE, Constants.Status.INTERNAL_ERROR, String.valueOf(DEFAULT_STATE_INFO_CODE)); } }
/** * Compares device firmware version with the latest upgrade file from the server. * * @return - Returns true if the firmware needs to be upgraded. */ 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; }
private Context createBaseContextForActivity(ActivityClientRecord r, final Activity activity) { ContextImpl appContext = new ContextImpl(); appContext.init(r.packageInfo, r.token, this); appContext.setOuterContext(activity); // For debugging purposes, if the activity's package name contains the value of // the "debug.use-second-display" system property as a substring, then show // its content on a secondary display if there is one. Context baseContext = appContext; String pkgName = SystemProperties.get("debug.second-display.pkg"); if (pkgName != null && !pkgName.isEmpty() && r.packageInfo.mPackageName.contains(pkgName)) { DisplayManagerGlobal dm = DisplayManagerGlobal.getInstance(); for (int displayId : dm.getDisplayIds()) { if (displayId != Display.DEFAULT_DISPLAY) { Display display = dm.getRealDisplay(displayId, r.token); baseContext = appContext.createDisplayContext(display); break; } } } return baseContext; }
@Override public boolean dispatchKeyEvent(KeyEvent event) { if (event.getAction() == KeyEvent.ACTION_DOWN) { switch (event.getKeyCode()) { case KeyEvent.KEYCODE_HOME: return true; case KeyEvent.KEYCODE_VOLUME_DOWN: if (SystemProperties.getInt("debug.launcher2.dumpstate", 0) != 0) { dumpState(); return true; } break; } } else if (event.getAction() == KeyEvent.ACTION_UP) { switch (event.getKeyCode()) { case KeyEvent.KEYCODE_HOME: return true; } } return super.dispatchKeyEvent(event); }
public static String getProductVariant() { String result = ""; try { result = SystemProperties.get(PROPERTY_PRODUCT_VARIANT, null).toUpperCase(); } catch (Exception e) { } catch (Error e2) { } return result; }
public static boolean isYunOS() { String hw = ""; try { hw = SystemProperties.get("ro.yunos.hardware", null).toLowerCase(); } catch (Exception e) { } catch (Error e2) { } return !TextUtils.isEmpty(hw) && hw.equals("yunos"); }
public static int getAdbPort() { // XXX: SystemProperties.get is @hide method String port = SystemProperties.get("service.adb.tcp.port", ""); UILog.i("service.adb.tcp.port: " + port); if (!TextUtils.isEmpty(port) && TextUtils.isDigitsOnly(port)) { int p = Integer.parseInt(port); if (p > 0 && p <= 0xffff) { return p; } } return -1; }
@Override public int getActualState(Context context) { try { return working ? STATE_INTERMEDIATE : ("5555".equals(SystemProperties.get("service.adb.tcp.port")) ? STATE_ENABLED : STATE_DISABLED); } catch (Throwable e) { Debug.log(e); return STATE_DISABLED; } }
@Override public void onPause() { super.onPause(); if (mRecServ != null) { mRecServ.onPause(); } SystemProperties.set("sys.dvr.run.state", "2"); }
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)); }
public static boolean isMiuiV5() { boolean result = false; String ver = SystemProperties.get("ro.miui.ui.version.name", "unkonw"); if (ver.equals("V5") || ver.equals("V6")) { if (hasAddWindowManager()) { result = true; } } return result; }
public static void openMiuiAutostartActivity(Context context) { Intent intent = new Intent(); String rom = SystemProperties.get("ro.miui.ui.version.name", "unkonw"); if("V5".equals(rom)) { // TODO 王天成自启动管理界面 V5 } else if("V6".equals(rom)) { intent.setClassName("com.miui.permcenter", "com.miui.permcenter.autostart.AutoStartManagementActivity"); if(isIntentAvailable(context, intent)) { context.startActivity(intent); } } }
private void removeNotification(int startId) { Log.d(TAG, "removeNotification, startId=" + startId); for (TxnRequest req : txnRequestsMap ) { if (req.serviceId == startId) { if (req.requestedSubId == -1) { Log.d(TAG, "Notification cleanup not required since subId is -1"); return; } if (req.anyRequestFailed ==1) { // dont remove notification. Log.d(TAG, "Some transaction failed for this sub, notification not cleared."); } else { // remove notification String ns = Context.NOTIFICATION_SERVICE; NotificationManager mNotificationManager = (NotificationManager) getApplicationContext().getSystemService(ns); mNotificationManager.cancel(req.requestedSubId); boolean isSilent = true; //default, silent enabled. if ("prompt".equals( SystemProperties.get(TelephonyProperties.PROPERTY_MMS_TRANSACTION))) { isSilent = false; } if (isSilent) { int nextSub = (req.requestedSubId ==1) ?0:1; Log.d(TAG, "MMS silent transaction finished for sub="+nextSub); Intent silentIntent = new Intent(getApplicationContext(), edu.bupt.mms.ui.SelectMmsSubscription.class); silentIntent.putExtra(Mms.SUB_ID, nextSub); silentIntent.putExtra("TRIGGER_SWITCH_ONLY", 1); getApplicationContext().startService(silentIntent); } } } } }
static boolean isRoaming() { // TODO: fix and put in Telephony layer String roaming = SystemProperties.get( TelephonyProperties.PROPERTY_OPERATOR_ISROAMING, null); if (LOCAL_LOGV) { Log.v(TAG, "roaming ------> " + roaming); } return "true".equals(roaming); }
@Override public boolean dispatchKeyEvent(KeyEvent event) { if (event.getAction() == KeyEvent.ACTION_DOWN) { switch (event.getKeyCode()) { case KeyEvent.KEYCODE_HOME: if (mThumbnailWorkspace.isVisible()) { mThumbnailWorkspace.setmCurSelectedScreenIndex(mWorkspace.getDefaultScreen()); closeThumbnailWorkspace(true); return true; } closeFolder(); return true; case KeyEvent.KEYCODE_VOLUME_DOWN: if (SystemProperties.getInt("debug.launcher2.dumpstate", 0) != 0) { dumpState(); return true; } break; default: break; } } else if (event.getAction() == KeyEvent.ACTION_UP) { switch (event.getKeyCode()) { case KeyEvent.KEYCODE_HOME: return true; default: break; } } return super.dispatchKeyEvent(event); }
final void performStart() { mActivityTransitionState.setEnterActivityOptions(this, getActivityOptions()); mFragments.noteStateNotSaved(); mCalled = false; mFragments.execPendingActions(); mInstrumentation.callActivityOnStart(this); if (!mCalled) { throw new SuperNotCalledException( "Activity " + mComponent.toShortString() + " did not call through to super.onStart()"); } mFragments.dispatchStart(); mFragments.reportLoaderStart(); // This property is set for all builds except final release boolean isDlwarningEnabled = SystemProperties.getInt("ro.bionic.ld.warning", 0) == 1; boolean isAppDebuggable = (mApplication.getApplicationInfo().flags & ApplicationInfo.FLAG_DEBUGGABLE) != 0; if (isAppDebuggable || isDlwarningEnabled) { String dlwarning = getDlWarning(); if (dlwarning != null) { String appName = getApplicationInfo().loadLabel(getPackageManager()) .toString(); String warning = "Detected problems with app native libraries\n" + "(please consult log for detail):\n" + dlwarning; if (isAppDebuggable) { new AlertDialog.Builder(this). setTitle(appName). setMessage(warning). setPositiveButton(android.R.string.ok, null). setCancelable(false). show(); } else { Toast.makeText(this, appName + "\n" + warning, Toast.LENGTH_LONG).show(); } } } mActivityTransitionState.enterReady(this); }
public static String getLetvRomVersion() { return SystemProperties.get(PROPERTY_RELEASE_VERSION, ""); }
static boolean isEmulator() { return "1".equals(SystemProperties.get("ro.kernel.qemu", Build.UNKNOWN)); }
static boolean isAdbRunning() { return "running".equals(SystemProperties.get("init.svc.adbd", Build.UNKNOWN)); }
public static boolean isMIUI() { return !SystemProperties.get("ro.miui.ui.version.name", "").equals(""); }