Skip to content

Commit 8e856f0

Browse files
committed
android-sdk-sources-for-api-level-21 [Android 5.0.1]
0 parents  commit 8e856f0

File tree

10,075 files changed

+3587654
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

10,075 files changed

+3587654
-0
lines changed

android/accessibilityservice/AccessibilityService.java

+788
Large diffs are not rendered by default.

android/accessibilityservice/AccessibilityServiceInfo.java

+976
Large diffs are not rendered by default.

android/accounts/AbstractAccountAuthenticator.java

+554
Large diffs are not rendered by default.

android/accounts/Account.java

+84
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
/*
2+
* Copyright (C) 2009 The Android Open Source Project
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package android.accounts;
18+
19+
import android.os.Parcelable;
20+
import android.os.Parcel;
21+
import android.text.TextUtils;
22+
23+
/**
24+
* Value type that represents an Account in the {@link AccountManager}. This object is
25+
* {@link Parcelable} and also overrides {@link #equals} and {@link #hashCode}, making it
26+
* suitable for use as the key of a {@link java.util.Map}
27+
*/
28+
public class Account implements Parcelable {
29+
public final String name;
30+
public final String type;
31+
32+
public boolean equals(Object o) {
33+
if (o == this) return true;
34+
if (!(o instanceof Account)) return false;
35+
final Account other = (Account)o;
36+
return name.equals(other.name) && type.equals(other.type);
37+
}
38+
39+
public int hashCode() {
40+
int result = 17;
41+
result = 31 * result + name.hashCode();
42+
result = 31 * result + type.hashCode();
43+
return result;
44+
}
45+
46+
public Account(String name, String type) {
47+
if (TextUtils.isEmpty(name)) {
48+
throw new IllegalArgumentException("the name must not be empty: " + name);
49+
}
50+
if (TextUtils.isEmpty(type)) {
51+
throw new IllegalArgumentException("the type must not be empty: " + type);
52+
}
53+
this.name = name;
54+
this.type = type;
55+
}
56+
57+
public Account(Parcel in) {
58+
this.name = in.readString();
59+
this.type = in.readString();
60+
}
61+
62+
public int describeContents() {
63+
return 0;
64+
}
65+
66+
public void writeToParcel(Parcel dest, int flags) {
67+
dest.writeString(name);
68+
dest.writeString(type);
69+
}
70+
71+
public static final Creator<Account> CREATOR = new Creator<Account>() {
72+
public Account createFromParcel(Parcel source) {
73+
return new Account(source);
74+
}
75+
76+
public Account[] newArray(int size) {
77+
return new Account[size];
78+
}
79+
};
80+
81+
public String toString() {
82+
return "Account {name=" + name + ", type=" + type + "}";
83+
}
84+
}

android/accounts/AccountAndUser.java

