[工作紀錄][AOSP-framework-SystemUI] keyguard 頁面下 下拉動畫的BUG

2016年7月24日 星期日

[工作紀錄][AOSP-framework-SystemUI] keyguard 頁面下,下拉無notification上彈且顯示 notification詳細資料的bug


BUG:
Aindroid 5.0~6.0 再有設定PING碼或其他鎖屏方式的情況下
再鎖屏頁面下往下拉 notify會上移並顯示notify詳細內容(可自行決定)
但手上裝置沒有




---------------------------------------------1.轉貼相關觀念-------------------------------------------------

[轉載自http://blog.csdn.net/wzy_1988/article/details/49659935#锁屏加载流程]

重点一
Android5.1和Android4.4锁屏机制展示的区别?
解答:在Android5.1中,keyguard本身不再是一个独立的apk,而是跟SystemUI进行了合并,作为SystemUI的静态库进行调用。对比Android5.1和Android4.4的SystemUI模块的Android.mk文件可以更加直观的对比。
Android5.1 SystemUI Android.mk
LOCAL_PATH:= $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE_TAGS := optional
LOCAL_SRC_FILES := $(call all-java--files-under, src)

# 指定Keyguard作为静态库
LOCAL_STATIC_JAVA_LIBRARIES := Keyguard

LOCAL_JAVA_LIBRATIES := telephony-common
# 指定名称
LOCAL_PACKAGE_NAME := SystemUI
LOCAL_CERTIFICATE := platform
LOCAL_PRIVILEGED_MODULE := true
LOCAL_PROGUARD_FLAG_FILES := proguard.flags
LOCAL_RESOURCE_DIR := \
    frameworks/base/packages/Keyguard/res \
    $(LOCAL_PATH)/res
LOCAL_AAPT_FLAGS := --auto-add-overlay --extra-packages com.android.keyguard
# 编译成apk
include $(BUILD_PACKAGE)
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
Android4.4 SystemUI Android.mk
LOCAL_PATH:= $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE_TAGS := optional
LOCAL_SRC_FILES := $(call all-java-files-under, src) \
    src/com/android/systemui/EventLogTags.logtags
LOCAL_JAVA_LIBRARIES := telephony-common
LOCAL_PACKAGE_NAME := SystemUI
LOCAL_CERTIFICATE := platform
LOCAL_PRIVILEGED_MODULE := true
LOCAL_PROGUARD_FLAG_FILES := proguard.flags
include $(BUILD_PACKAGE)
include $(call all-makefiles-under,$(LOCAL_PATH))
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
所以,系统调试锁屏,只需要单独编译SystemUI模块,然后替换SystemUI.apk即可。

重点二

如何替换系统锁屏,改为我们的锁屏应用?
解答:个人认为,如果能够修改SystemUI方法,那最好就是重载handleShow()方法,在这个方法中实现我们自己的锁屏界面。例如通过Activity跳转,别忘了释放PARTIAL_WEAK_LOCK。
重载这个方法,可以最大程度的不影响Android系统逻辑(ps:个人意见,大家有更好的办法可以指点我)

StatusBarKeyguardViewManager

位置:
framework/base/package/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarKeyguardViewManager.java
分析这个类,我们肯定是先从show方法开始入手。

show()

show方法的源码如下:
public class StatusBarKeyguardViewManager {
    public void show(Bundle options) {
        // 设置keguard是否显示的标志
        mShowing = true;
        mStatusBarWindowManager.setKeyguardShowing(true);
        // 重置view的状态,进行keyguard锁屏显示
        reset();
    }
}
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9

reset()

源码如下:
public class StatusBarKeyguardViewManager {
    public void reset() {
        Log.e("TAG", "mShowing:" + mShowing + ", mOccluded:" + mOccluded);
        if (mShowing) {
            if (mOccluded) {
                mPhoneStatusBar.hideKeyguard();
                mBouncer.hide(false /* destroyView */);
            } else {
                // 判断是调用安全锁屏还是调用滑动锁屏
                showBouncerOrKeyguard();
            }
            updateStates();
        }
    }
}
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15

showBouncerOrKeyguard()

public class StatusBarKeyguardViewManager {
    private void showBouncerOrKeyguard() {
        if (mBouncer.needsFullscreenBouncer()) {

            // The keyguard might be showing (already). So we need to hide it.
            mPhoneStatusBar.hideKeyguard();
            mBouncer.show(true);
        } else {
            mPhoneStatusBar.showKeyguard();
            mBouncer.hide(false);
            mBouncer.prepare();
        }
    }
}
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
接下来,就是view展示的过程了。其中,mBouncer是用来显示安全锁屏,例如图案、密码、PIN码等。有兴趣的同学可以继续跟踪一下mBouncer的展示或者mPhoneStatusBar的展示过程。

---------------------------------------------2.trace code-------------------------------------------------


思路:
設定完PING碼跳出的"是否要再keyguard頁面下顯示notify詳細內容" layout





老梗 從字串入手:

./apps/Settings/res/values-en-rGB/strings.xml: <string name="lock_screen_notifications_interstitial_message" msgid="6164532459432182244">"When your device is locked, how do you want notifications to show?"</string>



./apps/Settings/res/layout/redaction_interstitial.xml: android:text="@string/lock_screen_notifications_interstitial_message"

ryan@ryan-HP-Compaq-8100-Elite-CMT-PC:~/Project/Reborn-4290/LINUX/android/packages$ find -name "*.java" | xargs grep "redaction_interstitial"
./apps/Settings/src/com/android/settings/notification/RedactionInterstitial.java: View view = inflater.inflate(R.layout.redaction_interstitial, container, false);



ryan@ryan-HP-Compaq-8100-Elite-CMT-PC:~/Project/Reborn-4290/LINUX/android/packages/apps/Settings$ find -name "*.java" | xargs grep "Settings.Secure.LOCK_SCREEN_SHOW_NOTIFICATIONS"
./src/com/android/settings/notification/RedactionInterstitial.java: Settings.Secure.LOCK_SCREEN_SHOW_NOTIFICATIONS, 0) != 0;
./src/com/android/settings/notification/RedactionInterstitial.java: Settings.Secure.LOCK_SCREEN_SHOW_NOTIFICATIONS, enabled ? 1 : 0);
./src/com/android/settings/notification/AppNotificationSettings.java: Settings.Secure.LOCK_SCREEN_SHOW_NOTIFICATIONS, 0) != 0;
./src/com/android/settings/notification/NotificationSettings.java: Settings.Secure.LOCK_SCREEN_SHOW_NOTIFICATIONS, enabled ? 1 : 0);
./src/com/android/settings/notification/NotificationSettings.java: Settings.Secure.LOCK_SCREEN_SHOW_NOTIFICATIONS, 0) != 0;
./src/com/android/settings/notification/NotificationSettings.java: Settings.Secure.getUriFor(Settings.Secure.LOCK_SCREEN_SHOW_NOTIFICATIONS);





