import android.annotation.SdkConstant;
import android.annotation.Size;
import android.annotation.SystemApi;
+import android.annotation.SystemService;
import android.annotation.SdkConstant.SdkConstantType;
import android.annotation.BroadcastBehavior;
import android.app.Activity;
* the application's main event thread. These operations throw
* {@link IllegalStateException} if they are used on the main thread.
*/
+@SystemService(Context.ACCOUNT_SERVICE)
public class AccountManager {
private static final String TAG = "AccountManager";
* @hide
*/
@SystemApi
+ @RequiresPermission(android.Manifest.permission.INTERACT_ACROSS_USERS_FULL)
public AccountManagerFuture<Bundle> finishSessionAsUser(
final Bundle sessionBundle,
final Activity activity,
--- /dev/null
+/*
+ * Copyright (C) 2017 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.annotation;
+
+import static java.lang.annotation.ElementType.TYPE;
+import static java.lang.annotation.RetentionPolicy.SOURCE;
+
+import android.content.Context;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+/**
+ * Description of a system service available through
+ * {@link Context#getSystemService(Class)}.
+ *
+ * @hide
+ */
+@Retention(SOURCE)
+@Target(TYPE)
+public @interface SystemService {
+ String value();
+}
import android.annotation.Nullable;
import android.annotation.RequiresPermission;
import android.annotation.SystemApi;
+import android.annotation.SystemService;
import android.annotation.TestApi;
import android.content.pm.ActivityInfo;
import android.content.res.Configuration;
* be used for testing and debugging purposes only.
* </p>
*/
+@SystemService(Context.ACTIVITY_SERVICE)
public class ActivityManager {
private static String TAG = "ActivityManager";
* @hide
*/
@SystemApi @TestApi
+ @RequiresPermission(Manifest.permission.PACKAGE_USAGE_STATS)
public void addOnUidImportanceListener(OnUidImportanceListener listener,
@RunningAppProcessInfo.Importance int importanceCutpoint) {
synchronized (this) {
* @hide
*/
@SystemApi @TestApi
+ @RequiresPermission(Manifest.permission.PACKAGE_USAGE_STATS)
public void removeOnUidImportanceListener(OnUidImportanceListener listener) {
synchronized (this) {
UidObserver observer = mImportanceListeners.remove(listener);
* @hide
*/
@SystemApi
+ @RequiresPermission(anyOf = {
+ "android.permission.INTERACT_ACROSS_USERS",
+ "android.permission.INTERACT_ACROSS_USERS_FULL"
+ })
public static int getCurrentUser() {
UserInfo ui;
try {
import android.annotation.IntDef;
import android.annotation.SdkConstant;
import android.annotation.SystemApi;
+import android.annotation.SystemService;
import android.content.Context;
import android.content.Intent;
import android.os.Build;
* {@link #setExact(int, long, PendingIntent)}. Applications whose {@code targetSdkVersion}
* is earlier than API 19 will continue to see the previous behavior in which all
* alarms are delivered exactly when requested.
- *
- * <p>You do not
- * instantiate this class directly; instead, retrieve it through
- * {@link android.content.Context#getSystemService
- * Context.getSystemService(Context.ALARM_SERVICE)}.
*/
+@SystemService(Context.ALARM_SERVICE)
public class AlarmManager {
private static final String TAG = "AlarmManager";
package android.app;
import android.Manifest;
+import android.annotation.RequiresPermission;
import android.annotation.SystemApi;
+import android.annotation.SystemService;
import android.app.usage.UsageStatsManager;
import android.content.Context;
import android.media.AudioAttributes.AttributeUsage;
* API for interacting with "application operation" tracking.
*
* <p>This API is not generally intended for third party application developers; most
- * features are only available to system applications. Obtain an instance of it through
- * {@link Context#getSystemService(String) Context.getSystemService} with
- * {@link Context#APP_OPS_SERVICE Context.APP_OPS_SERVICE}.</p>
+ * features are only available to system applications.
*/
+@SystemService(Context.APP_OPS_SERVICE)
public class AppOpsManager {
/**
* <p>App ops allows callers to:</p>
* @hide
*/
@SystemApi
+ @RequiresPermission(android.Manifest.permission.UPDATE_APP_OPS_STATS)
public void setUidMode(String appOp, int uid, int mode) {
try {
mService.setUidMode(AppOpsManager.strOpToOp(appOp), uid, mode);
package android.app;
+import android.annotation.RequiresPermission;
import android.annotation.SystemApi;
import android.os.Build;
import android.os.Bundle;
* power whitelist when this broadcast is being delivered to it.
* @param duration The duration in milliseconds; 0 means to not place on whitelist.
*/
+ @RequiresPermission(android.Manifest.permission.CHANGE_DEVICE_IDLE_TEMP_WHITELIST)
public void setTemporaryAppWhitelistDuration(long duration) {
mTemporaryAppWhitelistDuration = duration;
}
import android.annotation.Nullable;
import android.annotation.SdkConstant;
import android.annotation.SystemApi;
+import android.annotation.SystemService;
import android.annotation.SdkConstant.SdkConstantType;
import android.content.ContentResolver;
import android.content.ContentUris;
* request that a URI be downloaded to a particular destination file. The download manager will
* conduct the download in the background, taking care of HTTP interactions and retrying downloads
* after failures or across connectivity changes and system reboots.
- *
- * Instances of this class should be obtained through
- * {@link android.content.Context#getSystemService(String)} by passing
- * {@link android.content.Context#DOWNLOAD_SERVICE}.
- *
+ * <p>
* Apps that request downloads through this API should register a broadcast receiver for
* {@link #ACTION_NOTIFICATION_CLICKED} to appropriately handle when the user clicks on a running
* download in a notification or from the downloads UI.
- *
+ * <p>
* Note that the application must have the {@link android.Manifest.permission#INTERNET}
* permission to use this class.
*/
+@SystemService(Context.DOWNLOAD_SERVICE)
public class DownloadManager {
/**
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.annotation.RequiresPermission;
+import android.annotation.SystemService;
import android.app.trust.ITrustManager;
import android.content.Context;
import android.content.Intent;
import java.util.List;
/**
- * Class that can be used to lock and unlock the keyboard. Get an instance of this
- * class by calling {@link android.content.Context#getSystemService(java.lang.String)}
- * with argument {@link android.content.Context#KEYGUARD_SERVICE}. The
+ * Class that can be used to lock and unlock the keyboard. The
* actual class to control the keyboard locking is
* {@link android.app.KeyguardManager.KeyguardLock}.
*/
+@SystemService(Context.KEYGUARD_SERVICE)
public class KeyguardManager {
private static final String TAG = "KeyguardManager";
import android.annotation.DrawableRes;
import android.annotation.IntDef;
import android.annotation.NonNull;
+import android.annotation.RequiresPermission;
import android.annotation.SdkConstant;
import android.annotation.SdkConstant.SdkConstantType;
import android.annotation.SystemApi;
* @hide
*/
@SystemApi
+ @RequiresPermission(android.Manifest.permission.NOTIFICATION_DURING_SETUP)
public static final String EXTRA_ALLOW_DURING_SETUP = "android.allowDuringSetup";
/**
/** @hide */
@SystemApi
+ @RequiresPermission(android.Manifest.permission.SUBSTITUTE_NOTIFICATION_APP_NAME)
public static final String EXTRA_SUBSTITUTE_APP_NAME = "android.substName";
/**
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.annotation.SdkConstant;
+import android.annotation.SystemService;
import android.annotation.TestApi;
import android.app.Notification.Builder;
import android.content.ComponentName;
* to the {@link #cancel(int)} or {@link #cancel(String, int)} method to clear
* this notification.
*
- * <p>
- * You do not instantiate this class directly; instead, retrieve it through
- * {@link android.content.Context#getSystemService}.
- *
* <div class="special reference">
* <h3>Developer Guides</h3>
* <p>For a guide to creating notifications, read the
* </div>
*
* @see android.app.Notification
- * @see android.content.Context#getSystemService
*/
-public class NotificationManager
-{
+@SystemService(Context.NOTIFICATION_SERVICE)
+public class NotificationManager {
private static String TAG = "NotificationManager";
private static boolean localLOGV = false;
package android.app;
+import android.annotation.SystemService;
import android.content.ActivityNotFoundException;
import android.content.ComponentName;
import android.content.ContentResolver;
* services are provided through methods in {@link android.app.Activity Activity}
* and the {@link android.content.Intent#ACTION_SEARCH ACTION_SEARCH}
* {@link android.content.Intent Intent}.
- * If you do require direct access to the SearchManager, do not instantiate
- * this class directly. Instead, retrieve it through
- * {@link android.content.Context#getSystemService
- * context.getSystemService(Context.SEARCH_SERVICE)}.
*
* <div class="special reference">
* <h3>Developer Guides</h3>
* <a href="{@docRoot}guide/topics/search/index.html">Search</a> developer guide.</p>
* </div>
*/
+@SystemService(Context.SEARCH_SERVICE)
public class SearchManager
- implements DialogInterface.OnDismissListener, DialogInterface.OnCancelListener
-{
+ implements DialogInterface.OnDismissListener, DialogInterface.OnCancelListener {
private static final boolean DBG = false;
private static final String TAG = "SearchManager";
package android.app;
import android.annotation.IntDef;
+import android.annotation.SystemService;
import android.content.Context;
import android.os.Binder;
import android.os.RemoteException;
*
* @hide
*/
+@SystemService(Context.STATUS_BAR_SERVICE)
public class StatusBarManager {
public static final int DISABLE_EXPAND = View.STATUS_BAR_DISABLE_EXPAND;
package android.app;
import android.annotation.IntDef;
+import android.annotation.SystemService;
import android.annotation.TestApi;
import android.content.Context;
import android.content.res.Configuration;
* displayed allowing the user to exit dock mode. Thus the dock mode
* represented here may be different than the current state of the underlying
* dock event broadcast.
- *
- * <p>You do not instantiate this class directly; instead, retrieve it through
- * {@link android.content.Context#getSystemService
- * Context.getSystemService(Context.UI_MODE_SERVICE)}.
*/
+@SystemService(Context.UI_MODE_SERVICE)
public class UiModeManager {
private static final String TAG = "UiModeManager";
package android.app;
+import android.annotation.RequiresPermission;
import android.annotation.SystemApi;
+import android.annotation.SystemService;
import android.content.ComponentName;
+import android.content.Context;
import android.os.RemoteException;
import android.service.vr.IVrManager;
/**
* Used to control aspects of a devices Virtual Reality (VR) capabilities.
- * <p>
- * You do not instantiate this class directly; instead, retrieve it through
- * {@link android.content.Context#getSystemService}.
* @hide
*/
@SystemApi
+@SystemService(Context.VR_SERVICE)
public class VrManager {
private final IVrManager mService;
* remain in VR mode even if the foreground does not specify Vr mode being enabled. Mainly used
* by VR viewers to indicate that a device is placed in a VR viewer.
*
- * <p>Requires {@link android.Manifest.permission#ACCESS_VR_MANAGER} permission.</p>
- *
* @see Activity#setVrModeEnabled(boolean, ComponentName)
* @param enabled true if the device should be placed in persistent VR mode.
*/
+ @RequiresPermission(android.Manifest.permission.RESTRICTED_VR_ACCESS)
public void setPersistentVrModeEnabled(boolean enabled) {
try {
mService.setPersistentVrModeEnabled(enabled);
* Sets the resolution and DPI of the vr2d virtual display used to display 2D
* applications in VR mode.
*
- * <p>Requires {@link android.Manifest.permission#ACCESS_VR_MANAGER} permission.</p>
- *
* @param vr2dDisplayProp properties to be set to the virtual display for
* 2D applications in VR mode.
*
* {@hide}
*/
+ @RequiresPermission(android.Manifest.permission.RESTRICTED_VR_ACCESS)
public void setVr2dDisplayProperties(
Vr2dDisplayProperties vr2dDisplayProp) {
try {
import android.annotation.IntDef;
import android.annotation.RawRes;
+import android.annotation.RequiresPermission;
import android.annotation.SdkConstant;
import android.annotation.SystemApi;
+import android.annotation.SystemService;
import android.annotation.SdkConstant.SdkConstantType;
import android.content.ComponentName;
import android.content.ContentResolver;
/**
* Provides access to the system wallpaper. With WallpaperManager, you can
* get the current wallpaper, get the desired dimensions for the wallpaper, set
- * the wallpaper, and more. Get an instance of WallpaperManager with
- * {@link #getInstance(android.content.Context) getInstance()}.
+ * the wallpaper, and more.
*
* <p> An app can check whether wallpapers are supported for the current user, by calling
* {@link #isWallpaperSupported()}, and whether setting of wallpapers is allowed, by calling
* {@link #isSetWallpaperAllowed()}.
*/
+@SystemService(Context.WALLPAPER_SERVICE)
public class WallpaperManager {
private static String TAG = "WallpaperManager";
private static boolean DEBUG = false;
* @hide
*/
@SystemApi
+ @RequiresPermission(android.Manifest.permission.SET_WALLPAPER_HINTS)
public void setDisplayPadding(Rect padding) {
try {
if (sGlobals.mService == null) {
* @hide
*/
@SystemApi
+ @RequiresPermission(android.Manifest.permission.SET_WALLPAPER)
public void clearWallpaper() {
clearWallpaper(FLAG_LOCK, mContext.getUserId());
clearWallpaper(FLAG_SYSTEM, mContext.getUserId());
* @hide
*/
@SystemApi
+ @RequiresPermission(android.Manifest.permission.SET_WALLPAPER)
public void clearWallpaper(@SetWallpaperFlags int which, int userId) {
if (sGlobals.mService == null) {
Log.w(TAG, "WallpaperService not running");
/**
* Set the live wallpaper.
*
- * This can only be called by packages with android.permission.SET_WALLPAPER_COMPONENT
- * permission.
- *
* @hide
*/
@SystemApi
+ @RequiresPermission(android.Manifest.permission.SET_WALLPAPER_COMPONENT)
public boolean setWallpaperComponent(ComponentName name) {
return setWallpaperComponent(name, UserHandle.myUserId());
}
import android.annotation.IntDef;
import android.annotation.NonNull;
import android.annotation.Nullable;
+import android.annotation.RequiresPermission;
import android.annotation.SdkConstant;
import android.annotation.SdkConstant.SdkConstantType;
+import android.annotation.SuppressLint;
import android.annotation.SystemApi;
+import android.annotation.SystemService;
import android.annotation.TestApi;
import android.annotation.UserIdInt;
import android.annotation.WorkerThread;
* "{@docRoot}guide/topics/admin/device-admin.html">Device Administration</a> developer
* guide. </div>
*/
+@SystemService(Context.DEVICE_POLICY_SERVICE)
public class DevicePolicyManager {
private static String TAG = "DevicePolicyManager";
*/
@Deprecated
@SystemApi
+ @SuppressLint("Doclava125")
public @Nullable String getDeviceInitializerApp() {
return null;
}
*/
@Deprecated
@SystemApi
+ @SuppressLint("Doclava125")
public @Nullable ComponentName getDeviceInitializerComponent() {
return null;
}
*/
@Deprecated
@SystemApi
+ @RequiresPermission(android.Manifest.permission.MANAGE_DEVICE_ADMINS)
public boolean setActiveProfileOwner(@NonNull ComponentName admin, @Deprecated String ownerName)
throws IllegalArgumentException {
throwIfParentInstance("setActiveProfileOwner");
* Called by the system update service to notify device and profile owners of pending system
* updates.
*
- * The caller must hold {@link android.Manifest.permission#NOTIFY_PENDING_SYSTEM_UPDATE}
- * permission. This method should only be used when it is unknown whether the pending system
+ * This method should only be used when it is unknown whether the pending system
* update is a security patch. Otherwise, use
* {@link #notifyPendingSystemUpdate(long, boolean)}.
*
* @hide
*/
@SystemApi
+ @RequiresPermission(android.Manifest.permission.NOTIFY_PENDING_SYSTEM_UPDATE)
public void notifyPendingSystemUpdate(long updateReceivedTime) {
throwIfParentInstance("notifyPendingSystemUpdate");
if (mService != null) {
* Called by the system update service to notify device and profile owners of pending system
* updates.
*
- * The caller must hold {@link android.Manifest.permission#NOTIFY_PENDING_SYSTEM_UPDATE}
- * permission. This method should be used instead of {@link #notifyPendingSystemUpdate(long)}
+ * This method should be used instead of {@link #notifyPendingSystemUpdate(long)}
* when it is known whether the pending system update is a security patch.
*
* @param updateReceivedTime The time as given by {@link System#currentTimeMillis()}
* @hide
*/
@SystemApi
+ @RequiresPermission(android.Manifest.permission.NOTIFY_PENDING_SYSTEM_UPDATE)
public void notifyPendingSystemUpdate(long updateReceivedTime, boolean isSecurityPatch) {
throwIfParentInstance("notifyPendingSystemUpdate");
if (mService != null) {
* @hide
*/
@SystemApi
+ @RequiresPermission(android.Manifest.permission.MANAGE_USERS)
public void setDeviceProvisioningConfigApplied() {
try {
mService.setDeviceProvisioningConfigApplied();
package android.app.backup;
+import android.annotation.RequiresPermission;
import android.annotation.SystemApi;
import android.content.ComponentName;
import android.content.Context;
* @hide
*/
@SystemApi
+ @RequiresPermission(android.Manifest.permission.BACKUP)
public RestoreSession beginRestoreSession() {
RestoreSession session = null;
checkServiceBinder();
* mechanism was disabled will still be backed up properly if it is enabled
* at some point in the future.
*
- * <p>Callers must hold the android.permission.BACKUP permission to use this method.
- *
* @hide
*/
@SystemApi
+ @RequiresPermission(android.Manifest.permission.BACKUP)
public void setBackupEnabled(boolean isEnabled) {
checkServiceBinder();
if (sService != null) {
/**
* Report whether the backup mechanism is currently enabled.
*
- * <p>Callers must hold the android.permission.BACKUP permission to use this method.
- *
* @hide
*/
@SystemApi
+ @RequiresPermission(android.Manifest.permission.BACKUP)
public boolean isBackupEnabled() {
checkServiceBinder();
if (sService != null) {
* the archival restore dataset (if any). When disabled, no such attempt will
* be made.
*
- * <p>Callers must hold the android.permission.BACKUP permission to use this method.
- *
* @hide
*/
@SystemApi
+ @RequiresPermission(android.Manifest.permission.BACKUP)
public void setAutoRestore(boolean isEnabled) {
checkServiceBinder();
if (sService != null) {
}
/**
- * Identify the currently selected transport. Callers must hold the
- * android.permission.BACKUP permission to use this method.
+ * Identify the currently selected transport.
* @return The name of the currently active backup transport. In case of
* failure or if no transport is currently active, this method returns {@code null}.
*
* @hide
*/
@SystemApi
+ @RequiresPermission(android.Manifest.permission.BACKUP)
public String getCurrentTransport() {
checkServiceBinder();
if (sService != null) {
}
/**
- * Request a list of all available backup transports' names. Callers must
- * hold the android.permission.BACKUP permission to use this method.
+ * Request a list of all available backup transports' names.
*
* @hide
*/
@SystemApi
+ @RequiresPermission(android.Manifest.permission.BACKUP)
public String[] listAllTransports() {
checkServiceBinder();
if (sService != null) {
/**
* Specify the current backup transport.
*
- * <p> Callers must hold the android.permission.BACKUP permission to use this method.
- *
* @param transport The name of the transport to select. This should be one
* of the names returned by {@link #listAllTransports()}. This is the String returned by
* {@link BackupTransport#name()} for the particular transport.
*/
@Deprecated
@SystemApi
+ @RequiresPermission(android.Manifest.permission.BACKUP)
public String selectBackupTransport(String transport) {
checkServiceBinder();
if (sService != null) {
* This method is async because BackupManager might need to bind to the specified transport
* which is in a separate process.
*
- * <p>Callers must hold the android.permission.BACKUP permission to use this method.
- *
* @param transport ComponentName of the service hosting the transport. This is different from
* the transport's name that is returned by {@link BackupTransport#name()}.
* @param listener A listener object to get a callback on the transport being selected.
* @hide
*/
@SystemApi
+ @RequiresPermission(android.Manifest.permission.BACKUP)
public void selectBackupTransport(ComponentName transport,
SelectBackupTransportCallback listener) {
checkServiceBinder();
* transport will still be asked to confirm via the usual requestBackupTime()
* method.
*
- * <p>Callers must hold the android.permission.BACKUP permission to use this method.
- *
* @hide
*/
@SystemApi
+ @RequiresPermission(android.Manifest.permission.BACKUP)
public void backupNow() {
checkServiceBinder();
if (sService != null) {
* Ask the framework which dataset, if any, the given package's data would be
* restored from if we were to install it right now.
*
- * <p>Callers must hold the android.permission.BACKUP permission to use this method.
- *
* @param packageName The name of the package whose most-suitable dataset we
* wish to look up
* @return The dataset token from which a restore should be attempted, or zero if
* @hide
*/
@SystemApi
+ @RequiresPermission(android.Manifest.permission.BACKUP)
public long getAvailableRestoreToken(String packageName) {
checkServiceBinder();
if (sService != null) {
/**
* Ask the framework whether this app is eligible for backup.
*
- * <p>Callers must hold the android.permission.BACKUP permission to use this method.
- *
* @param packageName The name of the package.
* @return Whether this app is eligible for backup.
*
* @hide
*/
@SystemApi
+ @RequiresPermission(android.Manifest.permission.BACKUP)
public boolean isAppEligibleForBackup(String packageName) {
checkServiceBinder();
if (sService != null) {
* @hide
*/
@SystemApi
+ @RequiresPermission(android.Manifest.permission.BACKUP)
public int requestBackup(String[] packages, BackupObserver observer) {
return requestBackup(packages, observer, null, 0);
}
* @hide
*/
@SystemApi
+ @RequiresPermission(android.Manifest.permission.BACKUP)
public int requestBackup(String[] packages, BackupObserver observer,
BackupManagerMonitor monitor, int flags) {
checkServiceBinder();
* Cancel all running backups. After this call returns, no currently running backups will
* interact with the selected transport.
*
- * <p>Callers must hold the android.permission.BACKUP permission to use this method.
- *
* @hide
*/
@SystemApi
+ @RequiresPermission(android.Manifest.permission.BACKUP)
public void cancelBackups() {
checkServiceBinder();
if (sService != null) {
import android.annotation.IntDef;
import android.annotation.NonNull;
import android.annotation.Nullable;
+import android.annotation.RequiresPermission;
import android.annotation.SystemApi;
+import android.annotation.SystemService;
import android.content.ClipData;
+import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.os.PersistableBundle;
* {@link android.content.Context#getSystemService
* Context.getSystemService(Context.JOB_SCHEDULER_SERVICE)}.
*/
+@SystemService(Context.JOB_SCHEDULER_SERVICE)
public abstract class JobScheduler {
/** @hide */
@IntDef(prefix = { "RESULT_" }, value = {
* @hide
*/
@SystemApi
+ @RequiresPermission(android.Manifest.permission.UPDATE_DEVICE_STATS)
public abstract @Result int scheduleAsPackage(@NonNull JobInfo job, @NonNull String packageName,
int userId, String tag);
import android.Manifest;
import android.annotation.RequiresPermission;
+import android.annotation.SystemService;
+import android.content.Context;
import android.os.Handler;
import android.os.IBinder;
import android.os.Looper;
* See {@link com.android.server.trust.TrustManagerService}
* @hide
*/
+@SystemService(Context.TRUST_SERVICE)
public class TrustManager {
private static final int MSG_TRUST_CHANGED = 1;
import static com.android.internal.util.Preconditions.checkNotNull;
import android.annotation.Nullable;
+import android.annotation.SystemService;
import android.app.usage.NetworkStats.Bucket;
import android.content.Context;
import android.net.ConnectivityManager;
* the above permission, even to access an app's own data usage, and carrier-privileged apps were
* not included.
*/
+@SystemService(Context.NETWORK_STATS_SERVICE)
public class NetworkStatsManager {
private static final String TAG = "NetworkStatsManager";
private static final boolean DBG = false;
import android.annotation.BytesLong;
import android.annotation.NonNull;
+import android.annotation.SystemService;
import android.annotation.TestApi;
import android.annotation.WorkerThread;
import android.content.Context;
* application.
* </p>
*/
+@SystemService(Context.STORAGE_STATS_SERVICE)
public class StorageStatsManager {
private final Context mContext;
private final IStorageStatsManager mService;
package android.app.usage;
+import android.annotation.RequiresPermission;
import android.annotation.SystemApi;
+import android.annotation.SystemService;
import android.content.Context;
import android.content.pm.ParceledListSlice;
import android.os.RemoteException;
* the permission implies intention to use the API and the user of the device can grant permission
* through the Settings application.
*/
+@SystemService(Context.USAGE_STATS_SERVICE)
public final class UsageStatsManager {
/**
* Temporarily whitelist the specified app for a short duration. This is to allow an app
* receiving a high priority message to be able to access the network and acquire wakelocks
* even if the device is in power-save mode or the app is currently considered inactive.
- * The caller must hold the CHANGE_DEVICE_IDLE_TEMP_WHITELIST permission.
* @param packageName The package name of the app to whitelist.
* @param duration Duration to whitelist the app for, in milliseconds. It is recommended that
* this be limited to 10s of seconds. Requested duration will be clamped to a few minutes.
* @see #isAppInactive(String)
*/
@SystemApi
+ @RequiresPermission(android.Manifest.permission.CHANGE_DEVICE_IDLE_TEMP_WHITELIST)
public void whitelistAppTemporarily(String packageName, long duration, UserHandle user) {
try {
mService.whitelistAppTemporarily(packageName, duration, user.getIdentifier());
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.annotation.SdkConstant;
+import android.annotation.SystemService;
import android.annotation.SdkConstant.SdkConstantType;
import android.app.PendingIntent;
import android.content.ComponentName;
* <a href="{@docRoot}guide/topics/appwidgets/index.html">App Widgets</a> developer guide.</p>
* </div>
*/
+@SystemService(Context.APPWIDGET_SERVICE)
public class AppWidgetManager {
/**
import android.Manifest;
import android.annotation.RequiresPermission;
+import android.annotation.SystemService;
import android.content.Context;
import android.os.RemoteException;
import android.util.Log;
* @see Context#getSystemService
* @see BluetoothAdapter#getDefaultAdapter()
*/
+@SystemService(Context.BLUETOOTH_SERVICE)
public final class BluetoothManager {
private static final String TAG = "BluetoothManager";
private static final boolean DBG = true;
import android.annotation.NonNull;
import android.annotation.Nullable;
+import android.annotation.SystemService;
import android.app.Activity;
import android.app.Application;
import android.app.PendingIntent;
*
* @see AssociationRequest
*/
+@SystemService(Context.COMPANION_DEVICE_SERVICE)
public final class CompanionDeviceManager {
private static final boolean DEBUG = false;
package android.content;
+import android.annotation.SystemService;
import android.os.Handler;
import android.os.Message;
import android.os.RemoteException;
* the global clipboard.
*
* <p>
- * You do not instantiate this class directly; instead, retrieve it through
- * {@link android.content.Context#getSystemService}.
- *
- * <p>
* The ClipboardManager API itself is very simple: it consists of methods
* to atomically get and set the current primary clipboard data. That data
* is expressed as a {@link ClipData} object, which defines the protocol
* <a href="{@docRoot}guide/topics/clipboard/copy-paste.html">Copy and Paste</a>
* developer guide.</p>
* </div>
- *
- * @see android.content.Context#getSystemService
*/
+@SystemService(Context.CLIPBOARD_SERVICE)
public class ClipboardManager extends android.text.ClipboardManager {
private final Context mContext;
private final IClipboard mService;
/**
* Version of {@link #startActivity(Intent)} that allows you to specify the
* user the activity will be started for. This is not available to applications
- * that are not pre-installed on the system image. Using it requires holding
- * the INTERACT_ACROSS_USERS_FULL permission.
+ * that are not pre-installed on the system image.
* @param intent The description of the activity to start.
* @param user The UserHandle of the user to start this activity for.
* @throws ActivityNotFoundException
* @hide
*/
+ @RequiresPermission(android.Manifest.permission.INTERACT_ACROSS_USERS_FULL)
public void startActivityAsUser(@RequiresPermission Intent intent, UserHandle user) {
throw new RuntimeException("Not implemented. Must override in a subclass.");
}
/**
* Version of {@link #startActivity(Intent, Bundle)} that allows you to specify the
* user the activity will be started for. This is not available to applications
- * that are not pre-installed on the system image. Using it requires holding
- * the INTERACT_ACROSS_USERS_FULL permission.
+ * that are not pre-installed on the system image.
* @param intent The description of the activity to start.
* @param options Additional options for how the Activity should be started.
* May be null if there are no options. See {@link android.app.ActivityOptions}
* @throws ActivityNotFoundException
* @hide
*/
+ @RequiresPermission(android.Manifest.permission.INTERACT_ACROSS_USERS_FULL)
public void startActivityAsUser(@RequiresPermission Intent intent, @Nullable Bundle options,
UserHandle userId) {
throw new RuntimeException("Not implemented. Must override in a subclass.");
* @see #startActivities(Intent[])
* @see PackageManager#resolveActivity
*/
+ @RequiresPermission(android.Manifest.permission.INTERACT_ACROSS_USERS_FULL)
public void startActivitiesAsUser(Intent[] intents, Bundle options, UserHandle userHandle) {
throw new RuntimeException("Not implemented. Must override in a subclass.");
}
/**
* Version of {@link #sendBroadcast(Intent)} that allows you to specify the
* user the broadcast will be sent to. This is not available to applications
- * that are not pre-installed on the system image. Using it requires holding
- * the INTERACT_ACROSS_USERS permission.
+ * that are not pre-installed on the system image.
* @param intent The intent to broadcast
* @param user UserHandle to send the intent to.
* @see #sendBroadcast(Intent)
*/
+ @RequiresPermission(android.Manifest.permission.INTERACT_ACROSS_USERS)
public abstract void sendBroadcastAsUser(@RequiresPermission Intent intent,
UserHandle user);
/**
* Version of {@link #sendBroadcast(Intent, String)} that allows you to specify the
* user the broadcast will be sent to. This is not available to applications
- * that are not pre-installed on the system image. Using it requires holding
- * the INTERACT_ACROSS_USERS permission.
+ * that are not pre-installed on the system image.
*
* @param intent The Intent to broadcast; all receivers matching this
* Intent will receive the broadcast.
*
* @see #sendBroadcast(Intent, String)
*/
+ @RequiresPermission(android.Manifest.permission.INTERACT_ACROSS_USERS)
public abstract void sendBroadcastAsUser(@RequiresPermission Intent intent,
UserHandle user, @Nullable String receiverPermission);
/**
* Version of {@link #sendBroadcast(Intent, String, Bundle)} that allows you to specify the
* user the broadcast will be sent to. This is not available to applications
- * that are not pre-installed on the system image. Using it requires holding
- * the INTERACT_ACROSS_USERS permission.
+ * that are not pre-installed on the system image.
*
* @param intent The Intent to broadcast; all receivers matching this
* Intent will receive the broadcast.
* @hide
*/
@SystemApi
+ @RequiresPermission(android.Manifest.permission.INTERACT_ACROSS_USERS)
public abstract void sendBroadcastAsUser(@RequiresPermission Intent intent,
UserHandle user, @Nullable String receiverPermission, @Nullable Bundle options);
/**
* Version of {@link #sendBroadcast(Intent, String)} that allows you to specify the
* user the broadcast will be sent to. This is not available to applications
- * that are not pre-installed on the system image. Using it requires holding
- * the INTERACT_ACROSS_USERS permission.
+ * that are not pre-installed on the system image.
*
* @param intent The Intent to broadcast; all receivers matching this
* Intent will receive the broadcast.
*
* @hide
*/
+ @RequiresPermission(android.Manifest.permission.INTERACT_ACROSS_USERS)
public abstract void sendBroadcastAsUser(@RequiresPermission Intent intent,
UserHandle user, @Nullable String receiverPermission, int appOp);
* {@link #sendOrderedBroadcast(Intent, String, BroadcastReceiver, Handler, int, String, Bundle)}
* that allows you to specify the
* user the broadcast will be sent to. This is not available to applications
- * that are not pre-installed on the system image. Using it requires holding
- * the INTERACT_ACROSS_USERS permission.
+ * that are not pre-installed on the system image.
*
* <p>See {@link BroadcastReceiver} for more information on Intent broadcasts.
*
*
* @see #sendOrderedBroadcast(Intent, String, BroadcastReceiver, Handler, int, String, Bundle)
*/
+ @RequiresPermission(android.Manifest.permission.INTERACT_ACROSS_USERS)
public abstract void sendOrderedBroadcastAsUser(@RequiresPermission Intent intent,
UserHandle user, @Nullable String receiverPermission, BroadcastReceiver resultReceiver,
@Nullable Handler scheduler, int initialCode, @Nullable String initialData,
* BroadcastReceiver, Handler, int, String, Bundle)
* @hide
*/
+ @RequiresPermission(android.Manifest.permission.INTERACT_ACROSS_USERS)
public abstract void sendOrderedBroadcastAsUser(Intent intent, UserHandle user,
@Nullable String receiverPermission, int appOp, BroadcastReceiver resultReceiver,
@Nullable Handler scheduler, int initialCode, @Nullable String initialData,
* BroadcastReceiver, Handler, int, String, Bundle)
* @hide
*/
+ @RequiresPermission(android.Manifest.permission.INTERACT_ACROSS_USERS)
public abstract void sendOrderedBroadcastAsUser(Intent intent, UserHandle user,
@Nullable String receiverPermission, int appOp, @Nullable Bundle options,
BroadcastReceiver resultReceiver, @Nullable Handler scheduler, int initialCode,
/**
* <p>Version of {@link #sendStickyBroadcast(Intent)} that allows you to specify the
* user the broadcast will be sent to. This is not available to applications
- * that are not pre-installed on the system image. Using it requires holding
- * the INTERACT_ACROSS_USERS permission.
+ * that are not pre-installed on the system image.
*
* @deprecated Sticky broadcasts should not be used. They provide no security (anyone
* can access them), no protection (anyone can modify them), and many other problems.
* @see #sendBroadcast(Intent)
*/
@Deprecated
+ @RequiresPermission(allOf = {
+ android.Manifest.permission.INTERACT_ACROSS_USERS,
+ android.Manifest.permission.BROADCAST_STICKY
+ })
public abstract void sendStickyBroadcastAsUser(@RequiresPermission Intent intent,
UserHandle user);
* This is just here for sending CONNECTIVITY_ACTION.
*/
@Deprecated
+ @RequiresPermission(allOf = {
+ android.Manifest.permission.INTERACT_ACROSS_USERS,
+ android.Manifest.permission.BROADCAST_STICKY
+ })
public abstract void sendStickyBroadcastAsUser(@RequiresPermission Intent intent,
UserHandle user, Bundle options);
* {@link #sendStickyOrderedBroadcast(Intent, BroadcastReceiver, Handler, int, String, Bundle)}
* that allows you to specify the
* user the broadcast will be sent to. This is not available to applications
- * that are not pre-installed on the system image. Using it requires holding
- * the INTERACT_ACROSS_USERS permission.
+ * that are not pre-installed on the system image.
*
* <p>See {@link BroadcastReceiver} for more information on Intent broadcasts.
*
* @see #sendStickyOrderedBroadcast(Intent, BroadcastReceiver, Handler, int, String, Bundle)
*/
@Deprecated
+ @RequiresPermission(allOf = {
+ android.Manifest.permission.INTERACT_ACROSS_USERS,
+ android.Manifest.permission.BROADCAST_STICKY
+ })
public abstract void sendStickyOrderedBroadcastAsUser(@RequiresPermission Intent intent,
UserHandle user, BroadcastReceiver resultReceiver,
@Nullable Handler scheduler, int initialCode, @Nullable String initialData,
/**
* <p>Version of {@link #removeStickyBroadcast(Intent)} that allows you to specify the
* user the broadcast will be sent to. This is not available to applications
- * that are not pre-installed on the system image. Using it requires holding
- * the INTERACT_ACROSS_USERS permission.
+ * that are not pre-installed on the system image.
*
* <p>You must hold the {@link android.Manifest.permission#BROADCAST_STICKY}
* permission in order to use this API. If you do not hold that
* @see #sendStickyBroadcastAsUser
*/
@Deprecated
+ @RequiresPermission(allOf = {
+ android.Manifest.permission.INTERACT_ACROSS_USERS,
+ android.Manifest.permission.BROADCAST_STICKY
+ })
public abstract void removeStickyBroadcastAsUser(@RequiresPermission Intent intent,
UserHandle user);
* @hide
* Same as {@link #registerReceiver(BroadcastReceiver, IntentFilter, String, Handler)
* but for a specific user. This receiver will receiver broadcasts that
- * are sent to the requested user. It
- * requires holding the {@link android.Manifest.permission#INTERACT_ACROSS_USERS_FULL}
- * permission.
+ * are sent to the requested user.
*
* @param receiver The BroadcastReceiver to handle the broadcast.
* @param user UserHandle to send the intent to.
* @see #unregisterReceiver
*/
@Nullable
+ @RequiresPermission(android.Manifest.permission.INTERACT_ACROSS_USERS_FULL)
public abstract Intent registerReceiverAsUser(BroadcastReceiver receiver,
UserHandle user, IntentFilter filter, @Nullable String broadcastPermission,
@Nullable Handler scheduler);
* @hide like {@link #startForegroundService(Intent)} but for a specific user.
*/
@Nullable
+ @RequiresPermission(android.Manifest.permission.INTERACT_ACROSS_USERS)
public abstract ComponentName startForegroundServiceAsUser(Intent service, UserHandle user);
/**
* @hide like {@link #startService(Intent)} but for a specific user.
*/
@Nullable
+ @RequiresPermission(android.Manifest.permission.INTERACT_ACROSS_USERS)
public abstract ComponentName startServiceAsUser(Intent service, UserHandle user);
/**
* @hide like {@link #stopService(Intent)} but for a specific user.
*/
+ @RequiresPermission(android.Manifest.permission.INTERACT_ACROSS_USERS)
public abstract boolean stopServiceAsUser(Intent service, UserHandle user);
/**
*/
@SystemApi
@SuppressWarnings("unused")
+ @RequiresPermission(android.Manifest.permission.INTERACT_ACROSS_USERS)
public boolean bindServiceAsUser(@RequiresPermission Intent service, ServiceConnection conn,
int flags, UserHandle user) {
throw new RuntimeException("Not implemented. Must override in a subclass.");
*
* @hide
*/
+ @RequiresPermission(android.Manifest.permission.INTERACT_ACROSS_USERS)
public boolean bindServiceAsUser(Intent service, ServiceConnection conn, int flags,
Handler handler, UserHandle user) {
throw new RuntimeException("Not implemented. Must override in a subclass.");
package android.content;
+import android.annotation.SystemService;
import android.app.Activity;
import android.app.admin.DevicePolicyManager;
import android.content.pm.ApplicationInfo;
* @see DevicePolicyManager#setRestrictionsProvider(ComponentName, ComponentName)
* @see DevicePolicyManager#setApplicationRestrictions(ComponentName, String, Bundle)
*/
+@SystemService(Context.RESTRICTIONS_SERVICE)
public class RestrictionsManager {
private static final String TAG = "RestrictionsManager";
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.annotation.SdkConstant;
+import android.annotation.SystemService;
import android.annotation.SdkConstant.SdkConstantType;
import android.annotation.TestApi;
import android.app.PendingIntent;
* Note as of Android O, apps on a managed profile are no longer allowed to access apps on the
* main profile. Apps can only access profiles returned by {@link #getProfiles()}.
*/
+@SystemService(Context.LAUNCHER_APPS_SERVICE)
public class LauncherApps {
static final String TAG = "LauncherApps";
/** {@hide} */
@SystemApi
+ @RequiresPermission(android.Manifest.permission.INSTALL_PACKAGES)
public void setPermissionsResult(int sessionId, boolean accepted) {
try {
mInstaller.setPermissionsResult(sessionId, accepted);
/** {@hide} */
@SystemApi
+ @RequiresPermission(android.Manifest.permission.ALLOCATE_AGGRESSIVE)
public void setAllocateAggressive(boolean allocateAggressive) {
if (allocateAggressive) {
installFlags |= PackageManager.INSTALL_ALLOCATE_AGGRESSIVE;
/**
* Return a List of all packages that are installed on the device, for a
- * specific user. Requesting a list of installed packages for another user
- * will require the permission INTERACT_ACROSS_USERS_FULL.
+ * specific user.
*
* @param flags Additional option flags to modify the data returned.
* @param userId The user for whom the installed packages are to be listed
* @hide
*/
@SystemApi
+ @RequiresPermission(android.Manifest.permission.INTERACT_ACROSS_USERS_FULL)
public abstract List<PackageInfo> getInstalledPackagesAsUser(@PackageInfoFlags int flags,
@UserIdInt int userId);
* @hide
*/
@SystemApi
+ @RequiresPermission(android.Manifest.permission.GRANT_RUNTIME_PERMISSIONS)
public abstract void grantRuntimePermission(@NonNull String packageName,
@NonNull String permissionName, @NonNull UserHandle user);
* @hide
*/
@SystemApi
+ @RequiresPermission(android.Manifest.permission.REVOKE_RUNTIME_PERMISSIONS)
public abstract void revokeRuntimePermission(@NonNull String packageName,
@NonNull String permissionName, @NonNull UserHandle user);
* @hide
*/
@SystemApi
+ @RequiresPermission(anyOf = {
+ android.Manifest.permission.GRANT_RUNTIME_PERMISSIONS,
+ android.Manifest.permission.REVOKE_RUNTIME_PERMISSIONS
+ })
public abstract @PermissionFlags int getPermissionFlags(String permissionName,
String packageName, @NonNull UserHandle user);
* @hide
*/
@SystemApi
+ @RequiresPermission(anyOf = {
+ android.Manifest.permission.GRANT_RUNTIME_PERMISSIONS,
+ android.Manifest.permission.REVOKE_RUNTIME_PERMISSIONS
+ })
public abstract void updatePermissionFlags(String permissionName,
String packageName, @PermissionFlags int flagMask, @PermissionFlags int flagValues,
@NonNull UserHandle user);
* @hide
*/
@SystemApi
+ @RequiresPermission(android.Manifest.permission.INTENT_FILTER_VERIFICATION_AGENT)
public abstract void verifyIntentFilter(int verificationId, int verificationCode,
List<String> failedDomains);
* @hide
*/
@SystemApi
+ @RequiresPermission(android.Manifest.permission.SET_PREFERRED_APPLICATIONS)
public abstract boolean updateIntentVerificationStatusAsUser(String packageName, int status,
@UserIdInt int userId);
* @hide
*/
@SystemApi
+ @RequiresPermission(android.Manifest.permission.SET_PREFERRED_APPLICATIONS)
public abstract boolean setDefaultBrowserPackageNameAsUser(String packageName,
@UserIdInt int userId);
* @hide
*/
@SystemApi
+ @RequiresPermission(Manifest.permission.OBSERVE_GRANT_REVOKE_PERMISSIONS)
public abstract void removeOnPermissionsChangeListener(OnPermissionsChangedListener listener);
/**
import android.annotation.NonNull;
import android.annotation.Nullable;
+import android.annotation.SystemService;
import android.annotation.TestApi;
import android.annotation.UserIdInt;
import android.app.Activity;
* All shortcut information is stored in credential encrypted storage, so no shortcuts can be
* accessed when the user is locked.
*/
+@SystemService(Context.SHORTCUT_SERVICE)
public class ShortcutManager {
private static final String TAG = "ShortcutManager";
package android.hardware;
+import android.annotation.SystemService;
import android.content.Context;
import android.os.RemoteException;
import android.os.ServiceManager;
/**
* Class that operates consumer infrared on the device.
- *
- * <p>
- * To obtain an instance of the system infrared transmitter, call
- * {@link android.content.Context#getSystemService(java.lang.String)
- * Context.getSystemService()} with
- * {@link android.content.Context#CONSUMER_IR_SERVICE} as the argument.
- * </p>
*/
+@SystemService(Context.CONSUMER_IR_SERVICE)
public final class ConsumerIrManager {
private static final String TAG = "ConsumerIr";
package android.hardware;
import android.annotation.SystemApi;
+import android.annotation.SystemService;
+import android.content.Context;
import android.os.Build;
import android.os.Handler;
import android.os.MemoryFile;
/**
* <p>
* SensorManager lets you access the device's {@link android.hardware.Sensor
- * sensors}. Get an instance of this class by calling
- * {@link android.content.Context#getSystemService(java.lang.String)
- * Context.getSystemService()} with the argument
- * {@link android.content.Context#SENSOR_SERVICE}.
+ * sensors}.
* </p>
* <p>
* Always make sure to disable sensors you don't need, especially when your
* @see Sensor
*
*/
+@SystemService(Context.SENSOR_SERVICE)
public abstract class SensorManager {
/** @hide */
protected static final String TAG = "SensorManager";
package android.hardware;
+import android.annotation.SystemService;
import android.content.Context;
import android.os.ParcelFileDescriptor;
import android.os.RemoteException;
/**
* @hide
*/
+@SystemService(Context.SERIAL_SERVICE)
public class SerialManager {
private static final String TAG = "SerialManager";
package android.hardware.camera2;
import android.annotation.RequiresPermission;
+import android.annotation.SystemService;
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.content.Context;
* <p>A system service manager for detecting, characterizing, and connecting to
* {@link CameraDevice CameraDevices}.</p>
*
- * <p>You can get an instance of this class by calling
- * {@link android.content.Context#getSystemService(String) Context.getSystemService()}.</p>
- *
- * <pre>CameraManager manager = (CameraManager) getSystemService(Context.CAMERA_SERVICE);</pre>
- *
* <p>For more details about communicating with camera devices, read the Camera
* developer guide or the {@link android.hardware.camera2 camera2}
* package documentation.</p>
*/
+@SystemService(Context.CAMERA_SERVICE)
public final class CameraManager {
private static final String TAG = "CameraManager";
import android.annotation.NonNull;
import android.annotation.Nullable;
+import android.annotation.SystemService;
import android.content.Context;
import android.media.projection.MediaProjection;
import android.os.Handler;
/**
* Manages the properties of attached displays.
- * <p>
- * Get an instance of this class by calling
- * {@link android.content.Context#getSystemService(java.lang.String)
- * Context.getSystemService()} with the argument
- * {@link android.content.Context#DISPLAY_SERVICE}.
- * </p>
*/
+@SystemService(Context.DISPLAY_SERVICE)
public final class DisplayManager {
private static final String TAG = "DisplayManager";
private static final boolean DEBUG = false;
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.annotation.RequiresPermission;
+import android.annotation.SystemService;
import android.app.ActivityManager;
import android.content.Context;
import android.os.Binder;
/**
* A class that coordinates access to the fingerprint hardware.
- * <p>
- * Use {@link android.content.Context#getSystemService(java.lang.String)}
- * with argument {@link android.content.Context#FINGERPRINT_SERVICE} to get
- * an instance of this class.
*/
-
+@SystemService(Context.FINGERPRINT_SERVICE)
public class FingerprintManager {
private static final String TAG = "FingerprintManager";
private static final boolean DEBUG = true;
import android.annotation.Nullable;
import android.annotation.SdkConstant;
import android.annotation.SdkConstant.SdkConstantType;
+import android.content.Context;
import android.annotation.SystemApi;
+import android.annotation.SystemService;
import android.os.RemoteException;
import android.util.ArrayMap;
import android.util.Log;
* @hide
*/
@SystemApi
+@SystemService(Context.HDMI_CONTROL_SERVICE)
public final class HdmiControlManager {
private static final String TAG = "HdmiControlManager";
import android.annotation.IntDef;
import android.annotation.Nullable;
import android.annotation.SdkConstant;
+import android.annotation.SystemService;
import android.annotation.SdkConstant.SdkConstantType;
import android.content.Context;
import android.media.AudioAttributes;
/**
* Provides information about input devices and available key layouts.
- * <p>
- * Get an instance of this class by calling
- * {@link android.content.Context#getSystemService(java.lang.String)
- * Context.getSystemService()} with the argument
- * {@link android.content.Context#INPUT_SERVICE}.
- * </p>
*/
+@SystemService(Context.INPUT_SERVICE)
public final class InputManager {
private static final String TAG = "InputManager";
private static final boolean DEBUG = false;
*/
package android.hardware.location;
+import android.annotation.RequiresPermission;
+import android.annotation.SuppressLint;
import android.annotation.SystemApi;
+import android.annotation.SystemService;
import android.content.Context;
import android.os.Handler;
import android.os.Looper;
* @hide
*/
@SystemApi
+@SystemService(Context.CONTEXTHUB_SERVICE)
public final class ContextHubManager {
private static final String TAG = "ContextHubManager";
* Get a handle to all the context hubs in the system
* @return array of context hub handles
*/
+ @RequiresPermission(android.Manifest.permission.LOCATION_HARDWARE)
public int[] getContextHubHandles() {
try {
return mService.getContextHubHandles();
*
* @see ContextHubInfo
*/
+ @RequiresPermission(android.Manifest.permission.LOCATION_HARDWARE)
public ContextHubInfo getContextHubInfo(int hubHandle) {
try {
return mService.getContextHubInfo(hubHandle);
*
* @see NanoApp
*/
+ @RequiresPermission(android.Manifest.permission.LOCATION_HARDWARE)
public int loadNanoApp(int hubHandle, NanoApp app) {
try {
return mService.loadNanoApp(hubHandle, app);
* @return 0 if the command for unloading was sent to the context hub;
* -1 otherwise
*/
+ @RequiresPermission(android.Manifest.permission.LOCATION_HARDWARE)
public int unloadNanoApp(int nanoAppHandle) {
try {
return mService.unloadNanoApp(nanoAppHandle);
*
* @see NanoAppInstanceInfo
*/
+ @RequiresPermission(android.Manifest.permission.LOCATION_HARDWARE)
public NanoAppInstanceInfo getNanoAppInstanceInfo(int nanoAppHandle) {
try {
return mService.getNanoAppInstanceInfo(nanoAppHandle);
*
* @return int[] Array of handles to any found nano apps
*/
+ @RequiresPermission(android.Manifest.permission.LOCATION_HARDWARE)
public int[] findNanoAppOnHub(int hubHandle, NanoAppFilter filter) {
try {
return mService.findNanoAppOnHub(hubHandle, filter);
*
* @return int 0 on success, -1 otherwise
*/
+ @RequiresPermission(android.Manifest.permission.LOCATION_HARDWARE)
public int sendMessage(int hubHandle, int nanoAppHandle, ContextHubMessage message) {
try {
return mService.sendMessage(hubHandle, nanoAppHandle, message);
*
* @return int 0 on success, -1 otherwise
*/
+ @SuppressLint("Doclava125")
public int registerCallback(Callback callback) {
return registerCallback(callback, null);
}
*
* @return int 0 on success, -1 otherwise
*/
+ @SuppressLint("Doclava125")
public int registerCallback(Callback callback, Handler handler) {
synchronized(this) {
if (mCallback != null) {
*
* @return int 0 on success, -1 otherwise
*/
+ @SuppressLint("Doclava125")
public int unregisterCallback(Callback callback) {
synchronized(this) {
if (callback != mCallback) {
package android.hardware.radio;
import android.annotation.SystemApi;
+import android.annotation.SystemService;
import android.content.Context;
import android.os.Handler;
import android.os.Parcel;
* @hide
*/
@SystemApi
+@SystemService(Context.RADIO_SERVICE)
public class RadioManager {
/** Method return status: successful operation */
import android.annotation.Nullable;
import android.annotation.SdkConstant;
+import android.annotation.SystemService;
import android.annotation.SdkConstant.SdkConstantType;
import android.app.PendingIntent;
import android.content.ComponentName;
* This class allows you to access the state of USB and communicate with USB devices.
* Currently only host mode is supported in the public API.
*
- * <p>You can obtain an instance of this class by calling
- * {@link android.content.Context#getSystemService(java.lang.String) Context.getSystemService()}.
- *
- * {@samplecode
- * UsbManager manager = (UsbManager) getSystemService(Context.USB_SERVICE);}
- *
* <div class="special reference">
* <h3>Developer Guides</h3>
* <p>For more information about communicating with USB hardware, read the
* <a href="{@docRoot}guide/topics/connectivity/usb/index.html">USB developer guide</a>.</p>
* </div>
*/
+@SystemService(Context.USB_SERVICE)
public class UsbManager {
private static final String TAG = "UsbManager";
import android.annotation.SdkConstant;
import android.annotation.SdkConstant.SdkConstantType;
import android.annotation.SystemApi;
+import android.annotation.SystemService;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
/**
* Class that answers queries about the state of network connectivity. It also
- * notifies applications when network connectivity changes. Get an instance
- * of this class by calling
- * {@link android.content.Context#getSystemService(String) Context.getSystemService(Context.CONNECTIVITY_SERVICE)}.
+ * notifies applications when network connectivity changes.
* <p>
* The primary responsibilities of this class are to:
* <ol>
* traffic</li>
* </ol>
*/
+@SystemService(Context.CONNECTIVITY_SERVICE)
public class ConnectivityManager {
private static final String TAG = "ConnectivityManager";
* @hide
*/
@SystemApi
+ @RequiresPermission(android.Manifest.permission.TETHER_PRIVILEGED)
public void startTethering(int type, boolean showProvisioningUi,
final OnStartTetheringCallback callback, Handler handler) {
checkNotNull(callback, "OnStartTetheringCallback cannot be null.");
* @hide
*/
@SystemApi
+ @RequiresPermission(android.Manifest.permission.TETHER_PRIVILEGED)
public void stopTethering(int type) {
try {
mService.stopTethering(type);
package android.net;
+import android.annotation.SystemService;
import android.content.Context;
import android.net.IEthernetManager;
import android.net.IEthernetServiceListener;
*
* @hide
*/
+@SystemService(Context.ETHERNET_SERVICE)
public class EthernetManager {
private static final String TAG = "EthernetManager";
private static final int MSG_AVAILABILITY_CHANGED = 1000;
import static com.android.internal.util.Preconditions.checkNotNull;
import android.annotation.NonNull;
+import android.annotation.SystemService;
+import android.content.Context;
import android.os.Binder;
import android.os.Bundle;
import android.os.ParcelFileDescriptor;
* This class contains methods for managing IPsec sessions, which will perform kernel-space
* encryption and decryption of socket or Network traffic.
*
- * <p>An IpSecManager may be obtained by calling {@link
- * android.content.Context#getSystemService(String) Context#getSystemService(String)} with {@link
- * android.content.Context#IPSEC_SERVICE Context#IPSEC_SERVICE}
- *
* @hide
*/
+@SystemService(Context.IPSEC_SERVICE)
public final class IpSecManager {
private static final String TAG = "IpSecManager";
import static android.content.pm.PackageManager.GET_SIGNATURES;
import static android.net.NetworkPolicy.CYCLE_NONE;
+import android.annotation.SystemService;
import android.app.ActivityManager;
import android.content.Context;
import android.content.Intent;
*
* {@hide}
*/
+@SystemService(Context.NETWORK_POLICY_SERVICE)
public class NetworkPolicyManager {
/* POLICY_* are masks and can be ORed, although currently they are not.*/
import android.Manifest.permission;
import android.annotation.IntDef;
import android.annotation.Nullable;
+import android.annotation.RequiresPermission;
import android.annotation.SdkConstant;
import android.annotation.SdkConstant.SdkConstantType;
import android.annotation.SystemApi;
+import android.annotation.SystemService;
import android.content.Context;
import android.os.RemoteException;
import android.os.ServiceManager;
/**
* Class that manages communication between network subsystems and a network scorer.
*
- * <p>You can get an instance of this class by calling
- * {@link android.content.Context#getSystemService(String)}:
- *
- * <pre>NetworkScoreManager manager =
- * (NetworkScoreManager) getSystemService(Context.NETWORK_SCORE_SERVICE)</pre>
- *
* <p>A network scorer is any application which:
* <ul>
* <li>Declares the {@link permission#SCORE_NETWORKS} permission.
* @hide
*/
@SystemApi
+@SystemService(Context.NETWORK_SCORE_SERVICE)
public class NetworkScoreManager {
/**
* Activity action: ask the user to change the active network scorer. This will show a dialog
* @hide
*/
@Nullable
+ @RequiresPermission(android.Manifest.permission.REQUEST_NETWORK_SCORES)
public NetworkScorerAppData getActiveScorer() {
try {
return mService.getActiveScorer();
* @return whether the update was successful.
* @throws SecurityException if the caller is not the active scorer.
*/
+ @RequiresPermission(android.Manifest.permission.SCORE_NETWORKS)
public boolean updateScores(ScoredNetwork[] networks) throws SecurityException {
try {
return mService.updateScores(networks);
* @return whether the clear was successful.
* @throws SecurityException if the caller is not the active scorer or privileged.
*/
+ @RequiresPermission(android.Manifest.permission.REQUEST_NETWORK_SCORES)
public boolean clearScores() throws SecurityException {
try {
return mService.clearScores();
* @hide
*/
@SystemApi
+ @RequiresPermission(android.Manifest.permission.SCORE_NETWORKS)
public boolean setActiveScorer(String packageName) throws SecurityException {
try {
return mService.setActiveScorer(packageName);
*
* @throws SecurityException if the caller is neither the active scorer nor the system.
*/
+ @RequiresPermission(android.Manifest.permission.REQUEST_NETWORK_SCORES)
public void disableScoring() throws SecurityException {
try {
mService.disableScoring();
package android.net;
+import android.annotation.RequiresPermission;
import android.annotation.SystemApi;
import android.app.DownloadManager;
import android.app.backup.BackupManager;
* @hide
*/
@SystemApi
+ @RequiresPermission(android.Manifest.permission.UPDATE_DEVICE_STATS)
public static void setThreadStatsUid(int uid) {
NetworkManagementSocketTagger.setThreadSocketStatsUid(uid);
}
* @hide
*/
@SystemApi
+ @RequiresPermission(android.Manifest.permission.UPDATE_DEVICE_STATS)
public static void clearThreadStatsUid() {
NetworkManagementSocketTagger.setThreadSocketStatsUid(-1);
}
import static android.system.OsConstants.AF_INET;
import static android.system.OsConstants.AF_INET6;
+import android.annotation.RequiresPermission;
import android.annotation.SystemApi;
import android.app.Activity;
import android.app.PendingIntent;
* @hide
*/
@SystemApi
+ @RequiresPermission(android.Manifest.permission.CONTROL_VPN)
public static void prepareAndAuthorize(Context context) {
IConnectivityManager cm = getService();
String packageName = context.getPackageName();
package android.net.nsd;
import android.annotation.SdkConstant;
+import android.annotation.SystemService;
import android.annotation.SdkConstant.SdkConstantType;
import android.content.Context;
import android.os.Handler;
* http://www.iana.org/form/ports-service. Existing services can be found at
* http://www.iana.org/assignments/service-names-port-numbers/service-names-port-numbers.xml
*
- * Get an instance of this class by calling {@link android.content.Context#getSystemService(String)
- * Context.getSystemService(Context.NSD_SERVICE)}.
- *
* {@see NsdServiceInfo}
*/
+@SystemService(Context.NSD_SERVICE)
public final class NsdManager {
private static final String TAG = NsdManager.class.getSimpleName();
private static final boolean DBG = false;
import java.util.HashMap;
+import android.annotation.RequiresPermission;
import android.annotation.SdkConstant;
import android.annotation.SdkConstant.SdkConstantType;
import android.annotation.SystemApi;
* @hide
*/
@SystemApi
+ @RequiresPermission(android.Manifest.permission.WRITE_SECURE_SETTINGS)
public boolean enable() {
try {
return sService.enable();
* @hide
*/
@SystemApi
+ @RequiresPermission(android.Manifest.permission.WRITE_SECURE_SETTINGS)
public boolean disable() {
try {
return sService.disable(true);
* @hide
*/
@SystemApi
+ @RequiresPermission(android.Manifest.permission.WRITE_SECURE_SETTINGS)
public boolean disable(boolean persist) {
try {
return sService.disable(persist);
* @hide
*/
@SystemApi
+ @RequiresPermission(android.Manifest.permission.WRITE_SECURE_SETTINGS)
public boolean enableNdefPush() {
if (!sHasNfcFeature) {
throw new UnsupportedOperationException();
* @hide
*/
@SystemApi
+ @RequiresPermission(android.Manifest.permission.WRITE_SECURE_SETTINGS)
public boolean disableNdefPush() {
synchronized (NfcAdapter.class) {
if (!sHasNfcFeature) {
* @hide
*/
@SystemApi
+ @RequiresPermission(android.Manifest.permission.WRITE_SECURE_SETTINGS)
public boolean addNfcUnlockHandler(final NfcUnlockHandler unlockHandler,
String[] tagTechnologies) {
synchronized (NfcAdapter.class) {
* @hide
*/
@SystemApi
+ @RequiresPermission(android.Manifest.permission.WRITE_SECURE_SETTINGS)
public boolean removeNfcUnlockHandler(NfcUnlockHandler unlockHandler) {
synchronized (NfcAdapter.class) {
if (!sHasNfcFeature) {
package android.nfc;
+import android.annotation.SystemService;
import android.content.Context;
/**
* <a href="{@docRoot}guide/topics/nfc/index.html">Near Field Communication</a> developer guide.</p>
* </div>
*
- * @see Context#getSystemService
* @see NfcAdapter#getDefaultAdapter(android.content.Context)
*/
+@SystemService(Context.NFC_SERVICE)
public final class NfcManager {
private final NfcAdapter mAdapter;
package android.os;
+import android.annotation.SystemService;
+import android.content.Context;
import android.hardware.health.V1_0.Constants;
import com.android.internal.app.IBatteryStats;
* in the {@link android.content.Intent#ACTION_BATTERY_CHANGED} Intent, and
* provides a method for querying battery and charging properties.
*/
+@SystemService(Context.BATTERY_SERVICE)
public class BatteryManager {
/**
* Extra for {@link android.content.Intent#ACTION_BATTERY_CHANGED}:
package android.os;
import android.annotation.SdkConstant;
+import android.annotation.SystemService;
import android.annotation.SdkConstant.SdkConstantType;
import android.content.Context;
import android.util.Log;
* enqueued data exceeds the maximum size. You can think of this as a
* persistent, system-wide, blob-oriented "logcat".
*
- * <p>You can obtain an instance of this class by calling
- * {@link android.content.Context#getSystemService}
- * with {@link android.content.Context#DROPBOX_SERVICE}.
- *
* <p>DropBoxManager entries are not sent anywhere directly, but other system
* services and debugging tools may scan and upload entries for processing.
*/
+@SystemService(Context.DROPBOX_SERVICE)
public class DropBoxManager {
private static final String TAG = "DropBoxManager";
import android.annotation.IntDef;
import android.annotation.NonNull;
+import android.annotation.SystemService;
import android.content.Context;
import android.hardware.thermal.V1_0.Constants;
import android.util.Log;
* The HardwarePropertiesManager class provides a mechanism of accessing hardware state of a
* device: CPU, GPU and battery temperatures, CPU usage per core, fan speed, etc.
*/
+@SystemService(Context.HARDWARE_PROPERTIES_SERVICE)
public class HardwarePropertiesManager {
private static final String TAG = HardwarePropertiesManager.class.getSimpleName();
package android.os;
+import android.annotation.RequiresPermission;
import android.annotation.SystemApi;
+import android.annotation.SystemService;
import android.annotation.TestApi;
import android.content.Context;
import android.os.IIncidentManager;
*/
@SystemApi
@TestApi
+@SystemService(Context.INCIDENT_SERVICE)
public class IncidentManager {
private static final String TAG = "incident";
/**
* Take an incident report and put it in dropbox.
*/
+ @RequiresPermission(allOf = {
+ android.Manifest.permission.DUMP,
+ android.Manifest.permission.PACKAGE_USAGE_STATS
+ })
public void reportIncident(IncidentReportArgs args) {
final IIncidentManager service = IIncidentManager.Stub.asInterface(
ServiceManager.getService("incident"));
* {@link android.util.proto.ProtoOutputStream#bytes bytes()} method to retrieve
* the encoded data for the header.
*/
+ @RequiresPermission(allOf = {
+ android.Manifest.permission.DUMP,
+ android.Manifest.permission.PACKAGE_USAGE_STATS
+ })
public void reportIncident(String settingName, byte[] headerProto) {
// Sections
String setting = Settings.System.getString(mContext.getContentResolver(), settingName);
package android.os;
import android.annotation.IntDef;
+import android.annotation.RequiresPermission;
import android.annotation.SdkConstant;
import android.annotation.SystemApi;
+import android.annotation.SystemService;
import android.content.Context;
import android.util.Log;
import java.lang.annotation.Retention;
* Do not acquire {@link WakeLock}s unless you really need them, use the minimum levels
* possible, and be sure to release them as soon as possible.
* </p><p>
- * You can obtain an instance of this class by calling
- * {@link android.content.Context#getSystemService(java.lang.String) Context.getSystemService()}.
- * </p><p>
* The primary API you'll use is {@link #newWakeLock(int, String) newWakeLock()}.
* This will create a {@link PowerManager.WakeLock} object. You can then use methods
* on the wake lock object to control the power state of the device.
* permission in an {@code <uses-permission>} element of the application's manifest.
* </p>
*/
+@SystemService(Context.POWER_SERVICE)
public final class PowerManager {
private static final String TAG = "PowerManager";
* @hide Requires signature or system permission.
*/
@SystemApi
+ @RequiresPermission(anyOf = {
+ android.Manifest.permission.DEVICE_POWER,
+ android.Manifest.permission.USER_ACTIVITY
+ })
public void userActivity(long when, int event, int flags) {
try {
mService.userActivity(when, event, flags);
import static java.nio.charset.StandardCharsets.UTF_8;
+import android.annotation.RequiresPermission;
+import android.annotation.SuppressLint;
import android.annotation.SystemApi;
+import android.annotation.SystemService;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
* recovery system (the separate partition that can be used to install
* system updates, wipe user data, etc.)
*/
+@SystemService(Context.RECOVERY_SERVICE)
public class RecoverySystem {
private static final String TAG = "RecoverySystem";
* {@hide}
*/
@SystemApi
+ @SuppressLint("Doclava125")
public static boolean verifyPackageCompatibility(File compatibilityFile) throws IOException {
try (InputStream inputStream = new FileInputStream(compatibilityFile)) {
return verifyPackageCompatibility(inputStream);
* @hide
*/
@SystemApi
+ @RequiresPermission(android.Manifest.permission.RECOVERY)
public static void processPackage(Context context,
File packageFile,
final ProgressListener listener,
* @hide
*/
@SystemApi
+ @RequiresPermission(android.Manifest.permission.RECOVERY)
public static void processPackage(Context context,
File packageFile,
final ProgressListener listener)
* @throws IOException if writing the recovery command file
* fails, or if the reboot itself fails.
*/
+ @RequiresPermission(android.Manifest.permission.RECOVERY)
public static void installPackage(Context context, File packageFile)
throws IOException {
installPackage(context, packageFile, false);
* @hide
*/
@SystemApi
+ @RequiresPermission(android.Manifest.permission.RECOVERY)
public static void installPackage(Context context, File packageFile, boolean processed)
throws IOException {
synchronized (sRequestLock) {
* @hide
*/
@SystemApi
+ @RequiresPermission(android.Manifest.permission.RECOVERY)
public static void scheduleUpdateOnBoot(Context context, File packageFile)
throws IOException {
String filename = packageFile.getCanonicalPath();
* @hide
*/
@SystemApi
+ @RequiresPermission(android.Manifest.permission.RECOVERY)
public static void cancelScheduledUpdate(Context context)
throws IOException {
RecoverySystem rs = (RecoverySystem) context.getSystemService(Context.RECOVERY_SERVICE);
* @hide
*/
@SystemApi
+ @RequiresPermission(allOf = {
+ android.Manifest.permission.RECOVERY,
+ android.Manifest.permission.REBOOT
+ })
public static void rebootWipeAb(Context context, File packageFile, String reason)
throws IOException {
String reasonArg = null;
import android.annotation.Nullable;
import android.annotation.RequiresPermission;
import android.annotation.SystemApi;
+import android.annotation.SystemService;
import android.annotation.TestApi;
import android.annotation.UserIdInt;
import android.annotation.WorkerThread;
* <p>
* See {@link DevicePolicyManager#ACTION_PROVISION_MANAGED_PROFILE} for more on managed profiles.
*/
+@SystemService(Context.USER_SERVICE)
public class UserManager {
private static final String TAG = "UserManager";
/**
* Checks if the calling app is running in a managed profile.
- * Requires {@link android.Manifest.permission#MANAGE_USERS} permission.
*
* @return whether the caller is in a managed profile.
* @hide
*/
@SystemApi
+ @RequiresPermission(android.Manifest.permission.MANAGE_USERS)
public boolean isManagedProfile() {
// No need for synchronization. Once it becomes non-null, it'll be non-null forever.
// Worst case we might end up calling the AIDL method multiple times but that's fine.
* @hide
*/
@SystemApi
+ @RequiresPermission(android.Manifest.permission.MANAGE_USERS)
public boolean isManagedProfile(@UserIdInt int userId) {
if (userId == UserHandle.myUserId()) {
return isManagedProfile();
* @hide
*
* Returns who set a user restriction on a user.
- * Requires {@link android.Manifest.permission#MANAGE_USERS} permission.
* @param restrictionKey the string key representing the restriction
* @param userHandle the UserHandle of the user for whom to retrieve the restrictions.
* @return The source of user restriction. Any combination of {@link #RESTRICTION_NOT_SET},
@Deprecated
@SystemApi
@UserRestrictionSource
+ @RequiresPermission(android.Manifest.permission.MANAGE_USERS)
public int getUserRestrictionSource(String restrictionKey, UserHandle userHandle) {
try {
return mService.getUserRestrictionSource(restrictionKey, userHandle.getIdentifier());
* @hide
*
* Returns a list of users who set a user restriction on a given user.
- * Requires {@link android.Manifest.permission#MANAGE_USERS} permission.
* @param restrictionKey the string key representing the restriction
* @param userHandle the UserHandle of the user for whom to retrieve the restrictions.
* @return a list of user ids enforcing this restriction.
*/
@SystemApi
+ @RequiresPermission(android.Manifest.permission.MANAGE_USERS)
public List<EnforcingUser> getUserRestrictionSources(
String restrictionKey, UserHandle userHandle) {
try {
/**
* @hide
*
- * Returns the preferred account name for user creation. Requires MANAGE_USERS permission.
+ * Returns the preferred account name for user creation.
*/
@SystemApi
+ @RequiresPermission(android.Manifest.permission.MANAGE_USERS)
public String getSeedAccountName() {
try {
return mService.getSeedAccountName();
/**
* @hide
*
- * Returns the preferred account type for user creation. Requires MANAGE_USERS permission.
+ * Returns the preferred account type for user creation.
*/
@SystemApi
+ @RequiresPermission(android.Manifest.permission.MANAGE_USERS)
public String getSeedAccountType() {
try {
return mService.getSeedAccountType();
/**
* @hide
*
- * Returns the preferred account's options bundle for user creation. Requires MANAGE_USERS
- * permission.
+ * Returns the preferred account's options bundle for user creation.
* @return Any options set by the requestor that created the user.
*/
@SystemApi
+ @RequiresPermission(android.Manifest.permission.MANAGE_USERS)
public PersistableBundle getSeedAccountOptions() {
try {
return mService.getSeedAccountOptions();
/**
* @hide
- * Clears the seed information used to create this user. Requires MANAGE_USERS permission.
+ * Clears the seed information used to create this user.
*/
@SystemApi
+ @RequiresPermission(android.Manifest.permission.MANAGE_USERS)
public void clearSeedAccountData() {
try {
mService.clearSeedAccountData();
/**
* Returns serial numbers of all users on this device.
- * Requires {@link android.Manifest.permission#MANAGE_USERS} permission.
*
* @param excludeDying specify if the list should exclude users being removed.
* @return the list of serial numbers of users that exist on the device.
* @hide
*/
@SystemApi
+ @RequiresPermission(android.Manifest.permission.MANAGE_USERS)
public long[] getSerialNumbersOfUsers(boolean excludeDying) {
try {
List<UserInfo> users = mService.getUsers(excludeDying);
package android.os;
import android.annotation.RequiresPermission;
+import android.annotation.SystemService;
import android.app.ActivityThread;
import android.content.Context;
import android.media.AudioAttributes;
* <p>
* If your process exits, any vibration you started will stop.
* </p>
- *
- * To obtain an instance of the system vibrator, call
- * {@link Context#getSystemService} with {@link Context#VIBRATOR_SERVICE} as the argument.
*/
+@SystemService(Context.VIBRATOR_SERVICE)
public abstract class Vibrator {
private static final String TAG = "Vibrator";
package android.os.health;
+import android.annotation.SystemService;
import android.content.Context;
import android.os.BatteryStats;
import android.os.Process;
* JobScheduler}), and while that can affect charging rates, it is still preferable
* to actually draining the battery.
*/
+@SystemService(Context.SYSTEM_HEALTH_SERVICE)
public class SystemHealthManager {
private final IBatteryStats mBatteryStats;
import android.annotation.RequiresPermission;
import android.annotation.SdkConstant;
import android.annotation.SystemApi;
+import android.annotation.SystemService;
import android.annotation.WorkerThread;
import android.app.ActivityThread;
import android.content.ContentResolver;
* guarantee the security of the OBB file itself: if any program modifies the
* OBB, there is no guarantee that a read from that OBB will produce the
* expected output.
- * <p>
- * Get an instance of this class by calling
- * {@link android.content.Context#getSystemService(java.lang.String)} with an
- * argument of {@link android.content.Context#STORAGE_SERVICE}.
*/
+@SystemService(Context.STORAGE_SERVICE)
public class StorageManager {
private static final String TAG = "StorageManager";
/** @hide */
@SystemApi
- public long getAllocatableBytes(@NonNull UUID storageUuid, @AllocateFlags int flags)
- throws IOException {
+ public long getAllocatableBytes(@NonNull UUID storageUuid,
+ @RequiresPermission @AllocateFlags int flags) throws IOException {
try {
return mStorageManager.getAllocatableBytes(convert(storageUuid), flags);
} catch (ParcelableException e) {
/** @removed */
@Deprecated
- public long getAllocatableBytes(@NonNull File path, @AllocateFlags int flags)
- throws IOException {
+ public long getAllocatableBytes(@NonNull File path,
+ @RequiresPermission @AllocateFlags int flags) throws IOException {
return getAllocatableBytes(getUuidForPath(path), flags);
}
/** @hide */
@SystemApi
public void allocateBytes(@NonNull UUID storageUuid, @BytesLong long bytes,
- @AllocateFlags int flags) throws IOException {
+ @RequiresPermission @AllocateFlags int flags) throws IOException {
try {
mStorageManager.allocateBytes(convert(storageUuid), bytes, flags);
} catch (ParcelableException e) {
/** @removed */
@Deprecated
- public void allocateBytes(@NonNull File path, @BytesLong long bytes, @AllocateFlags int flags)
- throws IOException {
+ public void allocateBytes(@NonNull File path, @BytesLong long bytes,
+ @RequiresPermission @AllocateFlags int flags) throws IOException {
allocateBytes(getUuidForPath(path), bytes, flags);
}
/** @hide */
@SystemApi
- public void allocateBytes(FileDescriptor fd, @BytesLong long bytes, @AllocateFlags int flags)
- throws IOException {
+ public void allocateBytes(FileDescriptor fd, @BytesLong long bytes,
+ @RequiresPermission @AllocateFlags int flags) throws IOException {
final File file = ParcelFileDescriptor.getFile(fd);
for (int i = 0; i < 3; i++) {
try {
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.annotation.SystemApi;
+import android.annotation.SystemService;
import android.app.Activity;
import android.app.Application.ActivityLifecycleCallbacks;
import android.content.ComponentName;
/**
* System level service for accessing the printing capabilities of the platform.
- * <p>
- * To obtain a handle to the print manager do the following:
- * </p>
- *
- * <pre>
- * PrintManager printManager =
- * (PrintManager) context.getSystemService(Context.PRINT_SERVICE);
- * </pre>
*
* <h3>Print mechanics</h3>
* <p>
* @see PrintJob
* @see PrintJobInfo
*/
+@SystemService(Context.PRINT_SERVICE)
public final class PrintManager {
private static final String LOG_TAG = "PrintManager";
package android.service.oemlock;
import android.annotation.Nullable;
+import android.annotation.RequiresPermission;
import android.annotation.SystemApi;
+import android.annotation.SystemService;
+import android.content.Context;
import android.os.RemoteException;
/**
* @hide
*/
@SystemApi
+@SystemService(Context.OEM_LOCK_SERVICE)
public class OemLockManager {
private IOemLockService mService;
*
* @see #isOemUnlockAllowedByCarrier()
*/
+ @RequiresPermission(android.Manifest.permission.MANAGE_CARRIER_OEM_UNLOCK_STATE)
public void setOemUnlockAllowedByCarrier(boolean allowed, @Nullable byte[] signature) {
try {
mService.setOemUnlockAllowedByCarrier(allowed, signature);
*
* @see #setOemUnlockAllowedByCarrier(boolean, byte[])
*/
+ @RequiresPermission(android.Manifest.permission.MANAGE_CARRIER_OEM_UNLOCK_STATE)
public boolean isOemUnlockAllowedByCarrier() {
try {
return mService.isOemUnlockAllowedByCarrier();
*
* @see #isOemUnlockAllowedByUser()
*/
+ @RequiresPermission(android.Manifest.permission.MANAGE_USER_OEM_UNLOCK_STATE)
public void setOemUnlockAllowedByUser(boolean allowed) {
try {
mService.setOemUnlockAllowedByUser(allowed);
*
* @see #setOemUnlockAllowedByUser(boolean)
*/
+ @RequiresPermission(android.Manifest.permission.MANAGE_USER_OEM_UNLOCK_STATE)
public boolean isOemUnlockAllowedByUser() {
try {
return mService.isOemUnlockAllowedByUser();
package android.service.persistentdata;
-import android.annotation.SystemApi;
import android.annotation.IntDef;
+import android.annotation.RequiresPermission;
+import android.annotation.SuppressLint;
+import android.annotation.SystemApi;
+import android.annotation.SystemService;
+import android.content.Context;
import android.os.RemoteException;
-import android.util.Slog;
+import android.service.oemlock.OemLockManager;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
* @hide
*/
@SystemApi
+@SystemService(Context.PERSISTENT_DATA_BLOCK_SERVICE)
public class PersistentDataBlockManager {
private static final String TAG = PersistentDataBlockManager.class.getSimpleName();
private IPersistentDataBlockService sService;
*
* @param data the data to write
*/
+ @SuppressLint("Doclava125")
public int write(byte[] data) {
try {
return sService.write(data);
/**
* Returns the data block stored on the persistent partition.
*/
+ @SuppressLint("Doclava125")
public byte[] read() {
try {
return sService.read();
*
* Return -1 on error.
*/
+ @RequiresPermission(android.Manifest.permission.ACCESS_PDB_STATE)
public int getDataBlockSize() {
try {
return sService.getDataBlockSize();
* It will also prevent any further {@link #write} operation until reboot,
* in order to prevent a potential race condition. See b/30352311.
*/
+ @RequiresPermission(android.Manifest.permission.OEM_UNLOCK_STATE)
public void wipe() {
try {
sService.wipe();
*
* @deprecated use {@link OemLockManager#setOemUnlockAllowedByUser(boolean)} instead.
*/
+ @RequiresPermission(android.Manifest.permission.OEM_UNLOCK_STATE)
public void setOemUnlockEnabled(boolean enabled) {
try {
sService.setOemUnlockEnabled(enabled);
*
* @deprecated use {@link OemLockManager#isOemUnlockAllowedByUser()} instead.
*/
+ @RequiresPermission(anyOf = {
+ android.Manifest.permission.READ_OEM_UNLOCK_STATE,
+ android.Manifest.permission.OEM_UNLOCK_STATE
+ })
public boolean getOemUnlockEnabled() {
try {
return sService.getOemUnlockEnabled();
* {@link #FLASH_LOCK_UNLOCKED} if device bootloader is unlocked, or {@link #FLASH_LOCK_UNKNOWN}
* if this information cannot be ascertained on this device.
*/
+ @RequiresPermission(anyOf = {
+ android.Manifest.permission.READ_OEM_UNLOCK_STATE,
+ android.Manifest.permission.OEM_UNLOCK_STATE
+ })
@FlashLockState
public int getFlashLockState() {
try {
import android.annotation.LayoutRes;
import android.annotation.Nullable;
+import android.annotation.SystemService;
import android.content.Context;
import android.content.res.Resources;
import android.content.res.TypedArray;
* {@link android.app.Activity#getLayoutInflater()} or
* {@link Context#getSystemService} to retrieve a standard LayoutInflater instance
* that is already hooked up to the current context and correctly configured
- * for the device you are running on. For example:
- *
- * <pre>LayoutInflater inflater = (LayoutInflater)context.getSystemService
- * (Context.LAYOUT_INFLATER_SERVICE);</pre>
+ * for the device you are running on.
*
* <p>
* To create a new LayoutInflater with an additional {@link Factory} for your
* to use LayoutInflater with an XmlPullParser over a plain XML file at runtime;
* it only works with an XmlPullParser returned from a compiled resource
* (R.<em>something</em> file.)
- *
- * @see Context#getSystemService
*/
+@SystemService(Context.LAYOUT_INFLATER_SERVICE)
public abstract class LayoutInflater {
private static final String TAG = LayoutInflater.class.getSimpleName();
import android.annotation.IntDef;
import android.annotation.NonNull;
import android.annotation.SystemApi;
+import android.annotation.SystemService;
import android.annotation.TestApi;
import android.app.KeyguardManager;
import android.app.Presentation;
/**
* The interface that apps use to talk to the window manager.
- * <p>
- * Use <code>Context.getSystemService(Context.WINDOW_SERVICE)</code> to get one of these.
* </p><p>
* Each window manager instance is bound to a particular {@link Display}.
* To obtain a {@link WindowManager} for a different display, use
* {@link Presentation}. The presentation will automatically obtain a
* {@link WindowManager} and {@link Context} for that display.
* </p>
- *
- * @see android.content.Context#getSystemService
- * @see android.content.Context#WINDOW_SERVICE
*/
+@SystemService(Context.WINDOW_SERVICE)
public interface WindowManager extends ViewManager {
/** @hide */
import android.annotation.Nullable;
import android.annotation.SdkConstant;
import android.annotation.SystemApi;
+import android.annotation.SystemService;
import android.content.ComponentName;
import android.content.Context;
import android.content.pm.PackageManager;
* {@link android.view.View} changes etc. Parties interested in handling accessibility
* events implement and register an accessibility service which extends
* {@link android.accessibilityservice.AccessibilityService}.
- * <p>
- * To obtain a handle to the accessibility manager do the following:
- * </p>
- * <p>
- * <code>
- * <pre>AccessibilityManager accessibilityManager =
- * (AccessibilityManager) context.getSystemService(Context.ACCESSIBILITY_SERVICE);</pre>
- * </code>
- * </p>
*
* @see AccessibilityEvent
* @see AccessibilityNodeInfo
* @see Context#getSystemService
* @see Context#ACCESSIBILITY_SERVICE
*/
+@SystemService(Context.ACCESSIBILITY_SERVICE)
public final class AccessibilityManager {
private static final boolean DEBUG = false;
import android.annotation.NonNull;
import android.annotation.Nullable;
+import android.annotation.SystemService;
import android.content.ContentResolver;
import android.content.Context;
import android.database.ContentObserver;
/**
* Contains methods for accessing and monitoring preferred video captioning state and visual
* properties.
- * <p>
- * To obtain a handle to the captioning manager, do the following:
- * <p>
- * <code>
- * <pre>CaptioningManager captioningManager =
- * (CaptioningManager) context.getSystemService(Context.CAPTIONING_SERVICE);</pre>
- * </code>
*/
+@SystemService(Context.CAPTIONING_SERVICE)
public class CaptioningManager {
/** Default captioning enabled value. */
private static final int DEFAULT_ENABLED = 0;
import android.annotation.IntDef;
import android.annotation.NonNull;
import android.annotation.Nullable;
+import android.annotation.SystemService;
import android.content.Context;
import android.content.Intent;
import android.content.IntentSender;
*
* <p>It is safe to call into this from any thread.
*/
+@SystemService(Context.AUTOFILL_MANAGER_SERVICE)
public final class AutofillManager {
private static final String TAG = "AutofillManager";
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.annotation.RequiresPermission;
+import android.annotation.SystemService;
import android.content.Context;
import android.graphics.Rect;
import android.net.Uri;
/**
* Central system API to the overall input method framework (IMF) architecture,
* which arbitrates interaction between applications and the current input method.
- * You can retrieve an instance of this interface with
- * {@link Context#getSystemService(String) Context.getSystemService()}.
*
* <p>Topics covered here:
* <ol>
* and want to make it available for use.</p>
* </ul>
*/
+@SystemService(Context.INPUT_METHOD_SERVICE)
public final class InputMethodManager {
static final boolean DEBUG = false;
static final String TAG = "InputMethodManager";
import android.annotation.NonNull;
import android.annotation.Nullable;
+import android.annotation.SystemService;
import android.content.Context;
import android.os.ParcelFileDescriptor;
import android.util.Log;
/**
* Interface to the text classification service.
- *
- * <p>You do not instantiate this class directly; instead, retrieve it through
- * {@link android.content.Context#getSystemService}.
*/
+@SystemService(Context.TEXT_CLASSIFICATION_SERVICE)
public final class TextClassificationManager {
private static final String LOG_TAG = "TextClassificationManager";
package android.view.textservice;
+import android.annotation.SystemService;
import android.content.Context;
import android.os.Bundle;
import android.os.RemoteException;
/**
* System API to the overall text services, which arbitrates interaction between applications
- * and text services. You can retrieve an instance of this interface with
- * {@link Context#getSystemService(String) Context.getSystemService()}.
+ * and text services.
*
* The user can change the current text services in Settings. And also applications can specify
* the target text services.
* </ul>
*
*/
+@SystemService(Context.TEXT_SERVICES_MANAGER_SERVICE)
public final class TextServicesManager {
private static final String TAG = TextServicesManager.class.getSimpleName();
private static final boolean DBG = false;
import java.util.HashMap;
+import android.annotation.SystemService;
+import android.content.Context;
import android.os.Handler;
import android.os.Looper;
import android.os.RemoteException;
* To be notified of the future country change, use the
* {@link #addCountryListener}
* <p>
- * <p>
- * You do not instantiate this class directly; instead, retrieve it through
- * {@link android.content.Context#getSystemService
- * Context.getSystemService(Context.COUNTRY_DETECTOR)}.
*
* @hide
*/
+@SystemService(Context.COUNTRY_DETECTOR)
public class CountryDetector {
/**
import android.Manifest;
import android.annotation.RequiresPermission;
+import android.annotation.SuppressLint;
import android.annotation.SystemApi;
+import android.annotation.SystemService;
import android.annotation.TestApi;
import android.app.PendingIntent;
import android.content.Context;
* {@link Intent} when the device enters the proximity of a given
* geographical location.
*
- * <p>You do not
- * instantiate this class directly; instead, retrieve it through
- * {@link android.content.Context#getSystemService
- * Context.getSystemService(Context.LOCATION_SERVICE)}.
- *
* <p class="note">Unless noted, all Location API methods require
* the {@link android.Manifest.permission#ACCESS_COARSE_LOCATION} or
* {@link android.Manifest.permission#ACCESS_FINE_LOCATION} permissions.
* return location results, but the update rate will be throttled and the exact
* location will be obfuscated to a coarse level of accuracy.
*/
-public class LocationManager
-{
+@SystemService(Context.LOCATION_SERVICE)
+public class LocationManager {
private static final String TAG = "LocationManager";
private final Context mContext;
*/
@Deprecated
@SystemApi
+ @SuppressLint("Doclava125")
public boolean addGpsMeasurementListener(GpsMeasurementsEvent.Listener listener) {
return false;
}
*/
@Deprecated
@SystemApi
+ @SuppressLint("Doclava125")
public void removeGpsMeasurementListener(GpsMeasurementsEvent.Listener listener) {
}
*/
@Deprecated
@SystemApi
+ @SuppressLint("Doclava125")
public boolean addGpsNavigationMessageListener(GpsNavigationMessageEvent.Listener listener) {
return false;
}
*/
@Deprecated
@SystemApi
+ @SuppressLint("Doclava125")
public void removeGpsNavigationMessageListener(GpsNavigationMessageEvent.Listener listener) {
}
import android.Manifest;
import android.annotation.NonNull;
import android.annotation.Nullable;
+import android.annotation.RequiresPermission;
import android.annotation.SdkConstant;
import android.annotation.SdkConstant.SdkConstantType;
import android.annotation.SystemApi;
+import android.annotation.SystemService;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.bluetooth.BluetoothDevice;
/**
* AudioManager provides access to volume and ringer mode control.
- * <p>
- * Use <code>Context.getSystemService(Context.AUDIO_SERVICE)</code> to get
- * an instance of this class.
*/
+@SystemService(Context.AUDIO_SERVICE)
public class AudioManager {
private Context mOriginalContext;
* {@link #SUCCESS} otherwise.
*/
@SystemApi
+ @RequiresPermission(android.Manifest.permission.MODIFY_AUDIO_ROUTING)
public int registerAudioPolicy(@NonNull AudioPolicy policy) {
if (policy == null) {
throw new IllegalArgumentException("Illegal null AudioPolicy argument");
* @param policy the non-null {@link AudioPolicy} to unregister.
*/
@SystemApi
+ @RequiresPermission(android.Manifest.permission.MODIFY_AUDIO_ROUTING)
public void unregisterAudioPolicyAsync(@NonNull AudioPolicy policy) {
if (policy == null) {
throw new IllegalArgumentException("Illegal null AudioPolicy argument");
import android.annotation.DrawableRes;
import android.annotation.IntDef;
import android.annotation.NonNull;
+import android.annotation.SystemService;
import android.app.ActivityThread;
import android.content.BroadcastReceiver;
import android.content.Context;
* <p>The media router API is not thread-safe; all interactions with it must be
* done from the main thread of the process.</p>
*/
+@SystemService(Context.MEDIA_ROUTER_SERVICE)
public class MediaRouter {
private static final String TAG = "MediaRouter";
private static final boolean DEBUG = Log.isLoggable(TAG, Log.DEBUG);
package android.media.midi;
+import android.annotation.SystemService;
import android.bluetooth.BluetoothDevice;
+import android.content.Context;
import android.os.Binder;
import android.os.IBinder;
import android.os.Bundle;
/**
* This class is the public application interface to the MIDI service.
- *
- * <p>You can obtain an instance of this class by calling
- * {@link android.content.Context#getSystemService(java.lang.String) Context.getSystemService()}.
- *
- * {@samplecode
- * MidiManager manager = (MidiManager) getSystemService(Context.MIDI_SERVICE);}
*/
+@SystemService(Context.MIDI_SERVICE)
public final class MidiManager {
private static final String TAG = "MidiManager";
import android.annotation.NonNull;
import android.annotation.Nullable;
+import android.annotation.SystemService;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
/**
* Manages the retrieval of certain types of {@link MediaProjection} tokens.
- *
- * <p>
- * Get an instance of this class by calling {@link
- * android.content.Context#getSystemService(java.lang.String)
- * Context.getSystemService()} with the argument {@link
- * android.content.Context#MEDIA_PROJECTION_SERVICE}.
- * </p>
*/
+@SystemService(Context.MEDIA_PROJECTION_SERVICE)
public final class MediaProjectionManager {
private static final String TAG = "MediaProjectionManager";
/** @hide */
import android.annotation.NonNull;
import android.annotation.Nullable;
+import android.annotation.RequiresPermission;
import android.annotation.SystemApi;
+import android.annotation.SystemService;
import android.content.ComponentName;
import android.content.Context;
import android.media.AudioManager;
* Provides support for interacting with {@link MediaSession media sessions}
* that applications have published to express their ongoing media playback
* state.
- * <p>
- * Use <code>Context.getSystemService(Context.MEDIA_SESSION_SERVICE)</code> to
- * get an instance of this class.
*
* @see MediaSession
* @see MediaController
*/
+@SystemService(Context.MEDIA_SESSION_SERVICE)
public final class MediaSessionManager {
private static final String TAG = "SessionManager";
* @hide
*/
@SystemApi
+ @RequiresPermission(android.Manifest.permission.SET_VOLUME_KEY_LONG_PRESS_LISTENER)
public void setOnVolumeKeyLongPressListener(
OnVolumeKeyLongPressListener listener, @Nullable Handler handler) {
synchronized (mLock) {
* @hide
*/
@SystemApi
+ @RequiresPermission(android.Manifest.permission.SET_MEDIA_KEY_LISTENER)
public void setOnMediaKeyListener(OnMediaKeyListener listener, @Nullable Handler handler) {
synchronized (mLock) {
try {
import android.annotation.IntDef;
import android.annotation.NonNull;
import android.annotation.Nullable;
+import android.annotation.RequiresPermission;
import android.annotation.SystemApi;
import android.hardware.soundtrigger.IRecognitionStatusCallback;
import android.hardware.soundtrigger.SoundTrigger;
* {@link Callback}.
* @return Indicates whether the call succeeded or not.
*/
+ @RequiresPermission(android.Manifest.permission.MANAGE_SOUND_TRIGGER)
public boolean startRecognition(@RecognitionFlags int recognitionFlags) {
if (DBG) {
Slog.d(TAG, "startRecognition()");
/**
* Stops recognition for the associated model.
*/
+ @RequiresPermission(android.Manifest.permission.MANAGE_SOUND_TRIGGER)
public boolean stopRecognition() {
int status = STATUS_OK;
try {
import android.annotation.NonNull;
import android.annotation.Nullable;
+import android.annotation.RequiresPermission;
import android.annotation.SystemApi;
+import android.annotation.SystemService;
import android.content.Context;
import android.hardware.soundtrigger.SoundTrigger;
import android.os.Handler;
* @hide
*/
@SystemApi
+@SystemService(Context.SOUND_TRIGGER_SERVICE)
public final class SoundTriggerManager {
private static final boolean DBG = false;
private static final String TAG = "SoundTriggerManager";
/**
* Updates the given sound trigger model.
*/
+ @RequiresPermission(android.Manifest.permission.MANAGE_SOUND_TRIGGER)
public void updateModel(Model model) {
try {
mSoundTriggerService.updateSoundModel(model.getGenericSoundModel());
* Returns the sound trigger model represented by the given UUID. An instance of {@link Model}
* is returned.
*/
+ @RequiresPermission(android.Manifest.permission.MANAGE_SOUND_TRIGGER)
public Model getModel(UUID soundModelId) {
try {
return new Model(mSoundTriggerService.getSoundModel(
/**
* Deletes the sound model represented by the provided UUID.
*/
+ @RequiresPermission(android.Manifest.permission.MANAGE_SOUND_TRIGGER)
public void deleteModel(UUID soundModelId) {
try {
mSoundTriggerService.deleteSoundModel(new ParcelUuid(soundModelId));
* @return Instance of {@link SoundTriggerDetector} or null on error.
*/
@Nullable
+ @RequiresPermission(android.Manifest.permission.MANAGE_SOUND_TRIGGER)
public SoundTriggerDetector createSoundTriggerDetector(UUID soundModelId,
@NonNull SoundTriggerDetector.Callback callback, @Nullable Handler handler) {
if (soundModelId == null) {
import android.annotation.Nullable;
import android.annotation.RequiresPermission;
import android.annotation.SystemApi;
+import android.annotation.SystemService;
+import android.content.Context;
import android.content.Intent;
import android.graphics.Rect;
import android.media.PlaybackParams;
/**
* Central system API to the overall TV input framework (TIF) architecture, which arbitrates
- * interaction between applications and the selected TV inputs. You can retrieve an instance of
- * this interface with {@link android.content.Context#getSystemService
- * Context.getSystemService(Context.TV_INPUT_SERVICE)}.
+ * interaction between applications and the selected TV inputs.
*
* <p>There are three primary parties involved in the TV input framework (TIF) architecture:
*
* programs.
* </ul>
*/
+@SystemService(Context.TV_INPUT_SERVICE)
public final class TvInputManager {
private static final String TAG = "TvInputManager";
* @hide
*/
@SystemApi
+ @RequiresPermission(android.Manifest.permission.CAPTURE_TV_INPUT)
public List<TvStreamConfig> getAvailableTvStreamConfigList(String inputId) {
try {
return mService.getAvailableTvStreamConfigList(inputId, mUserId);
* @hide
*/
@SystemApi
+ @RequiresPermission(android.Manifest.permission.CAPTURE_TV_INPUT)
public boolean captureFrame(String inputId, Surface surface, TvStreamConfig config) {
try {
return mService.captureFrame(inputId, surface, config, mUserId);
import android.annotation.RequiresPermission;
import android.annotation.SuppressAutoDoc;
import android.annotation.SystemApi;
+import android.annotation.SystemService;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
* descriptions.
*/
@SuppressAutoDoc
+@SystemService(Context.TELECOM_SERVICE)
public class TelecomManager {
/**
* @hide
*/
@SystemApi
+ @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE)
public boolean endCall() {
try {
if (isServiceConnected()) {
import android.annotation.NonNull;
import android.annotation.Nullable;
+import android.annotation.RequiresPermission;
+import android.annotation.SuppressLint;
import android.annotation.SystemApi;
+import android.annotation.SystemService;
import android.content.Context;
import android.os.PersistableBundle;
import android.os.RemoteException;
/**
* Provides access to telephony configuration values that are carrier-specific.
- * <p>
- * Users should obtain an instance of this class by calling
- * {@code mContext.getSystemService(Context.CARRIER_CONFIG_SERVICE);}
- * </p>
- *
- * @see Context#getSystemService
- * @see Context#CARRIER_CONFIG_SERVICE
*/
+@SystemService(Context.CARRIER_CONFIG_SERVICE)
public class CarrierConfigManager {
private final static String TAG = "CarrierConfigManager";
* @hide
*/
@SystemApi
+ @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE)
public void updateConfigForPhoneId(int phoneId, String simState) {
try {
ICarrierConfigLoader loader = getICarrierConfigLoader();
*/
@NonNull
@SystemApi
+ @SuppressLint("Doclava125")
public static PersistableBundle getDefaultConfig() {
return new PersistableBundle(sDefaults);
}
package android.telephony;
+import android.annotation.RequiresPermission;
import android.annotation.SystemApi;
import android.app.ActivityThread;
import android.app.PendingIntent;
* @hide
*/
@SystemApi
+ @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE)
public void sendTextMessageWithoutPersisting(
String destinationAddress, String scAddress, String text,
PendingIntent sentIntent, PendingIntent deliveryIntent) {
* @hide
**/
@SystemApi
+ @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE)
public void sendMultipartTextMessageWithoutPersisting(
String destinationAddress, String scAddress, List<String> parts,
List<PendingIntent> sentIntents, List<PendingIntent> deliveryIntents) {
import android.annotation.NonNull;
import android.annotation.SdkConstant;
+import android.annotation.SystemService;
import android.annotation.SdkConstant.SdkConstantType;
import android.content.Context;
import android.content.Intent;
/**
* SubscriptionManager is the application interface to SubscriptionController
* and provides information about the current Telephony Subscriptions.
- * * <p>
- * You do not instantiate this class directly; instead, you retrieve
- * a reference to an instance through {@link #from}.
* <p>
* All SDK public methods require android.Manifest.permission.READ_PHONE_STATE.
*/
+@SystemService(Context.TELEPHONY_SUBSCRIPTION_SERVICE)
public class SubscriptionManager {
private static final String LOG_TAG = "SubscriptionManager";
private static final boolean DBG = false;
import android.annotation.Nullable;
import android.annotation.RequiresPermission;
import android.annotation.SdkConstant;
+import android.annotation.SuppressLint;
import android.annotation.SdkConstant.SdkConstantType;
import android.annotation.SystemApi;
+import android.annotation.SystemService;
import android.annotation.WorkerThread;
import android.app.ActivityThread;
import android.app.PendingIntent;
* types of subscriber information. Applications can also register
* a listener to receive notification of telephony state changes.
* <p>
- * You do not instantiate this class directly; instead, you retrieve
- * a reference to an instance through
- * {@link android.content.Context#getSystemService
- * Context.getSystemService(Context.TELEPHONY_SERVICE)}.
- *
* The returned TelephonyManager will use the default subscription for all calls.
* To call an API for a specific subscription, use {@link #createForSubscriptionId(int)}. e.g.
* <code>
* its manifest file. Where permissions apply, they are noted in the
* the methods through which you access the protected information.
*/
+@SystemService(Context.TELEPHONY_SERVICE)
public class TelephonyManager {
private static final String TAG = "TelephonyManager";
* be implemented instead.
*/
@SystemApi
+ @SuppressLint("Doclava125")
public void setVisualVoicemailEnabled(PhoneAccountHandle phoneAccountHandle, boolean enabled){
-
}
/**
/** @hide */
@SystemApi
+ @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE)
public String getCdmaMdn() {
return getCdmaMdn(getSubId());
}
/** @hide */
@SystemApi
+ @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE)
public String getCdmaMdn(int subId) {
try {
ITelephony telephony = getITelephony();
/** @hide */
@SystemApi
+ @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE)
public String getCdmaMin() {
return getCdmaMin(getSubId());
}
/** @hide */
@SystemApi
+ @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE)
public String getCdmaMin(int subId) {
try {
ITelephony telephony = getITelephony();
/** @hide */
@SystemApi
+ @RequiresPermission(android.Manifest.permission.CALL_PHONE)
public void call(String callingPackage, String number) {
try {
ITelephony telephony = getITelephony();
/** @hide */
@SystemApi
+ @RequiresPermission(android.Manifest.permission.CALL_PHONE)
public boolean endCall() {
try {
ITelephony telephony = getITelephony();
/** @hide */
@SystemApi
+ @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE)
public void answerRingingCall() {
try {
ITelephony telephony = getITelephony();
/** @hide */
@SystemApi
+ @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE)
public boolean supplyPin(String pin) {
try {
ITelephony telephony = getITelephony();
/** @hide */
@SystemApi
+ @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE)
public boolean supplyPuk(String puk, String pin) {
try {
ITelephony telephony = getITelephony();
/** @hide */
@SystemApi
+ @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE)
public int[] supplyPinReportResult(String pin) {
try {
ITelephony telephony = getITelephony();
/** @hide */
@SystemApi
+ @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE)
public int[] supplyPukReportResult(String puk, String pin) {
try {
ITelephony telephony = getITelephony();
/** @hide */
@SystemApi
+ @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE)
public boolean handlePinMmi(String dialString) {
try {
ITelephony telephony = getITelephony();
/** @hide */
@SystemApi
+ @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE)
public boolean handlePinMmiForSubscriber(int subId, String dialString) {
try {
ITelephony telephony = getITelephony();
/** @hide */
@SystemApi
+ @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE)
public void toggleRadioOnOff() {
try {
ITelephony telephony = getITelephony();
/** @hide */
@SystemApi
+ @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE)
public boolean setRadio(boolean turnOn) {
try {
ITelephony telephony = getITelephony();
/** @hide */
@SystemApi
+ @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE)
public boolean setRadioPower(boolean turnOn) {
try {
ITelephony telephony = getITelephony();
/** @hide */
@SystemApi
+ @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE)
public boolean enableDataConnectivity() {
try {
ITelephony telephony = getITelephony();
/** @hide */
@SystemApi
+ @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE)
public boolean disableDataConnectivity() {
try {
ITelephony telephony = getITelephony();
*
* @see #hasCarrierPrivileges
*/
+ @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE)
public void setDataEnabled(boolean enable) {
setDataEnabled(getSubId(SubscriptionManager.getDefaultDataSubscriptionId()), enable);
}
/** @hide */
@SystemApi
+ @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE)
public void setDataEnabled(int subId, boolean enable) {
try {
Log.d(TAG, "setDataEnabled: enabled=" + enable);
/** @hide */
@SystemApi
+ @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE)
public void enableVideoCalling(boolean enable) {
try {
ITelephony telephony = getITelephony();
* @hide
*/
@SystemApi
+ @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE)
public List<TelephonyHistogram> getTelephonyHistograms() {
try {
ITelephony service = getITelephony();
* @hide
*/
@SystemApi
+ @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE)
public int setAllowedCarriers(int slotIndex, List<CarrierIdentifier> carriers) {
try {
ITelephony service = getITelephony();
* Get the allowed carrier list for slotIndex.
* Require system privileges. In the future we may add this to carrier APIs.
*
- * <p>Requires Permission:
- * {@link android.Manifest.permission#READ_PRIVILEGED_PHONE_STATE}
- *
* <p>This method returns valid data on devices with {@link
* android.content.pm.PackageManager#FEATURE_TELEPHONY_CARRIERLOCK} enabled.
*
* @hide
*/
@SystemApi
+ @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE)
public List<CarrierIdentifier> getAllowedCarriers(int slotIndex) {
try {
ITelephony service = getITelephony();
package android.net.wifi;
import android.annotation.NonNull;
+import android.annotation.RequiresPermission;
+import android.annotation.SuppressLint;
import android.annotation.SystemApi;
+import android.annotation.SystemService;
import android.content.Context;
import android.os.Bundle;
import android.os.Handler;
/** @hide */
@SystemApi
+@SystemService(Context.WIFI_RTT_SERVICE)
public class RttManager {
private static final boolean DBG = false;
/** @deprecated Use the new {@link android.net.wifi.RttManager#getRttCapabilities()} API.*/
@Deprecated
+ @SuppressLint("Doclava125")
public Capabilities getCapabilities() {
return new Capabilities();
}
* @exception throw IllegalArgumentException when params are illegal
* throw IllegalStateException when RttCapabilities do not exist
*/
-
+ @RequiresPermission(android.Manifest.permission.LOCATION_HARDWARE)
public void startRanging(RttParams[] params, RttListener listener) {
int index = 0;
for(RttParams rttParam : params) {
0, putListener(listener), parcelableParams);
}
+ @RequiresPermission(android.Manifest.permission.LOCATION_HARDWARE)
public void stopRanging(RttListener listener) {
validateChannel();
mAsyncChannel.sendMessage(CMD_OP_STOP_RANGING, 0, removeListener(listener));
* @param callback Callback for responder enabling/disabling result.
* @throws IllegalArgumentException If {@code callback} is null.
*/
+ @RequiresPermission(android.Manifest.permission.LOCATION_HARDWARE)
public void enableResponder(ResponderCallback callback) {
if (callback == null) {
throw new IllegalArgumentException("callback cannot be null");
* @param callback The same callback used for enabling responder.
* @throws IllegalArgumentException If {@code callback} is null.
*/
+ @RequiresPermission(android.Manifest.permission.LOCATION_HARDWARE)
public void disableResponder(ResponderCallback callback) {
if (callback == null) {
throw new IllegalArgumentException("callback cannot be null");
package android.net.wifi;
import android.annotation.Nullable;
+import android.annotation.RequiresPermission;
import android.annotation.SdkConstant;
+import android.annotation.SuppressLint;
import android.annotation.SdkConstant.SdkConstantType;
import android.annotation.SystemApi;
+import android.annotation.SystemService;
import android.content.Context;
import android.content.pm.ParceledListSlice;
import android.net.ConnectivityManager;
/**
* This class provides the primary API for managing all aspects of Wi-Fi
- * connectivity. Get an instance of this class by calling
- * {@link android.content.Context#getSystemService(String) Context.getSystemService(Context.WIFI_SERVICE)}.
- * On releases before NYC, it should only be obtained from an application context, and not from
- * any other derived context to avoid memory leaks within the calling process.
-
+ * connectivity.
+ * <p>
+ * On releases before {@link android.os.Build.VERSION_CODES#N}, this object
+ * should only be obtained from an {@linkplain Context#getApplicationContext()
+ * application context}, and not from any other derived context to avoid memory
+ * leaks within the calling process.
+ * <p>
* It deals with several categories of items:
* <ul>
- * <li>The list of configured networks. The list can be viewed and updated,
- * and attributes of individual entries can be modified.</li>
+ * <li>The list of configured networks. The list can be viewed and updated, and
+ * attributes of individual entries can be modified.</li>
* <li>The currently active Wi-Fi network, if any. Connectivity can be
- * established or torn down, and dynamic information about the state of
- * the network can be queried.</li>
- * <li>Results of access point scans, containing enough information to
- * make decisions about what access point to connect to.</li>
- * <li>It defines the names of various Intent actions that are broadcast
- * upon any sort of change in Wi-Fi state.
+ * established or torn down, and dynamic information about the state of the
+ * network can be queried.</li>
+ * <li>Results of access point scans, containing enough information to make
+ * decisions about what access point to connect to.</li>
+ * <li>It defines the names of various Intent actions that are broadcast upon
+ * any sort of change in Wi-Fi state.
* </ul>
- * This is the API to use when performing Wi-Fi specific operations. To
- * perform operations that pertain to network connectivity at an abstract
- * level, use {@link android.net.ConnectivityManager}.
+ * This is the API to use when performing Wi-Fi specific operations. To perform
+ * operations that pertain to network connectivity at an abstract level, use
+ * {@link android.net.ConnectivityManager}.
*/
+@SystemService(Context.WIFI_SERVICE)
public class WifiManager {
private static final String TAG = "WifiManager";
/** @hide */
@SystemApi
+ @RequiresPermission(android.Manifest.permission.READ_WIFI_CREDENTIAL)
public List<WifiConfiguration> getPrivilegedConfiguredNetworks() {
try {
ParceledListSlice<WifiConfiguration> parceledList =
/** @hide */
@SystemApi
+ @RequiresPermission(android.Manifest.permission.READ_WIFI_CREDENTIAL)
public WifiConnectionStatistics getConnectionStatistics() {
try {
return mService.getConnectionStatistics();
/** @hide */
@SystemApi
+ @RequiresPermission(android.Manifest.permission.UPDATE_DEVICE_STATS)
public boolean startScan(WorkSource workSource) {
try {
String packageName = mContext.getOpPackageName();
*/
@Deprecated
@SystemApi
+ @SuppressLint("Doclava125")
public boolean startLocationRestrictedScan(WorkSource workSource) {
return false;
}
*/
@Deprecated
@SystemApi
+ @SuppressLint("Doclava125")
public boolean isBatchedScanSupported() {
return false;
}
*/
@Deprecated
@SystemApi
+ @SuppressLint("Doclava125")
public List<BatchedScanResult> getBatchedScanResults() {
return null;
}
* @hide
*/
@SystemApi
+ @RequiresPermission(android.Manifest.permission.TETHER_PRIVILEGED)
public boolean setWifiApEnabled(WifiConfiguration wifiConfig, boolean enabled) {
String packageName = mContext.getOpPackageName();
package android.net.wifi;
+import android.annotation.RequiresPermission;
+import android.annotation.SuppressLint;
import android.annotation.SystemApi;
+import android.annotation.SystemService;
import android.content.Context;
import android.os.Bundle;
import android.os.Handler;
/**
* This class provides a way to scan the Wifi universe around the device
- * Get an instance of this class by calling
- * {@link android.content.Context#getSystemService(String) Context.getSystemService(Context
- * .WIFI_SCANNING_SERVICE)}.
* @hide
*/
@SystemApi
+@SystemService(Context.WIFI_SCANNING_SERVICE)
public class WifiScanner {
/** no band specified; use channel list instead */
* key for this scan, and must also be specified to cancel the scan. Multiple
* scans should also not share this object.
*/
+ @RequiresPermission(android.Manifest.permission.LOCATION_HARDWARE)
public void startBackgroundScan(ScanSettings settings, ScanListener listener) {
startBackgroundScan(settings, listener, null);
}
* key for this scan, and must also be specified to cancel the scan. Multiple
* scans should also not share this object.
*/
+ @RequiresPermission(android.Manifest.permission.LOCATION_HARDWARE)
public void startBackgroundScan(ScanSettings settings, ScanListener listener,
WorkSource workSource) {
Preconditions.checkNotNull(listener, "listener cannot be null");
* @param listener specifies which scan to cancel; must be same object as passed in {@link
* #startBackgroundScan}
*/
+ @RequiresPermission(android.Manifest.permission.LOCATION_HARDWARE)
public void stopBackgroundScan(ScanListener listener) {
Preconditions.checkNotNull(listener, "listener cannot be null");
int key = removeListener(listener);
* reports currently available scan results on appropriate listeners
* @return true if all scan results were reported correctly
*/
+ @RequiresPermission(android.Manifest.permission.LOCATION_HARDWARE)
public boolean getScanResults() {
validateChannel();
Message reply = mAsyncChannel.sendMessageSynchronously(CMD_GET_SCAN_RESULTS, 0);
* key for this scan, and must also be specified to cancel the scan. Multiple
* scans should also not share this object.
*/
+ @RequiresPermission(android.Manifest.permission.LOCATION_HARDWARE)
public void startScan(ScanSettings settings, ScanListener listener) {
startScan(settings, listener, null);
}
* key for this scan, and must also be specified to cancel the scan. Multiple
* scans should also not share this object.
*/
+ @RequiresPermission(android.Manifest.permission.LOCATION_HARDWARE)
public void startScan(ScanSettings settings, ScanListener listener, WorkSource workSource) {
Preconditions.checkNotNull(listener, "listener cannot be null");
int key = addListener(listener);
* hasn't been called on the listener, ignored otherwise
* @param listener
*/
+ @RequiresPermission(android.Manifest.permission.LOCATION_HARDWARE)
public void stopScan(ScanListener listener) {
Preconditions.checkNotNull(listener, "listener cannot be null");
int key = removeListener(listener);
* @param bssidInfos access points to watch
*/
@Deprecated
+ @SuppressLint("Doclava125")
public void configureWifiChange(
int rssiSampleSize, /* sample size for RSSI averaging */
int lostApSampleSize, /* samples to confirm AP's loss */
* provided on {@link #stopTrackingWifiChange}
*/
@Deprecated
+ @SuppressLint("Doclava125")
public void startTrackingWifiChange(WifiChangeListener listener) {
throw new UnsupportedOperationException();
}
* #stopTrackingWifiChange}
*/
@Deprecated
+ @SuppressLint("Doclava125")
public void stopTrackingWifiChange(WifiChangeListener listener) {
throw new UnsupportedOperationException();
}
/** @hide */
@SystemApi
@Deprecated
+ @SuppressLint("Doclava125")
public void configureWifiChange(WifiChangeSettings settings) {
throw new UnsupportedOperationException();
}
* also be provided on {@link #stopTrackingBssids}
*/
@Deprecated
+ @SuppressLint("Doclava125")
public void startTrackingBssids(BssidInfo[] bssidInfos,
int apLostThreshold, BssidListener listener) {
throw new UnsupportedOperationException();
* @param listener same object provided in {@link #startTrackingBssids}
*/
@Deprecated
+ @SuppressLint("Doclava125")
public void stopTrackingBssids(BssidListener listener) {
throw new UnsupportedOperationException();
}
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.annotation.SdkConstant;
+import android.annotation.SystemService;
import android.annotation.SdkConstant.SdkConstantType;
import android.content.Context;
import android.net.ConnectivityManager;
/**
* This class provides the primary API for managing Wi-Fi Aware operations:
- * discovery and peer-to-peer data connections. Get an instance of this class by calling
- * {@link android.content.Context#getSystemService(String)
- * Context.getSystemService(Context.WIFI_AWARE_SERVICE)}.
+ * discovery and peer-to-peer data connections.
* <p>
* The class provides access to:
* <ul>
* {@link DiscoverySession#createNetworkSpecifierPassphrase(PeerHandle, String)}.
* </ul>
*/
+@SystemService(Context.WIFI_AWARE_SERVICE)
public class WifiAwareManager {
private static final String TAG = "WifiAwareManager";
private static final boolean DBG = false;
package android.net.wifi.p2p;
import android.annotation.SdkConstant;
+import android.annotation.SystemService;
import android.annotation.SdkConstant.SdkConstantType;
import android.content.Context;
import android.net.wifi.WpsInfo;
* {@link android.Manifest.permission#CHANGE_WIFI_STATE} to perform any further peer-to-peer
* operations.
*
- * Get an instance of this class by calling {@link android.content.Context#getSystemService(String)
- * Context.getSystemService(Context.WIFI_P2P_SERVICE)}.
- *
* {@see WifiP2pConfig}
* {@see WifiP2pInfo}
* {@see WifiP2pGroup}
* {@see WifiP2pDeviceList}
* {@see android.net.wifi.WpsInfo}
*/
+@SystemService(Context.WIFI_P2P_SERVICE)
public class WifiP2pManager {
private static final String TAG = "WifiP2pManager";
/**