Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
P
platform_frameworks_base-old
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Farzin Kazemzadeh
platform_frameworks_base-old
Commits
2008f5c9
Commit
2008f5c9
authored
4 years ago
by
Nate Myren
Committed by
Android (Google) Code Review
4 years ago
Browse files
Options
Downloads
Plain Diff
Merge "Add wifi call special case, fix phone, predictor, filter system" into sc-dev
parents
a7e151f0
f7840682
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
core/java/android/permission/PermissionUsageHelper.java
+53
-6
53 additions, 6 deletions
core/java/android/permission/PermissionUsageHelper.java
with
53 additions
and
6 deletions
core/java/android/permission/PermissionUsageHelper.java
+
53
−
6
View file @
2008f5c9
...
...
@@ -28,7 +28,10 @@ import static android.app.AppOpsManager.OPSTR_RECORD_AUDIO;
import
static
android
.
app
.
AppOpsManager
.
OP_FLAGS_ALL_TRUSTED
;
import
static
android
.
app
.
AppOpsManager
.
opToPermission
;
import
static
android
.
content
.
pm
.
PackageManager
.
FLAG_PERMISSION_USER_SENSITIVE_WHEN_GRANTED
;
import
static
android
.
media
.
AudioSystem
.
MODE_IN_COMMUNICATION
;
import
static
android
.
telephony
.
TelephonyManager
.
CARRIER_PRIVILEGE_STATUS_HAS_ACCESS
;
import
android.Manifest
;
import
android.annotation.NonNull
;
import
android.app.AppOpsManager
;
import
android.content.ComponentName
;
...
...
@@ -41,12 +44,14 @@ import android.content.pm.PackageManager;
import
android.content.pm.ResolveInfo
;
import
android.icu.text.ListFormatter
;
import
android.location.LocationManager
;
import
android.media.AudioManager
;
import
android.os.Process
;
import
android.os.UserHandle
;
import
android.provider.DeviceConfig
;
import
android.provider.Settings
;
import
android.speech.RecognitionService
;
import
android.speech.RecognizerIntent
;
import
android.telephony.TelephonyManager
;
import
android.util.ArrayMap
;
import
android.util.ArraySet
;
import
android.view.inputmethod.InputMethodInfo
;
...
...
@@ -75,6 +80,9 @@ public class PermissionUsageHelper {
private
static
final
String
PROPERTY_LOCATION_INDICATORS_ENABLED
=
"location_indicators_enabled"
;
/** Whether to show the Permissions Hub. */
private
static
final
String
PROPERTY_PERMISSIONS_HUB_2_ENABLED
=
"permissions_hub_2_enabled"
;
/** How long after an access to show it as "recent" */
private
static
final
String
RECENT_ACCESS_TIME_MS
=
"recent_acccess_time_ms"
;
...
...
@@ -84,17 +92,25 @@ public class PermissionUsageHelper {
/** The name of the expected voice IME subtype */
private
static
final
String
VOICE_IME_SUBTYPE
=
"voice"
;
private
static
final
String
SYSTEM_PKG
=
"android"
;
private
static
final
long
DEFAULT_RUNNING_TIME_MS
=
5000L
;
private
static
final
long
DEFAULT_RECENT_TIME_MS
=
30000L
;
private
static
boolean
shouldShowPermissionsHub
()
{
return
DeviceConfig
.
getBoolean
(
DeviceConfig
.
NAMESPACE_PRIVACY
,
PROPERTY_PERMISSIONS_HUB_2_ENABLED
,
false
);
}
private
static
boolean
shouldShowIndicators
()
{
return
DeviceConfig
.
getBoolean
(
DeviceConfig
.
NAMESPACE_PRIVACY
,
PROPERTY_CAMERA_MIC_ICONS_ENABLED
,
true
);
PROPERTY_CAMERA_MIC_ICONS_ENABLED
,
true
)
||
shouldShowPermissionsHub
()
;
}
private
static
boolean
shouldShowLocationIndicator
()
{
return
DeviceConfig
.
getBoolean
(
DeviceConfig
.
NAMESPACE_PRIVACY
,
PROPERTY_LOCATION_INDICATORS_ENABLED
,
false
);
PROPERTY_LOCATION_INDICATORS_ENABLED
,
false
)
||
shouldShowPermissionsHub
();
}
private
static
long
getRecentThreshold
(
Long
now
)
{
...
...
@@ -113,7 +129,7 @@ public class PermissionUsageHelper {
);
private
static
final
List
<
String
>
MIC_OPS
=
List
.
of
(
OPSTR_PHONE_CALL_
CAMERA
,
OPSTR_PHONE_CALL_
MICROPHONE
,
OPSTR_RECORD_AUDIO
);
...
...
@@ -163,6 +179,13 @@ public class PermissionUsageHelper {
return
mUserContexts
.
get
(
user
);
}
// TODO ntmyren: Replace this with better check if this moves beyond teamfood
private
boolean
isAppPredictor
(
String
packageName
,
UserHandle
user
)
{
return
shouldShowPermissionsHub
()
&&
getUserContext
(
user
).
getPackageManager
()
.
checkPermission
(
Manifest
.
permission
.
MANAGE_APP_PREDICTIONS
,
packageName
)
==
PackageManager
.
PERMISSION_GRANTED
;
}
/**
* @see PermissionManager.getIndicatorAppOpUsageData
*/
...
...
@@ -186,7 +209,28 @@ public class PermissionUsageHelper {
Map
<
PackageAttribution
,
CharSequence
>
packagesWithAttributionLabels
=
getTrustedAttributions
(
rawUsages
.
get
(
MICROPHONE
),
proxyChains
);
List
<
String
>
usedPermGroups
=
new
ArrayList
<>(
rawUsages
.
keySet
());
ArrayList
<
String
>
usedPermGroups
=
new
ArrayList
<>(
rawUsages
.
keySet
());
// If we have a phone call, and a carrier privileged app using microphone, hide the
// phone call.
AudioManager
audioManager
=
mContext
.
getSystemService
(
AudioManager
.
class
);
boolean
hasPhoneCall
=
usedPermGroups
.
contains
(
OPSTR_PHONE_CALL_CAMERA
)
||
usedPermGroups
.
contains
(
OPSTR_PHONE_CALL_MICROPHONE
);
if
(
hasPhoneCall
&&
usedPermGroups
.
contains
(
MICROPHONE
)
&&
audioManager
.
getMode
()
==
MODE_IN_COMMUNICATION
)
{
TelephonyManager
telephonyManager
=
mContext
.
getSystemService
(
TelephonyManager
.
class
);
List
<
OpUsage
>
permUsages
=
rawUsages
.
get
(
MICROPHONE
);
for
(
int
usageNum
=
0
;
usageNum
<
permUsages
.
size
();
usageNum
++)
{
if
(
telephonyManager
.
checkCarrierPrivilegesForPackage
(
permUsages
.
get
(
usageNum
).
packageName
)
==
CARRIER_PRIVILEGE_STATUS_HAS_ACCESS
)
{
usedPermGroups
.
remove
(
OPSTR_PHONE_CALL_CAMERA
);
usedPermGroups
.
remove
(
OPSTR_PHONE_CALL_MICROPHONE
);
}
}
}
for
(
int
permGroupNum
=
0
;
permGroupNum
<
usedPermGroups
.
size
();
permGroupNum
++)
{
boolean
isPhone
=
false
;
String
permGroup
=
usedPermGroups
.
get
(
permGroupNum
);
...
...
@@ -269,8 +313,11 @@ public class PermissionUsageHelper {
if
(
lastAccessTime
<
recentThreshold
&&
!
attrOpEntry
.
isRunning
())
{
continue
;
}
if
(!
isUserSensitive
(
packageName
,
user
,
op
)
&&
!
isLocationProvider
(
packageName
,
user
))
{
if
(
packageName
.
equals
(
SYSTEM_PKG
)
||
(!
isUserSensitive
(
packageName
,
user
,
op
)
&&
!
isLocationProvider
(
packageName
,
user
)
&&
!
isAppPredictor
(
packageName
,
user
)))
{
continue
;
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment