am 219d9d38: Merge "Address KeySet API Review" into lmp-dev
* commit '219d9d387b1d6133e8dd61b78f5e2556a4566a87': Address KeySet API Review
This commit is contained in:
@@ -8582,9 +8582,6 @@ package android.content.pm {
|
||||
field public java.lang.String targetPackage;
|
||||
}
|
||||
|
||||
public class KeySet {
|
||||
}
|
||||
|
||||
public class LabeledIntent extends android.content.Intent {
|
||||
ctor public LabeledIntent(android.content.Intent, java.lang.String, int, int);
|
||||
ctor public LabeledIntent(android.content.Intent, java.lang.String, java.lang.CharSequence, int);
|
||||
@@ -8820,7 +8817,6 @@ package android.content.pm {
|
||||
method public abstract java.util.List<android.content.pm.PackageInfo> getInstalledPackages(int);
|
||||
method public abstract java.lang.String getInstallerPackageName(java.lang.String);
|
||||
method public abstract android.content.pm.InstrumentationInfo getInstrumentationInfo(android.content.ComponentName, int) throws android.content.pm.PackageManager.NameNotFoundException;
|
||||
method public abstract android.content.pm.KeySet getKeySetByAlias(java.lang.String, java.lang.String);
|
||||
method public abstract android.content.Intent getLaunchIntentForPackage(java.lang.String);
|
||||
method public abstract android.content.Intent getLeanbackLaunchIntentForPackage(java.lang.String);
|
||||
method public abstract java.lang.String getNameForUid(int);
|
||||
@@ -8840,15 +8836,12 @@ package android.content.pm {
|
||||
method public abstract android.content.res.Resources getResourcesForApplication(android.content.pm.ApplicationInfo) throws android.content.pm.PackageManager.NameNotFoundException;
|
||||
method public abstract android.content.res.Resources getResourcesForApplication(java.lang.String) throws android.content.pm.PackageManager.NameNotFoundException;
|
||||
method public abstract android.content.pm.ServiceInfo getServiceInfo(android.content.ComponentName, int) throws android.content.pm.PackageManager.NameNotFoundException;
|
||||
method public abstract android.content.pm.KeySet getSigningKeySet(java.lang.String);
|
||||
method public abstract android.content.pm.FeatureInfo[] getSystemAvailableFeatures();
|
||||
method public abstract java.lang.String[] getSystemSharedLibraryNames();
|
||||
method public abstract java.lang.CharSequence getText(java.lang.String, int, android.content.pm.ApplicationInfo);
|
||||
method public abstract android.content.res.XmlResourceParser getXml(java.lang.String, int, android.content.pm.ApplicationInfo);
|
||||
method public abstract boolean hasSystemFeature(java.lang.String);
|
||||
method public abstract boolean isSafeMode();
|
||||
method public abstract boolean isSignedBy(java.lang.String, android.content.pm.KeySet);
|
||||
method public abstract boolean isSignedByExactly(java.lang.String, android.content.pm.KeySet);
|
||||
method public abstract java.util.List<android.content.pm.ResolveInfo> queryBroadcastReceivers(android.content.Intent, int);
|
||||
method public abstract java.util.List<android.content.pm.ProviderInfo> queryContentProviders(java.lang.String, int, int);
|
||||
method public abstract java.util.List<android.content.pm.InstrumentationInfo> queryInstrumentation(java.lang.String, int);
|
||||
@@ -29805,7 +29798,6 @@ package android.test.mock {
|
||||
method public java.util.List<android.content.pm.PackageInfo> getInstalledPackages(int);
|
||||
method public java.lang.String getInstallerPackageName(java.lang.String);
|
||||
method public android.content.pm.InstrumentationInfo getInstrumentationInfo(android.content.ComponentName, int) throws android.content.pm.PackageManager.NameNotFoundException;
|
||||
method public android.content.pm.KeySet getKeySetByAlias(java.lang.String, java.lang.String);
|
||||
method public android.content.Intent getLaunchIntentForPackage(java.lang.String);
|
||||
method public android.content.Intent getLeanbackLaunchIntentForPackage(java.lang.String);
|
||||
method public java.lang.String getNameForUid(int);
|
||||
@@ -29824,15 +29816,12 @@ package android.test.mock {
|
||||
method public android.content.res.Resources getResourcesForApplication(android.content.pm.ApplicationInfo);
|
||||
method public android.content.res.Resources getResourcesForApplication(java.lang.String) throws android.content.pm.PackageManager.NameNotFoundException;
|
||||
method public android.content.pm.ServiceInfo getServiceInfo(android.content.ComponentName, int) throws android.content.pm.PackageManager.NameNotFoundException;
|
||||
method public android.content.pm.KeySet getSigningKeySet(java.lang.String);
|
||||
method public android.content.pm.FeatureInfo[] getSystemAvailableFeatures();
|
||||
method public java.lang.String[] getSystemSharedLibraryNames();
|
||||
method public java.lang.CharSequence getText(java.lang.String, int, android.content.pm.ApplicationInfo);
|
||||
method public android.content.res.XmlResourceParser getXml(java.lang.String, int, android.content.pm.ApplicationInfo);
|
||||
method public boolean hasSystemFeature(java.lang.String);
|
||||
method public boolean isSafeMode();
|
||||
method public boolean isSignedBy(java.lang.String, android.content.pm.KeySet);
|
||||
method public boolean isSignedByExactly(java.lang.String, android.content.pm.KeySet);
|
||||
method public java.util.List<android.content.pm.ResolveInfo> queryBroadcastReceivers(android.content.Intent, int);
|
||||
method public java.util.List<android.content.pm.ProviderInfo> queryContentProviders(java.lang.String, int, int);
|
||||
method public java.util.List<android.content.pm.InstrumentationInfo> queryInstrumentation(java.lang.String, int);
|
||||
|
||||
@@ -1494,57 +1494,52 @@ final class ApplicationPackageManager extends PackageManager {
|
||||
return false;
|
||||
}
|
||||
|
||||
/** @hide */
|
||||
@Override
|
||||
public KeySet getKeySetByAlias(String packageName, String alias) {
|
||||
Preconditions.checkNotNull(packageName);
|
||||
Preconditions.checkNotNull(alias);
|
||||
IBinder keySetToken;
|
||||
KeySet ks;
|
||||
try {
|
||||
keySetToken = mPM.getKeySetByAlias(packageName, alias);
|
||||
ks = mPM.getKeySetByAlias(packageName, alias);
|
||||
} catch (RemoteException e) {
|
||||
return null;
|
||||
}
|
||||
if (keySetToken == null) {
|
||||
return null;
|
||||
}
|
||||
return new KeySet(keySetToken);
|
||||
return ks;
|
||||
}
|
||||
|
||||
/** @hide */
|
||||
@Override
|
||||
public KeySet getSigningKeySet(String packageName) {
|
||||
Preconditions.checkNotNull(packageName);
|
||||
IBinder keySetToken;
|
||||
KeySet ks;
|
||||
try {
|
||||
keySetToken = mPM.getSigningKeySet(packageName);
|
||||
ks = mPM.getSigningKeySet(packageName);
|
||||
} catch (RemoteException e) {
|
||||
return null;
|
||||
}
|
||||
if (keySetToken == null) {
|
||||
return null;
|
||||
}
|
||||
return new KeySet(keySetToken);
|
||||
return ks;
|
||||
}
|
||||
|
||||
|
||||
/** @hide */
|
||||
@Override
|
||||
public boolean isSignedBy(String packageName, KeySet ks) {
|
||||
Preconditions.checkNotNull(packageName);
|
||||
Preconditions.checkNotNull(ks);
|
||||
IBinder keySetToken = ks.getToken();
|
||||
try {
|
||||
return mPM.isPackageSignedByKeySet(packageName, keySetToken);
|
||||
return mPM.isPackageSignedByKeySet(packageName, ks);
|
||||
} catch (RemoteException e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/** @hide */
|
||||
@Override
|
||||
public boolean isSignedByExactly(String packageName, KeySet ks) {
|
||||
Preconditions.checkNotNull(packageName);
|
||||
Preconditions.checkNotNull(ks);
|
||||
IBinder keySetToken = ks.getToken();
|
||||
try {
|
||||
return mPM.isPackageSignedByKeySetExactly(packageName, keySetToken);
|
||||
return mPM.isPackageSignedByKeySetExactly(packageName, ks);
|
||||
} catch (RemoteException e) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -32,6 +32,7 @@ import android.content.pm.IPackageDataObserver;
|
||||
import android.content.pm.IPackageMoveObserver;
|
||||
import android.content.pm.IPackageStatsObserver;
|
||||
import android.content.pm.InstrumentationInfo;
|
||||
import android.content.pm.KeySet;
|
||||
import android.content.pm.PackageInfo;
|
||||
import android.content.pm.ManifestDigest;
|
||||
import android.content.pm.PackageCleanItem;
|
||||
@@ -454,8 +455,8 @@ interface IPackageManager {
|
||||
boolean setBlockUninstallForUser(String packageName, boolean blockUninstall, int userId);
|
||||
boolean getBlockUninstallForUser(String packageName, int userId);
|
||||
|
||||
IBinder getKeySetByAlias(String packageName, String alias);
|
||||
IBinder getSigningKeySet(String packageName);
|
||||
boolean isPackageSignedByKeySet(String packageName, IBinder ks);
|
||||
boolean isPackageSignedByKeySetExactly(String packageName, IBinder ks);
|
||||
KeySet getKeySetByAlias(String packageName, String alias);
|
||||
KeySet getSigningKeySet(String packageName);
|
||||
boolean isPackageSignedByKeySet(String packageName, in KeySet ks);
|
||||
boolean isPackageSignedByKeySetExactly(String packageName, in KeySet ks);
|
||||
}
|
||||
|
||||
19
core/java/android/content/pm/KeySet.aidl
Normal file
19
core/java/android/content/pm/KeySet.aidl
Normal file
@@ -0,0 +1,19 @@
|
||||
/**
|
||||
* Copyright (c) 2014, The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package android.content.pm;
|
||||
|
||||
parcelable KeySet;
|
||||
@@ -17,13 +17,16 @@
|
||||
package android.content.pm;
|
||||
|
||||
import android.os.IBinder;
|
||||
import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
|
||||
/**
|
||||
* Represents a {@code KeySet} that has been declared in the AndroidManifest.xml
|
||||
* file for the application. A {@code KeySet} can be used explicitly to
|
||||
* represent a trust relationship with other applications on the device.
|
||||
* @hide
|
||||
*/
|
||||
public class KeySet {
|
||||
public class KeySet implements Parcelable {
|
||||
|
||||
private IBinder token;
|
||||
|
||||
@@ -40,6 +43,7 @@ public class KeySet {
|
||||
return token;
|
||||
}
|
||||
|
||||
/** @hide */
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (o instanceof KeySet) {
|
||||
@@ -48,4 +52,58 @@ public class KeySet {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/** @hide */
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return token.hashCode();
|
||||
}
|
||||
|
||||
/**
|
||||
* Implement Parcelable
|
||||
* @hide
|
||||
*/
|
||||
public static final Parcelable.Creator<KeySet> CREATOR
|
||||
= new Parcelable.Creator<KeySet>() {
|
||||
|
||||
/**
|
||||
* Create a KeySet from a Parcel
|
||||
*
|
||||
* @param in The parcel containing the KeySet
|
||||
*/
|
||||
public KeySet createFromParcel(Parcel source) {
|
||||
return readFromParcel(source);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an array of null KeySets
|
||||
*/
|
||||
public KeySet[] newArray(int size) {
|
||||
return new KeySet[size];
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* @hide
|
||||
*/
|
||||
private static KeySet readFromParcel(Parcel in) {
|
||||
IBinder token = in.readStrongBinder();
|
||||
return new KeySet(token);
|
||||
}
|
||||
|
||||
/**
|
||||
* @hide
|
||||
*/
|
||||
@Override
|
||||
public void writeToParcel(Parcel out, int flags) {
|
||||
out.writeStrongBinder(token);
|
||||
}
|
||||
|
||||
/**
|
||||
* @hide
|
||||
*/
|
||||
@Override
|
||||
public int describeContents() {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@@ -3698,10 +3698,13 @@ public abstract class PackageManager {
|
||||
*
|
||||
* @param alias The alias for a given {@link KeySet} as defined in the
|
||||
* application's AndroidManifest.xml.
|
||||
* @hide
|
||||
*/
|
||||
public abstract KeySet getKeySetByAlias(String packageName, String alias);
|
||||
|
||||
/** Return the signing {@link KeySet} for this application. */
|
||||
/** Return the signing {@link KeySet} for this application.
|
||||
* @hide
|
||||
*/
|
||||
public abstract KeySet getSigningKeySet(String packageName);
|
||||
|
||||
/**
|
||||
@@ -3709,6 +3712,7 @@ public abstract class PackageManager {
|
||||
* of the keys specified by the {@link KeySet} ks. This will return true if
|
||||
* the package has been signed by additional keys (a superset) as well.
|
||||
* Compare to {@link #isSignedByExactly(String packageName, KeySet ks)}.
|
||||
* @hide
|
||||
*/
|
||||
public abstract boolean isSignedBy(String packageName, KeySet ks);
|
||||
|
||||
@@ -3716,6 +3720,7 @@ public abstract class PackageManager {
|
||||
* Return whether the package denoted by packageName has been signed by all
|
||||
* of, and only, the keys specified by the {@link KeySet} ks. Compare to
|
||||
* {@link #isSignedBy(String packageName, KeySet ks)}.
|
||||
* @hide
|
||||
*/
|
||||
public abstract boolean isSignedByExactly(String packageName, KeySet ks);
|
||||
|
||||
|
||||
@@ -104,6 +104,7 @@ import android.content.pm.IPackageManager;
|
||||
import android.content.pm.IPackageMoveObserver;
|
||||
import android.content.pm.IPackageStatsObserver;
|
||||
import android.content.pm.InstrumentationInfo;
|
||||
import android.content.pm.KeySet;
|
||||
import android.content.pm.ManifestDigest;
|
||||
import android.content.pm.PackageCleanItem;
|
||||
import android.content.pm.PackageInfo;
|
||||
@@ -13132,7 +13133,7 @@ public class PackageManagerService extends IPackageManager.Stub {
|
||||
}
|
||||
|
||||
@Override
|
||||
public KeySetHandle getKeySetByAlias(String packageName, String alias) {
|
||||
public KeySet getKeySetByAlias(String packageName, String alias) {
|
||||
if (packageName == null || alias == null) {
|
||||
return null;
|
||||
}
|
||||
@@ -13142,18 +13143,13 @@ public class PackageManagerService extends IPackageManager.Stub {
|
||||
Slog.w(TAG, "KeySet requested for unknown package:" + packageName);
|
||||
throw new IllegalArgumentException("Unknown package: " + packageName);
|
||||
}
|
||||
if (pkg.applicationInfo.uid != Binder.getCallingUid()
|
||||
&& Process.SYSTEM_UID != Binder.getCallingUid()) {
|
||||
throw new SecurityException("May not access KeySets defined by"
|
||||
+ " aliases in other applications.");
|
||||
}
|
||||
KeySetManagerService ksms = mSettings.mKeySetManagerService;
|
||||
return ksms.getKeySetByAliasAndPackageNameLPr(packageName, alias);
|
||||
return new KeySet(ksms.getKeySetByAliasAndPackageNameLPr(packageName, alias));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public KeySetHandle getSigningKeySet(String packageName) {
|
||||
public KeySet getSigningKeySet(String packageName) {
|
||||
if (packageName == null) {
|
||||
return null;
|
||||
}
|
||||
@@ -13168,12 +13164,12 @@ public class PackageManagerService extends IPackageManager.Stub {
|
||||
throw new SecurityException("May not access signing KeySet of other apps.");
|
||||
}
|
||||
KeySetManagerService ksms = mSettings.mKeySetManagerService;
|
||||
return ksms.getSigningKeySetByPackageNameLPr(packageName);
|
||||
return new KeySet(ksms.getSigningKeySetByPackageNameLPr(packageName));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPackageSignedByKeySet(String packageName, IBinder ks) {
|
||||
public boolean isPackageSignedByKeySet(String packageName, KeySet ks) {
|
||||
if (packageName == null || ks == null) {
|
||||
return false;
|
||||
}
|
||||
@@ -13183,16 +13179,17 @@ public class PackageManagerService extends IPackageManager.Stub {
|
||||
Slog.w(TAG, "KeySet requested for unknown package:" + packageName);
|
||||
throw new IllegalArgumentException("Unknown package: " + packageName);
|
||||
}
|
||||
if (ks instanceof KeySetHandle) {
|
||||
IBinder ksh = ks.getToken();
|
||||
if (ksh instanceof KeySetHandle) {
|
||||
KeySetManagerService ksms = mSettings.mKeySetManagerService;
|
||||
return ksms.packageIsSignedByLPr(packageName, (KeySetHandle) ks);
|
||||
return ksms.packageIsSignedByLPr(packageName, (KeySetHandle) ksh);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPackageSignedByKeySetExactly(String packageName, IBinder ks) {
|
||||
public boolean isPackageSignedByKeySetExactly(String packageName, KeySet ks) {
|
||||
if (packageName == null || ks == null) {
|
||||
return false;
|
||||
}
|
||||
@@ -13202,9 +13199,10 @@ public class PackageManagerService extends IPackageManager.Stub {
|
||||
Slog.w(TAG, "KeySet requested for unknown package:" + packageName);
|
||||
throw new IllegalArgumentException("Unknown package: " + packageName);
|
||||
}
|
||||
if (ks instanceof KeySetHandle) {
|
||||
IBinder ksh = ks.getToken();
|
||||
if (ksh instanceof KeySetHandle) {
|
||||
KeySetManagerService ksms = mSettings.mKeySetManagerService;
|
||||
return ksms.packageIsSignedByExactlyLPr(packageName, (KeySetHandle) ks);
|
||||
return ksms.packageIsSignedByExactlyLPr(packageName, (KeySetHandle) ksh);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -617,21 +617,25 @@ public class MockPackageManager extends PackageManager {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
/** @hide */
|
||||
@Override
|
||||
public KeySet getKeySetByAlias(String packageName, String alias) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
/** @hide */
|
||||
@Override
|
||||
public KeySet getSigningKeySet(String packageName) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
/** @hide */
|
||||
@Override
|
||||
public boolean isSignedBy(String packageName, KeySet ks) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
/** @hide */
|
||||
@Override
|
||||
public boolean isSignedByExactly(String packageName, KeySet ks) {
|
||||
throw new UnsupportedOperationException();
|
||||
|
||||
Reference in New Issue
Block a user