use of android.os.RemoteException in project platform_frameworks_base by android.
the class AppRestrictionsHelper method fetchAndMergeApps.
public void fetchAndMergeApps() {
mVisibleApps = new ArrayList<>();
final PackageManager pm = mPackageManager;
final IPackageManager ipm = mIPm;
final HashSet<String> excludePackages = new HashSet<>();
addSystemImes(excludePackages);
// Add launchers
Intent launcherIntent = new Intent(Intent.ACTION_MAIN);
if (mLeanback) {
launcherIntent.addCategory(Intent.CATEGORY_LEANBACK_LAUNCHER);
} else {
launcherIntent.addCategory(Intent.CATEGORY_LAUNCHER);
}
addSystemApps(mVisibleApps, launcherIntent, excludePackages);
// Add widgets
Intent widgetIntent = new Intent(AppWidgetManager.ACTION_APPWIDGET_UPDATE);
addSystemApps(mVisibleApps, widgetIntent, excludePackages);
List<ApplicationInfo> installedApps = pm.getInstalledApplications(PackageManager.MATCH_UNINSTALLED_PACKAGES);
for (ApplicationInfo app : installedApps) {
// If it's not installed, skip
if ((app.flags & ApplicationInfo.FLAG_INSTALLED) == 0)
continue;
if ((app.flags & ApplicationInfo.FLAG_SYSTEM) == 0 && (app.flags & ApplicationInfo.FLAG_UPDATED_SYSTEM_APP) == 0) {
// Downloaded app
SelectableAppInfo info = new SelectableAppInfo();
info.packageName = app.packageName;
info.appName = app.loadLabel(pm);
info.activityName = info.appName;
info.icon = app.loadIcon(pm);
mVisibleApps.add(info);
} else {
try {
PackageInfo pi = pm.getPackageInfo(app.packageName, 0);
// but will still be marked as false and immutable.
if (mRestrictedProfile && pi.requiredAccountType != null && pi.restrictedAccountType == null) {
mSelectedPackages.put(app.packageName, false);
}
} catch (PackageManager.NameNotFoundException re) {
// Skip
}
}
}
// Get the list of apps already installed for the user
List<ApplicationInfo> userApps = null;
try {
ParceledListSlice<ApplicationInfo> listSlice = ipm.getInstalledApplications(PackageManager.MATCH_UNINSTALLED_PACKAGES, mUser.getIdentifier());
if (listSlice != null) {
userApps = listSlice.getList();
}
} catch (RemoteException re) {
// Ignore
}
if (userApps != null) {
for (ApplicationInfo app : userApps) {
if ((app.flags & ApplicationInfo.FLAG_INSTALLED) == 0)
continue;
if ((app.flags & ApplicationInfo.FLAG_SYSTEM) == 0 && (app.flags & ApplicationInfo.FLAG_UPDATED_SYSTEM_APP) == 0) {
// Downloaded app
SelectableAppInfo info = new SelectableAppInfo();
info.packageName = app.packageName;
info.appName = app.loadLabel(pm);
info.activityName = info.appName;
info.icon = app.loadIcon(pm);
mVisibleApps.add(info);
}
}
}
// Sort the list of visible apps
Collections.sort(mVisibleApps, new AppLabelComparator());
// Remove dupes
Set<String> dedupPackageSet = new HashSet<String>();
for (int i = mVisibleApps.size() - 1; i >= 0; i--) {
SelectableAppInfo info = mVisibleApps.get(i);
if (DEBUG)
Log.i(TAG, info.toString());
String both = info.packageName + "+" + info.activityName;
if (!TextUtils.isEmpty(info.packageName) && !TextUtils.isEmpty(info.activityName) && dedupPackageSet.contains(both)) {
mVisibleApps.remove(i);
} else {
dedupPackageSet.add(both);
}
}
// Establish master/slave relationship for entries that share a package name
HashMap<String, SelectableAppInfo> packageMap = new HashMap<String, SelectableAppInfo>();
for (SelectableAppInfo info : mVisibleApps) {
if (packageMap.containsKey(info.packageName)) {
info.masterEntry = packageMap.get(info.packageName);
} else {
packageMap.put(info.packageName, info);
}
}
}
use of android.os.RemoteException in project platform_frameworks_base by android.
the class DisplayDensityUtils method setForcedDisplayDensity.
/**
* Asynchronously applies display density changes to the specified display.
* <p>
* The change will be applied to the user specified by the value of
* {@link UserHandle#myUserId()} at the time the method is called.
*
* @param displayId the identifier of the display to modify
* @param density the density to force for the specified display
*/
public static void setForcedDisplayDensity(final int displayId, final int density) {
final int userId = UserHandle.myUserId();
AsyncTask.execute(() -> {
try {
final IWindowManager wm = WindowManagerGlobal.getWindowManagerService();
wm.setForcedDisplayDensityForUser(displayId, density, userId);
} catch (RemoteException exc) {
Log.w(LOG_TAG, "Unable to save forced display density setting");
}
});
}
use of android.os.RemoteException in project platform_frameworks_base by android.
the class DisplayDensityUtils method clearForcedDisplayDensity.
/**
* Asynchronously applies display density changes to the specified display.
* <p>
* The change will be applied to the user specified by the value of
* {@link UserHandle#myUserId()} at the time the method is called.
*
* @param displayId the identifier of the display to modify
*/
public static void clearForcedDisplayDensity(final int displayId) {
final int userId = UserHandle.myUserId();
AsyncTask.execute(() -> {
try {
final IWindowManager wm = WindowManagerGlobal.getWindowManagerService();
wm.clearForcedDisplayDensityForUser(displayId, userId);
} catch (RemoteException exc) {
Log.w(LOG_TAG, "Unable to clear forced display density setting");
}
});
}
use of android.os.RemoteException in project platform_frameworks_base by android.
the class ApplicationsState method addPackage.
void addPackage(String pkgName, int userId) {
try {
synchronized (mEntriesMap) {
if (DEBUG_LOCKING)
Log.v(TAG, "addPackage acquired lock");
if (DEBUG)
Log.i(TAG, "Adding package " + pkgName);
if (!mResumed) {
// here.
if (DEBUG_LOCKING)
Log.v(TAG, "addPackage release lock: not resumed");
return;
}
if (indexOfApplicationInfoLocked(pkgName, userId) >= 0) {
if (DEBUG)
Log.i(TAG, "Package already exists!");
if (DEBUG_LOCKING)
Log.v(TAG, "addPackage release lock: already exists");
return;
}
ApplicationInfo info = mIpm.getApplicationInfo(pkgName, mUm.isUserAdmin(userId) ? mAdminRetrieveFlags : mRetrieveFlags, userId);
if (info == null) {
return;
}
if (!info.enabled) {
if (info.enabledSetting != PackageManager.COMPONENT_ENABLED_STATE_DISABLED_USER) {
return;
}
mHaveDisabledApps = true;
}
mApplications.add(info);
if (!mBackgroundHandler.hasMessages(BackgroundHandler.MSG_LOAD_ENTRIES)) {
mBackgroundHandler.sendEmptyMessage(BackgroundHandler.MSG_LOAD_ENTRIES);
}
if (!mMainHandler.hasMessages(MainHandler.MSG_PACKAGE_LIST_CHANGED)) {
mMainHandler.sendEmptyMessage(MainHandler.MSG_PACKAGE_LIST_CHANGED);
}
if (DEBUG_LOCKING)
Log.v(TAG, "addPackage releasing lock");
}
} catch (RemoteException e) {
}
}
use of android.os.RemoteException in project platform_frameworks_base by android.
the class GuestResumeSessionReceiver method wipeGuestSession.
/**
* Wipes the guest session.
*
* The guest must be the current user and its id must be {@param userId}.
*/
private static void wipeGuestSession(Context context, int userId) {
UserManager userManager = (UserManager) context.getSystemService(Context.USER_SERVICE);
UserInfo currentUser;
try {
currentUser = ActivityManagerNative.getDefault().getCurrentUser();
} catch (RemoteException e) {
Log.e(TAG, "Couldn't wipe session because ActivityManager is dead");
return;
}
if (currentUser.id != userId) {
Log.w(TAG, "User requesting to start a new session (" + userId + ")" + " is not current user (" + currentUser.id + ")");
return;
}
if (!currentUser.isGuest()) {
Log.w(TAG, "User requesting to start a new session (" + userId + ")" + " is not a guest");
return;
}
boolean marked = userManager.markGuestForDeletion(currentUser.id);
if (!marked) {
Log.w(TAG, "Couldn't mark the guest for deletion for user " + userId);
return;
}
UserInfo newGuest = userManager.createGuest(context, currentUser.name);
try {
if (newGuest == null) {
Log.e(TAG, "Could not create new guest, switching back to system user");
ActivityManagerNative.getDefault().switchUser(UserHandle.USER_SYSTEM);
userManager.removeUser(currentUser.id);
WindowManagerGlobal.getWindowManagerService().lockNow(null);
return;
}
ActivityManagerNative.getDefault().switchUser(newGuest.id);
userManager.removeUser(currentUser.id);
} catch (RemoteException e) {
Log.e(TAG, "Couldn't wipe session because ActivityManager or WindowManager is dead");
return;
}
}
Aggregations