summaryrefslogtreecommitdiffstats
path: root/services/java/com
diff options
context:
space:
mode:
Diffstat (limited to 'services/java/com')
-rw-r--r--services/java/com/android/server/AppWidgetServiceImpl.java16
-rw-r--r--services/java/com/android/server/ClipboardService.java18
-rw-r--r--services/java/com/android/server/ConnectivityService.java19
-rw-r--r--services/java/com/android/server/WifiService.java34
-rw-r--r--services/java/com/android/server/accessibility/AccessibilityManagerService.java36
-rw-r--r--services/java/com/android/server/accessibility/TouchExplorer.java129
-rw-r--r--services/java/com/android/server/net/NetworkPolicyManagerService.java221
-rw-r--r--services/java/com/android/server/net/NetworkStatsService.java76
-rw-r--r--services/java/com/android/server/pm/PackageManagerService.java48
-rw-r--r--services/java/com/android/server/wm/DisplayContent.java4
10 files changed, 386 insertions, 215 deletions
diff --git a/services/java/com/android/server/AppWidgetServiceImpl.java b/services/java/com/android/server/AppWidgetServiceImpl.java
index 95d7623..499c15e 100644
--- a/services/java/com/android/server/AppWidgetServiceImpl.java
+++ b/services/java/com/android/server/AppWidgetServiceImpl.java
@@ -42,6 +42,7 @@ import android.os.Binder;
import android.os.Bundle;
import android.os.Environment;
import android.os.IBinder;
+import android.os.Process;
import android.os.RemoteException;
import android.os.SystemClock;
import android.os.UserHandle;
@@ -409,7 +410,7 @@ class AppWidgetServiceImpl {
}
public int allocateAppWidgetId(String packageName, int hostId) {
- int callingUid = enforceCallingUid(packageName);
+ int callingUid = enforceSystemOrCallingUid(packageName);
synchronized (mAppWidgetIds) {
ensureStateLoadedLocked();
int appWidgetId = mNextAppWidgetId++;
@@ -1358,10 +1359,10 @@ class AppWidgetServiceImpl {
com.android.internal.R.styleable.AppWidgetProviderInfo_resizeMode,
AppWidgetProviderInfo.RESIZE_NONE);
info.widgetCategory = sa.getInt(
- com.android.internal.R.styleable.AppWidgetProviderInfo_resizeMode,
+ com.android.internal.R.styleable.AppWidgetProviderInfo_widgetCategory,
AppWidgetProviderInfo.WIDGET_CATEGORY_HOME_SCREEN);
info.widgetFeatures = sa.getInt(
- com.android.internal.R.styleable.AppWidgetProviderInfo_resizeMode,
+ com.android.internal.R.styleable.AppWidgetProviderInfo_widgetFeatures,
AppWidgetProviderInfo.WIDGET_FEATURES_NONE);
sa.recycle();
@@ -1391,6 +1392,15 @@ class AppWidgetServiceImpl {
return pkgInfo.applicationInfo.uid;
}
+ int enforceSystemOrCallingUid(String packageName) throws IllegalArgumentException {
+ int callingUid = Binder.getCallingUid();
+ int uid = Process.myUid();
+ if (UserHandle.getAppId(uid) == Process.SYSTEM_UID || uid == 0) {
+ return callingUid;
+ }
+ return enforceCallingUid(packageName);
+ }
+
int enforceCallingUid(String packageName) throws IllegalArgumentException {
int callingUid = Binder.getCallingUid();
int packageUid;
diff --git a/services/java/com/android/server/ClipboardService.java b/services/java/com/android/server/ClipboardService.java
index 0bf7aad..74ec6e2 100644
--- a/services/java/com/android/server/ClipboardService.java
+++ b/services/java/com/android/server/ClipboardService.java
@@ -17,6 +17,7 @@
package com.android.server;
import android.app.ActivityManagerNative;
+import android.app.AppGlobals;
import android.app.IActivityManager;
import android.content.BroadcastReceiver;
import android.content.ClipData;
@@ -26,6 +27,7 @@ import android.content.IOnPrimaryClipChangedListener;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
+import android.content.pm.IPackageManager;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.content.pm.PackageManager.NameNotFoundException;
@@ -120,7 +122,6 @@ public class ClipboardService extends IClipboard.Stub {
private PerUserClipboard getClipboard(int userId) {
synchronized (mClipboards) {
- Slog.i(TAG, "Got clipboard for user=" + userId);
PerUserClipboard puc = mClipboards.get(userId);
if (puc == null) {
puc = new PerUserClipboard(userId);
@@ -255,15 +256,22 @@ public class ClipboardService extends IClipboard.Stub {
}
private final void addActiveOwnerLocked(int uid, String pkg) {
- PackageInfo pi;
+ final IPackageManager pm = AppGlobals.getPackageManager();
+ final int targetUserHandle = UserHandle.getCallingUserId();
+ final long oldIdentity = Binder.clearCallingIdentity();
try {
- pi = mPm.getPackageInfo(pkg, 0);
+ PackageInfo pi = pm.getPackageInfo(pkg, 0, targetUserHandle);
+ if (pi == null) {
+ throw new IllegalArgumentException("Unknown package " + pkg);
+ }
if (!UserHandle.isSameApp(pi.applicationInfo.uid, uid)) {
throw new SecurityException("Calling uid " + uid
+ " does not own package " + pkg);
}
- } catch (NameNotFoundException e) {
- throw new IllegalArgumentException("Unknown package " + pkg, e);
+ } catch (RemoteException e) {
+ // Can't happen; the package manager is in the same process
+ } finally {
+ Binder.restoreCallingIdentity(oldIdentity);
}
PerUserClipboard clipboard = getClipboard();
if (clipboard.primaryClip != null && !clipboard.activePermissionOwners.contains(pkg)) {
diff --git a/services/java/com/android/server/ConnectivityService.java b/services/java/com/android/server/ConnectivityService.java
index 3a338a9..5c7a3ed 100644
--- a/services/java/com/android/server/ConnectivityService.java
+++ b/services/java/com/android/server/ConnectivityService.java
@@ -96,6 +96,7 @@ import com.android.internal.net.VpnConfig;
import com.android.internal.net.VpnProfile;
import com.android.internal.telephony.Phone;
import com.android.internal.telephony.PhoneConstants;
+import com.android.internal.util.IndentingPrintWriter;
import com.android.server.am.BatteryStatsService;
import com.android.server.connectivity.Tethering;
import com.android.server.connectivity.Vpn;
@@ -2593,7 +2594,8 @@ public class ConnectivityService extends IConnectivityManager.Stub {
}
@Override
- protected void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
+ protected void dump(FileDescriptor fd, PrintWriter writer, String[] args) {
+ final IndentingPrintWriter pw = new IndentingPrintWriter(writer, " ");
if (mContext.checkCallingOrSelfPermission(
android.Manifest.permission.DUMP)
!= PackageManager.PERMISSION_GRANTED) {
@@ -2602,20 +2604,28 @@ public class ConnectivityService extends IConnectivityManager.Stub {
Binder.getCallingUid());
return;
}
+
+ // TODO: add locking to get atomic snapshot
pw.println();
- for (NetworkStateTracker nst : mNetTrackers) {
+ for (int i = 0; i < mNetTrackers.length; i++) {
+ final NetworkStateTracker nst = mNetTrackers[i];
if (nst != null) {
+ pw.println("NetworkStateTracker for " + getNetworkTypeName(i) + ":");
+ pw.increaseIndent();
if (nst.getNetworkInfo().isConnected()) {
pw.println("Active network: " + nst.getNetworkInfo().
getTypeName());
}
pw.println(nst.getNetworkInfo());
+ pw.println(nst.getLinkProperties());
pw.println(nst);
pw.println();
+ pw.decreaseIndent();
}
}
pw.println("Network Requester Pids:");
+ pw.increaseIndent();
for (int net : mPriorityList) {
String pidString = net + ": ";
for (Object pid : mNetRequestersPids[net]) {
@@ -2624,12 +2634,15 @@ public class ConnectivityService extends IConnectivityManager.Stub {
pw.println(pidString);
}
pw.println();
+ pw.decreaseIndent();
pw.println("FeatureUsers:");
+ pw.increaseIndent();
for (Object requester : mFeatureUsers) {
pw.println(requester.toString());
}
pw.println();
+ pw.decreaseIndent();
synchronized (this) {
pw.println("NetworkTranstionWakeLock is currently " +
@@ -2643,9 +2656,11 @@ public class ConnectivityService extends IConnectivityManager.Stub {
if (mInetLog != null) {
pw.println();
pw.println("Inet condition reports:");
+ pw.increaseIndent();
for(int i = 0; i < mInetLog.size(); i++) {
pw.println(mInetLog.get(i));
}
+ pw.decreaseIndent();
}
}
diff --git a/services/java/com/android/server/WifiService.java b/services/java/com/android/server/WifiService.java
index 7ed4f8a..5c3af79 100644
--- a/services/java/com/android/server/WifiService.java
+++ b/services/java/com/android/server/WifiService.java
@@ -133,8 +133,8 @@ public class WifiService extends IWifiManager.Stub {
private static final int POLL_TRAFFIC_STATS_INTERVAL_MSECS = 1000;
/**
- * See {@link Settings.Secure#WIFI_IDLE_MS}. This is the default value if a
- * Settings.Secure value is not present. This timeout value is chosen as
+ * See {@link Settings.Global#WIFI_IDLE_MS}. This is the default value if a
+ * Settings.Global value is not present. This timeout value is chosen as
* the approximate point at which the battery drain caused by Wi-Fi
* being enabled but not active exceeds the battery drain caused by
* re-establishing a connection to the mobile data network.
@@ -431,8 +431,8 @@ public class WifiService extends IWifiManager.Stub {
mWifiStateMachineHandler = new WifiStateMachineHandler(wifiThread.getLooper());
// Setting is in seconds
- NOTIFICATION_REPEAT_DELAY_MS = Settings.Secure.getInt(context.getContentResolver(),
- Settings.Secure.WIFI_NETWORKS_AVAILABLE_REPEAT_DELAY, 900) * 1000l;
+ NOTIFICATION_REPEAT_DELAY_MS = Settings.Global.getInt(context.getContentResolver(),
+ Settings.Global.WIFI_NETWORKS_AVAILABLE_REPEAT_DELAY, 900) * 1000l;
mNotificationEnabledSettingObserver = new NotificationEnabledSettingObserver(new Handler());
mNotificationEnabledSettingObserver.register();
}
@@ -502,9 +502,9 @@ public class WifiService extends IWifiManager.Stub {
final ContentResolver cr = mContext.getContentResolver();
int wifiSavedState = 0;
try {
- wifiSavedState = Settings.Secure.getInt(cr, Settings.Secure.WIFI_SAVED_STATE);
+ wifiSavedState = Settings.Global.getInt(cr, Settings.Global.WIFI_SAVED_STATE);
if(wifiSavedState == 1)
- Settings.Secure.putInt(cr, Settings.Secure.WIFI_SAVED_STATE, 0);
+ Settings.Global.putInt(cr, Settings.Global.WIFI_SAVED_STATE, 0);
} catch (Settings.SettingNotFoundException e) {
;
}
@@ -514,9 +514,9 @@ public class WifiService extends IWifiManager.Stub {
private int getPersistedWifiState() {
final ContentResolver cr = mContext.getContentResolver();
try {
- return Settings.Secure.getInt(cr, Settings.Secure.WIFI_ON);
+ return Settings.Global.getInt(cr, Settings.Global.WIFI_ON);
} catch (Settings.SettingNotFoundException e) {
- Settings.Secure.putInt(cr, Settings.Secure.WIFI_ON, WIFI_DISABLED);
+ Settings.Global.putInt(cr, Settings.Global.WIFI_ON, WIFI_DISABLED);
return WIFI_DISABLED;
}
}
@@ -564,7 +564,7 @@ public class WifiService extends IWifiManager.Stub {
private void persistWifiState(int state) {
final ContentResolver cr = mContext.getContentResolver();
mPersistWifiState.set(state);
- Settings.Secure.putInt(cr, Settings.Secure.WIFI_ON, state);
+ Settings.Global.putInt(cr, Settings.Global.WIFI_ON, state);
}
/**
@@ -996,11 +996,11 @@ public class WifiService extends IWifiManager.Stub {
String action = intent.getAction();
long idleMillis =
- Settings.Secure.getLong(mContext.getContentResolver(),
- Settings.Secure.WIFI_IDLE_MS, DEFAULT_IDLE_MS);
+ Settings.Global.getLong(mContext.getContentResolver(),
+ Settings.Global.WIFI_IDLE_MS, DEFAULT_IDLE_MS);
int stayAwakeConditions =
- Settings.System.getInt(mContext.getContentResolver(),
- Settings.System.STAY_ON_WHILE_PLUGGED_IN, 0);
+ Settings.Global.getInt(mContext.getContentResolver(),
+ Settings.Global.STAY_ON_WHILE_PLUGGED_IN, 0);
if (action.equals(Intent.ACTION_SCREEN_ON)) {
if (DBG) {
Slog.d(TAG, "ACTION_SCREEN_ON");
@@ -1779,8 +1779,8 @@ public class WifiService extends IWifiManager.Stub {
public void register() {
ContentResolver cr = mContext.getContentResolver();
- cr.registerContentObserver(Settings.Secure.getUriFor(
- Settings.Secure.WIFI_NETWORKS_AVAILABLE_NOTIFICATION_ON), true, this);
+ cr.registerContentObserver(Settings.Global.getUriFor(
+ Settings.Global.WIFI_NETWORKS_AVAILABLE_NOTIFICATION_ON), true, this);
mNotificationEnabled = getValue();
}
@@ -1793,8 +1793,8 @@ public class WifiService extends IWifiManager.Stub {
}
private boolean getValue() {
- return Settings.Secure.getInt(mContext.getContentResolver(),
- Settings.Secure.WIFI_NETWORKS_AVAILABLE_NOTIFICATION_ON, 1) == 1;
+ return Settings.Global.getInt(mContext.getContentResolver(),
+ Settings.Global.WIFI_NETWORKS_AVAILABLE_NOTIFICATION_ON, 1) == 1;
}
}
diff --git a/services/java/com/android/server/accessibility/AccessibilityManagerService.java b/services/java/com/android/server/accessibility/AccessibilityManagerService.java
index 99ec1d2..e7f3599 100644
--- a/services/java/com/android/server/accessibility/AccessibilityManagerService.java
+++ b/services/java/com/android/server/accessibility/AccessibilityManagerService.java
@@ -173,10 +173,6 @@ public class AccessibilityManagerService extends IAccessibilityManager.Stub {
private Service mQueryBridge;
- private boolean mTouchExplorationGestureEnded;
-
- private boolean mTouchExplorationGestureStarted;
-
private AlertDialog mEnableTouchExplorationDialog;
/**
@@ -400,18 +396,6 @@ public class AccessibilityManagerService extends IAccessibilityManager.Stub {
}
public boolean sendAccessibilityEvent(AccessibilityEvent event) {
- final int eventType = event.getEventType();
-
- // The event for gesture start should be strictly before the
- // first hover enter event for the gesture.
- if (eventType == AccessibilityEvent.TYPE_VIEW_HOVER_ENTER
- && mTouchExplorationGestureStarted) {
- mTouchExplorationGestureStarted = false;
- AccessibilityEvent gestureStartEvent = AccessibilityEvent.obtain(
- AccessibilityEvent.TYPE_TOUCH_EXPLORATION_GESTURE_START);
- sendAccessibilityEvent(gestureStartEvent);
- }
-
synchronized (mLock) {
if (mSecurityPolicy.canDispatchAccessibilityEvent(event)) {
mSecurityPolicy.updateActiveWindowAndEventSourceLocked(event);
@@ -421,22 +405,10 @@ public class AccessibilityManagerService extends IAccessibilityManager.Stub {
if (mHasInputFilter && mInputFilter != null) {
mMainHandler.obtainMessage(MSG_SEND_ACCESSIBILITY_EVENT_TO_INPUT_FILTER,
AccessibilityEvent.obtain(event)).sendToTarget();
-
}
event.recycle();
mHandledFeedbackTypes = 0;
}
-
- // The event for gesture end should be strictly after the
- // last hover exit event for the gesture.
- if (eventType == AccessibilityEvent.TYPE_VIEW_HOVER_EXIT
- && mTouchExplorationGestureEnded) {
- mTouchExplorationGestureEnded = false;
- AccessibilityEvent gestureEndEvent = AccessibilityEvent.obtain(
- AccessibilityEvent.TYPE_TOUCH_EXPLORATION_GESTURE_END);
- sendAccessibilityEvent(gestureEndEvent);
- }
-
return (OWN_PROCESS_ID != Binder.getCallingPid());
}
@@ -628,14 +600,6 @@ public class AccessibilityManagerService extends IAccessibilityManager.Stub {
return mQueryBridge;
}
- public void touchExplorationGestureEnded() {
- mTouchExplorationGestureEnded = true;
- }
-
- public void touchExplorationGestureStarted() {
- mTouchExplorationGestureStarted = true;
- }
-
private boolean notifyGestureLocked(int gestureId, boolean isDefault) {
// TODO: Now we are giving the gestures to the last enabled
// service that can handle them which is the last one
diff --git a/services/java/com/android/server/accessibility/TouchExplorer.java b/services/java/com/android/server/accessibility/TouchExplorer.java
index 9e4f33e..cb6b31a 100644
--- a/services/java/com/android/server/accessibility/TouchExplorer.java
+++ b/services/java/com/android/server/accessibility/TouchExplorer.java
@@ -25,6 +25,7 @@ import android.gesture.GestureStore;
import android.gesture.GestureStroke;
import android.gesture.Prediction;
import android.graphics.Rect;
+import android.os.Build;
import android.os.Handler;
import android.os.SystemClock;
import android.util.Slog;
@@ -35,6 +36,7 @@ import android.view.VelocityTracker;
import android.view.ViewConfiguration;
import android.view.WindowManagerPolicy;
import android.view.accessibility.AccessibilityEvent;
+import android.view.accessibility.AccessibilityManager;
import com.android.internal.R;
@@ -168,6 +170,9 @@ class TouchExplorer implements EventStreamTransformation {
// Temporary rectangle to avoid instantiation.
private final Rect mTempRect = new Rect();
+ // Context in which this explorer operates.
+ private final Context mContext;
+
// The X of the previous event.
private float mPreviousX;
@@ -198,6 +203,12 @@ class TouchExplorer implements EventStreamTransformation {
// The id of the last touch explored window.
private int mLastTouchedWindowId;
+ // Whether touch exploration gesture has ended.
+ private boolean mTouchExplorationGestureEnded;
+
+ // Whether touch interaction has ended.
+ private boolean mTouchInteractionEnded;
+
/**
* Creates a new instance.
*
@@ -205,11 +216,12 @@ class TouchExplorer implements EventStreamTransformation {
* @param context A context handle for accessing resources.
*/
public TouchExplorer(Context context, AccessibilityManagerService service) {
+ mContext = context;
mAms = service;
mReceivedPointerTracker = new ReceivedPointerTracker(context);
mInjectedPointerTracker = new InjectedPointerTracker();
mTapTimeout = ViewConfiguration.getTapTimeout();
- mDetermineUserIntentTimeout = (int) (mTapTimeout * 1.5f);
+ mDetermineUserIntentTimeout = ViewConfiguration.getDoubleTapTimeout();
mDoubleTapTimeout = ViewConfiguration.getDoubleTapTimeout();
mTouchSlop = ViewConfiguration.get(context).getScaledTouchSlop();
mDoubleTapSlop = ViewConfiguration.get(context).getScaledDoubleTapSlop();
@@ -317,9 +329,26 @@ class TouchExplorer implements EventStreamTransformation {
}
public void onAccessibilityEvent(AccessibilityEvent event) {
+ final int eventType = event.getEventType();
+
+ // The event for gesture end should be strictly after the
+ // last hover exit event.
+ if (mTouchExplorationGestureEnded
+ && eventType == AccessibilityEvent.TYPE_VIEW_HOVER_EXIT) {
+ mTouchExplorationGestureEnded = false;
+ sendAccessibilityEvent(AccessibilityEvent.TYPE_TOUCH_EXPLORATION_GESTURE_END);
+ }
+
+ // The event for touch interaction end should be strictly after the
+ // last hover exit and the touch exploration gesture end events.
+ if (mTouchInteractionEnded
+ && eventType == AccessibilityEvent.TYPE_VIEW_HOVER_EXIT) {
+ mTouchInteractionEnded = false;
+ sendAccessibilityEvent(AccessibilityEvent.TYPE_TOUCH_INTERACTION_END);
+ }
+
// If a new window opens or the accessibility focus moves we no longer
// want to click/long press on the last touch explored location.
- final int eventType = event.getEventType();
switch (eventType) {
case AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED:
case AccessibilityEvent.TYPE_VIEW_ACCESSIBILITY_FOCUSED: {
@@ -358,6 +387,15 @@ class TouchExplorer implements EventStreamTransformation {
switch (event.getActionMasked()) {
case MotionEvent.ACTION_DOWN:
+ // The delayed enter not delivered implies that we have delivered
+ // TYPE_TOUCH_INTERACTION_START and not TYPE_TOUCH_INTERACTION_END,
+ // therefore we need to deliver the interaction end event here.
+ if (mSendHoverEnterDelayed.isPending()) {
+ sendAccessibilityEvent(AccessibilityEvent.TYPE_TOUCH_INTERACTION_END);
+ }
+ // Announce the start of a new touch interaction.
+ sendAccessibilityEvent(
+ AccessibilityEvent.TYPE_TOUCH_INTERACTION_START);
// Pre-feed the motion events to the gesture detector since we
// have a distance slop before getting into gesture detection
// mode and not using the points within this slop significantly
@@ -396,7 +434,7 @@ class TouchExplorer implements EventStreamTransformation {
// to detect what the user is trying to do.
final int pointerId = receivedTracker.getPrimaryActivePointerId();
final int pointerIdBits = (1 << pointerId);
- mSendHoverEnterDelayed.post(event, pointerIdBits, policyFlags);
+ mSendHoverEnterDelayed.post(event, true, pointerIdBits, policyFlags);
} break;
default: {
/* do nothing - let the code for ACTION_MOVE decide what to do */
@@ -443,6 +481,10 @@ class TouchExplorer implements EventStreamTransformation {
mSendHoverExitDelayed.remove();
mPerformLongPressDelayed.remove();
mExitGestureDetectionModeDelayed.post();
+ // Send accessibility event to announce the start
+ // of gesture recognition.
+ sendAccessibilityEvent(
+ AccessibilityEvent.TYPE_GESTURE_DETECTION_START);
} else {
// We have just decided that the user is touch,
// exploring so start sending events.
@@ -551,7 +593,8 @@ class TouchExplorer implements EventStreamTransformation {
// If we have not delivered the enter schedule exit.
if (mSendHoverEnterDelayed.isPending()) {
- mSendHoverExitDelayed.post(event, pointerIdBits, policyFlags);
+ mSendHoverEnterDelayed.mTouchExplorationInProgress = false;
+ mSendHoverExitDelayed.post(event, false, pointerIdBits, policyFlags);
} else {
// The user is touch exploring so we send events for end.
sendExitEventsIfNeeded(policyFlags);
@@ -656,6 +699,9 @@ class TouchExplorer implements EventStreamTransformation {
}
} break;
case MotionEvent.ACTION_UP: {
+ // Announce the end of a new touch interaction.
+ sendAccessibilityEvent(
+ AccessibilityEvent.TYPE_TOUCH_INTERACTION_END);
mCurrentState = STATE_TOUCH_EXPLORING;
} break;
case MotionEvent.ACTION_CANCEL: {
@@ -687,6 +733,10 @@ class TouchExplorer implements EventStreamTransformation {
}
} break;
case MotionEvent.ACTION_UP:
+ // Announce the end of a new touch interaction.
+ sendAccessibilityEvent(
+ AccessibilityEvent.TYPE_TOUCH_INTERACTION_END);
+ //$FALL-THROUGH$
case MotionEvent.ACTION_POINTER_UP: {
mLongPressingPointerId = -1;
mLongPressingPointerDeltaX = 0;
@@ -725,6 +775,13 @@ class TouchExplorer implements EventStreamTransformation {
}
} break;
case MotionEvent.ACTION_UP: {
+ // Announce the end of gesture recognition.
+ sendAccessibilityEvent(
+ AccessibilityEvent.TYPE_GESTURE_DETECTION_END);
+ // Announce the end of a new touch interaction.
+ sendAccessibilityEvent(
+ AccessibilityEvent.TYPE_TOUCH_INTERACTION_END);
+
float x = event.getX();
float y = event.getY();
mStrokeBuffer.add(new GesturePoint(x, y, event.getEventTime()));
@@ -760,6 +817,19 @@ class TouchExplorer implements EventStreamTransformation {
}
/**
+ * Sends an accessibility event of the given type.
+ *
+ * @param type The event type.
+ */
+ private void sendAccessibilityEvent(int type) {
+ AccessibilityManager accessibilityManager = AccessibilityManager.getInstance(mContext);
+ if (accessibilityManager.isEnabled()) {
+ AccessibilityEvent event = AccessibilityEvent.obtain(type);
+ accessibilityManager.sendAccessibilityEvent(event);
+ }
+ }
+
+ /**
* Sends down events to the view hierarchy for all active pointers which are
* not already being delivered i.e. pointers that are not yet injected.
*
@@ -807,7 +877,8 @@ class TouchExplorer implements EventStreamTransformation {
MotionEvent event = mInjectedPointerTracker.getLastInjectedHoverEvent();
if (event != null && event.getActionMasked() != MotionEvent.ACTION_HOVER_EXIT) {
final int pointerIdBits = event.getPointerIdBits();
- mAms.touchExplorationGestureEnded();
+ mTouchExplorationGestureEnded = true;
+ mTouchInteractionEnded = true;
sendMotionEvent(event, MotionEvent.ACTION_HOVER_EXIT, pointerIdBits, policyFlags);
}
}
@@ -822,7 +893,6 @@ class TouchExplorer implements EventStreamTransformation {
MotionEvent event = mInjectedPointerTracker.getLastInjectedHoverEvent();
if (event != null && event.getActionMasked() == MotionEvent.ACTION_HOVER_EXIT) {
final int pointerIdBits = event.getPointerIdBits();
- mAms.touchExplorationGestureStarted();
sendMotionEvent(event, MotionEvent.ACTION_HOVER_ENTER, pointerIdBits, policyFlags);
}
}
@@ -1080,16 +1150,24 @@ class TouchExplorer implements EventStreamTransformation {
return;
}
+ if (Build.IS_DEBUGGABLE) {
+ if (mSendHoverEnterDelayed.isPending()) {
+ throw new IllegalStateException("mSendHoverEnterDelayed must not be pending.");
+ }
+ if (mSendHoverExitDelayed.isPending()) {
+ throw new IllegalStateException("mSendHoverExitDelayed must not be pending.");
+ }
+ if (!mPerformLongPressDelayed.isPending()) {
+ throw new IllegalStateException(
+ "mPerformLongPressDelayed must not be pending.");
+ }
+ }
+
// Remove pending event deliveries.
- mSendHoverEnterDelayed.remove();
- mSendHoverExitDelayed.remove();
mPerformLongPressDelayed.remove();
- // This is a tap so do not send hover events since
- // this events will result in firing the corresponding
- // accessibility events confusing the user about what
- // is actually clicked.
- sendExitEventsIfNeeded(policyFlags);
+ // The touch interaction has ended since we will send a click.
+ sendAccessibilityEvent(AccessibilityEvent.TYPE_TOUCH_INTERACTION_END);
int clickLocationX;
int clickLocationY;
@@ -1257,13 +1335,13 @@ class TouchExplorer implements EventStreamTransformation {
}
public void remove() {
- if (isPenidng()) {
+ if (isPending()) {
mHandler.removeCallbacks(this);
clear();
}
}
- private boolean isPenidng() {
+ public boolean isPending() {
return (mEvent != null);
}
@@ -1326,7 +1404,7 @@ class TouchExplorer implements EventStreamTransformation {
}
private void clear() {
- if (!isPenidng()) {
+ if (!isPending()) {
return;
}
mEvent.recycle();
@@ -1347,15 +1425,18 @@ class TouchExplorer implements EventStreamTransformation {
private MotionEvent mPrototype;
private int mPointerIdBits;
private int mPolicyFlags;
+ private boolean mTouchExplorationInProgress;
public SendHoverDelayed(int hoverAction, boolean gestureStarted) {
mHoverAction = hoverAction;
mGestureStarted = gestureStarted;
}
- public void post(MotionEvent prototype, int pointerIdBits, int policyFlags) {
+ public void post(MotionEvent prototype, boolean touchExplorationInProgress,
+ int pointerIdBits, int policyFlags) {
remove();
mPrototype = MotionEvent.obtain(prototype);
+ mTouchExplorationInProgress = touchExplorationInProgress;
mPointerIdBits = pointerIdBits;
mPolicyFlags = policyFlags;
mHandler.postDelayed(this, mDetermineUserIntentTimeout);
@@ -1392,6 +1473,7 @@ class TouchExplorer implements EventStreamTransformation {
mPrototype = null;
mPointerIdBits = -1;
mPolicyFlags = 0;
+ mTouchExplorationInProgress = false;
}
public void forceSendAndRemove() {
@@ -1408,10 +1490,17 @@ class TouchExplorer implements EventStreamTransformation {
Slog.d(LOG_TAG_SEND_HOVER_DELAYED, mGestureStarted ?
"touchExplorationGestureStarted" : "touchExplorationGestureEnded");
}
- if (mGestureStarted) {
- mAms.touchExplorationGestureStarted();
+ if (mTouchExplorationInProgress) {
+ if (mGestureStarted) {
+ sendAccessibilityEvent(AccessibilityEvent.TYPE_TOUCH_EXPLORATION_GESTURE_START);
+ } else {
+ mTouchExplorationGestureEnded = true;
+ mTouchInteractionEnded = true;
+ }
} else {
- mAms.touchExplorationGestureEnded();
+ if (!mGestureStarted) {
+ mTouchInteractionEnded = true;
+ }
}
sendMotionEvent(mPrototype, mHoverAction, mPointerIdBits, mPolicyFlags);
clear();
diff --git a/services/java/com/android/server/net/NetworkPolicyManagerService.java b/services/java/com/android/server/net/NetworkPolicyManagerService.java
index 46bddc4..43ddf8d 100644
--- a/services/java/com/android/server/net/NetworkPolicyManagerService.java
+++ b/services/java/com/android/server/net/NetworkPolicyManagerService.java
@@ -24,6 +24,8 @@ import static android.Manifest.permission.READ_NETWORK_USAGE_HISTORY;
import static android.Manifest.permission.READ_PHONE_STATE;
import static android.content.Intent.ACTION_PACKAGE_ADDED;
import static android.content.Intent.ACTION_UID_REMOVED;
+import static android.content.Intent.ACTION_USER_ADDED;
+import static android.content.Intent.ACTION_USER_REMOVED;
import static android.content.Intent.EXTRA_UID;
import static android.net.ConnectivityManager.CONNECTIVITY_ACTION_IMMEDIATE;
import static android.net.ConnectivityManager.TYPE_ETHERNET;
@@ -179,7 +181,8 @@ public class NetworkPolicyManagerService extends INetworkPolicyManager.Stub {
private static final int VERSION_ADDED_INFERRED = 7;
private static final int VERSION_SWITCH_APP_ID = 8;
private static final int VERSION_ADDED_NETWORK_ID = 9;
- private static final int VERSION_LATEST = VERSION_ADDED_NETWORK_ID;
+ private static final int VERSION_SWITCH_UID = 10;
+ private static final int VERSION_LATEST = VERSION_SWITCH_UID;
// @VisibleForTesting
public static final int TYPE_WARNING = 0x1;
@@ -250,8 +253,8 @@ public class NetworkPolicyManagerService extends INetworkPolicyManager.Stub {
/** Currently active network rules for ifaces. */
private HashMap<NetworkPolicy, String[]> mNetworkRules = Maps.newHashMap();
- /** Defined app policies. */
- private SparseIntArray mAppPolicy = new SparseIntArray();
+ /** Defined UID policies. */
+ private SparseIntArray mUidPolicy = new SparseIntArray();
/** Currently derived rules for each UID. */
private SparseIntArray mUidRules = new SparseIntArray();
@@ -357,12 +360,22 @@ public class NetworkPolicyManagerService extends INetworkPolicyManager.Stub {
final IntentFilter connFilter = new IntentFilter(CONNECTIVITY_ACTION_IMMEDIATE);
mContext.registerReceiver(mConnReceiver, connFilter, CONNECTIVITY_INTERNAL, mHandler);
- // listen for package/uid changes to update policy
+ // listen for package changes to update policy
final IntentFilter packageFilter = new IntentFilter();
packageFilter.addAction(ACTION_PACKAGE_ADDED);
- packageFilter.addAction(ACTION_UID_REMOVED);
+ packageFilter.addDataScheme("package");
mContext.registerReceiver(mPackageReceiver, packageFilter, null, mHandler);
+ // listen for UID changes to update policy
+ mContext.registerReceiver(
+ mUidRemovedReceiver, new IntentFilter(ACTION_UID_REMOVED), null, mHandler);
+
+ // listen for user changes to update policy
+ final IntentFilter userFilter = new IntentFilter();
+ userFilter.addAction(ACTION_USER_ADDED);
+ userFilter.addAction(ACTION_USER_REMOVED);
+ mContext.registerReceiver(mUserReceiver, userFilter, null, mHandler);
+
// listen for stats update events
final IntentFilter statsFilter = new IntentFilter(ACTION_NETWORK_STATS_UPDATED);
mContext.registerReceiver(
@@ -421,33 +434,58 @@ public class NetworkPolicyManagerService extends INetworkPolicyManager.Stub {
private BroadcastReceiver mPackageReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
- // on background handler thread, and PACKAGE_ADDED and UID_REMOVED
- // are protected broadcasts.
+ // on background handler thread, and PACKAGE_ADDED is protected
final String action = intent.getAction();
- final int uid = intent.getIntExtra(EXTRA_UID, 0);
- final int appId = UserHandle.getAppId(uid);
+ final int uid = intent.getIntExtra(EXTRA_UID, -1);
+ if (uid == -1) return;
+
+ if (ACTION_PACKAGE_ADDED.equals(action)) {
+ // update rules for UID, since it might be subject to
+ // global background data policy
+ if (LOGV) Slog.v(TAG, "ACTION_PACKAGE_ADDED for uid=" + uid);
+ synchronized (mRulesLock) {
+ updateRulesForUidLocked(uid);
+ }
+ }
+ }
+ };
+
+ private BroadcastReceiver mUidRemovedReceiver = new BroadcastReceiver() {
+ @Override
+ public void onReceive(Context context, Intent intent) {
+ // on background handler thread, and UID_REMOVED is protected
+
+ final int uid = intent.getIntExtra(EXTRA_UID, -1);
+ if (uid == -1) return;
+
+ // remove any policy and update rules to clean up
+ if (LOGV) Slog.v(TAG, "ACTION_UID_REMOVED for uid=" + uid);
synchronized (mRulesLock) {
- if (ACTION_PACKAGE_ADDED.equals(action)) {
- // NOTE: PACKAGE_ADDED is currently only sent once, and is
- // not broadcast when users are added.
+ mUidPolicy.delete(uid);
+ updateRulesForUidLocked(uid);
+ writePolicyLocked();
+ }
+ }
+ };
- // update rules for UID, since it might be subject to
- // global background data policy.
- if (LOGV) Slog.v(TAG, "ACTION_PACKAGE_ADDED for uid=" + uid);
- updateRulesForAppLocked(appId);
+ private BroadcastReceiver mUserReceiver = new BroadcastReceiver() {
+ @Override
+ public void onReceive(Context context, Intent intent) {
+ // on background handler thread, and USER_ADDED and USER_REMOVED
+ // broadcasts are protected
- } else if (ACTION_UID_REMOVED.equals(action)) {
- // NOTE: UID_REMOVED is currently only sent once, and is not
- // broadcast when users are removed.
+ final String action = intent.getAction();
+ final int userId = intent.getIntExtra(Intent.EXTRA_USER_HANDLE, -1);
+ if (userId == -1) return;
- // remove any policy and update rules to clean up.
- if (LOGV) Slog.v(TAG, "ACTION_UID_REMOVED for uid=" + uid);
+ // Remove any policies for given user; both cleaning up after a
+ // USER_REMOVED, and one last sanity check during USER_ADDED
+ removePoliciesForUserLocked(userId);
- mAppPolicy.delete(appId);
- updateRulesForAppLocked(appId);
- writePolicyLocked();
- }
+ // Update global restrict for new user
+ synchronized (mRulesLock) {
+ updateRulesForRestrictBackgroundLocked();
}
}
};
@@ -1107,7 +1145,7 @@ public class NetworkPolicyManagerService extends INetworkPolicyManager.Stub {
// clear any existing policy and read from disk
mNetworkPolicy.clear();
- mAppPolicy.clear();
+ mUidPolicy.clear();
FileInputStream fis = null;
try {
@@ -1188,24 +1226,25 @@ public class NetworkPolicyManagerService extends INetworkPolicyManager.Stub {
cycleTimezone, warningBytes, limitBytes, lastWarningSnooze,
lastLimitSnooze, metered, inferred));
- } else if (TAG_UID_POLICY.equals(tag) && version < VERSION_SWITCH_APP_ID) {
+ } else if (TAG_UID_POLICY.equals(tag)) {
final int uid = readIntAttribute(in, ATTR_UID);
final int policy = readIntAttribute(in, ATTR_POLICY);
- final int appId = UserHandle.getAppId(uid);
- if (UserHandle.isApp(appId)) {
- setAppPolicyUnchecked(appId, policy, false);
+ if (UserHandle.isApp(uid)) {
+ setUidPolicyUnchecked(uid, policy, false);
} else {
Slog.w(TAG, "unable to apply policy to UID " + uid + "; ignoring");
}
- } else if (TAG_APP_POLICY.equals(tag) && version >= VERSION_SWITCH_APP_ID) {
+ } else if (TAG_APP_POLICY.equals(tag)) {
final int appId = readIntAttribute(in, ATTR_APP_ID);
final int policy = readIntAttribute(in, ATTR_POLICY);
- if (UserHandle.isApp(appId)) {
- setAppPolicyUnchecked(appId, policy, false);
+ // TODO: set for other users during upgrade
+ final int uid = UserHandle.getUid(UserHandle.USER_OWNER, appId);
+ if (UserHandle.isApp(uid)) {
+ setUidPolicyUnchecked(uid, policy, false);
} else {
- Slog.w(TAG, "unable to apply policy to appId " + appId + "; ignoring");
+ Slog.w(TAG, "unable to apply policy to UID " + uid + "; ignoring");
}
}
}
@@ -1280,17 +1319,17 @@ public class NetworkPolicyManagerService extends INetworkPolicyManager.Stub {
}
// write all known uid policies
- for (int i = 0; i < mAppPolicy.size(); i++) {
- final int appId = mAppPolicy.keyAt(i);
- final int policy = mAppPolicy.valueAt(i);
+ for (int i = 0; i < mUidPolicy.size(); i++) {
+ final int uid = mUidPolicy.keyAt(i);
+ final int policy = mUidPolicy.valueAt(i);
// skip writing empty policies
if (policy == POLICY_NONE) continue;
- out.startTag(null, TAG_APP_POLICY);
- writeIntAttribute(out, ATTR_APP_ID, appId);
+ out.startTag(null, TAG_UID_POLICY);
+ writeIntAttribute(out, ATTR_UID, uid);
writeIntAttribute(out, ATTR_POLICY, policy);
- out.endTag(null, TAG_APP_POLICY);
+ out.endTag(null, TAG_UID_POLICY);
}
out.endTag(null, TAG_POLICY_LIST);
@@ -1305,24 +1344,24 @@ public class NetworkPolicyManagerService extends INetworkPolicyManager.Stub {
}
@Override
- public void setAppPolicy(int appId, int policy) {
+ public void setUidPolicy(int uid, int policy) {
mContext.enforceCallingOrSelfPermission(MANAGE_NETWORK_POLICY, TAG);
- if (!UserHandle.isApp(appId)) {
- throw new IllegalArgumentException("cannot apply policy to appId " + appId);
+ if (!UserHandle.isApp(uid)) {
+ throw new IllegalArgumentException("cannot apply policy to UID " + uid);
}
- setAppPolicyUnchecked(appId, policy, true);
+ setUidPolicyUnchecked(uid, policy, true);
}
- private void setAppPolicyUnchecked(int appId, int policy, boolean persist) {
+ private void setUidPolicyUnchecked(int uid, int policy, boolean persist) {
final int oldPolicy;
synchronized (mRulesLock) {
- oldPolicy = getAppPolicy(appId);
- mAppPolicy.put(appId, policy);
+ oldPolicy = getUidPolicy(uid);
+ mUidPolicy.put(uid, policy);
// uid policy changed, recompute rules and persist policy.
- updateRulesForAppLocked(appId);
+ updateRulesForUidLocked(uid);
if (persist) {
writePolicyLocked();
}
@@ -1330,29 +1369,53 @@ public class NetworkPolicyManagerService extends INetworkPolicyManager.Stub {
}
@Override
- public int getAppPolicy(int appId) {
+ public int getUidPolicy(int uid) {
mContext.enforceCallingOrSelfPermission(MANAGE_NETWORK_POLICY, TAG);
synchronized (mRulesLock) {
- return mAppPolicy.get(appId, POLICY_NONE);
+ return mUidPolicy.get(uid, POLICY_NONE);
}
}
@Override
- public int[] getAppsWithPolicy(int policy) {
+ public int[] getUidsWithPolicy(int policy) {
mContext.enforceCallingOrSelfPermission(MANAGE_NETWORK_POLICY, TAG);
- int[] appIds = new int[0];
+ int[] uids = new int[0];
synchronized (mRulesLock) {
- for (int i = 0; i < mAppPolicy.size(); i++) {
- final int appId = mAppPolicy.keyAt(i);
- final int appPolicy = mAppPolicy.valueAt(i);
- if (appPolicy == policy) {
- appIds = appendInt(appIds, appId);
+ for (int i = 0; i < mUidPolicy.size(); i++) {
+ final int uid = mUidPolicy.keyAt(i);
+ final int uidPolicy = mUidPolicy.valueAt(i);
+ if (uidPolicy == policy) {
+ uids = appendInt(uids, uid);
}
}
}
- return appIds;
+ return uids;
+ }
+
+ /**
+ * Remove any policies associated with given {@link UserHandle}, persisting
+ * if any changes are made.
+ */
+ private void removePoliciesForUserLocked(int userId) {
+ if (LOGV) Slog.v(TAG, "removePoliciesForUserLocked()");
+
+ int[] uids = new int[0];
+ for (int i = 0; i < mUidPolicy.size(); i++) {
+ final int uid = mUidPolicy.keyAt(i);
+ if (UserHandle.getUserId(uid) == userId) {
+ uids = appendInt(uids, uid);
+ }
+ }
+
+ if (uids.length > 0) {
+ for (int uid : uids) {
+ mUidPolicy.delete(uid);
+ updateRulesForUidLocked(uid);
+ }
+ writePolicyLocked();
+ }
}
@Override
@@ -1586,14 +1649,14 @@ public class NetworkPolicyManagerService extends INetworkPolicyManager.Stub {
}
fout.decreaseIndent();
- fout.println("Policy for apps:");
+ fout.println("Policy for UIDs:");
fout.increaseIndent();
- int size = mAppPolicy.size();
+ int size = mUidPolicy.size();
for (int i = 0; i < size; i++) {
- final int appId = mAppPolicy.keyAt(i);
- final int policy = mAppPolicy.valueAt(i);
- fout.print("appId=");
- fout.print(appId);
+ final int uid = mUidPolicy.keyAt(i);
+ final int policy = mUidPolicy.valueAt(i);
+ fout.print("UID=");
+ fout.print(uid);
fout.print(" policy=");
dumpPolicy(fout, policy);
fout.println();
@@ -1698,12 +1761,19 @@ public class NetworkPolicyManagerService extends INetworkPolicyManager.Stub {
* Update rules that might be changed by {@link #mRestrictBackground} value.
*/
private void updateRulesForRestrictBackgroundLocked() {
- // update rules for all installed applications
final PackageManager pm = mContext.getPackageManager();
- final List<ApplicationInfo> apps = pm.getInstalledApplications(0);
- for (ApplicationInfo app : apps) {
- final int appId = UserHandle.getAppId(app.uid);
- updateRulesForAppLocked(appId);
+ final UserManager um = (UserManager) mContext.getSystemService(Context.USER_SERVICE);
+
+ // update rules for all installed applications
+ final List<UserInfo> users = um.getUsers();
+ final List<ApplicationInfo> apps = pm.getInstalledApplications(
+ PackageManager.GET_UNINSTALLED_PACKAGES | PackageManager.GET_DISABLED_COMPONENTS);
+
+ for (UserInfo user : users) {
+ for (ApplicationInfo app : apps) {
+ final int uid = UserHandle.getUid(user.id, app.uid);
+ updateRulesForUidLocked(uid);
+ }
}
// limit data usage for some internal system services
@@ -1711,14 +1781,6 @@ public class NetworkPolicyManagerService extends INetworkPolicyManager.Stub {
updateRulesForUidLocked(android.os.Process.DRM_UID);
}
- private void updateRulesForAppLocked(int appId) {
- UserManager um = (UserManager) mContext.getSystemService(Context.USER_SERVICE);
- for (UserInfo user : um.getUsers()) {
- final int uid = UserHandle.getUid(user.id, appId);
- updateRulesForUidLocked(uid);
- }
- }
-
private static boolean isUidValidForRules(int uid) {
// allow rules on specific system services, and any apps
if (uid == android.os.Process.MEDIA_UID || uid == android.os.Process.DRM_UID
@@ -1732,13 +1794,12 @@ public class NetworkPolicyManagerService extends INetworkPolicyManager.Stub {
private void updateRulesForUidLocked(int uid) {
if (!isUidValidForRules(uid)) return;
- final int appId = UserHandle.getAppId(uid);
- final int appPolicy = getAppPolicy(appId);
+ final int uidPolicy = getUidPolicy(uid);
final boolean uidForeground = isUidForeground(uid);
// derive active rules based on policy and active state
int uidRules = RULE_ALLOW_ALL;
- if (!uidForeground && (appPolicy & POLICY_REJECT_METERED_BACKGROUND) != 0) {
+ if (!uidForeground && (uidPolicy & POLICY_REJECT_METERED_BACKGROUND) != 0) {
// uid in background, and policy says to block metered data
uidRules = RULE_REJECT_METERED;
}
diff --git a/services/java/com/android/server/net/NetworkStatsService.java b/services/java/com/android/server/net/NetworkStatsService.java
index f2d2fb7..3a593e4 100644
--- a/services/java/com/android/server/net/NetworkStatsService.java
+++ b/services/java/com/android/server/net/NetworkStatsService.java
@@ -38,23 +38,23 @@ import static android.net.NetworkTemplate.buildTemplateMobileWildcard;
import static android.net.NetworkTemplate.buildTemplateWifiWildcard;
import static android.net.TrafficStats.KB_IN_BYTES;
import static android.net.TrafficStats.MB_IN_BYTES;
-import static android.provider.Settings.Secure.NETSTATS_DEV_BUCKET_DURATION;
-import static android.provider.Settings.Secure.NETSTATS_DEV_DELETE_AGE;
-import static android.provider.Settings.Secure.NETSTATS_DEV_PERSIST_BYTES;
-import static android.provider.Settings.Secure.NETSTATS_DEV_ROTATE_AGE;
-import static android.provider.Settings.Secure.NETSTATS_GLOBAL_ALERT_BYTES;
-import static android.provider.Settings.Secure.NETSTATS_POLL_INTERVAL;
-import static android.provider.Settings.Secure.NETSTATS_REPORT_XT_OVER_DEV;
-import static android.provider.Settings.Secure.NETSTATS_SAMPLE_ENABLED;
-import static android.provider.Settings.Secure.NETSTATS_TIME_CACHE_MAX_AGE;
-import static android.provider.Settings.Secure.NETSTATS_UID_BUCKET_DURATION;
-import static android.provider.Settings.Secure.NETSTATS_UID_DELETE_AGE;
-import static android.provider.Settings.Secure.NETSTATS_UID_PERSIST_BYTES;
-import static android.provider.Settings.Secure.NETSTATS_UID_ROTATE_AGE;
-import static android.provider.Settings.Secure.NETSTATS_UID_TAG_BUCKET_DURATION;
-import static android.provider.Settings.Secure.NETSTATS_UID_TAG_DELETE_AGE;
-import static android.provider.Settings.Secure.NETSTATS_UID_TAG_PERSIST_BYTES;
-import static android.provider.Settings.Secure.NETSTATS_UID_TAG_ROTATE_AGE;
+import static android.provider.Settings.Global.NETSTATS_DEV_BUCKET_DURATION;
+import static android.provider.Settings.Global.NETSTATS_DEV_DELETE_AGE;
+import static android.provider.Settings.Global.NETSTATS_DEV_PERSIST_BYTES;
+import static android.provider.Settings.Global.NETSTATS_DEV_ROTATE_AGE;
+import static android.provider.Settings.Global.NETSTATS_GLOBAL_ALERT_BYTES;
+import static android.provider.Settings.Global.NETSTATS_POLL_INTERVAL;
+import static android.provider.Settings.Global.NETSTATS_REPORT_XT_OVER_DEV;
+import static android.provider.Settings.Global.NETSTATS_SAMPLE_ENABLED;
+import static android.provider.Settings.Global.NETSTATS_TIME_CACHE_MAX_AGE;
+import static android.provider.Settings.Global.NETSTATS_UID_BUCKET_DURATION;
+import static android.provider.Settings.Global.NETSTATS_UID_DELETE_AGE;
+import static android.provider.Settings.Global.NETSTATS_UID_PERSIST_BYTES;
+import static android.provider.Settings.Global.NETSTATS_UID_ROTATE_AGE;
+import static android.provider.Settings.Global.NETSTATS_UID_TAG_BUCKET_DURATION;
+import static android.provider.Settings.Global.NETSTATS_UID_TAG_DELETE_AGE;
+import static android.provider.Settings.Global.NETSTATS_UID_TAG_PERSIST_BYTES;
+import static android.provider.Settings.Global.NETSTATS_UID_TAG_ROTATE_AGE;
import static android.telephony.PhoneStateListener.LISTEN_DATA_CONNECTION_STATE;
import static android.telephony.PhoneStateListener.LISTEN_NONE;
import static android.text.format.DateUtils.DAY_IN_MILLIS;
@@ -1218,39 +1218,39 @@ public class NetworkStatsService extends INetworkStatsService.Stub {
// TODO: adjust these timings for production builds
}
- private long getSecureLong(String name, long def) {
- return Settings.Secure.getLong(mResolver, name, def);
+ private long getGlobalLong(String name, long def) {
+ return Settings.Global.getLong(mResolver, name, def);
}
- private boolean getSecureBoolean(String name, boolean def) {
+ private boolean getGlobalBoolean(String name, boolean def) {
final int defInt = def ? 1 : 0;
- return Settings.Secure.getInt(mResolver, name, defInt) != 0;
+ return Settings.Global.getInt(mResolver, name, defInt) != 0;
}
@Override
public long getPollInterval() {
- return getSecureLong(NETSTATS_POLL_INTERVAL, 30 * MINUTE_IN_MILLIS);
+ return getGlobalLong(NETSTATS_POLL_INTERVAL, 30 * MINUTE_IN_MILLIS);
}
@Override
public long getTimeCacheMaxAge() {
- return getSecureLong(NETSTATS_TIME_CACHE_MAX_AGE, DAY_IN_MILLIS);
+ return getGlobalLong(NETSTATS_TIME_CACHE_MAX_AGE, DAY_IN_MILLIS);
}
@Override
public long getGlobalAlertBytes(long def) {
- return getSecureLong(NETSTATS_GLOBAL_ALERT_BYTES, def);
+ return getGlobalLong(NETSTATS_GLOBAL_ALERT_BYTES, def);
}
@Override
public boolean getSampleEnabled() {
- return getSecureBoolean(NETSTATS_SAMPLE_ENABLED, true);
+ return getGlobalBoolean(NETSTATS_SAMPLE_ENABLED, true);
}
@Override
public boolean getReportXtOverDev() {
- return getSecureBoolean(NETSTATS_REPORT_XT_OVER_DEV, true);
+ return getGlobalBoolean(NETSTATS_REPORT_XT_OVER_DEV, true);
}
@Override
public Config getDevConfig() {
- return new Config(getSecureLong(NETSTATS_DEV_BUCKET_DURATION, HOUR_IN_MILLIS),
- getSecureLong(NETSTATS_DEV_ROTATE_AGE, 15 * DAY_IN_MILLIS),
- getSecureLong(NETSTATS_DEV_DELETE_AGE, 90 * DAY_IN_MILLIS));
+ return new Config(getGlobalLong(NETSTATS_DEV_BUCKET_DURATION, HOUR_IN_MILLIS),
+ getGlobalLong(NETSTATS_DEV_ROTATE_AGE, 15 * DAY_IN_MILLIS),
+ getGlobalLong(NETSTATS_DEV_DELETE_AGE, 90 * DAY_IN_MILLIS));
}
@Override
public Config getXtConfig() {
@@ -1258,19 +1258,19 @@ public class NetworkStatsService extends INetworkStatsService.Stub {
}
@Override
public Config getUidConfig() {
- return new Config(getSecureLong(NETSTATS_UID_BUCKET_DURATION, 2 * HOUR_IN_MILLIS),
- getSecureLong(NETSTATS_UID_ROTATE_AGE, 15 * DAY_IN_MILLIS),
- getSecureLong(NETSTATS_UID_DELETE_AGE, 90 * DAY_IN_MILLIS));
+ return new Config(getGlobalLong(NETSTATS_UID_BUCKET_DURATION, 2 * HOUR_IN_MILLIS),
+ getGlobalLong(NETSTATS_UID_ROTATE_AGE, 15 * DAY_IN_MILLIS),
+ getGlobalLong(NETSTATS_UID_DELETE_AGE, 90 * DAY_IN_MILLIS));
}
@Override
public Config getUidTagConfig() {
- return new Config(getSecureLong(NETSTATS_UID_TAG_BUCKET_DURATION, 2 * HOUR_IN_MILLIS),
- getSecureLong(NETSTATS_UID_TAG_ROTATE_AGE, 5 * DAY_IN_MILLIS),
- getSecureLong(NETSTATS_UID_TAG_DELETE_AGE, 15 * DAY_IN_MILLIS));
+ return new Config(getGlobalLong(NETSTATS_UID_TAG_BUCKET_DURATION, 2 * HOUR_IN_MILLIS),
+ getGlobalLong(NETSTATS_UID_TAG_ROTATE_AGE, 5 * DAY_IN_MILLIS),
+ getGlobalLong(NETSTATS_UID_TAG_DELETE_AGE, 15 * DAY_IN_MILLIS));
}
@Override
public long getDevPersistBytes(long def) {
- return getSecureLong(NETSTATS_DEV_PERSIST_BYTES, def);
+ return getGlobalLong(NETSTATS_DEV_PERSIST_BYTES, def);
}
@Override
public long getXtPersistBytes(long def) {
@@ -1278,11 +1278,11 @@ public class NetworkStatsService extends INetworkStatsService.Stub {
}
@Override
public long getUidPersistBytes(long def) {
- return getSecureLong(NETSTATS_UID_PERSIST_BYTES, def);
+ return getGlobalLong(NETSTATS_UID_PERSIST_BYTES, def);
}
@Override
public long getUidTagPersistBytes(long def) {
- return getSecureLong(NETSTATS_UID_TAG_PERSIST_BYTES, def);
+ return getGlobalLong(NETSTATS_UID_TAG_PERSIST_BYTES, def);
}
}
}
diff --git a/services/java/com/android/server/pm/PackageManagerService.java b/services/java/com/android/server/pm/PackageManagerService.java
index fe5889d..2ef1f9e 100644
--- a/services/java/com/android/server/pm/PackageManagerService.java
+++ b/services/java/com/android/server/pm/PackageManagerService.java
@@ -5664,6 +5664,8 @@ public class PackageManagerService extends IPackageManager.Stub {
filteredFlags = flags & ~PackageManager.INSTALL_FROM_ADB;
}
+ verificationParams.setInstallerUid(uid);
+
final Message msg = mHandler.obtainMessage(INIT_COPY);
msg.obj = new InstallParams(packageURI, observer, filteredFlags, installerPackageName,
verificationParams, encryptionParams, user);
@@ -5902,9 +5904,12 @@ public class PackageManagerService extends IPackageManager.Stub {
* @return true if verification should be performed
*/
private boolean isVerificationEnabled() {
+ if (!DEFAULT_VERIFY_ENABLE) {
+ return false;
+ }
+
return android.provider.Settings.Global.getInt(mContext.getContentResolver(),
- android.provider.Settings.Global.PACKAGE_VERIFIER_ENABLE,
- DEFAULT_VERIFY_ENABLE ? 1 : 0) == 1 ? true : false;
+ android.provider.Settings.Global.PACKAGE_VERIFIER_ENABLE, 1) == 1;
}
/**
@@ -6334,7 +6339,8 @@ public class PackageManagerService extends IPackageManager.Stub {
packageFile = mTempPackage;
FileUtils.setPermissions(packageFile.getAbsolutePath(),
- FileUtils.S_IRUSR | FileUtils.S_IWUSR | FileUtils.S_IROTH,
+ FileUtils.S_IRUSR | FileUtils.S_IWUSR | FileUtils.S_IRGRP
+ | FileUtils.S_IROTH,
-1, -1);
} else {
packageFile = null;
@@ -6424,6 +6430,12 @@ public class PackageManagerService extends IPackageManager.Stub {
verification.putExtra(PackageManager.EXTRA_VERIFICATION_INSTALL_FLAGS, flags);
+ verification.putExtra(PackageManager.EXTRA_VERIFICATION_PACKAGE_NAME,
+ pkgLite.packageName);
+
+ verification.putExtra(PackageManager.EXTRA_VERIFICATION_VERSION_CODE,
+ pkgLite.versionCode);
+
if (verificationParams != null) {
if (verificationParams.getVerificationURI() != null) {
verification.putExtra(PackageManager.EXTRA_VERIFICATION_URI,
@@ -6437,6 +6449,10 @@ public class PackageManagerService extends IPackageManager.Stub {
verification.putExtra(Intent.EXTRA_REFERRER,
verificationParams.getReferrer());
}
+ if (verificationParams.getInstallerUid() >= 0) {
+ verification.putExtra(PackageManager.EXTRA_VERIFICATION_INSTALLER_UID,
+ verificationParams.getInstallerUid());
+ }
}
final PackageVerificationState verificationState = new PackageVerificationState(
@@ -6515,12 +6531,12 @@ public class PackageManagerService extends IPackageManager.Stub {
// will succeed.
if (mArgs != null) {
processPendingInstall(mArgs, mRet);
- }
- if (mTempPackage != null) {
- if (!mTempPackage.delete()) {
- Slog.w(TAG, "Couldn't delete temporary file: "
- + mTempPackage.getAbsolutePath());
+ if (mTempPackage != null) {
+ if (!mTempPackage.delete()) {
+ Slog.w(TAG, "Couldn't delete temporary file: " +
+ mTempPackage.getAbsolutePath());
+ }
}
}
}
@@ -7942,17 +7958,23 @@ public class PackageManagerService extends IPackageManager.Stub {
}
private void deleteTempPackageFiles() {
- FilenameFilter filter = new FilenameFilter() {
+ final FilenameFilter filter = new FilenameFilter() {
public boolean accept(File dir, String name) {
return name.startsWith("vmdl") && name.endsWith(".tmp");
}
};
- String tmpFilesList[] = mAppInstallDir.list(filter);
- if(tmpFilesList == null) {
+ deleteTempPackageFilesInDirectory(mAppInstallDir, filter);
+ deleteTempPackageFilesInDirectory(mDrmAppPrivateInstallDir, filter);
+ }
+
+ private static final void deleteTempPackageFilesInDirectory(File directory,
+ FilenameFilter filter) {
+ final String[] tmpFilesList = directory.list(filter);
+ if (tmpFilesList == null) {
return;
}
- for(int i = 0; i < tmpFilesList.length; i++) {
- File tmpFile = new File(mAppInstallDir, tmpFilesList[i]);
+ for (int i = 0; i < tmpFilesList.length; i++) {
+ final File tmpFile = new File(directory, tmpFilesList[i]);
tmpFile.delete();
}
}
diff --git a/services/java/com/android/server/wm/DisplayContent.java b/services/java/com/android/server/wm/DisplayContent.java
index 4df692b..d1742ff 100644
--- a/services/java/com/android/server/wm/DisplayContent.java
+++ b/services/java/com/android/server/wm/DisplayContent.java
@@ -124,7 +124,9 @@ class DisplayContent {
pw.print("-"); pw.print(mDisplayInfo.largestNominalAppWidth);
pw.print("x"); pw.println(mDisplayInfo.largestNominalAppHeight);
pw.print(" layoutNeeded="); pw.println(layoutNeeded);
- pw.print("magnificationSpec="); pw.println(mMagnificationSpec);
+ if (mMagnificationSpec != null) {
+ pw.print(" mMagnificationSpec="); pw.println(mMagnificationSpec);
+ }
pw.println();
}
}