全志 增加启动默launcher函数 Patch
生活随笔
收集整理的這篇文章主要介紹了
全志 增加启动默launcher函数 Patch
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
add 添加啟動默launcher函數diff --git a/android/frameworks/base/services/core/java/com/android/server/am/ActivityManagerService.java b/android/fr
index 446b0e4..9b7e2ba 100755
--- a/android/frameworks/base/services/core/java/com/android/server/am/ActivityManagerService.java
+++ b/android/frameworks/base/services/core/java/com/android/server/am/ActivityManagerService.java
@@ -3692,7 +3692,81 @@ public final class ActivityManagerService extends ActivityManagerNative}return intent;}
-
+
+ /* launch the defualt launcher when the system boots for the first time */
+ private boolean mFirstLaunch = false;
+ private void setDefaultLauncher(int userId)
+ {
+ // get default component
+ String packageName = SystemProperties.get("ro.sw.defaultlauncherpackage", "no");
+ String className = SystemProperties.get("ro.sw.defaultlauncherclass", "no");
+ Slog.i(TAG, "default packageName = " + packageName + ", default className = " + className);
+ if(!packageName.equals("no") && !className.equals("no")){
+ boolean firstLaunch = true;//SystemProperties.getBoolean("persist.sys.sw.firstLaunch", true);
+ Slog.d(TAG, "firstLaunch = " + firstLaunch);
+ if(firstLaunch){
+ mFirstLaunch = true;
+ // do this only for the first boot
+ SystemProperties.set("persist.sys.sw.firstLaunch", "false");
+ }
+ Slog.d(TAG, "mFirstLaunch = " + mFirstLaunch);
+ if(mFirstLaunch){
+ IPackageManager pm = ActivityThread.getPackageManager();
+
+ //clear the current preferred launcher
+ ArrayList<IntentFilter> intentList = new ArrayList<IntentFilter>();
+ ArrayList<ComponentName> cnList = new ArrayList<ComponentName>();
+ mContext.getPackageManager().getPreferredActivities(intentList, cnList, null);
+ IntentFilter dhIF;
+ for(int i = 0; i < cnList.size(); i++)
+ {
+ dhIF = intentList.get(i);
+ if(dhIF.hasAction(Intent.ACTION_MAIN) &&
+ dhIF.hasCategory(Intent.CATEGORY_HOME))
+ {
+ mContext.getPackageManager().clearPackagePreferredActivities(cnList.get(i).getPackageName());
+ }
+ }
+
+ // get all Launcher activities
+ Intent intent = new Intent(Intent.ACTION_MAIN);
+ intent.addCategory(Intent.CATEGORY_HOME);
+ List<ResolveInfo> list = new ArrayList<ResolveInfo>();
+ try
+ {
+ list = pm.queryIntentActivities(intent,
+ intent.resolveTypeIfNeeded(mContext.getContentResolver()),
+ PackageManager.MATCH_DEFAULT_ONLY, userId);
+ }catch (RemoteException e) {
+ throw new RuntimeException("Package manager has died", e);
+ }
+ // get all components and the best match
+ IntentFilter filter = new IntentFilter();
+ filter.addAction(Intent.ACTION_MAIN);
+ filter.addCategory(Intent.CATEGORY_HOME);
+ filter.addCategory(Intent.CATEGORY_DEFAULT);
+ final int N = list.size();
+ ComponentName[] set = new ComponentName[N];
+ int bestMatch = 0;
+ for (int i = 0; i < N; i++)
+ {
+ ResolveInfo r = list.get(i);
+ set[i] = new ComponentName(r.activityInfo.packageName,
+ r.activityInfo.name);
+ if (r.match > bestMatch) bestMatch = r.match;
+ }
+ // add the default launcher as the preferred launcher
+ ComponentName launcher = new ComponentName(packageName, className);
+ try
+ {
+ pm.addPreferredActivity(filter, bestMatch, set, launcher, userId);
+ } catch (RemoteException e) {
+ throw new RuntimeException("Package manager has died", e);
+ }
+ }
+ }
+ }
+ boolean startHomeActivityLocked(int userId, String reason) {if (mFactoryTest == FactoryTest.FACTORY_TEST_LOW_LEVEL&& mTopAction == null) {
@@ -3701,6 +3775,10 @@ public final class ActivityManagerService extends ActivityManagerNative// error message and don't try to start anything.return false;}
+ /* launch the defualt launcher when the system boots for the first time */
+ setDefaultLauncher(userId);
+
+
總結
以上是生活随笔為你收集整理的全志 增加启动默launcher函数 Patch的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 全志 强制隐藏导航栏状态栏 Patch
- 下一篇: 全志 添加PWM7参数