任务完成过程中遇到的问题点及经验:
1. 总结了自己在实现两个需求中遇到的问题点及难点
1)图标不可视;
2)实现开机进入短信的几种方式;
3)实现开机进入浏览器的几种方式,以及自己使用的方法的优缺点分析。
2. 总结了在实现这两个需求中重点用到的几个java文件:(个人理解)
1)keyguardBottomAreaView.java:功能实现部分,重点修改的一个类文件;
id/phone_button--->"drawable/ic_phone_alt_24dp"
id/camera_button--->"drawable/ic_camera_alt_24dp"
id/lock_icon--->"drawable/ic_lock_24dp"
2)phoneStatusBar.java:手机的状态栏,用于提示用户处于某个状态下;
id/phone_hint--->Swipe right for phone
id/camera_hint--->Swipe left for camera
3)NotificationPanelView.java:通知状态栏,主要用于启动相应的功能模块;
3. 总结归纳了在完成功能实现中所用到知识点:
1)Intent的属性(主要用到了Component属性);
如:PHONE—INTENT.SetClassName(”com.android.mms“,”com.android.mms.ui.BootActivity“);
3)第二种方法使用到的Intent属性(Action、Data、Extra属性)
如:BROWSER—INTENT.SetAction(Intent.ACTION—VIEW);
BROWSER—INTENT.SetData(Uri.parse(”http://www.google.com“));
mActivityStarter.StartActivity(BROWSER—INTENT,false);
(缺点:如果整机里面有两个及以上的浏览器,这种方式启动时需要用户来选择使用哪个浏览器打开)
1)使用hierarchyViewer找到相对应的图形按钮的id和所在的包和布局文件;
2)在keyguardBottomAreaView.java找到了重要的函数launchCamera(),简单理解为发动照相机(也就是需要修改的重点部分)。
frameworks/base/packages/SystemUI/res/values-en-rIN/strings.xml: <string name="camera_hint" msgid="5241441720959174226">"Swipe left for camera"</string>
frameworks/base/packages/SystemUI/res/values-en-rGB/strings.xml: <string name="camera_hint" msgid="5241441720959174226">"Swipe left for camera"</string>
frameworks/base/packages/SystemUI/res/values/strings.xml: <string name="camera_hint">Swipe left for camera</string>
frameworks/base/packages/SystemUI/res/values/strings.xml: <string name="browser_hint">Swipe left for browser</string>
cd frameworks/base/packages/SystemUI/res/values/strings.xml打开该文件,修改字符串。
android@c0525:~/Projects/XXX/src/baseline/frameworks/base/packages/Keyguard
../../core/res/res/values/strings.xml
../SystemUI/res/drawable-hdpi/ic_camera_alt_24dp.png
../SystemUI/res/drawable-hdpi/ic_phone_24dp.png../SystemUI/res/layout/keyguard_bottom_area.xml
../SystemUI/res/values-en-rIN/strings.xml
../SystemUI/res/values-zh-rCN/strings.xml
../SystemUI/res/values/strings.xml
../SystemUI/src/com/android/systemui/statusbar/phone/KeyguardBottomAreaView.java(功能实现部分的主要代码)
../SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelView.java
../SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java(状态栏)
../SystemUI/src/com/android/systemui/statusbar/phone/SecureCameraLaunchManager.java
../SystemUI/res/drawable-hdpi/ic_browser_alt_24dp.png
../SystemUI/res/drawable-hdpi/ic_camera_alt_24dp.4.png
../SystemUI/res/drawable-hdpi/ic_mms_24dp.png
../SystemUI/res/drawable-hdpi/ic_phone_24dp1.png
//声明两个变量
private static final Intent BROWSER_INTENT=new Intent();
private static final Intent MMS_INTENT = new Intent();
//更新浏览器的显示
private void updateBrowserVisibility() {
boolean visible =isBrowserVisible();
Log.d(TAG, "updateBrowserVisibility()------visible=" + visible);
mBrowserImageView.setVisibility(visible ? View.VISIBLE : View.GONE);
}
private void updateMmsVisibility() {
boolean visible = isMmsVisible();
Log.d(TAG, "updateMmsVisibility()------visible=" + visible);
mMmsImageView.setVisibility(visible ? View.VISIBLE : View.GONE);
}
//让短信和浏览器界面显示
private boolean isMmsVisible() {
MMS_INTENT.setClassName("com.android.mms", "com.android.mms.ui.BootActivity");
PackageManager pm = mContext.getPackageManager();
return pm.hasSystemFeature(PackageManager.FEATURE_TELEPHONY)
&& pm.resolveActivity(MMS_INTENT, 0) != null;
}
private boolean isBrowserVisible() {
BROWSER_INTENT.setClassName("com.android.browser", "com.android.browser.BrowserActivity");
PackageManager pm = mContext.getPackageManager();
return pm.resolveActivity(BROWSER_INTENT, 0) != null;
}
//发动浏览器和短信的显示
public void launchBrowser() {
mActivityStarter.startActivity(BROWSER_INTENT, false);
}
public void launchMms() {
if (DEBUG) {
Log.d(TAG, "launchMms() is called.") ;
}
final TelecomManager tm = TelecomManager.from(mContext);
if (tm.isInCall()) {
AsyncTask.execute(new Runnable() {
@Override
public void run() {
tm.showInCallScreen(false );
}
});
} else {
mActivityStarter.startActivity(MMS_INTENT, false );
}
}