From d86b8fea43ebb6e5c31691b44d8ceb0d8d3c9072 Mon Sep 17 00:00:00 2001
From: Jeff Sharkey
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"; diff --git a/core/java/android/app/AppOpsManager.java b/core/java/android/app/AppOpsManager.java index 82921524457f..e672ada3cbb4 100644 --- a/core/java/android/app/AppOpsManager.java +++ b/core/java/android/app/AppOpsManager.java @@ -17,7 +17,9 @@ 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; @@ -42,10 +44,9 @@ import java.util.List; * API for interacting with "application operation" tracking. * *
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}.
+ * features are only available to system applications. */ +@SystemService(Context.APP_OPS_SERVICE) public class AppOpsManager { /** *App ops allows callers to:
@@ -1409,6 +1410,7 @@ public class AppOpsManager { * @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); diff --git a/core/java/android/app/BroadcastOptions.java b/core/java/android/app/BroadcastOptions.java index 175b9799c5db..b6cff385d752 100644 --- a/core/java/android/app/BroadcastOptions.java +++ b/core/java/android/app/BroadcastOptions.java @@ -16,6 +16,7 @@ package android.app; +import android.annotation.RequiresPermission; import android.annotation.SystemApi; import android.os.Build; import android.os.Bundle; @@ -72,6 +73,7 @@ public class BroadcastOptions { * 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; } diff --git a/core/java/android/app/DownloadManager.java b/core/java/android/app/DownloadManager.java index b89c16539b4c..5baaeb30e233 100644 --- a/core/java/android/app/DownloadManager.java +++ b/core/java/android/app/DownloadManager.java @@ -19,6 +19,7 @@ package android.app; 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; @@ -51,18 +52,15 @@ import java.util.List; * 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}. - * + ** 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. - * + *
* Note that the application must have the {@link android.Manifest.permission#INTERNET} * permission to use this class. */ +@SystemService(Context.DOWNLOAD_SERVICE) public class DownloadManager { /** diff --git a/core/java/android/app/KeyguardManager.java b/core/java/android/app/KeyguardManager.java index fcf0aab0c821..2a29616aab76 100644 --- a/core/java/android/app/KeyguardManager.java +++ b/core/java/android/app/KeyguardManager.java @@ -20,6 +20,7 @@ import android.Manifest; 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; @@ -44,12 +45,11 @@ import com.android.internal.policy.IKeyguardDismissCallback; 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"; diff --git a/core/java/android/app/Notification.java b/core/java/android/app/Notification.java index 31f52dbea548..ad6b45476c4b 100644 --- a/core/java/android/app/Notification.java +++ b/core/java/android/app/Notification.java @@ -22,6 +22,7 @@ import android.annotation.ColorInt; 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; @@ -1009,6 +1010,7 @@ public class Notification implements Parcelable * @hide */ @SystemApi + @RequiresPermission(android.Manifest.permission.NOTIFICATION_DURING_SETUP) public static final String EXTRA_ALLOW_DURING_SETUP = "android.allowDuringSetup"; /** @@ -1110,6 +1112,7 @@ public class Notification implements Parcelable /** @hide */ @SystemApi + @RequiresPermission(android.Manifest.permission.SUBSTITUTE_NOTIFICATION_APP_NAME) public static final String EXTRA_SUBSTITUTE_APP_NAME = "android.substName"; /** diff --git a/core/java/android/app/NotificationManager.java b/core/java/android/app/NotificationManager.java index 6c55548c2ea4..235b8d445b1c 100644 --- a/core/java/android/app/NotificationManager.java +++ b/core/java/android/app/NotificationManager.java @@ -20,6 +20,7 @@ import android.annotation.IntDef; 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; @@ -81,10 +82,6 @@ import java.util.Objects; * to the {@link #cancel(int)} or {@link #cancel(String, int)} method to clear * this notification. * - *
- * You do not instantiate this class directly; instead, retrieve it through - * {@link android.content.Context#getSystemService}. - * *
For a guide to creating notifications, read the @@ -93,10 +90,9 @@ import java.util.Objects; *
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"; diff --git a/core/java/android/app/VrManager.java b/core/java/android/app/VrManager.java index 8014ecafa9a2..b40c96c6f0c8 100644 --- a/core/java/android/app/VrManager.java +++ b/core/java/android/app/VrManager.java @@ -1,19 +1,20 @@ 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. - *
- * 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; @@ -29,11 +30,10 @@ public class VrManager { * 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. * - *
Requires {@link android.Manifest.permission#ACCESS_VR_MANAGER} permission.
- * * @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); @@ -46,13 +46,12 @@ public class VrManager { * Sets the resolution and DPI of the vr2d virtual display used to display 2D * applications in VR mode. * - *Requires {@link android.Manifest.permission#ACCESS_VR_MANAGER} permission.
- * * @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 { diff --git a/core/java/android/app/WallpaperManager.java b/core/java/android/app/WallpaperManager.java index db2f937e2ef2..a8504237e82b 100644 --- a/core/java/android/app/WallpaperManager.java +++ b/core/java/android/app/WallpaperManager.java @@ -18,8 +18,10 @@ package android.app; 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; @@ -76,13 +78,13 @@ import java.util.concurrent.TimeUnit; /** * 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. * *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; @@ -1355,6 +1357,7 @@ public class WallpaperManager { * @hide */ @SystemApi + @RequiresPermission(android.Manifest.permission.SET_WALLPAPER_HINTS) public void setDisplayPadding(Rect padding) { try { if (sGlobals.mService == null) { @@ -1395,6 +1398,7 @@ public class WallpaperManager { * @hide */ @SystemApi + @RequiresPermission(android.Manifest.permission.SET_WALLPAPER) public void clearWallpaper() { clearWallpaper(FLAG_LOCK, mContext.getUserId()); clearWallpaper(FLAG_SYSTEM, mContext.getUserId()); @@ -1407,6 +1411,7 @@ public class WallpaperManager { * @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"); @@ -1422,12 +1427,10 @@ public class WallpaperManager { /** * 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()); } diff --git a/core/java/android/app/admin/DevicePolicyManager.java b/core/java/android/app/admin/DevicePolicyManager.java index 9ae5d1c86842..b6c6f5b0c035 100644 --- a/core/java/android/app/admin/DevicePolicyManager.java +++ b/core/java/android/app/admin/DevicePolicyManager.java @@ -20,9 +20,12 @@ import android.annotation.ColorInt; 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; @@ -98,6 +101,7 @@ import java.util.Set; * "{@docRoot}guide/topics/admin/device-admin.html">Device Administration developer * guide. */ +@SystemService(Context.DEVICE_POLICY_SERVICE) public class DevicePolicyManager { private static String TAG = "DevicePolicyManager"; @@ -4653,6 +4657,7 @@ public class DevicePolicyManager { */ @Deprecated @SystemApi + @SuppressLint("Doclava125") public @Nullable String getDeviceInitializerApp() { return null; } @@ -4664,6 +4669,7 @@ public class DevicePolicyManager { */ @Deprecated @SystemApi + @SuppressLint("Doclava125") public @Nullable ComponentName getDeviceInitializerComponent() { return null; } @@ -4686,6 +4692,7 @@ public class DevicePolicyManager { */ @Deprecated @SystemApi + @RequiresPermission(android.Manifest.permission.MANAGE_DEVICE_ADMINS) public boolean setActiveProfileOwner(@NonNull ComponentName admin, @Deprecated String ownerName) throws IllegalArgumentException { throwIfParentInstance("setActiveProfileOwner"); @@ -6773,8 +6780,7 @@ public class DevicePolicyManager { * 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)}. * @@ -6785,6 +6791,7 @@ public class DevicePolicyManager { * @hide */ @SystemApi + @RequiresPermission(android.Manifest.permission.NOTIFY_PENDING_SYSTEM_UPDATE) public void notifyPendingSystemUpdate(long updateReceivedTime) { throwIfParentInstance("notifyPendingSystemUpdate"); if (mService != null) { @@ -6800,8 +6807,7 @@ public class DevicePolicyManager { * 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()} @@ -6813,6 +6819,7 @@ public class DevicePolicyManager { * @hide */ @SystemApi + @RequiresPermission(android.Manifest.permission.NOTIFY_PENDING_SYSTEM_UPDATE) public void notifyPendingSystemUpdate(long updateReceivedTime, boolean isSecurityPatch) { throwIfParentInstance("notifyPendingSystemUpdate"); if (mService != null) { @@ -7711,6 +7718,7 @@ public class DevicePolicyManager { * @hide */ @SystemApi + @RequiresPermission(android.Manifest.permission.MANAGE_USERS) public void setDeviceProvisioningConfigApplied() { try { mService.setDeviceProvisioningConfigApplied(); diff --git a/core/java/android/app/backup/BackupManager.java b/core/java/android/app/backup/BackupManager.java index 9d02f53b13bd..9f9b217069d8 100644 --- a/core/java/android/app/backup/BackupManager.java +++ b/core/java/android/app/backup/BackupManager.java @@ -16,6 +16,7 @@ package android.app.backup; +import android.annotation.RequiresPermission; import android.annotation.SystemApi; import android.content.ComponentName; import android.content.Context; @@ -324,6 +325,7 @@ public class BackupManager { * @hide */ @SystemApi + @RequiresPermission(android.Manifest.permission.BACKUP) public RestoreSession beginRestoreSession() { RestoreSession session = null; checkServiceBinder(); @@ -348,11 +350,10 @@ public class BackupManager { * mechanism was disabled will still be backed up properly if it is enabled * at some point in the future. * - *
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) { @@ -367,11 +368,10 @@ public class BackupManager { /** * Report whether the backup mechanism is currently enabled. * - *
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) { @@ -390,11 +390,10 @@ public class BackupManager { * the archival restore dataset (if any). When disabled, no such attempt will * be made. * - *
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) { @@ -407,14 +406,14 @@ public class BackupManager { } /** - * 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) { @@ -428,12 +427,12 @@ public class BackupManager { } /** - * 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) { @@ -449,8 +448,6 @@ public class BackupManager { /** * Specify the current backup transport. * - *
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. @@ -462,6 +459,7 @@ public class BackupManager { */ @Deprecated @SystemApi + @RequiresPermission(android.Manifest.permission.BACKUP) public String selectBackupTransport(String transport) { checkServiceBinder(); if (sService != null) { @@ -479,8 +477,6 @@ public class BackupManager { * This method is async because BackupManager might need to bind to the specified transport * which is in a separate process. * - *
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. @@ -488,6 +484,7 @@ public class BackupManager { * @hide */ @SystemApi + @RequiresPermission(android.Manifest.permission.BACKUP) public void selectBackupTransport(ComponentName transport, SelectBackupTransportCallback listener) { checkServiceBinder(); @@ -510,11 +507,10 @@ public class BackupManager { * transport will still be asked to confirm via the usual requestBackupTime() * method. * - *
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) { @@ -530,8 +526,6 @@ public class BackupManager { * Ask the framework which dataset, if any, the given package's data would be * restored from if we were to install it right now. * - *
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 @@ -540,6 +534,7 @@ public class BackupManager { * @hide */ @SystemApi + @RequiresPermission(android.Manifest.permission.BACKUP) public long getAvailableRestoreToken(String packageName) { checkServiceBinder(); if (sService != null) { @@ -555,14 +550,13 @@ public class BackupManager { /** * Ask the framework whether this app is eligible for backup. * - *
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) { @@ -592,6 +586,7 @@ public class BackupManager { * @hide */ @SystemApi + @RequiresPermission(android.Manifest.permission.BACKUP) public int requestBackup(String[] packages, BackupObserver observer) { return requestBackup(packages, observer, null, 0); } @@ -615,6 +610,7 @@ public class BackupManager { * @hide */ @SystemApi + @RequiresPermission(android.Manifest.permission.BACKUP) public int requestBackup(String[] packages, BackupObserver observer, BackupManagerMonitor monitor, int flags) { checkServiceBinder(); @@ -638,11 +634,10 @@ public class BackupManager { * Cancel all running backups. After this call returns, no currently running backups will * interact with the selected transport. * - *
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) { diff --git a/core/java/android/app/job/JobScheduler.java b/core/java/android/app/job/JobScheduler.java index 1768828eb76c..3868439f092f 100644 --- a/core/java/android/app/job/JobScheduler.java +++ b/core/java/android/app/job/JobScheduler.java @@ -19,8 +19,11 @@ package android.app.job; 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; @@ -53,6 +56,7 @@ import java.util.List; * {@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 = { @@ -132,6 +136,7 @@ public abstract class JobScheduler { * @hide */ @SystemApi + @RequiresPermission(android.Manifest.permission.UPDATE_DEVICE_STATS) public abstract @Result int scheduleAsPackage(@NonNull JobInfo job, @NonNull String packageName, int userId, String tag); diff --git a/core/java/android/app/trust/TrustManager.java b/core/java/android/app/trust/TrustManager.java index 06b0aacd8654..54a7e5caa270 100644 --- a/core/java/android/app/trust/TrustManager.java +++ b/core/java/android/app/trust/TrustManager.java @@ -18,6 +18,8 @@ package android.app.trust; 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; @@ -31,6 +33,7 @@ import com.android.internal.widget.LockPatternUtils; * See {@link com.android.server.trust.TrustManagerService} * @hide */ +@SystemService(Context.TRUST_SERVICE) public class TrustManager { private static final int MSG_TRUST_CHANGED = 1; diff --git a/core/java/android/app/usage/NetworkStatsManager.java b/core/java/android/app/usage/NetworkStatsManager.java index 6cd4e92383b2..ef262e046021 100644 --- a/core/java/android/app/usage/NetworkStatsManager.java +++ b/core/java/android/app/usage/NetworkStatsManager.java @@ -19,6 +19,7 @@ package android.app.usage; 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; @@ -82,6 +83,7 @@ import android.util.Log; * 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; diff --git a/core/java/android/app/usage/StorageStatsManager.java b/core/java/android/app/usage/StorageStatsManager.java index 0b2b1900c4e0..7c680794d140 100644 --- a/core/java/android/app/usage/StorageStatsManager.java +++ b/core/java/android/app/usage/StorageStatsManager.java @@ -20,6 +20,7 @@ import static android.os.storage.StorageManager.convert; import android.annotation.BytesLong; import android.annotation.NonNull; +import android.annotation.SystemService; import android.annotation.TestApi; import android.annotation.WorkerThread; import android.content.Context; @@ -50,6 +51,7 @@ import java.util.UUID; * application. *
*/ +@SystemService(Context.STORAGE_STATS_SERVICE) public class StorageStatsManager { private final Context mContext; private final IStorageStatsManager mService; diff --git a/core/java/android/app/usage/UsageStatsManager.java b/core/java/android/app/usage/UsageStatsManager.java index 75a4a535186e..1f939f996c68 100644 --- a/core/java/android/app/usage/UsageStatsManager.java +++ b/core/java/android/app/usage/UsageStatsManager.java @@ -16,7 +16,9 @@ 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; @@ -51,6 +53,7 @@ import java.util.Map; * 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 { /** @@ -252,7 +255,6 @@ 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. @@ -261,6 +263,7 @@ public final class UsageStatsManager { * @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()); diff --git a/core/java/android/appwidget/AppWidgetManager.java b/core/java/android/appwidget/AppWidgetManager.java index 6327f34ebd5e..969b19ee48ac 100644 --- a/core/java/android/appwidget/AppWidgetManager.java +++ b/core/java/android/appwidget/AppWidgetManager.java @@ -20,6 +20,7 @@ import android.annotation.BroadcastBehavior; 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; @@ -51,6 +52,7 @@ import java.util.List; * App Widgets developer guide. * */ +@SystemService(Context.APPWIDGET_SERVICE) public class AppWidgetManager { /** diff --git a/core/java/android/bluetooth/BluetoothManager.java b/core/java/android/bluetooth/BluetoothManager.java index c7191ba2638b..e2fa38a9309f 100644 --- a/core/java/android/bluetooth/BluetoothManager.java +++ b/core/java/android/bluetooth/BluetoothManager.java @@ -18,6 +18,7 @@ package android.bluetooth; import android.Manifest; import android.annotation.RequiresPermission; +import android.annotation.SystemService; import android.content.Context; import android.os.RemoteException; import android.util.Log; @@ -48,6 +49,7 @@ import java.util.List; * @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; diff --git a/core/java/android/companion/CompanionDeviceManager.java b/core/java/android/companion/CompanionDeviceManager.java index 4e70e3fe8ce5..dabe608c038f 100644 --- a/core/java/android/companion/CompanionDeviceManager.java +++ b/core/java/android/companion/CompanionDeviceManager.java @@ -21,6 +21,7 @@ import static com.android.internal.util.Preconditions.checkNotNull; import android.annotation.NonNull; import android.annotation.Nullable; +import android.annotation.SystemService; import android.app.Activity; import android.app.Application; import android.app.PendingIntent; @@ -47,6 +48,7 @@ import java.util.List; * * @see AssociationRequest */ +@SystemService(Context.COMPANION_DEVICE_SERVICE) public final class CompanionDeviceManager { private static final boolean DEBUG = false; diff --git a/core/java/android/content/ClipboardManager.java b/core/java/android/content/ClipboardManager.java index f1c2f342eb3e..718e465bf0de 100644 --- a/core/java/android/content/ClipboardManager.java +++ b/core/java/android/content/ClipboardManager.java @@ -16,6 +16,7 @@ package android.content; +import android.annotation.SystemService; import android.os.Handler; import android.os.Message; import android.os.RemoteException; @@ -29,10 +30,6 @@ import java.util.ArrayList; * the global clipboard. * *- * You do not instantiate this class directly; instead, retrieve it through - * {@link android.content.Context#getSystemService}. - * - *
* 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 @@ -44,9 +41,8 @@ import java.util.ArrayList; * Copy and Paste * developer guide.
* - * - * @see android.content.Context#getSystemService */ +@SystemService(Context.CLIPBOARD_SERVICE) public class ClipboardManager extends android.text.ClipboardManager { private final Context mContext; private final IClipboard mService; diff --git a/core/java/android/content/Context.java b/core/java/android/content/Context.java index 10594afc7f9d..db80c7259179 100644 --- a/core/java/android/content/Context.java +++ b/core/java/android/content/Context.java @@ -1630,13 +1630,13 @@ public abstract class Context { /** * 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."); } @@ -1672,8 +1672,7 @@ public abstract class Context { /** * 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} @@ -1683,6 +1682,7 @@ public abstract class Context { * @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."); @@ -1781,6 +1781,7 @@ public abstract class Context { * @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."); } @@ -2081,20 +2082,19 @@ public abstract class Context { /** * 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. @@ -2105,14 +2105,14 @@ public abstract class Context { * * @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. @@ -2127,14 +2127,14 @@ public abstract class Context { * @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. @@ -2148,6 +2148,7 @@ public abstract class Context { * * @hide */ + @RequiresPermission(android.Manifest.permission.INTERACT_ACROSS_USERS) public abstract void sendBroadcastAsUser(@RequiresPermission Intent intent, UserHandle user, @Nullable String receiverPermission, int appOp); @@ -2156,8 +2157,7 @@ public abstract class Context { * {@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. * *See {@link BroadcastReceiver} for more information on Intent broadcasts. * @@ -2181,6 +2181,7 @@ public abstract class Context { * * @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, @@ -2192,6 +2193,7 @@ public abstract class Context { * 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, @@ -2203,6 +2205,7 @@ public abstract class Context { * 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, @@ -2307,8 +2310,7 @@ public abstract class Context { /** *
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. @@ -2324,6 +2326,10 @@ public abstract class Context { * @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); @@ -2332,6 +2338,10 @@ public abstract class Context { * 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); @@ -2340,8 +2350,7 @@ public abstract class Context { * {@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. * *
See {@link BroadcastReceiver} for more information on Intent broadcasts. * @@ -2369,6 +2378,10 @@ public abstract class Context { * @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, @@ -2377,8 +2390,7 @@ public abstract class Context { /** *
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. * *
You must hold the {@link android.Manifest.permission#BROADCAST_STICKY}
* permission in order to use this API. If you do not hold that
@@ -2396,6 +2408,10 @@ public abstract class Context {
* @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);
@@ -2562,9 +2578,7 @@ public abstract class Context {
* @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.
@@ -2583,6 +2597,7 @@ public abstract class Context {
* @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);
@@ -2691,6 +2706,7 @@ public abstract class Context {
* @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);
/**
@@ -2728,11 +2744,13 @@ public abstract class Context {
* @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);
/**
@@ -2792,6 +2810,7 @@ public abstract class Context {
*/
@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.");
@@ -2803,6 +2822,7 @@ public abstract class Context {
*
* @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.");
diff --git a/core/java/android/content/RestrictionsManager.java b/core/java/android/content/RestrictionsManager.java
index 88aae6655428..b463ec6277e7 100644
--- a/core/java/android/content/RestrictionsManager.java
+++ b/core/java/android/content/RestrictionsManager.java
@@ -16,6 +16,7 @@
package android.content;
+import android.annotation.SystemService;
import android.app.Activity;
import android.app.admin.DevicePolicyManager;
import android.content.pm.ApplicationInfo;
@@ -120,6 +121,7 @@ import java.util.List;
* @see DevicePolicyManager#setRestrictionsProvider(ComponentName, ComponentName)
* @see DevicePolicyManager#setApplicationRestrictions(ComponentName, String, Bundle)
*/
+@SystemService(Context.RESTRICTIONS_SERVICE)
public class RestrictionsManager {
private static final String TAG = "RestrictionsManager";
diff --git a/core/java/android/content/pm/LauncherApps.java b/core/java/android/content/pm/LauncherApps.java
index 8ead0ec612f8..ed41e79e2c6c 100644
--- a/core/java/android/content/pm/LauncherApps.java
+++ b/core/java/android/content/pm/LauncherApps.java
@@ -20,6 +20,7 @@ import android.annotation.IntDef;
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;
@@ -79,6 +80,7 @@ import java.util.List;
* 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";
diff --git a/core/java/android/content/pm/PackageInstaller.java b/core/java/android/content/pm/PackageInstaller.java
index 4e112331a1ed..7f3f35ffd4f3 100644
--- a/core/java/android/content/pm/PackageInstaller.java
+++ b/core/java/android/content/pm/PackageInstaller.java
@@ -473,6 +473,7 @@ public class PackageInstaller {
/** {@hide} */
@SystemApi
+ @RequiresPermission(android.Manifest.permission.INSTALL_PACKAGES)
public void setPermissionsResult(int sessionId, boolean accepted) {
try {
mInstaller.setPermissionsResult(sessionId, accepted);
@@ -1156,6 +1157,7 @@ public class PackageInstaller {
/** {@hide} */
@SystemApi
+ @RequiresPermission(android.Manifest.permission.ALLOCATE_AGGRESSIVE)
public void setAllocateAggressive(boolean allocateAggressive) {
if (allocateAggressive) {
installFlags |= PackageManager.INSTALL_ALLOCATE_AGGRESSIVE;
diff --git a/core/java/android/content/pm/PackageManager.java b/core/java/android/content/pm/PackageManager.java
index a68c0973b473..be2cd107fcbf 100644
--- a/core/java/android/content/pm/PackageManager.java
+++ b/core/java/android/content/pm/PackageManager.java
@@ -3208,8 +3208,7 @@ public abstract class PackageManager {
/**
* 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
@@ -3224,6 +3223,7 @@ public abstract class PackageManager {
* @hide
*/
@SystemApi
+ @RequiresPermission(android.Manifest.permission.INTERACT_ACROSS_USERS_FULL)
public abstract List
- * 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.
- *
* 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}.
*
* Always make sure to disable sensors you don't need, especially when your
@@ -79,6 +78,7 @@ import java.util.List;
* @see Sensor
*
*/
+@SystemService(Context.SENSOR_SERVICE)
public abstract class SensorManager {
/** @hide */
protected static final String TAG = "SensorManager";
diff --git a/core/java/android/hardware/SerialManager.java b/core/java/android/hardware/SerialManager.java
index 83f7649ff326..610f6a587e51 100644
--- a/core/java/android/hardware/SerialManager.java
+++ b/core/java/android/hardware/SerialManager.java
@@ -16,6 +16,7 @@
package android.hardware;
+import android.annotation.SystemService;
import android.content.Context;
import android.os.ParcelFileDescriptor;
import android.os.RemoteException;
@@ -25,6 +26,7 @@ import java.io.IOException;
/**
* @hide
*/
+@SystemService(Context.SERIAL_SERVICE)
public class SerialManager {
private static final String TAG = "SerialManager";
diff --git a/core/java/android/hardware/camera2/CameraManager.java b/core/java/android/hardware/camera2/CameraManager.java
index f61032ef8250..1b150bfca63a 100644
--- a/core/java/android/hardware/camera2/CameraManager.java
+++ b/core/java/android/hardware/camera2/CameraManager.java
@@ -17,6 +17,7 @@
package android.hardware.camera2;
import android.annotation.RequiresPermission;
+import android.annotation.SystemService;
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.content.Context;
@@ -44,15 +45,11 @@ import java.util.ArrayList;
* A system service manager for detecting, characterizing, and connecting to
* {@link CameraDevice CameraDevices}. You can get an instance of this class by calling
- * {@link android.content.Context#getSystemService(String) Context.getSystemService()}. For more details about communicating with camera devices, read the Camera
* developer guide or the {@link android.hardware.camera2 camera2}
* package documentation.
- * 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}.
- *
- * 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;
diff --git a/core/java/android/hardware/hdmi/HdmiControlManager.java b/core/java/android/hardware/hdmi/HdmiControlManager.java
index 27e2a5072287..1371351cc8ff 100644
--- a/core/java/android/hardware/hdmi/HdmiControlManager.java
+++ b/core/java/android/hardware/hdmi/HdmiControlManager.java
@@ -19,7 +19,9 @@ package android.hardware.hdmi;
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;
@@ -37,6 +39,7 @@ import android.util.Log;
* @hide
*/
@SystemApi
+@SystemService(Context.HDMI_CONTROL_SERVICE)
public final class HdmiControlManager {
private static final String TAG = "HdmiControlManager";
diff --git a/core/java/android/hardware/input/InputManager.java b/core/java/android/hardware/input/InputManager.java
index 631b77d4132c..5149e930d94a 100644
--- a/core/java/android/hardware/input/InputManager.java
+++ b/core/java/android/hardware/input/InputManager.java
@@ -21,6 +21,7 @@ import com.android.internal.os.SomeArgs;
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;
@@ -53,13 +54,8 @@ import java.util.List;
/**
* Provides information about input devices and available key layouts.
- *
- * 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}.
- * 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);}
- *
* For more information about communicating with USB hardware, read the
* USB developer guide.
* The primary responsibilities of this class are to:
* 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";
diff --git a/core/java/android/net/NetworkPolicyManager.java b/core/java/android/net/NetworkPolicyManager.java
index 43fab037f254..4d94a55cd0c4 100644
--- a/core/java/android/net/NetworkPolicyManager.java
+++ b/core/java/android/net/NetworkPolicyManager.java
@@ -19,6 +19,7 @@ package android.net;
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;
@@ -40,6 +41,7 @@ import java.util.TimeZone;
*
* {@hide}
*/
+@SystemService(Context.NETWORK_POLICY_SERVICE)
public class NetworkPolicyManager {
/* POLICY_* are masks and can be ORed, although currently they are not.*/
diff --git a/core/java/android/net/NetworkScoreManager.java b/core/java/android/net/NetworkScoreManager.java
index 9f6e45ca6fb5..7e0c9ce33b82 100644
--- a/core/java/android/net/NetworkScoreManager.java
+++ b/core/java/android/net/NetworkScoreManager.java
@@ -19,9 +19,11 @@ package android.net;
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;
@@ -34,12 +36,6 @@ import java.util.List;
/**
* Class that manages communication between network subsystems and a network scorer.
*
- * You can get an instance of this class by calling
- * {@link android.content.Context#getSystemService(String)}:
- *
- * A network scorer is any application which:
* CameraManager manager = (CameraManager) getSystemService(Context.CAMERA_SERVICE);
- *
* Developer Guides
*
@@ -80,6 +79,7 @@ import java.util.concurrent.atomic.AtomicInteger;
* traffic
*
*/
+@SystemService(Context.CONNECTIVITY_SERVICE)
public class ConnectivityManager {
private static final String TAG = "ConnectivityManager";
@@ -2105,6 +2105,7 @@ public class 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.");
@@ -2139,6 +2140,7 @@ public class ConnectivityManager {
* @hide
*/
@SystemApi
+ @RequiresPermission(android.Manifest.permission.TETHER_PRIVILEGED)
public void stopTethering(int type) {
try {
mService.stopTethering(type);
diff --git a/core/java/android/net/EthernetManager.java b/core/java/android/net/EthernetManager.java
index 664b7b408975..31a30968cbcd 100644
--- a/core/java/android/net/EthernetManager.java
+++ b/core/java/android/net/EthernetManager.java
@@ -16,6 +16,7 @@
package android.net;
+import android.annotation.SystemService;
import android.content.Context;
import android.net.IEthernetManager;
import android.net.IEthernetServiceListener;
@@ -31,6 +32,7 @@ import java.util.ArrayList;
*
* @hide
*/
+@SystemService(Context.ETHERNET_SERVICE)
public class EthernetManager {
private static final String TAG = "EthernetManager";
private static final int MSG_AVAILABILITY_CHANGED = 1000;
diff --git a/core/java/android/net/IpSecManager.java b/core/java/android/net/IpSecManager.java
index 114e46e54fe7..e3cda5e7d85d 100644
--- a/core/java/android/net/IpSecManager.java
+++ b/core/java/android/net/IpSecManager.java
@@ -18,6 +18,8 @@ package android.net;
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;
@@ -34,12 +36,9 @@ import java.net.Socket;
* This class contains methods for managing IPsec sessions, which will perform kernel-space
* encryption and decryption of socket or Network traffic.
*
- * NetworkScoreManager manager =
- * (NetworkScoreManager) getSystemService(Context.NETWORK_SCORE_SERVICE)
- *
*
*
You can obtain an instance of this class by calling - * {@link android.content.Context#getSystemService} - * with {@link android.content.Context#DROPBOX_SERVICE}. - * *
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"; diff --git a/core/java/android/os/HardwarePropertiesManager.java b/core/java/android/os/HardwarePropertiesManager.java index 67edefc16bd0..aad202e77710 100644 --- a/core/java/android/os/HardwarePropertiesManager.java +++ b/core/java/android/os/HardwarePropertiesManager.java @@ -17,6 +17,7 @@ package android.os; 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; @@ -28,6 +29,7 @@ import java.lang.annotation.RetentionPolicy; * 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(); diff --git a/core/java/android/os/IncidentManager.java b/core/java/android/os/IncidentManager.java index 976d59472e69..bc8e2e470c55 100644 --- a/core/java/android/os/IncidentManager.java +++ b/core/java/android/os/IncidentManager.java @@ -16,7 +16,9 @@ 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; @@ -31,6 +33,7 @@ import android.util.Slog; */ @SystemApi @TestApi +@SystemService(Context.INCIDENT_SERVICE) public class IncidentManager { private static final String TAG = "incident"; @@ -46,6 +49,10 @@ public class IncidentManager { /** * 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")); @@ -76,6 +83,10 @@ public class IncidentManager { * {@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); diff --git a/core/java/android/os/PowerManager.java b/core/java/android/os/PowerManager.java index 7d1369fe1b69..a85ed9c0ce34 100644 --- a/core/java/android/os/PowerManager.java +++ b/core/java/android/os/PowerManager.java @@ -17,8 +17,10 @@ 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; @@ -32,9 +34,6 @@ import java.lang.annotation.RetentionPolicy; * 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. *
- * You can obtain an instance of this class by calling - * {@link android.content.Context#getSystemService(java.lang.String) Context.getSystemService()}. - *
* 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.
@@ -102,6 +101,7 @@ import java.lang.annotation.RetentionPolicy;
* permission in an {@code
* 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";
@@ -1038,12 +1040,12 @@ public class 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.
@@ -1067,6 +1069,7 @@ public class UserManager {
* @hide
*/
@SystemApi
+ @RequiresPermission(android.Manifest.permission.MANAGE_USERS)
public boolean isManagedProfile(@UserIdInt int userId) {
if (userId == UserHandle.myUserId()) {
return isManagedProfile();
@@ -1252,7 +1255,6 @@ public class UserManager {
* @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},
@@ -1263,6 +1265,7 @@ public class UserManager {
@Deprecated
@SystemApi
@UserRestrictionSource
+ @RequiresPermission(android.Manifest.permission.MANAGE_USERS)
public int getUserRestrictionSource(String restrictionKey, UserHandle userHandle) {
try {
return mService.getUserRestrictionSource(restrictionKey, userHandle.getIdentifier());
@@ -1275,12 +1278,12 @@ public class UserManager {
* @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
* If your process exits, any vibration you started will stop.
*
- * 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";
@@ -1701,8 +1699,8 @@ public class 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) {
@@ -1715,8 +1713,8 @@ public class StorageManager {
/** @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);
}
@@ -1750,7 +1748,7 @@ public class StorageManager {
/** @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) {
@@ -1762,8 +1760,8 @@ public class StorageManager {
/** @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);
}
@@ -1798,8 +1796,8 @@ public class StorageManager {
/** @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 {
diff --git a/core/java/android/print/PrintManager.java b/core/java/android/print/PrintManager.java
index 8ee05177f186..e8ff2e2cee98 100644
--- a/core/java/android/print/PrintManager.java
+++ b/core/java/android/print/PrintManager.java
@@ -19,6 +19,7 @@ package android.print;
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;
@@ -57,14 +58,6 @@ import java.util.Map;
/**
* System level service for accessing the printing capabilities of the platform.
- *
- * To obtain a handle to the print manager do the following:
- *
@@ -109,6 +102,7 @@ import java.util.Map;
* @see PrintJob
* @see PrintJobInfo
*/
+@SystemService(Context.PRINT_SERVICE)
public final class PrintManager {
private static final String LOG_TAG = "PrintManager";
diff --git a/core/java/android/service/oemlock/OemLockManager.java b/core/java/android/service/oemlock/OemLockManager.java
index c4fbe5ec7e1a..e2ade87af981 100644
--- a/core/java/android/service/oemlock/OemLockManager.java
+++ b/core/java/android/service/oemlock/OemLockManager.java
@@ -17,7 +17,10 @@
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;
/**
@@ -31,6 +34,7 @@ import android.os.RemoteException;
* @hide
*/
@SystemApi
+@SystemService(Context.OEM_LOCK_SERVICE)
public class OemLockManager {
private IOemLockService mService;
@@ -55,6 +59,7 @@ public class OemLockManager {
*
* @see #isOemUnlockAllowedByCarrier()
*/
+ @RequiresPermission(android.Manifest.permission.MANAGE_CARRIER_OEM_UNLOCK_STATE)
public void setOemUnlockAllowedByCarrier(boolean allowed, @Nullable byte[] signature) {
try {
mService.setOemUnlockAllowedByCarrier(allowed, signature);
@@ -69,6 +74,7 @@ public class OemLockManager {
*
* @see #setOemUnlockAllowedByCarrier(boolean, byte[])
*/
+ @RequiresPermission(android.Manifest.permission.MANAGE_CARRIER_OEM_UNLOCK_STATE)
public boolean isOemUnlockAllowedByCarrier() {
try {
return mService.isOemUnlockAllowedByCarrier();
@@ -86,6 +92,7 @@ public class OemLockManager {
*
* @see #isOemUnlockAllowedByUser()
*/
+ @RequiresPermission(android.Manifest.permission.MANAGE_USER_OEM_UNLOCK_STATE)
public void setOemUnlockAllowedByUser(boolean allowed) {
try {
mService.setOemUnlockAllowedByUser(allowed);
@@ -100,6 +107,7 @@ public class OemLockManager {
*
* @see #setOemUnlockAllowedByUser(boolean)
*/
+ @RequiresPermission(android.Manifest.permission.MANAGE_USER_OEM_UNLOCK_STATE)
public boolean isOemUnlockAllowedByUser() {
try {
return mService.isOemUnlockAllowedByUser();
diff --git a/core/java/android/service/persistentdata/PersistentDataBlockManager.java b/core/java/android/service/persistentdata/PersistentDataBlockManager.java
index 326796afb3ad..fa75ad33d250 100644
--- a/core/java/android/service/persistentdata/PersistentDataBlockManager.java
+++ b/core/java/android/service/persistentdata/PersistentDataBlockManager.java
@@ -16,10 +16,14 @@
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;
@@ -43,6 +47,7 @@ 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;
@@ -85,6 +90,7 @@ public class PersistentDataBlockManager {
*
* @param data the data to write
*/
+ @SuppressLint("Doclava125")
public int write(byte[] data) {
try {
return sService.write(data);
@@ -96,6 +102,7 @@ public class PersistentDataBlockManager {
/**
* Returns the data block stored on the persistent partition.
*/
+ @SuppressLint("Doclava125")
public byte[] read() {
try {
return sService.read();
@@ -109,6 +116,7 @@ public class PersistentDataBlockManager {
*
* Return -1 on error.
*/
+ @RequiresPermission(android.Manifest.permission.ACCESS_PDB_STATE)
public int getDataBlockSize() {
try {
return sService.getDataBlockSize();
@@ -136,6 +144,7 @@ public class PersistentDataBlockManager {
* 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();
@@ -149,6 +158,7 @@ public class PersistentDataBlockManager {
*
* @deprecated use {@link OemLockManager#setOemUnlockAllowedByUser(boolean)} instead.
*/
+ @RequiresPermission(android.Manifest.permission.OEM_UNLOCK_STATE)
public void setOemUnlockEnabled(boolean enabled) {
try {
sService.setOemUnlockEnabled(enabled);
@@ -162,6 +172,10 @@ public class PersistentDataBlockManager {
*
* @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();
@@ -177,6 +191,10 @@ public class PersistentDataBlockManager {
* {@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 {
diff --git a/core/java/android/view/LayoutInflater.java b/core/java/android/view/LayoutInflater.java
index ad46d07d61c9..47b8d921da2e 100644
--- a/core/java/android/view/LayoutInflater.java
+++ b/core/java/android/view/LayoutInflater.java
@@ -18,6 +18,7 @@ package android.view;
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;
@@ -47,10 +48,7 @@ import java.util.HashMap;
* {@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:
- *
- *
* To create a new LayoutInflater with an additional {@link Factory} for your
@@ -64,9 +62,8 @@ import java.util.HashMap;
* 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.something file.)
- *
- * @see Context#getSystemService
*/
+@SystemService(Context.LAYOUT_INFLATER_SERVICE)
public abstract class LayoutInflater {
private static final String TAG = LayoutInflater.class.getSimpleName();
diff --git a/core/java/android/view/WindowManager.java b/core/java/android/view/WindowManager.java
index 3dd8d2aca4fb..4060b9a7c271 100644
--- a/core/java/android/view/WindowManager.java
+++ b/core/java/android/view/WindowManager.java
@@ -19,6 +19,7 @@ package android.view;
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;
@@ -39,8 +40,6 @@ import java.util.Objects;
/**
* The interface that apps use to talk to the window manager.
- *
- * Use
* Each window manager instance is bound to a particular {@link Display}.
* To obtain a {@link WindowManager} for a different display, use
@@ -52,10 +51,8 @@ import java.util.Objects;
* {@link Presentation}. The presentation will automatically obtain a
* {@link WindowManager} and {@link Context} for that display.
*
- * To obtain a handle to the accessibility manager do the following:
- *
- *
- * To obtain a handle to the captioning manager, do the following:
- *
- * 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";
diff --git a/core/java/android/view/inputmethod/InputMethodManager.java b/core/java/android/view/inputmethod/InputMethodManager.java
index da9316c300b3..e2f7979c61d9 100644
--- a/core/java/android/view/inputmethod/InputMethodManager.java
+++ b/core/java/android/view/inputmethod/InputMethodManager.java
@@ -21,6 +21,7 @@ import static android.Manifest.permission.WRITE_SECURE_SETTINGS;
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;
@@ -73,8 +74,6 @@ import java.util.concurrent.TimeUnit;
/**
* 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()}.
*
* Topics covered here:
*
- * PrintManager printManager =
- * (PrintManager) context.getSystemService(Context.PRINT_SERVICE);
- *
*
* Print mechanics
* LayoutInflater inflater = (LayoutInflater)context.getSystemService
- * (Context.LAYOUT_INFLATER_SERVICE);
+ * for the device you are running on.
*
* Context.getSystemService(Context.WINDOW_SERVICE)
to get one of these.
*
- *
- * AccessibilityManager accessibilityManager =
- * (AccessibilityManager) context.getSystemService(Context.ACCESSIBILITY_SERVICE);
- *
- *
*/
+@SystemService(Context.CAPTIONING_SERVICE)
public class CaptioningManager {
/** Default captioning enabled value. */
private static final int DEFAULT_ENABLED = 0;
diff --git a/core/java/android/view/autofill/AutofillManager.java b/core/java/android/view/autofill/AutofillManager.java
index 02ecc501ea39..310ec1c938d0 100644
--- a/core/java/android/view/autofill/AutofillManager.java
+++ b/core/java/android/view/autofill/AutofillManager.java
@@ -23,6 +23,7 @@ import static android.view.autofill.Helper.sVerbose;
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;
@@ -55,6 +56,7 @@ import java.util.Objects;
*
* CaptioningManager captioningManager =
- * (CaptioningManager) context.getSystemService(Context.CAPTIONING_SERVICE);
- *
@@ -211,6 +210,7 @@ import java.util.concurrent.TimeUnit;
* and want to make it available for use.
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"; diff --git a/core/java/android/view/textservice/TextServicesManager.java b/core/java/android/view/textservice/TextServicesManager.java index b4e6c5699007..d9bfade33539 100644 --- a/core/java/android/view/textservice/TextServicesManager.java +++ b/core/java/android/view/textservice/TextServicesManager.java @@ -16,6 +16,7 @@ package android.view.textservice; +import android.annotation.SystemService; import android.content.Context; import android.os.Bundle; import android.os.RemoteException; @@ -30,8 +31,7 @@ import java.util.Locale; /** * 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. @@ -61,6 +61,7 @@ import java.util.Locale; * * */ +@SystemService(Context.TEXT_SERVICES_MANAGER_SERVICE) public final class TextServicesManager { private static final String TAG = TextServicesManager.class.getSimpleName(); private static final boolean DBG = false; diff --git a/location/java/android/location/CountryDetector.java b/location/java/android/location/CountryDetector.java index ce3c56f73c01..ec6dfb713b10 100644 --- a/location/java/android/location/CountryDetector.java +++ b/location/java/android/location/CountryDetector.java @@ -18,6 +18,8 @@ package android.location; import java.util.HashMap; +import android.annotation.SystemService; +import android.content.Context; import android.os.Handler; import android.os.Looper; import android.os.RemoteException; @@ -40,13 +42,10 @@ import android.util.Log; * To be notified of the future country change, use the * {@link #addCountryListener} *
- *
- * 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 { /** diff --git a/location/java/android/location/LocationManager.java b/location/java/android/location/LocationManager.java index f9385c6d3b7f..4ab8543b7f6a 100644 --- a/location/java/android/location/LocationManager.java +++ b/location/java/android/location/LocationManager.java @@ -20,7 +20,9 @@ import com.android.internal.location.ProviderProperties; 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; @@ -47,11 +49,6 @@ import static android.Manifest.permission.ACCESS_FINE_LOCATION; * {@link Intent} when the device enters the proximity of a given * geographical location. * - *
You do not - * instantiate this class directly; instead, retrieve it through - * {@link android.content.Context#getSystemService - * Context.getSystemService(Context.LOCATION_SERVICE)}. - * *
Unless noted, all Location API methods require * the {@link android.Manifest.permission#ACCESS_COARSE_LOCATION} or * {@link android.Manifest.permission#ACCESS_FINE_LOCATION} permissions. @@ -60,8 +57,8 @@ import static android.Manifest.permission.ACCESS_FINE_LOCATION; * 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; @@ -1820,6 +1817,7 @@ public class LocationManager */ @Deprecated @SystemApi + @SuppressLint("Doclava125") public boolean addGpsMeasurementListener(GpsMeasurementsEvent.Listener listener) { return false; } @@ -1857,6 +1855,7 @@ public class LocationManager */ @Deprecated @SystemApi + @SuppressLint("Doclava125") public void removeGpsMeasurementListener(GpsMeasurementsEvent.Listener listener) { } @@ -1877,6 +1876,7 @@ public class LocationManager */ @Deprecated @SystemApi + @SuppressLint("Doclava125") public boolean addGpsNavigationMessageListener(GpsNavigationMessageEvent.Listener listener) { return false; } @@ -1891,6 +1891,7 @@ public class LocationManager */ @Deprecated @SystemApi + @SuppressLint("Doclava125") public void removeGpsNavigationMessageListener(GpsNavigationMessageEvent.Listener listener) { } diff --git a/media/java/android/media/AudioManager.java b/media/java/android/media/AudioManager.java index 0b5dff227d23..20deeb1634c8 100644 --- a/media/java/android/media/AudioManager.java +++ b/media/java/android/media/AudioManager.java @@ -19,9 +19,11 @@ package android.media; 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; @@ -58,10 +60,8 @@ import java.util.concurrent.ConcurrentHashMap; /** * AudioManager provides access to volume and ringer mode control. - *
- * Use Context.getSystemService(Context.AUDIO_SERVICE)
to get
- * an instance of this class.
*/
+@SystemService(Context.AUDIO_SERVICE)
public class AudioManager {
private Context mOriginalContext;
@@ -2827,6 +2827,7 @@ public class AudioManager {
* {@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");
@@ -2852,6 +2853,7 @@ public class AudioManager {
* @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");
diff --git a/media/java/android/media/MediaRouter.java b/media/java/android/media/MediaRouter.java
index 44494a644178..91dada7f1066 100644
--- a/media/java/android/media/MediaRouter.java
+++ b/media/java/android/media/MediaRouter.java
@@ -20,6 +20,7 @@ import android.Manifest;
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;
@@ -61,6 +62,7 @@ import java.util.concurrent.CopyOnWriteArrayList;
*
The media router API is not thread-safe; all interactions with it must be * done from the main thread of the process.
*/ +@SystemService(Context.MEDIA_ROUTER_SERVICE) public class MediaRouter { private static final String TAG = "MediaRouter"; private static final boolean DEBUG = Log.isLoggable(TAG, Log.DEBUG); diff --git a/media/java/android/media/midi/MidiManager.java b/media/java/android/media/midi/MidiManager.java index 07c8ae86adcf..a015732ddfdd 100644 --- a/media/java/android/media/midi/MidiManager.java +++ b/media/java/android/media/midi/MidiManager.java @@ -16,7 +16,9 @@ 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; @@ -28,13 +30,8 @@ import java.util.concurrent.ConcurrentHashMap; /** * This class is the public application interface to the MIDI service. - * - *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"; diff --git a/media/java/android/media/projection/MediaProjectionManager.java b/media/java/android/media/projection/MediaProjectionManager.java index f4a548bb5329..9f2c08e5c6ae 100644 --- a/media/java/android/media/projection/MediaProjectionManager.java +++ b/media/java/android/media/projection/MediaProjectionManager.java @@ -18,6 +18,7 @@ package android.media.projection; import android.annotation.NonNull; import android.annotation.Nullable; +import android.annotation.SystemService; import android.app.Activity; import android.content.Context; import android.content.Intent; @@ -33,14 +34,8 @@ import java.util.Map; /** * Manages the retrieval of certain types of {@link MediaProjection} tokens. - * - *
- * 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}. - *
*/ +@SystemService(Context.MEDIA_PROJECTION_SERVICE) public final class MediaProjectionManager { private static final String TAG = "MediaProjectionManager"; /** @hide */ diff --git a/media/java/android/media/session/MediaSessionManager.java b/media/java/android/media/session/MediaSessionManager.java index 83793aeb2466..e02a4dcba9e4 100644 --- a/media/java/android/media/session/MediaSessionManager.java +++ b/media/java/android/media/session/MediaSessionManager.java @@ -18,7 +18,9 @@ package android.media.session; 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; @@ -42,13 +44,11 @@ import java.util.List; * Provides support for interacting with {@link MediaSession media sessions} * that applications have published to express their ongoing media playback * state. - *
- * Use Context.getSystemService(Context.MEDIA_SESSION_SERVICE)
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";
@@ -357,6 +357,7 @@ public final class MediaSessionManager {
* @hide
*/
@SystemApi
+ @RequiresPermission(android.Manifest.permission.SET_VOLUME_KEY_LONG_PRESS_LISTENER)
public void setOnVolumeKeyLongPressListener(
OnVolumeKeyLongPressListener listener, @Nullable Handler handler) {
synchronized (mLock) {
@@ -392,6 +393,7 @@ public final class MediaSessionManager {
* @hide
*/
@SystemApi
+ @RequiresPermission(android.Manifest.permission.SET_MEDIA_KEY_LISTENER)
public void setOnMediaKeyListener(OnMediaKeyListener listener, @Nullable Handler handler) {
synchronized (mLock) {
try {
diff --git a/media/java/android/media/soundtrigger/SoundTriggerDetector.java b/media/java/android/media/soundtrigger/SoundTriggerDetector.java
index d5296ae42031..a48abff29555 100644
--- a/media/java/android/media/soundtrigger/SoundTriggerDetector.java
+++ b/media/java/android/media/soundtrigger/SoundTriggerDetector.java
@@ -20,6 +20,7 @@ import static android.hardware.soundtrigger.SoundTrigger.STATUS_OK;
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;
@@ -235,6 +236,7 @@ public final class SoundTriggerDetector {
* {@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()");
@@ -258,6 +260,7 @@ public final class SoundTriggerDetector {
/**
* Stops recognition for the associated model.
*/
+ @RequiresPermission(android.Manifest.permission.MANAGE_SOUND_TRIGGER)
public boolean stopRecognition() {
int status = STATUS_OK;
try {
diff --git a/media/java/android/media/soundtrigger/SoundTriggerManager.java b/media/java/android/media/soundtrigger/SoundTriggerManager.java
index fdd7fc2a8f19..7f8140adaed2 100644
--- a/media/java/android/media/soundtrigger/SoundTriggerManager.java
+++ b/media/java/android/media/soundtrigger/SoundTriggerManager.java
@@ -18,7 +18,9 @@ package android.media.soundtrigger;
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;
@@ -39,6 +41,7 @@ import java.util.UUID;
* @hide
*/
@SystemApi
+@SystemService(Context.SOUND_TRIGGER_SERVICE)
public final class SoundTriggerManager {
private static final boolean DBG = false;
private static final String TAG = "SoundTriggerManager";
@@ -65,6 +68,7 @@ public final class SoundTriggerManager {
/**
* Updates the given sound trigger model.
*/
+ @RequiresPermission(android.Manifest.permission.MANAGE_SOUND_TRIGGER)
public void updateModel(Model model) {
try {
mSoundTriggerService.updateSoundModel(model.getGenericSoundModel());
@@ -77,6 +81,7 @@ public final class SoundTriggerManager {
* 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(
@@ -89,6 +94,7 @@ public final class SoundTriggerManager {
/**
* 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));
@@ -110,6 +116,7 @@ public final class SoundTriggerManager {
* @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) {
diff --git a/media/java/android/media/tv/TvInputManager.java b/media/java/android/media/tv/TvInputManager.java
index 68ee02cab7a4..28fd338aabc7 100644
--- a/media/java/android/media/tv/TvInputManager.java
+++ b/media/java/android/media/tv/TvInputManager.java
@@ -21,6 +21,8 @@ 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.content.Intent;
import android.graphics.Rect;
import android.media.PlaybackParams;
@@ -57,9 +59,7 @@ import java.util.Map;
/**
* 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.
*
*
There are three primary parties involved in the TV input framework (TIF) architecture:
*
@@ -78,6 +78,7 @@ import java.util.Map;
* programs.
*
*/
+@SystemService(Context.TV_INPUT_SERVICE)
public final class TvInputManager {
private static final String TAG = "TvInputManager";
@@ -1516,6 +1517,7 @@ public final class TvInputManager {
* @hide
*/
@SystemApi
+ @RequiresPermission(android.Manifest.permission.CAPTURE_TV_INPUT)
public List
- * Users should obtain an instance of this class by calling
- * {@code mContext.getSystemService(Context.CARRIER_CONFIG_SERVICE);}
- *
- * You do not instantiate this class directly; instead, you retrieve
- * a reference to an instance through {@link #from}.
*
* 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;
diff --git a/telephony/java/android/telephony/TelephonyManager.java b/telephony/java/android/telephony/TelephonyManager.java
index b8e24f0aa4d1..e3555627a486 100644
--- a/telephony/java/android/telephony/TelephonyManager.java
+++ b/telephony/java/android/telephony/TelephonyManager.java
@@ -22,8 +22,10 @@ import android.annotation.IntDef;
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;
@@ -79,11 +81,6 @@ import java.util.regex.Pattern;
* types of subscriber information. Applications can also register
* a listener to receive notification of telephony state changes.
*
- * 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.
* Requires Permission:
- * {@link android.Manifest.permission#READ_PRIVILEGED_PHONE_STATE}
- *
* This method returns valid data on devices with {@link
* android.content.pm.PackageManager#FEATURE_TELEPHONY_CARRIERLOCK} enabled.
*
@@ -6402,6 +6420,7 @@ public class TelephonyManager {
* @hide
*/
@SystemApi
+ @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE)
public List
+ * 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.
+ *
* It deals with several categories of items:
*
* The class provides access to:
*
@@ -96,6 +93,7 @@ import java.util.regex.Pattern;
* 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";
@@ -2671,8 +2669,8 @@ public class TelephonyManager {
* be implemented instead.
*/
@SystemApi
+ @SuppressLint("Doclava125")
public void setVisualVoicemailEnabled(PhoneAccountHandle phoneAccountHandle, boolean enabled){
-
}
/**
@@ -4855,12 +4853,14 @@ public class TelephonyManager {
/** @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();
@@ -4876,12 +4876,14 @@ public class TelephonyManager {
/** @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();
@@ -4975,6 +4977,7 @@ public class TelephonyManager {
/** @hide */
@SystemApi
+ @RequiresPermission(android.Manifest.permission.CALL_PHONE)
public void call(String callingPackage, String number) {
try {
ITelephony telephony = getITelephony();
@@ -4987,6 +4990,7 @@ public class TelephonyManager {
/** @hide */
@SystemApi
+ @RequiresPermission(android.Manifest.permission.CALL_PHONE)
public boolean endCall() {
try {
ITelephony telephony = getITelephony();
@@ -5000,6 +5004,7 @@ public class TelephonyManager {
/** @hide */
@SystemApi
+ @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE)
public void answerRingingCall() {
try {
ITelephony telephony = getITelephony();
@@ -5074,6 +5079,7 @@ public class TelephonyManager {
/** @hide */
@SystemApi
+ @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE)
public boolean supplyPin(String pin) {
try {
ITelephony telephony = getITelephony();
@@ -5087,6 +5093,7 @@ public class TelephonyManager {
/** @hide */
@SystemApi
+ @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE)
public boolean supplyPuk(String puk, String pin) {
try {
ITelephony telephony = getITelephony();
@@ -5100,6 +5107,7 @@ public class TelephonyManager {
/** @hide */
@SystemApi
+ @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE)
public int[] supplyPinReportResult(String pin) {
try {
ITelephony telephony = getITelephony();
@@ -5113,6 +5121,7 @@ public class TelephonyManager {
/** @hide */
@SystemApi
+ @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE)
public int[] supplyPukReportResult(String puk, String pin) {
try {
ITelephony telephony = getITelephony();
@@ -5232,6 +5241,7 @@ public class TelephonyManager {
/** @hide */
@SystemApi
+ @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE)
public boolean handlePinMmi(String dialString) {
try {
ITelephony telephony = getITelephony();
@@ -5245,6 +5255,7 @@ public class TelephonyManager {
/** @hide */
@SystemApi
+ @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE)
public boolean handlePinMmiForSubscriber(int subId, String dialString) {
try {
ITelephony telephony = getITelephony();
@@ -5258,6 +5269,7 @@ public class TelephonyManager {
/** @hide */
@SystemApi
+ @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE)
public void toggleRadioOnOff() {
try {
ITelephony telephony = getITelephony();
@@ -5270,6 +5282,7 @@ public class TelephonyManager {
/** @hide */
@SystemApi
+ @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE)
public boolean setRadio(boolean turnOn) {
try {
ITelephony telephony = getITelephony();
@@ -5283,6 +5296,7 @@ public class TelephonyManager {
/** @hide */
@SystemApi
+ @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE)
public boolean setRadioPower(boolean turnOn) {
try {
ITelephony telephony = getITelephony();
@@ -5308,6 +5322,7 @@ public class TelephonyManager {
/** @hide */
@SystemApi
+ @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE)
public boolean enableDataConnectivity() {
try {
ITelephony telephony = getITelephony();
@@ -5321,6 +5336,7 @@ public class TelephonyManager {
/** @hide */
@SystemApi
+ @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE)
public boolean disableDataConnectivity() {
try {
ITelephony telephony = getITelephony();
@@ -5371,12 +5387,14 @@ public class TelephonyManager {
*
* @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);
@@ -5466,6 +5484,7 @@ public class TelephonyManager {
/** @hide */
@SystemApi
+ @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE)
public void enableVideoCalling(boolean enable) {
try {
ITelephony telephony = getITelephony();
@@ -6346,6 +6365,7 @@ public class TelephonyManager {
* @hide
*/
@SystemApi
+ @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE)
public List
- *
- * 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";
@@ -966,6 +972,7 @@ public class WifiManager {
/** @hide */
@SystemApi
+ @RequiresPermission(android.Manifest.permission.READ_WIFI_CREDENTIAL)
public List
@@ -120,6 +119,7 @@ import java.util.List;
* {@link DiscoverySession#createNetworkSpecifierPassphrase(PeerHandle, String)}.
*
*/
+@SystemService(Context.WIFI_AWARE_SERVICE)
public class WifiAwareManager {
private static final String TAG = "WifiAwareManager";
private static final boolean DBG = false;
diff --git a/wifi/java/android/net/wifi/p2p/WifiP2pManager.java b/wifi/java/android/net/wifi/p2p/WifiP2pManager.java
index c93ac7b5f8f1..95d0a79bb28b 100644
--- a/wifi/java/android/net/wifi/p2p/WifiP2pManager.java
+++ b/wifi/java/android/net/wifi/p2p/WifiP2pManager.java
@@ -17,6 +17,7 @@
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;
@@ -119,9 +120,6 @@ import java.util.Map;
* {@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}
@@ -129,6 +127,7 @@ import java.util.Map;
* {@see WifiP2pDeviceList}
* {@see android.net.wifi.WpsInfo}
*/
+@SystemService(Context.WIFI_P2P_SERVICE)
public class WifiP2pManager {
private static final String TAG = "WifiP2pManager";
/**
--
2.11.0