summaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
Diffstat (limited to 'core')
-rw-r--r--core/java/android/app/Activity.java12
-rw-r--r--core/java/android/app/ActivityManagerNative.java8
-rw-r--r--core/java/android/app/Fragment.java3
-rw-r--r--core/java/android/app/IActivityManager.java3
-rw-r--r--core/java/android/app/Instrumentation.java5
-rw-r--r--core/java/android/content/Intent.java2
-rw-r--r--core/java/android/content/pm/PackageInstaller.java24
-rw-r--r--core/java/com/android/internal/app/IntentForwarderActivity.java2
-rw-r--r--core/java/com/android/internal/app/ResolverActivity.java2
-rw-r--r--core/java/com/android/internal/util/XmlUtils.java3
-rw-r--r--core/res/AndroidManifest.xml24
11 files changed, 69 insertions, 19 deletions
diff --git a/core/java/android/app/Activity.java b/core/java/android/app/Activity.java
index 7572799..96c7f84 100644
--- a/core/java/android/app/Activity.java
+++ b/core/java/android/app/Activity.java
@@ -3977,16 +3977,24 @@ public class Activity extends ContextThemeWrapper
* as intermediaries that dispatch their intent to the target the user selects -- to
* do this, they must perform all security checks including permission grants as if
* their launch had come from the original activity.
+ * @param intent The Intent to start.
+ * @param options ActivityOptions or null.
+ * @param ignoreTargetSecurity If true, the activity manager will not check whether the
+ * caller it is doing the start is, is actually allowed to start the target activity.
+ * If you set this to true, you must set an explicit component in the Intent and do any
+ * appropriate security checks yourself.
+ * @param userId The user the new activity should run as.
* @hide
*/
- public void startActivityAsCaller(Intent intent, @Nullable Bundle options, int userId) {
+ public void startActivityAsCaller(Intent intent, @Nullable Bundle options,
+ boolean ignoreTargetSecurity, int userId) {
if (mParent != null) {
throw new RuntimeException("Can't be called from a child");
}
Instrumentation.ActivityResult ar =
mInstrumentation.execStartActivityAsCaller(
this, mMainThread.getApplicationThread(), mToken, this,
- intent, -1, options, userId);
+ intent, -1, options, ignoreTargetSecurity, userId);
if (ar != null) {
mMainThread.sendActivityResult(
mToken, mEmbeddedID, -1, ar.getResultCode(),
diff --git a/core/java/android/app/ActivityManagerNative.java b/core/java/android/app/ActivityManagerNative.java
index fc408a8..bfb92c4 100644
--- a/core/java/android/app/ActivityManagerNative.java
+++ b/core/java/android/app/ActivityManagerNative.java
@@ -206,9 +206,11 @@ public abstract class ActivityManagerNative extends Binder implements IActivityM
? ProfilerInfo.CREATOR.createFromParcel(data) : null;
Bundle options = data.readInt() != 0
? Bundle.CREATOR.createFromParcel(data) : null;
+ boolean ignoreTargetSecurity = data.readInt() != 0;
int userId = data.readInt();
int result = startActivityAsCaller(app, callingPackage, intent, resolvedType,
- resultTo, resultWho, requestCode, startFlags, profilerInfo, options, userId);
+ resultTo, resultWho, requestCode, startFlags, profilerInfo, options,
+ ignoreTargetSecurity, userId);
reply.writeNoException();
reply.writeInt(result);
return true;
@@ -2675,7 +2677,8 @@ class ActivityManagerProxy implements IActivityManager
}
public int startActivityAsCaller(IApplicationThread caller, String callingPackage,
Intent intent, String resolvedType, IBinder resultTo, String resultWho, int requestCode,
- int startFlags, ProfilerInfo profilerInfo, Bundle options, int userId) throws RemoteException {
+ int startFlags, ProfilerInfo profilerInfo, Bundle options, boolean ignoreTargetSecurity,
+ int userId) throws RemoteException {
Parcel data = Parcel.obtain();
Parcel reply = Parcel.obtain();
data.writeInterfaceToken(IActivityManager.descriptor);
@@ -2699,6 +2702,7 @@ class ActivityManagerProxy implements IActivityManager
} else {
data.writeInt(0);
}
+ data.writeInt(ignoreTargetSecurity ? 1 : 0);
data.writeInt(userId);
mRemote.transact(START_ACTIVITY_AS_CALLER_TRANSACTION, data, reply, 0);
reply.readException();
diff --git a/core/java/android/app/Fragment.java b/core/java/android/app/Fragment.java
index 5490fe7..66e2733 100644
--- a/core/java/android/app/Fragment.java
+++ b/core/java/android/app/Fragment.java
@@ -1249,7 +1249,8 @@ public class Fragment implements ComponentCallbacks2, OnCreateContextMenuListene
*/
public boolean shouldShowRequestPermissionRationale(@NonNull String permission) {
if (mHost != null) {
- mHost.getContext().getPackageManager().shouldShowRequestPermissionRationale(permission);
+ return mHost.getContext().getPackageManager()
+ .shouldShowRequestPermissionRationale(permission);
}
return false;
}
diff --git a/core/java/android/app/IActivityManager.java b/core/java/android/app/IActivityManager.java
index 1d87d77..5eb3961 100644
--- a/core/java/android/app/IActivityManager.java
+++ b/core/java/android/app/IActivityManager.java
@@ -72,7 +72,8 @@ public interface IActivityManager extends IInterface {
ProfilerInfo profilerInfo, Bundle options, int userId) throws RemoteException;
public int startActivityAsCaller(IApplicationThread caller, String callingPackage,
Intent intent, String resolvedType, IBinder resultTo, String resultWho, int requestCode,
- int flags, ProfilerInfo profilerInfo, Bundle options, int userId) throws RemoteException;
+ int flags, ProfilerInfo profilerInfo, Bundle options, boolean ignoreTargetSecurity,
+ int userId) throws RemoteException;
public WaitResult startActivityAndWait(IApplicationThread caller, String callingPackage,
Intent intent, String resolvedType, IBinder resultTo, String resultWho,
int requestCode, int flags, ProfilerInfo profilerInfo, Bundle options,
diff --git a/core/java/android/app/Instrumentation.java b/core/java/android/app/Instrumentation.java
index 653f1b6..c2d901d 100644
--- a/core/java/android/app/Instrumentation.java
+++ b/core/java/android/app/Instrumentation.java
@@ -1701,7 +1701,8 @@ public class Instrumentation {
*/
public ActivityResult execStartActivityAsCaller(
Context who, IBinder contextThread, IBinder token, Activity target,
- Intent intent, int requestCode, Bundle options, int userId) {
+ Intent intent, int requestCode, Bundle options, boolean ignoreTargetSecurity,
+ int userId) {
IApplicationThread whoThread = (IApplicationThread) contextThread;
if (mActivityMonitors != null) {
synchronized (mSync) {
@@ -1725,7 +1726,7 @@ public class Instrumentation {
.startActivityAsCaller(whoThread, who.getBasePackageName(), intent,
intent.resolveTypeIfNeeded(who.getContentResolver()),
token, target != null ? target.mEmbeddedID : null,
- requestCode, 0, null, options, userId);
+ requestCode, 0, null, options, ignoreTargetSecurity, userId);
checkStartActivityResult(result, intent);
} catch (RemoteException e) {
throw new RuntimeException("Failure from system", e);
diff --git a/core/java/android/content/Intent.java b/core/java/android/content/Intent.java
index 5571662..f786d2f 100644
--- a/core/java/android/content/Intent.java
+++ b/core/java/android/content/Intent.java
@@ -1023,7 +1023,7 @@ public class Intent implements Parcelable, Cloneable {
*
* <p>Note: if you app targets {@link android.os.Build.VERSION_CODES#MNC MNC}
* and above and declares as using the {@link android.Manifest.permission#CALL_PHONE}
- * permission which is not granted, then atempting to use this action will
+ * permission which is not granted, then attempting to use this action will
* result in a {@link java.lang.SecurityException}.
*/
@SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
diff --git a/core/java/android/content/pm/PackageInstaller.java b/core/java/android/content/pm/PackageInstaller.java
index b7ee82d..9341be1 100644
--- a/core/java/android/content/pm/PackageInstaller.java
+++ b/core/java/android/content/pm/PackageInstaller.java
@@ -18,8 +18,10 @@ package android.content.pm;
import android.annotation.NonNull;
import android.annotation.Nullable;
+import android.annotation.RequiresPermission;
import android.annotation.SdkConstant;
import android.annotation.SdkConstant.SdkConstantType;
+import android.annotation.SystemApi;
import android.app.ActivityManager;
import android.content.Context;
import android.content.Intent;
@@ -889,6 +891,8 @@ public class PackageInstaller {
public String abiOverride;
/** {@hide} */
public String volumeUuid;
+ /** {@hide} */
+ public String[] grantedRuntimePermissions;
/**
* Construct parameters for a new package install session.
@@ -914,6 +918,7 @@ public class PackageInstaller {
referrerUri = source.readParcelable(null);
abiOverride = source.readString();
volumeUuid = source.readString();
+ grantedRuntimePermissions = source.readStringArray();
}
/**
@@ -987,6 +992,23 @@ public class PackageInstaller {
this.referrerUri = referrerUri;
}
+ /**
+ * Sets which runtime permissions to be granted to the package at installation.
+ * Using this API requires holding {@link android.Manifest.permission
+ * #INSTALL_GRANT_RUNTIME_PERMISSIONS}
+ *
+ * @param permissions The permissions to grant or null to grant all runtime
+ * permissions.
+ *
+ * @hide
+ */
+ @SystemApi
+ @RequiresPermission(android.Manifest.permission.INSTALL_GRANT_RUNTIME_PERMISSIONS)
+ public void setGrantedRuntimePermissions(String[] permissions) {
+ installFlags |= PackageManager.INSTALL_GRANT_RUNTIME_PERMISSIONS;
+ this.grantedRuntimePermissions = permissions;
+ }
+
/** {@hide} */
public void setInstallFlagsInternal() {
installFlags |= PackageManager.INSTALL_INTERNAL;
@@ -1012,6 +1034,7 @@ public class PackageInstaller {
pw.printPair("referrerUri", referrerUri);
pw.printPair("abiOverride", abiOverride);
pw.printPair("volumeUuid", volumeUuid);
+ pw.printPair("grantedRuntimePermissions", grantedRuntimePermissions);
pw.println();
}
@@ -1033,6 +1056,7 @@ public class PackageInstaller {
dest.writeParcelable(referrerUri, flags);
dest.writeString(abiOverride);
dest.writeString(volumeUuid);
+ dest.writeStringArray(grantedRuntimePermissions);
}
public static final Parcelable.Creator<SessionParams>
diff --git a/core/java/com/android/internal/app/IntentForwarderActivity.java b/core/java/com/android/internal/app/IntentForwarderActivity.java
index 233bee3..39b66aa 100644
--- a/core/java/com/android/internal/app/IntentForwarderActivity.java
+++ b/core/java/com/android/internal/app/IntentForwarderActivity.java
@@ -103,7 +103,7 @@ public class IntentForwarderActivity extends Activity {
|| ChooserActivity.class.getName().equals(ri.activityInfo.name));
try {
- startActivityAsCaller(newIntent, null, targetUserId);
+ startActivityAsCaller(newIntent, null, false, targetUserId);
} catch (RuntimeException e) {
int launchedFromUid = -1;
String launchedFromPackage = "?";
diff --git a/core/java/com/android/internal/app/ResolverActivity.java b/core/java/com/android/internal/app/ResolverActivity.java
index 7bc18f3..ba19131 100644
--- a/core/java/com/android/internal/app/ResolverActivity.java
+++ b/core/java/com/android/internal/app/ResolverActivity.java
@@ -973,7 +973,7 @@ public class ResolverActivity extends Activity {
@Override
public boolean startAsCaller(Activity activity, Bundle options, int userId) {
- activity.startActivityAsCaller(mResolvedIntent, options, userId);
+ activity.startActivityAsCaller(mResolvedIntent, options, false, userId);
return true;
}
diff --git a/core/java/com/android/internal/util/XmlUtils.java b/core/java/com/android/internal/util/XmlUtils.java
index 32746c2..6393fba 100644
--- a/core/java/com/android/internal/util/XmlUtils.java
+++ b/core/java/com/android/internal/util/XmlUtils.java
@@ -20,6 +20,7 @@ import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Bitmap.CompressFormat;
import android.net.Uri;
+import android.text.TextUtils;
import android.util.ArrayMap;
import android.util.Base64;
import android.util.Xml;
@@ -45,6 +46,8 @@ import java.util.Set;
/** {@hide} */
public class XmlUtils {
+ private static final String STRING_ARRAY_SEPARATOR = ":";
+
public static void skipCurrentTag(XmlPullParser parser)
throws XmlPullParserException, IOException {
int outerDepth = parser.getDepth();
diff --git a/core/res/AndroidManifest.xml b/core/res/AndroidManifest.xml
index 062ae27..0c0ba7f 100644
--- a/core/res/AndroidManifest.xml
+++ b/core/res/AndroidManifest.xml
@@ -2052,10 +2052,24 @@
<permission android:name="android.permission.CHANGE_COMPONENT_ENABLED_STATE"
android:protectionLevel="signature|privileged" />
- <!-- @hide Allows an application to grant or revoke specific permissions. -->
- <permission android:name="android.permission.GRANT_REVOKE_PERMISSIONS"
+ <!-- Allows an application to grant specific permissions.
+ @hide -->
+ <permission android:name="android.permission.GRANT_RUNTIME_PERMISSIONS"
android:protectionLevel="signature|installer" />
+ <!-- Allows an app that has this permission and the permissions to install packages
+ to request certain runtime permissions to be granted at installation.
+ @hide
+ @SystemApi -->
+ <permission android:name="android.permission.INSTALL_GRANT_RUNTIME_PERMISSIONS"
+ android:protectionLevel="signature|installer|verifier" />
+
+ <!-- Allows an application to revoke specific permissions.
+ @hide
+ @SystemApi -->
+ <permission android:name="android.permission.REVOKE_RUNTIME_PERMISSIONS"
+ android:protectionLevel="signature|installer|verifier" />
+
<!-- @hide Allows an application to observe permission changes. -->
<permission android:name="android.permission.OBSERVE_GRANT_REVOKE_PERMISSIONS"
android:protectionLevel="signature|privileged" />
@@ -2539,12 +2553,6 @@
<permission android:name="android.permission.ACCESS_VOICE_INTERACTION_SERVICE"
android:protectionLevel="signature" />
- <!-- Allows an app that has this permission and a permissions to install packages
- to request all runtime permissions to be granted at installation.
- @hide -->
- <permission android:name="android.permission.INSTALL_GRANT_RUNTIME_PERMISSIONS"
- android:protectionLevel="signature" />
-
<!-- The system process that is allowed to bind to services in carrier apps will
have this permission. Carrier apps should use this permission to protect
their services that only the system is allowed to bind to.