summaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorFyodor Kupolov <fkupolov@google.com>2015-04-17 17:59:14 -0700
committerFyodor Kupolov <fkupolov@google.com>2015-05-08 17:17:16 -0700
commitb501330a1b6ef14ff512a5727f7a01bc423d6fbb (patch)
tree59796487de2723dc92a0520def552124fb3aa556 /core
parent4f434a04708e7a254afe2e0d362f715229dc15d1 (diff)
downloadframeworks_base-b501330a1b6ef14ff512a5727f7a01bc423d6fbb.zip
frameworks_base-b501330a1b6ef14ff512a5727f7a01bc423d6fbb.tar.gz
frameworks_base-b501330a1b6ef14ff512a5727f7a01bc423d6fbb.tar.bz2
Disable multi-user background recording
On user switch, kill existing processes of the background user with android.permission.RECORD_AUDIO permission. Home activity should not be killed to avoid an expensive restart of the home launcher, when the user switches back. Introduced DISALLOW_RECORD_AUDIO user restriction, which is enabled for the background user, and removed for the foreground user. Introduced a concept of system controlled user restriction, which can only be set by the system, rather than device administrator. Bug: 20346194 Change-Id: Ic942fd565e80d14424230dae612965a8e229c4ef
Diffstat (limited to 'core')
-rw-r--r--core/java/android/app/ActivityManagerInternal.java7
-rw-r--r--core/java/android/app/AppOpsManager.java2
-rw-r--r--core/java/android/os/IUserManager.aidl2
-rw-r--r--core/java/android/os/UserManager.java18
4 files changed, 25 insertions, 4 deletions
diff --git a/core/java/android/app/ActivityManagerInternal.java b/core/java/android/app/ActivityManagerInternal.java
index bde8f39..40eb799 100644
--- a/core/java/android/app/ActivityManagerInternal.java
+++ b/core/java/android/app/ActivityManagerInternal.java
@@ -17,6 +17,7 @@
package android.app;
import android.annotation.NonNull;
+import android.content.ComponentName;
/**
* Activity manager local system service interface.
@@ -48,4 +49,10 @@ public abstract class ActivityManagerInternal {
*/
public abstract void release();
}
+
+ /**
+ * Returns home activity for the specified user.
+ * @param userId ID of the user or {@link android.os.UserHandle#USER_ALL}
+ */
+ public abstract ComponentName getHomeActivityForUser(int userId);
}
diff --git a/core/java/android/app/AppOpsManager.java b/core/java/android/app/AppOpsManager.java
index 5aa399b..7104185 100644
--- a/core/java/android/app/AppOpsManager.java
+++ b/core/java/android/app/AppOpsManager.java
@@ -606,7 +606,7 @@ public class AppOpsManager {
UserManager.DISALLOW_CREATE_WINDOWS, //SYSTEM_ALERT_WINDOW
null, //ACCESS_NOTIFICATIONS
null, //CAMERA
- null, //RECORD_AUDIO
+ UserManager.DISALLOW_RECORD_AUDIO, //RECORD_AUDIO
null, //PLAY_AUDIO
null, //READ_CLIPBOARD
null, //WRITE_CLIPBOARD
diff --git a/core/java/android/os/IUserManager.aidl b/core/java/android/os/IUserManager.aidl
index 811418b..f212daf 100644
--- a/core/java/android/os/IUserManager.aidl
+++ b/core/java/android/os/IUserManager.aidl
@@ -45,6 +45,8 @@ interface IUserManager {
Bundle getUserRestrictions(int userHandle);
boolean hasUserRestriction(in String restrictionKey, int userHandle);
void setUserRestrictions(in Bundle restrictions, int userHandle);
+ void setUserRestriction(String key, boolean value, int userId);
+ void setSystemControlledUserRestriction(String key, boolean value, int userId);
void setApplicationRestrictions(in String packageName, in Bundle restrictions,
int userHandle);
Bundle getApplicationRestrictions(in String packageName);
diff --git a/core/java/android/os/UserManager.java b/core/java/android/os/UserManager.java
index c7ac7ce..cc37d5e 100644
--- a/core/java/android/os/UserManager.java
+++ b/core/java/android/os/UserManager.java
@@ -412,6 +412,16 @@ public class UserManager {
public static final String DISALLOW_SAFE_BOOT = "no_safe_boot";
/**
+ * Specifies if a user is not allowed to record audio. This restriction is always enabled for
+ * background users. The default value is <code>false</code>.
+ *
+ * @see #setUserRestrictions(Bundle)
+ * @see #getUserRestrictions()
+ * @hide
+ */
+ public static final String DISALLOW_RECORD_AUDIO = "no_record_audio";
+
+ /**
* Application restriction key that is used to indicate the pending arrival
* of real restrictions for the app.
*
@@ -688,9 +698,11 @@ public class UserManager {
*/
@Deprecated
public void setUserRestriction(String key, boolean value, UserHandle userHandle) {
- Bundle bundle = getUserRestrictions(userHandle);
- bundle.putBoolean(key, value);
- setUserRestrictions(bundle, userHandle);
+ try {
+ mService.setUserRestriction(key, value, userHandle.getIdentifier());
+ } catch (RemoteException re) {
+ Log.w(TAG, "Could not set user restriction", re);
+ }
}
/**