public final class AssetManager implements java.lang.AutoCloseable {
method public void close();
- method public final java.lang.String[] getLocales();
- method public final java.lang.String[] list(java.lang.String) throws java.io.IOException;
- method public final java.io.InputStream open(java.lang.String) throws java.io.IOException;
- method public final java.io.InputStream open(java.lang.String, int) throws java.io.IOException;
- method public final android.content.res.AssetFileDescriptor openFd(java.lang.String) throws java.io.IOException;
- method public final android.content.res.AssetFileDescriptor openNonAssetFd(java.lang.String) throws java.io.IOException;
- method public final android.content.res.AssetFileDescriptor openNonAssetFd(int, java.lang.String) throws java.io.IOException;
- method public final android.content.res.XmlResourceParser openXmlResourceParser(java.lang.String) throws java.io.IOException;
- method public final android.content.res.XmlResourceParser openXmlResourceParser(int, java.lang.String) throws java.io.IOException;
+ method public java.lang.String[] getLocales();
+ method public java.lang.String[] list(java.lang.String) throws java.io.IOException;
+ method public java.io.InputStream open(java.lang.String) throws java.io.IOException;
+ method public java.io.InputStream open(java.lang.String, int) throws java.io.IOException;
+ method public android.content.res.AssetFileDescriptor openFd(java.lang.String) throws java.io.IOException;
+ method public android.content.res.AssetFileDescriptor openNonAssetFd(java.lang.String) throws java.io.IOException;
+ method public android.content.res.AssetFileDescriptor openNonAssetFd(int, java.lang.String) throws java.io.IOException;
+ method public android.content.res.XmlResourceParser openXmlResourceParser(java.lang.String) throws java.io.IOException;
+ method public android.content.res.XmlResourceParser openXmlResourceParser(int, java.lang.String) throws java.io.IOException;
field public static final int ACCESS_BUFFER = 3; // 0x3
field public static final int ACCESS_RANDOM = 1; // 0x1
field public static final int ACCESS_STREAMING = 2; // 0x2
}
public abstract class Context {
- method public abstract int getUserId();
- }
-
- public class ContextWrapper extends android.content.Context {
+ method public android.os.UserHandle getUser();
method public int getUserId();
}
*/
@NonNull
public Account[] getAccountsByType(String type) {
- return getAccountsByTypeAsUser(type, Process.myUserHandle());
+ return getAccountsByTypeAsUser(type, mContext.getUser());
}
/** @hide Same as {@link #getAccountsByType(String)} but for a specific user. */
final AccountManagerCallback<Bundle> callback,
final Handler handler) {
return confirmCredentialsAsUser(account, options, activity, callback, handler,
- Process.myUserHandle());
+ mContext.getUser());
}
/**
return finishSessionAsUser(
sessionBundle,
activity,
- Process.myUserHandle(),
+ mContext.getUser(),
callback,
handler);
}
ActivityManager.INTENT_SENDER_ACTIVITY_RESULT, packageName,
mParent == null ? mToken : mParent.mToken,
mEmbeddedID, requestCode, new Intent[] { data }, null, flags, null,
- UserHandle.myUserId());
+ getUserId());
return target != null ? new PendingIntent(target) : null;
} catch (RemoteException e) {
// Empty
if (maxNum < 0) {
throw new IllegalArgumentException("The requested number of tasks should be >= 0");
}
- return getService().getRecentTasks(maxNum, flags, UserHandle.myUserId()).getList();
+ return getService().getRecentTasks(maxNum, flags, mContext.getUserId()).getList();
} catch (RemoteException e) {
throw e.rethrowFromSystemServer();
}
public boolean clearApplicationUserData(String packageName, IPackageDataObserver observer) {
try {
return getService().clearApplicationUserData(packageName, false,
- observer, UserHandle.myUserId());
+ observer, mContext.getUserId());
} catch (RemoteException e) {
throw e.rethrowFromSystemServer();
}
try {
@SuppressWarnings("unchecked")
final ParceledListSlice<GrantedUriPermission> castedList = getService()
- .getGrantedUriPermissions(packageName, UserHandle.myUserId());
+ .getGrantedUriPermissions(packageName, mContext.getUserId());
return castedList;
} catch (RemoteException e) {
throw e.rethrowFromSystemServer();
public void clearGrantedUriPermissions(String packageName) {
try {
getService().clearGrantedUriPermissions(packageName,
- UserHandle.myUserId());
+ mContext.getUserId());
} catch (RemoteException e) {
throw e.rethrowFromSystemServer();
}
public void killBackgroundProcesses(String packageName) {
try {
getService().killBackgroundProcesses(packageName,
- UserHandle.myUserId());
+ mContext.getUserId());
} catch (RemoteException e) {
throw e.rethrowFromSystemServer();
}
@SystemApi
@RequiresPermission(Manifest.permission.FORCE_STOP_PACKAGES)
public void forceStopPackage(String packageName) {
- forceStopPackageAsUser(packageName, UserHandle.myUserId());
+ forceStopPackageAsUser(packageName, mContext.getUserId());
}
/**
public static final int FLAG_IDLE_UNTIL = 1<<4;
private final IAlarmManager mService;
+ private final Context mContext;
private final String mPackageName;
private final boolean mAlwaysExact;
private final int mTargetSdkVersion;
AlarmManager(IAlarmManager service, Context ctx) {
mService = service;
+ mContext = ctx;
mPackageName = ctx.getPackageName();
mTargetSdkVersion = ctx.getApplicationInfo().targetSdkVersion;
mAlwaysExact = (mTargetSdkVersion < Build.VERSION_CODES.KITKAT);
* @see #ACTION_NEXT_ALARM_CLOCK_CHANGED
*/
public AlarmClockInfo getNextAlarmClock() {
- return getNextAlarmClock(UserHandle.myUserId());
+ return getNextAlarmClock(mContext.getUserId());
}
/**
/** @hide */
public void resetAllModes() {
try {
- mService.resetAllModes(UserHandle.myUserId(), null);
+ mService.resetAllModes(mContext.getUserId(), null);
} catch (RemoteException e) {
throw e.rethrowFromSystemServer();
}
}
@Override
+ public int getUserId() {
+ return mContext.getUserId();
+ }
+
+ @Override
public PackageInfo getPackageInfo(String packageName, int flags)
throws NameNotFoundException {
return getPackageInfoAsUser(packageName, flags, mContext.getUserId());
private final @Nullable IBinder mActivityToken;
- private final @Nullable UserHandle mUser;
+ private final @NonNull UserHandle mUser;
private final ApplicationContentResolver mContentResolver;
public boolean bindService(Intent service, ServiceConnection conn,
int flags) {
warnIfCallingFromSystemProcess();
- return bindServiceCommon(service, conn, flags, mMainThread.getHandler(),
- Process.myUserHandle());
+ return bindServiceCommon(service, conn, flags, mMainThread.getHandler(), getUser());
}
/** @hide */
@Override
public Context createPackageContext(String packageName, int flags)
throws NameNotFoundException {
- return createPackageContextAsUser(packageName, flags,
- mUser != null ? mUser : Process.myUserHandle());
+ return createPackageContextAsUser(packageName, flags, mUser);
}
@Override
/** {@hide} */
@Override
+ public UserHandle getUser() {
+ return mUser;
+ }
+
+ /** {@hide} */
+ @Override
public int getUserId() {
return mUser.getIdentifier();
}
}
}
- mContentResolver = new ApplicationContentResolver(this, mainThread, user);
+ mContentResolver = new ApplicationContentResolver(this, mainThread);
}
void setResources(Resources r) {
private static final class ApplicationContentResolver extends ContentResolver {
private final ActivityThread mMainThread;
- private final UserHandle mUser;
- public ApplicationContentResolver(
- Context context, ActivityThread mainThread, UserHandle user) {
+ public ApplicationContentResolver(Context context, ActivityThread mainThread) {
super(context);
mMainThread = Preconditions.checkNotNull(mainThread);
- mUser = Preconditions.checkNotNull(user);
}
@Override
/** @hide */
protected int resolveUserIdFromAuthority(String auth) {
- return ContentProvider.getUserIdFromAuthority(auth, mUser.getIdentifier());
+ return ContentProvider.getUserIdFromAuthority(auth, getUserId());
}
}
}
public void execStartActivities(Context who, IBinder contextThread,
IBinder token, Activity target, Intent[] intents, Bundle options) {
execStartActivitiesAsUser(who, contextThread, token, target, intents, options,
- UserHandle.myUserId());
+ who.getUserId());
}
/**
* password.
*/
public boolean isDeviceLocked() {
- return isDeviceLocked(UserHandle.myUserId());
+ return isDeviceLocked(mContext.getUserId());
}
/**
* @return true if a PIN, pattern or password was set.
*/
public boolean isDeviceSecure() {
- return isDeviceSecure(UserHandle.myUserId());
+ return isDeviceSecure(mContext.getUserId());
}
/**
*/
public void notify(String tag, int id, Notification notification)
{
- notifyAsUser(tag, id, notification, new UserHandle(UserHandle.myUserId()));
+ notifyAsUser(tag, id, notification, mContext.getUser());
}
/**
*/
public void cancel(String tag, int id)
{
- cancelAsUser(tag, id, new UserHandle(UserHandle.myUserId()));
+ cancelAsUser(tag, id, mContext.getUser());
}
/**
String pkg = mContext.getPackageName();
if (localLOGV) Log.v(TAG, pkg + ": cancelAll()");
try {
- service.cancelAllNotifications(pkg, UserHandle.myUserId());
+ service.cancelAllNotifications(pkg, mContext.getUserId());
} catch (RemoteException e) {
throw e.rethrowFromSystemServer();
}
final String pkg = mContext.getPackageName();
try {
final ParceledListSlice<StatusBarNotification> parceledList
- = service.getAppActiveNotifications(pkg, UserHandle.myUserId());
+ = service.getAppActiveNotifications(pkg, mContext.getUserId());
final List<StatusBarNotification> list = parceledList.getList();
return list.toArray(new StatusBarNotification[list.size()]);
} catch (RemoteException e) {
ActivityManager.INTENT_SENDER_ACTIVITY, packageName,
null, null, requestCode, new Intent[] { intent },
resolvedType != null ? new String[] { resolvedType } : null,
- flags, options, UserHandle.myUserId());
+ flags, options, context.getUserId());
return target != null ? new PendingIntent(target) : null;
} catch (RemoteException e) {
throw e.rethrowFromSystemServer();
ActivityManager.getService().getIntentSender(
ActivityManager.INTENT_SENDER_ACTIVITY, packageName,
null, null, requestCode, intents, resolvedTypes, flags, options,
- UserHandle.myUserId());
+ context.getUserId());
return target != null ? new PendingIntent(target) : null;
} catch (RemoteException e) {
throw e.rethrowFromSystemServer();
*/
public static PendingIntent getBroadcast(Context context, int requestCode,
Intent intent, @Flags int flags) {
- return getBroadcastAsUser(context, requestCode, intent, flags,
- new UserHandle(UserHandle.myUserId()));
+ return getBroadcastAsUser(context, requestCode, intent, flags, context.getUser());
}
/**
serviceKind, packageName,
null, null, requestCode, new Intent[] { intent },
resolvedType != null ? new String[] { resolvedType } : null,
- flags, null, UserHandle.myUserId());
+ flags, null, context.getUserId());
return target != null ? new PendingIntent(target) : null;
} catch (RemoteException e) {
throw e.rethrowFromSystemServer();
import android.content.Context;
import android.content.IRestrictionsManager;
import android.content.RestrictionsManager;
+import android.content.pm.ApplicationInfo;
import android.content.pm.CrossProfileApps;
import android.content.pm.ICrossProfileApps;
import android.content.pm.IShortcutService;
service = IPrintManager.Stub.asInterface(ServiceManager
.getServiceOrThrow(Context.PRINT_SERVICE));
}
- return new PrintManager(ctx.getOuterContext(), service, UserHandle.myUserId(),
- UserHandle.getAppId(Process.myUid()));
+ final int userId = ctx.getUserId();
+ final int appId = UserHandle.getAppId(ctx.getApplicationInfo().uid);
+ return new PrintManager(ctx.getOuterContext(), service, userId, appId);
}});
registerService(Context.COMPANION_DEVICE_SERVICE, CompanionDeviceManager.class,
}});
registerService(Context.TV_INPUT_SERVICE, TvInputManager.class,
- new StaticServiceFetcher<TvInputManager>() {
+ new CachedServiceFetcher<TvInputManager>() {
@Override
- public TvInputManager createService() throws ServiceNotFoundException {
+ public TvInputManager createService(ContextImpl ctx) throws ServiceNotFoundException {
IBinder iBinder = ServiceManager.getServiceOrThrow(Context.TV_INPUT_SERVICE);
ITvInputManager service = ITvInputManager.Stub.asInterface(iBinder);
- return new TvInputManager(service, UserHandle.myUserId());
+ return new TvInputManager(service, ctx.getUserId());
}});
registerService(Context.NETWORK_SCORE_SERVICE, NetworkScoreManager.class,
* Context.startActivity(Intent, Bundle)} for more details.
*/
public void startActivities(Bundle options) {
- startActivities(options, new UserHandle(UserHandle.myUserId()));
+ startActivities(options, mSourceContext.getUser());
}
/**
Log.w(TAG, "WallpaperService not running");
throw new RuntimeException(new DeadSystemException());
} else {
- return sGlobals.mService.getWallpaperInfo(UserHandle.myUserId());
+ return sGlobals.mService.getWallpaperInfo(mContext.getUserId());
}
} catch (RemoteException e) {
throw e.rethrowFromSystemServer();
ParcelFileDescriptor fd = sGlobals.mService.setWallpaper(
"res:" + resources.getResourceName(resid),
mContext.getOpPackageName(), null, false, result, which, completion,
- UserHandle.myUserId());
+ mContext.getUserId());
if (fd != null) {
FileOutputStream fos = null;
boolean ok = false;
boolean allowBackup, @SetWallpaperFlags int which)
throws IOException {
return setBitmap(fullImage, visibleCropHint, allowBackup, which,
- UserHandle.myUserId());
+ mContext.getUserId());
}
/**
try {
ParcelFileDescriptor fd = sGlobals.mService.setWallpaper(null,
mContext.getOpPackageName(), visibleCropHint, allowBackup,
- result, which, completion, UserHandle.myUserId());
+ result, which, completion, mContext.getUserId());
if (fd != null) {
FileOutputStream fos = null;
try {
@SystemApi
@RequiresPermission(android.Manifest.permission.SET_WALLPAPER_COMPONENT)
public boolean setWallpaperComponent(ComponentName name) {
- return setWallpaperComponent(name, UserHandle.myUserId());
+ return setWallpaperComponent(name, mContext.getUserId());
}
/**
/** @hide test will override it. */
@VisibleForTesting
protected int myUserId() {
- return UserHandle.myUserId();
+ return mContext.getUserId();
}
/**
@SystemApi
public @Nullable ComponentName getProfileOwner() throws IllegalArgumentException {
throwIfParentInstance("getProfileOwner");
- return getProfileOwnerAsUser(Process.myUserHandle().getIdentifier());
+ return getProfileOwnerAsUser(mContext.getUserId());
}
/**
public @Nullable String getProfileOwnerName() throws IllegalArgumentException {
if (mService != null) {
try {
- return mService.getProfileOwnerName(Process.myUserHandle().getIdentifier());
+ return mService.getProfileOwnerName(mContext.getUserId());
} catch (RemoteException re) {
throw re.rethrowFromSystemServer();
}
*/
public boolean isAppInactive(String packageName) {
try {
- return mService.isAppInactive(packageName, UserHandle.myUserId());
+ return mService.isAppInactive(packageName, mContext.getUserId());
} catch (RemoteException e) {
// fall through and return default
}
*/
public void setAppInactive(String packageName, boolean inactive) {
try {
- mService.setAppInactive(packageName, inactive, UserHandle.myUserId());
+ mService.setAppInactive(packageName, inactive, mContext.getUserId());
} catch (RemoteException e) {
// fall through
}
*/
public static final String META_DATA_APPWIDGET_PROVIDER = "android.appwidget.provider";
+ private final Context mContext;
private final String mPackageName;
-
private final IAppWidgetService mService;
-
private final DisplayMetrics mDisplayMetrics;
/**
* @hide
*/
public AppWidgetManager(Context context, IAppWidgetService service) {
+ mContext = context;
mPackageName = context.getOpPackageName();
mService = service;
mDisplayMetrics = context.getResources().getDisplayMetrics();
}
if (profile == null) {
- profile = Process.myUserHandle();
+ profile = mContext.getUser();
}
try {
if (mService == null) {
return;
}
- bindAppWidgetIdIfAllowed(appWidgetId, Process.myUserHandle(), provider, options);
+ bindAppWidgetIdIfAllowed(appWidgetId, mContext.getUser(), provider, options);
}
/**
if (mService == null) {
return false;
}
- return bindAppWidgetIdIfAllowed(appWidgetId, UserHandle.myUserId(), provider, null);
+ return bindAppWidgetIdIfAllowed(appWidgetId, mContext.getUserId(), provider, null);
}
/**
if (mService == null) {
return false;
}
- return bindAppWidgetIdIfAllowed(appWidgetId, UserHandle.myUserId(), provider, options);
+ return bindAppWidgetIdIfAllowed(appWidgetId, mContext.getUserId(), provider, options);
}
/**
return false;
}
try {
- return mService.hasBindAppWidgetPermission(packageName, UserHandle.myUserId());
+ return mService.hasBindAppWidgetPermission(packageName, mContext.getUserId());
} catch (RemoteException e) {
throw e.rethrowFromSystemServer();
}
if (mService == null) {
return;
}
- setBindAppWidgetPermission(packageName, UserHandle.myUserId(), permission);
+ setBindAppWidgetPermission(packageName, mContext.getUserId(), permission);
}
/**
ComponentName comp = intent.resolveSystemService(mContext.getPackageManager(), 0);
intent.setComponent(comp);
if (comp == null || !mContext.bindServiceAsUser(intent, mConnection, 0,
- android.os.Process.myUserHandle())) {
+ mContext.getUser())) {
Log.e(TAG, "Could not bind to Bluetooth A2DP Service with " + intent);
return false;
}
ComponentName comp = intent.resolveSystemService(mContext.getPackageManager(), 0);
intent.setComponent(comp);
if (comp == null || !mContext.bindServiceAsUser(intent, mConnection, 0,
- android.os.Process.myUserHandle())) {
+ mContext.getUser())) {
Log.e(TAG, "Could not bind to Bluetooth A2DP Service with " + intent);
return false;
}
ComponentName comp = intent.resolveSystemService(mContext.getPackageManager(), 0);
intent.setComponent(comp);
if (comp == null || !mContext.bindServiceAsUser(intent, mConnection, 0,
- android.os.Process.myUserHandle())) {
+ mContext.getUser())) {
Log.e(TAG, "Could not bind to Bluetooth AVRCP Controller Service with " + intent);
return false;
}
ComponentName comp = intent.resolveSystemService(mContext.getPackageManager(), 0);
intent.setComponent(comp);
if (comp == null || !mContext.bindServiceAsUser(intent, mConnection, 0,
- android.os.Process.myUserHandle())) {
+ mContext.getUser())) {
Log.e(TAG, "Could not bind to Bluetooth Headset Client Service with " + intent);
return false;
}
ComponentName comp = intent.resolveSystemService(mContext.getPackageManager(), 0);
intent.setComponent(comp);
if (comp == null || !mContext.bindServiceAsUser(intent, mConnection, 0,
- android.os.Process.myUserHandle())) {
+ mContext.getUser())) {
Log.e(TAG, "Could not bind to Bluetooth Health Service with " + intent);
return false;
}
ComponentName comp = intent.resolveSystemService(mContext.getPackageManager(), 0);
intent.setComponent(comp);
if (comp == null || !mContext.bindServiceAsUser(intent, mConnection, 0,
- android.os.Process.myUserHandle())) {
+ mContext.getUser())) {
Log.e(TAG, "Could not bind to Bluetooth HID Device Service with " + intent);
return false;
}
ComponentName comp = intent.resolveSystemService(mContext.getPackageManager(), 0);
intent.setComponent(comp);
if (comp == null || !mContext.bindServiceAsUser(intent, mConnection, 0,
- android.os.Process.myUserHandle())) {
+ mContext.getUser())) {
Log.e(TAG, "Could not bind to Bluetooth HID Service with " + intent);
return false;
}
ComponentName comp = intent.resolveSystemService(mContext.getPackageManager(), 0);
intent.setComponent(comp);
if (comp == null || !mContext.bindServiceAsUser(intent, mConnection, 0,
- android.os.Process.myUserHandle())) {
+ mContext.getUser())) {
Log.e(TAG, "Could not bind to Bluetooth MAP Service with " + intent);
return false;
}
ComponentName comp = intent.resolveSystemService(mContext.getPackageManager(), 0);
intent.setComponent(comp);
if (comp == null || !mContext.bindServiceAsUser(intent, mConnection, 0,
- android.os.Process.myUserHandle())) {
+ mContext.getUser())) {
Log.e(TAG, "Could not bind to Bluetooth MAP MCE Service with " + intent);
return false;
}
ComponentName comp = intent.resolveSystemService(mContext.getPackageManager(), 0);
intent.setComponent(comp);
if (comp == null || !mContext.bindServiceAsUser(intent, mConnection, 0,
- android.os.Process.myUserHandle())) {
+ mContext.getUser())) {
Log.e(TAG, "Could not bind to Bluetooth Pan Service with " + intent);
return false;
}
ComponentName comp = intent.resolveSystemService(mContext.getPackageManager(), 0);
intent.setComponent(comp);
if (comp == null || !mContext.bindServiceAsUser(intent, mConnection, 0,
- android.os.Process.myUserHandle())) {
+ mContext.getUser())) {
Log.e(TAG, "Could not bind to Bluetooth Pbap Service with " + intent);
return false;
}
ComponentName comp = intent.resolveSystemService(mContext.getPackageManager(), 0);
intent.setComponent(comp);
if (comp == null || !mContext.bindServiceAsUser(intent, mConnection, 0,
- android.os.Process.myUserHandle())) {
+ mContext.getUser())) {
Log.e(TAG, "Could not bind to Bluetooth PBAP Client Service with " + intent);
return false;
}
ComponentName comp = intent.resolveSystemService(mContext.getPackageManager(), 0);
intent.setComponent(comp);
if (comp == null || !mContext.bindServiceAsUser(intent, mConnection, 0,
- android.os.Process.myUserHandle())) {
+ mContext.getUser())) {
Log.e(TAG, "Could not bind to Bluetooth SAP Service with " + intent);
return false;
}
}
/** @hide */
+ public int getUserId() {
+ return mContext.getUserId();
+ }
+
+ /** @hide */
public Drawable getTypeDrawable(String mimeType) {
return MimeIconUtils.loadMimeIcon(mContext, mimeType);
}
throws PackageManager.NameNotFoundException;
/**
- * Get the userId associated with this context
- * @return user id
- *
+ * Get the user associated with this context
+ * @hide
+ */
+ @TestApi
+ public UserHandle getUser() {
+ return android.os.Process.myUserHandle();
+ }
+
+ /**
+ * Get the user associated with this context
* @hide
*/
@TestApi
- public abstract @UserIdInt int getUserId();
+ public @UserIdInt int getUserId() {
+ return android.os.UserHandle.myUserId();
+ }
/**
* Return a new Context object for the current Context but whose resources
*/
public static final int VERSION_CODE_HIGHEST = -1;
+ /** {@hide} */
+ public int getUserId() {
+ return UserHandle.myUserId();
+ }
+
/**
* Retrieve overall information about an application package that is
* installed on the system.
*/
@Deprecated
public void getPackageSizeInfo(String packageName, IPackageStatsObserver observer) {
- getPackageSizeInfoAsUser(packageName, UserHandle.myUserId(), observer);
+ getPackageSizeInfoAsUser(packageName, getUserId(), observer);
}
/**
dr = pm.getDrawable(ci.packageName, iconResourceId, ai);
}
if (dr != null) {
- return pm.getUserBadgedIcon(dr, new UserHandle(UserHandle.myUserId()));
+ return pm.getUserBadgedIcon(dr, new UserHandle(pm.getUserId()));
}
return ci.loadIcon(pm);
}
/** @hide injection point */
@VisibleForTesting
protected int injectMyUserId() {
- return UserHandle.myUserId();
+ return mContext.getUserId();
}
}
*/
@Override
public void setNotificationUri(ContentResolver cr, Uri notifyUri) {
- setNotificationUri(cr, notifyUri, UserHandle.myUserId());
+ setNotificationUri(cr, notifyUri, cr.getUserId());
}
/** @hide - set the notification uri but with an observer for a particular user's view */
@TestApi
@RequiresPermission(Manifest.permission.CONFIGURE_DISPLAY_BRIGHTNESS)
public void setBrightnessConfiguration(BrightnessConfiguration c) {
- setBrightnessConfigurationForUser(c, UserHandle.myUserId(), mContext.getPackageName());
+ setBrightnessConfigurationForUser(c, mContext.getUserId(), mContext.getPackageName());
}
/**
@RequiresPermission(USE_FINGERPRINT)
public void authenticate(@Nullable CryptoObject crypto, @Nullable CancellationSignal cancel,
int flags, @NonNull AuthenticationCallback callback, @Nullable Handler handler) {
- authenticate(crypto, cancel, flags, callback, handler, UserHandle.myUserId());
+ authenticate(crypto, cancel, flags, callback, handler, mContext.getUserId());
}
/**
if (callback == null) {
throw new IllegalArgumentException("Must supply a calback");
}
- authenticate(UserHandle.myUserId(), null, cancel, bundle, executor, receiver, callback);
+ authenticate(mContext.getUserId(), null, cancel, bundle, executor, receiver, callback);
}
/**
if (callback == null) {
throw new IllegalArgumentException("Must supply a callback");
}
- authenticate(UserHandle.myUserId(), crypto, cancel,
+ authenticate(mContext.getUserId(), crypto, cancel,
bundle, executor, receiver, callback);
}
*/
@RequiresPermission(USE_FINGERPRINT)
public List<Fingerprint> getEnrolledFingerprints() {
- return getEnrolledFingerprints(UserHandle.myUserId());
+ return getEnrolledFingerprints(mContext.getUserId());
}
/**
public boolean hasEnrolledFingerprints() {
if (mService != null) try {
return mService.hasEnrolledFingerprints(
- UserHandle.myUserId(), mContext.getOpPackageName());
+ mContext.getUserId(), mContext.getOpPackageName());
} catch (RemoteException e) {
throw e.rethrowFromSystemServer();
}
*/
public static Intent prepare(Context context) {
try {
- if (getService().prepareVpn(context.getPackageName(), null, UserHandle.myUserId())) {
+ if (getService().prepareVpn(context.getPackageName(), null, context.getUserId())) {
return null;
}
} catch (RemoteException e) {
String packageName = context.getPackageName();
try {
// Only prepare if we're not already prepared.
- int userId = UserHandle.myUserId();
+ int userId = context.getUserId();
if (!cm.prepareVpn(packageName, null, userId)) {
cm.prepareVpn(null, packageName, userId);
}
"either scheme file or scheme content");
continue;
}
- uri = ContentProvider.maybeAddUserId(uri, UserHandle.myUserId());
+ uri = ContentProvider.maybeAddUserId(uri, activity.getUserId());
validUris.add(uri);
}
} finally {
Binder.restoreCallingIdentity(ident);
}
- return new BeamShareData(message, uris, new UserHandle(UserHandle.myUserId()), flags);
+ return new BeamShareData(message, uris, activity.getUser(), flags);
}
/** Callback from NFC service, usually on binder thread */
*/
public boolean isDefaultServiceForCategory(ComponentName service, String category) {
try {
- return sService.isDefaultServiceForCategory(UserHandle.myUserId(), service, category);
+ return sService.isDefaultServiceForCategory(mContext.getUserId(), service, category);
} catch (RemoteException e) {
// Try one more time
recoverService();
return false;
}
try {
- return sService.isDefaultServiceForCategory(UserHandle.myUserId(), service,
+ return sService.isDefaultServiceForCategory(mContext.getUserId(), service,
category);
} catch (RemoteException ee) {
Log.e(TAG, "Failed to recover CardEmulationService.");
*/
public boolean isDefaultServiceForAid(ComponentName service, String aid) {
try {
- return sService.isDefaultServiceForAid(UserHandle.myUserId(), service, aid);
+ return sService.isDefaultServiceForAid(mContext.getUserId(), service, aid);
} catch (RemoteException e) {
// Try one more time
recoverService();
return false;
}
try {
- return sService.isDefaultServiceForAid(UserHandle.myUserId(), service, aid);
+ return sService.isDefaultServiceForAid(mContext.getUserId(), service, aid);
} catch (RemoteException ee) {
Log.e(TAG, "Failed to reach CardEmulationService.");
return false;
List<String> aids) {
AidGroup aidGroup = new AidGroup(aids, category);
try {
- return sService.registerAidGroupForService(UserHandle.myUserId(), service, aidGroup);
+ return sService.registerAidGroupForService(mContext.getUserId(), service, aidGroup);
} catch (RemoteException e) {
// Try one more time
recoverService();
return false;
}
try {
- return sService.registerAidGroupForService(UserHandle.myUserId(), service,
+ return sService.registerAidGroupForService(mContext.getUserId(), service,
aidGroup);
} catch (RemoteException ee) {
Log.e(TAG, "Failed to reach CardEmulationService.");
*/
public List<String> getAidsForService(ComponentName service, String category) {
try {
- AidGroup group = sService.getAidGroupForService(UserHandle.myUserId(), service,
+ AidGroup group = sService.getAidGroupForService(mContext.getUserId(), service,
category);
return (group != null ? group.getAids() : null);
} catch (RemoteException e) {
return null;
}
try {
- AidGroup group = sService.getAidGroupForService(UserHandle.myUserId(), service,
+ AidGroup group = sService.getAidGroupForService(mContext.getUserId(), service,
category);
return (group != null ? group.getAids() : null);
} catch (RemoteException ee) {
*/
public boolean removeAidsForService(ComponentName service, String category) {
try {
- return sService.removeAidGroupForService(UserHandle.myUserId(), service, category);
+ return sService.removeAidGroupForService(mContext.getUserId(), service, category);
} catch (RemoteException e) {
// Try one more time
recoverService();
return false;
}
try {
- return sService.removeAidGroupForService(UserHandle.myUserId(), service, category);
+ return sService.removeAidGroupForService(mContext.getUserId(), service, category);
} catch (RemoteException ee) {
Log.e(TAG, "Failed to reach CardEmulationService.");
return false;
*/
public boolean setDefaultServiceForCategory(ComponentName service, String category) {
try {
- return sService.setDefaultServiceForCategory(UserHandle.myUserId(), service, category);
+ return sService.setDefaultServiceForCategory(mContext.getUserId(), service, category);
} catch (RemoteException e) {
// Try one more time
recoverService();
return false;
}
try {
- return sService.setDefaultServiceForCategory(UserHandle.myUserId(), service,
+ return sService.setDefaultServiceForCategory(mContext.getUserId(), service,
category);
} catch (RemoteException ee) {
Log.e(TAG, "Failed to reach CardEmulationService.");
*/
public boolean setDefaultForNextTap(ComponentName service) {
try {
- return sService.setDefaultForNextTap(UserHandle.myUserId(), service);
+ return sService.setDefaultForNextTap(mContext.getUserId(), service);
} catch (RemoteException e) {
// Try one more time
recoverService();
return false;
}
try {
- return sService.setDefaultForNextTap(UserHandle.myUserId(), service);
+ return sService.setDefaultForNextTap(mContext.getUserId(), service);
} catch (RemoteException ee) {
Log.e(TAG, "Failed to reach CardEmulationService.");
return false;
*/
public List<ApduServiceInfo> getServices(String category) {
try {
- return sService.getServices(UserHandle.myUserId(), category);
+ return sService.getServices(mContext.getUserId(), category);
} catch (RemoteException e) {
// Try one more time
recoverService();
return null;
}
try {
- return sService.getServices(UserHandle.myUserId(), category);
+ return sService.getServices(mContext.getUserId(), category);
} catch (RemoteException ee) {
Log.e(TAG, "Failed to reach CardEmulationService.");
return null;
throw new NullPointerException("service is null");
}
try {
- return sService.getSystemCodeForService(UserHandle.myUserId(), service);
+ return sService.getSystemCodeForService(mContext.getUserId(), service);
} catch (RemoteException e) {
// Try one more time
recoverService();
return null;
}
try {
- return sService.getSystemCodeForService(UserHandle.myUserId(), service);
+ return sService.getSystemCodeForService(mContext.getUserId(), service);
} catch (RemoteException ee) {
Log.e(TAG, "Failed to reach CardEmulationService.");
ee.rethrowAsRuntimeException();
throw new NullPointerException("service or systemCode is null");
}
try {
- return sService.registerSystemCodeForService(UserHandle.myUserId(),
+ return sService.registerSystemCodeForService(mContext.getUserId(),
service, systemCode);
} catch (RemoteException e) {
// Try one more time
return false;
}
try {
- return sService.registerSystemCodeForService(UserHandle.myUserId(),
+ return sService.registerSystemCodeForService(mContext.getUserId(),
service, systemCode);
} catch (RemoteException ee) {
Log.e(TAG, "Failed to reach CardEmulationService.");
throw new NullPointerException("service is null");
}
try {
- return sService.removeSystemCodeForService(UserHandle.myUserId(), service);
+ return sService.removeSystemCodeForService(mContext.getUserId(), service);
} catch (RemoteException e) {
// Try one more time
recoverService();
return false;
}
try {
- return sService.removeSystemCodeForService(UserHandle.myUserId(), service);
+ return sService.removeSystemCodeForService(mContext.getUserId(), service);
} catch (RemoteException ee) {
Log.e(TAG, "Failed to reach CardEmulationService.");
ee.rethrowAsRuntimeException();
throw new NullPointerException("service is null");
}
try {
- return sService.getNfcid2ForService(UserHandle.myUserId(), service);
+ return sService.getNfcid2ForService(mContext.getUserId(), service);
} catch (RemoteException e) {
// Try one more time
recoverService();
return null;
}
try {
- return sService.getNfcid2ForService(UserHandle.myUserId(), service);
+ return sService.getNfcid2ForService(mContext.getUserId(), service);
} catch (RemoteException ee) {
Log.e(TAG, "Failed to reach CardEmulationService.");
ee.rethrowAsRuntimeException();
throw new NullPointerException("service or nfcid2 is null");
}
try {
- return sService.setNfcid2ForService(UserHandle.myUserId(),
+ return sService.setNfcid2ForService(mContext.getUserId(),
service, nfcid2);
} catch (RemoteException e) {
// Try one more time
return false;
}
try {
- return sService.setNfcid2ForService(UserHandle.myUserId(),
+ return sService.setNfcid2ForService(mContext.getUserId(),
service, nfcid2);
} catch (RemoteException ee) {
Log.e(TAG, "Failed to reach CardEmulationService.");
*/
public List<NfcFServiceInfo> getNfcFServices() {
try {
- return sService.getNfcFServices(UserHandle.myUserId());
+ return sService.getNfcFServices(mContext.getUserId());
} catch (RemoteException e) {
// Try one more time
recoverService();
return null;
}
try {
- return sService.getNfcFServices(UserHandle.myUserId());
+ return sService.getNfcFServices(mContext.getUserId());
} catch (RemoteException ee) {
Log.e(TAG, "Failed to reach CardEmulationService.");
return null;
public @NonNull List<StorageVolume> getStorageVolumes() {
final ArrayList<StorageVolume> res = new ArrayList<>();
Collections.addAll(res,
- getVolumeList(UserHandle.myUserId(), FLAG_REAL_STATE | FLAG_INCLUDE_INVISIBLE));
+ getVolumeList(mContext.getUserId(), FLAG_REAL_STATE | FLAG_INCLUDE_INVISIBLE));
return res;
}
* {@link Context#getExternalFilesDir(String)}.
*/
public @NonNull StorageVolume getPrimaryStorageVolume() {
- return getVolumeList(UserHandle.myUserId(), FLAG_REAL_STATE | FLAG_INCLUDE_INVISIBLE)[0];
+ return getVolumeList(mContext.getUserId(), FLAG_REAL_STATE | FLAG_INCLUDE_INVISIBLE)[0];
}
/** {@hide} */
}
}
// Launch on the current profile.
- startQuickContactWithErrorToastForUser(context, intent, Process.myUserHandle());
+ startQuickContactWithErrorToastForUser(context, intent, context.getUser());
}
public static void startQuickContactWithErrorToastForUser(Context context, Intent intent,
* @return the corresponding value, or null if not present
*/
public static String getString(ContentResolver resolver, String name) {
- return getStringForUser(resolver, name, UserHandle.myUserId());
+ return getStringForUser(resolver, name, resolver.getUserId());
}
/** @hide */
* @return true if the value was set, false on database errors
*/
public static boolean putString(ContentResolver resolver, String name, String value) {
- return putStringForUser(resolver, name, value, UserHandle.myUserId());
+ return putStringForUser(resolver, name, value, resolver.getUserId());
}
/** @hide */
* or not a valid integer.
*/
public static int getInt(ContentResolver cr, String name, int def) {
- return getIntForUser(cr, name, def, UserHandle.myUserId());
+ return getIntForUser(cr, name, def, cr.getUserId());
}
/** @hide */
*/
public static int getInt(ContentResolver cr, String name)
throws SettingNotFoundException {
- return getIntForUser(cr, name, UserHandle.myUserId());
+ return getIntForUser(cr, name, cr.getUserId());
}
/** @hide */
* @return true if the value was set, false on database errors
*/
public static boolean putInt(ContentResolver cr, String name, int value) {
- return putIntForUser(cr, name, value, UserHandle.myUserId());
+ return putIntForUser(cr, name, value, cr.getUserId());
}
/** @hide */
* or not a valid {@code long}.
*/
public static long getLong(ContentResolver cr, String name, long def) {
- return getLongForUser(cr, name, def, UserHandle.myUserId());
+ return getLongForUser(cr, name, def, cr.getUserId());
}
/** @hide */
*/
public static long getLong(ContentResolver cr, String name)
throws SettingNotFoundException {
- return getLongForUser(cr, name, UserHandle.myUserId());
+ return getLongForUser(cr, name, cr.getUserId());
}
/** @hide */
* @return true if the value was set, false on database errors
*/
public static boolean putLong(ContentResolver cr, String name, long value) {
- return putLongForUser(cr, name, value, UserHandle.myUserId());
+ return putLongForUser(cr, name, value, cr.getUserId());
}
/** @hide */
* or not a valid float.
*/
public static float getFloat(ContentResolver cr, String name, float def) {
- return getFloatForUser(cr, name, def, UserHandle.myUserId());
+ return getFloatForUser(cr, name, def, cr.getUserId());
}
/** @hide */
*/
public static float getFloat(ContentResolver cr, String name)
throws SettingNotFoundException {
- return getFloatForUser(cr, name, UserHandle.myUserId());
+ return getFloatForUser(cr, name, cr.getUserId());
}
/** @hide */
* @return true if the value was set, false on database errors
*/
public static boolean putFloat(ContentResolver cr, String name, float value) {
- return putFloatForUser(cr, name, value, UserHandle.myUserId());
+ return putFloatForUser(cr, name, value, cr.getUserId());
}
/** @hide */
* @param outConfig Where to place the configuration settings.
*/
public static void getConfiguration(ContentResolver cr, Configuration outConfig) {
- adjustConfigurationForUser(cr, outConfig, UserHandle.myUserId(),
+ adjustConfigurationForUser(cr, outConfig, cr.getUserId(),
false /* updateSettingsIfEmpty */);
}
* @return true if the values were set, false on database errors
*/
public static boolean putConfiguration(ContentResolver cr, Configuration config) {
- return putConfigurationForUser(cr, config, UserHandle.myUserId());
+ return putConfigurationForUser(cr, config, cr.getUserId());
}
/** @hide */
/** @deprecated - Do not use */
@Deprecated
public static boolean getShowGTalkServiceStatus(ContentResolver cr) {
- return getShowGTalkServiceStatusForUser(cr, UserHandle.myUserId());
+ return getShowGTalkServiceStatusForUser(cr, cr.getUserId());
}
/**
/** @deprecated - Do not use */
@Deprecated
public static void setShowGTalkServiceStatus(ContentResolver cr, boolean flag) {
- setShowGTalkServiceStatusForUser(cr, flag, UserHandle.myUserId());
+ setShowGTalkServiceStatusForUser(cr, flag, cr.getUserId());
}
/**
* @return the corresponding value, or null if not present
*/
public static String getString(ContentResolver resolver, String name) {
- return getStringForUser(resolver, name, UserHandle.myUserId());
+ return getStringForUser(resolver, name, resolver.getUserId());
}
/** @hide */
* @return true if the value was set, false on database errors
*/
public static boolean putString(ContentResolver resolver, String name, String value) {
- return putStringForUser(resolver, name, value, UserHandle.myUserId());
+ return putStringForUser(resolver, name, value, resolver.getUserId());
}
/** @hide */
@NonNull String name, @Nullable String value, @Nullable String tag,
boolean makeDefault) {
return putStringForUser(resolver, name, value, tag, makeDefault,
- UserHandle.myUserId());
+ resolver.getUserId());
}
/**
public static void resetToDefaults(@NonNull ContentResolver resolver,
@Nullable String tag) {
resetToDefaultsAsUser(resolver, tag, RESET_MODE_PACKAGE_DEFAULTS,
- UserHandle.myUserId());
+ resolver.getUserId());
}
/**
* or not a valid integer.
*/
public static int getInt(ContentResolver cr, String name, int def) {
- return getIntForUser(cr, name, def, UserHandle.myUserId());
+ return getIntForUser(cr, name, def, cr.getUserId());
}
/** @hide */
*/
public static int getInt(ContentResolver cr, String name)
throws SettingNotFoundException {
- return getIntForUser(cr, name, UserHandle.myUserId());
+ return getIntForUser(cr, name, cr.getUserId());
}
/** @hide */
* @return true if the value was set, false on database errors
*/
public static boolean putInt(ContentResolver cr, String name, int value) {
- return putIntForUser(cr, name, value, UserHandle.myUserId());
+ return putIntForUser(cr, name, value, cr.getUserId());
}
/** @hide */
* or not a valid {@code long}.
*/
public static long getLong(ContentResolver cr, String name, long def) {
- return getLongForUser(cr, name, def, UserHandle.myUserId());
+ return getLongForUser(cr, name, def, cr.getUserId());
}
/** @hide */
*/
public static long getLong(ContentResolver cr, String name)
throws SettingNotFoundException {
- return getLongForUser(cr, name, UserHandle.myUserId());
+ return getLongForUser(cr, name, cr.getUserId());
}
/** @hide */
* @return true if the value was set, false on database errors
*/
public static boolean putLong(ContentResolver cr, String name, long value) {
- return putLongForUser(cr, name, value, UserHandle.myUserId());
+ return putLongForUser(cr, name, value, cr.getUserId());
}
/** @hide */
* or not a valid float.
*/
public static float getFloat(ContentResolver cr, String name, float def) {
- return getFloatForUser(cr, name, def, UserHandle.myUserId());
+ return getFloatForUser(cr, name, def, cr.getUserId());
}
/** @hide */
*/
public static float getFloat(ContentResolver cr, String name)
throws SettingNotFoundException {
- return getFloatForUser(cr, name, UserHandle.myUserId());
+ return getFloatForUser(cr, name, cr.getUserId());
}
/** @hide */
* @return true if the value was set, false on database errors
*/
public static boolean putFloat(ContentResolver cr, String name, float value) {
- return putFloatForUser(cr, name, value, UserHandle.myUserId());
+ return putFloatForUser(cr, name, value, cr.getUserId());
}
/** @hide */
*/
@Deprecated
public static final boolean isLocationProviderEnabled(ContentResolver cr, String provider) {
- return isLocationProviderEnabledForUser(cr, provider, UserHandle.myUserId());
+ return isLocationProviderEnabledForUser(cr, provider, cr.getUserId());
}
/**
@Deprecated
public static final void setLocationProviderEnabled(ContentResolver cr,
String provider, boolean enabled) {
- setLocationProviderEnabledForUser(cr, provider, enabled, UserHandle.myUserId());
+ setLocationProviderEnabledForUser(cr, provider, enabled, cr.getUserId());
}
/**
* @return the corresponding value, or null if not present
*/
public static String getString(ContentResolver resolver, String name) {
- return getStringForUser(resolver, name, UserHandle.myUserId());
+ return getStringForUser(resolver, name, resolver.getUserId());
}
/** @hide */
*/
public static boolean putString(ContentResolver resolver,
String name, String value) {
- return putStringForUser(resolver, name, value, null, false, UserHandle.myUserId());
+ return putStringForUser(resolver, name, value, null, false, resolver.getUserId());
}
/**
@NonNull String name, @Nullable String value, @Nullable String tag,
boolean makeDefault) {
return putStringForUser(resolver, name, value, tag, makeDefault,
- UserHandle.myUserId());
+ resolver.getUserId());
}
/**
public static void resetToDefaults(@NonNull ContentResolver resolver,
@Nullable String tag) {
resetToDefaultsAsUser(resolver, tag, RESET_MODE_PACKAGE_DEFAULTS,
- UserHandle.myUserId());
+ resolver.getUserId());
}
/**
* @return true if 24 hour time format is selected, false otherwise.
*/
public static boolean is24HourFormat(Context context) {
- return is24HourFormat(context, UserHandle.myUserId());
+ return is24HourFormat(context, context.getUserId());
}
/**
* @hide
*/
public static String getTimeFormatString(Context context) {
- return getTimeFormatString(context, UserHandle.myUserId());
+ return getTimeFormatString(context, context.getUserId());
}
/**
== PackageManager.PERMISSION_GRANTED) {
userId = UserHandle.USER_CURRENT;
} else {
- userId = UserHandle.myUserId();
+ userId = context.getUserId();
}
sInstance = new AccessibilityManager(context, null, userId);
}
Bundle args = new Bundle();
args.putInt(Intent.EXTRA_ASSIST_INPUT_DEVICE_ID, event.getDeviceId());
return ((SearchManager)getContext().getSystemService(Context.SEARCH_SERVICE))
- .launchLegacyAssist(null, UserHandle.myUserId(), args);
+ .launchLegacyAssist(null, getContext().getUserId(), args);
}
return result;
}