ComponentCallbacks
, ComponentCallbacks2
public abstract class PolicyManagerService extends Service
Modifier and Type | Class | Description |
---|---|---|
static interface |
PolicyManagerService.PrivacySettingListener |
Interface for receiving updates when privacy quick setting tiles are pressed
|
ComponentCallbacks2.TrimMemoryLevel
Context.BindServiceFlags, Context.CreatePackageOptions, Context.DatabaseMode, Context.FileMode, Context.PreferencesMode, Context.RegisterReceiverFlags, Context.ServiceName
Service.StartArgFlags, Service.StartResult, Service.StopForegroundFlags
Modifier and Type | Field | Description |
---|---|---|
static int |
FROM_ANDROID_REQ |
Flag to indicate that the request came from the Android system on behalf of an app, i.e.
|
static int |
FROM_PRIV_APP_REQ |
Flag to indicate that the request came from a privileged system app, and may lead to system instability if denied
|
static int |
FROM_SYS_APP_REQ |
Flag to indicate that the request came from a system app
|
TRIM_MEMORY_BACKGROUND, TRIM_MEMORY_COMPLETE, TRIM_MEMORY_MODERATE, TRIM_MEMORY_RUNNING_CRITICAL, TRIM_MEMORY_RUNNING_LOW, TRIM_MEMORY_RUNNING_MODERATE, TRIM_MEMORY_UI_HIDDEN
ACCESSIBILITY_SERVICE, ACCOUNT_SERVICE, ACTIVITY_SERVICE, ALARM_SERVICE, APP_OPS_SERVICE, APPWIDGET_SERVICE, AUDIO_SERVICE, AUTOFILL_MANAGER_SERVICE, BACKUP_SERVICE, BATTERY_SERVICE, BIND_ABOVE_CLIENT, BIND_ADJUST_BELOW_PERCEPTIBLE, BIND_ADJUST_WITH_ACTIVITY, BIND_ALLOW_INSTANT, BIND_ALLOW_OOM_MANAGEMENT, BIND_ALLOW_WHITELIST_MANAGEMENT, BIND_AUTO_CREATE, BIND_DEBUG_UNBIND, BIND_EXTERNAL_SERVICE, BIND_FOREGROUND_SERVICE, BIND_FOREGROUND_SERVICE_WHILE_AWAKE, BIND_IMPORTANT, BIND_IMPORTANT_BACKGROUND, BIND_NOT_FOREGROUND, BIND_NOT_VISIBLE, BIND_SHOWING_UI, BIND_TREAT_LIKE_ACTIVITY, BIND_VISIBLE, BIND_WAIVE_PRIORITY, BLUETOOTH_SERVICE, CAMERA_SERVICE, CAPTIONING_SERVICE, CARRIER_CONFIG_SERVICE, CLIPBOARD_SERVICE, COMPANION_DEVICE_SERVICE, CONNECTIVITY_SERVICE, CONSUMER_IR_SERVICE, CONTEXT_CREDENTIAL_PROTECTED_STORAGE, CONTEXT_DEVICE_PROTECTED_STORAGE, CONTEXT_IGNORE_SECURITY, CONTEXT_INCLUDE_CODE, CONTEXT_REGISTER_PACKAGE, CONTEXT_RESTRICTED, CONTEXTHUB_SERVICE, COUNTRY_DETECTOR, CROSS_PROFILE_APPS_SERVICE, DEVICE_IDENTIFIERS_SERVICE, DEVICE_IDLE_CONTROLLER, DEVICE_POLICY_SERVICE, DISPLAY_SERVICE, DOWNLOAD_SERVICE, DROPBOX_SERVICE, ETHERNET_SERVICE, EUICC_CARD_SERVICE, EUICC_SERVICE, FINGERPRINT_SERVICE, GATEKEEPER_SERVICE, HARDWARE_PROPERTIES_SERVICE, HDMI_CONTROL_SERVICE, INCIDENT_SERVICE, INPUT_METHOD_SERVICE, INPUT_SERVICE, IPSEC_SERVICE, JOB_SCHEDULER_SERVICE, KEYGUARD_SERVICE, LAUNCHER_APPS_SERVICE, LAYOUT_INFLATER_SERVICE, LOCATION_SERVICE, LOWPAN_SERVICE, MEDIA_PROJECTION_SERVICE, MEDIA_ROUTER_SERVICE, MEDIA_SESSION_SERVICE, MIDI_SERVICE, MODE_APPEND, MODE_ENABLE_WRITE_AHEAD_LOGGING, MODE_MULTI_PROCESS, MODE_NO_LOCALIZED_COLLATORS, MODE_PRIVATE, MODE_WORLD_READABLE, MODE_WORLD_WRITEABLE, NETWORK_POLICY_SERVICE, NETWORK_SCORE_SERVICE, NETWORK_STATS_SERVICE, NETWORK_WATCHLIST_SERVICE, NETWORKMANAGEMENT_SERVICE, NFC_SERVICE, NOTIFICATION_SERVICE, NSD_SERVICE, OEM_LOCK_SERVICE, OVERLAY_SERVICE, PERSISTENT_DATA_BLOCK_SERVICE, POWER_SERVICE, PRINT_SERVICE, RADIO_SERVICE, RECEIVER_VISIBLE_TO_INSTANT_APPS, RECOVERY_SERVICE, RESTRICTIONS_SERVICE, SEARCH_SERVICE, SECURE_ELEMENT_SERVICE, SENSOR_SERVICE, SERIAL_SERVICE, SHORTCUT_SERVICE, SIP_SERVICE, SLICE_SERVICE, SOUND_TRIGGER_SERVICE, STATS_COMPANION_SERVICE, STATS_MANAGER, STATUS_BAR_SERVICE, STORAGE_SERVICE, STORAGE_STATS_SERVICE, SYSTEM_HEALTH_SERVICE, SYSTEM_UPDATE_SERVICE, TELECOM_SERVICE, TELEPHONY_SERVICE, TELEPHONY_SUBSCRIPTION_SERVICE, TEXT_CLASSIFICATION_SERVICE, TEXT_SERVICES_MANAGER_SERVICE, TIME_ZONE_RULES_MANAGER_SERVICE, TRUST_SERVICE, TV_INPUT_SERVICE, UI_MODE_SERVICE, UPDATE_LOCK_SERVICE, USAGE_STATS_SERVICE, USB_SERVICE, USER_SERVICE, VIBRATOR_SERVICE, VOICE_INTERACTION_MANAGER_SERVICE, VR_SERVICE, WALLPAPER_SERVICE, WIFI_AWARE_SERVICE, WIFI_P2P_SERVICE, WIFI_RTT_RANGING_SERVICE, WIFI_RTT_SERVICE, WIFI_SCANNING_SERVICE, WIFI_SERVICE, WINDOW_SERVICE
START_CONTINUATION_MASK, START_FLAG_REDELIVERY, START_FLAG_RETRY, START_NOT_STICKY, START_REDELIVER_INTENT, START_STICKY, START_STICKY_COMPATIBILITY, START_TASK_REMOVED_COMPLETE, STOP_FOREGROUND_DETACH, STOP_FOREGROUND_REMOVE
Constructor | Description |
---|---|
PolicyManagerService() |
Modifier and Type | Method | Description |
---|---|---|
protected void |
addPrivacyQuickSetting(String id,
String text,
Drawable enabledIcon,
Drawable disabledIcon,
PolicyManagerService.PrivacySettingListener callback) |
Add a new privacy quick setting tile.
|
String |
getOffDevicePolicy(String packageName) |
Get the off device policy for a package
|
abstract boolean |
onAppInstall(String packageName,
String odp) |
Called when an app is installed and its declared permissions and purposes are being parsed
|
IBinder |
onBind(Intent intent) |
|
void |
onCreate() |
|
abstract void |
onDangerousPermissionRequest(String packageName,
String permission,
String purpose,
List<StackTraceElement[]> stackTraceElements,
int flags,
ComponentName callingComponent,
ComponentName topActivity,
ResultReceiver recv) |
Called whenever a new dangerous permission request occurs.
|
abstract void |
onPrivateDataRequest(String packageName,
String permission,
String purpose,
String pal,
String description,
ResultReceiver recv) |
Called whenever a new Private Data Request is received.
|
protected void |
removePrivacyQuickSetting(String id) |
Remove a privacy quick setting.
|
protected void |
sendPrivacyNotification(String packageName,
String title,
String body) |
Send a privacy alert notification to a package.
|
protected void |
setPrivacyQuickSettingEnabled(String id,
boolean enabled) |
Set the state of an existing privacy quick setting tile.
|
assertRuntimeOverlayThemable, getColor, getColorStateList, getDrawable, getSharedPrefsFile, getString, getString, getSystemService, getText, getUser, obtainStyledAttributes, obtainStyledAttributes, obtainStyledAttributes, obtainStyledAttributes, registerComponentCallbacks, unregisterComponentCallbacks
attachBaseContext, bindService, bindServiceAsUser, bindServiceAsUser, canLoadUnsafeResources, canStartActivityForResult, checkCallingOrSelfPermission, checkCallingOrSelfUriPermission, checkCallingPermission, checkCallingUriPermission, checkPermission, checkPermission, checkSelfPermission, checkUriPermission, checkUriPermission, checkUriPermission, clearWallpaper, createApplicationContext, createConfigurationContext, createContextForSplit, createCredentialProtectedStorageContext, createDeviceProtectedStorageContext, createDisplayContext, createPackageContext, createPackageContextAsUser, databaseList, deleteDatabase, deleteFile, deleteSharedPreferences, enforceCallingOrSelfPermission, enforceCallingOrSelfUriPermission, enforceCallingPermission, enforceCallingUriPermission, enforcePermission, enforceUriPermission, enforceUriPermission, fileList, getActivityToken, getApplicationContext, getApplicationInfo, getAssets, getAutofillClient, getBaseContext, getBasePackageName, getCacheDir, getClassLoader, getCodeCacheDir, getContentResolver, getDatabasePath, getDataDir, getDir, getDisplay, getDisplayAdjustments, getExternalCacheDir, getExternalCacheDirs, getExternalFilesDir, getExternalFilesDirs, getExternalMediaDirs, getFilesDir, getFileStreamPath, getIApplicationThread, getMainExecutor, getMainLooper, getMainThreadHandler, getNextAutofillId, getNoBackupFilesDir, getObbDir, getObbDirs, getOpPackageName, getPackageCodePath, getPackageManager, getPackageName, getPackageResourcePath, getPreloadsFileCache, getResources, getServiceDispatcher, getSharedPreferences, getSharedPreferences, getSharedPreferencesPath, getSystemService, getSystemServiceName, getTheme, getThemeResId, getUserId, getWallpaper, getWallpaperDesiredMinimumHeight, getWallpaperDesiredMinimumWidth, grantUriPermission, isAutofillCompatibilityEnabled, isCredentialProtectedStorage, isDeviceProtectedStorage, isRestricted, moveDatabaseFrom, moveSharedPreferencesFrom, openFileInput, openFileOutput, openOrCreateDatabase, openOrCreateDatabase, peekWallpaper, registerReceiver, registerReceiver, registerReceiver, registerReceiver, registerReceiverAsUser, reloadSharedPreferences, removeStickyBroadcast, removeStickyBroadcastAsUser, revokeUriPermission, revokeUriPermission, sendBroadcast, sendBroadcast, sendBroadcast, sendBroadcast, sendBroadcastAsUser, sendBroadcastAsUser, sendBroadcastAsUser, sendBroadcastAsUser, sendBroadcastAsUserMultiplePermissions, sendBroadcastMultiplePermissions, sendOrderedBroadcast, sendOrderedBroadcast, sendOrderedBroadcast, sendOrderedBroadcast, sendOrderedBroadcastAsUser, sendOrderedBroadcastAsUser, sendOrderedBroadcastAsUser, sendStickyBroadcast, sendStickyBroadcastAsUser, sendStickyBroadcastAsUser, sendStickyOrderedBroadcast, sendStickyOrderedBroadcastAsUser, setAutofillClient, setAutofillCompatibilityEnabled, setTheme, setWallpaper, setWallpaper, startActivities, startActivities, startActivitiesAsUser, startActivity, startActivity, startActivityAsUser, startActivityAsUser, startActivityForResult, startForegroundService, startForegroundServiceAsUser, startInstrumentation, startIntentSender, startIntentSender, startService, startServiceAsUser, stopService, stopServiceAsUser, unbindService, unregisterReceiver, updateDisplay
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
attach, detachAndCleanUp, dump, getApplication, onConfigurationChanged, onDestroy, onLowMemory, onRebind, onStart, onStartCommand, onTaskRemoved, onTrimMemory, onUnbind, setForeground, startForeground, stopForeground, stopForeground, stopSelf, stopSelf, stopSelfResult
public static final int FROM_SYS_APP_REQ
public static final int FROM_PRIV_APP_REQ
public static final int FROM_ANDROID_REQ
public String getOffDevicePolicy(String packageName)
packageName
- package for which to get the policyprotected final void addPrivacyQuickSetting(String id, String text, Drawable enabledIcon, Drawable disabledIcon, PolicyManagerService.PrivacySettingListener callback)
id
- A unique string identifier for the new setting.text
- Text to be displayed with this settingenabledIcon
- Icon to display when the setting is enableddisabledIcon
- Icon to display when the setting is disabled.
If null, the enabled Icon will be usedcallback
- A PrivacySettingListener used to detect when the setting is pressed
protected final void setPrivacyQuickSettingEnabled(String id, boolean enabled)
id
- Id of the setting to changeenabled
- Sets the setting to enabled or disabledprotected final void removePrivacyQuickSetting(String id)
id
- Id of the setting to removeprotected final void sendPrivacyNotification(String packageName, String title, String body)
packageName
- Package name of the app to send the notification fortitle
- Title text of the notificationbody
- Body text of the notificationpublic abstract boolean onAppInstall(String packageName, String odp)
packageName
- The package name of the app being installedodp
- The string representation of the entire Off Device Policy, a.k.a. App policypublic abstract void onPrivateDataRequest(String packageName, String permission, String purpose, String pal, String description, ResultReceiver recv)
packageName
- The name of the package that made the private data requestpermission
- The name of the permissionpurpose
- The purpose of this private data requestdescription
- A description of the transformrecv
- A RequestReceiver object that should be utilized to return the permission decision along with any associated policy for the request.
The result of the permission request should be set via putting the boolean allow/deny into the Bundle with key 'allowPerm'. The policy
should be returned to the caller by setting the String to the policy for tag 'ODP'. See code snippet below as an indication for the expected
return parameters.
public void onPrivateDataRequest(String packageName, String permission, String purpose, String description, ResultReceiver recv) {
...
Bundle b = new Bundle();
b.putBoolean("allowPerm", true);
recv.send(0, b);
}public abstract void onDangerousPermissionRequest(String packageName, String permission, String purpose, List<StackTraceElement[]> stackTraceElements, int flags, ComponentName callingComponent, ComponentName topActivity, ResultReceiver recv)
packageName
- The name of the package that made the dangerous requestpermission
- The name of the permissionpurpose
- The purpose of this permission requeststackTraceElements
- A stack trace of the permission callflags
- A bitmask of flags indicating the origin of the permission requestcallingComponent
- The calling component from the Application making the request. If it can not be determined it will be nulltopActivity
- The top activity that is displayed on the device.recv
- A RequestReceiver object that should be utilized to return the permission decision along with any associated policy for the request.
The result of the permission request should be set via putting the boolean allow/deny into the Bundle with key 'allowPerm'. The policy
should be returned to the caller by setting the String to the policy for tag 'ODP'. See code snippet below as an indication for the expected
return parameters.
public void onDangerousPermissionRequest(String packageName, String permission, String purpose, List<StackTraceElement[]>{ stackTrace, int flags, ResultReceiver recv) {
...
Bundle b = new Bundle();
b.putBoolean("allowPerm", true);
b.putString("ODP", "This is the policy...");
recv.send(0, b);
}