Search in sources :

Example 21 with RemoteException

use of android.os.RemoteException in project android_frameworks_base by ParanoidAndroid.

the class ActivityThread method handleSleeping.

private void handleSleeping(IBinder token, boolean sleeping) {
    ActivityClientRecord r = mActivities.get(token);
    if (r == null) {
        Log.w(TAG, "handleSleeping: no activity for token " + token);
        return;
    }
    if (sleeping) {
        if (!r.stopped && !r.isPreHoneycomb()) {
            try {
                // Now we are idle.
                r.activity.performStop();
            } catch (Exception e) {
                if (!mInstrumentation.onException(r.activity, e)) {
                    throw new RuntimeException("Unable to stop activity " + r.intent.getComponent().toShortString() + ": " + e.toString(), e);
                }
            }
            r.stopped = true;
        }
        // Make sure any pending writes are now committed.
        if (!r.isPreHoneycomb()) {
            QueuedWork.waitToFinish();
        }
        // Tell activity manager we slept.
        try {
            ActivityManagerNative.getDefault().activitySlept(r.token);
        } catch (RemoteException ex) {
        }
    } else {
        if (r.stopped && r.activity.mVisibleFromServer) {
            r.activity.performRestart();
            r.stopped = false;
        }
    }
}
Also used : AndroidRuntimeException(android.util.AndroidRuntimeException) RemoteException(android.os.RemoteException) InflateException(android.view.InflateException) RemoteException(android.os.RemoteException) IOException(java.io.IOException) AndroidRuntimeException(android.util.AndroidRuntimeException) NameNotFoundException(android.content.pm.PackageManager.NameNotFoundException)

Example 22 with RemoteException

use of android.os.RemoteException in project android_frameworks_base by ParanoidAndroid.

the class ActivityThread method attachThemeAssets.

/**
     * Attach the necessary theme asset paths and meta information to convert an
     * AssetManager to being globally "theme-aware".
     *
     * @param assets
     * @param theme
     * @return true if the AssetManager is now theme-aware; false otherwise.
     *         This can fail, for example, if the theme package has been been
     *         removed and the theme manager has yet to revert formally back to
     *         the framework default.
     */
private boolean attachThemeAssets(AssetManager assets, CustomTheme theme) {
    IAssetRedirectionManager rm = getAssetRedirectionManager();
    if (rm == null) {
        return false;
    }
    PackageInfo pi = null;
    try {
        pi = getPackageManager().getPackageInfo(theme.getThemePackageName(), 0, UserHandle.myUserId());
    } catch (RemoteException e) {
    }
    if (pi != null && pi.applicationInfo != null && pi.themeInfos != null) {
        String themeResDir = pi.applicationInfo.publicSourceDir;
        int cookie = assets.attachThemePath(themeResDir);
        if (cookie != 0) {
            String themePackageName = theme.getThemePackageName();
            String themeId = theme.getThemeId();
            int N = assets.getBasePackageCount();
            for (int i = 0; i < N; i++) {
                String packageName = assets.getBasePackageName(i);
                int packageId = assets.getBasePackageId(i);
                /*
                     * For now, we only consider redirections coming from the
                     * framework or regular android packages. This excludes
                     * themes and other specialty APKs we are not aware of.
                     */
                if (packageId != 0x01 && packageId != 0x7f) {
                    continue;
                }
                try {
                    PackageRedirectionMap map = rm.getPackageRedirectionMap(themePackageName, themeId, packageName);
                    if (map != null) {
                        assets.addRedirections(map);
                    }
                } catch (RemoteException e) {
                    Log.e(TAG, "Failure accessing package redirection map, removing theme support.");
                    assets.detachThemePath(themePackageName, cookie);
                    return false;
                }
            }
            assets.setThemePackageName(theme.getThemePackageName());
            assets.setThemeCookie(cookie);
            return true;
        } else {
            Log.e(TAG, "Unable to attach theme assets at " + themeResDir);
        }
    }
    return false;
}
Also used : PackageInfo(android.content.pm.PackageInfo) PackageRedirectionMap(android.content.res.PackageRedirectionMap) IAssetRedirectionManager(com.android.internal.app.IAssetRedirectionManager) RemoteException(android.os.RemoteException)

Example 23 with RemoteException

use of android.os.RemoteException in project android_frameworks_base by ParanoidAndroid.

the class ActivityThread method acquireProvider.

