summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--res/layout/ongoing_usage_dialog_content.xml8
-rw-r--r--res/values/overlayable.xml2
-rw-r--r--res/values/strings.xml11
-rw-r--r--res/values/styles.xml12
-rw-r--r--src/com/android/permissioncontroller/permission/ui/handheld/ReviewOngoingUsageFragment.java69
5 files changed, 82 insertions, 20 deletions
diff --git a/res/layout/ongoing_usage_dialog_content.xml b/res/layout/ongoing_usage_dialog_content.xml
index 100c9d7a0..f9a0f07f0 100644
--- a/res/layout/ongoing_usage_dialog_content.xml
+++ b/res/layout/ongoing_usage_dialog_content.xml
@@ -44,6 +44,14 @@
android:id="@+id/other_use_content"
style="@style/PermissionUsageDialogOtherUseContent"/>
+ <View
+ android:id="@+id/other_use_inside_spacer"
+ style="@style/PermissionUsageDialogOtherUseInsideSpacer"/>
+
+ <TextView
+ android:id="@+id/system_use_content"
+ style="@style/PermissionUsageDialogSystemUseContent"/>
+
</LinearLayout>
</ScrollView>
diff --git a/res/values/overlayable.xml b/res/values/overlayable.xml
index 0a0f9761f..aa683a43e 100644
--- a/res/values/overlayable.xml
+++ b/res/values/overlayable.xml
@@ -155,6 +155,8 @@
<item type="style" name="PermissionUsageDialogItemIconsContainer" />
<item type="style" name="PermissionUsageDialogOtherUseHeader" />
<item type="style" name="PermissionUsageDialogOtherUseContent" />
+ <item type="style" name="PermissionUsageDialogOtherUseInsideSpacer" />
+ <item type="style" name="PermissionUsageDialogSystemUseContent" />
<!-- END ONGOING USAGE DIALOG -->
<!-- START REQUEST ROLE DIALOG TITLE -->
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 653e2144a..e7804ffb2 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -887,9 +887,16 @@
<!-- Message telling the user that a phone call is currently using the microphone [CHAR LIMIT=none] -->
<string name="phone_call_uses_microphone">Microphone is used in &lt;b>phone call&lt;/b></string>
<!-- Message telling the user that a phone call is currently using the microphone and the camera [CHAR LIMIT=none] -->
- <string name="phone_call_uses_microphone_and_camera">Camera and Microphone are used in &lt;b>phone call&lt;/b></string>
+ <string name="phone_call_uses_microphone_and_camera">Camera and Microphone are used in &lt;b>video call&lt;/b></string>
<!-- Message telling the user that a phone call is currently using the camera [CHAR LIMIT=none] -->
- <string name="phone_call_uses_camera">Camera is used in &lt;b>phone call&lt;/b></string>
+ <string name="phone_call_uses_camera">Camera is used in &lt;b>video call&lt;/b></string>
+
+ <!-- Message telling the user that a system service is currently using the microphone [CHAR LIMIT=none] -->
+ <string name="system_uses_microphone">Microphone is accessed using system service</string>
+ <!-- Message telling the user that a system service is currently using the microphone and the camera [CHAR LIMIT=none] -->
+ <string name="system_uses_microphone_and_camera">Camera and Microphone are accessed using system service</string>
+ <!-- Message telling the user that a system service is currently using the camera [CHAR LIMIT=none] -->
+ <string name="system_uses_camera">Camera is accessed using system service</string>
<!-- Line above a list of other apps and system service that are currently microphone or camera [CHAR LIMIT=60] -->
<string name="other_use">Other use:</string>
diff --git a/res/values/styles.xml b/res/values/styles.xml
index b269a4c00..c1c8e2d2f 100644
--- a/res/values/styles.xml
+++ b/res/values/styles.xml
@@ -677,6 +677,18 @@
<item name="android:layout_marginStart">16dp</item>
</style>
+ <style name="PermissionUsageDialogOtherUseInsideSpacer">
+ <item name="android:layout_width">0dp</item>
+ <item name="android:layout_height">16dp</item>
+ </style>
+
+ <style name="PermissionUsageDialogSystemUseContent">
+ <item name="android:layout_width">wrap_content</item>
+ <item name="android:layout_height">wrap_content</item>
+ <item name="android:textAppearance">?android:textAppearanceListItemSecondary</item>
+ <item name="android:layout_marginStart">16dp</item>
+ </style>
+
<!-- END ONGOING USAGE DIALOG -->
<!-- START REQUEST ROLE DIALOG TITLE -->
diff --git a/src/com/android/permissioncontroller/permission/ui/handheld/ReviewOngoingUsageFragment.java b/src/com/android/permissioncontroller/permission/ui/handheld/ReviewOngoingUsageFragment.java
index 1ffb9238e..41b8a21b8 100644
--- a/src/com/android/permissioncontroller/permission/ui/handheld/ReviewOngoingUsageFragment.java
+++ b/src/com/android/permissioncontroller/permission/ui/handheld/ReviewOngoingUsageFragment.java
@@ -28,10 +28,12 @@ import static com.android.permissioncontroller.permission.debug.UtilsKt.shouldSh
import android.app.AlertDialog;
import android.content.Context;
import android.content.Intent;
+import android.location.LocationManager;
import android.os.Bundle;
import android.os.UserHandle;
import android.text.Html;
import android.util.ArrayMap;
+import android.util.ArraySet;
import android.util.Pair;
import android.view.LayoutInflater;
import android.view.View;
@@ -77,6 +79,7 @@ public class ReviewOngoingUsageFragment extends PreferenceFragmentCompat {
private @Nullable AlertDialog mDialog;
private OpUsageLiveData mOpUsageLiveData;
private @Nullable Map<String, List<OpAccess>> mOpUsage;
+ private ArraySet<String> mSystemUsage = new ArraySet<>(0);
private long mStartTime;
/**
@@ -157,11 +160,13 @@ public class ReviewOngoingUsageFragment extends PreferenceFragmentCompat {
}
}
- if (!Utils.isGroupOrBgGroupUserSensitive(groupUsage.getGroup())) {
- continue;
+ if (Utils.isGroupOrBgGroupUserSensitive(groupUsage.getGroup())) {
+ usedGroups.add(appGroups.get(groupNum));
+ } else if (getContext().getSystemService(LocationManager.class).isProviderPackage(
+ appUsage.getPackageName())
+ && (groupName.equals(CAMERA) || groupName.equals(MICROPHONE))) {
+ mSystemUsage.add(groupName);
}
-
- usedGroups.add(appGroups.get(groupNum));
}
if (!usedGroups.isEmpty()) {
@@ -170,7 +175,7 @@ public class ReviewOngoingUsageFragment extends PreferenceFragmentCompat {
}
}
- if (usages.isEmpty() && mOpUsage.isEmpty()) {
+ if (usages.isEmpty() && mOpUsage.isEmpty() && mSystemUsage.isEmpty()) {
getActivity().finish();
return;
}
@@ -230,7 +235,6 @@ public class ReviewOngoingUsageFragment extends PreferenceFragmentCompat {
private @NonNull View createDialogView(
@NonNull List<Pair<AppPermissionUsage, List<GroupUsage>>> usages) {
- Map<String, List<OpAccess>> otherAccesses = mOpUsage;
Context context = getActivity();
LayoutInflater inflater = LayoutInflater.from(context);
View contentView = inflater.inflate(R.layout.ongoing_usage_dialog_content, null);
@@ -250,38 +254,67 @@ public class ReviewOngoingUsageFragment extends PreferenceFragmentCompat {
TextView otherUseHeader = contentView.requireViewById(R.id.other_use_header);
TextView otherUseContent = contentView.requireViewById(R.id.other_use_content);
- if (otherAccesses == null) {
+ TextView systemUseContent = contentView.requireViewById(R.id.system_use_content);
+ View otherUseSpacer = contentView.requireViewById(R.id.other_use_inside_spacer);
+
+ if (mOpUsage.isEmpty() && mSystemUsage.isEmpty()) {
otherUseHeader.setVisibility(View.GONE);
otherUseContent.setVisibility(View.GONE);
- } else {
- if (numUsages == 0) {
- otherUseHeader.setVisibility(View.GONE);
- }
+ }
+
+ if (numUsages == 0) {
+ otherUseHeader.setVisibility(View.GONE);
+ appsList.setVisibility(View.GONE);
+ }
+
+ if (mOpUsage.isEmpty() || mSystemUsage.isEmpty()) {
+ otherUseSpacer.setVisibility(View.GONE);
+ }
+
+ if (mOpUsage.isEmpty()) {
+ otherUseContent.setVisibility(View.GONE);
+ }
+
+ if (mSystemUsage.isEmpty()) {
+ systemUseContent.setVisibility(View.GONE);
+ }
- if (otherAccesses.containsKey(VIDEO_CALL) && otherAccesses.containsKey(PHONE_CALL)) {
+ if (!mOpUsage.isEmpty()) {
+ if (mOpUsage.containsKey(VIDEO_CALL) && mOpUsage.containsKey(
+ PHONE_CALL)) {
otherUseContent.setText(
Html.fromHtml(getString(R.string.phone_call_uses_microphone_and_camera),
0));
- } else if (otherAccesses.containsKey(VIDEO_CALL)) {
+ } else if (mOpUsage.containsKey(VIDEO_CALL)) {
otherUseContent.setText(
Html.fromHtml(getString(R.string.phone_call_uses_camera), 0));
- } else {
+ } else if (mOpUsage.containsKey(PHONE_CALL)) {
otherUseContent.setText(
Html.fromHtml(getString(R.string.phone_call_uses_microphone), 0));
}
- if (otherAccesses.containsKey(VIDEO_CALL)) {
+ if (mOpUsage.containsKey(VIDEO_CALL)) {
usedGroups.put(CAMERA, KotlinUtils.INSTANCE.getPermGroupLabel(context, CAMERA));
}
- if (otherAccesses.containsKey(PHONE_CALL)) {
+ if (mOpUsage.containsKey(PHONE_CALL)) {
usedGroups.put(MICROPHONE,
KotlinUtils.INSTANCE.getPermGroupLabel(context, MICROPHONE));
}
}
- if (numUsages == 0) {
- appsList.setVisibility(View.GONE);
+ if (!mSystemUsage.isEmpty()) {
+ if (mSystemUsage.contains(MICROPHONE) && mSystemUsage.contains(CAMERA)) {
+ systemUseContent.setText(getString(R.string.system_uses_microphone_and_camera));
+ } else if (mSystemUsage.contains(CAMERA)) {
+ systemUseContent.setText(getString(R.string.system_uses_camera));
+ } else if (mSystemUsage.contains(MICROPHONE) ) {
+ systemUseContent.setText(getString(R.string.system_uses_microphone));
+ }
+
+ for (String usage : mSystemUsage) {
+ usedGroups.put(usage, KotlinUtils.INSTANCE.getPermGroupLabel(context, usage));
+ }
}
// Add the layout for each app.