rethrowFromSystemServer ( )源码实例Demo

android.os.RemoteException#rethrowFromSystemServer ( )源码实例Demo

下面列出了android.os.RemoteException#rethrowFromSystemServer ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: android_9.0.0_r45   文件: AlarmManager.java
/**
 * Sets the system's persistent default time zone. This is the time zone for all apps, even
 * after a reboot. Use {@link java.util.TimeZone#setDefault} if you just want to change the
 * time zone within your app, and even then prefer to pass an explicit
 * {@link java.util.TimeZone} to APIs that require it rather than changing the time zone for
 * all threads.
 *
 * <p> On android M and above, it is an error to pass in a non-Olson timezone to this
 * function. Note that this is a bad idea on all Android releases because POSIX and
 * the {@code TimeZone} class have opposite interpretations of {@code '+'} and {@code '-'}
 * in the same non-Olson ID.
 *
 * @param timeZone one of the Olson ids from the list returned by
 *     {@link java.util.TimeZone#getAvailableIDs}
 */
public void setTimeZone(String timeZone) {
    if (TextUtils.isEmpty(timeZone)) {
        return;
    }

    // Reject this timezone if it isn't an Olson zone we recognize.
    if (mTargetSdkVersion >= Build.VERSION_CODES.M) {
        boolean hasTimeZone = false;
        try {
            hasTimeZone = ZoneInfoDB.getInstance().hasTimeZone(timeZone);
        } catch (IOException ignored) {
        }

        if (!hasTimeZone) {
            throw new IllegalArgumentException("Timezone: " + timeZone + " is not an Olson ID");
        }
    }

    try {
        mService.setTimeZone(timeZone);
    } catch (RemoteException ex) {
        throw ex.rethrowFromSystemServer();
    }
}
 
/** @hide Same as above but for a specific user */
@Override
@SuppressWarnings("unchecked")
public List<ResolveInfo> queryIntentActivitiesAsUser(Intent intent,
        int flags, int userId) {
    try {
        ParceledListSlice<ResolveInfo> parceledList =
                mPM.queryIntentActivities(intent,
                        intent.resolveTypeIfNeeded(mContext.getContentResolver()),
                        flags, userId);
        if (parceledList == null) {
            return Collections.emptyList();
        }
        return parceledList.getList();
    } catch (RemoteException e) {
        throw e.rethrowFromSystemServer();
    }
}
 
@Override
@SuppressWarnings("unchecked")
public List<PermissionInfo> queryPermissionsByGroup(String group, int flags)
        throws NameNotFoundException {
    try {
        ParceledListSlice<PermissionInfo> parceledList =
                mPM.queryPermissionsByGroup(group, flags);
        if (parceledList != null) {
            List<PermissionInfo> pi = parceledList.getList();
            if (pi != null) {
                return pi;
            }
        }
    } catch (RemoteException e) {
        throw e.rethrowFromSystemServer();
    }

    throw new NameNotFoundException(group);
}
 
源代码4 项目: android_9.0.0_r45   文件: PrintManager.java
/**
 * Gets a print job given its id.
 *
 * @param printJobId The id of the print job.
 * @return The print job list.
 * @see PrintJob
 * @hide
 */
public PrintJob getPrintJob(PrintJobId printJobId) {
    if (mService == null) {
        Log.w(LOG_TAG, "Feature android.software.print not available");
        return null;
    }
    try {
        PrintJobInfo printJob = mService.getPrintJobInfo(printJobId, mAppId, mUserId);
        if (printJob != null) {
            return new PrintJob(printJob, this);
        }
    } catch (RemoteException re) {
        throw re.rethrowFromSystemServer();
    }
    return null;
}
 
@Override
public boolean hasSigningCertificate(
        int uid, byte[] certificate, @PackageManager.CertificateInputType int type) {
    try {
        return mPM.hasUidSigningCertificate(uid, certificate, type);
    } catch (RemoteException e) {
        throw e.rethrowFromSystemServer();
    }
}
 
