日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

全志 增加启动默launcher函数 Patch

發布時間:2024/10/14 编程问答 42 豆豆
生活随笔 收集整理的這篇文章主要介紹了 全志 增加启动默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的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。