1、通过裁剪应用的方式进行内存优化的一般方案
[ANSWER] 开机后静置10min,通过命令行命令: adb shell dumpsys meminfo > meminfo.txt 抓取当前内存信息,查看Total PSS by OOM adjustment列,对不需要的应用进行裁剪
2、为什么有些版本不显示紧急电话通话记录
[ANSWER] 现在的紧急电话通话记录是否显示是随版本(运营商)控制的。 1.所有版本都需要显示紧急电话通话记录 /packages/services/Telecomm/res/values/config.xml true 2.某个或多个运营商需要显示,而其他不显示 在/vendor/sprd/carriers下选择运营商,比如claro需要显示,则添加 /vendor/sprd/carriers/claro/overlays/packages/services/Telecomm/res/values/ true /packages/services/Telecomm/res/values/config.xml false
3、如何在某个Activity中屏蔽状态栏与导航键
[ANSWER] 1.在某个Activity界面禁止下拉状态栏: //获取StatusBarManager StatusBarManager mStatusBarManager = (StatusBarManager) mContext.getSystemService(Context.STATUS_BAR_SERVICE); //禁止下拉状态栏 mStatusBarManager.disable(StatusBarManager.DISABLE_EXPAND); //退出时解除禁止 mStatusBarManager.disable(StatusBarManager.DISABLE_NONE); 2.在某个Activity界面禁用某个导航键: 可以通过如下flag分别屏蔽导航栏Back/Home/Recent键,屏蔽方式与上面一致。StatusBarManager.DISABLE_BACK/StatusBarManager.DISABLE_HOME/StatusBarManager.DISABLE_RECENT
4、如何配置高温关机默认值?
[ANSWER] 平台上层有高温关机,没有低温关机,在下面配置,默认68度关机 /frameworks/base/core/res/res/values/config.xml
680
5、在Launcher主界面上,长按指定应用的shortcut以后,可以拖动,但是上方的移除按钮不显示
[ANSWER] 定位到src/com/android/launcher3/ButtonDropTarget.java中
public void onDragStart(DropTarget.DragObject dragObject, DragOptions options) {
+ if("com.android.xxx".equals(dragObject.dragInfo.getTargetComponent().getPackageName()))
+ {
+ setVisibility(View.GONE);
+ }
+ else
+ {
mActive = supportsDrop(dragObject.dragInfo);
mDrawable.setColorFilter(null);
if (mCurrentColorAnim != null) {
mCurrentColorAnim.cancel();
mCurrentColorAnim = null;
}
setTextColor(mOriginalTextColor);
setVisibility(mActive ? View.VISIBLE : View.GONE);
mAccessibleDrag = options.isAccessibleDrag;
setOnClickListener(mAccessibleDrag ? this : null);
+ }
}
6、如何通过adb获取imei
[ANSWER] Android11: adb shell service call iphonesubinfo 1
Android12: (a)userdebug 需要执行adb root adb shell service call iphonesubinfo 4 i32 0 s16 com.android.phone null
(b)user版本用shell adb shell service call iphonesubinfo 4 i32 2 s16 shell null
Android 13 adb shell service call iphonesubinfo 4 i32 1 s16 shell
7、Android10平台如何修改支持多应用同时录音
[ANSWER] 在AudioPolicyService::isVirtualSource中增加对应的audio source。 例如:假设应用层申请的音源类型为MediaRecorder.AudioSource.MIC,在AudioPolicyService::isVirtualSource中增加对应的audio source:
frameworks\av\services\audiopolicy\service\AudioPolicyService.cpp
bool AudioPolicyService::isVirtualSource(audio_source_t source)
{
switch (source) {
case AUDIO_SOURCE_VOICE_UPLINK:
case AUDIO_SOURCE_VOICE_DOWNLINK:
case AUDIO_SOURCE_VOICE_CALL:
case AUDIO_SOURCE_REMOTE_SUBMIX:
case AUDIO_SOURCE_FM_TUNER:
+++ case AUDIO_SOURCE_MIC:
return true;
default:
break;
}
return false;
}
8、展讯如何实现插USB上电自动开机
[ANSWER] 在u-boot15\common\cmd_cboot.c
boot_mode_enum_type get_mode_from_charger(void中
if (charger_connected()) {
debugf("get mode from charger\n");
return CMD_CHARGE_MODE;
} else {
return CMD_UNDEFINED_MODE;
}
9、后台录音app如何录制通话过程中的音频
[ANSWER] 1、如果应用需要通话录音,需要申请 android.permission.CAPTURE_AUDIO_OUTPUT 权限,且UID改成 “android.uid.system”,即只能是系统应用。
2、如果录音应用为第三方应用,无法修改应用代码,可在FW层做修改,参考代码如下:
/frameworks/av/services/audiopolicy/service/AudioPolicyService.cpp文件
@@ -385,6 +386,13 @@ status_t AudioPolicyService::getInputForAttr(const audio_attributes_t *attr,
}
bool canCaptureOutput = captureAudioOutputAllowed(opPackageName,pid, uid);
+
+ if(!strcmp("应用包名",String8(opPackageName).c_str())){
+ ALOGI("%s, set canCaptureOutput=true, opPackageName=%s",
+ __func__, String8(opPackageName).c_str());
+ canCaptureOutput = true;
+ }
+
if ((attr->source == AUDIO_SOURCE_VOICE_UPLINK ||
attr->source == AUDIO_SOURCE_VOICE_DOWNLINK ||
attr->source == AUDIO_SOURCE_VOICE_CALL ||
10、android13中锁屏界面充电信息显示逻辑?
[ANSWER] 平台支持在锁屏界面针对不同充电速度显示不同的充电提示语,快充、慢充对应的充电功率在相关配置文件中配置。相关代码逻辑如下:
根据充电速度mChargingSpeed显示对应提示语
SystemUI/src/com/android/systemui/statusbar/KeyguardIndicationController.java
protected String computePowerIndication() {
...
switch (mChargingSpeed) {
case BatteryStatus.CHARGING_FAST:
chargingId = hasChargingTime
? R.string.keyguard_indication_charging_time_fast
: R.string.keyguard_plugged_in_charging_fast;
break;
case BatteryStatus.CHARGING_SLOWLY:
chargingId = hasChargingTime
? R.string.keyguard_indication_charging_time_slowly
: R.string.keyguard_plugged_in_charging_slowly;
break;
default:
chargingId = hasChargingTime
? R.string.keyguard_indication_charging_time
: R.string.keyguard_plugged_in;
break;
}
判断充电速度:快充、慢充、常规充电 frameworks/base/packages/SettingsLib/src/com/android/settingslib/fuelgauge/BatteryStatus.java
public final int getChargingSpeed(Context context) {
final int slowThreshold = context.getResources().getInteger(
R.integer.config_chargingSlowlyThreshold);
final int fastThreshold = context.getResources().getInteger(
R.integer.config_chargingFastThreshold);
return maxChargingWattage <= 0 ? CHARGING_UNKNOWN :
maxChargingWattage < slowThreshold ? CHARGING_SLOWLY :
maxChargingWattage > fastThreshold ? CHARGING_FAST :
CHARGING_REGULAR;
}
配置文件中小于5w是慢充,大于15w是快充
<!-- These resources are around just to allow their values to be customized -->
<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
<!-- Threshold in micro watts below which a charger is rated as "slow"; 1A @ 5V -->
<integer name="config_chargingSlowlyThreshold">5000000</integer>
<!-- Threshold in micro watts above which a charger is rated as "fast"; 3A @ 5V -->
<!-- UNISOC: modify for Bug1838475 Modify the fast charge threshold -->
<integer name="config_chargingFastThreshold">15000000</integer>
11、Android 12 pull /data/system/下的文件是乱码
[ANSWER] Android12的/data/system/XXXX.xml被默认设置二进制xml格式,直接打开是乱码。 可以通过修改配置将其改为普通的xml格式 adb shell setprop persist.sys.binary_xml false 重启手机,再获取XXXX.xml,就是普通xml格式了
|