在 AppNotificationSettings.java: 以及 NotificationSettings.java: 都有下面這兩個

private boolean getLockscreenNotificationsEnabled() {
return Settings.Secure.getInt(getContentResolver(),
Settings.Secure.LOCK_SCREEN_SHOW_NOTIFICATIONS, 0) != 0;
}

private boolean getLockscreenAllowPrivateNotifications() {
return Settings.Secure.getInt(getContentResolver(),
Settings.Secure.LOCK_SCREEN_ALLOW_PRIVATE_NOTIFICATIONS, 0) != 0;
}



//放棄上面 找不到用他的 回頭到framework找 Settings.Secure.LOCK_SCREEN_SHOW_NOTIFICATIONS

ryan@ryan-HP-Compaq-8100-Elite-CMT-PC:~/Project/Reborn-4290/LINUX/android/frameworks$ find -name "*.java" | xargs grep "Settings.Secure.LOCK_SCREEN_SHOW_NOTIFICATIONS"
./base/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java: Settings.Secure.getUriFor(Settings.Secure.LOCK_SCREEN_SHOW_NOTIFICATIONS), false,
./base/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java: Settings.Secure.LOCK_SCREEN_SHOW_NOTIFICATIONS, 0);
./base/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java: Settings.Secure.LOCK_SCREEN_SHOW_NOTIFICATIONS,
./base/packages/SettingsProvider/src/com/android/providers/settings/DatabaseHelper.java: loadIntegerSetting(stmt, Settings.Secure.LOCK_SCREEN_SHOW_NOTIFICATIONS,
./base/packages/SettingsProvider/src/com/android/providers/settings/DatabaseHelper.java: TABLE_GLOBAL, Settings.Secure.LOCK_SCREEN_SHOW_NOTIFICATIONS, -1);
./base/packages/SettingsProvider/src/com/android/providers/settings/DatabaseHelper.java: loadSetting(stmt, Settings.Secure.LOCK_SCREEN_SHOW_NOTIFICATIONS, oldShow);
./base/packages/SettingsProvider/src/com/android/providers/settings/DatabaseHelper.java: deleteStmt.bindString(1, Settings.Secure.LOCK_SCREEN_SHOW_NOTIFICATIONS);
ryan@ryan-HP-Compaq-8100-Elite-CMT-PC:~/Project/Reborn-4290/LINUX/android/frameworks$





