diff options
23 files changed, 175 insertions, 733 deletions
diff --git a/api/current.txt b/api/current.txt index 3f3d026de54e..9ff38f9d0c09 100644 --- a/api/current.txt +++ b/api/current.txt @@ -6751,7 +6751,6 @@ package android.content { method public final android.os.Bundle call(android.net.Uri, java.lang.String, java.lang.String, android.os.Bundle); method public deprecated void cancelSync(android.net.Uri); method public static void cancelSync(android.accounts.Account, java.lang.String); - method public static void cancelSync(android.content.ComponentName); method public static void cancelSync(android.content.SyncRequest); method public final android.net.Uri canonicalize(android.net.Uri); method public final int delete(android.net.Uri, java.lang.String, java.lang.String[]); @@ -6761,18 +6760,14 @@ package android.content { method public static boolean getMasterSyncAutomatically(); method public java.util.List<android.content.UriPermission> getOutgoingPersistedUriPermissions(); method public static java.util.List<android.content.PeriodicSync> getPeriodicSyncs(android.accounts.Account, java.lang.String); - method public static java.util.List<android.content.PeriodicSync> getPeriodicSyncs(android.content.ComponentName); method public java.util.List<android.content.UriPermission> getPersistedUriPermissions(); method public java.lang.String[] getStreamTypes(android.net.Uri, java.lang.String); method public static android.content.SyncAdapterType[] getSyncAdapterTypes(); method public static boolean getSyncAutomatically(android.accounts.Account, java.lang.String); method public final java.lang.String getType(android.net.Uri); method public final android.net.Uri insert(android.net.Uri, android.content.ContentValues); - method public static boolean isServiceActive(android.content.ComponentName); method public static boolean isSyncActive(android.accounts.Account, java.lang.String); - method public static boolean isSyncActive(android.content.ComponentName); method public static boolean isSyncPending(android.accounts.Account, java.lang.String); - method public static boolean isSyncPending(android.content.ComponentName); method public void notifyChange(android.net.Uri, android.database.ContentObserver); method public void notifyChange(android.net.Uri, android.database.ContentObserver, boolean); method public final android.content.res.AssetFileDescriptor openAssetFileDescriptor(android.net.Uri, java.lang.String) throws java.io.FileNotFoundException; @@ -6794,7 +6789,6 @@ package android.content { method public static void requestSync(android.content.SyncRequest); method public static void setIsSyncable(android.accounts.Account, java.lang.String, int); method public static void setMasterSyncAutomatically(boolean); - method public static void setServiceActive(android.content.ComponentName, boolean); method public static void setSyncAutomatically(android.accounts.Account, java.lang.String, boolean); method public deprecated void startSync(android.net.Uri, android.os.Bundle); method public void takePersistableUriPermission(android.net.Uri, int); @@ -7762,9 +7756,7 @@ package android.content { field public final android.accounts.Account account; field public final java.lang.String authority; field public final android.os.Bundle extras; - field public final boolean isService; field public final long period; - field public final android.content.ComponentName service; } public class ReceiverCallNotAllowedException extends android.util.AndroidRuntimeException { @@ -7880,7 +7872,6 @@ package android.content { method public void writeToParcel(android.os.Parcel, int); field public final android.accounts.Account account; field public final java.lang.String authority; - field public final android.content.ComponentName service; field public final long startTime; } @@ -7903,8 +7894,6 @@ package android.content { method public android.content.SyncRequest.Builder setNoRetry(boolean); method public android.content.SyncRequest.Builder setPriority(int); method public android.content.SyncRequest.Builder setSyncAdapter(android.accounts.Account, java.lang.String); - method public android.content.SyncRequest.Builder setSyncAdapter(android.content.ComponentName); - method public android.content.SyncRequest.Builder setTransferSize(long, long); method public android.content.SyncRequest.Builder syncOnce(); method public android.content.SyncRequest.Builder syncPeriodic(long, long); } @@ -7932,13 +7921,6 @@ package android.content { field public boolean tooManyRetries; } - public abstract class SyncService extends android.app.Service { - ctor public SyncService(); - method public android.os.IBinder onBind(android.content.Intent); - method public abstract void onPerformSync(android.os.Bundle, android.content.SyncResult); - method protected boolean parallelSyncsEnabled(); - } - public class SyncStats implements android.os.Parcelable { ctor public SyncStats(); ctor public SyncStats(android.os.Parcel); @@ -12600,14 +12582,7 @@ package android.hardware.camera2 { public final class DngCreator implements java.lang.AutoCloseable { ctor public DngCreator(android.hardware.camera2.CameraCharacteristics, android.hardware.camera2.CaptureResult); method public void close(); - method public android.hardware.camera2.DngCreator setDescription(java.lang.String); - method public android.hardware.camera2.DngCreator setLocation(android.location.Location); - method public android.hardware.camera2.DngCreator setOrientation(int); - method public android.hardware.camera2.DngCreator setThumbnail(android.graphics.Bitmap); - method public android.hardware.camera2.DngCreator setThumbnail(android.media.Image); - method public void writeByteBuffer(java.io.OutputStream, android.util.Size, java.nio.ByteBuffer, long) throws java.io.IOException; method public void writeImage(java.io.OutputStream, android.media.Image) throws java.io.IOException; - method public void writeInputStream(java.io.OutputStream, android.util.Size, java.io.InputStream, long) throws java.io.IOException; } public final class TotalCaptureResult extends android.hardware.camera2.CaptureResult { diff --git a/core/java/android/content/ContentResolver.java b/core/java/android/content/ContentResolver.java index 7642e1349c76..392bfbc0b942 100644 --- a/core/java/android/content/ContentResolver.java +++ b/core/java/android/content/ContentResolver.java @@ -1839,19 +1839,6 @@ public abstract class ContentResolver { } /** - * Cancel any active or pending syncs that are running on this service. - * - * @param cname the service for which to cancel all active/pending operations. - */ - public static void cancelSync(ComponentName cname) { - try { - getContentService().cancelSync(null, null, cname); - } catch (RemoteException e) { - - } - } - - /** * Get information about the SyncAdapters that are known to the system. * @return an array of SyncAdapters that have registered with the system */ @@ -1991,13 +1978,13 @@ public abstract class ContentResolver { /** * Remove the specified sync. This will cancel any pending or active syncs. If the request is * for a periodic sync, this call will remove any future occurrences. - * <p>If a periodic sync is specified, the caller must hold the permission - * {@link android.Manifest.permission#WRITE_SYNC_SETTINGS}. If this SyncRequest targets a - * SyncService adapter,the calling application must be signed with the same certificate as the - * adapter. - *</p>It is possible to cancel a sync using a SyncRequest object that is not the same object + * <p> + * If a periodic sync is specified, the caller must hold the permission + * {@link android.Manifest.permission#WRITE_SYNC_SETTINGS}. + *</p> + * It is possible to cancel a sync using a SyncRequest object that is not the same object * with which you requested the sync. Do so by building a SyncRequest with the same - * service/adapter, frequency, <b>and</b> extras bundle. + * adapter, frequency, <b>and</b> extras bundle. * * @param request SyncRequest object containing information about sync to cancel. */ @@ -2031,22 +2018,6 @@ public abstract class ContentResolver { } /** - * Return periodic syncs associated with the provided component. - * <p>The calling application must be signed with the same certificate as the target component, - * otherwise this call will fail. - */ - public static List<PeriodicSync> getPeriodicSyncs(ComponentName cname) { - if (cname == null) { - throw new IllegalArgumentException("Component must not be null"); - } - try { - return getContentService().getPeriodicSyncs(null, null, cname); - } catch (RemoteException e) { - throw new RuntimeException("the ContentService should always be reachable", e); - } - } - - /** * Check if this account/provider is syncable. * <p>This method requires the caller to hold the permission * {@link android.Manifest.permission#READ_SYNC_SETTINGS}. @@ -2076,38 +2047,6 @@ public abstract class ContentResolver { } /** - * Set whether the provided {@link SyncService} is available to process work. - * <p>This method requires the caller to hold the permission - * {@link android.Manifest.permission#WRITE_SYNC_SETTINGS}. - * <p>The calling application must be signed with the same certificate as the target component, - * otherwise this call will fail. - */ - public static void setServiceActive(ComponentName cname, boolean active) { - try { - getContentService().setServiceActive(cname, active); - } catch (RemoteException e) { - // exception ignored; if this is thrown then it means the runtime is in the midst of - // being restarted - } - } - - /** - * Query the state of this sync service. - * <p>Set with {@link #setServiceActive(ComponentName cname, boolean active)}. - * <p>The calling application must be signed with the same certificate as the target component, - * otherwise this call will fail. - * @param cname ComponentName referring to a {@link SyncService} - * @return true if jobs will be run on this service, false otherwise. - */ - public static boolean isServiceActive(ComponentName cname) { - try { - return getContentService().isServiceActive(cname); - } catch (RemoteException e) { - throw new RuntimeException("the ContentService should always be reachable", e); - } - } - - /** * Gets the master auto-sync setting that applies to all the providers and accounts. * If this is false then the per-provider auto-sync setting is ignored. * <p>This method requires the caller to hold the permission @@ -2164,17 +2103,6 @@ public abstract class ContentResolver { } } - public static boolean isSyncActive(ComponentName cname) { - if (cname == null) { - throw new IllegalArgumentException("component name must not be null"); - } - try { - return getContentService().isSyncActive(null, null, cname); - } catch (RemoteException e) { - throw new RuntimeException("the ContentService should always be reachable", e); - } - } - /** * If a sync is active returns the information about it, otherwise returns null. * <p> @@ -2249,14 +2177,6 @@ public abstract class ContentResolver { } } - public static boolean isSyncPending(ComponentName cname) { - try { - return getContentService().isSyncPending(null, null, cname); - } catch (RemoteException e) { - throw new RuntimeException("the ContentService should always be reachable", e); - } - } - /** * Request notifications when the different aspects of the SyncManager change. The * different items that can be requested are: diff --git a/core/java/android/content/IContentService.aidl b/core/java/android/content/IContentService.aidl index 73a76e805127..373f2fb62494 100644 --- a/core/java/android/content/IContentService.aidl +++ b/core/java/android/content/IContentService.aidl @@ -121,19 +121,6 @@ interface IContentService { */ void setIsSyncable(in Account account, String providerName, int syncable); - /** - * Corresponds roughly to setIsSyncable(String account, String provider) for syncs that bind - * to a SyncService. - */ - void setServiceActive(in ComponentName cname, boolean active); - - /** - * Corresponds roughly to getIsSyncable(String account, String provider) for syncs that bind - * to a SyncService. - * @return 0 if this SyncService is not enabled, 1 if enabled, <0 if unknown. - */ - boolean isServiceActive(in ComponentName cname); - void setMasterSyncAutomatically(boolean flag); boolean getMasterSyncAutomatically(); diff --git a/core/java/android/content/PeriodicSync.java b/core/java/android/content/PeriodicSync.java index 836c6f8c6abf..3efd89aa38de 100644 --- a/core/java/android/content/PeriodicSync.java +++ b/core/java/android/content/PeriodicSync.java @@ -29,14 +29,10 @@ public class PeriodicSync implements Parcelable { public final Account account; /** The authority of the sync. Can be null. */ public final String authority; - /** The service for syncing, if this is an anonymous sync. Can be null.*/ - public final ComponentName service; /** Any extras that parameters that are to be passed to the sync adapter. */ public final Bundle extras; /** How frequently the sync should be scheduled, in seconds. Kept around for API purposes. */ public final long period; - /** Whether this periodic sync runs on a {@link SyncService}. */ - public final boolean isService; /** * How much flexibility can be taken in scheduling the sync, in seconds. * {@hide} @@ -44,16 +40,11 @@ public class PeriodicSync implements Parcelable { public final long flexTime; /** - * Creates a new PeriodicSync, copying the Bundle. SM no longer uses this ctor - kept around - * becuse it is part of the API. - * Note - even calls to the old API will not use this ctor, as - * they are given a default flex time. + * Creates a new PeriodicSync, copying the Bundle. This constructor is no longer used. */ public PeriodicSync(Account account, String authority, Bundle extras, long periodInSeconds) { this.account = account; this.authority = authority; - this.service = null; - this.isService = false; if (extras == null) { this.extras = new Bundle(); } else { @@ -71,8 +62,6 @@ public class PeriodicSync implements Parcelable { public PeriodicSync(PeriodicSync other) { this.account = other.account; this.authority = other.authority; - this.service = other.service; - this.isService = other.isService; this.extras = new Bundle(other.extras); this.period = other.period; this.flexTime = other.flexTime; @@ -86,40 +75,14 @@ public class PeriodicSync implements Parcelable { long period, long flexTime) { this.account = account; this.authority = authority; - this.service = null; - this.isService = false; - this.extras = new Bundle(extras); - this.period = period; - this.flexTime = flexTime; - } - - /** - * A PeriodicSync for a sync with a specified SyncService. - * {@hide} - */ - public PeriodicSync(ComponentName service, Bundle extras, - long period, - long flexTime) { - this.account = null; - this.authority = null; - this.service = service; - this.isService = true; this.extras = new Bundle(extras); this.period = period; this.flexTime = flexTime; } private PeriodicSync(Parcel in) { - this.isService = (in.readInt() != 0); - if (this.isService) { - this.service = in.readParcelable(null); - this.account = null; - this.authority = null; - } else { - this.account = in.readParcelable(null); - this.authority = in.readString(); - this.service = null; - } + this.account = in.readParcelable(null); + this.authority = in.readString(); this.extras = in.readBundle(); this.period = in.readLong(); this.flexTime = in.readLong(); @@ -132,13 +95,8 @@ public class PeriodicSync implements Parcelable { @Override public void writeToParcel(Parcel dest, int flags) { - dest.writeInt(isService ? 1 : 0); - if (account == null && authority == null) { - dest.writeParcelable(service, flags); - } else { - dest.writeParcelable(account, flags); - dest.writeString(authority); - } + dest.writeParcelable(account, flags); + dest.writeString(authority); dest.writeBundle(extras); dest.writeLong(period); dest.writeLong(flexTime); @@ -165,24 +123,14 @@ public class PeriodicSync implements Parcelable { return false; } final PeriodicSync other = (PeriodicSync) o; - if (this.isService != other.isService) { - return false; - } - boolean equal = false; - if (this.isService) { - equal = service.equals(other.service); - } else { - equal = account.equals(other.account) - && authority.equals(other.authority); - } - return equal - && period == other.period - && syncExtrasEquals(extras, other.extras); + return account.equals(other.account) + && authority.equals(other.authority) + && period == other.period + && syncExtrasEquals(extras, other.extras); } /** - * Periodic sync extra comparison function. Duplicated from - * {@link com.android.server.content.SyncManager#syncExtrasEquals(Bundle b1, Bundle b2)} + * Periodic sync extra comparison function. * {@hide} */ public static boolean syncExtrasEquals(Bundle b1, Bundle b2) { @@ -207,7 +155,6 @@ public class PeriodicSync implements Parcelable { public String toString() { return "account: " + account + ", authority: " + authority + - ", service: " + service + ". period: " + period + "s " + ", flex: " + flexTime; } diff --git a/core/java/android/content/SyncInfo.java b/core/java/android/content/SyncInfo.java index 146dd99e9ef7..a586d6fc96ae 100644 --- a/core/java/android/content/SyncInfo.java +++ b/core/java/android/content/SyncInfo.java @@ -28,24 +28,16 @@ public class SyncInfo implements Parcelable { public final int authorityId; /** - * The {@link Account} that is currently being synced. Will be null if this sync is running via - * a {@link SyncService}. + * The {@link Account} that is currently being synced. */ public final Account account; /** - * The authority of the provider that is currently being synced. Will be null if this sync - * is running via a {@link SyncService}. + * The authority of the provider that is currently being synced. */ public final String authority; /** - * The {@link SyncService} that is targeted by this operation. Null if this sync is running via - * a {@link AbstractThreadedSyncAdapter}. - */ - public final ComponentName service; - - /** * The start time of the current sync operation in milliseconds since boot. * This is represented in elapsed real time. * See {@link android.os.SystemClock#elapsedRealtime()}. @@ -53,13 +45,11 @@ public class SyncInfo implements Parcelable { public final long startTime; /** @hide */ - public SyncInfo(int authorityId, Account account, String authority, ComponentName service, - long startTime) { + public SyncInfo(int authorityId, Account account, String authority, long startTime) { this.authorityId = authorityId; this.account = account; this.authority = authority; this.startTime = startTime; - this.service = service; } /** @hide */ @@ -68,7 +58,6 @@ public class SyncInfo implements Parcelable { this.account = new Account(other.account.name, other.account.type); this.authority = other.authority; this.startTime = other.startTime; - this.service = other.service; } /** @hide */ @@ -82,8 +71,6 @@ public class SyncInfo implements Parcelable { parcel.writeParcelable(account, flags); parcel.writeString(authority); parcel.writeLong(startTime); - parcel.writeParcelable(service, flags); - } /** @hide */ @@ -92,7 +79,6 @@ public class SyncInfo implements Parcelable { account = parcel.readParcelable(Account.class.getClassLoader()); authority = parcel.readString(); startTime = parcel.readLong(); - service = parcel.readParcelable(ComponentName.class.getClassLoader()); } /** @hide */ diff --git a/core/java/android/content/SyncRequest.java b/core/java/android/content/SyncRequest.java index 9ba45cac160a..869f85c900c5 100644 --- a/core/java/android/content/SyncRequest.java +++ b/core/java/android/content/SyncRequest.java @@ -27,23 +27,11 @@ public class SyncRequest implements Parcelable { private final Account mAccountToSync; /** Authority string that corresponds to a ContentProvider. */ private final String mAuthority; - /** {@link SyncService} identifier. */ - private final ComponentName mComponentInfo; /** Bundle containing user info as well as sync settings. */ private final Bundle mExtras; /** Don't allow this sync request on metered networks. */ private final boolean mDisallowMetered; /** - * Anticipated upload size in bytes. - * TODO: Not yet used - we put this information into the bundle for simplicity. - */ - private final long mTxBytes; - /** - * Anticipated download size in bytes. - * TODO: Not yet used - we put this information into the bundle. - */ - private final long mRxBytes; - /** * Amount of time before {@link #mSyncRunTimeSecs} from which the sync may optionally be * started. */ @@ -75,25 +63,12 @@ public class SyncRequest implements Parcelable { /** * {@hide} - * @return true if this sync uses an account/authority pair, or false if - * this is an anonymous sync bound to an @link AnonymousSyncService. - */ - public boolean hasAuthority() { - return mIsAuthority; - } - - /** - * {@hide} * * @return account object for this sync. * @throws IllegalArgumentException if this function is called for a request that targets a * sync service. */ public Account getAccount() { - if (!hasAuthority()) { - throw new IllegalArgumentException("Cannot getAccount() for a sync that targets a sync" - + "service."); - } return mAccountToSync; } @@ -105,30 +80,11 @@ public class SyncRequest implements Parcelable { * sync service. */ public String getProvider() { - if (!hasAuthority()) { - throw new IllegalArgumentException("Cannot getProvider() for a sync that targets a" - + "sync service."); - } return mAuthority; } /** * {@hide} - * Throws a runtime IllegalArgumentException if this function is called for a - * SyncRequest that is bound to an account/provider. - * - * @return ComponentName for the service that this sync will bind to. - */ - public ComponentName getService() { - if (hasAuthority()) { - throw new IllegalArgumentException( - "Cannot getAnonymousService() for a sync that has specified a provider."); - } - return mComponentInfo; - } - - /** - * {@hide} * Retrieve bundle for this SyncRequest. Will not be null. */ public Bundle getBundle() { @@ -175,16 +131,10 @@ public class SyncRequest implements Parcelable { parcel.writeLong(mSyncRunTimeSecs); parcel.writeInt((mIsPeriodic ? 1 : 0)); parcel.writeInt((mDisallowMetered ? 1 : 0)); - parcel.writeLong(mTxBytes); - parcel.writeLong(mRxBytes); parcel.writeInt((mIsAuthority ? 1 : 0)); parcel.writeInt((mIsExpedited? 1 : 0)); - if (mIsAuthority) { - parcel.writeParcelable(mAccountToSync, flags); - parcel.writeString(mAuthority); - } else { - parcel.writeParcelable(mComponentInfo, flags); - } + parcel.writeParcelable(mAccountToSync, flags); + parcel.writeString(mAuthority); } private SyncRequest(Parcel in) { @@ -193,19 +143,10 @@ public class SyncRequest implements Parcelable { mSyncRunTimeSecs = in.readLong(); mIsPeriodic = (in.readInt() != 0); mDisallowMetered = (in.readInt() != 0); - mTxBytes = in.readLong(); - mRxBytes = in.readLong(); mIsAuthority = (in.readInt() != 0); mIsExpedited = (in.readInt() != 0); - if (mIsAuthority) { - mComponentInfo = null; - mAccountToSync = in.readParcelable(null); - mAuthority = in.readString(); - } else { - mComponentInfo = in.readParcelable(null); - mAccountToSync = null; - mAuthority = null; - } + mAccountToSync = in.readParcelable(null); + mAuthority = in.readString(); } /** {@hide} Protected ctor to instantiate anonymous SyncRequest. */ @@ -214,7 +155,6 @@ public class SyncRequest implements Parcelable { mSyncRunTimeSecs = b.mSyncRunTimeSecs; mAccountToSync = b.mAccount; mAuthority = b.mAuthority; - mComponentInfo = b.mComponentName; mIsPeriodic = (b.mSyncType == Builder.SYNC_TYPE_PERIODIC); mIsAuthority = (b.mSyncTarget == Builder.SYNC_TARGET_ADAPTER); mIsExpedited = b.mExpedited; @@ -223,8 +163,6 @@ public class SyncRequest implements Parcelable { // TODO: pass the configuration extras through separately. mExtras.putAll(b.mSyncConfigExtras); mDisallowMetered = b.mDisallowMetered; - mTxBytes = b.mTxBytes; - mRxBytes = b.mRxBytes; } /** @@ -240,8 +178,6 @@ public class SyncRequest implements Parcelable { private static final int SYNC_TYPE_ONCE = 2; /** Unknown sync target. */ private static final int SYNC_TARGET_UNKNOWN = 0; - /** Specify that this is an anonymous sync. */ - private static final int SYNC_TARGET_SERVICE = 1; /** Specify that this is a sync with a provider. */ private static final int SYNC_TARGET_ADAPTER = 2; /** @@ -275,7 +211,7 @@ public class SyncRequest implements Parcelable { * Whether this builder is building a periodic sync, or a one-time sync. */ private int mSyncType = SYNC_TYPE_UNKNOWN; - /** Whether this will go to a sync adapter or to a sync service. */ + /** Whether this will go to a sync adapter. */ private int mSyncTarget = SYNC_TARGET_UNKNOWN; /** Whether this is a user-activated sync. */ private boolean mIsManual; @@ -298,12 +234,6 @@ public class SyncRequest implements Parcelable { private boolean mExpedited; /** - * The {@link SyncService} component that - * contains the sync logic if this is a provider-less sync, otherwise - * null. - */ - private ComponentName mComponentName; - /** * The Account object that together with an Authority name define the SyncAdapter (if * this sync is bound to a provider), otherwise null. */ @@ -336,7 +266,7 @@ public class SyncRequest implements Parcelable { /** * Build a periodic sync. Either this or syncOnce() <b>must</b> be called for this builder. - * Syncs are identified by target {@link SyncService}/{@link android.provider} and by the + * Syncs are identified by target {@link android.provider} and by the * contents of the extras bundle. * You cannot reuse the same builder for one-time syncs after having specified a periodic * sync (by calling this function). If you do, an <code>IllegalArgumentException</code> @@ -395,23 +325,10 @@ public class SyncRequest implements Parcelable { } /** - * Developer can provide insight into their payload size; optional. -1 specifies unknown, - * so that you are not restricted to defining both fields. - * - * @param rxBytes Bytes expected to be downloaded. - * @param txBytes Bytes expected to be uploaded. - */ - public Builder setTransferSize(long rxBytes, long txBytes) { - mRxBytes = rxBytes; - mTxBytes = txBytes; - return this; - } - - /** * Will throw an <code>IllegalArgumentException</code> if called and * {@link #setIgnoreSettings(boolean ignoreSettings)} has already been called. * @param disallow true to allow this transfer on metered networks. Default false. - * + * */ public Builder setDisallowMetered(boolean disallow) { if (mIgnoreSettings && disallow) { @@ -423,10 +340,9 @@ public class SyncRequest implements Parcelable { } /** - * Specify an authority and account for this transfer. Cannot be used with - * {@link #setSyncAdapter(ComponentName cname)}. + * Specify an authority and account for this transfer. * - * @param authority + * @param authority A String identifying the content provider to be synced. * @param account Account to sync. Can be null unless this is a periodic * sync, for which verification by the ContentResolver will * fail. If a sync is performed without an account, the @@ -441,25 +357,6 @@ public class SyncRequest implements Parcelable { mSyncTarget = SYNC_TARGET_ADAPTER; mAccount = account; mAuthority = authority; - mComponentName = null; - return this; - } - - /** - * Specify the {@link SyncService} component for this sync. This is not validated until - * sync time so providing an incorrect component name here will not fail. Cannot be used - * with {@link #setSyncAdapter(Account account, String authority)}. - * - * @param cname ComponentName to identify your Anonymous service - */ - public Builder setSyncAdapter(ComponentName cname) { - if (mSyncTarget != SYNC_TARGET_UNKNOWN) { - throw new IllegalArgumentException("Sync target has already been defined."); - } - mSyncTarget = SYNC_TARGET_SERVICE; - mComponentName = cname; - mAccount = null; - mAuthority = null; return this; } @@ -630,25 +527,17 @@ public class SyncRequest implements Parcelable { mSyncConfigExtras.putInt(ContentResolver.SYNC_EXTRAS_PRIORITY, mPriority); if (mSyncType == SYNC_TYPE_PERIODIC) { // If this is a periodic sync ensure than invalid extras were not set. - if (ContentResolver.invalidPeriodicExtras(mCustomExtras) || + if (ContentResolver.invalidPeriodicExtras(mCustomExtras) || ContentResolver.invalidPeriodicExtras(mSyncConfigExtras)) { throw new IllegalArgumentException("Illegal extras were set"); } - } else if (mSyncType == SYNC_TYPE_UNKNOWN) { - throw new IllegalArgumentException("Must call either syncOnce() or syncPeriodic()"); - } - if (mSyncTarget == SYNC_TARGET_SERVICE) { - if (mSyncConfigExtras.getBoolean(ContentResolver.SYNC_EXTRAS_INITIALIZE, false)) { - throw new IllegalArgumentException("Cannot specify an initialisation sync" - + " that targets a service."); - } } // Ensure that a target for the sync has been set. if (mSyncTarget == SYNC_TARGET_UNKNOWN) { - throw new IllegalArgumentException("Must specify an adapter with one of" - + "setSyncAdapter(ComponentName) or setSyncAdapter(Account, String"); + throw new IllegalArgumentException("Must specify an adapter with" + + " setSyncAdapter(Account, String"); } return new SyncRequest(this); } - } + } } diff --git a/core/java/android/content/SyncService.java b/core/java/android/content/SyncService.java deleted file mode 100644 index 4df998cddc4e..000000000000 --- a/core/java/android/content/SyncService.java +++ /dev/null @@ -1,211 +0,0 @@ -/* - * Copyright (C) 2013 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; - -import android.app.Service; -import android.os.Bundle; -import android.os.IBinder; -import android.os.Process; -import android.os.Trace; -import android.util.SparseArray; -import android.util.Log; - -import com.android.internal.annotations.GuardedBy; - -/** - * Simplified @link android.content.AbstractThreadedSyncAdapter. Folds that - * behaviour into a service to which the system can bind when requesting an - * anonymous (providerless/accountless) sync. - * <p> - * In order to perform an anonymous sync operation you must extend this service, implementing the - * abstract methods. This service must be declared in the application's manifest as usual. You - * can use this service for other work, however you <b> must not </b> override the onBind() method - * unless you know what you're doing, which limits the usefulness of this service for other work. - * <p>A {@link SyncService} can either be active or inactive. Different to an - * {@link AbstractThreadedSyncAdapter}, there is no - * {@link ContentResolver#setSyncAutomatically(android.accounts.Account account, String provider, boolean sync)}, - * as well as no concept of initialisation (you can handle your own if needed). - * - * <pre> - * <service android:name=".MySyncService"/> - * </pre> - * Like @link android.content.AbstractThreadedSyncAdapter this service supports - * multiple syncs at the same time. Each incoming startSync() with a unique tag - * will spawn a thread to do the work of that sync. If startSync() is called - * with a tag that already exists, a SyncResult.ALREADY_IN_PROGRESS is returned. - * Remember that your service will spawn multiple threads if you schedule multiple syncs - * at once, so if you mutate local objects you must ensure synchronization. - */ -public abstract class SyncService extends Service { - private static final String TAG = "SyncService"; - - private final SyncAdapterImpl mSyncAdapter = new SyncAdapterImpl(); - - /** Keep track of on-going syncs, keyed by bundle. */ - @GuardedBy("mSyncThreadLock") - private final SparseArray<SyncThread> - mSyncThreads = new SparseArray<SyncThread>(); - /** Lock object for accessing the SyncThreads HashMap. */ - private final Object mSyncThreadLock = new Object(); - /** - * Default key for if this sync service does not support parallel operations. Currently not - * sure if null keys will make it into the ArrayMap for KLP, so keeping our default for now. - */ - private static final int KEY_DEFAULT = 0; - /** Identifier for this sync service. */ - private ComponentName mServiceComponent; - - /** {@hide} */ - public IBinder onBind(Intent intent) { - mServiceComponent = new ComponentName(this, getClass()); - return mSyncAdapter.asBinder(); - } - - /** {@hide} */ - private class SyncAdapterImpl extends ISyncServiceAdapter.Stub { - @Override - public void startSync(ISyncContext syncContext, Bundle extras) { - // Wrap the provided Sync Context because it may go away by the time - // we call it. - final SyncContext syncContextClient = new SyncContext(syncContext); - boolean alreadyInProgress = false; - final int extrasAsKey = extrasToKey(extras); - synchronized (mSyncThreadLock) { - if (mSyncThreads.get(extrasAsKey) == null) { - if (Log.isLoggable(TAG, Log.VERBOSE)) { - Log.v(TAG, "starting sync for : " + mServiceComponent); - } - // Start sync. - SyncThread syncThread = new SyncThread(syncContextClient, extras); - mSyncThreads.put(extrasAsKey, syncThread); - syncThread.start(); - } else { - // Don't want to call back to SyncManager while still - // holding lock. - alreadyInProgress = true; - } - } - if (alreadyInProgress) { - syncContextClient.onFinished(SyncResult.ALREADY_IN_PROGRESS); - } - } - - /** - * Used by the SM to cancel a specific sync using the - * com.android.server.content.SyncManager.ActiveSyncContext as a handle. - */ - @Override - public void cancelSync(ISyncContext syncContext) { - SyncThread runningSync = null; - synchronized (mSyncThreadLock) { - for (int i = 0; i < mSyncThreads.size(); i++) { - SyncThread thread = mSyncThreads.valueAt(i); - if (thread.mSyncContext.getSyncContextBinder() == syncContext.asBinder()) { - runningSync = thread; - break; - } - } - } - if (runningSync != null) { - runningSync.interrupt(); - } - } - } - - /** - * - * @param extras Bundle for which to compute hash - * @return an integer hash that is equal to that of another bundle if they both contain the - * same key -> value mappings, however, not necessarily in order. - * Based on the toString() representation of the value mapped. - */ - private int extrasToKey(Bundle extras) { - int hash = KEY_DEFAULT; // Empty bundle, or no parallel operations enabled. - if (parallelSyncsEnabled()) { - for (String key : extras.keySet()) { - String mapping = key + " " + extras.get(key).toString(); - hash += mapping.hashCode(); - } - } - return hash; - } - - /** - * {@hide} - * Similar to {@link android.content.AbstractThreadedSyncAdapter.SyncThread}. However while - * the ATSA considers an already in-progress sync to be if the account provided is currently - * syncing, this anonymous sync has no notion of account and considers a sync unique if the - * provided bundle is different. - */ - private class SyncThread extends Thread { - private final SyncContext mSyncContext; - private final Bundle mExtras; - private final int mThreadsKey; - - public SyncThread(SyncContext syncContext, Bundle extras) { - mSyncContext = syncContext; - mExtras = extras; - mThreadsKey = extrasToKey(extras); - } - - @Override - public void run() { - Process.setThreadPriority(Process.THREAD_PRIORITY_BACKGROUND); - - Trace.traceBegin(Trace.TRACE_TAG_SYNC_MANAGER, getApplication().getPackageName()); - - SyncResult syncResult = new SyncResult(); - try { - if (isCancelled()) return; - // Run the sync. - SyncService.this.onPerformSync(mExtras, syncResult); - } finally { - Trace.traceEnd(Trace.TRACE_TAG_SYNC_MANAGER); - if (!isCancelled()) { - mSyncContext.onFinished(syncResult); - } - // Synchronize so that the assignment will be seen by other - // threads that also synchronize accesses to mSyncThreads. - synchronized (mSyncThreadLock) { - mSyncThreads.remove(mThreadsKey); - } - } - } - - private boolean isCancelled() { - return Thread.currentThread().isInterrupted(); - } - } - - /** - * Initiate an anonymous sync using this service. SyncAdapter-specific - * parameters may be specified in extras, which is guaranteed to not be - * null. - */ - public abstract void onPerformSync(Bundle extras, SyncResult syncResult); - - /** - * Override this function to indicated whether you want to support parallel syncs. - * <p>If you override and return true multiple threads will be spawned within your Service to - * handle each concurrent sync request. - * - * @return false to indicate that this service does not support parallel operations by default. - */ - protected boolean parallelSyncsEnabled() { - return false; - } -} diff --git a/core/java/android/hardware/camera2/CameraCharacteristics.java b/core/java/android/hardware/camera2/CameraCharacteristics.java index 2f5b4feee781..222374a0e72a 100644 --- a/core/java/android/hardware/camera2/CameraCharacteristics.java +++ b/core/java/android/hardware/camera2/CameraCharacteristics.java @@ -810,6 +810,7 @@ public final class CameraCharacteristics extends CameraMetadata<CameraCharacteri * {@link CameraCharacteristics#INFO_SUPPORTED_HARDWARE_LEVEL android.info.supportedHardwareLevel} <code>==</code> FULL devices:</p> * <ul> * <li>MANUAL_SENSOR</li> + * <li>MANUAL_POST_PROCESSING</li> * </ul> * <p>Other capabilities may be available on either FULL or LIMITED * devices, but the app. should query this field to be sure.</p> @@ -1033,8 +1034,6 @@ public final class CameraCharacteristics extends CameraMetadata<CameraCharacteri * (i.e. format, width, height, output/input stream).</p> * <p>The configurations are listed as <code>(format, width, height, input?)</code> * tuples.</p> - * <p>All camera devices will support sensor maximum resolution (defined by - * {@link CameraCharacteristics#SENSOR_INFO_ACTIVE_ARRAY_SIZE android.sensor.info.activeArraySize}) for the JPEG format.</p> * <p>For a given use case, the actual maximum supported resolution * may be lower than what is listed here, depending on the destination * Surface for the image data. For example, for recording video, diff --git a/core/java/android/hardware/camera2/DngCreator.java b/core/java/android/hardware/camera2/DngCreator.java index e64deeb3a435..3e3303cbb09a 100644 --- a/core/java/android/hardware/camera2/DngCreator.java +++ b/core/java/android/hardware/camera2/DngCreator.java @@ -121,6 +121,7 @@ public final class DngCreator implements AutoCloseable { * <li>{@link android.media.ExifInterface#ORIENTATION_ROTATE_270}</li> * </ul> * @return this {@link #DngCreator} object. + * @hide */ public DngCreator setOrientation(int orientation) { @@ -147,6 +148,7 @@ public final class DngCreator implements AutoCloseable { * * @param pixels a {@link android.graphics.Bitmap} of pixel data. * @return this {@link #DngCreator} object. + * @hide */ public DngCreator setThumbnail(Bitmap pixels) { if (pixels == null) { @@ -180,6 +182,7 @@ public final class DngCreator implements AutoCloseable { * @param pixels an {@link android.media.Image} object with the format * {@link android.graphics.ImageFormat#YUV_420_888}. * @return this {@link #DngCreator} object. + * @hide */ public DngCreator setThumbnail(Image pixels) { if (pixels == null) { @@ -216,6 +219,7 @@ public final class DngCreator implements AutoCloseable { * * @throws java.lang.IllegalArgumentException if the given location object doesn't * contain enough information to set location metadata. + * @hide */ public DngCreator setLocation(Location location) { /*TODO*/ @@ -231,6 +235,7 @@ public final class DngCreator implements AutoCloseable { * * @param description the user description string. * @return this {@link #DngCreator} object. + * @hide */ public DngCreator setDescription(String description) { /*TODO*/ @@ -263,6 +268,7 @@ public final class DngCreator implements AutoCloseable { * @throws java.lang.IllegalStateException if not enough metadata information has been * set to write a well-formatted DNG file. * @throws java.lang.IllegalArgumentException if the size passed in does not match the + * @hide */ public void writeInputStream(OutputStream dngOutput, Size size, InputStream pixels, long offset) throws IOException { @@ -297,6 +303,7 @@ public final class DngCreator implements AutoCloseable { * @throws IOException if an error was encountered in the input or output stream. * @throws java.lang.IllegalStateException if not enough metadata information has been * set to write a well-formatted DNG file. + * @hide */ public void writeByteBuffer(OutputStream dngOutput, Size size, ByteBuffer pixels, long offset) throws IOException { diff --git a/core/java/android/widget/AbsListView.java b/core/java/android/widget/AbsListView.java index 9a46052242cd..372228c5337f 100644 --- a/core/java/android/widget/AbsListView.java +++ b/core/java/android/widget/AbsListView.java @@ -4028,12 +4028,10 @@ public abstract class AbsListView extends AdapterView<ListAdapter> implements Te final int scrollY = mScrollY; if (!mEdgeGlowTop.isFinished()) { final int restoreCount = canvas.save(); - final int leftPadding = mListPadding.left + mGlowPaddingLeft; - final int rightPadding = mListPadding.right + mGlowPaddingRight; - final int width = getWidth() - leftPadding - rightPadding; + final int width = getWidth(); int edgeY = Math.min(0, scrollY + mFirstPositionDistanceGuess); - canvas.translate(leftPadding, edgeY); + canvas.translate(0, edgeY); mEdgeGlowTop.setSize(width, getHeight()); if (mEdgeGlowTop.draw(canvas)) { invalidate(0, 0, getWidth(), @@ -4043,12 +4041,10 @@ public abstract class AbsListView extends AdapterView<ListAdapter> implements Te } if (!mEdgeGlowBottom.isFinished()) { final int restoreCount = canvas.save(); - final int leftPadding = mListPadding.left + mGlowPaddingLeft; - final int rightPadding = mListPadding.right + mGlowPaddingRight; - final int width = getWidth() - leftPadding - rightPadding; + final int width = getWidth(); final int height = getHeight(); - int edgeX = -width + leftPadding; + int edgeX = -width; int edgeY = Math.max(height, scrollY + mLastPositionDistanceGuess); canvas.translate(edgeX, edgeY); canvas.rotate(180, width, 0); diff --git a/core/java/android/widget/EdgeEffect.java b/core/java/android/widget/EdgeEffect.java index b2315ffb20af..25029541677c 100644 --- a/core/java/android/widget/EdgeEffect.java +++ b/core/java/android/widget/EdgeEffect.java @@ -312,8 +312,7 @@ public class EdgeEffect { final float displacement = Math.max(0, Math.min(mDisplacement, 1.f)) - 0.5f; float translateX = mBounds.width() * displacement / 2; - canvas.clipRect(Float.MIN_VALUE, mBounds.top, - Float.MAX_VALUE, Float.MAX_VALUE); + canvas.clipRect(mBounds); canvas.translate(translateX, 0); canvas.drawArc(mArcRect, 45, 90, true, mPaint); canvas.restoreToCount(count); diff --git a/core/java/android/widget/ShareActionProvider.java b/core/java/android/widget/ShareActionProvider.java index 99a7886ed5f1..ac79d0575a46 100644 --- a/core/java/android/widget/ShareActionProvider.java +++ b/core/java/android/widget/ShareActionProvider.java @@ -280,6 +280,7 @@ public class ShareActionProvider extends ActionProvider { final String action = shareIntent.getAction(); if (Intent.ACTION_SEND.equals(action) || Intent.ACTION_SEND_MULTIPLE.equals(action)) { shareIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_DOCUMENT | + Intent.FLAG_ACTIVITY_MULTIPLE_TASK | Intent.FLAG_ACTIVITY_AUTO_REMOVE_FROM_RECENTS); } } @@ -303,6 +304,7 @@ public class ShareActionProvider extends ActionProvider { if (Intent.ACTION_SEND.equals(action) || Intent.ACTION_SEND_MULTIPLE.equals(action)) { launchIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_DOCUMENT | + Intent.FLAG_ACTIVITY_MULTIPLE_TASK | Intent.FLAG_ACTIVITY_AUTO_REMOVE_FROM_RECENTS); } mContext.startActivity(launchIntent); diff --git a/core/java/com/android/internal/app/ChooserActivity.java b/core/java/com/android/internal/app/ChooserActivity.java index 106ac0b2ef0a..877938ed9ddd 100644 --- a/core/java/com/android/internal/app/ChooserActivity.java +++ b/core/java/com/android/internal/app/ChooserActivity.java @@ -38,6 +38,7 @@ public class ChooserActivity extends ResolverActivity { if (Intent.ACTION_SEND.equals(action) || Intent.ACTION_SEND_MULTIPLE.equals(action)) { target.addFlags(Intent.FLAG_ACTIVITY_NEW_DOCUMENT | + Intent.FLAG_ACTIVITY_MULTIPLE_TASK | Intent.FLAG_ACTIVITY_AUTO_REMOVE_FROM_RECENTS); } } @@ -61,6 +62,7 @@ public class ChooserActivity extends ResolverActivity { if (Intent.ACTION_SEND.equals(action) || Intent.ACTION_SEND_MULTIPLE.equals(action)) { in.addFlags(Intent.FLAG_ACTIVITY_NEW_DOCUMENT | + Intent.FLAG_ACTIVITY_MULTIPLE_TASK | Intent.FLAG_ACTIVITY_AUTO_REMOVE_FROM_RECENTS); } initialIntents[i] = in; diff --git a/core/java/com/android/internal/widget/ActionBarView.java b/core/java/com/android/internal/widget/ActionBarView.java index aa642fd55c8a..77559c0ba3f6 100644 --- a/core/java/com/android/internal/widget/ActionBarView.java +++ b/core/java/com/android/internal/widget/ActionBarView.java @@ -755,6 +755,7 @@ public class ActionBarView extends AbsActionBarView implements DecorToolbar { mNavItemSelectedListener = l; if (mSpinner != null) { mSpinner.setAdapter(adapter); + mSpinner.setOnItemSelectedListener(l); } } diff --git a/core/jni/android/graphics/TypefaceImpl.cpp b/core/jni/android/graphics/TypefaceImpl.cpp index ff52b07740ef..786d19c49486 100644 --- a/core/jni/android/graphics/TypefaceImpl.cpp +++ b/core/jni/android/graphics/TypefaceImpl.cpp @@ -134,18 +134,19 @@ static TypefaceImpl* createFromSkTypeface(SkTypeface* typeface) { return result; } +// Delete when removing USE_MINIKIN ifdef TypefaceImpl* TypefaceImpl_createFromName(const char* name, SkTypeface::Style style) { - // TODO: should create a font collection with all styles corresponding to - // the name SkTypeface* face = SkTypeface::CreateFromName(name, style); return createFromSkTypeface(face); } +// Delete when removing USE_MINIKIN ifdef TypefaceImpl* TypefaceImpl_createFromFile(const char* filename) { SkTypeface* face = SkTypeface::CreateFromFile(filename); return createFromSkTypeface(face); } +// Delete when removing USE_MINIKIN ifdef TypefaceImpl* TypefaceImpl_createFromAsset(Asset* asset) { SkStream* stream = new AssetStreamAdaptor(asset, AssetStreamAdaptor::kYes_OwnAsset, @@ -158,7 +159,6 @@ TypefaceImpl* TypefaceImpl_createFromAsset(Asset* asset) { } TypefaceImpl* TypefaceImpl_createFromFamilies(const jlong* families, size_t size) { - ALOGD("createFromFamilies size=%d", size); std::vector<FontFamily *>familyVec; for (size_t i = 0; i < size; i++) { FontFamily* family = reinterpret_cast<FontFamily*>(families[i]); @@ -166,7 +166,18 @@ TypefaceImpl* TypefaceImpl_createFromFamilies(const jlong* families, size_t size } TypefaceImpl* result = new TypefaceImpl; result->fFontCollection = new FontCollection(familyVec); - result->fStyle = FontStyle(); // TODO: improve + if (size == 0) { + ALOGW("createFromFamilies creating empty collection"); + result->fStyle = FontStyle(); + } else { + const FontStyle defaultStyle; + FontFamily* firstFamily = reinterpret_cast<FontFamily*>(families[0]); + MinikinFont* mf = firstFamily->getClosestMatch(defaultStyle); + SkTypeface* skTypeface = reinterpret_cast<MinikinFontSkia*>(mf)->GetSkTypeface(); + // TODO: probably better to query more precise style from family, will be important + // when we open up API to access 100..900 weights + result->fStyle = styleFromSkiaStyle(skTypeface->style()); + } return result; } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelView.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelView.java index b28dad7a38ea..7926d03fd259 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelView.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelView.java @@ -698,11 +698,9 @@ public class NotificationPanelView extends PanelView implements @Override protected int getMaxPanelHeight() { // TODO: Figure out transition for collapsing when QS is open, adjust height here. - int maxPanelHeight = super.getMaxPanelHeight(); int emptyBottomMargin = mNotificationStackScroller.getEmptyBottomMargin(); - emptyBottomMargin += mStackScrollerContainer.getHeight() - - mNotificationStackScroller.getHeight(); - int maxHeight = maxPanelHeight - emptyBottomMargin - mTopPaddingAdjustment; + int maxHeight = mNotificationStackScroller.getHeight() - emptyBottomMargin + - mTopPaddingAdjustment; maxHeight = Math.max(maxHeight, mStatusBarMinHeight); return maxHeight; } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/stack/NotificationStackScrollLayout.java b/packages/SystemUI/src/com/android/systemui/statusbar/stack/NotificationStackScrollLayout.java index c29f1059e682..038370606985 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/stack/NotificationStackScrollLayout.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/stack/NotificationStackScrollLayout.java @@ -108,6 +108,7 @@ public class NotificationStackScrollLayout extends ViewGroup private ArrayList<View> mSwipedOutViews = new ArrayList<View>(); private final StackStateAnimator mStateAnimator = new StackStateAnimator(this); private boolean mAnimationsEnabled; + private boolean mChangePositionInProgress; /** * The raw amount of the overScroll on the top, which is not rubber-banded. @@ -1318,7 +1319,7 @@ public class NotificationStackScrollLayout extends ViewGroup protected void onViewRemoved(View child) { super.onViewRemoved(child); mStackScrollAlgorithm.notifyChildrenChanged(this); - if (mChildrenChangingPositions.contains(child)) { + if (mChangePositionInProgress) { // This is only a position change, don't do anything special return; } @@ -1413,7 +1414,7 @@ public class NotificationStackScrollLayout extends ViewGroup * @param child The view to be added. */ public void generateAddAnimation(View child) { - if (mIsExpanded && mAnimationsEnabled && !mChildrenChangingPositions.contains(child)) { + if (mIsExpanded && mAnimationsEnabled && !mChangePositionInProgress) { // Generate Animations mChildrenToAddAnimated.add(child); mNeedsAnimation = true; @@ -1428,10 +1429,14 @@ public class NotificationStackScrollLayout extends ViewGroup */ public void changeViewPosition(View child, int newIndex) { if (child != null && child.getParent() == this) { - mChildrenChangingPositions.add(child); + mChangePositionInProgress = true; removeView(child); addView(child, newIndex); - mNeedsAnimation = true; + mChangePositionInProgress = false; + if (mIsExpanded && mAnimationsEnabled) { + mChildrenChangingPositions.add(child); + mNeedsAnimation = true; + } } } diff --git a/services/core/java/com/android/server/ConnectivityService.java b/services/core/java/com/android/server/ConnectivityService.java index abb8cc5e255e..bd4576115b75 100644 --- a/services/core/java/com/android/server/ConnectivityService.java +++ b/services/core/java/com/android/server/ConnectivityService.java @@ -3103,7 +3103,7 @@ public class ConnectivityService extends IConnectivityManager.Stub { break; } Integer score = (Integer) msg.obj; - updateNetworkScore(nai, score); + if (score != null) updateNetworkScore(nai, score.intValue()); break; } case NetworkMonitor.EVENT_NETWORK_VALIDATED: { @@ -5915,9 +5915,30 @@ public class ConnectivityService extends IConnectivityManager.Stub { } } - private void updateNetworkScore(NetworkAgentInfo nai, Integer scoreInteger) { - int score = scoreInteger.intValue(); - // TODO + private void updateNetworkScore(NetworkAgentInfo nai, int score) { + if (DBG) log("updateNetworkScore for " + nai.name() + " to " + score); + + nai.currentScore = score; + + // TODO - This will not do the right thing if this network is lowering + // its score and has requests that can be served by other + // currently-active networks, or if the network is increasing its + // score and other networks have requests that can be better served + // by this network. + // + // Really we want to see if any of our requests migrate to other + // active/lingered networks and if any other requests migrate to us (depending + // on increasing/decreasing currentScore. That's a bit of work and probably our + // score checking/network allocation code needs to be modularized so we can understand + // (see handleConnectionValided for an example). + // + // As a first order approx, lets just advertise the new score to factories. If + // somebody can beat it they will nominate a network and our normal net replacement + // code will fire. + for (int i = 0; i < nai.networkRequests.size(); i++) { + NetworkRequest nr = nai.networkRequests.valueAt(i); + sendUpdatedScoreToFactories(nr, score); + } } // notify only this one new request of the current state diff --git a/services/core/java/com/android/server/content/ContentService.java b/services/core/java/com/android/server/content/ContentService.java index c7d28714e4db..c502bf3fdbb9 100644 --- a/services/core/java/com/android/server/content/ContentService.java +++ b/services/core/java/com/android/server/content/ContentService.java @@ -365,15 +365,8 @@ public final class ContentService extends IContentService.Stub { Manifest.permission.WRITE_SYNC_SETTINGS, "no permission to write the sync settings"); SyncStorageEngine.EndPoint info; - if (!request.hasAuthority()) { - // Extra permissions checking for sync service. - verifySignatureForPackage(callerUid, - request.getService().getPackageName(), "sync"); - info = new SyncStorageEngine.EndPoint(request.getService(), userId); - } else { - info = new SyncStorageEngine.EndPoint( - request.getAccount(), request.getProvider(), userId); - } + info = new SyncStorageEngine.EndPoint( + request.getAccount(), request.getProvider(), userId); if (runAtTime < 60) { Slog.w(TAG, "Requested poll frequency of " + runAtTime + " seconds being rounded up to 60 seconds."); @@ -385,17 +378,10 @@ public final class ContentService extends IContentService.Stub { } else { long beforeRuntimeMillis = (flextime) * 1000; long runtimeMillis = runAtTime * 1000; - if (request.hasAuthority()) { syncManager.scheduleSync( request.getAccount(), userId, callerUid, request.getProvider(), extras, beforeRuntimeMillis, runtimeMillis, false /* onlyThoseWithUnknownSyncableState */); - } else { - syncManager.scheduleSync( - request.getService(), userId, callerUid, extras, - beforeRuntimeMillis, - runtimeMillis); // Empty function. - } } } finally { restoreCallingIdentity(identityToken); @@ -442,22 +428,14 @@ public final class ContentService extends IContentService.Stub { SyncManager syncManager = getSyncManager(); if (syncManager == null) return; int userId = UserHandle.getCallingUserId(); - int callerUid = Binder.getCallingUid(); long identityToken = clearCallingIdentity(); try { SyncStorageEngine.EndPoint info; Bundle extras = new Bundle(request.getBundle()); - if (request.hasAuthority()) { - Account account = request.getAccount(); - String provider = request.getProvider(); - info = new SyncStorageEngine.EndPoint(account, provider, userId); - } else { - // Only allowed to manipulate syncs for a service which you own. - ComponentName service = request.getService(); - verifySignatureForPackage(callerUid, service.getPackageName(), "cancel"); - info = new SyncStorageEngine.EndPoint(service, userId); - } + Account account = request.getAccount(); + String provider = request.getProvider(); + info = new SyncStorageEngine.EndPoint(account, provider, userId); if (request.isPeriodic()) { // Remove periodic sync. mContext.enforceCallingOrSelfPermission(Manifest.permission.WRITE_SYNC_SETTINGS, @@ -599,20 +577,11 @@ public final class ContentService extends IContentService.Stub { mContext.enforceCallingOrSelfPermission(Manifest.permission.READ_SYNC_SETTINGS, "no permission to read the sync settings"); - int callerUid = Binder.getCallingUid(); int userId = UserHandle.getCallingUserId(); long identityToken = clearCallingIdentity(); try { - if (cname == null) { - return getSyncManager().getSyncStorageEngine().getPeriodicSyncs( - new SyncStorageEngine.EndPoint(account, providerName, userId)); - } else if (account == null && providerName == null) { - verifySignatureForPackage(callerUid, cname.getPackageName(), "getPeriodicSyncs"); - return getSyncManager().getSyncStorageEngine().getPeriodicSyncs( - new SyncStorageEngine.EndPoint(cname, userId)); - } else { - throw new IllegalArgumentException("Invalid authority specified"); - } + return getSyncManager().getSyncStorageEngine().getPeriodicSyncs( + new SyncStorageEngine.EndPoint(account, providerName, userId)); } finally { restoreCallingIdentity(identityToken); } @@ -656,45 +625,6 @@ public final class ContentService extends IContentService.Stub { } } - public void setServiceActive(ComponentName cname, boolean active) { - mContext.enforceCallingOrSelfPermission(Manifest.permission.WRITE_SYNC_SETTINGS, - "no permission to write the sync settings"); - verifySignatureForPackage(Binder.getCallingUid(), cname.getPackageName(), - "setServiceActive"); - - int userId = UserHandle.getCallingUserId(); - long identityToken = clearCallingIdentity(); - try { - SyncManager syncManager = getSyncManager(); - if (syncManager != null) { - syncManager.getSyncStorageEngine().setIsTargetServiceActive( - cname, userId, active); - } - } finally { - restoreCallingIdentity(identityToken); - } - } - - public boolean isServiceActive(ComponentName cname) { - mContext.enforceCallingOrSelfPermission(Manifest.permission.READ_SYNC_SETTINGS, - "no permission to read the sync settings"); - verifySignatureForPackage(Binder.getCallingUid(), cname.getPackageName(), - "isServiceActive"); - - int userId = UserHandle.getCallingUserId(); - long identityToken = clearCallingIdentity(); - try { - SyncManager syncManager = getSyncManager(); - if (syncManager != null) { - return syncManager.getSyncStorageEngine() - .getIsTargetServiceActive(cname, userId); - } - } finally { - restoreCallingIdentity(identityToken); - } - return false; - } - @Override public boolean getMasterSyncAutomatically() { mContext.enforceCallingOrSelfPermission(Manifest.permission.READ_SYNC_SETTINGS, @@ -741,18 +671,11 @@ public final class ContentService extends IContentService.Stub { if (syncManager == null) { return false; } - if (cname == null) { - return syncManager.getSyncStorageEngine().isSyncActive( - new SyncStorageEngine.EndPoint(account, authority, userId)); - } else if (account == null && authority == null) { - verifySignatureForPackage(callingUid, cname.getPackageName(), "isSyncActive"); - return syncManager.getSyncStorageEngine().isSyncActive( - new SyncStorageEngine.EndPoint(cname, userId)); - } + return syncManager.getSyncStorageEngine().isSyncActive( + new SyncStorageEngine.EndPoint(account, authority, userId)); } finally { restoreCallingIdentity(identityToken); } - return false; } public List<SyncInfo> getCurrentSyncs() { @@ -784,11 +707,8 @@ public final class ContentService extends IContentService.Stub { return null; } SyncStorageEngine.EndPoint info; - if (cname == null) { + if (!(account == null || authority == null)) { info = new SyncStorageEngine.EndPoint(account, authority, userId); - } else if (account == null && authority == null) { - verifySignatureForPackage(callerUid, cname.getPackageName(), "getSyncStatus"); - info = new SyncStorageEngine.EndPoint(cname, userId); } else { throw new IllegalArgumentException("Must call sync status with valid authority"); } @@ -810,11 +730,8 @@ public final class ContentService extends IContentService.Stub { try { SyncStorageEngine.EndPoint info; - if (cname == null) { + if (!(account == null || authority == null)) { info = new SyncStorageEngine.EndPoint(account, authority, userId); - } else if (account == null && authority == null) { - verifySignatureForPackage(callerUid, cname.getPackageName(), "isSyncPending"); - info = new SyncStorageEngine.EndPoint(cname, userId); } else { throw new IllegalArgumentException("Invalid authority specified"); } @@ -855,30 +772,6 @@ public final class ContentService extends IContentService.Stub { } /** - * Helper to verify that the provided package name shares the same cert as the caller. - * @param callerUid uid of the calling process. - * @param packageName package to verify against package of calling application. - * @param tag a tag to use when throwing an exception if the signatures don't - * match. Cannot be null. - * @return true if the calling application and the provided package are signed with the same - * certificate. - */ - private boolean verifySignatureForPackage(int callerUid, String packageName, String tag) { - PackageManager pm = mContext.getPackageManager(); - try { - int serviceUid = pm.getApplicationInfo(packageName, 0).uid; - if (pm.checkSignatures(callerUid, serviceUid) == PackageManager.SIGNATURE_MATCH) { - return true; - } else { - throw new SecurityException(tag + ": Caller certificate does not match that for - " - + packageName); - } - } catch (PackageManager.NameNotFoundException e) { - throw new IllegalArgumentException(tag + ": " + packageName + " package not found."); - } - } - - /** * Hide this class since it is not part of api, * but current unittest framework requires it to be public * @hide diff --git a/services/core/java/com/android/server/content/SyncStorageEngine.java b/services/core/java/com/android/server/content/SyncStorageEngine.java index 35c494d829c5..94993707b69a 100644 --- a/services/core/java/com/android/server/content/SyncStorageEngine.java +++ b/services/core/java/com/android/server/content/SyncStorageEngine.java @@ -925,10 +925,7 @@ public class SyncStorageEngine extends Handler { period, flextime); } else { - toUpdate = new PeriodicSync(info.service, - extras, - period, - flextime); + return; } AuthorityInfo authority = getOrCreateAuthorityLocked(info, -1, false); @@ -1246,7 +1243,6 @@ public class SyncStorageEngine extends Handler { authorityInfo.ident, authorityInfo.target.account, authorityInfo.target.provider, - authorityInfo.target.service, activeSyncContext.mStartTime); getCurrentSyncs(authorityInfo.target.userId).add(syncInfo); } @@ -1262,8 +1258,7 @@ public class SyncStorageEngine extends Handler { if (Log.isLoggable(TAG, Log.VERBOSE)) { Log.v(TAG, "removeActiveSync: account=" + syncInfo.account + " user=" + userId - + " auth=" + syncInfo.authority - + " service=" + syncInfo.service); + + " auth=" + syncInfo.authority); } getCurrentSyncs(userId).remove(syncInfo); } @@ -2109,12 +2104,8 @@ public class SyncStorageEngine extends Handler { extras, period, flextime); } else { - periodicSync = - new PeriodicSync( - authorityInfo.target.service, - extras, - period, - flextime); + Log.e(TAG, "Unknown target."); + return null; } authorityInfo.periodicSyncs.add(periodicSync); return periodicSync; @@ -2700,7 +2691,10 @@ public class SyncStorageEngine extends Handler { if (authorityInfo.target.target_provider) { req.setSyncAdapter(authorityInfo.target.account, authorityInfo.target.provider); } else { - req.setSyncAdapter(authorityInfo.target.service); + if (Log.isLoggable(TAG, Log.DEBUG)) { + Log.d(TAG, "Unknown target, skipping sync request."); + } + return; } ContentResolver.requestSync(req.build()); } diff --git a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/bars/ActionBarLayout.java b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/bars/ActionBarLayout.java index e59ccd735f4d..d95c815771de 100644 --- a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/bars/ActionBarLayout.java +++ b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/bars/ActionBarLayout.java @@ -23,10 +23,8 @@ import com.android.ide.common.rendering.api.ActionBarCallback.HomeButtonStyle; import com.android.ide.common.rendering.api.RenderResources; import com.android.ide.common.rendering.api.ResourceValue; import com.android.ide.common.rendering.api.SessionParams; -import com.android.ide.common.rendering.api.SystemViewCookie; import com.android.internal.R; import com.android.internal.app.WindowDecorActionBar; -import com.android.internal.util.Predicate; import com.android.internal.view.menu.MenuBuilder; import com.android.internal.view.menu.MenuItemImpl; import com.android.internal.widget.ActionBarAccessor; @@ -50,7 +48,6 @@ import android.view.LayoutInflater; import android.view.MenuInflater; import android.view.View; import android.view.ViewGroup; -import android.widget.ActionMenuView; import android.widget.FrameLayout; import android.widget.LinearLayout; import android.widget.ListAdapter; @@ -59,8 +56,6 @@ import android.widget.RelativeLayout; import java.util.ArrayList; -import static com.android.ide.common.rendering.api.SystemViewCookie.ACTION_BAR_OVERFLOW; - /** * A layout representing the action bar. */ @@ -174,29 +169,6 @@ public class ActionBarLayout extends LinearLayout { mActionBarView.setSplitToolbar(mSplit); inflateMenus(); - - // Find if the Overflow Menu Button (the three dots) exists. If yes, - // add the view cookie. - Predicate<View> overflowMenuButtonTest = new Predicate<View>() { - @Override - public boolean apply(View view) { - ViewGroup.LayoutParams lp = view.getLayoutParams(); - return lp instanceof ActionMenuView.LayoutParams && - ((ActionMenuView.LayoutParams) lp).isOverflowButton; - } - }; - View overflowMenu = null; - if (mSplit) { - if (splitView != null) { - overflowMenu = splitView.findViewByPredicate(overflowMenuButtonTest); - } - } - else { - overflowMenu = mActionBarView.findViewByPredicate(overflowMenuButtonTest); - } - if (overflowMenu != null) { - mBridgeContext.addViewKey(overflowMenu, new SystemViewCookie(ACTION_BAR_OVERFLOW)); - } } } diff --git a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/RenderSessionImpl.java b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/RenderSessionImpl.java index 4af73cf52814..13b822c74a9d 100644 --- a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/RenderSessionImpl.java +++ b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/RenderSessionImpl.java @@ -37,6 +37,7 @@ import com.android.ide.common.rendering.api.Result.Status; import com.android.ide.common.rendering.api.SessionParams; import com.android.ide.common.rendering.api.SessionParams.RenderingMode; import com.android.ide.common.rendering.api.ViewInfo; +import com.android.ide.common.rendering.api.ViewType; import com.android.internal.util.XmlUtils; import com.android.internal.view.menu.ActionMenuItemView; import com.android.internal.view.menu.BridgeMenuItemImpl; @@ -83,9 +84,11 @@ import android.view.View.MeasureSpec; import android.view.ViewGroup; import android.view.ViewGroup.LayoutParams; import android.view.ViewGroup.MarginLayoutParams; +import android.view.ViewParent; import android.view.WindowManagerGlobal_Delegate; import android.widget.AbsListView; import android.widget.AbsSpinner; +import android.widget.ActionMenuView; import android.widget.AdapterView; import android.widget.ExpandableListView; import android.widget.FrameLayout; @@ -1473,16 +1476,49 @@ public class RenderSessionImpl extends RenderAction<SessionParams> { ViewInfo result; if (isContentFrame) { + // The view is part of the layout added by the user. Hence, + // the ViewCookie may be obtained only through the Context. result = new ViewInfo(view.getClass().getName(), - getViewKey(view), + getContext().getViewKey(view), view.getLeft(), view.getTop() + offset, view.getRight(), view.getBottom() + offset, view, view.getLayoutParams()); - } else { - result = new SystemViewInfo(view.getClass().getName(), + // We are part of the system decor. + SystemViewInfo r = new SystemViewInfo(view.getClass().getName(), getViewKey(view), view.getLeft(), view.getTop(), view.getRight(), view.getBottom(), view, view.getLayoutParams()); + result = r; + // We currently mark three kinds of views: + // 1. Menus in the Action Bar + // 2. Menus in the Overflow popup. + // 3. The overflow popup button. + if (view instanceof ListMenuItemView) { + // Mark 2. + // All menus in the popup are of type ListMenuItemView. + r.setViewType(ViewType.ACTION_BAR_OVERFLOW_MENU); + } else { + // Mark 3. + ViewGroup.LayoutParams lp = view.getLayoutParams(); + if (lp instanceof ActionMenuView.LayoutParams && + ((ActionMenuView.LayoutParams) lp).isOverflowButton) { + r.setViewType(ViewType.ACTION_BAR_OVERFLOW); + } else { + // Mark 1. + // A view is a menu in the Action Bar is it is not the overflow button and of + // its parent is of type ActionMenuView. We can also check if the view is + // instanceof ActionMenuItemView but that will fail for menus using + // actionProviderClass. + ViewParent parent = view.getParent(); + while (parent != mViewRoot && parent instanceof ViewGroup) { + if (parent instanceof ActionMenuView) { + r.setViewType(ViewType.ACTION_BAR_MENU); + break; + } + parent = parent.getParent(); + } + } + } } if (setExtendedInfo) { @@ -1501,7 +1537,7 @@ public class RenderSessionImpl extends RenderAction<SessionParams> { return result; } - /** + /* (non-Javadoc) * The cookie for menu items are stored in menu item and not in the map from View stored in * BridgeContext. */ diff --git a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/SystemViewInfo.java b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/SystemViewInfo.java index 5c267df56a3a..9fea1677d5f2 100644 --- a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/SystemViewInfo.java +++ b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/SystemViewInfo.java @@ -17,9 +17,15 @@ package com.android.layoutlib.bridge.impl; import com.android.ide.common.rendering.api.ViewInfo; +import com.android.ide.common.rendering.api.ViewType; +/** + * ViewInfo for views added by the platform. + */ public class SystemViewInfo extends ViewInfo { + private ViewType mViewType; + public SystemViewInfo(String name, Object cookie, int left, int top, int right, int bottom) { super(name, cookie, left, top, right, bottom); @@ -32,7 +38,14 @@ public class SystemViewInfo extends ViewInfo { } @Override - public boolean isSystemView() { - return true; + public ViewType getViewType() { + if (mViewType != null) { + return mViewType; + } + return ViewType.SYSTEM_UNKNOWN; + } + + public void setViewType(ViewType type) { + mViewType = type; } } |