summaryrefslogtreecommitdiffstats
path: root/packages
diff options
context:
space:
mode:
authorSelim Cinek <cinek@google.com>2014-08-27 12:51:45 +0200
committerSelim Cinek <cinek@google.com>2014-08-28 15:09:28 +0200
commit24ac55e658f955c330fff4bb143cfc6af37e40bf (patch)
treee77fad0fc8953c956ad2c7c04a344a859d0584ad /packages
parente6afe9c75c0a8a4f3f8fc0a6f8981b0dba4afd2a (diff)
downloadframeworks_base-24ac55e658f955c330fff4bb143cfc6af37e40bf.zip
frameworks_base-24ac55e658f955c330fff4bb143cfc6af37e40bf.tar.gz
frameworks_base-24ac55e658f955c330fff4bb143cfc6af37e40bf.tar.bz2
Added a warning when the profile has an owner
Also fixed a bug where a post in the QSFooter was not always on the mainthread leading to a crash. Bug: 17066115 Change-Id: Iea9e1032973058ed5e63e70da4dc0bcf34fa59a3
Diffstat (limited to 'packages')
-rw-r--r--packages/SystemUI/res/values/strings.xml24
-rw-r--r--packages/SystemUI/src/com/android/systemui/qs/QSFooter.java72
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/phone/QSTileHost.java1
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/policy/SecurityController.java11
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/policy/SecurityControllerImpl.java31
5 files changed, 118 insertions, 21 deletions
diff --git a/packages/SystemUI/res/values/strings.xml b/packages/SystemUI/res/values/strings.xml
index 0fe389a..189c052 100644
--- a/packages/SystemUI/res/values/strings.xml
+++ b/packages/SystemUI/res/values/strings.xml
@@ -837,12 +837,18 @@
<!-- Footer device owned text [CHAR LIMIT=50] -->
<string name="device_owned_footer">Device may be monitored</string>
+ <!-- Footer profile owned text [CHAR LIMIT=50] -->
+ <string name="profile_owned_footer">Profile may be monitored</string>
+
<!-- Footer vpn present text [CHAR LIMIT=50] -->
<string name="vpn_footer">Network may be monitored</string>
<!-- Monitoring dialog title for device owned devices [CHAR LIMIT=35] -->
<string name="monitoring_title_device_owned">Device monitoring</string>
+ <!-- Monitoring dialog title for profile owned devices [CHAR LIMIT=35] -->
+ <string name="monitoring_title_profile_owned">Profile monitoring</string>
+
<!-- Monitoring dialog title for normal devices [CHAR LIMIT=35]-->
<string name="monitoring_title">Network monitoring</string>
@@ -867,6 +873,24 @@
<!-- Monitoring dialog legacy VPN with device owner text [CHAR LIMIT=300] -->
<string name="monitoring_description_legacy_vpn_device_owned">This device is managed by:\n<xliff:g id="organization">%1$s</xliff:g>\n\nYour administrator is capable of monitoring your network activity including emails, apps, and secure websites. For more information, contact your administrator.\n\nAlso, you\'re connected to a VPN (\"<xliff:g id="application">%2$s</xliff:g>\"). Your VPN service provider can monitor network activity too.</string>
+ <!-- Monitoring dialog profile owner body text [CHAR LIMIT=300] -->
+ <string name="monitoring_description_profile_owned">This profile is managed by:\n<xliff:g id="organization">%1$s</xliff:g>\n\nYour administrator can monitor your device and network activity, including emails, apps and secure websites.\n\nFor more information, contact your administrator.</string>
+
+ <!-- Monitoring dialog device and profile owner body text [CHAR LIMIT=300] -->
+ <string name="monitoring_description_device_and_profile_owned">This device is managed by:\n<xliff:g id="organization">%1$s</xliff:g>\nYour profile is managed by:\n<xliff:g id="organization">%2$s</xliff:g>\n\nYour administrator can monitor your device and network activity, including emails, apps and secure websites.\n\nFor more information, contact your administrator.</string>
+
+ <!-- Monitoring dialog non-legacy VPN with profile owner text [CHAR LIMIT=300] -->
+ <string name="monitoring_description_vpn_profile_owned">This profile is managed by:\n<xliff:g id="organization">%1$s</xliff:g>\n\nYour administrator is capable of monitoring your network activity including emails, apps, and secure websites. For more information, contact your administrator.\n\nAlso, you gave \"<xliff:g id="application">%2$s</xliff:g>\" permission to set up a VPN connection. This app can monitor network activity too.</string>
+
+ <!-- Monitoring dialog legacy VPN with profile owner text [CHAR LIMIT=300] -->
+ <string name="monitoring_description_legacy_vpn_profile_owned">This profile is managed by:\n<xliff:g id="organization">%1$s</xliff:g>\n\nYour administrator is capable of monitoring your network activity including emails, apps, and secure websites. For more information, contact your administrator.\n\nAlso, you\'re connected to a VPN (\"<xliff:g id="application">%2$s</xliff:g>\"). Your VPN service provider can monitor network activity too.</string>
+
+ <!-- Monitoring dialog non-legacy VPN with device and profile owner text [CHAR LIMIT=300] -->
+ <string name="monitoring_description_vpn_device_and_profile_owned">This device is managed by:\n<xliff:g id="organization">%1$s</xliff:g>\nYour profile is managed by:\n<xliff:g id="organization">%2$s</xliff:g>\n\nYour administrator is capable of monitoring your network activity including emails, apps, and secure websites. For more information, contact your administrator.\n\nAlso, you gave \"<xliff:g id="application">%3$s</xliff:g>\" permission to set up a VPN connection. This app can monitor network activity too.</string>
+
+ <!-- Monitoring dialog legacy VPN with device and profile owner text [CHAR LIMIT=300] -->
+ <string name="monitoring_description_legacy_vpn_device_and_profile_owned">This device is managed by:\n<xliff:g id="organization">%1$s</xliff:g>\nYour profile is managed by:\n<xliff:g id="organization">%2$s</xliff:g>\n\nYour administrator is capable of monitoring your network activity including emails, apps, and secure websites. For more information, contact your administrator.\n\nAlso, you\'re connected to a VPN (\"<xliff:g id="application">%3$s</xliff:g>\"). Your VPN service provider can monitor network activity too.</string>
+
<!-- Indication on the keyguard that appears when the user disables trust agents until the next time they unlock manually. [CHAR LIMIT=NONE] -->
<string name="keyguard_indication_trust_disabled">Device will stay locked until you manually unlock</string>
diff --git a/packages/SystemUI/src/com/android/systemui/qs/QSFooter.java b/packages/SystemUI/src/com/android/systemui/qs/QSFooter.java
index 82e6df2..a0b6e82 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/QSFooter.java
+++ b/packages/SystemUI/src/com/android/systemui/qs/QSFooter.java
@@ -24,11 +24,9 @@ import android.os.Looper;
import android.os.Message;
import android.util.Log;
import android.util.TypedValue;
-import android.view.ContextThemeWrapper;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
-import android.view.WindowManager;
import android.widget.ImageView;
import android.widget.TextView;
@@ -37,7 +35,6 @@ import com.android.systemui.R;
import com.android.systemui.statusbar.phone.QSTileHost;
import com.android.systemui.statusbar.phone.SystemUIDialog;
import com.android.systemui.statusbar.policy.SecurityController;
-import com.android.systemui.statusbar.policy.SecurityController.VpnCallback;
public class QSFooter implements OnClickListener, DialogInterface.OnClickListener {
protected static final String TAG = "QSFooter";
@@ -53,6 +50,7 @@ public class QSFooter implements OnClickListener, DialogInterface.OnClickListene
private AlertDialog mDialog;
private QSTileHost mHost;
private Handler mHandler;
+ private final Handler mMainHandler;
private boolean mIsVisible;
private boolean mIsIconVisible;
@@ -65,6 +63,7 @@ public class QSFooter implements OnClickListener, DialogInterface.OnClickListene
mFooterText = (TextView) mRootView.findViewById(R.id.footer_text);
mFooterIcon = (ImageView) mRootView.findViewById(R.id.footer_icon);
mContext = context;
+ mMainHandler = new Handler();
}
public void setHost(QSTileHost host) {
@@ -113,14 +112,19 @@ public class QSFooter implements OnClickListener, DialogInterface.OnClickListene
mFooterTextId = R.string.device_owned_footer;
mIsVisible = true;
mIsIconVisible = false;
+ } else if (mSecurityController.hasProfileOwner()) {
+ mFooterTextId = R.string.profile_owned_footer;
+ mIsVisible = true;
+ mIsIconVisible = false;
} else if (mSecurityController.isVpnEnabled()) {
mFooterTextId = R.string.vpn_footer;
mIsVisible = true;
mIsIconVisible = true;
} else {
mIsVisible = false;
+ mIsIconVisible = false;
}
- mRootView.post(mUpdateDisplayState);
+ mMainHandler.post(mUpdateDisplayState);
}
@Override
@@ -155,20 +159,61 @@ public class QSFooter implements OnClickListener, DialogInterface.OnClickListene
private String getMessage() {
if (mSecurityController.hasDeviceOwner()) {
+ if (mSecurityController.hasProfileOwner()) {
+ if (mSecurityController.isVpnEnabled()) {
+ if (mSecurityController.isLegacyVpn()) {
+ return mContext.getString(
+ R.string.monitoring_description_legacy_vpn_device_and_profile_owned,
+ mSecurityController.getDeviceOwnerName(),
+ mSecurityController.getProfileOwnerName(),
+ mSecurityController.getLegacyVpnName());
+ } else {
+ return mContext.getString(
+ R.string.monitoring_description_vpn_device_and_profile_owned,
+ mSecurityController.getDeviceOwnerName(),
+ mSecurityController.getProfileOwnerName(),
+ mSecurityController.getVpnApp());
+ }
+ } else {
+ return mContext.getString(
+ R.string.monitoring_description_device_and_profile_owned,
+ mSecurityController.getDeviceOwnerName(),
+ mSecurityController.getProfileOwnerName());
+ }
+ } else {
+ if (mSecurityController.isVpnEnabled()) {
+ if (mSecurityController.isLegacyVpn()) {
+ return mContext.getString(
+ R.string.monitoring_description_legacy_vpn_device_owned,
+ mSecurityController.getDeviceOwnerName(),
+ mSecurityController.getLegacyVpnName());
+ } else {
+ return mContext.getString(R.string.monitoring_description_vpn_device_owned,
+ mSecurityController.getDeviceOwnerName(),
+ mSecurityController.getVpnApp());
+ }
+ } else {
+ return mContext.getString(R.string.monitoring_description_device_owned,
+ mSecurityController.getDeviceOwnerName());
+ }
+ }
+ } else if (mSecurityController.hasProfileOwner()) {
if (mSecurityController.isVpnEnabled()) {
if (mSecurityController.isLegacyVpn()) {
return mContext.getString(
- R.string.monitoring_description_legacy_vpn_device_owned,
- mSecurityController.getDeviceOwnerName(),
+ R.string.monitoring_description_legacy_vpn_profile_owned,
+ mSecurityController.getProfileOwnerName(),
mSecurityController.getLegacyVpnName());
} else {
- return mContext.getString(R.string.monitoring_description_vpn_device_owned,
- mSecurityController.getDeviceOwnerName(),
+ return mContext.getString(
+ R.string.monitoring_description_vpn_profile_owned,
+ mSecurityController.getProfileOwnerName(),
mSecurityController.getVpnApp());
}
} else {
- return mContext.getString(R.string.monitoring_description_device_owned,
- mSecurityController.getDeviceOwnerName());
+ return mContext.getString(
+ R.string.monitoring_description_profile_owned,
+ mSecurityController.getProfileOwnerName());
}
} else {
if (mSecurityController.isLegacyVpn()) {
@@ -186,6 +231,9 @@ public class QSFooter implements OnClickListener, DialogInterface.OnClickListene
if (mSecurityController.hasDeviceOwner()) {
return R.string.monitoring_title_device_owned;
}
+ if (mSecurityController.hasProfileOwner()) {
+ return R.string.monitoring_title_profile_owned;
+ }
return R.string.monitoring_title;
}
@@ -200,9 +248,9 @@ public class QSFooter implements OnClickListener, DialogInterface.OnClickListene
}
};
- private class Callback implements VpnCallback {
+ private class Callback implements SecurityController.SecurityControllerCallback {
@Override
- public void onVpnStateChanged() {
+ public void onStateChanged() {
refreshState();
}
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/QSTileHost.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/QSTileHost.java
index 729d459..2dc08d4 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/QSTileHost.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/QSTileHost.java
@@ -119,6 +119,7 @@ public class QSTileHost implements QSTile.Host {
for (QSTile<?> tile : mTiles.values()) {
tile.userSwitch(newUserId);
}
+ mSecurity.onUserSwitched(newUserId);
mObserver.register();
}
};
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/SecurityController.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/SecurityController.java
index 3a5a53b..6148feb 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/SecurityController.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/SecurityController.java
@@ -18,18 +18,21 @@ package com.android.systemui.statusbar.policy;
public interface SecurityController {
boolean hasDeviceOwner();
+ boolean hasProfileOwner();
String getDeviceOwnerName();
+ String getProfileOwnerName();
boolean isVpnEnabled();
String getVpnApp();
boolean isLegacyVpn();
String getLegacyVpnName();
void disconnectFromVpn();
+ void onUserSwitched(int newUserId);
- void addCallback(VpnCallback callback);
- void removeCallback(VpnCallback callback);
+ void addCallback(SecurityControllerCallback callback);
+ void removeCallback(SecurityControllerCallback callback);
- public interface VpnCallback {
- void onVpnStateChanged();
+ public interface SecurityControllerCallback {
+ void onStateChanged();
}
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/SecurityControllerImpl.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/SecurityControllerImpl.java
index 499fe0b..a15ddaf 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/SecurityControllerImpl.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/SecurityControllerImpl.java
@@ -15,6 +15,7 @@
*/
package com.android.systemui.statusbar.policy;
+import android.app.ActivityManager;
import android.app.admin.DevicePolicyManager;
import android.content.Context;
import android.content.pm.PackageManager.NameNotFoundException;
@@ -52,11 +53,13 @@ public class SecurityControllerImpl implements SecurityController {
private final IConnectivityManager mConnectivityService = IConnectivityManager.Stub.asInterface(
ServiceManager.getService(Context.CONNECTIVITY_SERVICE));
private final DevicePolicyManager mDevicePolicyManager;
- private final ArrayList<VpnCallback> mCallbacks = new ArrayList<VpnCallback>();
+ private final ArrayList<SecurityControllerCallback> mCallbacks
+ = new ArrayList<SecurityControllerCallback>();
private VpnConfig mVpnConfig;
private String mVpnName;
private int mCurrentVpnNetworkId = NO_NETWORK;
+ private int mCurrentUserId;
public SecurityControllerImpl(Context context) {
mContext = context;
@@ -67,6 +70,7 @@ public class SecurityControllerImpl implements SecurityController {
// TODO: re-register network callback on user change.
mConnectivityManager.registerNetworkCallback(REQUEST, mNetworkCallback);
+ mCurrentUserId = ActivityManager.getCurrentUser();
}
public void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
@@ -82,11 +86,22 @@ public class SecurityControllerImpl implements SecurityController {
}
@Override
+ public boolean hasProfileOwner() {
+ return !TextUtils.isEmpty(mDevicePolicyManager.getProfileOwnerNameAsUser(mCurrentUserId));
+ }
+
+ @Override
public String getDeviceOwnerName() {
return mDevicePolicyManager.getDeviceOwnerName();
}
@Override
+ public String getProfileOwnerName() {
+ return mDevicePolicyManager.getProfileOwnerNameAsUser(mCurrentUserId);
+ }
+
+
+ @Override
public boolean isVpnEnabled() {
return mCurrentVpnNetworkId != NO_NETWORK;
}
@@ -124,19 +139,25 @@ public class SecurityControllerImpl implements SecurityController {
}
@Override
- public void addCallback(VpnCallback callback) {
+ public void addCallback(SecurityControllerCallback callback) {
if (callback == null) return;
if (DEBUG) Log.d(TAG, "removeCallback " + callback);
mCallbacks.remove(callback);
}
@Override
- public void removeCallback(VpnCallback callback) {
+ public void removeCallback(SecurityControllerCallback callback) {
if (callback == null || mCallbacks.contains(callback)) return;
if (DEBUG) Log.d(TAG, "addCallback " + callback);
mCallbacks.add(callback);
}
+ @Override
+ public void onUserSwitched(int newUserId) {
+ mCurrentUserId = newUserId;
+ fireCallbacks();
+ }
+
private void setCurrentNetid(int netId) {
if (netId != mCurrentVpnNetworkId) {
mCurrentVpnNetworkId = netId;
@@ -146,8 +167,8 @@ public class SecurityControllerImpl implements SecurityController {
}
private void fireCallbacks() {
- for (VpnCallback callback : mCallbacks) {
- callback.onVpnStateChanged();
+ for (SecurityControllerCallback callback : mCallbacks) {
+ callback.onStateChanged();
}
}