Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 60307343 authored by Fred Quintana's avatar Fred Quintana Committed by The Android Open Source Project
Browse files

Automated import from //branches/master/...@142414,142414

parent d86c7821
Loading
Loading
Loading
Loading
+8 −2
Original line number Diff line number Diff line
@@ -52,7 +52,10 @@ LOCAL_SRC_FILES := $(filter-out \
##
## READ ME: ########################################################
LOCAL_SRC_FILES += \
	core/java/android/accounts/IAccountsService.aidl \
	core/java/android/accounts/IAccountManager.aidl \
	core/java/android/accounts/IAccountManagerResponse.aidl \
	core/java/android/accounts/IAccountAuthenticator.aidl \
	core/java/android/accounts/IAccountAuthenticatorResponse.aidl \
	core/java/android/app/IActivityPendingResult.aidl \
	core/java/android/app/IActivityWatcher.aidl \
	core/java/android/app/IAlarmManager.aidl \
@@ -161,7 +164,10 @@ framework_built := $(LOCAL_BUILT_MODULE)
# relative to the root of the build tree.
# ============================================================
aidl_files := \
	frameworks/base/core/java/android/accounts/IAccountsService.aidl \
	frameworks/base/core/java/android/accounts/IAccountManager.aidl \
	frameworks/base/core/java/android/accounts/IAccountManagerResponse.aidl \
	frameworks/base/core/java/android/accounts/IAccountAuthenticator.aidl \
	frameworks/base/core/java/android/accounts/IAccountAuthenticatorResponse.aidl \
	frameworks/base/core/java/android/app/Notification.aidl \
	frameworks/base/core/java/android/app/PendingIntent.aidl \
	frameworks/base/core/java/android/content/ComponentName.aidl \
+2588 −214

File changed.

Preview size limit exceeded, changes collapsed.

+126 −0
Original line number Diff line number Diff line
/*
 * 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;

import android.os.RemoteException;

/**
 * Base class for creating AccountAuthenticators. This implements the IAccountAuthenticator
 * binder interface and also provides helper libraries to simplify the creation of
 * AccountAuthenticators.
 */
public abstract class AbstractAccountAuthenticator {
    private static final String TAG = "AccountAuthenticator";

    class Transport extends IAccountAuthenticator.Stub {
        public void addAccount(IAccountAuthenticatorResponse response, String accountType)
                throws RemoteException {
            AbstractAccountAuthenticator.this.addAccount(new AccountAuthenticatorResponse(response),
                    accountType);
        }

        public void authenticateAccount(IAccountAuthenticatorResponse
                response, String name, String type, String password)
                throws RemoteException {
            AbstractAccountAuthenticator.this.authenticateAccount(
                    new AccountAuthenticatorResponse(response), new Account(name, type), password);
        }

        public void getAuthToken(IAccountAuthenticatorResponse response,
                String name, String type, String authTokenType)
                throws RemoteException {
            AbstractAccountAuthenticator.this.getAuthToken(
                    new AccountAuthenticatorResponse(response),
                    new Account(name, type), authTokenType);
        }

        public void getPasswordStrength(IAccountAuthenticatorResponse response,
                String accountType, String password)
                throws RemoteException {
            AbstractAccountAuthenticator.this.getPasswordStrength(
                    new AccountAuthenticatorResponse(response), accountType, password);
        }

        public void checkUsernameExistence(IAccountAuthenticatorResponse response,
                String accountType, String username)
                throws RemoteException {
            AbstractAccountAuthenticator.this.checkUsernameExistence(
                    new AccountAuthenticatorResponse(response), accountType, username);
        }

        public void updatePassword(IAccountAuthenticatorResponse response, String name, String type)
                throws RemoteException {
            AbstractAccountAuthenticator.this.updatePassword(
                    new AccountAuthenticatorResponse(response), new Account(name, type));
        }

        public void editProperties(IAccountAuthenticatorResponse response, String accountType)
                throws RemoteException {
            AbstractAccountAuthenticator.this.editProperties(
                    new AccountAuthenticatorResponse(response), accountType);
        }
    }

    Transport mTransport = new Transport();

    /**
     * @return the IAccountAuthenticator binder transport object
     */
    public final IAccountAuthenticator getIAccountAuthenticator()
    {
        return mTransport;
    }

    /**
     * prompts the user for account information and adds the result to the IAccountManager
     */
    public abstract void addAccount(AccountAuthenticatorResponse response, String accountType);

    /**
     * prompts the user for the credentials of the account
     */
    public abstract void authenticateAccount(AccountAuthenticatorResponse response,
            Account account, String password);

    /**
     * gets the password by either prompting the user or querying the IAccountManager
     */
    public abstract void getAuthToken(AccountAuthenticatorResponse response,
            Account account, String authTokenType);

    /**
     * does local analysis or uses a service in the cloud
     */
    public abstract void getPasswordStrength(AccountAuthenticatorResponse response,
        String accountType, String password);

    /**
     * checks with the login service in the cloud
     */
    public abstract void checkUsernameExistence(AccountAuthenticatorResponse response,
        String accountType, String username);

    /**
     * prompts the user for a new password and writes it to the IAccountManager
     */
    public abstract void updatePassword(AccountAuthenticatorResponse response, Account account);

    /**
     * launches an activity that lets the user edit and set the properties for an authenticator
     */
    public abstract void editProperties(AccountAuthenticatorResponse response, String accountType);
}
+19 −0
Original line number Diff line number Diff line
/*
 * 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;

parcelable Account;
+77 −0
Original line number Diff line number Diff line
/*
 * 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;

import android.os.Parcelable;
import android.os.Parcel;

/**
 * Value type that represents an Account in the {@link AccountManager}. This object is
 * {@link Parcelable} and also overrides {@link #equals} and {@link #hashCode}, making it
 * suitable for use as the key of a {@link java.util.Map}
 */
public class Account implements Parcelable {
    public final String mName;
    public final String mType;

    public boolean equals(Object o) {
        if (o == this) return true;
        if (!(o instanceof Account)) return false;
        final Account other = (Account)o;
        return mName.equals(other.mName) && mType.equals(other.mType);
    }

    public int hashCode() {
        int result = 17;
        result = 31 * result + mName.hashCode();
        result = 31 * result + mType.hashCode();
        return result;
    }

    public Account(String name, String type) {
        mName = name;
        mType = type;
    }

    public Account(Parcel in) {
        mName = in.readString();
        mType = in.readString();
    }

    public int describeContents() {
        return 0;
    }

    public void writeToParcel(Parcel dest, int flags) {
        dest.writeString(mName);
        dest.writeString(mType);
    }

    public static final Creator<Account> CREATOR = new Creator<Account>() {
        public Account createFromParcel(Parcel source) {
            return new Account(source);
        }

        public Account[] newArray(int size) {
            return new Account[size];
        }
    };

    public String toString() {
        return "Account {name=" + mName + ", type=" + mType + "}";
    }
}
Loading