use of android.app.IActivityManager in project android_frameworks_base by ResurrectionRemix.
the class BroadcastReceiver method peekService.
/**
* Provide a binder to an already-bound service. This method is synchronous
* and will not start the target service if it is not present, so it is safe
* to call from {@link #onReceive}.
*
* For peekService() to return a non null {@link android.os.IBinder} interface
* the service must have published it before. In other words some component
* must have called {@link android.content.Context#bindService(Intent, ServiceConnection, int)} on it.
*
* @param myContext The Context that had been passed to {@link #onReceive(Context, Intent)}
* @param service Identifies the already-bound service you wish to use. See
* {@link android.content.Context#bindService(Intent, ServiceConnection, int)}
* for more information.
*/
public IBinder peekService(Context myContext, Intent service) {
IActivityManager am = ActivityManagerNative.getDefault();
IBinder binder = null;
try {
service.prepareToLeaveProcess(myContext);
binder = am.peekService(service, service.resolveTypeIfNeeded(myContext.getContentResolver()), myContext.getOpPackageName());
} catch (RemoteException e) {
}
return binder;
}
use of android.app.IActivityManager in project android_frameworks_base by ResurrectionRemix.
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.
}
}
use of android.app.IActivityManager in project android_frameworks_base by ResurrectionRemix.
the class UserManagerService method runList.
private int runList(PrintWriter pw) throws RemoteException {
final IActivityManager am = ActivityManagerNative.getDefault();
final List<UserInfo> users = getUsers(false);
if (users == null) {
pw.println("Error: couldn't get users");
return 1;
} else {
pw.println("Users:");
for (int i = 0; i < users.size(); i++) {
String running = am.isUserRunning(users.get(i).id, 0) ? " running" : "";
pw.println("\t" + users.get(i).toString() + running);
}
return 0;
}
}
use of android.app.IActivityManager in project android_frameworks_base by DirtyUnicorns.
the class LocalePicker method updateLocales.
/**
* Requests the system to update the list of system locales.
* 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 updateLocales(LocaleList locales) {
try {
final IActivityManager am = ActivityManagerNative.getDefault();
final Configuration config = am.getConfiguration();
config.setLocales(locales);
config.userSetLocale = true;
am.updatePersistentConfiguration(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 ResurrectionRemix.
the class StrictMode method dropboxViolationAsync.
/**
* In the common case, as set by conditionallyEnableDebugLogging,
* we're just dropboxing any violations but not showing a dialog,
* not loggging, and not killing the process. In these cases we
* don't need to do a synchronous call to the ActivityManager.
* This is used by both per-thread and vm-wide violations when
* applicable.
*/
private static void dropboxViolationAsync(final int violationMaskSubset, final ViolationInfo info) {
int outstanding = sDropboxCallsInFlight.incrementAndGet();
if (outstanding > 20) {
// What's going on? Let's not make make the situation
// worse and just not log.
sDropboxCallsInFlight.decrementAndGet();
return;
}
if (LOG_V)
Log.d(TAG, "Dropboxing async; in-flight=" + outstanding);
new Thread("callActivityManagerForStrictModeDropbox") {
public void run() {
Process.setThreadPriority(Process.THREAD_PRIORITY_BACKGROUND);
try {
IActivityManager am = ActivityManagerNative.getDefault();
if (am == null) {
Log.d(TAG, "No activity manager; failed to Dropbox violation.");
} else {
am.handleApplicationStrictModeViolation(RuntimeInit.getApplicationObject(), violationMaskSubset, info);
}
} catch (RemoteException e) {
if (e instanceof DeadObjectException) {
// System process is dead; ignore
} else {
Log.e(TAG, "RemoteException handling StrictMode violation", e);
}
}
int outstanding = sDropboxCallsInFlight.decrementAndGet();
if (LOG_V)
Log.d(TAG, "Dropbox complete; in-flight=" + outstanding);
}
}.start();
}
Aggregations