@Override
public void addPreferredActivity(IntentFilter filter,
                                 int match, ComponentName[] set, ComponentName activity) {
    try {
        mPM.addPreferredActivity(filter, match, set, activity, mContext.getUserId());
    } catch (RemoteException e) {
        throw e.rethrowFromSystemServer();
    }
}
 
private void installCommon(Uri packageURI,
        PackageInstallObserver observer, int flags, String installerPackageName,
        int userId) {
    if (!"file".equals(packageURI.getScheme())) {
        throw new UnsupportedOperationException("Only file:// URIs are supported");
    }

    final String originPath = packageURI.getPath();
    try {
        mPM.installPackageAsUser(originPath, observer.getBinder(), flags, installerPackageName,
                userId);
    } catch (RemoteException e) {
        throw e.rethrowFromSystemServer();
    }
}
 
/**
 * @hide
 */
public @NonNull String getSharedSystemSharedLibraryPackageName() {
    try {
        return mPM.getSharedSystemSharedLibraryPackageName();
    } catch (RemoteException e) {
        throw e.rethrowFromSystemServer();
    }
}
 
@Override
public int getPreferredActivities(List<IntentFilter> outFilters,
                                  List<ComponentName> outActivities, String packageName) {
    try {
        return mPM.getPreferredActivities(outFilters, outActivities, packageName);
    } catch (RemoteException e) {
        throw e.rethrowFromSystemServer();
    }
}
 
源代码10 项目: android_9.0.0_r45   文件: TrafficStats.java
/** {@hide} */
public static long getMobileTcpRxPackets() {
    long total = 0;
    for (String iface : getMobileIfaces()) {
        long stat = UNSUPPORTED;
        try {
            stat = getStatsService().getIfaceStats(iface, TYPE_TCP_RX_PACKETS);
        } catch (RemoteException e) {
            throw e.rethrowFromSystemServer();
        }
        total += addIfSupported(stat);
    }
    return total;
}
 
源代码11 项目: AndroidComponentPlugin   文件: ContextImpl.java
void sendOrderedBroadcast(Intent intent,
        String receiverPermission, int appOp, BroadcastReceiver resultReceiver,
        Handler scheduler, int initialCode, String initialData,
        Bundle initialExtras, Bundle options) {
    warnIfCallingFromSystemProcess();
    IIntentReceiver rd = null;
    if (resultReceiver != null) {
        if (mPackageInfo != null) {
            if (scheduler == null) {
                scheduler = mMainThread.getHandler();
            }
            rd = mPackageInfo.getReceiverDispatcher(
                resultReceiver, getOuterContext(), scheduler,
                mMainThread.getInstrumentation(), false);
        } else {
            if (scheduler == null) {
                scheduler = mMainThread.getHandler();
            }
            rd = new LoadedApk.ReceiverDispatcher(
                    resultReceiver, getOuterContext(), scheduler, null, false).getIIntentReceiver();
        }
    }
    String resolvedType = intent.resolveTypeIfNeeded(getContentResolver());
    String[] receiverPermissions = receiverPermission == null ? null
            : new String[] {receiverPermission};
    try {
        intent.prepareToLeaveProcess(this);
        ActivityManagerNative.getDefault().broadcastIntent(
            mMainThread.getApplicationThread(), intent, resolvedType, rd,
            initialCode, initialData, initialExtras, receiverPermissions, appOp,
                options, true, false, getUserId());
    } catch (RemoteException e) {
        throw e.rethrowFromSystemServer();
    }
}
 
@Override
public ArtManager getArtManager() {
    synchronized (mLock) {
        if (mArtManager == null) {
            try {
                mArtManager = new ArtManager(mContext, mPM.getArtManager());
            } catch (RemoteException e) {
                throw e.rethrowFromSystemServer();
            }
        }
        return mArtManager;
    }
}
 
