Search in sources :

Example 21 with AndroidRuntimeException

use of android.util.AndroidRuntimeException in project android_frameworks_base by ResurrectionRemix.

the class WebViewFactory method getProviderClass.

private static Class<WebViewFactoryProvider> getProviderClass() {
    Context webViewContext = null;
    Application initialApplication = AppGlobals.getInitialApplication();
    try {
        Trace.traceBegin(Trace.TRACE_TAG_WEBVIEW, "WebViewFactory.getWebViewContextAndSetProvider()");
        try {
            webViewContext = getWebViewContextAndSetProvider();
        } finally {
            Trace.traceEnd(Trace.TRACE_TAG_WEBVIEW);
        }
        Log.i(LOGTAG, "Loading " + sPackageInfo.packageName + " version " + sPackageInfo.versionName + " (code " + sPackageInfo.versionCode + ")");
        Trace.traceBegin(Trace.TRACE_TAG_WEBVIEW, "WebViewFactory.getChromiumProviderClass()");
        try {
            initialApplication.getAssets().addAssetPathAsSharedLibrary(webViewContext.getApplicationInfo().sourceDir);
            ClassLoader clazzLoader = webViewContext.getClassLoader();
            Trace.traceBegin(Trace.TRACE_TAG_WEBVIEW, "WebViewFactory.loadNativeLibrary()");
            loadNativeLibrary(clazzLoader);
            Trace.traceEnd(Trace.TRACE_TAG_WEBVIEW);
            Trace.traceBegin(Trace.TRACE_TAG_WEBVIEW, "Class.forName()");
            try {
                return (Class<WebViewFactoryProvider>) Class.forName(CHROMIUM_WEBVIEW_FACTORY, true, clazzLoader);
            } finally {
                Trace.traceEnd(Trace.TRACE_TAG_WEBVIEW);
            }
        } catch (ClassNotFoundException e) {
            Log.e(LOGTAG, "error loading provider", e);
            throw new AndroidRuntimeException(e);
        } finally {
            Trace.traceEnd(Trace.TRACE_TAG_WEBVIEW);
        }
    } catch (MissingWebViewPackageException e) {
        // original exception.
        try {
            return (Class<WebViewFactoryProvider>) Class.forName(NULL_WEBVIEW_FACTORY);
        } catch (ClassNotFoundException e2) {
        // Ignore.
        }
        Log.e(LOGTAG, "Chromium WebView package does not exist", e);
        throw new AndroidRuntimeException(e);
    }
}
Also used : Context(android.content.Context) AndroidRuntimeException(android.util.AndroidRuntimeException) Application(android.app.Application)

Example 22 with AndroidRuntimeException

use of android.util.AndroidRuntimeException in project android_frameworks_base by ResurrectionRemix.

the class AudioService method killBackgroundUserProcessesWithRecordAudioPermission.

// end class AudioServiceUserRestrictionsListener
private void killBackgroundUserProcessesWithRecordAudioPermission(UserInfo oldUser) {
    PackageManager pm = mContext.getPackageManager();
    // Find the home activity of the user. It should not be killed to avoid expensive restart,
    // when the user switches back. For managed profiles, we should kill all recording apps
    ComponentName homeActivityName = null;
    if (!oldUser.isManagedProfile()) {
        homeActivityName = LocalServices.getService(ActivityManagerInternal.class).getHomeActivityForUser(oldUser.id);
    }
    final String[] permissions = { Manifest.permission.RECORD_AUDIO };
    List<PackageInfo> packages;
    try {
        packages = AppGlobals.getPackageManager().getPackagesHoldingPermissions(permissions, 0, oldUser.id).getList();
    } catch (RemoteException e) {
        throw new AndroidRuntimeException(e);
    }
    for (int j = packages.size() - 1; j >= 0; j--) {
        PackageInfo pkg = packages.get(j);
        // Skip system processes
        if (UserHandle.getAppId(pkg.applicationInfo.uid) < FIRST_APPLICATION_UID) {
            continue;
        }
        // Skip packages that have permission to interact across users
        if (pm.checkPermission(Manifest.permission.INTERACT_ACROSS_USERS, pkg.packageName) == PackageManager.PERMISSION_GRANTED) {
            continue;
        }
        if (homeActivityName != null && pkg.packageName.equals(homeActivityName.getPackageName()) && pkg.applicationInfo.isSystemApp()) {
            continue;
        }
        try {
            final int uid = pkg.applicationInfo.uid;
            ActivityManagerNative.getDefault().killUid(UserHandle.getAppId(uid), UserHandle.getUserId(uid), "killBackgroundUserProcessesWithAudioRecordPermission");
        } catch (RemoteException e) {
            Log.w(TAG, "Error calling killUid", e);
        }
    }
}
Also used : AndroidRuntimeException(android.util.AndroidRuntimeException) PackageManager(android.content.pm.PackageManager) PackageInfo(android.content.pm.PackageInfo) ComponentName(android.content.ComponentName) RemoteException(android.os.RemoteException)

