diff --git a/api/current.xml b/api/current.xml index bbd653a8ac786..e764fa5aa6076 100644 --- a/api/current.xml +++ b/api/current.xml @@ -122,11 +122,11 @@ visibility="public" > - - - - + - - - - - - - - - - - @@ -14223,7 +14196,7 @@ deprecated="not deprecated" visibility="public" > - + @@ -14278,6 +14251,8 @@ > + + @@ -14285,25 +14260,6 @@ - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - + - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - confirmPassword(final Account account, final String password, - AccountManagerCallback callback, Handler handler) { - return new Future2Task(handler, callback) { - public void doWork() throws RemoteException { - mService.confirmPassword(mResponse, account, password); - } - public Boolean bundleToResult(Bundle bundle) throws AuthenticatorException { - if (!bundle.containsKey(Constants.BOOLEAN_RESULT_KEY)) { - throw new AuthenticatorException("no result in response"); - } - return bundle.getBoolean(Constants.BOOLEAN_RESULT_KEY); - } - }.start(); - } - public AccountManagerFuture getAccountsByTypeAndFeatures( final String type, final String[] features, AccountManagerCallback callback, Handler handler) { @@ -288,10 +306,10 @@ public class AccountManager { mService.getAccountsByFeatures(mResponse, type, features); } public Account[] bundleToResult(Bundle bundle) throws AuthenticatorException { - if (!bundle.containsKey(Constants.ACCOUNTS_KEY)) { + if (!bundle.containsKey(KEY_ACCOUNTS)) { throw new AuthenticatorException("no result in response"); } - final Parcelable[] parcelables = bundle.getParcelableArray(Constants.ACCOUNTS_KEY); + final Parcelable[] parcelables = bundle.getParcelableArray(KEY_ACCOUNTS); Account[] descs = new Account[parcelables.length]; for (int i = 0; i < parcelables.length; i++) { descs[i] = (Account) parcelables[i]; @@ -301,12 +319,14 @@ public class AccountManager { }.start(); } - public AccountManagerFuture confirmCredentials(final Account account, final Activity activity, + public AccountManagerFuture confirmCredentials(final Account account, + final Bundle options, + final Activity activity, final AccountManagerCallback callback, final Handler handler) { return new AmsTask(activity, handler, callback) { public void doWork() throws RemoteException { - mService.confirmCredentials(mResponse, account, activity != null); + mService.confirmCredentials(mResponse, account, options, activity != null); } }.start(); } @@ -357,7 +377,7 @@ public class AccountManager { }); } - private void postToHandler(Handler handler, final OnAccountsUpdatedListener listener, + private void postToHandler(Handler handler, final OnAccountsUpdateListener listener, final Account[] accounts) { final Account[] accountsCopy = new Account[accounts.length]; // send a copy to make sure that one doesn't @@ -480,7 +500,7 @@ public class AccountManager { } public void onError(int code, String message) { - if (code == Constants.ERROR_CODE_CANCELED) { + if (code == ERROR_CODE_CANCELED) { // the authenticator indicated that this request was canceled, do so now cancel(true /* mayInterruptIfRunning */); return; @@ -536,11 +556,11 @@ public class AccountManager { } catch (AuthenticatorException e) { // we will set the exception below } - onError(Constants.ERROR_CODE_INVALID_RESPONSE, "no result in response"); + onError(ERROR_CODE_INVALID_RESPONSE, "no result in response"); } public void onError(int code, String message) { - if (code == Constants.ERROR_CODE_CANCELED) { + if (code == ERROR_CODE_CANCELED) { cancel(true /* mayInterruptIfRunning */); return; } @@ -621,19 +641,19 @@ public class AccountManager { } private Exception convertErrorToException(int code, String message) { - if (code == Constants.ERROR_CODE_NETWORK_ERROR) { + if (code == ERROR_CODE_NETWORK_ERROR) { return new IOException(message); } - if (code == Constants.ERROR_CODE_UNSUPPORTED_OPERATION) { + if (code == ERROR_CODE_UNSUPPORTED_OPERATION) { return new UnsupportedOperationException(message); } - if (code == Constants.ERROR_CODE_INVALID_RESPONSE) { + if (code == ERROR_CODE_INVALID_RESPONSE) { return new AuthenticatorException(message); } - if (code == Constants.ERROR_CODE_BAD_ARGUMENTS) { + if (code == ERROR_CODE_BAD_ARGUMENTS) { return new IllegalArgumentException(message); } @@ -690,9 +710,9 @@ public class AccountManager { } else { // send result since we can't prompt to add an account Bundle result = new Bundle(); - result.putString(Constants.ACCOUNT_NAME_KEY, null); - result.putString(Constants.ACCOUNT_TYPE_KEY, null); - result.putString(Constants.AUTHTOKEN_KEY, null); + result.putString(KEY_ACCOUNT_NAME, null); + result.putString(KEY_ACCOUNT_TYPE, null); + result.putString(KEY_AUTHTOKEN, null); try { mResponse.onResult(result); } catch (RemoteException e) { @@ -716,8 +736,8 @@ public class AccountManager { new IAccountManagerResponse.Stub() { public void onResult(Bundle value) throws RemoteException { Account account = new Account( - value.getString(Constants.ACCOUNT_NAME_KEY), - value.getString(Constants.ACCOUNT_TYPE_KEY)); + value.getString(KEY_ACCOUNT_NAME), + value.getString(KEY_ACCOUNT_TYPE)); mFuture = getAuthToken(account, mAuthTokenType, mLoginOptions, mActivity, mMyCallback, mHandler); } @@ -731,15 +751,15 @@ public class AccountManager { Intent intent = new Intent(); intent.setClassName("android", "android.accounts.ChooseAccountActivity"); - intent.putExtra(Constants.ACCOUNTS_KEY, accounts); - intent.putExtra(Constants.ACCOUNT_MANAGER_RESPONSE_KEY, + intent.putExtra(KEY_ACCOUNTS, accounts); + intent.putExtra(KEY_ACCOUNT_MANAGER_RESPONSE, new AccountManagerResponse(chooseResponse)); mActivity.startActivity(intent); // the result will arrive via the IAccountManagerResponse } else { // send result since we can't prompt to select an account Bundle result = new Bundle(); - result.putString(Constants.ACCOUNTS_KEY, null); + result.putString(KEY_ACCOUNTS, null); try { mResponse.onResult(result); } catch (RemoteException e) { @@ -751,38 +771,34 @@ public class AccountManager { }}, mHandler); } - - - // TODO(fredq) pass through the calls to our implemention of Future2 to the underlying - // future that we create. We need to do things like have cancel cancel the mFuture, if set - // or to cause this to be canceled if mFuture isn't set. - // Once this is done then getAuthTokenByFeatures can be changed to return a Future2. - public void run(AccountManagerFuture future) { try { - set(future.get()); - } catch (InterruptedException e) { - cancel(true); - } catch (CancellationException e) { - cancel(true); - } catch (ExecutionException e) { - setException(e.getCause()); + set(future.getResult()); + } catch (OperationCanceledException e) { + cancel(true /* mayInterruptIfRUnning */); + } catch (IOException e) { + setException(e); + } catch (AuthenticatorException e) { + setException(e); } } } - public void getAuthTokenByFeatures( + public AccountManagerFuture getAuthTokenByFeatures( final String accountType, final String authTokenType, final String[] features, final Activity activityForPrompting, final Bundle addAccountOptions, final Bundle loginOptions, final AccountManagerCallback callback, final Handler handler) { if (accountType == null) throw new IllegalArgumentException("account type is null"); if (authTokenType == null) throw new IllegalArgumentException("authTokenType is null"); - new GetAuthTokenByTypeAndFeaturesTask(accountType, authTokenType, features, - activityForPrompting, addAccountOptions, loginOptions, callback, handler).start(); + final GetAuthTokenByTypeAndFeaturesTask task = + new GetAuthTokenByTypeAndFeaturesTask(accountType, authTokenType, features, + activityForPrompting, addAccountOptions, loginOptions, callback, handler); + task.start(); + return task; } - private final HashMap mAccountsUpdatedListeners = + private final HashMap mAccountsUpdatedListeners = Maps.newHashMap(); /** @@ -795,7 +811,7 @@ public class AccountManager { final Account[] accounts = getAccounts(); // send the result to the listeners synchronized (mAccountsUpdatedListeners) { - for (Map.Entry entry : + for (Map.Entry entry : mAccountsUpdatedListeners.entrySet()) { postToHandler(entry.getValue(), entry.getKey(), accounts); } @@ -804,7 +820,7 @@ public class AccountManager { }; /** - * Add a {@link OnAccountsUpdatedListener} to this instance of the {@link AccountManager}. + * Add a {@link OnAccountsUpdateListener} to this instance of the {@link AccountManager}. * The listener is guaranteed to be invoked on the thread of the Handler that is passed * in or the main thread's Handler if handler is null. *

@@ -819,7 +835,7 @@ public class AccountManager { * @throws IllegalArgumentException if listener is null * @throws IllegalStateException if listener was already added */ - public void addOnAccountsUpdatedListener(final OnAccountsUpdatedListener listener, + public void addOnAccountsUpdatedListener(final OnAccountsUpdateListener listener, Handler handler, boolean updateImmediately) { if (listener == null) { throw new IllegalArgumentException("the listener is null"); @@ -835,7 +851,7 @@ public class AccountManager { if (wasEmpty) { // Register a broadcast receiver to monitor account changes IntentFilter intentFilter = new IntentFilter(); - intentFilter.addAction(Constants.LOGIN_ACCOUNTS_CHANGED_ACTION); + intentFilter.addAction(LOGIN_ACCOUNTS_CHANGED_ACTION); // To recover from disk-full. intentFilter.addAction(Intent.ACTION_DEVICE_STORAGE_OK); mContext.registerReceiver(mAccountsChangedBroadcastReceiver, intentFilter); @@ -848,13 +864,13 @@ public class AccountManager { } /** - * Remove an {@link OnAccountsUpdatedListener} that was previously registered with + * Remove an {@link OnAccountsUpdateListener} that was previously registered with * {@link #addOnAccountsUpdatedListener}. * @param listener the listener to remove * @throws IllegalArgumentException if listener is null * @throws IllegalStateException if listener was not already added */ - public void removeOnAccountsUpdatedListener(OnAccountsUpdatedListener listener) { + public void removeOnAccountsUpdatedListener(OnAccountsUpdateListener listener) { if (listener == null) { throw new IllegalArgumentException("the listener is null"); } diff --git a/core/java/android/accounts/AccountManagerFuture.java b/core/java/android/accounts/AccountManagerFuture.java index 74d83eb348a24..0a26bfa02e0c1 100644 --- a/core/java/android/accounts/AccountManagerFuture.java +++ b/core/java/android/accounts/AccountManagerFuture.java @@ -22,12 +22,63 @@ import java.util.concurrent.TimeoutException; import java.io.IOException; /** - * An extension of {@link java.util.concurrent.Future} that provides wrappers for {@link #get()} - * that handle the various - * exceptions that {@link #get()} may return and rethrows them as exceptions specific to - * {@link android.accounts.AccountManager}. + * A AccountManagerFuture represents the result of an asynchronous + * {@link AccountManager} call. Methods are provided to check if the computation is + * complete, to wait for its completion, and to retrieve the result of + * the computation. The result can only be retrieved using method + * get when the computation has completed, blocking if + * necessary until it is ready. Cancellation is performed by the + * cancel method. Additional methods are provided to + * determine if the task completed normally or was cancelled. Once a + * computation has completed, the computation cannot be cancelled. + * If you would like to use a Future for the sake + * of cancellability but not provide a usable result, you can + * declare types of the form Future<?> and + * return null as a result of the underlying task. */ -public interface AccountManagerFuture extends Future { +public interface AccountManagerFuture { + /** + * Attempts to cancel execution of this task. This attempt will + * fail if the task has already completed, has already been cancelled, + * or could not be cancelled for some other reason. If successful, + * and this task has not started when cancel is called, + * this task should never run. If the task has already started, + * then the mayInterruptIfRunning parameter determines + * whether the thread executing this task should be interrupted in + * an attempt to stop the task. + * + *

After this method returns, subsequent calls to {@link #isDone} will + * always return true. Subsequent calls to {@link #isCancelled} + * will always return true if this method returned true. + * + * @param mayInterruptIfRunning true if the thread executing this + * task should be interrupted; otherwise, in-progress tasks are allowed + * to complete + * @return false if the task could not be cancelled, + * typically because it has already completed normally; + * true otherwise + */ + boolean cancel(boolean mayInterruptIfRunning); + + /** + * Returns true if this task was cancelled before it completed + * normally. + * + * @return true if this task was cancelled before it completed + */ + boolean isCancelled(); + + /** + * Returns true if this task completed. + * + * Completion may be due to normal termination, an exception, or + * cancellation -- in all of these cases, this method will return + * true. + * + * @return true if this task completed + */ + boolean isDone(); + /** * Wrapper for {@link java.util.concurrent.Future#get()}. If the get() throws * {@link InterruptedException} then the @@ -55,13 +106,4 @@ public interface AccountManagerFuture extends Future { */ V getResult(long timeout, TimeUnit unit) throws OperationCanceledException, IOException, AuthenticatorException; - - /** @deprecated Use {@link #getResult} */ - @Deprecated - V get() throws InterruptedException, ExecutionException; - - /** @deprecated Use {@link #getResult} */ - @Deprecated - V get(long timeout, TimeUnit unit) - throws InterruptedException, ExecutionException, TimeoutException; } \ No newline at end of file diff --git a/core/java/android/accounts/AccountManagerService.java b/core/java/android/accounts/AccountManagerService.java index 6dea0231cdb1f..3a11cb337b376 100644 --- a/core/java/android/accounts/AccountManagerService.java +++ b/core/java/android/accounts/AccountManagerService.java @@ -156,7 +156,7 @@ public class AccountManagerService && SystemProperties.getBoolean("ro.debuggable", false); static { - ACCOUNTS_CHANGED_INTENT = new Intent(Constants.LOGIN_ACCOUNTS_CHANGED_ACTION); + ACCOUNTS_CHANGED_INTENT = new Intent(AccountManager.LOGIN_ACCOUNTS_CHANGED_ACTION); ACCOUNTS_CHANGED_INTENT.setFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT); } @@ -440,16 +440,16 @@ public class AccountManagerService } public void onResult(Bundle result) { - if (result != null && result.containsKey(Constants.BOOLEAN_RESULT_KEY) - && !result.containsKey(Constants.INTENT_KEY)) { - final boolean removalAllowed = result.getBoolean(Constants.BOOLEAN_RESULT_KEY); + if (result != null && result.containsKey(AccountManager.KEY_BOOLEAN_RESULT) + && !result.containsKey(AccountManager.KEY_INTENT)) { + final boolean removalAllowed = result.getBoolean(AccountManager.KEY_BOOLEAN_RESULT); if (removalAllowed) { removeAccount(mAccount); } IAccountManagerResponse response = getResponseAndClose(); if (response != null) { Bundle result2 = new Bundle(); - result2.putBoolean(Constants.BOOLEAN_RESULT_KEY, removalAllowed); + result2.putBoolean(AccountManager.KEY_BOOLEAN_RESULT, removalAllowed); try { response.onResult(result2); } catch (RemoteException e) { @@ -691,9 +691,9 @@ public class AccountManagerService String authToken = readAuthTokenFromDatabase(account, authTokenType); if (authToken != null) { Bundle result = new Bundle(); - result.putString(Constants.AUTHTOKEN_KEY, authToken); - result.putString(Constants.ACCOUNT_NAME_KEY, account.name); - result.putString(Constants.ACCOUNT_TYPE_KEY, account.type); + result.putString(AccountManager.KEY_AUTHTOKEN, authToken); + result.putString(AccountManager.KEY_ACCOUNT_NAME, account.name); + result.putString(AccountManager.KEY_ACCOUNT_TYPE, account.type); onResult(response, result); return; } @@ -721,22 +721,22 @@ public class AccountManagerService public void onResult(Bundle result) { if (result != null) { - if (result.containsKey(Constants.AUTH_TOKEN_LABEL_KEY)) { + if (result.containsKey(AccountManager.KEY_AUTH_TOKEN_LABEL)) { Intent intent = newGrantCredentialsPermissionIntent(account, callerUid, new AccountAuthenticatorResponse(this), authTokenType, - result.getString(Constants.AUTH_TOKEN_LABEL_KEY)); + result.getString(AccountManager.KEY_AUTH_TOKEN_LABEL)); Bundle bundle = new Bundle(); - bundle.putParcelable(Constants.INTENT_KEY, intent); + bundle.putParcelable(AccountManager.KEY_INTENT, intent); onResult(bundle); return; } - String authToken = result.getString(Constants.AUTHTOKEN_KEY); + String authToken = result.getString(AccountManager.KEY_AUTHTOKEN); if (authToken != null) { - String name = result.getString(Constants.ACCOUNT_NAME_KEY); - String type = result.getString(Constants.ACCOUNT_TYPE_KEY); + String name = result.getString(AccountManager.KEY_ACCOUNT_NAME); + String type = result.getString(AccountManager.KEY_ACCOUNT_TYPE); if (TextUtils.isEmpty(type) || TextUtils.isEmpty(name)) { - onError(Constants.ERROR_CODE_INVALID_RESPONSE, + onError(AccountManager.ERROR_CODE_INVALID_RESPONSE, "the type and name should not be empty"); return; } @@ -744,10 +744,10 @@ public class AccountManagerService authTokenType, authToken); } - Intent intent = result.getParcelable(Constants.INTENT_KEY); + Intent intent = result.getParcelable(AccountManager.KEY_INTENT); if (intent != null && notifyOnAuthFailure) { doNotification( - account, result.getString(Constants.AUTH_FAILED_MESSAGE_KEY), + account, result.getString(AccountManager.KEY_AUTH_FAILED_MESSAGE), intent); } } @@ -871,13 +871,13 @@ public class AccountManagerService } public void confirmCredentials(IAccountManagerResponse response, - final Account account, final boolean expectActivityLaunch) { + final Account account, final Bundle options, final boolean expectActivityLaunch) { checkManageAccountsPermission(); long identityToken = clearCallingIdentity(); try { new Session(response, account.type, expectActivityLaunch) { public void run() throws RemoteException { - mAuthenticator.confirmCredentials(this, account); + mAuthenticator.confirmCredentials(this, account, options); } protected String toDebugString(long now) { return super.toDebugString(now) + ", confirmCredentials" @@ -889,25 +889,6 @@ public class AccountManagerService } } - public void confirmPassword(IAccountManagerResponse response, final Account account, - final String password) { - checkManageAccountsPermission(); - long identityToken = clearCallingIdentity(); - try { - new Session(response, account.type, false /* expectActivityLaunch */) { - public void run() throws RemoteException { - mAuthenticator.confirmPassword(this, account, password); - } - protected String toDebugString(long now) { - return super.toDebugString(now) + ", confirmPassword" - + ", " + account; - } - }.bind(); - } finally { - restoreCallingIdentity(identityToken); - } - } - public void updateCredentials(IAccountManagerResponse response, final Account account, final String authTokenType, final boolean expectActivityLaunch, final Bundle loginOptions) { @@ -980,17 +961,17 @@ public class AccountManagerService try { mAuthenticator.hasFeatures(this, mAccountsOfType[mCurrentAccount], mFeatures); } catch (RemoteException e) { - onError(Constants.ERROR_CODE_REMOTE_EXCEPTION, "remote exception"); + onError(AccountManager.ERROR_CODE_REMOTE_EXCEPTION, "remote exception"); } } public void onResult(Bundle result) { mNumResults++; if (result == null) { - onError(Constants.ERROR_CODE_INVALID_RESPONSE, "null bundle"); + onError(AccountManager.ERROR_CODE_INVALID_RESPONSE, "null bundle"); return; } - if (result.getBoolean(Constants.BOOLEAN_RESULT_KEY, false)) { + if (result.getBoolean(AccountManager.KEY_BOOLEAN_RESULT, false)) { mAccountsWithFeatures.add(mAccountsOfType[mCurrentAccount]); } mCurrentAccount++; @@ -1006,7 +987,7 @@ public class AccountManagerService accounts[i] = mAccountsWithFeatures.get(i); } Bundle result = new Bundle(); - result.putParcelableArray(Constants.ACCOUNTS_KEY, accounts); + result.putParcelableArray(AccountManager.KEY_ACCOUNTS, accounts); response.onResult(result); } catch (RemoteException e) { // if the caller is dead then there is no one to care about remote exceptions @@ -1040,7 +1021,7 @@ public class AccountManagerService if (features != null && type == null) { if (response != null) { try { - response.onError(Constants.ERROR_CODE_BAD_ARGUMENTS, "type is null"); + response.onError(AccountManager.ERROR_CODE_BAD_ARGUMENTS, "type is null"); } catch (RemoteException e) { // ignore this } @@ -1171,7 +1152,7 @@ public class AccountManagerService } if (!mBindHelper.bind(mAccountType, this)) { Log.d(TAG, "bind attempt failed for " + toDebugString()); - onError(Constants.ERROR_CODE_REMOTE_EXCEPTION, "bind failure"); + onError(AccountManager.ERROR_CODE_REMOTE_EXCEPTION, "bind failure"); } } @@ -1196,7 +1177,7 @@ public class AccountManagerService try { run(); } catch (RemoteException e) { - onError(Constants.ERROR_CODE_REMOTE_EXCEPTION, + onError(AccountManager.ERROR_CODE_REMOTE_EXCEPTION, "remote exception"); } } @@ -1207,7 +1188,7 @@ public class AccountManagerService mAuthenticator = null; IAccountManagerResponse response = getResponseAndClose(); if (response != null) { - onError(Constants.ERROR_CODE_REMOTE_EXCEPTION, + onError(AccountManager.ERROR_CODE_REMOTE_EXCEPTION, "disconnected"); } } @@ -1215,16 +1196,16 @@ public class AccountManagerService public void onTimedOut() { IAccountManagerResponse response = getResponseAndClose(); if (response != null) { - onError(Constants.ERROR_CODE_REMOTE_EXCEPTION, + onError(AccountManager.ERROR_CODE_REMOTE_EXCEPTION, "timeout"); } } public void onResult(Bundle result) { mNumResults++; - if (result != null && !TextUtils.isEmpty(result.getString(Constants.AUTHTOKEN_KEY))) { - String accountName = result.getString(Constants.ACCOUNT_NAME_KEY); - String accountType = result.getString(Constants.ACCOUNT_TYPE_KEY); + if (result != null && !TextUtils.isEmpty(result.getString(AccountManager.KEY_AUTHTOKEN))) { + String accountName = result.getString(AccountManager.KEY_ACCOUNT_NAME); + String accountType = result.getString(AccountManager.KEY_ACCOUNT_TYPE); if (!TextUtils.isEmpty(accountName) && !TextUtils.isEmpty(accountType)) { Account account = new Account(accountName, accountType); cancelNotification(getSigninRequiredNotificationId(account)); @@ -1232,7 +1213,7 @@ public class AccountManagerService } IAccountManagerResponse response; if (mExpectActivityLaunch && result != null - && result.containsKey(Constants.INTENT_KEY)) { + && result.containsKey(AccountManager.KEY_INTENT)) { response = mResponse; } else { response = getResponseAndClose(); @@ -1240,7 +1221,7 @@ public class AccountManagerService if (response != null) { try { if (result == null) { - response.onError(Constants.ERROR_CODE_INVALID_RESPONSE, + response.onError(AccountManager.ERROR_CODE_INVALID_RESPONSE, "null bundle returned"); } else { response.onResult(result); diff --git a/core/java/android/accounts/AccountsException.java b/core/java/android/accounts/AccountsException.java new file mode 100644 index 0000000000000..b997390d65274 --- /dev/null +++ b/core/java/android/accounts/AccountsException.java @@ -0,0 +1,32 @@ +/* + * Copyright (C) 2009 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.accounts; + +public class AccountsException extends Exception { + public AccountsException() { + super(); + } + public AccountsException(String message) { + super(message); + } + public AccountsException(String message, Throwable cause) { + super(message, cause); + } + public AccountsException(Throwable cause) { + super(cause); + } +} \ No newline at end of file diff --git a/core/java/android/accounts/AuthenticatorException.java b/core/java/android/accounts/AuthenticatorException.java index 40234945cfbe3..f778d7d7cada7 100644 --- a/core/java/android/accounts/AuthenticatorException.java +++ b/core/java/android/accounts/AuthenticatorException.java @@ -16,7 +16,7 @@ package android.accounts; -public class AuthenticatorException extends Exception { +public class AuthenticatorException extends AccountsException { public AuthenticatorException() { super(); } diff --git a/core/java/android/accounts/ChooseAccountActivity.java b/core/java/android/accounts/ChooseAccountActivity.java index bd6f2054e668d..4a0018e1f7226 100644 --- a/core/java/android/accounts/ChooseAccountActivity.java +++ b/core/java/android/accounts/ChooseAccountActivity.java @@ -23,6 +23,9 @@ import android.widget.ListView; import android.view.View; import android.util.Log; +/** + * @hide + */ public class ChooseAccountActivity extends ListActivity { private static final String TAG = "AccountManager"; private Parcelable[] mAccounts = null; @@ -34,13 +37,13 @@ public class ChooseAccountActivity extends ListActivity { super.onCreate(savedInstanceState); if (savedInstanceState == null) { - mAccounts = getIntent().getParcelableArrayExtra(Constants.ACCOUNTS_KEY); + mAccounts = getIntent().getParcelableArrayExtra(AccountManager.KEY_ACCOUNTS); mAccountManagerResponse = - getIntent().getParcelableExtra(Constants.ACCOUNT_MANAGER_RESPONSE_KEY); + getIntent().getParcelableExtra(AccountManager.KEY_ACCOUNT_MANAGER_RESPONSE); } else { - mAccounts = savedInstanceState.getParcelableArray(Constants.ACCOUNTS_KEY); + mAccounts = savedInstanceState.getParcelableArray(AccountManager.KEY_ACCOUNTS); mAccountManagerResponse = - savedInstanceState.getParcelable(Constants.ACCOUNT_MANAGER_RESPONSE_KEY); + savedInstanceState.getParcelable(AccountManager.KEY_ACCOUNT_MANAGER_RESPONSE); } String[] mAccountNames = new String[mAccounts.length]; @@ -59,8 +62,8 @@ public class ChooseAccountActivity extends ListActivity { Account account = (Account) mAccounts[position]; Log.d(TAG, "selected account " + account); Bundle bundle = new Bundle(); - bundle.putString(Constants.ACCOUNT_NAME_KEY, account.name); - bundle.putString(Constants.ACCOUNT_TYPE_KEY, account.type); + bundle.putString(AccountManager.KEY_ACCOUNT_NAME, account.name); + bundle.putString(AccountManager.KEY_ACCOUNT_TYPE, account.type); mResult = bundle; finish(); } @@ -70,7 +73,7 @@ public class ChooseAccountActivity extends ListActivity { if (mResult != null) { mAccountManagerResponse.onResult(mResult); } else { - mAccountManagerResponse.onError(Constants.ERROR_CODE_CANCELED, "canceled"); + mAccountManagerResponse.onError(AccountManager.ERROR_CODE_CANCELED, "canceled"); } } super.finish(); diff --git a/core/java/android/accounts/Constants.java b/core/java/android/accounts/Constants.java deleted file mode 100644 index 15b1773ba188f..0000000000000 --- a/core/java/android/accounts/Constants.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Copyright (C) 2009 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.accounts; - -public class Constants { - // this should never be instantiated - private Constants() {} - - public static final int ERROR_CODE_REMOTE_EXCEPTION = 1; - public static final int ERROR_CODE_NETWORK_ERROR = 3; - public static final int ERROR_CODE_CANCELED = 4; - public static final int ERROR_CODE_INVALID_RESPONSE = 5; - public static final int ERROR_CODE_UNSUPPORTED_OPERATION = 6; - public static final int ERROR_CODE_BAD_ARGUMENTS = 7; - public static final int ERROR_CODE_BAD_REQUEST = 8; - - public static final String ACCOUNTS_KEY = "accounts"; - public static final String AUTHENTICATOR_TYPES_KEY = "authenticator_types"; - public static final String USERDATA_KEY = "userdata"; - public static final String AUTHTOKEN_KEY = "authtoken"; - public static final String PASSWORD_KEY = "password"; - public static final String ACCOUNT_NAME_KEY = "authAccount"; - public static final String ACCOUNT_TYPE_KEY = "accountType"; - public static final String ERROR_CODE_KEY = "errorCode"; - public static final String ERROR_MESSAGE_KEY = "errorMessage"; - public static final String INTENT_KEY = "intent"; - public static final String BOOLEAN_RESULT_KEY = "booleanResult"; - public static final String ACCOUNT_AUTHENTICATOR_RESPONSE_KEY = "accountAuthenticatorResponse"; - public static final String ACCOUNT_MANAGER_RESPONSE_KEY = "accountManagerResponse"; - public static final String AUTH_FAILED_MESSAGE_KEY = "authFailedMessage"; - public static final String AUTH_TOKEN_LABEL_KEY = "authTokenLabelKey"; - - public static final String AUTHENTICATOR_INTENT_ACTION = - "android.accounts.AccountAuthenticator"; - public static final String AUTHENTICATOR_META_DATA_NAME = - "android.accounts.AccountAuthenticator"; - public static final String AUTHENTICATOR_ATTRIBUTES_NAME = "account-authenticator"; - - /** - * Action sent as a broadcast Intent by the AccountsService - * when accounts are added to and/or removed from the device's - * database. - */ - public static final String LOGIN_ACCOUNTS_CHANGED_ACTION = - "android.accounts.LOGIN_ACCOUNTS_CHANGED"; -} diff --git a/core/java/android/accounts/GrantCredentialsPermissionActivity.java b/core/java/android/accounts/GrantCredentialsPermissionActivity.java index e06afb4d5948d..e3ed2e949a637 100644 --- a/core/java/android/accounts/GrantCredentialsPermissionActivity.java +++ b/core/java/android/accounts/GrantCredentialsPermissionActivity.java @@ -121,7 +121,7 @@ public class GrantCredentialsPermissionActivity extends Activity implements View if (mResultBundle != null) { accountAuthenticatorResponse.onResult(mResultBundle); } else { - accountAuthenticatorResponse.onError(Constants.ERROR_CODE_CANCELED, "canceled"); + accountAuthenticatorResponse.onError(AccountManager.ERROR_CODE_CANCELED, "canceled"); } } super.finish(); diff --git a/core/java/android/accounts/IAccountAuthenticator.aidl b/core/java/android/accounts/IAccountAuthenticator.aidl index 1592eea90e101..88607102883d4 100644 --- a/core/java/android/accounts/IAccountAuthenticator.aidl +++ b/core/java/android/accounts/IAccountAuthenticator.aidl @@ -22,6 +22,7 @@ import android.os.Bundle; /** * Service that allows the interaction with an authentication server. + * @hide */ oneway interface IAccountAuthenticator { /** @@ -30,17 +31,11 @@ oneway interface IAccountAuthenticator { void addAccount(in IAccountAuthenticatorResponse response, String accountType, String authTokenType, in String[] requiredFeatures, in Bundle options); - /** - * Checks that the account/password combination is valid. - * note -- deprecated - */ - void confirmPassword(in IAccountAuthenticatorResponse response, - in Account account, String password); - /** * prompts the user for the credentials of the account */ - void confirmCredentials(in IAccountAuthenticatorResponse response, in Account account); + void confirmCredentials(in IAccountAuthenticatorResponse response, in Account account, + in Bundle options); /** * gets the password by either prompting the user or querying the IAccountManager diff --git a/core/java/android/accounts/IAccountAuthenticatorResponse.aidl b/core/java/android/accounts/IAccountAuthenticatorResponse.aidl index a9ac2f1bb0802..0c75e507f1e83 100644 --- a/core/java/android/accounts/IAccountAuthenticatorResponse.aidl +++ b/core/java/android/accounts/IAccountAuthenticatorResponse.aidl @@ -19,6 +19,7 @@ import android.os.Bundle; /** * The interface used to return responses from an {@link IAccountAuthenticator} + * @hide */ oneway interface IAccountAuthenticatorResponse { void onResult(in Bundle value); diff --git a/core/java/android/accounts/IAccountManager.aidl b/core/java/android/accounts/IAccountManager.aidl index 411952b2664a4..0e318c051ff45 100644 --- a/core/java/android/accounts/IAccountManager.aidl +++ b/core/java/android/accounts/IAccountManager.aidl @@ -52,11 +52,5 @@ interface IAccountManager { void editProperties(in IAccountManagerResponse response, String accountType, boolean expectActivityLaunch); void confirmCredentials(in IAccountManagerResponse response, in Account account, - boolean expectActivityLaunch); - - /* - * @deprecated - */ - void confirmPassword(in IAccountManagerResponse response, in Account account, - String password); + in Bundle options, boolean expectActivityLaunch); } diff --git a/core/java/android/accounts/NetworkErrorException.java b/core/java/android/accounts/NetworkErrorException.java index f855cc802915b..07f4ce978747d 100644 --- a/core/java/android/accounts/NetworkErrorException.java +++ b/core/java/android/accounts/NetworkErrorException.java @@ -15,7 +15,7 @@ */ package android.accounts; -public class NetworkErrorException extends Exception { +public class NetworkErrorException extends AccountsException { public NetworkErrorException() { super(); } diff --git a/core/java/android/accounts/OnAccountsUpdatedListener.java b/core/java/android/accounts/OnAccountsUpdateListener.java similarity index 95% rename from core/java/android/accounts/OnAccountsUpdatedListener.java rename to core/java/android/accounts/OnAccountsUpdateListener.java index bd249d0a3f9e2..38b371d26e4fb 100644 --- a/core/java/android/accounts/OnAccountsUpdatedListener.java +++ b/core/java/android/accounts/OnAccountsUpdateListener.java @@ -19,7 +19,7 @@ package android.accounts; /** * An interface that contains the callback used by the AccountMonitor */ -public interface OnAccountsUpdatedListener { +public interface OnAccountsUpdateListener { /** * This invoked when the AccountMonitor starts up and whenever the account * set changes. diff --git a/core/java/android/accounts/OperationCanceledException.java b/core/java/android/accounts/OperationCanceledException.java index 2f2c1646caf36..896d194e221ce 100644 --- a/core/java/android/accounts/OperationCanceledException.java +++ b/core/java/android/accounts/OperationCanceledException.java @@ -15,7 +15,7 @@ */ package android.accounts; -public class OperationCanceledException extends Exception { +public class OperationCanceledException extends AccountsException { public OperationCanceledException() { super(); } diff --git a/core/java/android/app/SearchDialog.java b/core/java/android/app/SearchDialog.java index 605647aa41df5..933c2fc2fa794 100644 --- a/core/java/android/app/SearchDialog.java +++ b/core/java/android/app/SearchDialog.java @@ -364,10 +364,12 @@ public class SearchDialog extends Dialog implements OnItemClickListener, OnItemS mGlobalSearchMode = globalSearch || searchManager.isDefaultSearchable(mSearchable); mActivityContext = mSearchable.getActivityContext(getContext()); - createContentView(); - // show the dialog. this will call onStart(). - if (!isShowing()) { + if (!isShowing()) { + // Recreate the search bar view every time the dialog is shown, to get rid + // of any bad state in the AutoCompleteTextView etc + createContentView(); + // The Dialog uses a ContextThemeWrapper for the context; use this to change the // theme out from underneath us, between the global search theme and the in-app // search theme. They are identical except that the global search theme does not diff --git a/core/java/android/content/AbstractSyncableContentProvider.java b/core/java/android/content/AbstractSyncableContentProvider.java index fc3acc5ca1602..eba87150e4e7e 100644 --- a/core/java/android/content/AbstractSyncableContentProvider.java +++ b/core/java/android/content/AbstractSyncableContentProvider.java @@ -4,7 +4,7 @@ import android.database.sqlite.SQLiteOpenHelper; import android.database.sqlite.SQLiteDatabase; import android.database.Cursor; import android.net.Uri; -import android.accounts.OnAccountsUpdatedListener; +import android.accounts.OnAccountsUpdateListener; import android.accounts.Account; import android.accounts.AccountManager; import android.provider.SyncConstValue; @@ -160,7 +160,7 @@ public abstract class AbstractSyncableContentProvider extends SyncableContentPro mDatabaseName); mSyncState = new SyncStateContentProviderHelper(mOpenHelper); AccountManager.get(getContext()).addOnAccountsUpdatedListener( - new OnAccountsUpdatedListener() { + new OnAccountsUpdateListener() { public void onAccountsUpdated(Account[] accounts) { // Some providers override onAccountsChanged(); give them a database to // work with. diff --git a/core/java/android/content/SyncManager.java b/core/java/android/content/SyncManager.java index 5376f782af48b..3877f161f34cb 100644 --- a/core/java/android/content/SyncManager.java +++ b/core/java/android/content/SyncManager.java @@ -23,7 +23,7 @@ import com.android.internal.util.ArrayUtils; import android.accounts.Account; import android.accounts.AccountManager; -import android.accounts.OnAccountsUpdatedListener; +import android.accounts.OnAccountsUpdateListener; import android.app.AlarmManager; import android.app.Notification; import android.app.NotificationManager; @@ -78,7 +78,7 @@ import java.util.concurrent.CountDownLatch; /** * @hide */ -class SyncManager implements OnAccountsUpdatedListener { +class SyncManager implements OnAccountsUpdateListener { private static final String TAG = "SyncManager"; // used during dumping of the Sync history diff --git a/core/java/android/content/SyncStorageEngine.java b/core/java/android/content/SyncStorageEngine.java index fb2608a33334e..be7090999bc12 100644 --- a/core/java/android/content/SyncStorageEngine.java +++ b/core/java/android/content/SyncStorageEngine.java @@ -1028,7 +1028,7 @@ public class SyncStorageEngine extends Handler { ident++; } } - Log.d(TAG, "created a new AuthorityInfo for " + accountName + if (DEBUG) Log.v(TAG, "created a new AuthorityInfo for " + accountName + ", provider " + authorityName); authority = new AuthorityInfo(accountName, authorityName, ident); account.authorities.put(authorityName, authority); diff --git a/core/java/android/content/pm/PackageParser.java b/core/java/android/content/pm/PackageParser.java index 83e63b9c435ec..75ba26f7cad23 100644 --- a/core/java/android/content/pm/PackageParser.java +++ b/core/java/android/content/pm/PackageParser.java @@ -973,8 +973,9 @@ public class PackageParser { return null; } else { - Log.w(TAG, "Bad element under : " - + parser.getName()); + Log.w(TAG, "Unknown element under : " + parser.getName() + + " at " + mArchiveSourcePath + " " + + parser.getPositionDescription()); XmlUtils.skipCurrentTag(parser); continue; } @@ -1729,8 +1730,9 @@ public class PackageParser { return null; } if (intent.countActions() == 0) { - Log.w(TAG, "Intent filter for activity " + intent - + " defines no actions"); + Log.w(TAG, "No actions in intent filter at " + + mArchiveSourcePath + " " + + parser.getPositionDescription()); } else { a.intents.add(intent); } @@ -1877,8 +1879,9 @@ public class PackageParser { return null; } if (intent.countActions() == 0) { - Log.w(TAG, "Intent filter for activity alias " + intent - + " defines no actions"); + Log.w(TAG, "No actions in intent filter at " + + mArchiveSourcePath + " " + + parser.getPositionDescription()); } else { a.intents.add(intent); } diff --git a/core/java/android/net/MobileDataStateTracker.java b/core/java/android/net/MobileDataStateTracker.java index 709766b486849..b619feeab00c4 100644 --- a/core/java/android/net/MobileDataStateTracker.java +++ b/core/java/android/net/MobileDataStateTracker.java @@ -42,7 +42,7 @@ import android.text.TextUtils; public class MobileDataStateTracker extends NetworkStateTracker { private static final String TAG = "MobileDataStateTracker"; - private static final boolean DBG = true; + private static final boolean DBG = false; private Phone.DataState mMobileDataState; private ITelephony mPhoneService; diff --git a/core/java/com/android/internal/backup/LocalTransport.java b/core/java/com/android/internal/backup/LocalTransport.java index 4fc3edc76c8d8..12bc5a888fc20 100644 --- a/core/java/com/android/internal/backup/LocalTransport.java +++ b/core/java/com/android/internal/backup/LocalTransport.java @@ -41,7 +41,6 @@ public class LocalTransport extends IBackupTransport.Stub { public LocalTransport(Context context) { - if (DEBUG) Log.v(TAG, "Transport constructed"); mContext = context; mPackageManager = context.getPackageManager(); } diff --git a/core/res/AndroidManifest.xml b/core/res/AndroidManifest.xml index d0621e72813e7..7d6f158b27d91 100644 --- a/core/res/AndroidManifest.xml +++ b/core/res/AndroidManifest.xml @@ -331,7 +331,7 @@ - " + decodeURI(query) + ""); + $("#searchTitle").html("search results for " + query + ""); }); // forcefully regain key-up event control (previously jacked by search api) diff --git a/graphics/java/android/renderscript/SimpleMesh.java b/graphics/java/android/renderscript/SimpleMesh.java index 987ec44432127..b422702bbc43b 100644 --- a/graphics/java/android/renderscript/SimpleMesh.java +++ b/graphics/java/android/renderscript/SimpleMesh.java @@ -82,7 +82,7 @@ public class SimpleMesh extends BaseObj { } public int addVertexType(Type t) throws IllegalStateException { - if(mVertexTypeCount >= mVertexTypes.length) { + if (mVertexTypeCount >= mVertexTypes.length) { throw new IllegalStateException("Max vertex types exceeded."); } @@ -94,7 +94,7 @@ public class SimpleMesh extends BaseObj { } public int addVertexType(Element e, int size) throws IllegalStateException { - if(mVertexTypeCount >= mVertexTypes.length) { + if (mVertexTypeCount >= mVertexTypes.length) { throw new IllegalStateException("Max vertex types exceeded."); } @@ -134,9 +134,9 @@ public class SimpleMesh extends BaseObj { int toDestroyCount = 0; int indexID = 0; - if(b.mIndexType.t != null) { + if (b.mIndexType.t != null) { indexID = b.mIndexType.t.mID; - } else if(b.mIndexType.size != 0) { + } else if (b.mIndexType.size != 0) { b.mIndexType.t = b.newType(b.mIndexType.e, b.mIndexType.size); indexID = b.mIndexType.t.mID; toDestroy[toDestroyCount++] = b.mIndexType.t; @@ -144,7 +144,7 @@ public class SimpleMesh extends BaseObj { int[] IDs = new int[b.mVertexTypeCount]; for(int ct=0; ct < b.mVertexTypeCount; ct++) { - if(b.mVertexTypes[ct].t != null) { + if (b.mVertexTypes[ct].t != null) { IDs[ct] = b.mVertexTypes[ct].t.mID; } else { b.mVertexTypes[ct].t = b.newType(b.mVertexTypes[ct].e, b.mVertexTypes[ct].size); @@ -181,92 +181,116 @@ public class SimpleMesh extends BaseObj { RenderScript mRS; Element mElement; - int mVtxSize; - boolean mNorm; - boolean mTex; + float mNX = 0; + float mNY = 0; + float mNZ = -1; + float mS0 = 0; + float mT0 = 0; + float mR = 1; + float mG = 1; + float mB = 1; + float mA = 1; - public TriangleMeshBuilder(RenderScript rs, int vtxSize, boolean norm, boolean tex) { + int mVtxSize; + int mFlags; + + public static final int COLOR = 0x0001; + public static final int NORMAL = 0x0002; + public static final int TEXTURE_0 = 0x0100; + + public TriangleMeshBuilder(RenderScript rs, int vtxSize, int flags) { mRS = rs; mVtxCount = 0; mIndexCount = 0; mVtxData = new float[128]; mIndexData = new short[128]; mVtxSize = vtxSize; - mNorm = norm; - mTex = tex; + mFlags = flags; - if(vtxSize < 2 || vtxSize > 3) { + if (vtxSize < 2 || vtxSize > 3) { throw new IllegalArgumentException("Vertex size out of range."); } } private void makeSpace(int count) { - if((mVtxCount + count) >= mVtxData.length) { + if ((mVtxCount + count) >= mVtxData.length) { float t[] = new float[mVtxData.length * 2]; System.arraycopy(mVtxData, 0, t, 0, mVtxData.length); mVtxData = t; } } - public void add_XY(float x, float y) { - if((mVtxSize != 2) || mNorm || mTex) { - throw new IllegalStateException("add mistmatch with declaired components."); + private void latch() { + if ((mFlags & COLOR) != 0) { + makeSpace(4); + mVtxData[mVtxCount++] = mR; + mVtxData[mVtxCount++] = mG; + mVtxData[mVtxCount++] = mB; + mVtxData[mVtxCount++] = mA; + } + if ((mFlags & NORMAL) != 0) { + makeSpace(3); + mVtxData[mVtxCount++] = mNX; + mVtxData[mVtxCount++] = mNY; + mVtxData[mVtxCount++] = mNZ; + } + if ((mFlags & TEXTURE_0) != 0) { + makeSpace(2); + mVtxData[mVtxCount++] = mS0; + mVtxData[mVtxCount++] = mT0; + } + } + + public void addVertex(float x, float y) { + if (mVtxSize != 2) { + throw new IllegalStateException("add mistmatch with declared components."); } makeSpace(2); mVtxData[mVtxCount++] = x; mVtxData[mVtxCount++] = y; + latch(); } - public void add_XYZ(float x, float y, float z) { - if((mVtxSize != 3) || mNorm || mTex) { - throw new IllegalStateException("add mistmatch with declaired components."); + public void addVertex(float x, float y, float z) { + if (mVtxSize != 3) { + throw new IllegalStateException("add mistmatch with declared components."); } makeSpace(3); mVtxData[mVtxCount++] = x; mVtxData[mVtxCount++] = y; mVtxData[mVtxCount++] = z; + latch(); } - public void add_XY_ST(float x, float y, float s, float t) { - if((mVtxSize != 2) || mNorm || !mTex) { - throw new IllegalStateException("add mistmatch with declaired components."); + public void setTexture(float s, float t) { + if ((mFlags & TEXTURE_0) == 0) { + throw new IllegalStateException("add mistmatch with declared components."); } - makeSpace(4); - mVtxData[mVtxCount++] = x; - mVtxData[mVtxCount++] = y; - mVtxData[mVtxCount++] = s; - mVtxData[mVtxCount++] = t; + mS0 = s; + mT0 = t; } - public void add_XYZ_ST(float x, float y, float z, float s, float t) { - if((mVtxSize != 3) || mNorm || !mTex) { - throw new IllegalStateException("add mistmatch with declaired components."); + public void setNormal(float x, float y, float z) { + if ((mFlags & NORMAL) == 0) { + throw new IllegalStateException("add mistmatch with declared components."); } - makeSpace(5); - mVtxData[mVtxCount++] = x; - mVtxData[mVtxCount++] = y; - mVtxData[mVtxCount++] = z; - mVtxData[mVtxCount++] = s; - mVtxData[mVtxCount++] = t; + mNX = x; + mNY = y; + mNZ = z; } - public void add_XYZ_ST_NORM(float x, float y, float z, float s, float t, float nx, float ny, float nz) { - if((mVtxSize != 3) || !mNorm || !mTex) { - throw new IllegalStateException("add mistmatch with declaired components."); + public void setColor(float r, float g, float b, float a) { + if ((mFlags & COLOR) == 0) { + throw new IllegalStateException("add mistmatch with declared components."); } - makeSpace(8); - mVtxData[mVtxCount++] = x; - mVtxData[mVtxCount++] = y; - mVtxData[mVtxCount++] = z; - mVtxData[mVtxCount++] = s; - mVtxData[mVtxCount++] = t; - mVtxData[mVtxCount++] = nx; - mVtxData[mVtxCount++] = ny; - mVtxData[mVtxCount++] = nz; + mR = r; + mG = g; + mB = b; + mA = a; } public void addTriangle(int idx1, int idx2, int idx3) { - if((mIndexCount + 3) >= mIndexData.length) { + if ((mIndexCount + 3) >= mIndexData.length) { short t[] = new short[mIndexData.length * 2]; System.arraycopy(mIndexData, 0, t, 0, mIndexData.length); mIndexData = t; @@ -279,16 +303,20 @@ public class SimpleMesh extends BaseObj { public SimpleMesh create() { Element.Builder b = new Element.Builder(mRS); int floatCount = mVtxSize; - if(mVtxSize == 2) { + if (mVtxSize == 2) { b.addFloatXY(); } else { b.addFloatXYZ(); } - if(mTex) { + if ((mFlags & COLOR) != 0) { + floatCount += 4; + b.addFloatRGBA(); + } + if ((mFlags & TEXTURE_0) != 0) { floatCount += 2; b.addFloatST(); } - if(mNorm) { + if ((mFlags & NORMAL) != 0) { floatCount += 3; b.addFloatNorm(); } diff --git a/include/private/ui/SharedBufferStack.h b/include/private/ui/SharedBufferStack.h index c02b2e7659062..59cf31c89c717 100644 --- a/include/private/ui/SharedBufferStack.h +++ b/include/private/ui/SharedBufferStack.h @@ -142,6 +142,7 @@ public: SharedBufferBase(SharedClient* sharedClient, int surface, int num); ~SharedBufferBase(); uint32_t getIdentity(); + status_t getStatus() const; size_t getFrontBuffer() const; String8 dump(char const* prefix) const; @@ -177,7 +178,7 @@ status_t SharedBufferBase::waitForCondition(T condition) { const SharedBufferStack& stack( *mSharedStack ); SharedClient& client( *mSharedClient ); - const nsecs_t TIMEOUT = s2ns(1); + const nsecs_t TIMEOUT = s2ns(1); Mutex::Autolock _l(client.lock); while ((condition()==false) && (stack.status == NO_ERROR)) { status_t err = client.cv.waitRelative(client.lock, TIMEOUT); @@ -187,14 +188,15 @@ status_t SharedBufferBase::waitForCondition(T condition) if (err == TIMED_OUT) { if (condition()) { LOGE("waitForCondition(%s) timed out (identity=%d), " - "but condition is true! We recovered but it " - "shouldn't happen." , - T::name(), mSharedStack->identity); + "but condition is true! We recovered but it " + "shouldn't happen." , T::name(), + mSharedStack->identity); break; } else { - LOGW("waitForCondition(%s) timed out (identity=%d). " - "CPU may be pegged. trying again.", - T::name(), mSharedStack->identity); + LOGW("waitForCondition(%s) timed out " + "(identity=%d, status=%d). " + "CPU may be pegged. trying again.", T::name(), + mSharedStack->identity, mSharedStack->status); } } else { LOGE("waitForCondition(%s) error (%s) ", diff --git a/libs/rs/java/Film/src/com/android/film/FilmStripMesh.java b/libs/rs/java/Film/src/com/android/film/FilmStripMesh.java index 64aac26163a97..448cce02745d7 100644 --- a/libs/rs/java/Film/src/com/android/film/FilmStripMesh.java +++ b/libs/rs/java/Film/src/com/android/film/FilmStripMesh.java @@ -212,7 +212,9 @@ class FilmStripMesh { t.nxyz(1, 0, 0); int count = vtx.length / 2; - SimpleMesh.TriangleMeshBuilder tm = new SimpleMesh.TriangleMeshBuilder(rs, 3, true, true); + SimpleMesh.TriangleMeshBuilder tm = new SimpleMesh.TriangleMeshBuilder( + rs, 3, + SimpleMesh.TriangleMeshBuilder.NORMAL | SimpleMesh.TriangleMeshBuilder.TEXTURE_0); float runningS = 0; for (int ct=0; ct < (count-1); ct++) { @@ -227,11 +229,14 @@ class FilmStripMesh { t.ny /= len; t.y = -0.5f; t.t = 0; - tm.add_XYZ_ST_NORM(t.x, t.y, t.z, t.s, t.t, t.nx, t.ny, t.nz); + tm.setNormal(t.nx, t.ny, t.nz); + tm.setTexture(t.s, t.t); + tm.addVertex(t.x, t.y, t.z); //android.util.Log.e("rs", "vtx x="+t.x+" y="+t.y+" z="+t.z+" s="+t.s+" t="+t.t); t.y = .5f; t.t = 1; - tm.add_XYZ_ST_NORM(t.x, t.y, t.z, t.s, t.t, t.nx, t.ny, t.nz); + tm.setTexture(t.s, t.t); + tm.addVertex(t.x, t.y, t.z); //android.util.Log.e("rs", "vtx x="+t.x+" y="+t.y+" z="+t.z+" s="+t.s+" t="+t.t); if((runningS*2) > mTriangleOffsetsCount) { diff --git a/libs/surfaceflinger/Buffer.cpp b/libs/surfaceflinger/Buffer.cpp index 65650aadbe8b2..6190cd82b98ab 100644 --- a/libs/surfaceflinger/Buffer.cpp +++ b/libs/surfaceflinger/Buffer.cpp @@ -20,17 +20,12 @@ #include #include -#include -#include #include -#include #include #include "Buffer.h" #include "BufferAllocator.h" -#include "SurfaceFlinger.h" - namespace android { diff --git a/libs/surfaceflinger/Buffer.h b/libs/surfaceflinger/Buffer.h index 79f4eeb6a9816..203da3bba8f3e 100644 --- a/libs/surfaceflinger/Buffer.h +++ b/libs/surfaceflinger/Buffer.h @@ -20,20 +20,11 @@ #include #include -#include - -#include - #include #include -#include - #include - -#include #include -class copybit_image_t; struct android_native_buffer_t; namespace android { @@ -42,8 +33,6 @@ namespace android { // Buffer // =========================================================================== -class NativeBuffer; - class Buffer : public SurfaceBuffer { public: diff --git a/libs/surfaceflinger/BufferAllocator.cpp b/libs/surfaceflinger/BufferAllocator.cpp index caf9bec767fd1..3e37bc346565c 100644 --- a/libs/surfaceflinger/BufferAllocator.cpp +++ b/libs/surfaceflinger/BufferAllocator.cpp @@ -15,8 +15,6 @@ ** limitations under the License. */ -#include -#include #include #include diff --git a/libs/surfaceflinger/Layer.cpp b/libs/surfaceflinger/Layer.cpp index 07222eca8efce..13201db04ce08 100644 --- a/libs/surfaceflinger/Layer.cpp +++ b/libs/surfaceflinger/Layer.cpp @@ -65,14 +65,6 @@ Layer::~Layer() // the actual buffers will be destroyed here } -// called with SurfaceFlinger::mStateLock as soon as the layer is entered -// in the purgatory list -void Layer::onRemoved() -{ - // wake up the condition - lcblk->setStatus(NO_INIT); -} - void Layer::destroy() { for (size_t i=0 ; i requestBuffer(int index, int usage); diff --git a/libs/surfaceflinger/LayerBase.cpp b/libs/surfaceflinger/LayerBase.cpp index d83c8429eb3b4..83814ccf9a9ff 100644 --- a/libs/surfaceflinger/LayerBase.cpp +++ b/libs/surfaceflinger/LayerBase.cpp @@ -690,6 +690,14 @@ sp LayerBaseClient::createSurface() const const_cast(this)); } +// called with SurfaceFlinger::mStateLock as soon as the layer is entered +// in the purgatory list +void LayerBaseClient::onRemoved() +{ + // wake up the condition + lcblk->setStatus(NO_INIT); +} + // --------------------------------------------------------------------------- LayerBaseClient::Surface::Surface( @@ -700,7 +708,6 @@ LayerBaseClient::Surface::Surface( { } - LayerBaseClient::Surface::~Surface() { /* diff --git a/libs/surfaceflinger/LayerBase.h b/libs/surfaceflinger/LayerBase.h index 16ee542246886..0dfa4fe86225b 100644 --- a/libs/surfaceflinger/LayerBase.h +++ b/libs/surfaceflinger/LayerBase.h @@ -205,10 +205,13 @@ public: */ virtual bool isSecure() const { return false; } - /** signal this layer that it's not needed any longer. called from the - * main thread */ + /** Called from the main thread, when the surface is removed from the + * draw list */ virtual status_t ditch() { return NO_ERROR; } + /** called with the state lock when the surface is removed from the + * current list */ + virtual void onRemoved() { }; enum { // flags for doTransaction() @@ -318,7 +321,7 @@ public: sp getSurface(); virtual sp createSurface() const; - virtual void onRemoved() { } + virtual void onRemoved(); class Surface : public BnSurface { diff --git a/libs/surfaceflinger/SurfaceFlinger.cpp b/libs/surfaceflinger/SurfaceFlinger.cpp index eb0983ab58f48..f2b918fa2a1c7 100644 --- a/libs/surfaceflinger/SurfaceFlinger.cpp +++ b/libs/surfaceflinger/SurfaceFlinger.cpp @@ -1073,6 +1073,8 @@ status_t SurfaceFlinger::purgatorizeLayer_l(const sp& layerBase) // remove the layer from the main list (through a transaction). ssize_t err = removeLayer_l(layerBase); + layerBase->onRemoved(); + // it's possible that we don't find a layer, because it might // have been destroyed already -- this is not technically an error // from the user because there is a race between BClient::destroySurface(), @@ -1321,7 +1323,6 @@ status_t SurfaceFlinger::removeSurface(SurfaceID index) if (layer != 0) { err = purgatorizeLayer_l(layer); if (err == NO_ERROR) { - layer->onRemoved(); setTransactionFlags(eTransactionNeeded); } } diff --git a/libs/ui/SharedBufferStack.cpp b/libs/ui/SharedBufferStack.cpp index 9ad4349da2993..47c596c5c22b1 100644 --- a/libs/ui/SharedBufferStack.cpp +++ b/libs/ui/SharedBufferStack.cpp @@ -114,6 +114,12 @@ uint32_t SharedBufferBase::getIdentity() return stack.identity; } +status_t SharedBufferBase::getStatus() const +{ + SharedBufferStack& stack( *mSharedStack ); + return stack.status; +} + size_t SharedBufferBase::getFrontBuffer() const { SharedBufferStack& stack( *mSharedStack ); @@ -135,7 +141,6 @@ String8 SharedBufferBase::dump(char const* prefix) const return result; } - // ============================================================================ // conditions and updates // ============================================================================ @@ -375,8 +380,10 @@ status_t SharedBufferServer::unlock(int buffer) void SharedBufferServer::setStatus(status_t status) { - StatusUpdate update(this, status); - updateCondition( update ); + if (status < NO_ERROR) { + StatusUpdate update(this, status); + updateCondition( update ); + } } status_t SharedBufferServer::reallocate() diff --git a/libs/ui/Surface.cpp b/libs/ui/Surface.cpp index 64522fb6c374d..285edb4faca92 100644 --- a/libs/ui/Surface.cpp +++ b/libs/ui/Surface.cpp @@ -733,9 +733,11 @@ status_t Surface::getBufferLocked(int index, int usage) index, usage); if (buffer != 0) { // this should never happen by construction LOGE_IF(buffer->handle == NULL, - "requestBuffer(%d, %08x) returned a buffer with a null handle", - index, usage); - if (buffer->handle != NULL) { + "Surface (identity=%d) requestBuffer(%d, %08x) returned" + "a buffer with a null handle", mIdentity, index, usage); + err = mSharedBufferClient->getStatus(); + LOGE_IF(err, "Surface (identity=%d) state = %d", mIdentity, err); + if (!err && buffer->handle != NULL) { err = getBufferMapper().registerBuffer(buffer->handle); LOGW_IF(err, "registerBuffer(...) failed %d (%s)", err, strerror(-err)); diff --git a/services/java/com/android/server/ConnectivityService.java b/services/java/com/android/server/ConnectivityService.java index 9c64709c90f69..6a8d6924c86c4 100644 --- a/services/java/com/android/server/ConnectivityService.java +++ b/services/java/com/android/server/ConnectivityService.java @@ -53,7 +53,7 @@ import java.util.List; */ public class ConnectivityService extends IConnectivityManager.Stub { - private static final boolean DBG = true; + private static final boolean DBG = false; private static final String TAG = "ConnectivityService"; // Event log tags (must be in sync with event-log-tags) diff --git a/services/java/com/android/server/DockObserver.java b/services/java/com/android/server/DockObserver.java index aa9c2438e4266..f089de1135bc9 100644 --- a/services/java/com/android/server/DockObserver.java +++ b/services/java/com/android/server/DockObserver.java @@ -26,6 +26,7 @@ import android.os.Handler; import android.os.Message; import android.os.SystemClock; import android.os.UEventObserver; +import android.provider.Settings; import android.util.Log; import com.android.internal.widget.LockPatternUtils; @@ -154,26 +155,16 @@ class DockObserver extends UEventObserver { mHandler.sendEmptyMessage(0); } - private final void updateKeyguardLocked() { - if (!mLockPatternUtils.isLockPatternEnabled()) { - if (!mKeyguardDisabled && mDockState != Intent.EXTRA_DOCK_STATE_UNDOCKED) { - Log.d(TAG, "calling mKeyguardLock.disableKeyguard"); - mKeyguardLock.disableKeyguard(); - mKeyguardDisabled = true; - } else if (mKeyguardDisabled && mDockState == Intent.EXTRA_DOCK_STATE_UNDOCKED) { - Log.d(TAG, "calling mKeyguardLock.reenableKeyguard"); - mKeyguardLock.reenableKeyguard(); - mKeyguardDisabled = false; - } - } - } - private final Handler mHandler = new Handler() { @Override public void handleMessage(Message msg) { synchronized (this) { - updateKeyguardLocked(); - Log.d(TAG, "Broadcasting dock state " + mDockState); + Log.i(TAG, "Dock state changed: " + mDockState); + if (Settings.Secure.getInt(mContext.getContentResolver(), + Settings.Secure.DEVICE_PROVISIONED, 0) == 0) { + Log.i(TAG, "Device not provisioned, skipping dock broadcast"); + return; + } // Pack up the values and broadcast them to everyone mPowerManager.userActivityWithForce(SystemClock.uptimeMillis(), false, true); Intent intent = new Intent(Intent.ACTION_DOCK_EVENT); diff --git a/services/java/com/android/server/KeyInputQueue.java b/services/java/com/android/server/KeyInputQueue.java index d7b8f57098d34..35ed448603c32 100644 --- a/services/java/com/android/server/KeyInputQueue.java +++ b/services/java/com/android/server/KeyInputQueue.java @@ -48,6 +48,7 @@ import java.util.ArrayList; public abstract class KeyInputQueue { static final String TAG = "KeyInputQueue"; + static final boolean DEBUG = false; static final boolean DEBUG_VIRTUAL_KEYS = false; static final boolean DEBUG_POINTERS = false; @@ -200,7 +201,7 @@ public abstract class KeyInputQueue { FileInputStream fis = new FileInputStream( "/sys/board_properties/virtualkeys." + deviceName); InputStreamReader isr = new InputStreamReader(fis); - BufferedReader br = new BufferedReader(isr); + BufferedReader br = new BufferedReader(isr, 2048); String str = br.readLine(); if (str != null) { String[] it = str.split(":"); @@ -257,7 +258,7 @@ public abstract class KeyInputQueue { } String name = parser.getAttributeValue(null, "name"); if (name != null) { - Log.d(TAG, "addExcludedDevice " + name); + if (DEBUG) Log.v(TAG, "addExcludedDevice " + name); addExcludedDevice(name); } } @@ -413,7 +414,7 @@ public abstract class KeyInputQueue { Thread mThread = new Thread("InputDeviceReader") { public void run() { - Log.d(TAG, "InputDeviceReader.run()"); + if (DEBUG) Log.v(TAG, "InputDeviceReader.run()"); android.os.Process.setThreadPriority( android.os.Process.THREAD_PRIORITY_URGENT_DISPLAY); diff --git a/services/java/com/android/server/RandomBlock.java b/services/java/com/android/server/RandomBlock.java index 4ac1c6e21b3fa..f7847eccb3506 100644 --- a/services/java/com/android/server/RandomBlock.java +++ b/services/java/com/android/server/RandomBlock.java @@ -32,13 +32,14 @@ import java.io.RandomAccessFile; class RandomBlock { private static final String TAG = "RandomBlock"; + private static final boolean DEBUG = false; private static final int BLOCK_SIZE = 4096; private byte[] block = new byte[BLOCK_SIZE]; private RandomBlock() { } static RandomBlock fromFile(String filename) throws IOException { - Log.v(TAG, "reading from file " + filename); + if (DEBUG) Log.v(TAG, "reading from file " + filename); InputStream stream = null; try { stream = new FileInputStream(filename); @@ -62,7 +63,7 @@ class RandomBlock { } void toFile(String filename) throws IOException { - Log.v(TAG, "writing to file " + filename); + if (DEBUG) Log.v(TAG, "writing to file " + filename); RandomAccessFile out = null; try { out = new RandomAccessFile(filename, "rws"); diff --git a/services/java/com/android/server/WindowManagerService.java b/services/java/com/android/server/WindowManagerService.java index ed6476697c284..67b8a855ed6bb 100644 --- a/services/java/com/android/server/WindowManagerService.java +++ b/services/java/com/android/server/WindowManagerService.java @@ -3218,7 +3218,6 @@ public class WindowManagerService extends IWindowManager.Stub ttoken.windows.remove(startingWindow); ttoken.allAppWindows.remove(startingWindow); addWindowToListInOrderLocked(startingWindow, true); - wtoken.allAppWindows.add(startingWindow); // Propagate other interesting state between the // tokens. If the old token is displayed, we should diff --git a/services/java/com/android/server/am/ActivityManagerService.java b/services/java/com/android/server/am/ActivityManagerService.java index 20fc1da33f002..cd39d0d8af246 100644 --- a/services/java/com/android/server/am/ActivityManagerService.java +++ b/services/java/com/android/server/am/ActivityManagerService.java @@ -9183,7 +9183,7 @@ public final class ActivityManagerService extends ActivityManagerNative implemen pw.print(" lowMem="); pw.print(proc.reportLowMemory); pw.print(", last gced="); pw.print(now-proc.lastRequestedGc); - pw.print(" ms ago, last lowMwm="); + pw.print(" ms ago, last lowMem="); pw.print(now-proc.lastLowMemory); pw.println(" ms ago"); @@ -12306,8 +12306,10 @@ public final class ActivityManagerService extends ActivityManagerNative implemen // broadcast, then do nothing at this point. Just in case, we // check that the process we're waiting for still exists. if (mPendingBroadcast != null) { - Log.i(TAG, "processNextBroadcast: waiting for " - + mPendingBroadcast.curApp); + if (DEBUG_BROADCAST_LIGHT) { + Log.v(TAG, "processNextBroadcast: waiting for " + + mPendingBroadcast.curApp); + } boolean isDead; synchronized (mPidsSelfLocked) { diff --git a/services/java/com/android/server/status/StatusBarIcon.java b/services/java/com/android/server/status/StatusBarIcon.java index 6d09919655e3d..857784b445777 100644 --- a/services/java/com/android/server/status/StatusBarIcon.java +++ b/services/java/com/android/server/status/StatusBarIcon.java @@ -149,6 +149,11 @@ class StatusBarIcon { r = context.getResources(); } + if (data.iconId == 0) { + Log.w(StatusBarService.TAG, "No icon ID for slot " + data.slot); + return null; + } + try { return r.getDrawable(data.iconId); } catch (RuntimeException e) { diff --git a/services/java/com/android/server/status/StatusBarPolicy.java b/services/java/com/android/server/status/StatusBarPolicy.java index 6d54caec1275c..cf63d0220c036 100644 --- a/services/java/com/android/server/status/StatusBarPolicy.java +++ b/services/java/com/android/server/status/StatusBarPolicy.java @@ -1180,16 +1180,16 @@ public class StatusBarPolicy { final String action = intent.getAction(); final boolean enabled = intent.getBooleanExtra(TtyIntent.TTY_ENABLED, false); - Log.i(TAG, "updateTTY: enabled: " + enabled); + if (false) Log.v(TAG, "updateTTY: enabled: " + enabled); if (enabled) { // TTY is on - Log.i(TAG, "updateTTY: set TTY on"); + if (false) Log.v(TAG, "updateTTY: set TTY on"); mService.updateIcon(mTTYModeIcon, mTTYModeEnableIconData, null); mService.setIconVisibility(mTTYModeIcon, true); } else { // TTY is off - Log.i(TAG, "updateTTY: set TTY off"); + if (false) Log.v(TAG, "updateTTY: set TTY off"); mService.setIconVisibility(mTTYModeIcon, false); } } @@ -1220,7 +1220,7 @@ public class StatusBarPolicy { } if (iconIndex == EriInfo.ROAMING_INDICATOR_OFF) { - Log.d(TAG, "Cdma ROAMING_INDICATOR_OFF, removing ERI icon"); + if (false) Log.v(TAG, "Cdma ROAMING_INDICATOR_OFF, removing ERI icon"); mService.setIconVisibility(mCdmaRoamingIndicatorIcon, false); return; } diff --git a/services/java/com/android/server/status/StatusBarService.java b/services/java/com/android/server/status/StatusBarService.java index 99294989b9522..fe761eaa62d85 100644 --- a/services/java/com/android/server/status/StatusBarService.java +++ b/services/java/com/android/server/status/StatusBarService.java @@ -1733,7 +1733,7 @@ public class StatusBarService extends IStatusBar.Stub mOngoingTitle.setText(mContext.getText(R.string.status_bar_ongoing_events_title)); mLatestTitle.setText(mContext.getText(R.string.status_bar_latest_events_title)); mNoNotificationsTitle.setText(mContext.getText(R.string.status_bar_no_notifications_title)); - Log.d(TAG, "updateResources"); + if (false) Log.v(TAG, "updateResources"); } // diff --git a/test-runner/android/test/IsolatedContext.java b/test-runner/android/test/IsolatedContext.java index 5c6616980c663..485e45c957c99 100644 --- a/test-runner/android/test/IsolatedContext.java +++ b/test-runner/android/test/IsolatedContext.java @@ -3,7 +3,7 @@ package android.test; import com.google.android.collect.Lists; import android.accounts.AccountManager; -import android.accounts.OnAccountsUpdatedListener; +import android.accounts.OnAccountsUpdateListener; import android.accounts.Account; import android.content.ContextWrapper; import android.content.ContentResolver; @@ -15,7 +15,6 @@ import android.content.IntentFilter; import android.content.pm.PackageManager; import android.net.Uri; import android.os.Handler; -import android.os.Looper; import java.util.List; import java.io.File; @@ -98,7 +97,7 @@ public class IsolatedContext extends ContextWrapper { super(IsolatedContext.this, null /* IAccountManager */, null /* handler */); } - public void addOnAccountsUpdatedListener(OnAccountsUpdatedListener listener, + public void addOnAccountsUpdatedListener(OnAccountsUpdateListener listener, Handler handler, boolean updateImmediately) { // do nothing }