Search in sources :

Example 11 with RemoteException

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

the class Pm method displayPackageFilePath.

/**
     * Displays the package file for a package.
     * @param pckg
     */
private void displayPackageFilePath(String pckg) {
    try {
        PackageInfo info = mPm.getPackageInfo(pckg, 0, 0);
        if (info != null && info.applicationInfo != null) {
            System.out.print("package:");
            System.out.println(info.applicationInfo.sourceDir);
        }
    } catch (RemoteException e) {
        System.err.println(e.toString());
        System.err.println(PM_NOT_RUNNING_ERR);
    }
}
Also used : PackageInfo(android.content.pm.PackageInfo) RemoteException(android.os.RemoteException)

Example 12 with RemoteException

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

the class Pm method runListPackages.

/**
     * Lists all the installed packages.
     */
private void runListPackages(boolean showApplicationPackage) {
    int getFlags = 0;
    boolean listDisabled = false, listEnabled = false;
    boolean listSystem = false, listThirdParty = false;
    boolean listInstaller = false;
    int userId = UserHandle.USER_OWNER;
    try {
        String opt;
        while ((opt = nextOption()) != null) {
            if (opt.equals("-l")) {
            // old compat
            } else if (opt.equals("-lf")) {
                showApplicationPackage = true;
            } else if (opt.equals("-f")) {
                showApplicationPackage = true;
            } else if (opt.equals("-d")) {
                listDisabled = true;
            } else if (opt.equals("-e")) {
                listEnabled = true;
            } else if (opt.equals("-s")) {
                listSystem = true;
            } else if (opt.equals("-3")) {
                listThirdParty = true;
            } else if (opt.equals("-i")) {
                listInstaller = true;
            } else if (opt.equals("--user")) {
                userId = Integer.parseInt(nextArg());
            } else if (opt.equals("-u")) {
                getFlags |= PackageManager.GET_UNINSTALLED_PACKAGES;
            } else {
                System.err.println("Error: Unknown option: " + opt);
                return;
            }
        }
    } catch (RuntimeException ex) {
        System.err.println("Error: " + ex.toString());
        return;
    }
    String filter = nextArg();
    try {
        final List<PackageInfo> packages = getInstalledPackages(mPm, getFlags, userId);
        int count = packages.size();
        for (int p = 0; p < count; p++) {
            PackageInfo info = packages.get(p);
            if (filter != null && !info.packageName.contains(filter)) {
                continue;
            }
            final boolean isSystem = (info.applicationInfo.flags & ApplicationInfo.FLAG_SYSTEM) != 0;
            if ((!listDisabled || !info.applicationInfo.enabled) && (!listEnabled || info.applicationInfo.enabled) && (!listSystem || isSystem) && (!listThirdParty || !isSystem)) {
                System.out.print("package:");
                if (showApplicationPackage) {
                    System.out.print(info.applicationInfo.sourceDir);
                    System.out.print("=");
                }
                System.out.print(info.packageName);
                if (listInstaller) {
                    System.out.print("  installer=");
                    System.out.print(mPm.getInstallerPackageName(info.packageName));
                }
                System.out.println();
            }
        }
    } catch (RemoteException e) {
        System.err.println(e.toString());
        System.err.println(PM_NOT_RUNNING_ERR);
    }
}
Also used : PackageInfo(android.content.pm.PackageInfo) RemoteException(android.os.RemoteException)

Example 13 with RemoteException

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

the class SettingsCmd method putForUser.

void putForUser(IContentProvider provider, int userHandle, final String table, final String key, final String value) {
    final String callPutCommand;
    if ("system".equals(table))
        callPutCommand = Settings.CALL_METHOD_PUT_SYSTEM;
    else if ("secure".equals(table))
        callPutCommand = Settings.CALL_METHOD_PUT_SECURE;
    else if ("global".equals(table))
        callPutCommand = Settings.CALL_METHOD_PUT_GLOBAL;
    else {
        System.err.println("Invalid table; no put performed");
        return;
    }
    try {
        Bundle arg = new Bundle();
        arg.putString(Settings.NameValueTable.VALUE, value);
        arg.putInt(Settings.CALL_METHOD_USER_KEY, userHandle);
        provider.call(null, callPutCommand, key, arg);
    } catch (RemoteException e) {
        System.err.println("Can't set key " + key + " in " + table + " for user " + userHandle);
    }
}
Also used : Bundle(android.os.Bundle) RemoteException(android.os.RemoteException)

Example 14 with RemoteException

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

the class DataCommand method run.

public void run(String[] args) {
    boolean validCommand = false;
    if (args.length >= 2) {
        boolean flag = false;
        if ("enable".equals(args[1])) {
            flag = true;
            validCommand = true;
        } else if ("disable".equals(args[1])) {
            flag = false;
            validCommand = true;
        } else if ("prefer".equals(args[1])) {
            IConnectivityManager connMgr = IConnectivityManager.Stub.asInterface(ServiceManager.getService(Context.CONNECTIVITY_SERVICE));
            try {
                connMgr.setNetworkPreference(ConnectivityManager.TYPE_MOBILE);
            } catch (RemoteException e) {
                System.err.println("Failed to set preferred network: " + e);
            }
            return;
        }
        if (validCommand) {
            ITelephony phoneMgr = ITelephony.Stub.asInterface(ServiceManager.getService(Context.TELEPHONY_SERVICE));
            try {
                if (flag) {
                    phoneMgr.enableDataConnectivity();
                } else
                    phoneMgr.disableDataConnectivity();
            } catch (RemoteException e) {
                System.err.println("Mobile data operation failed: " + e);
            }
            return;
        }
    }
    System.err.println(longHelp());
}
Also used : IConnectivityManager(android.net.IConnectivityManager) RemoteException(android.os.RemoteException) ITelephony(com.android.internal.telephony.ITelephony)

Example 15 with RemoteException

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

the class Wm method runDisplaySize.

private void runDisplaySize() throws Exception {
    String size = nextArg();
    int w, h;
    if (size == null) {
        Point initialSize = new Point();
        Point baseSize = new Point();
        try {
            mWm.getInitialDisplaySize(Display.DEFAULT_DISPLAY, initialSize);
            mWm.getBaseDisplaySize(Display.DEFAULT_DISPLAY, baseSize);
            System.out.println("Physical size: " + initialSize.x + "x" + initialSize.y);
            if (!initialSize.equals(baseSize)) {
                System.out.println("Override size: " + baseSize.x + "x" + baseSize.y);
            }
        } catch (RemoteException e) {
        }
        return;
    } else if ("reset".equals(size)) {
        w = h = -1;
    } else {
        int div = size.indexOf('x');
        if (div <= 0 || div >= (size.length() - 1)) {
            System.err.println("Error: bad size " + size);
            return;
        }
        String wstr = size.substring(0, div);
        String hstr = size.substring(div + 1);
        try {
            w = Integer.parseInt(wstr);
            h = Integer.parseInt(hstr);
        } catch (NumberFormatException e) {
            System.err.println("Error: bad number " + e);
            return;
        }
    }
    try {
        if (w >= 0 && h >= 0) {
            // TODO(multidisplay): For now Configuration only applies to main screen.
            mWm.setForcedDisplaySize(Display.DEFAULT_DISPLAY, w, h);
        } else {
            mWm.clearForcedDisplaySize(Display.DEFAULT_DISPLAY);
        }
    } catch (RemoteException e) {
    }
}
Also used : Point(android.graphics.Point) RemoteException(android.os.RemoteException) Point(android.graphics.Point)

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