Example 23 with AndroidRuntimeException

use of android.util.AndroidRuntimeException in project android_frameworks_base by crdroidandroid.

the class WebViewFactory method getProviderClass.

private static Class<WebViewFactoryProvider> getProviderClass() {
    Context webViewContext = null;
    Application initialApplication = AppGlobals.getInitialApplication();
    try {
        Trace.traceBegin(Trace.TRACE_TAG_WEBVIEW, "WebViewFactory.getWebViewContextAndSetProvider()");
        try {
            webViewContext = getWebViewContextAndSetProvider();
        } finally {
            Trace.traceEnd(Trace.TRACE_TAG_WEBVIEW);
        }
        Log.i(LOGTAG, "Loading " + sPackageInfo.packageName + " version " + sPackageInfo.versionName + " (code " + sPackageInfo.versionCode + ")");
        Trace.traceBegin(Trace.TRACE_TAG_WEBVIEW, "WebViewFactory.getChromiumProviderClass()");
        try {
            initialApplication.getAssets().addAssetPathAsSharedLibrary(webViewContext.getApplicationInfo().sourceDir);
            ClassLoader clazzLoader = webViewContext.getClassLoader();
            Trace.traceBegin(Trace.TRACE_TAG_WEBVIEW, "WebViewFactory.loadNativeLibrary()");
            loadNativeLibrary(clazzLoader);
            Trace.traceEnd(Trace.TRACE_TAG_WEBVIEW);
            Trace.traceBegin(Trace.TRACE_TAG_WEBVIEW, "Class.forName()");
            try {
                return (Class<WebViewFactoryProvider>) Class.forName(CHROMIUM_WEBVIEW_FACTORY, true, clazzLoader);
            } finally {
                Trace.traceEnd(Trace.TRACE_TAG_WEBVIEW);
            }
        } catch (ClassNotFoundException e) {
            Log.e(LOGTAG, "error loading provider", e);
            throw new AndroidRuntimeException(e);
        } finally {
            Trace.traceEnd(Trace.TRACE_TAG_WEBVIEW);
        }
    } catch (MissingWebViewPackageException e) {
        // original exception.
        try {
            return (Class<WebViewFactoryProvider>) Class.forName(NULL_WEBVIEW_FACTORY);
        } catch (ClassNotFoundException e2) {
        // Ignore.
        }
        Log.e(LOGTAG, "Chromium WebView package does not exist", e);
        throw new AndroidRuntimeException(e);
    }
}
Also used : Context(android.content.Context) AndroidRuntimeException(android.util.AndroidRuntimeException) Application(android.app.Application)

Aggregations

AndroidRuntimeException (android.util.AndroidRuntimeException)23 RemoteException (android.os.RemoteException)10 Application (android.app.Application)5 AutomaticZenRule (android.app.AutomaticZenRule)5 ComponentName (android.content.ComponentName)5 Context (android.content.Context)5 PackageInfo (android.content.pm.PackageInfo)5 PackageManager (android.content.pm.PackageManager)5 ServiceInfo (android.content.pm.ServiceInfo)5 StrictMode (android.os.StrictMode)5 ZenModeConfig (android.service.notification.ZenModeConfig)5 ZenRule (android.service.notification.ZenModeConfig.ZenRule)5 IOException (java.io.IOException)5 List (java.util.List)1