use of android.app.IActivityManager in project android_frameworks_base by DirtyUnicorns.
the class PackageManagerService method postPreferredActivityChangedBroadcast.
private void postPreferredActivityChangedBroadcast(int userId) {
mHandler.post(() -> {
final IActivityManager am = ActivityManagerNative.getDefault();
if (am == null) {
return;
}
final Intent intent = new Intent(Intent.ACTION_PREFERRED_ACTIVITY_CHANGED);
intent.putExtra(Intent.EXTRA_USER_HANDLE, userId);
try {
am.broadcastIntent(null, intent, null, null, 0, null, null, null, android.app.AppOpsManager.OP_NONE, null, false, false, userId);
} catch (RemoteException e) {
}
});
}
use of android.app.IActivityManager in project android_frameworks_base by DirtyUnicorns.
the class PackageManagerService method sendPackageAddedForUser.
private void sendPackageAddedForUser(String packageName, boolean isSystem, int appId, int userId) {
Bundle extras = new Bundle(1);
extras.putInt(Intent.EXTRA_UID, UserHandle.getUid(userId, appId));
sendPackageBroadcast(Intent.ACTION_PACKAGE_ADDED, packageName, extras, 0, null, null, new int[] { userId });
try {
IActivityManager am = ActivityManagerNative.getDefault();
if (isSystem && am.isUserRunning(userId, 0)) {
// The just-installed/enabled app is bundled on the system, so presumed
// to be able to run automatically without needing an explicit launch.
// Send it a BOOT_COMPLETED if it would ordinarily have gotten one.
Intent bcIntent = new Intent(Intent.ACTION_BOOT_COMPLETED).addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES).setPackage(packageName);
am.broadcastIntent(null, bcIntent, null, null, 0, null, null, null, android.app.AppOpsManager.OP_NONE, null, false, false, userId);
}
} catch (RemoteException e) {
// shouldn't happen
Slog.w(TAG, "Unable to bootstrap installed package", e);
}
}
use of android.app.IActivityManager in project android_frameworks_base by ParanoidAndroid.
the class LocalePicker method updateLocale.
/**
* Requests the system to update the system locale. Note that the system looks halted
* for a while during the Locale migration, so the caller need to take care of it.
*/
public static void updateLocale(Locale locale) {
try {
IActivityManager am = ActivityManagerNative.getDefault();
Configuration config = am.getConfiguration();
// Will set userSetLocale to indicate this isn't some passing default - the user
// wants this remembered
config.setLocale(locale);
am.updateConfiguration(config);
// Trigger the dirty bit for the Settings Provider.
BackupManager.dataChanged("com.android.providers.settings");
} catch (RemoteException e) {
// Intentionally left blank
}
}
use of android.app.IActivityManager in project android_frameworks_base by AOSPA.
the class PhoneStatusBar method handleLongPressBackRecents.
/**
* This handles long-press of both back and recents. They are
* handled together to capture them both being long-pressed
* at the same time to exit screen pinning (lock task).
*
* When accessibility mode is on, only a long-press from recents
* is required to exit.
*
* In all other circumstances we try to pass through long-press events
* for Back, so that apps can still use it. Which can be from two things.
* 1) Not currently in screen pinning (lock task).
* 2) Back is long-pressed without recents.
*/
private boolean handleLongPressBackRecents(View v) {
try {
boolean sendBackLongPress = false;
IActivityManager activityManager = ActivityManagerNative.getDefault();
boolean touchExplorationEnabled = mAccessibilityManager.isTouchExplorationEnabled();
boolean inLockTaskMode = activityManager.isInLockTaskMode();
if (inLockTaskMode && !touchExplorationEnabled) {
long time = System.currentTimeMillis();
// long-pressed 'together'
if ((time - mLastLockToAppLongPress) < LOCK_TO_APP_GESTURE_TOLERENCE) {
activityManager.stopLockTaskMode();
// When exiting refresh disabled flags.
mNavigationBarView.setDisabledFlags(mDisabled1, true);
return true;
} else if ((v.getId() == R.id.back) && !mNavigationBarView.getRecentsButton().getCurrentView().isPressed()) {
// If we aren't pressing recents right now then they presses
// won't be together, so send the standard long-press action.
sendBackLongPress = true;
}
mLastLockToAppLongPress = time;
} else {
// If this is back still need to handle sending the long-press event.
if (v.getId() == R.id.back) {
sendBackLongPress = true;
} else if (touchExplorationEnabled && inLockTaskMode) {
// When in accessibility mode a long press that is recents (not back)
// should stop lock task.
activityManager.stopLockTaskMode();
// When exiting refresh disabled flags.
mNavigationBarView.setDisabledFlags(mDisabled1, true);
return true;
} else if (v.getId() == R.id.recent_apps) {
return handleLongPressRecents();
}
}
if (sendBackLongPress) {
KeyButtonView keyButtonView = (KeyButtonView) v;
keyButtonView.sendEvent(KeyEvent.ACTION_DOWN, KeyEvent.FLAG_LONG_PRESS);
keyButtonView.sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_LONG_CLICKED);
return true;
}
} catch (RemoteException e) {
Log.d(TAG, "Unable to reach activity manager", e);
}
return false;
}
use of android.app.IActivityManager in project android_frameworks_base by AOSPA.
the class OverlayManagerService method updateSelectedAssets.
private void updateSelectedAssets(final int userId, List<String> targetPackageNames) {
final PackageManagerInternal pm = LocalServices.getService(PackageManagerInternal.class);
final boolean updateFrameworkRes = targetPackageNames.contains("android");
if (updateFrameworkRes) {
targetPackageNames = pm.getTargetPackageNames(userId);
}
final Map<String, String[]> allPaths = new ArrayMap<>(targetPackageNames.size());
synchronized (mLock) {
final List<String> frameworkPaths = mImpl.onGetEnabledOverlayPaths("android", userId);
for (final String packageName : targetPackageNames) {
final List<String> paths = new ArrayList<>();
paths.addAll(frameworkPaths);
if (!"android".equals(packageName)) {
paths.addAll(mImpl.onGetEnabledOverlayPaths(packageName, userId));
}
allPaths.put(packageName, paths.isEmpty() ? null : paths.toArray(new String[paths.size()]));
}
}
for (String packageName : targetPackageNames) {
pm.setResourceDirs(userId, packageName, allPaths.get(packageName));
}
final IActivityManager am = ActivityManagerNative.getDefault();
try {
am.updateAssets(userId, targetPackageNames);
} catch (RemoteException e) {
// Intentionally left empty.
}
}
Aggregations