summaryrefslogtreecommitdiffstats
path: root/services/java/com/android
diff options
context:
space:
mode:
Diffstat (limited to 'services/java/com/android')
-rw-r--r--services/java/com/android/server/AppWidgetService.java74
-rw-r--r--services/java/com/android/server/StatusBarManagerService.java9
-rw-r--r--services/java/com/android/server/connectivity/Vpn.java23
-rw-r--r--services/java/com/android/server/net/NetworkPolicyManagerService.java26
4 files changed, 69 insertions, 63 deletions
diff --git a/services/java/com/android/server/AppWidgetService.java b/services/java/com/android/server/AppWidgetService.java
index fd502d8..158c778 100644
--- a/services/java/com/android/server/AppWidgetService.java
+++ b/services/java/com/android/server/AppWidgetService.java
@@ -395,41 +395,47 @@ class AppWidgetService extends IAppWidgetService.Stub
public void bindAppWidgetId(int appWidgetId, ComponentName provider) {
mContext.enforceCallingPermission(android.Manifest.permission.BIND_APPWIDGET,
"bindGagetId appWidgetId=" + appWidgetId + " provider=" + provider);
- synchronized (mAppWidgetIds) {
- AppWidgetId id = lookupAppWidgetIdLocked(appWidgetId);
- if (id == null) {
- throw new IllegalArgumentException("bad appWidgetId");
- }
- if (id.provider != null) {
- throw new IllegalArgumentException("appWidgetId " + appWidgetId + " already bound to "
- + id.provider.info.provider);
- }
- Provider p = lookupProviderLocked(provider);
- if (p == null) {
- throw new IllegalArgumentException("not a appwidget provider: " + provider);
- }
- if (p.zombie) {
- throw new IllegalArgumentException("can't bind to a 3rd party provider in"
- + " safe mode: " + provider);
- }
-
- id.provider = p;
- p.instances.add(id);
- int instancesSize = p.instances.size();
- if (instancesSize == 1) {
- // tell the provider that it's ready
- sendEnableIntentLocked(p);
+
+ final long ident = Binder.clearCallingIdentity();
+ try {
+ synchronized (mAppWidgetIds) {
+ AppWidgetId id = lookupAppWidgetIdLocked(appWidgetId);
+ if (id == null) {
+ throw new IllegalArgumentException("bad appWidgetId");
+ }
+ if (id.provider != null) {
+ throw new IllegalArgumentException("appWidgetId " + appWidgetId + " already bound to "
+ + id.provider.info.provider);
+ }
+ Provider p = lookupProviderLocked(provider);
+ if (p == null) {
+ throw new IllegalArgumentException("not a appwidget provider: " + provider);
+ }
+ if (p.zombie) {
+ throw new IllegalArgumentException("can't bind to a 3rd party provider in"
+ + " safe mode: " + provider);
+ }
+
+ id.provider = p;
+ p.instances.add(id);
+ int instancesSize = p.instances.size();
+ if (instancesSize == 1) {
+ // tell the provider that it's ready
+ sendEnableIntentLocked(p);
+ }
+
+ // send an update now -- We need this update now, and just for this appWidgetId.
+ // It's less critical when the next one happens, so when we schdule the next one,
+ // we add updatePeriodMillis to its start time. That time will have some slop,
+ // but that's okay.
+ sendUpdateIntentLocked(p, new int[] { appWidgetId });
+
+ // schedule the future updates
+ registerForBroadcastsLocked(p, getAppWidgetIds(p));
+ saveStateLocked();
}
-
- // send an update now -- We need this update now, and just for this appWidgetId.
- // It's less critical when the next one happens, so when we schdule the next one,
- // we add updatePeriodMillis to its start time. That time will have some slop,
- // but that's okay.
- sendUpdateIntentLocked(p, new int[] { appWidgetId });
-
- // schedule the future updates
- registerForBroadcastsLocked(p, getAppWidgetIds(p));
- saveStateLocked();
+ } finally {
+ Binder.restoreCallingIdentity(ident);
}
}
diff --git a/services/java/com/android/server/StatusBarManagerService.java b/services/java/com/android/server/StatusBarManagerService.java
index b1bce50..286a937 100644
--- a/services/java/com/android/server/StatusBarManagerService.java
+++ b/services/java/com/android/server/StatusBarManagerService.java
@@ -345,6 +345,15 @@ public class StatusBarManagerService extends IStatusBarService.Stub
});
}
+ @Override
+ public void toggleRecentApps() {
+ if (mBar != null) {
+ try {
+ mBar.toggleRecentApps();
+ } catch (RemoteException ex) {}
+ }
+ }
+
private void enforceStatusBar() {
mContext.enforceCallingOrSelfPermission(android.Manifest.permission.STATUS_BAR,
"StatusBarManagerService");
diff --git a/services/java/com/android/server/connectivity/Vpn.java b/services/java/com/android/server/connectivity/Vpn.java
index ab85b14..941ab80 100644
--- a/services/java/com/android/server/connectivity/Vpn.java
+++ b/services/java/com/android/server/connectivity/Vpn.java
@@ -160,15 +160,6 @@ public class Vpn extends INetworkManagementEventObserver.Stub {
return descriptor;
}
- public synchronized boolean onInterfaceRemoved(String name) {
- if (name.equals(mInterfaceName) && nativeCheck(name) == 0) {
- hideNotification();
- mInterfaceName = null;
- return true;
- }
- return false;
- }
-
// INetworkManagementEventObserver.Stub
public void interfaceLinkStatusChanged(String name, boolean up) {
}
@@ -186,7 +177,7 @@ public class Vpn extends INetworkManagementEventObserver.Stub {
}
}
- private void showNotification(PackageManager pm, ApplicationInfo app, String session) {
+ private void showNotification(PackageManager pm, ApplicationInfo app, String sessionName) {
NotificationManager nm = (NotificationManager)
mContext.getSystemService(Context.NOTIFICATION_SERVICE);
@@ -207,11 +198,6 @@ public class Vpn extends INetworkManagementEventObserver.Stub {
// Load the label.
String label = app.loadLabel(pm).toString();
- // If session is null, use the application name instead.
- if (session == null) {
- session = label;
- }
-
// Build the intent.
// TODO: move these into VpnBuilder.
Intent intent = new Intent();
@@ -219,23 +205,24 @@ public class Vpn extends INetworkManagementEventObserver.Stub {
"com.android.vpndialogs.ManageDialog");
intent.putExtra("packageName", mPackageName);
intent.putExtra("interfaceName", mInterfaceName);
- intent.putExtra("session", session);
+ intent.putExtra("session", sessionName);
intent.putExtra("startTime", android.os.SystemClock.elapsedRealtime());
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
// Build the notification.
+ String text = (sessionName == null) ? mContext.getString(R.string.vpn_text) :
+ mContext.getString(R.string.vpn_text_long, sessionName);
long identity = Binder.clearCallingIdentity();
Notification notification = new Notification.Builder(mContext)
.setSmallIcon(R.drawable.vpn_connected)
.setLargeIcon(bitmap)
.setTicker(mContext.getString(R.string.vpn_ticker, label))
.setContentTitle(mContext.getString(R.string.vpn_title, label))
- .setContentText(mContext.getString(R.string.vpn_text, session))
+ .setContentText(text)
.setContentIntent(PendingIntent.getActivity(mContext, 0, intent, 0))
.setDefaults(Notification.DEFAULT_ALL)
.setOngoing(true)
.getNotification();
-
nm.notify(R.drawable.vpn_connected, notification);
Binder.restoreCallingIdentity(identity);
}
diff --git a/services/java/com/android/server/net/NetworkPolicyManagerService.java b/services/java/com/android/server/net/NetworkPolicyManagerService.java
index 2164334..dac0044 100644
--- a/services/java/com/android/server/net/NetworkPolicyManagerService.java
+++ b/services/java/com/android/server/net/NetworkPolicyManagerService.java
@@ -25,6 +25,9 @@ import static android.Manifest.permission.READ_PHONE_STATE;
import static android.net.ConnectivityManager.CONNECTIVITY_ACTION;
import static android.net.NetworkPolicy.LIMIT_DISABLED;
import static android.net.NetworkPolicy.WARNING_DISABLED;
+import static android.net.NetworkPolicyManager.ACTION_DATA_USAGE_LIMIT;
+import static android.net.NetworkPolicyManager.ACTION_DATA_USAGE_WARNING;
+import static android.net.NetworkPolicyManager.EXTRA_NETWORK_TEMPLATE;
import static android.net.NetworkPolicyManager.POLICY_NONE;
import static android.net.NetworkPolicyManager.POLICY_REJECT_PAID_BACKGROUND;
import static android.net.NetworkPolicyManager.RULE_ALLOW_ALL;
@@ -138,11 +141,6 @@ public class NetworkPolicyManagerService extends INetworkPolicyManager.Stub {
private static final String ATTR_UID = "uid";
private static final String ATTR_POLICY = "policy";
- public static final String ACTION_DATA_USAGE_WARNING =
- "android.intent.action.DATA_USAGE_WARNING";
- public static final String ACTION_DATA_USAGE_LIMIT =
- "android.intent.action.DATA_USAGE_LIMIT";
-
private static final long TIME_CACHE_MAX_AGE = DAY_IN_MILLIS;
private final Context mContext;
@@ -402,9 +400,12 @@ public class NetworkPolicyManagerService extends INetworkPolicyManager.Stub {
builder.setTicker(title);
builder.setContentTitle(title);
builder.setContentText(body);
- builder.setContentIntent(PendingIntent.getActivity(mContext, 0,
- new Intent(ACTION_DATA_USAGE_WARNING),
- PendingIntent.FLAG_UPDATE_CURRENT));
+
+ final Intent intent = new Intent(ACTION_DATA_USAGE_WARNING);
+ intent.addCategory(Intent.CATEGORY_DEFAULT);
+ intent.putExtra(EXTRA_NETWORK_TEMPLATE, policy.networkTemplate);
+ builder.setContentIntent(PendingIntent.getActivity(
+ mContext, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT));
break;
}
case TYPE_LIMIT: {
@@ -426,9 +427,12 @@ public class NetworkPolicyManagerService extends INetworkPolicyManager.Stub {
builder.setTicker(title);
builder.setContentTitle(title);
builder.setContentText(body);
- builder.setContentIntent(PendingIntent.getActivity(mContext, 0,
- new Intent(ACTION_DATA_USAGE_LIMIT),
- PendingIntent.FLAG_UPDATE_CURRENT));
+
+ final Intent intent = new Intent(ACTION_DATA_USAGE_LIMIT);
+ intent.addCategory(Intent.CATEGORY_DEFAULT);
+ intent.putExtra(EXTRA_NETWORK_TEMPLATE, policy.networkTemplate);
+ builder.setContentIntent(PendingIntent.getActivity(
+ mContext, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT));
break;
}
}