+49
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
/*
2+
* Copyright (C) 2012 The Android Open Source Project
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package android.accounts;
18+
19+
/**
20+
* Used to store the Account and the UserId this account is associated with.
21+
*
22+
* @hide
23+
*/
24+
public class AccountAndUser {
25+
public Account account;
26+
public int userId;
27+
28+
public AccountAndUser(Account account, int userId) {
29+
this.account = account;
30+
this.userId = userId;
31+
}
32+
33+
public boolean equals(Object o) {
34+
if (this == o) return true;
35+
if (!(o instanceof AccountAndUser)) return false;
36+
final AccountAndUser other = (AccountAndUser) o;
37+
return this.account.equals(other.account)
38+
&& this.userId == other.userId;
39+
}
40+
41+
@Override
42+
public int hashCode() {
43+
return account.hashCode() + userId;
44+
}
45+
46+
public String toString() {
47+
return account.toString() + " u" + userId;
48+
}
49+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
/*
2+
* Copyright (C) 2009 The Android Open Source Project
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package android.accounts;
18+
19+
import android.app.Activity;
20+
import android.os.Bundle;
21+
22+
/**
23+
* Base class for implementing an Activity that is used to help implement an
24+
* AbstractAccountAuthenticator. If the AbstractAccountAuthenticator needs to use an activity
25+
* to handle the request then it can have the activity extend AccountAuthenticatorActivity.
26+
* The AbstractAccountAuthenticator passes in the response to the intent using the following:
27+
* <pre>
28+
* intent.putExtra({@link AccountManager#KEY_ACCOUNT_AUTHENTICATOR_RESPONSE}, response);
29+
* </pre>
30+
* The activity then sets the result that is to be handed to the response via
31+
* {@link #setAccountAuthenticatorResult(android.os.Bundle)}.
32+
* This result will be sent as the result of the request when the activity finishes. If this
33+
* is never set or if it is set to null then error {@link AccountManager#ERROR_CODE_CANCELED}
34+
* will be called on the response.
35+
*/
36+
public class AccountAuthenticatorActivity extends Activity {
37+
private AccountAuthenticatorResponse mAccountAuthenticatorResponse = null;
38+
private Bundle mResultBundle = null;
39+
40+
/**
41+
* Set the result that is to be sent as the result of the request that caused this
42+
* Activity to be launched. If result is null or this method is never called then
43+
* the request will be canceled.
44+
* @param result this is returned as the result of the AbstractAccountAuthenticator request
45+
*/
46+
public final void setAccountAuthenticatorResult(Bundle result) {
47+
mResultBundle = result;
48+
}
49+
50+
/**
51+
* Retreives the AccountAuthenticatorResponse from either the intent of the icicle, if the
52+
* icicle is non-zero.
53+
* @param icicle the save instance data of this Activity, may be null
54+
*/
55+
protected void onCreate(Bundle icicle) {
56+
super.onCreate(icicle);
57+
58+
mAccountAuthenticatorResponse =
59+
getIntent().getParcelableExtra(AccountManager.KEY_ACCOUNT_AUTHENTICATOR_RESPONSE);
60+
61+
if (mAccountAuthenticatorResponse != null) {
62+
mAccountAuthenticatorResponse.onRequestContinued();
63+
}
64+
}
65+
66+
/**
67+
* Sends the result or a Constants.ERROR_CODE_CANCELED error if a result isn't present.
68+
*/
69+
public void finish() {
70+
if (mAccountAuthenticatorResponse != null) {
71+
// send the result bundle back if set, otherwise send an error.
72+
if (mResultBundle != null) {
73+
mAccountAuthenticatorResponse.onResult(mResultBundle);
74+
} else {
75+
mAccountAuthenticatorResponse.onError(AccountManager.ERROR_CODE_CANCELED,
76+
"canceled");
77+
}
78+
mAccountAuthenticatorResponse = null;
79+
}
80+
super.finish();
81+
}
82+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
/*
2+
* Copyright (C) 2009 The Android Open Source Project
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package android.accounts;
18+
19+
import android.os.Bundle;
20+
import android.os.Parcelable;
21+
import android.os.Parcel;
22+
import android.os.RemoteException;
23+
import android.util.Log;
24+
25+
/**
26+
* Object used to communicate responses back to the AccountManager
27+
*/
28+
public class AccountAuthenticatorResponse implements Parcelable {
29+
private static final String TAG = "AccountAuthenticator";
30+
31+
private IAccountAuthenticatorResponse mAccountAuthenticatorResponse;
32+
33+
/**
34+
* @hide
35+
*/
36+
public AccountAuthenticatorResponse(IAccountAuthenticatorResponse response) {
37+
mAccountAuthenticatorResponse = response;
38+
}
39+
40+
public AccountAuthenticatorResponse(Parcel parcel) {
41+
mAccountAuthenticatorResponse =
42+
IAccountAuthenticatorResponse.Stub.asInterface(parcel.readStrongBinder());
43+
}
44+
45+
public void onResult(Bundle result) {
46+
if (Log.isLoggable(TAG, Log.VERBOSE)) {
47+
result.keySet(); // force it to be unparcelled
48+
Log.v(TAG, "AccountAuthenticatorResponse.onResult: "
49+
+ AccountManager.sanitizeResult(result));
50+
}
51+
try {
52+
mAccountAuthenticatorResponse.onResult(result);
53+
} catch (RemoteException e) {
54+
// this should never happen
55+
}
56+
}
57+
58+
public void onRequestContinued() {
59+
if (Log.isLoggable(TAG, Log.VERBOSE)) {
60+
Log.v(TAG, "AccountAuthenticatorResponse.onRequestContinued");
61+
}
62+
try {
63+
mAccountAuthenticatorResponse.onRequestContinued();
64+
} catch (RemoteException e) {
65+
// this should never happen
66+
}
67+
}
68+
69+
public void onError(int errorCode, String errorMessage) {
70+
if (Log.isLoggable(TAG, Log.VERBOSE)) {
71+
Log.v(TAG, "AccountAuthenticatorResponse.onError: " + errorCode + ", " + errorMessage);
72+
}
73+
try {
74+
mAccountAuthenticatorResponse.onError(errorCode, errorMessage);
75+
} catch (RemoteException e) {
76+
// this should never happen
77+
}
78+
}
79+
80+
public int describeContents() {
81+
return 0;
82+
}
83+
84+
public void writeToParcel(Parcel dest, int flags) {
85+
dest.writeStrongBinder(mAccountAuthenticatorResponse.asBinder());
86+
}
87+
88+
public static final Creator<AccountAuthenticatorResponse> CREATOR =
89+
new Creator<AccountAuthenticatorResponse>() {
90+
public AccountAuthenticatorResponse createFromParcel(Parcel source) {
91+
return new AccountAuthenticatorResponse(source);
92+
}
93+
94+
public AccountAuthenticatorResponse[] newArray(int size) {
95+
return new AccountAuthenticatorResponse[size];
96+
}
97+
};
98+
}

0 commit comments

Comments
 (0)