summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--core/java/android/widget/Editor.java115
-rw-r--r--core/java/com/android/internal/logging/MetricsConstants.java1
-rw-r--r--core/res/AndroidManifest.xml2
-rw-r--r--services/core/java/com/android/server/am/RecentTasks.java11
-rw-r--r--services/core/java/com/android/server/pm/PermissionsState.java4
-rw-r--r--services/core/java/com/android/server/pm/Settings.java173
6 files changed, 154 insertions, 152 deletions
diff --git a/core/java/android/widget/Editor.java b/core/java/android/widget/Editor.java
index 34620e6..19184d6 100644
--- a/core/java/android/widget/Editor.java
+++ b/core/java/android/widget/Editor.java
@@ -3495,6 +3495,10 @@ public class Editor {
mIdealVerticalOffset = 0.7f * handleHeight;
}
+ public float getIdealVerticalOffset() {
+ return mIdealVerticalOffset;
+ }
+
protected void updateDrawable() {
final int offset = getCurrentCursorOffset();
final boolean isRtlCharAtOffset = mTextView.getLayout().isRtlCharAt(offset);
@@ -4279,6 +4283,7 @@ public class Editor {
private int mStartOffset = -1;
// Indicates whether the user is selecting text and using the drag accelerator.
private boolean mDragAcceleratorActive;
+ private boolean mHaventMovedEnoughToStartDrag;
SelectionModifierCursorController() {
resetTouchOffsets();
@@ -4343,19 +4348,20 @@ public class Editor {
public void onTouchEvent(MotionEvent event) {
// This is done even when the View does not have focus, so that long presses can start
// selection and tap can move cursor from this tap position.
+ final float eventX = event.getX();
+ final float eventY = event.getY();
switch (event.getActionMasked()) {
case MotionEvent.ACTION_DOWN:
- final float x = event.getX();
- final float y = event.getY();
// Remember finger down position, to be able to start selection from there.
- mMinTouchOffset = mMaxTouchOffset = mTextView.getOffsetForPosition(x, y);
+ mMinTouchOffset = mMaxTouchOffset = mTextView.getOffsetForPosition(
+ eventX, eventY);
// Double tap detection
if (mGestureStayedInTapRegion) {
if (mDoubleTap) {
- final float deltaX = x - mDownPositionX;
- final float deltaY = y - mDownPositionY;
+ final float deltaX = eventX - mDownPositionX;
+ final float deltaY = eventY - mDownPositionY;
final float distanceSquared = deltaX * deltaX + deltaY * deltaY;
ViewConfiguration viewConfiguration = ViewConfiguration.get(
@@ -4363,16 +4369,17 @@ public class Editor {
int doubleTapSlop = viewConfiguration.getScaledDoubleTapSlop();
boolean stayedInArea = distanceSquared < doubleTapSlop * doubleTapSlop;
- if (stayedInArea && isPositionOnText(x, y)) {
+ if (stayedInArea && isPositionOnText(eventX, eventY)) {
startSelectionActionModeWithSelectionAndStartDrag();
mDiscardNextActionUp = true;
}
}
}
- mDownPositionX = x;
- mDownPositionY = y;
+ mDownPositionX = eventX;
+ mDownPositionY = eventY;
mGestureStayedInTapRegion = true;
+ mHaventMovedEnoughToStartDrag = true;
break;
case MotionEvent.ACTION_POINTER_DOWN:
@@ -4386,18 +4393,24 @@ public class Editor {
break;
case MotionEvent.ACTION_MOVE:
- final ViewConfiguration viewConfiguration = ViewConfiguration.get(
+ final ViewConfiguration viewConfig = ViewConfiguration.get(
mTextView.getContext());
+ final int touchSlop = viewConfig.getScaledTouchSlop();
- if (mGestureStayedInTapRegion) {
- final float deltaX = event.getX() - mDownPositionX;
- final float deltaY = event.getY() - mDownPositionY;
+ if (mGestureStayedInTapRegion || mHaventMovedEnoughToStartDrag) {
+ final float deltaX = eventX - mDownPositionX;
+ final float deltaY = eventY - mDownPositionY;
final float distanceSquared = deltaX * deltaX + deltaY * deltaY;
- int doubleTapTouchSlop = viewConfiguration.getScaledDoubleTapTouchSlop();
-
- if (distanceSquared > doubleTapTouchSlop * doubleTapTouchSlop) {
- mGestureStayedInTapRegion = false;
+ if (mGestureStayedInTapRegion) {
+ int doubleTapTouchSlop = viewConfig.getScaledDoubleTapTouchSlop();
+ mGestureStayedInTapRegion =
+ distanceSquared <= doubleTapTouchSlop * doubleTapTouchSlop;
+ }
+ if (mHaventMovedEnoughToStartDrag) {
+ // We don't start dragging until the user has moved enough.
+ mHaventMovedEnoughToStartDrag =
+ distanceSquared <= touchSlop * touchSlop;
}
}
@@ -4407,56 +4420,28 @@ public class Editor {
}
if (mStartOffset != -1) {
- final int rawOffset = mTextView.getOffsetForPosition(event.getX(),
- event.getY());
- int offset = rawOffset;
-
- // We don't start "dragging" until the user is past the initial word that
- // gets selected on long press.
- int firstWordStart = getWordStart(mStartOffset);
- int firstWordEnd = getWordEnd(mStartOffset);
- if (offset > firstWordEnd || offset < firstWordStart) {
-
- // Basically the goal in the below code is to have the highlight be
- // offset so that your finger isn't covering the end point.
- int fingerOffset = viewConfiguration.getScaledTouchSlop();
- float mx = event.getX();
- float my = event.getY();
- if (mx > fingerOffset) mx -= fingerOffset;
- if (my > fingerOffset) my -= fingerOffset;
- offset = mTextView.getOffsetForPosition(mx, my);
-
- // Perform the check for closeness at edge of view, if we're very close
- // don't adjust the offset to be in front of the finger - otherwise the
- // user can't select words at the edge.
- if (mTextView.getWidth() - fingerOffset > mx) {
- // We're going by word, so we need to make sure that the offset
- // that we get is within this, so we'll get the previous boundary.
- final WordIterator wordIterator = getWordIteratorWithText();
-
- final int precedingOffset = wordIterator.preceding(offset);
- if (mStartOffset < offset) {
- // Expanding with bottom handle, in this case the selection end
- // is before the finger.
- offset = Math.max(precedingOffset - 1, 0);
- } else {
- // Expand with the start handle, in this case the selection
- // start is before the finger.
- if (precedingOffset == WordIterator.DONE) {
- offset = 0;
- } else {
- offset = wordIterator.preceding(precedingOffset);
- }
- }
+ if (!mHaventMovedEnoughToStartDrag) {
+ // Offset the finger by the same vertical offset as the handles. This
+ // improves visibility of the content being selected by shifting
+ // the finger below the content.
+ final float fingerOffset = (mStartHandle != null)
+ ? mStartHandle.getIdealVerticalOffset()
+ : touchSlop;
+ int offset =
+ mTextView.getOffsetForPosition(eventX, eventY - fingerOffset);
+ int startOffset;
+ // Snap to word boundaries.
+ if (mStartOffset < offset) {
+ // Expanding with end handle.
+ offset = getWordEnd(offset);
+ startOffset = getWordStart(mStartOffset);
+ } else {
+ // Expanding with start handle.
+ offset = getWordStart(offset);
+ startOffset = getWordEnd(mStartOffset);
}
- if (offset == WordIterator.DONE)
- offset = rawOffset;
-
- // Need to adjust start offset based on direction of movement.
- int newStart = mStartOffset < offset ? getWordStart(mStartOffset)
- : getWordEnd(mStartOffset);
- Selection.setSelection((Spannable) mTextView.getText(), newStart,
- offset);
+ Selection.setSelection((Spannable) mTextView.getText(),
+ startOffset, offset);
}
}
break;
diff --git a/core/java/com/android/internal/logging/MetricsConstants.java b/core/java/com/android/internal/logging/MetricsConstants.java
index b9a75d3..65dc743 100644
--- a/core/java/com/android/internal/logging/MetricsConstants.java
+++ b/core/java/com/android/internal/logging/MetricsConstants.java
@@ -208,7 +208,6 @@ public interface MetricsConstants {
public static final int APPLICATIONS_USAGE_ACCESS_DETAIL = 183;
public static final int APPLICATIONS_HIGH_POWER_APPS = 184;
public static final int FUELGAUGE_HIGH_POWER_DETAILS = 185;
- public static final int APPLICATIONS_MANAGE_ASSIST = 186;
//aliases
public static final int DEVICEINFO_STORAGE = DEVICEINFO_MEMORY;
diff --git a/core/res/AndroidManifest.xml b/core/res/AndroidManifest.xml
index 595f9f0..4f451c7 100644
--- a/core/res/AndroidManifest.xml
+++ b/core/res/AndroidManifest.xml
@@ -681,7 +681,7 @@
android:permissionGroup="android.permission-group.SENSORS"
android:label="@string/permlab_useFingerprint"
android:description="@string/permdesc_useFingerprint"
- android:protectionLevel="dangerous" />
+ android:protectionLevel="normal" />
<!-- ====================================================================== -->
<!-- INSTALLTIME PERMISSIONS -->
diff --git a/services/core/java/com/android/server/am/RecentTasks.java b/services/core/java/com/android/server/am/RecentTasks.java
index 3a20ded..9f11def 100644
--- a/services/core/java/com/android/server/am/RecentTasks.java
+++ b/services/core/java/com/android/server/am/RecentTasks.java
@@ -435,9 +435,7 @@ class RecentTasks extends ArrayList<TaskRecord> {
*/
int trimForTaskLocked(TaskRecord task, boolean doTrim) {
int recentsCount = size();
- final Intent intent = task.intent;
- final boolean document = intent != null && intent.isDocument();
-
+ final boolean document = task.intent != null && task.intent.isDocument();
int maxRecents = task.maxRecents - 1;
for (int i = 0; i < recentsCount; i++) {
final TaskRecord tr = get(i);
@@ -448,12 +446,11 @@ class RecentTasks extends ArrayList<TaskRecord> {
if (i > MAX_RECENT_BITMAPS) {
tr.freeLastThumbnail();
}
- final Intent trIntent = tr.intent;
- if ((task.affinity == null || !task.affinity.equals(tr.affinity)) &&
- (intent == null || !intent.filterEquals(trIntent))) {
+ if (task.realActivity == null || tr.realActivity == null ||
+ !task.realActivity.equals(tr.realActivity)) {
continue;
}
- final boolean trIsDocument = trIntent != null && trIntent.isDocument();
+ final boolean trIsDocument = tr.intent != null && tr.intent.isDocument();
if (document && trIsDocument) {
// These are the same document activity (not necessarily the same doc).
if (maxRecents > 0) {
diff --git a/services/core/java/com/android/server/pm/PermissionsState.java b/services/core/java/com/android/server/pm/PermissionsState.java
index 8942325..ad662be 100644
--- a/services/core/java/com/android/server/pm/PermissionsState.java
+++ b/services/core/java/com/android/server/pm/PermissionsState.java
@@ -381,10 +381,10 @@ public final class PermissionsState {
*
* @return The gids for all device users.
*/
- public int[] computeGids() {
+ public int[] computeGids(int[] userIds) {
int[] gids = mGlobalGids;
- for (int userId : UserManagerService.getInstance().getUserIds()) {
+ for (int userId : userIds) {
final int[] userGids = computeGids(userId);
gids = appendInts(gids, userGids);
}
diff --git a/services/core/java/com/android/server/pm/Settings.java b/services/core/java/com/android/server/pm/Settings.java
index 76ef19f..d2a135c 100644
--- a/services/core/java/com/android/server/pm/Settings.java
+++ b/services/core/java/com/android/server/pm/Settings.java
@@ -2022,83 +2022,8 @@ final class Settings {
|FileUtils.S_IRGRP|FileUtils.S_IWGRP,
-1, -1);
- // Write package list file now, use a JournaledFile.
- File tempFile = new File(mPackageListFilename.getAbsolutePath() + ".tmp");
- JournaledFile journal = new JournaledFile(mPackageListFilename, tempFile);
-
- final File writeTarget = journal.chooseForWrite();
- fstr = new FileOutputStream(writeTarget);
- str = new BufferedOutputStream(fstr);
- try {
- FileUtils.setPermissions(fstr.getFD(), 0640, SYSTEM_UID, PACKAGE_INFO_GID);
-
- StringBuilder sb = new StringBuilder();
- for (final PackageSetting pkg : mPackages.values()) {
- if (pkg.pkg == null || pkg.pkg.applicationInfo == null) {
- Slog.w(TAG, "Skipping " + pkg + " due to missing metadata");
- continue;
- }
-
- final ApplicationInfo ai = pkg.pkg.applicationInfo;
- final String dataPath = ai.dataDir;
- final boolean isDebug = (ai.flags & ApplicationInfo.FLAG_DEBUGGABLE) != 0;
- final int[] gids = pkg.getPermissionsState().computeGids();
-
- // Avoid any application that has a space in its path.
- if (dataPath.indexOf(" ") >= 0)
- continue;
-
- // we store on each line the following information for now:
- //
- // pkgName - package name
- // userId - application-specific user id
- // debugFlag - 0 or 1 if the package is debuggable.
- // dataPath - path to package's data path
- // seinfo - seinfo label for the app (assigned at install time)
- // gids - supplementary gids this app launches with
- //
- // NOTE: We prefer not to expose all ApplicationInfo flags for now.
- //
- // DO NOT MODIFY THIS FORMAT UNLESS YOU CAN ALSO MODIFY ITS USERS
- // FROM NATIVE CODE. AT THE MOMENT, LOOK AT THE FOLLOWING SOURCES:
- // system/core/logd/LogStatistics.cpp
- // system/core/run-as/run-as.c
- // system/core/sdcard/sdcard.c
- // external/libselinux/src/android.c:package_info_init()
- //
- sb.setLength(0);
- sb.append(ai.packageName);
- sb.append(" ");
- sb.append((int)ai.uid);
- sb.append(isDebug ? " 1 " : " 0 ");
- sb.append(dataPath);
- sb.append(" ");
- sb.append(ai.seinfo);
- sb.append(" ");
- if (gids != null && gids.length > 0) {
- sb.append(gids[0]);
- for (int i = 1; i < gids.length; i++) {
- sb.append(",");
- sb.append(gids[i]);
- }
- } else {
- sb.append("none");
- }
- sb.append("\n");
- str.write(sb.toString().getBytes());
- }
- str.flush();
- FileUtils.sync(fstr);
- str.close();
- journal.commit();
- } catch (Exception e) {
- Slog.wtf(TAG, "Failed to write packages.list", e);
- IoUtils.closeQuietly(str);
- journal.rollback();
- }
-
+ writePackageListLPr();
writeAllUsersPackageRestrictionsLPr();
-
writeAllRuntimePermissionsLPr();
return;
@@ -2119,6 +2044,99 @@ final class Settings {
//Debug.stopMethodTracing();
}
+ void writePackageListLPr() {
+ writePackageListLPr(-1);
+ }
+
+ void writePackageListLPr(int creatingUserId) {
+ // Only derive GIDs for active users (not dying)
+ final List<UserInfo> users = UserManagerService.getInstance().getUsers(true);
+ int[] userIds = new int[users.size()];
+ for (int i = 0; i < userIds.length; i++) {
+ userIds[i] = users.get(i).id;
+ }
+ if (creatingUserId != -1) {
+ userIds = ArrayUtils.appendInt(userIds, creatingUserId);
+ }
+
+ // Write package list file now, use a JournaledFile.
+ File tempFile = new File(mPackageListFilename.getAbsolutePath() + ".tmp");
+ JournaledFile journal = new JournaledFile(mPackageListFilename, tempFile);
+
+ final File writeTarget = journal.chooseForWrite();
+ FileOutputStream fstr = null;
+ BufferedOutputStream str = null;
+ try {
+ fstr = new FileOutputStream(writeTarget);
+ str = new BufferedOutputStream(fstr);
+ FileUtils.setPermissions(fstr.getFD(), 0640, SYSTEM_UID, PACKAGE_INFO_GID);
+
+ StringBuilder sb = new StringBuilder();
+ for (final PackageSetting pkg : mPackages.values()) {
+ if (pkg.pkg == null || pkg.pkg.applicationInfo == null) {
+ Slog.w(TAG, "Skipping " + pkg + " due to missing metadata");
+ continue;
+ }
+
+ final ApplicationInfo ai = pkg.pkg.applicationInfo;
+ final String dataPath = ai.dataDir;
+ final boolean isDebug = (ai.flags & ApplicationInfo.FLAG_DEBUGGABLE) != 0;
+ final int[] gids = pkg.getPermissionsState().computeGids(userIds);
+
+ // Avoid any application that has a space in its path.
+ if (dataPath.indexOf(" ") >= 0)
+ continue;
+
+ // we store on each line the following information for now:
+ //
+ // pkgName - package name
+ // userId - application-specific user id
+ // debugFlag - 0 or 1 if the package is debuggable.
+ // dataPath - path to package's data path
+ // seinfo - seinfo label for the app (assigned at install time)
+ // gids - supplementary gids this app launches with
+ //
+ // NOTE: We prefer not to expose all ApplicationInfo flags for now.
+ //
+ // DO NOT MODIFY THIS FORMAT UNLESS YOU CAN ALSO MODIFY ITS USERS
+ // FROM NATIVE CODE. AT THE MOMENT, LOOK AT THE FOLLOWING SOURCES:
+ // system/core/logd/LogStatistics.cpp
+ // system/core/run-as/run-as.c
+ // system/core/sdcard/sdcard.c
+ // external/libselinux/src/android.c:package_info_init()
+ //
+ sb.setLength(0);
+ sb.append(ai.packageName);
+ sb.append(" ");
+ sb.append((int)ai.uid);
+ sb.append(isDebug ? " 1 " : " 0 ");
+ sb.append(dataPath);
+ sb.append(" ");
+ sb.append(ai.seinfo);
+ sb.append(" ");
+ if (gids != null && gids.length > 0) {
+ sb.append(gids[0]);
+ for (int i = 1; i < gids.length; i++) {
+ sb.append(",");
+ sb.append(gids[i]);
+ }
+ } else {
+ sb.append("none");
+ }
+ sb.append("\n");
+ str.write(sb.toString().getBytes());
+ }
+ str.flush();
+ FileUtils.sync(fstr);
+ str.close();
+ journal.commit();
+ } catch (Exception e) {
+ Slog.wtf(TAG, "Failed to write packages.list", e);
+ IoUtils.closeQuietly(str);
+ journal.rollback();
+ }
+ }
+
void writeDisabledSysPackageLPr(XmlSerializer serializer, final PackageSetting pkg)
throws java.io.IOException {
serializer.startTag(null, "updated-package");
@@ -3491,6 +3509,7 @@ final class Settings {
}
readDefaultPreferredAppsLPw(service, userHandle);
writePackageRestrictionsLPr(userHandle);
+ writePackageListLPr(userHandle);
}
void removeUserLPw(int userId) {
@@ -3506,6 +3525,8 @@ final class Settings {
removeCrossProfileIntentFiltersLPw(userId);
mRuntimePermissionsPersistence.onUserRemoved(userId);
+
+ writePackageListLPr();
}
void removeCrossProfileIntentFiltersLPw(int userId) {