/** @hide */
@Override
public Drawable getInstantAppIcon(String packageName) {
    try {
        Bitmap bitmap = mPM.getInstantAppIcon(packageName, getUserId());
        if (bitmap != null) {
            return new BitmapDrawable(null, bitmap);
        }
        return null;
    } catch (RemoteException e) {
        throw e.rethrowFromSystemServer();
    }
}
 
@Override
public void deleteApplicationCacheFiles(String packageName,
                                        IPackageDataObserver observer) {
    try {
        mPM.deleteApplicationCacheFiles(packageName, observer);
    } catch (RemoteException e) {
        throw e.rethrowFromSystemServer();
    }
}
 
源代码15 项目: android_9.0.0_r45   文件: NotificationManager.java
/** @hide */
public void setNotificationListenerAccessGrantedForUser(ComponentName listener, int userId,
        boolean granted) {
    INotificationManager service = getService();
    try {
        service.setNotificationListenerAccessGrantedForUser(listener, userId, granted);
    } catch (RemoteException e) {
        throw e.rethrowFromSystemServer();
    }
}
 
/**
 * @hide
 */
@Override
public void addCrossProfileIntentFilter(IntentFilter filter, int sourceUserId, int targetUserId,
        int flags) {
    try {
        mPM.addCrossProfileIntentFilter(filter, mContext.getOpPackageName(),
                sourceUserId, targetUserId, flags);
    } catch (RemoteException e) {
        throw e.rethrowFromSystemServer();
    }
}
 
源代码17 项目: android_9.0.0_r45   文件: InputMethodManager.java
/**
 * @hide
 */
public void hideStatusIconInternal(IBinder imeToken) {
    try {
        mService.updateStatusIcon(imeToken, null, 0);
    } catch (RemoteException e) {
        throw e.rethrowFromSystemServer();
    }
}
 
源代码18 项目: android_9.0.0_r45   文件: AppOpsManager.java
/**
 * Like {@link #noteProxyOp(int, String)} but instead
 * of throwing a {@link SecurityException} it returns {@link #MODE_ERRORED}.
 * @hide
 */
public int noteProxyOpNoThrow(int op, String proxiedPackageName) {
    try {
        return mService.noteProxyOperation(op, mContext.getOpPackageName(),
                Binder.getCallingUid(), proxiedPackageName);
    } catch (RemoteException e) {
        throw e.rethrowFromSystemServer();
    }
}
 
源代码19 项目: android_9.0.0_r45   文件: WallpaperManager.java
/**
 * Return whether any users are currently set to use the wallpaper
 * with the given resource ID.  That is, their wallpaper has been
 * set through {@link #setResource(int)} with the same resource id.
 */
public boolean hasResourceWallpaper(@RawRes int resid) {
    if (sGlobals.mService == null) {
        Log.w(TAG, "WallpaperService not running");
        throw new RuntimeException(new DeadSystemException());
    }
    try {
        Resources resources = mContext.getResources();
        String name = "res:" + resources.getResourceName(resid);
        return sGlobals.mService.hasNamedWallpaper(name);
    } catch (RemoteException e) {
        throw e.rethrowFromSystemServer();
    }
}
 
源代码20 项目: android_9.0.0_r45   文件: AppWidgetManager.java
/**
 * Update the extras for a given widget instance.
 * <p>
 * The extras can be used to embed additional information about this widget to be accessed
 * by the associated widget's AppWidgetProvider.
 *
 * @see #getAppWidgetOptions(int)
 *
 * @param appWidgetId The AppWidget instances for which to set the RemoteViews.
 * @param options The options to associate with this widget
 */
public void updateAppWidgetOptions(int appWidgetId, Bundle options) {
    if (mService == null) {
        return;
    }
    try {
        mService.updateAppWidgetOptions(mPackageName, appWidgetId, options);
    } catch (RemoteException e) {
        throw e.rethrowFromSystemServer();
    }
}
 
如果文章对您有帮助,请点击页面广告。以鼓励作者做出的努力。
 方法所在类