summaryrefslogtreecommitdiffstats
path: root/core/java
diff options
context:
space:
mode:
Diffstat (limited to 'core/java')
-rw-r--r--core/java/android/app/Activity.java7
-rw-r--r--core/java/android/app/Fragment.java7
-rw-r--r--core/java/android/app/VoiceInteractor.java32
-rw-r--r--core/java/android/content/pm/PackageManager.java32
-rw-r--r--core/java/android/text/Hyphenator.java15
-rw-r--r--core/java/android/view/ViewAnimationUtils.java6
6 files changed, 73 insertions, 26 deletions
diff --git a/core/java/android/app/Activity.java b/core/java/android/app/Activity.java
index 9c2e208..d07238a 100644
--- a/core/java/android/app/Activity.java
+++ b/core/java/android/app/Activity.java
@@ -3723,6 +3723,12 @@ public class Activity extends ContextThemeWrapper
* #checkSelfPermission(String)}.
* </p>
* <p>
+ * You cannot request a permission if your activity sets {@link
+ * android.R.styleable#AndroidManifestActivity_noHistory noHistory} to
+ * <code>true</code> because in this case the activity would not receive
+ * result callbacks including {@link #onRequestPermissionsResult(int, String[], int[])}.
+ * </p>
+ * <p>
* A sample permissions request looks like this:
* </p>
* <code><pre><p>
@@ -3749,6 +3755,7 @@ public class Activity extends ContextThemeWrapper
* @param permissions The requested permissions.
* @param requestCode Application specific request code to match with a result
* reported to {@link #onRequestPermissionsResult(int, String[], int[])}.
+ * Should be >= 0.
*
* @see #onRequestPermissionsResult(int, String[], int[])
* @see #checkSelfPermission(String)
diff --git a/core/java/android/app/Fragment.java b/core/java/android/app/Fragment.java
index 95b3b8e..5490fe7 100644
--- a/core/java/android/app/Fragment.java
+++ b/core/java/android/app/Fragment.java
@@ -1166,6 +1166,12 @@ public class Fragment implements ComponentCallbacks2, OnCreateContextMenuListene
* android.content.Context#checkSelfPermission(String)}.
* </p>
* <p>
+ * You cannot request a permission if your activity sets {@link
+ * android.R.styleable#AndroidManifestActivity_noHistory noHistory} to
+ * <code>true</code> because in this case the activity would not receive
+ * result callbacks including {@link #onRequestPermissionsResult(int, String[], int[])}.
+ * </p>
+ * <p>
* A sample permissions request looks like this:
* </p>
* <code><pre><p>
@@ -1192,6 +1198,7 @@ public class Fragment implements ComponentCallbacks2, OnCreateContextMenuListene
* @param permissions The requested permissions.
* @param requestCode Application specific request code to match with a result
* reported to {@link #onRequestPermissionsResult(int, String[], int[])}.
+ * Should be >= 0.
*
* @see #onRequestPermissionsResult(int, String[], int[])
* @see android.content.Context#checkSelfPermission(String)
diff --git a/core/java/android/app/VoiceInteractor.java b/core/java/android/app/VoiceInteractor.java
index abb8244..bf7458c 100644
--- a/core/java/android/app/VoiceInteractor.java
+++ b/core/java/android/app/VoiceInteractor.java
@@ -253,7 +253,8 @@ public final class VoiceInteractor {
/**
* Report from voice interaction service: this operation has been canceled, typically
- * as a completion of a previous call to {@link #cancel}.
+ * as a completion of a previous call to {@link #cancel} or when the user explicitly
+ * cancelled.
*/
public void onCancel() {
}
@@ -288,7 +289,8 @@ public final class VoiceInteractor {
* would require the user to touch the screen when voice interaction mode is not enabled.
* The result of the confirmation will be returned through an asynchronous call to
* either {@link #onConfirmationResult(boolean, android.os.Bundle)} or
- * {@link #onCancel()}.
+ * {@link #onCancel()} - these methods should be overridden to define the application specific
+ * behavior.
*
* <p>In some cases this may be a simple yes / no confirmation or the confirmation could
* include context information about how the action will be completed
@@ -315,13 +317,19 @@ public final class VoiceInteractor {
* @param prompt Optional confirmation to speak to the user or null if nothing
* should be spoken.
* @param extras Additional optional information or null.
- * @deprecated Prefer the version that takes a {@link Prompt}.
+ * @hide
*/
public ConfirmationRequest(CharSequence prompt, Bundle extras) {
mPrompt = (prompt != null ? new Prompt(prompt) : null);
mExtras = extras;
}
+ /**
+ * Handle the confirmation result. Override this method to define
+ * the behavior when the user confirms or rejects the operation.
+ * @param confirmed Whether the user confirmed or rejected the operation.
+ * @param result Additional result information or null.
+ */
public void onConfirmationResult(boolean confirmed, Bundle result) {
}
@@ -336,7 +344,8 @@ public final class VoiceInteractor {
* VoiceInteractionService. Typically, the application would present this visually as
* a list view to allow selecting the option by touch.
* The result of the confirmation will be returned through an asynchronous call to
- * either {@link #onPickOptionResult} or {@link #onCancel()}.
+ * either {@link #onPickOptionResult} or {@link #onCancel()} - these methods should
+ * be overridden to define the application specific behavior.
*/
public static class PickOptionRequest extends Request {
final Prompt mPrompt;
@@ -344,7 +353,9 @@ public final class VoiceInteractor {
final Bundle mExtras;
/**
- * Represents a single option that the user may select using their voice.
+ * Represents a single option that the user may select using their voice. The
+ * {@link #getIndex()} method should be used as a unique ID to identify the option
+ * when it is returned from the voice interactor.
*/
public static final class Option implements Parcelable {
final CharSequence mLabel;
@@ -357,6 +368,7 @@ public final class VoiceInteractor {
* or one of several synonyms.
* @param label The label that will both be matched against what the user speaks
* and displayed visually.
+ * @hide
*/
public Option(CharSequence label) {
mLabel = label;
@@ -481,7 +493,7 @@ public final class VoiceInteractor {
* presented or null if nothing should be asked.
* @param options The set of {@link Option}s the user is selecting from.
* @param extras Additional optional information or null.
- * @deprecated Prefer the version that takes a {@link Prompt}.
+ * @hide
*/
public PickOptionRequest(CharSequence prompt, Option[] options, Bundle extras) {
mPrompt = (prompt != null ? new Prompt(prompt) : null);
@@ -490,7 +502,9 @@ public final class VoiceInteractor {
}
/**
- * Called when a single option is confirmed or narrowed to one of several options.
+ * Called when a single option is confirmed or narrowed to one of several options. Override
+ * this method to define the behavior when the user selects an option or narrows down the
+ * set of options.
* @param finished True if the voice interaction has finished making a selection, in
* which case {@code selections} contains the final result. If false, this request is
* still active and you will continue to get calls on it.
@@ -536,7 +550,7 @@ public final class VoiceInteractor {
* @param message Optional message to speak to the user about the completion status of
* the task or null if nothing should be spoken.
* @param extras Additional optional information or null.
- * @deprecated Prefer the version that takes a {@link Prompt}.
+ * @hide
*/
public CompleteVoiceRequest(CharSequence message, Bundle extras) {
mPrompt = (message != null ? new Prompt(message) : null);
@@ -583,7 +597,7 @@ public final class VoiceInteractor {
* @param message Optional message to speak to the user indicating why the task could
* not be completed by voice or null if nothing should be spoken.
* @param extras Additional optional information or null.
- * @deprecated Prefer the version that takes a {@link Prompt}.
+ * @hide
*/
public AbortVoiceRequest(CharSequence message, Bundle extras) {
mPrompt = (message != null ? new Prompt(message) : null);
diff --git a/core/java/android/content/pm/PackageManager.java b/core/java/android/content/pm/PackageManager.java
index dd1c5c2..538007a 100644
--- a/core/java/android/content/pm/PackageManager.java
+++ b/core/java/android/content/pm/PackageManager.java
@@ -1924,7 +1924,6 @@ public abstract class PackageManager {
*
* @hide
*/
- @SystemApi
public static final int FLAG_PERMISSION_USER_SET = 1 << 0;
/**
@@ -1934,7 +1933,6 @@ public abstract class PackageManager {
*
* @hide
*/
- @SystemApi
public static final int FLAG_PERMISSION_USER_FIXED = 1 << 1;
/**
@@ -1944,7 +1942,6 @@ public abstract class PackageManager {
*
* @hide
*/
- @SystemApi
public static final int FLAG_PERMISSION_POLICY_FIXED = 1 << 2;
/**
@@ -1957,7 +1954,6 @@ public abstract class PackageManager {
*
* @hide
*/
- @SystemApi
public static final int FLAG_PERMISSION_REVOKE_ON_UPGRADE = 1 << 3;
/**
@@ -1966,9 +1962,19 @@ public abstract class PackageManager {
*
* @hide
*/
- @SystemApi
public static final int FLAG_PERMISSION_SYSTEM_FIXED = 1 << 4;
+
+ /**
+ * Permission flag: The permission is granted by default because it
+ * enables app functionality that is expected to work out-of-the-box
+ * for providing a smooth user experience. For example, the phone app
+ * is expected to have the phone permission.
+ *
+ * @hide
+ */
+ public static final int FLAG_PERMISSION_GRANTED_BY_DEFAULT = 1 << 5;
+
/**
* Mask for all permission flags.
*
@@ -2474,7 +2480,8 @@ public abstract class PackageManager {
FLAG_PERMISSION_USER_FIXED,
FLAG_PERMISSION_POLICY_FIXED,
FLAG_PERMISSION_REVOKE_ON_UPGRADE,
- FLAG_PERMISSION_SYSTEM_FIXED})
+ FLAG_PERMISSION_SYSTEM_FIXED,
+ FLAG_PERMISSION_GRANTED_BY_DEFAULT})
@Retention(RetentionPolicy.SOURCE)
public @interface PermissionFlags {}
@@ -4634,6 +4641,19 @@ public abstract class PackageManager {
}
/** {@hide} */
+ public static String permissionFlagToString(int flag) {
+ switch (flag) {
+ case FLAG_PERMISSION_GRANTED_BY_DEFAULT: return "FLAG_PERMISSION_GRANTED_BY_DEFAULT";
+ case FLAG_PERMISSION_POLICY_FIXED: return "FLAG_PERMISSION_POLICY_FIXED";
+ case FLAG_PERMISSION_SYSTEM_FIXED: return "FLAG_PERMISSION_SYSTEM_FIXED";
+ case FLAG_PERMISSION_USER_SET: return "FLAG_PERMISSION_USER_SET";
+ case FLAG_PERMISSION_REVOKE_ON_UPGRADE: return "FLAG_PERMISSION_REVOKE_ON_UPGRADE";
+ case FLAG_PERMISSION_USER_FIXED: return "FLAG_PERMISSION_USER_FIXED";
+ default: return Integer.toString(flag);
+ }
+ }
+
+ /** {@hide} */
public static class LegacyPackageInstallObserver extends PackageInstallObserver {
private final IPackageInstallObserver mLegacy;
diff --git a/core/java/android/text/Hyphenator.java b/core/java/android/text/Hyphenator.java
index 67c36e3..1ee3827 100644
--- a/core/java/android/text/Hyphenator.java
+++ b/core/java/android/text/Hyphenator.java
@@ -21,9 +21,10 @@ import com.android.internal.annotations.GuardedBy;
import android.annotation.Nullable;
import android.util.Log;
+import libcore.io.IoUtils;
+
import java.io.File;
import java.io.IOException;
-import java.io.RandomAccessFile;
import java.util.HashMap;
import java.util.Locale;
@@ -42,9 +43,9 @@ public class Hyphenator {
private final static Object sLock = new Object();
@GuardedBy("sLock")
- static HashMap<Locale, Hyphenator> sMap = new HashMap<Locale, Hyphenator>();
+ final static HashMap<Locale, Hyphenator> sMap = new HashMap<Locale, Hyphenator>();
- private long mNativePtr;
+ final private long mNativePtr;
private Hyphenator(long nativePtr) {
mNativePtr = nativePtr;
@@ -90,17 +91,13 @@ public class Hyphenator {
String patternFilename = "hyph-"+languageTag.toLowerCase(Locale.US)+".pat.txt";
File patternFile = new File(getSystemHyphenatorLocation(), patternFilename);
try {
- RandomAccessFile rf = new RandomAccessFile(patternFile, "r");
- byte[] buf = new byte[(int)rf.length()];
- rf.read(buf);
- rf.close();
- String patternData = new String(buf);
+ String patternData = IoUtils.readFileAsString(patternFile.getAbsolutePath());
long nativePtr = StaticLayout.nLoadHyphenator(patternData);
return new Hyphenator(nativePtr);
} catch (IOException e) {
Log.e(TAG, "error loading hyphenation " + patternFile, e);
+ return null;
}
- return null;
}
private static File getSystemHyphenatorLocation() {
diff --git a/core/java/android/view/ViewAnimationUtils.java b/core/java/android/view/ViewAnimationUtils.java
index d44df31..4c75935 100644
--- a/core/java/android/view/ViewAnimationUtils.java
+++ b/core/java/android/view/ViewAnimationUtils.java
@@ -43,8 +43,10 @@ public final class ViewAnimationUtils {
* on thread responsiveness.
*
* @param view The View will be clipped to the animating circle.
- * @param centerX The x coordinate of the center of the animating circle.
- * @param centerY The y coordinate of the center of the animating circle.
+ * @param centerX The x coordinate of the center of the animating circle, relative to
+ * <code>view</code>.
+ * @param centerY The y coordinate of the center of the animating circle, relative to
+ * <code>view</code>.
* @param startRadius The starting radius of the animating circle.
* @param endRadius The ending radius of the animating circle.
*/