public final IContentProvider acquireProvider(Context c, String auth, int userId, boolean stable) {
    final IContentProvider provider = acquireExistingProvider(c, auth, userId, stable);
    if (provider != null) {
        return provider;
    }
    // There is a possible race here.  Another thread may try to acquire
    // the same provider at the same time.  When this happens, we want to ensure
    // that the first one wins.
    // Note that we cannot hold the lock while acquiring and installing the
    // provider since it might take a long time to run and it could also potentially
    // be re-entrant in the case where the provider is in the same process.
    IActivityManager.ContentProviderHolder holder = null;
    try {
        holder = ActivityManagerNative.getDefault().getContentProvider(getApplicationThread(), auth, userId, stable);
    } catch (RemoteException ex) {
    }
    if (holder == null) {
        Slog.e(TAG, "Failed to find provider info for " + auth);
        return null;
    }
    // Install provider will increment the reference count for us, and break
    // any ties in the race.
    holder = installProvider(c, holder, holder.info, true, /*noisy*/
    holder.noReleaseNeeded, stable);
    return holder.provider;
}
Also used : IContentProvider(android.content.IContentProvider) RemoteException(android.os.RemoteException)

Example 24 with RemoteException

use of android.os.RemoteException in project android_frameworks_base by ParanoidAndroid.

the class ActivityThread method handleStopService.

private void handleStopService(IBinder token) {
    Service s = mServices.remove(token);
    if (s != null) {
        try {
            if (localLOGV)
                Slog.v(TAG, "Destroying service " + s);
            s.onDestroy();
            Context context = s.getBaseContext();
            if (context instanceof ContextImpl) {
                final String who = s.getClassName();
                ((ContextImpl) context).scheduleFinalCleanup(who, "Service");
            }
            QueuedWork.waitToFinish();
            try {
                ActivityManagerNative.getDefault().serviceDoneExecuting(token, 0, 0, 0);
            } catch (RemoteException e) {
            // nothing to do.
            }
        } catch (Exception e) {
            if (!mInstrumentation.onException(s, e)) {
                throw new RuntimeException("Unable to stop service " + s + ": " + e.toString(), e);
            }
        }
    }
//Slog.i(TAG, "Running services: " + mServices);
}
Also used : Context(android.content.Context) AndroidRuntimeException(android.util.AndroidRuntimeException) RemoteException(android.os.RemoteException) InflateException(android.view.InflateException) RemoteException(android.os.RemoteException) IOException(java.io.IOException) AndroidRuntimeException(android.util.AndroidRuntimeException) NameNotFoundException(android.content.pm.PackageManager.NameNotFoundException)

Example 25 with RemoteException

use of android.os.RemoteException in project android_frameworks_base by ParanoidAndroid.

the class ActivityThread method installContentProviders.

private void installContentProviders(Context context, List<ProviderInfo> providers) {
    final ArrayList<IActivityManager.ContentProviderHolder> results = new ArrayList<IActivityManager.ContentProviderHolder>();
    for (ProviderInfo cpi : providers) {
        if (DEBUG_PROVIDER) {
            StringBuilder buf = new StringBuilder(128);
            buf.append("Pub ");
            buf.append(cpi.authority);
            buf.append(": ");
            buf.append(cpi.name);
            Log.i(TAG, buf.toString());
        }
        IActivityManager.ContentProviderHolder cph = installProvider(context, null, cpi, false, /*noisy*/
        true, /*noReleaseNeeded*/
        true);
        if (cph != null) {
            cph.noReleaseNeeded = true;
            results.add(cph);
        }
    }
    try {
        ActivityManagerNative.getDefault().publishContentProviders(getApplicationThread(), results);
    } catch (RemoteException ex) {
    }
}
Also used : ProviderInfo(android.content.pm.ProviderInfo) ArrayList(java.util.ArrayList) RemoteException(android.os.RemoteException)

Aggregations

RemoteException (android.os.RemoteException)4527 Intent (android.content.Intent)595 IBinder (android.os.IBinder)480 Bundle (android.os.Bundle)461 Point (android.graphics.Point)423 IOException (java.io.IOException)381 PendingIntent (android.app.PendingIntent)274 ComponentName (android.content.ComponentName)265 ArrayList (java.util.ArrayList)248 ApplicationInfo (android.content.pm.ApplicationInfo)190 IPackageManager (android.content.pm.IPackageManager)190 Message (android.os.Message)184 Uri (android.net.Uri)157 UserHandle (android.os.UserHandle)154 NameNotFoundException (android.content.pm.PackageManager.NameNotFoundException)151 Cursor (android.database.Cursor)150 Configuration (android.content.res.Configuration)133 UserInfo (android.content.pm.UserInfo)129 AndroidRuntimeException (android.util.AndroidRuntimeException)128 ParcelFileDescriptor (android.os.ParcelFileDescriptor)126