import android.content.ComponentName;
import android.content.Intent;
import android.content.pm.IOnAppsChangedListener;
+import android.content.pm.ParceledListSlice;
import android.content.pm.ResolveInfo;
import android.graphics.Rect;
import android.os.Bundle;
interface ILauncherApps {
void addOnAppsChangedListener(in IOnAppsChangedListener listener);
void removeOnAppsChangedListener(in IOnAppsChangedListener listener);
- List<ResolveInfo> getLauncherActivities(String packageName, in UserHandle user);
+ ParceledListSlice getLauncherActivities(String packageName, in UserHandle user);
ResolveInfo resolveActivity(in Intent intent, in UserHandle user);
void startActivityAsUser(in ComponentName component, in Rect sourceBounds,
in Bundle opts, in UserHandle user);
* @return List of launchable activities. Can be an empty list but will not be null.
*/
public List<LauncherActivityInfo> getActivityList(String packageName, UserHandle user) {
- List<ResolveInfo> activities = null;
+ ParceledListSlice<ResolveInfo> activities = null;
try {
activities = mService.getLauncherActivities(packageName, user);
} catch (RemoteException re) {
- throw new RuntimeException("Failed to call LauncherAppsService");
+ throw new RuntimeException("Failed to call LauncherAppsService", re);
}
if (activities == null) {
return Collections.EMPTY_LIST;
}
ArrayList<LauncherActivityInfo> lais = new ArrayList<LauncherActivityInfo>();
- final int count = activities.size();
- for (int i = 0; i < count; i++) {
- ResolveInfo ri = activities.get(i);
+ for (ResolveInfo ri : activities.getList()) {
LauncherActivityInfo lai = new LauncherActivityInfo(mContext, ri, user);
if (DEBUG) {
Log.v(TAG, "Returning activity for profile " + user + " : "
return info;
}
} catch (RemoteException re) {
- throw new RuntimeException("Failed to call LauncherAppsService");
+ throw new RuntimeException("Failed to call LauncherAppsService", re);
}
return null;
}
try {
return mService.isPackageEnabled(packageName, user);
} catch (RemoteException re) {
- throw new RuntimeException("Failed to call LauncherAppsService");
+ throw new RuntimeException("Failed to call LauncherAppsService", re);
}
}
try {
return mService.isActivityEnabled(component, user);
} catch (RemoteException re) {
- throw new RuntimeException("Failed to call LauncherAppsService");
+ throw new RuntimeException("Failed to call LauncherAppsService", re);
}
}
import android.content.pm.IPackageManager;
import android.content.pm.PackageManager;
import android.content.pm.PackageInfo;
+import android.content.pm.ParceledListSlice;
import android.content.pm.ResolveInfo;
import android.content.pm.UserInfo;
import android.graphics.Rect;
}
@Override
- public List<ResolveInfo> getLauncherActivities(String packageName, UserHandle user)
+ public ParceledListSlice<ResolveInfo> getLauncherActivities(String packageName, UserHandle user)
throws RemoteException {
ensureInUserProfiles(user, "Cannot retrieve activities for unrelated profile " + user);
if (!isUserEnabled(user)) {
- return new ArrayList<ResolveInfo>();
+ return null;
}
final Intent mainIntent = new Intent(Intent.ACTION_MAIN, null);
try {
List<ResolveInfo> apps = mPm.queryIntentActivitiesAsUser(mainIntent, 0 /* flags */,
user.getIdentifier());
- return apps;
+ return new ParceledListSlice<>(apps);
} finally {
Binder.restoreCallingIdentity(ident);
}