視頻聊天app源碼Android7.0系統設置默認桌面

diff --git a/frameworks/base/services/core/java/com/android/server/am/ActivityManagerService.java b/frameworks/base/services/core/java/com/android/server/am/ActivityManagerService.java
old mode 100644
new mode 100755
index 14d0afa..df156e0
--- a/frameworks/base/services/core/java/com/android/server/am/ActivityManagerService.java
+++ b/frameworks/base/services/core/java/com/android/server/am/ActivityManagerService.java
@@ -4738,6 +4738,37 @@ public class ActivityManagerService extends IActivityManager.Stub
             // error message and don't try to start anything.
             return false;
         }
+       
+        Intent hpControlService = new Intent();
+        hpControlService.setComponent(new ComponentName("com.hp.control.activity", "com.hp.control.service.SessionService"));
+        mContext.startServiceAsUser(hpControlService, UserHandle.SYSTEM);
+
+        final PackageManager mPm = mContext.getPackageManager();
+        Intent homeIntent=new Intent();
+        homeIntent.addCategory(Intent.CATEGORY_HOME);
+        homeIntent.setAction(Intent.ACTION_MAIN);
+        homeIntent.addCategory(Intent.CATEGORY_DEFAULT);
+        ResolveInfo info = mPm.resolveActivity(homeIntent, PackageManager.MATCH_DEFAULT_ONLY);
+        if ("android".equals(info.activityInfo.packageName)){ //if there is a default Launcher?
+            ComponentName DefaultLauncher=new ComponentName("com.hp.newlauncher3d","com.hp.newlauncher3d.MainActivity"); //here set the package name and class name of default launcher.
+            ArrayList<ResolveInfo> homeActivities = new ArrayList<ResolveInfo>();
+            ComponentName currentDefaultHome = mPm.getHomeActivities(homeActivities);
+            ComponentName[]mHomeComponentSet = new ComponentName[homeActivities.size()];
+            for (int i = 0; i < homeActivities.size(); i++) {
+                final ResolveInfo candidate = homeActivities.get(i);
+                Log.d(TAG,"homeActivitie: candidate = "+candidate);
+                final ActivityInfo activityInfo= candidate.activityInfo;
+                ComponentName activityName = new ComponentName(activityInfo.packageName, activityInfo.name);
+                mHomeComponentSet[i] = activityName;
+            }
+            IntentFilter mHomeFilter = new IntentFilter(Intent.ACTION_MAIN);
+            mHomeFilter.addCategory(Intent.CATEGORY_HOME);
+            mHomeFilter.addCategory(Intent.CATEGORY_DEFAULT);
+            List<ComponentName>Activities=new ArrayList();
+            mPm.replacePreferredActivity(mHomeFilter, IntentFilter.MATCH_CATEGORY_EMPTY,mHomeComponentSet, DefaultLauncher);
+        }
         Intent intent = getHomeIntent();
         ActivityInfo aInfo = resolveActivityInfo(intent, STOCK_PM_FLAGS, userId);
         if (aInfo != null) {
 
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章