Merge "Add Permission Indicator methods/classes to Test Api" into sc-dev am: 4cbdb452de
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/13956404 Change-Id: I7cf9303740e1f05b6378e9fa8b113aee64a2bd45
This commit is contained in:
@@ -233,6 +233,8 @@ package android.app {
|
||||
field public static final String KEY_FG_SERVICE_STATE_SETTLE_TIME = "fg_service_state_settle_time";
|
||||
field public static final String KEY_TOP_STATE_SETTLE_TIME = "top_state_settle_time";
|
||||
field public static final String OPSTR_MANAGE_ONGOING_CALLS = "android:manage_ongoing_calls";
|
||||
field public static final String OPSTR_PHONE_CALL_CAMERA = "android:phone_call_camera";
|
||||
field public static final String OPSTR_PHONE_CALL_MICROPHONE = "android:phone_call_microphone";
|
||||
field public static final String OPSTR_USE_ICC_AUTH_WITH_DEVICE_IDENTIFIER = "android:use_icc_auth_with_device_identifier";
|
||||
field public static final int OP_COARSE_LOCATION = 0; // 0x0
|
||||
field public static final int OP_RECORD_AUDIO = 27; // 0x1b
|
||||
@@ -1939,6 +1941,17 @@ package android.os.vibrator {
|
||||
|
||||
package android.permission {
|
||||
|
||||
public final class PermGroupUsage {
|
||||
ctor public PermGroupUsage(@NonNull String, int, @NonNull String, long, boolean, boolean, @Nullable CharSequence);
|
||||
method @Nullable public CharSequence getAttribution();
|
||||
method public long getLastAccess();
|
||||
method @NonNull public String getPackageName();
|
||||
method @NonNull public String getPermGroupName();
|
||||
method public int getUid();
|
||||
method public boolean isActive();
|
||||
method public boolean isPhoneCall();
|
||||
}
|
||||
|
||||
public final class PermissionControllerManager {
|
||||
method @RequiresPermission(android.Manifest.permission.GET_RUNTIME_PERMISSIONS) public void countPermissionApps(@NonNull java.util.List<java.lang.String>, int, @NonNull android.permission.PermissionControllerManager.OnCountPermissionAppsResultCallback, @Nullable android.os.Handler);
|
||||
method @RequiresPermission(android.Manifest.permission.GET_RUNTIME_PERMISSIONS) public void getAppPermissions(@NonNull String, @NonNull android.permission.PermissionControllerManager.OnGetAppPermissionResultCallback, @Nullable android.os.Handler);
|
||||
@@ -1953,6 +1966,10 @@ package android.permission {
|
||||
method public void onGetAppPermissions(@NonNull java.util.List<android.permission.RuntimePermissionPresentationInfo>);
|
||||
}
|
||||
|
||||
public final class PermissionManager {
|
||||
method @NonNull @RequiresPermission(android.Manifest.permission.GET_APP_OPS_STATS) public java.util.List<android.permission.PermGroupUsage> getIndicatorAppOpUsageData();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
package android.print {
|
||||
|
||||
@@ -1561,12 +1561,14 @@ public class AppOpsManager {
|
||||
*
|
||||
* @hide
|
||||
*/
|
||||
@TestApi
|
||||
public static final String OPSTR_PHONE_CALL_MICROPHONE = "android:phone_call_microphone";
|
||||
/**
|
||||
* Phone call is using camera
|
||||
*
|
||||
* @hide
|
||||
*/
|
||||
@TestApi
|
||||
public static final String OPSTR_PHONE_CALL_CAMERA = "android:phone_call_camera";
|
||||
|
||||
/**
|
||||
|
||||
@@ -18,6 +18,7 @@ package android.permission;
|
||||
|
||||
import android.annotation.NonNull;
|
||||
import android.annotation.Nullable;
|
||||
import android.annotation.TestApi;
|
||||
|
||||
/**
|
||||
* Represents the usage of a permission group by an app. Supports package name, user, permission
|
||||
@@ -26,6 +27,7 @@ import android.annotation.Nullable;
|
||||
*
|
||||
* @hide
|
||||
*/
|
||||
@TestApi
|
||||
public final class PermGroupUsage {
|
||||
|
||||
private final String mPackageName;
|
||||
@@ -36,7 +38,19 @@ public final class PermGroupUsage {
|
||||
private final boolean mIsPhoneCall;
|
||||
private final CharSequence mAttribution;
|
||||
|
||||
PermGroupUsage(@NonNull String packageName, int uid,
|
||||
/**
|
||||
*
|
||||
* @param packageName The package name of the using app
|
||||
* @param uid The uid of the using app
|
||||
* @param permGroupName The name of the permission group being used
|
||||
* @param lastAccess The time of last access
|
||||
* @param isActive Whether this is active
|
||||
* @param isPhoneCall Whether this is a usage by the phone
|
||||
* @param attribution An optional string attribution to show
|
||||
* @hide
|
||||
*/
|
||||
@TestApi
|
||||
public PermGroupUsage(@NonNull String packageName, int uid,
|
||||
@NonNull String permGroupName, long lastAccess, boolean isActive, boolean isPhoneCall,
|
||||
@Nullable CharSequence attribution) {
|
||||
this.mPackageName = packageName;
|
||||
@@ -48,30 +62,58 @@ public final class PermGroupUsage {
|
||||
this.mAttribution = attribution;
|
||||
}
|
||||
|
||||
/**
|
||||
* @hide
|
||||
*/
|
||||
@TestApi
|
||||
public @NonNull String getPackageName() {
|
||||
return mPackageName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @hide
|
||||
*/
|
||||
@TestApi
|
||||
public int getUid() {
|
||||
return mUid;
|
||||
}
|
||||
|
||||
/**
|
||||
* @hide
|
||||
*/
|
||||
@TestApi
|
||||
public @NonNull String getPermGroupName() {
|
||||
return mPermGroupName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @hide
|
||||
*/
|
||||
@TestApi
|
||||
public long getLastAccess() {
|
||||
return mLastAccess;
|
||||
}
|
||||
|
||||
/**
|
||||
* @hide
|
||||
*/
|
||||
@TestApi
|
||||
public boolean isActive() {
|
||||
return mIsActive;
|
||||
}
|
||||
|
||||
/**
|
||||
* @hide
|
||||
*/
|
||||
@TestApi
|
||||
public boolean isPhoneCall() {
|
||||
return mIsPhoneCall;
|
||||
}
|
||||
|
||||
/**
|
||||
* @hide
|
||||
*/
|
||||
@TestApi
|
||||
public @Nullable CharSequence getAttribution() {
|
||||
return mAttribution;
|
||||
}
|
||||
@@ -80,6 +122,7 @@ public final class PermGroupUsage {
|
||||
public String toString() {
|
||||
return getClass().getSimpleName() + "@" + Integer.toHexString(System.identityHashCode(this))
|
||||
+ " packageName: " + mPackageName + ", UID: " + mUid + ", permGroup: "
|
||||
+ mPermGroupName + ", isActive: " + mIsActive + ", attribution: " + mAttribution;
|
||||
+ mPermGroupName + ", lastAccess: " + mLastAccess + ", isActive: " + mIsActive
|
||||
+ ", attribution: " + mAttribution;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,6 +26,7 @@ import android.annotation.Nullable;
|
||||
import android.annotation.RequiresPermission;
|
||||
import android.annotation.SystemApi;
|
||||
import android.annotation.SystemService;
|
||||
import android.annotation.TestApi;
|
||||
import android.annotation.UserIdInt;
|
||||
import android.app.ActivityManager;
|
||||
import android.app.ActivityThread;
|
||||
@@ -851,6 +852,7 @@ public final class PermissionManager {
|
||||
*
|
||||
* @hide
|
||||
*/
|
||||
@TestApi
|
||||
@NonNull
|
||||
@RequiresPermission(Manifest.permission.GET_APP_OPS_STATS)
|
||||
public List<PermGroupUsage> getIndicatorAppOpUsageData() {
|
||||
|
||||
@@ -71,13 +71,10 @@ public class PermissionUsageHelper {
|
||||
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";
|
||||
private static final String RECENT_ACCESS_TIME_MS = "recent_access_time_ms";
|
||||
|
||||
/** How long after an access to show it as "running" */
|
||||
private static final String RUNNING_ACCESS_TIME_MS = "running_acccess_time_ms";
|
||||
|
||||
/** The name of the expected voice IME subtype */
|
||||
private static final String VOICE_IME_SUBTYPE = "voice";
|
||||
private static final String RUNNING_ACCESS_TIME_MS = "running_access_time_ms";
|
||||
|
||||
private static final String SYSTEM_PKG = "android";
|
||||
|
||||
@@ -279,6 +276,10 @@ public class PermissionUsageHelper {
|
||||
opEntry.getAttributedOpEntries().get(attributionTag);
|
||||
|
||||
long lastAccessTime = attrOpEntry.getLastAccessTime(opFlags);
|
||||
if (attrOpEntry.isRunning()) {
|
||||
lastAccessTime = now;
|
||||
}
|
||||
|
||||
if (lastAccessTime < recentThreshold && !attrOpEntry.isRunning()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user