AndroidO,AndroidP SystemUI问题修改笔记
- 修改NavigationBar ‘back’ 触控范围
SystemUI/src/com/android/systemui/statusbar/phone/NearestTouchFrame.java
@VisibleForTesting
NearestTouchFrame(Context context, AttributeSet attrs, Configuration c) {
super(context, attrs);
//mIsActive = c.smallestScreenWidthDp < 600;
mIsActive = false
}
- 修改阿拉伯语布局NavigationBar顺序
只需要修改config.xml中如下值的顺序即可(ps:图片需要单独修改)
<string name="config_navBarLayout" translatable="false">left,recent;home;back,right</string>
- back按键的处理在onBackPressed()方法中
SystemUI/src/com/android/systemui/statusbar/phone/StatusBarKeyguardViewManager.java
/**
* Notifies this manager that the back button has been pressed.
*
* @param hideImmediately Hide bouncer when {@code true}, keep it around otherwise.
* Non-scrimmed bouncers have a special animation tied to the expansion
* of the notification panel.
* @return whether the back press has been handled
*/
public boolean onBackPressed(boolean hideImmediately) {
Log.d(TAG, "onBackPressed()");
if (mBouncer.isShowing()) {
mStatusBar.endAffordanceLaunch();
reset(true/*hideImmediately*/);//add by [email protected] for defect 7216010
///M : fix ALPS01852958, clear mAfterKeyguardGoneAction when leaving bouncer.
mAfterKeyguardGoneAction = null ;
return true;
}
if (DEBUG) Log.d(TAG, "onBackPressed() - reset & return false");
return false;
}
- screen pinnerUI处理需要修改如下两个值
res/values/dimens.xml
<dimen name="screen_pinning_request_button_height">85dp</dimen>
<dimen name="screen_pinning_request_nav_icon_padding">0dp</dimen>
- 隐藏MTK原生的SIM ME LOCK需要修改
SystemUI/src/com/android/keyguard/KeyguardSecurityModel.java
其中注释// check ME required,修改其中一个值为false就行了
public boolean isPinPukOrMeRequiredOfPhoneId(int phoneId) {
KeyguardUpdateMonitor updateMonitor = KeyguardUpdateMonitor.getInstance(mContext);
if (updateMonitor != null) {
final IccCardConstants.State simState = updateMonitor.getSimStateOfPhoneId(phoneId);
Log.d(TAG, "isPinPukOrMeRequiredOfSubId() - phoneId = " + phoneId +
", simState = " + simState) ;
return (
// check PIN required
(simState == IccCardConstants.State.PIN_REQUIRED
&& !updateMonitor.getPinPukMeDismissFlagOfPhoneId(phoneId))
// check PUK required
|| (simState == IccCardConstants.State.PUK_REQUIRED
&& !updateMonitor.getPinPukMeDismissFlagOfPhoneId(phoneId)
&& updateMonitor.getRetryPukCountOfPhoneId(phoneId) != 0)
// check ME required
|| (simState == IccCardConstants.State.NETWORK_LOCKED
&& !updateMonitor.getPinPukMeDismissFlagOfPhoneId(phoneId)
&& updateMonitor.getSimMeLeftRetryCountOfPhoneId(phoneId) != 0
&& KeyguardUtils.isMediatekSimMeLockSupport()
&& !updateMonitor.getSimmeDismissFlagOfPhoneId(phoneId)
&& KeyguardUtils.isSimMeLockValid(phoneId)&&isShowSimMeLock)
);
} else {
return false;
}
}
- 锁屏界面底部shortcut图标启动应用涉及到如下几个类
SystemUI/src/com/android/systemui/statusbar/phone/KeyguardBottomAreaView.java
private void launchMessage() {
Intent messageIntent = new Intent();
mActivityStarter.startActivity(messageIntent, true);
}
SystemUI/src/com/android/systemui/ActivityStarterDelegate.java
@Override
public void startActivity(Intent intent, boolean dismissShade, Callback callback) {
if (mActualStarter == null) return;
mActualStarter.startActivity(intent, dismissShade, callback);
}
SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java
@Override
public void startActivity(Intent intent, boolean dismissShade, Callback callback) {
startActivityDismissingKeyguard(intent, false, dismissShade, callback);
}
//隐藏NotificationPanelView
mStatusBarView.collapsePanel(true, false /* delayed */, 100.0f /* speedUpFactor */);
- 禁用锁屏代码
private void setLockScreenisDisable(){
LockPatternUtils lockPatternUtils = new LockPatternUtils(mContext);
if(lockPatternUtils == null)return;
boolean isOTA;
try {
if(AppGlobals.getPackageManager() == null)return;
isOTA = AppGlobals.getPackageManager().isUpgrade();
Log.d(TAG,"setLockScreenisDisable...isOTA = :"+isOTA+",isLockScreenDisable = :"+(lockPatternUtils.isLockScreenDisabled(UserHandle.USER_OWNER))+",!ro.lockscreen.disable.default = :"+(!(SystemProperties.getBoolean("ro.lockscreen.disable.default", false))));
} catch (RemoteException e) {
throw new IllegalStateException("Package manager not available");
}
if(lockPatternUtils.isLockScreenDisabled(UserHandle.USER_OWNER) && isOTA && !(SystemProperties.getBoolean("ro.lockscreen.disable.default", false))){
lockPatternUtils.setLockScreenDisabled(false, UserHandle.USER_OWNER);
}
}
- 插拔SIM卡之后,原来的pin/password/pattern会缩小,原因是Android原生没有考虑锁屏加入其他
buncer的情况
SystemUI/src/com/android/keyguard/KeyguardSecurityViewFlipper.java
@Override
protected void onMeasure(int widthSpec, int heightSpec) {
....
for (int i = 0; i < count; i++) {
final View child = getChildAt(i);
final LayoutParams lp = (LayoutParams) child.getLayoutParams();
//add by [email protected] for defect 7485624 begin
if(child.getVisibility() == View.INVISIBLE || child.getVisibility() == View.GONE){
continue;
}
//add by [email protected] for defect 7485624 end
......
}
- Home键在PhoneWindowManager.java中的调用
void launchHomeFromHotKey(final boolean awakenFromDreams, final boolean respectKeyguard)
- 中文或者日语中使用plurals类型字符串不管单数复数都只会使用other,不会区分单复数,使用plurals时要特别注意中文和日语
- 隐藏QuickSettings代码
SystemUI/src/com/android/systemui/statusbar/phone/StatusBarKeyguardViewManager.java
if (mBouncer.isShowing()) {
if (mShowing) {
mStatusBar.hideKeyguard();
mBouncer.hide(false /* destroyView */);
KeyguardUpdateMonitor.getInstance(mContext).sendKeyguardReset();
updateStates();
}
}
- SIM卡的View和password的View都在一个父类里面,未插SIM卡测量的寬高和插了SIM卡测量的寬高发生了变化导致password向上浮动,添加:android:layout_gravity=“bottom”
SystemUI/res-keyguard/layout/keyguard_password_view.xml
<com.android.keyguard.KeyguardPasswordView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:androidprv="http://schemas.android.com/apk/res-auto"
android:id="@+id/keyguard_password_view"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
androidprv:layout_maxWidth="@dimen/keyguard_security_width"
androidprv:layout_maxHeight="@dimen/keyguard_security_height"
android:gravity="bottom"
>
- framework层有关锁屏密码长度的代码
services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java
//PasswordMetrics 存储密码的矩阵
public void setActivePasswordState(PasswordMetrics metrics, int userHandle)
- 定制默认锁屏壁纸需求
SystemUI/res-keyguard/drawable-xhdpi/default_lock_wallpaper.jpg
SystemUI/src/com/android/systemui/statusbar/phone/LockscreenWallpaper.java
//注意导入import com.android.systemui.R;
public LoaderResult loadBitmap(int currentUserId, UserHandle selectedUser) {
......
} else {
if (selectedUser != null) {
// Show the selected user's static wallpaper.
return LoaderResult.success(
mWallpaperManager.getBitmapAsUser(selectedUser.getIdentifier()));
} else {
// When there is no selected user, show the system wallpaper
//return LoaderResult.success(null);
//add by [email protected] for defect 7325149
return LoaderResult.success(BitmapFactory.decodeResource(mContext.getResources(), R.drawable.default_lock_wallpaper));
}
}
}
- 插入SIM卡,点击Emergency之后再返回SIM PIN界面,QuickSettings会下拉下来
修改代码
SystemUI/src/com/android/systemui/statusbar/phone/PanelView.java
public void expand(final boolean animate){
......
getViewTreeObserver().addOnGlobalLayoutListener(
new ViewTreeObserver.OnGlobalLayoutListener() {
@Override
public void onGlobalLayout() {
if (!mInstantExpanding) {
getViewTreeObserver().removeOnGlobalLayoutListener(this);
return;
}//add by [email protected] for defect 7226148 begin
if (mStatusBar.getStatusBarWindow().getHeight()
!= mStatusBar.getStatusBarHeight()&&!mStatusBar.isBouncerShowing()
|| (mStatusBar.isKeyguardSecure() ?
mStatusBar.getBarState() != StatusBarState.SHADE : true)) {
//add by [email protected] for defect 7226148 end
......
}
- 锁屏notification渐变度设置
vendor/mediatek/proprietary/packages/apps/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelView.java
private void updateNotificationTranslucency() {
float alpha = 1f;
if (mClosingWithAlphaFadeOut && !mExpandingFromHeadsUp &&
!mHeadsUpManager.hasPinnedHeadsUp()) {
alpha = getFadeoutAlpha();
}
if (mBarState == StatusBarState.KEYGUARD && !mHintAnimationRunning) {
alpha *= mClockPositionResult.clockAlpha;
}
//add by [email protected] for defect 8503312 begin
if(!mUnlockMethodCache.isMethodSecure() && mNotificationStackScroller.getAlpha() != 1 && mNotificationStackScroller.getAlpha() != 0){
mStatusBar.getLockIcon().setAlpha(alpha);
}
//add by [email protected] for defect 8503312 end
mNotificationStackScroller.setAlpha(alpha);
}