/////////////////////////////////////////////////////////////
Bouncer是鎖屏容器

ryan@ryan-HP-Compaq-8100-Elite-CMT-PC:~/Project/Reborn-4290/LINUX/android/frameworks$ find -name "*.java" | xargs grep "Bouncer.show"
./base/packages/Keyguard/src/com/android/keyguard/KeyguardHostView.java: super.showBouncer(show);
./base/packages/Keyguard/src/com/android/keyguard/KeyguardHostView.java: mViewStateManager.showBouncer(show);
./base/packages/Keyguard/src/com/android/keyguard/KeyguardSimpleHostView.java: super.showBouncer(show);
./base/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarKeyguardViewManager.java: mBouncer.show(true /* resetSecuritySelection */);
./base/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarKeyguardViewManager.java: mBouncer.show(false /* resetSecuritySelection */);
./base/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarKeyguardViewManager.java: mBouncer.showWithDismissAction(r);
./base/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarKeyguardViewManager.java: mBouncer.show(false /* resetSecuritySelection */);
ryan@ryan-HP-Compaq-8100-Elite-CMT-PC:~/Project/Reborn-4290/LINUX/android/frameworks$



///////////////////////////////////

KeyguardViewMediator.java

private void handleShow(Bundle options) {
synchronized (KeyguardViewMediator.this) {
if (!mSystemReady) {
if (DEBUG) Log.d(TAG, "ignoring handleShow because system is not ready.");
return;
} else {
if (DEBUG) Log.d(TAG, "handleShow");
}

setShowingLocked(true);
mStatusBarKeyguardViewManager.show(options);
mHiding = false;
resetKeyguardDonePendingLocked();
mHideAnimationRun = false;
updateActivityLockScreenState();
adjustStatusBarLocked();
userActivity();

// Do this at the end to not slow down display of the keyguard.
playSounds(true);

mShowKeyguardWakeLock.release();
}
mKeyguardDisplayManager.show();
}


///////////////////////////////////////

R.string.notification_tap_again

ryan@ryan-HP-Compaq-8100-Elite-CMT-PC:~/Project/Reborn-4290/LINUX/android/frameworks/base$ find -name "*.xml" | xargs grep "Swipe up to unlock"
./packages/SystemUI/res/values-en-rIN/strings.xml: <string name="keyguard_unlock" msgid="8043466894212841998">"Swipe up to unlock"</string>
./packages/SystemUI/res/values/strings.xml: <string name="keyguard_unlock">Swipe up to unlock</string>
./packages/SystemUI/res/values-en-rGB/strings.xml: <string name="keyguard_unlock" msgid="8043466894212841998">"Swipe up to unlock"</string>


ryan@ryan-HP-Compaq-8100-Elite-CMT-PC:~/Project/Reborn-4290/LINUX/android/frameworks/base$ find -name "*.java" | xargs grep "keyguard_unlock"
./packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java: mKeyguardIndicationController.showTransientIndication(R.string.keyguard_unlock);


讀了一下PhoneStatusBar.java ,開始懷疑應該滑動部份是覆寫了哪個class
開始再懷疑的地方加上log

@Override
public void onActivated(ActivatableNotificationView view) {
mKeyguardIndicationController.showTransientIndication(R.string.notification_tap_again);
ActivatableNotificationView previousView = mStackScroller.getActivatedChild();
if (previousView != null) {
previousView.makeInactive(true /* animate */);
}
mStackScroller.setActivatedChild(view);
}


最後實機滑動操作的時候,得到以下LOG
onTouchSlopExceeded
onTrackingStopped
onDragDownReset
然後就在onDragDownReset找到答案了


onDragDownReset 來自於DragDownHelper.java

    public interface DragDownCallback {

        /**
         * @return true if the interaction is accepted, false if it should be cancelled
         */
        boolean onDraggedDown(View startingChild);
        void onDragDownReset();
        void onThresholdReached();
        void onTouchSlopExceeded();
        void setEmptyDragAmount(float amount);
    }


case MotionEvent.ACTION_UP: 
後面這段的CODE莫名的背qcom拿掉了
我們一開始拿到的那包code就沒人改過這個檔案
取消註解後並且修改了一下引入變數後即OK















0 意見:

張貼留言