diff --git a/apps/PushApiAuthenticator/Android.mk b/apps/PushApiAuthenticator/Android.mk
new file mode 100644
index 000000000..8616882b6
--- /dev/null
+++ b/apps/PushApiAuthenticator/Android.mk
@@ -0,0 +1,18 @@
+LOCAL_PATH:= $(call my-dir)
+include $(CLEAR_VARS)
+
+LOCAL_MODULE_TAGS := tests
+
+# Only compile source java files in this apk.
+LOCAL_SRC_FILES := $(call all-java-files-under, src)
+
+LOCAL_PACKAGE_NAME := PushApiAuthenticator
+
+LOCAL_SDK_VERSION := current
+
+LOCAL_DEX_PREOPT := false
+
+include $(BUILD_PACKAGE)
+
+# Use the following include to make our test apk.
+include $(call all-makefiles-under,$(LOCAL_PATH))
\ No newline at end of file
diff --git a/apps/PushApiAuthenticator/AndroidManifest.xml b/apps/PushApiAuthenticator/AndroidManifest.xml
new file mode 100644
index 000000000..7628a6b68
--- /dev/null
+++ b/apps/PushApiAuthenticator/AndroidManifest.xml
@@ -0,0 +1,41 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/apps/PushApiAuthenticator/res/drawable/push.png b/apps/PushApiAuthenticator/res/drawable/push.png
new file mode 100644
index 000000000..d34e3360c
Binary files /dev/null and b/apps/PushApiAuthenticator/res/drawable/push.png differ
diff --git a/apps/PushApiAuthenticator/res/layout/activity_main.xml b/apps/PushApiAuthenticator/res/layout/activity_main.xml
new file mode 100644
index 000000000..52c17ea72
--- /dev/null
+++ b/apps/PushApiAuthenticator/res/layout/activity_main.xml
@@ -0,0 +1,246 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/apps/PushApiAuthenticator/res/xml/auth_account_preferences.xml b/apps/PushApiAuthenticator/res/xml/auth_account_preferences.xml
new file mode 100644
index 000000000..bd7902c39
--- /dev/null
+++ b/apps/PushApiAuthenticator/res/xml/auth_account_preferences.xml
@@ -0,0 +1,45 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/apps/PushApiAuthenticator/res/xml/authenticator.xml b/apps/PushApiAuthenticator/res/xml/authenticator.xml
new file mode 100644
index 000000000..06cd96277
--- /dev/null
+++ b/apps/PushApiAuthenticator/res/xml/authenticator.xml
@@ -0,0 +1,25 @@
+
+
+
+
+
\ No newline at end of file
diff --git a/apps/PushApiAuthenticator/src/com/example/android/pushapiauthenticator/MainActivity.java b/apps/PushApiAuthenticator/src/com/example/android/pushapiauthenticator/MainActivity.java
new file mode 100644
index 000000000..2d547e92f
--- /dev/null
+++ b/apps/PushApiAuthenticator/src/com/example/android/pushapiauthenticator/MainActivity.java
@@ -0,0 +1,217 @@
+/*
+ * Copyright (C) 2016 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 com.example.android.pushapiauthenticator;
+
+import android.accounts.Account;
+import android.accounts.AccountManager;
+import android.accounts.AccountManagerCallback;
+import android.accounts.AccountManagerFuture;
+import android.accounts.AuthenticatorDescription;
+import android.app.Activity;
+import android.app.AlertDialog;
+import android.content.Context;
+import android.content.DialogInterface;
+import android.content.Intent;
+import android.os.Bundle;
+import android.view.View;
+import android.view.WindowManager;
+import android.widget.Button;
+import android.widget.EditText;
+import android.widget.RadioButton;
+import android.widget.RadioGroup;
+import android.widget.TextView;
+import android.widget.Toast;
+
+public class MainActivity extends Activity {
+
+ private static AccountManager am;
+
+ public boolean isAccountAdded(Account a) {
+ Account[] accounts = am.getAccountsByType(getApplicationContext().getPackageName());
+ for (Account account : accounts) {
+ if (a.equals(account)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_main);
+
+ am = AccountManager.get(getApplicationContext());
+ final Button getAllRequestingApps = (Button) findViewById(R.id.getallrequestingapps);
+ final TextView getAllRequesting3pUids = (TextView) findViewById(R.id.uidsrequestingapps);
+ final TextView getAllRequesting3pPackages =
+ (TextView) findViewById(R.id.packagesrequestingapps);
+
+ final RadioGroup accountChooser = (RadioGroup) findViewById(R.id.accountGroup);
+ final RadioGroup optionChooser = (RadioGroup) findViewById(R.id.optionsGroup);
+ final EditText uidChooser = (EditText) findViewById(R.id.uidchooser);
+ final Button selectOption = (Button) findViewById(R.id.selectoptionbutton);
+ final TextView authStatus = (TextView) findViewById(R.id.authenticatorstatus);
+
+ final Toast hitGet = Toast.makeText(getApplicationContext(),
+ "Hit the GET Button!", Toast.LENGTH_SHORT);
+ final Toast enterUidWarning = Toast.makeText(getApplicationContext(),
+ "Enter a UID!", Toast.LENGTH_SHORT);
+ final Toast chooseAccountWarning = Toast.makeText(getApplicationContext(),
+ "Choose an Account!", Toast.LENGTH_SHORT);
+ final Toast chooseOptionWarning = Toast.makeText(getApplicationContext(),
+ "Choose an Option!", Toast.LENGTH_SHORT);
+
+ final String ACCOUNT_PASSWORD = "some password";
+ final Bundle ACCOUNT_BUNDLE = new Bundle();
+
+ Account terraAccount = new Account("TERRA", getPackageName());
+ Account aquaAccount = new Account("AQUA", getPackageName());
+ Account ventusAccount = new Account("VENTUS", getPackageName());
+
+ AlertDialog.Builder builder = new AlertDialog.Builder(this);
+ builder.setMessage("Welcome to Auth App. \nPlease make sure you have: \n\n1. Test App 1\n"
+ +"\n2. Test App 2 \n\ninstalled for the demo. These applications" +
+ " together provide tests, use cases, and proof of concept of Push API!\n")
+ .setTitle("WELCOME")
+ .setPositiveButton("Okay", new DialogInterface.OnClickListener() {
+ @Override
+ public void onClick(DialogInterface dialogInterface, int i) {
+ //do nothing
+ }
+ });
+
+ AlertDialog dialog = builder.create();
+ dialog.show();
+
+ getAllRequestingApps.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View view) {
+ int[] allRequestedUids = am.getRequestingUidsForType(getApplicationContext()
+ .getPackageName());
+ if (allRequestedUids != null) {
+ StringBuilder uidMasterString = new StringBuilder();
+ StringBuilder packageMasterString = new StringBuilder();
+ for (int i = 0 ; i < allRequestedUids.length ; i++) {
+ uidMasterString.append(allRequestedUids[i] + ",\n\n");
+ packageMasterString.append(getPackageManager().
+ getNameForUid(allRequestedUids[i])
+ + ",\n\n");
+ }
+ if (uidMasterString.length() > 0) {
+ getAllRequesting3pUids.setText(uidMasterString);
+ } else {
+ getAllRequesting3pUids.setText("----");
+ }
+ if (packageMasterString.length() > 0) {
+ getAllRequesting3pPackages.setText(packageMasterString);
+ } else {
+ getAllRequesting3pPackages.setText("----");
+ }
+ } else {
+ getAllRequesting3pPackages.setText("----");
+ getAllRequesting3pUids.setText("----");
+ }
+ }
+ });
+
+ selectOption.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View view) {
+ Account currentAccount = terraAccount;
+ int checkedAccount = accountChooser.getCheckedRadioButtonId();
+ int checkedOption = optionChooser.getCheckedRadioButtonId();
+ if (uidChooser.getText().length() == 0) {
+ enterUidWarning.show();
+ } else if (checkedAccount == -1) {
+ chooseAccountWarning.show();
+ } else if (checkedOption == -1) {
+ chooseOptionWarning.show();
+ } else {
+ //all conditions satisfied
+ if (checkedAccount == R.id.terrabutton) {
+ currentAccount = terraAccount;
+ } else if (checkedAccount == R.id.aquabutton) {
+ currentAccount = aquaAccount;
+ } else if (checkedAccount == R.id.ventusbutton) {
+ currentAccount = ventusAccount;
+ }
+ String uidstr = uidChooser.getText().toString();
+ int uid = Integer.parseInt(uidstr);
+ if (checkedOption == R.id.addButton) {
+ am.makeAccountVisible(currentAccount, uid);
+ Toast.makeText(getApplicationContext(), "Giving Visibility of " +
+ currentAccount.name + " to " +
+ getPackageManager().getNameForUid(uid),
+ Toast.LENGTH_SHORT).show();
+ } else if (checkedOption == R.id.removeButton) {
+ am.removeAccountVisibility(currentAccount, uid);
+ Toast.makeText(getApplicationContext(), "Removing Visibility of " +
+ currentAccount.name + " to " +
+ getPackageManager().getNameForUid(uid),
+ Toast.LENGTH_SHORT).show();
+
+ } else if (checkedOption == R.id.getButton) {
+ Toast.makeText(getApplicationContext(), "Is " + currentAccount.name +
+ " visible to " + getPackageManager().getNameForUid(uid) + "?\n" +
+ am.isAccountVisible(currentAccount, uid), Toast.LENGTH_SHORT)
+ .show();
+ } else if (checkedOption == R.id.addAccountButton) {
+ Toast.makeText(getApplicationContext(), "Adding account explicitly!"
+ + am.addAccountExplicitly(currentAccount, null, null),
+ Toast.LENGTH_SHORT).show();
+ } else if (checkedOption == R.id.addAccountButtonWithUid) {
+ int[] uidsToAdd = new int[] {uid};
+ Toast.makeText(getApplicationContext(), "Adding account explicitly!"
+ + am.addAccountExplicitly(currentAccount, null, null, uidsToAdd)
+ + " TO: " + getPackageManager().getNameForUid(uid) + "!",
+ Toast.LENGTH_SHORT).show();
+ } else if (checkedOption == R.id.removeAccount) {
+ Toast.makeText(getApplicationContext(), "Removing account explicitly!"
+ + am.removeAccountExplicitly(currentAccount),
+ Toast.LENGTH_SHORT).show();
+ }
+ StringBuilder masterString = new StringBuilder();
+ String uidMasterString = getAllRequesting3pUids.getText().toString();
+ int[] allUids = am.getRequestingUidsForType(getApplicationContext().
+ getPackageName());
+ if (allUids != null) {
+ for (int i = 0 ; i < allUids.length ; i++) {
+ masterString.append(allUids[i] + "\n");
+ if (am.isAccountVisible(terraAccount, allUids[i])) {
+ masterString.append(terraAccount.name + ",");
+ }
+ if (am.isAccountVisible(aquaAccount, allUids[i])) {
+ masterString.append(aquaAccount.name + ",");
+ }
+ if (am.isAccountVisible(ventusAccount, allUids[i])) {
+ masterString.append(ventusAccount.name);
+ }
+ masterString.append("\n");
+ }
+ }
+ if (masterString.length() > 0) {
+ authStatus.setText(masterString);
+ }
+ else {
+ authStatus.setText("----");
+ }
+ }
+ }
+ });
+ }
+}
\ No newline at end of file
diff --git a/apps/PushApiAuthenticator/src/com/example/android/pushapiauthenticator/MyAccountAuthenticator.java b/apps/PushApiAuthenticator/src/com/example/android/pushapiauthenticator/MyAccountAuthenticator.java
new file mode 100644
index 000000000..fa4adeba3
--- /dev/null
+++ b/apps/PushApiAuthenticator/src/com/example/android/pushapiauthenticator/MyAccountAuthenticator.java
@@ -0,0 +1,69 @@
+/*
+ * Copyright (C) 2016 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 com.example.android.pushapiauthenticator;
+
+import android.accounts.AbstractAccountAuthenticator;
+import android.accounts.Account;
+import android.accounts.AccountAuthenticatorResponse;
+import android.accounts.AccountManager;
+import android.content.Context;
+import android.content.Intent;
+import android.os.Bundle;
+import android.text.TextUtils;
+
+public class MyAccountAuthenticator extends AbstractAccountAuthenticator {
+
+ private final Context mContext;
+
+ public MyAccountAuthenticator(Context context) {
+ super(context);
+ mContext = context;
+ }
+
+ public Bundle addAccount(AccountAuthenticatorResponse response, String accountType,
+ String authTokenType, String[] requiredFeatures, Bundle options) {
+ return null;
+ }
+
+ public Bundle getAuthToken(AccountAuthenticatorResponse response, Account account,
+ String authTokenType, Bundle options) {
+ return null;
+ }
+
+ public Bundle confirmCredentials(AccountAuthenticatorResponse response, Account account,
+ Bundle options) {
+ return null;
+ }
+
+ public Bundle editProperties(AccountAuthenticatorResponse response, String accountType) {
+ return null;
+ }
+
+ public String getAuthTokenLabel(String authTokenType) {
+ return null;
+ }
+
+ public Bundle hasFeatures(AccountAuthenticatorResponse response, Account account,
+ String[] features) {
+ return null;
+ }
+
+ public Bundle updateCredentials(AccountAuthenticatorResponse response, Account account,
+ String authTokenType, Bundle options) {
+ return null;
+ }
+}
\ No newline at end of file
diff --git a/apps/PushApiAuthenticator/src/com/example/android/pushapiauthenticator/MyAccountAuthenticatorService.java b/apps/PushApiAuthenticator/src/com/example/android/pushapiauthenticator/MyAccountAuthenticatorService.java
new file mode 100644
index 000000000..deef404f1
--- /dev/null
+++ b/apps/PushApiAuthenticator/src/com/example/android/pushapiauthenticator/MyAccountAuthenticatorService.java
@@ -0,0 +1,32 @@
+/*
+ * Copyright (C) 2016 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 com.example.android.pushapiauthenticator;
+
+import android.app.Service;
+import android.content.Intent;
+import android.os.IBinder;
+
+public class MyAccountAuthenticatorService extends Service {
+
+ private static final String TAG = "AuthenticationService";
+ private final MyAccountAuthenticator authenticator = new MyAccountAuthenticator(this);
+
+ @Override
+ public IBinder onBind(Intent intent) {
+ return authenticator.getIBinder();
+ }
+}
\ No newline at end of file
diff --git a/apps/PushApiTestAppOne/Android.mk b/apps/PushApiTestAppOne/Android.mk
new file mode 100644
index 000000000..ccd2236d6
--- /dev/null
+++ b/apps/PushApiTestAppOne/Android.mk
@@ -0,0 +1,18 @@
+LOCAL_PATH:= $(call my-dir)
+include $(CLEAR_VARS)
+
+LOCAL_MODULE_TAGS := tests
+
+# Only compile source java files in this apk.
+LOCAL_SRC_FILES := $(call all-java-files-under, src)
+
+LOCAL_PACKAGE_NAME := PushApiTestAppOne
+
+LOCAL_SDK_VERSION := current
+
+LOCAL_DEX_PREOPT := false
+
+include $(BUILD_PACKAGE)
+
+# Use the following include to make our test apk.
+include $(call all-makefiles-under,$(LOCAL_PATH))
\ No newline at end of file
diff --git a/apps/PushApiTestAppOne/AndroidManifest.xml b/apps/PushApiTestAppOne/AndroidManifest.xml
new file mode 100644
index 000000000..3999fdc57
--- /dev/null
+++ b/apps/PushApiTestAppOne/AndroidManifest.xml
@@ -0,0 +1,37 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/apps/PushApiTestAppOne/res/drawable/push.png b/apps/PushApiTestAppOne/res/drawable/push.png
new file mode 100644
index 000000000..d34e3360c
Binary files /dev/null and b/apps/PushApiTestAppOne/res/drawable/push.png differ
diff --git a/apps/PushApiTestAppOne/res/layout/activity_main.xml b/apps/PushApiTestAppOne/res/layout/activity_main.xml
new file mode 100644
index 000000000..952e35352
--- /dev/null
+++ b/apps/PushApiTestAppOne/res/layout/activity_main.xml
@@ -0,0 +1,92 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/apps/PushApiTestAppOne/src/com/example/android/pushapithirdpartyone/MainActivity.java b/apps/PushApiTestAppOne/src/com/example/android/pushapithirdpartyone/MainActivity.java
new file mode 100644
index 000000000..7513f0b9a
--- /dev/null
+++ b/apps/PushApiTestAppOne/src/com/example/android/pushapithirdpartyone/MainActivity.java
@@ -0,0 +1,112 @@
+/*
+ * Copyright (C) 2016 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 com.example.android.pushapithirdpartyone;
+
+import android.accounts.Account;
+import android.accounts.AccountManager;
+import android.accounts.AccountManagerCallback;
+import android.accounts.AccountManagerFuture;
+import android.accounts.AuthenticatorDescription;
+import android.app.Activity;
+import android.app.AlertDialog;
+import android.content.Context;
+import android.content.DialogInterface;
+import android.content.Intent;
+import android.content.pm.ApplicationInfo;
+import android.content.pm.PackageManager;
+import android.os.Bundle;
+import android.util.Log;
+import android.view.View;
+import android.view.WindowManager;
+import android.widget.Button;
+import android.widget.CompoundButton;
+import android.widget.TextView;
+import android.widget.Toast;
+import android.widget.ToggleButton;
+
+public class MainActivity extends Activity {
+
+ private static AccountManager am;
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_main);
+ am = AccountManager.get(getApplicationContext());
+ final TextView loginTypesRegistered = (TextView) findViewById(R.id.logintypesregistered);
+ final TextView visibleAccounts = (TextView) findViewById(R.id.visibleaccounts);
+ final Button getVisibleAccounts = (Button) findViewById(R.id.getvisibleaccounts);
+ final Toast notifOn = Toast.makeText(getApplicationContext(), "Notifs Turned On!",
+ Toast.LENGTH_SHORT);
+ final Toast notifOff = Toast.makeText(getApplicationContext(), "Notifs Turned Off!",
+ Toast.LENGTH_SHORT);
+ AlertDialog.Builder builder = new AlertDialog.Builder(this);
+ builder.setMessage("Welcome to Test App 1.\nPlease make sure you have:\n\n1. Test App 2\n"
+ + "\n2. Auth App \n\ninstalled for the demo. These applications together provide" +
+ " tests, use cases, and proof of concept of Push API!\n")
+ .setTitle("WELCOME")
+ .setPositiveButton("Okay", new DialogInterface.OnClickListener() {
+ @Override
+ public void onClick(DialogInterface dialogInterface, int i) {
+ //do nothing
+ }
+ });
+ AlertDialog dialog = builder.create();
+ dialog.show();
+ String supportedPackages = "";
+ try{
+ ApplicationInfo ai = getPackageManager().getApplicationInfo(getPackageName(),
+ PackageManager.GET_META_DATA);
+ Bundle bundle = ai.metaData;
+ supportedPackages = bundle.getString("android.accounts.SupportedLoginTypes");
+ } catch (PackageManager.NameNotFoundException e) {
+ Log.e("PushApiTestAppOne", "Failed to load meta-data, NameNotFound: "
+ + e.getMessage());
+ } catch (NullPointerException e) {
+ Log.e("PushApiTestAppOne", "Failed to load meta-data, NullPointer: " + e.getMessage());
+ }
+ String[] manifestSupportedAccountTypes = supportedPackages.split(";");
+ final StringBuilder masterString = new StringBuilder();
+ for (int i = 0 ; i < manifestSupportedAccountTypes.length ; i++) {
+ masterString.append(manifestSupportedAccountTypes[i] + "\n");
+ }
+ if (masterString.length() > 0) {
+ loginTypesRegistered.setText(masterString);
+ }
+ else {
+ loginTypesRegistered.setText("----");
+ }
+
+ getVisibleAccounts.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View view) {
+ Account[] accountsAccessedByAuthApp = am.getAccounts();
+ StringBuilder masterString = new StringBuilder();
+ for (int i = 0 ; i < accountsAccessedByAuthApp.length ; i++) {
+ masterString.append(accountsAccessedByAuthApp[i].name + ", " +
+ accountsAccessedByAuthApp[i].type + "\n");
+ }
+ if (masterString.length() > 0) {
+ visibleAccounts.setText(masterString);
+ }
+ else {
+ visibleAccounts.setText("----");
+ }
+ }
+ });
+ }
+}
\ No newline at end of file
diff --git a/apps/PushApiTestAppOne/src/com/example/android/pushapithirdpartyone/MessageReceiver.java b/apps/PushApiTestAppOne/src/com/example/android/pushapithirdpartyone/MessageReceiver.java
new file mode 100644
index 000000000..21951f322
--- /dev/null
+++ b/apps/PushApiTestAppOne/src/com/example/android/pushapithirdpartyone/MessageReceiver.java
@@ -0,0 +1,31 @@
+/*
+ * Copyright (C) 2016 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 com.example.android.pushapithirdpartyone;
+
+import android.accounts.Account;
+import android.content.BroadcastReceiver;
+import android.content.Context;
+import android.content.Intent;
+import android.widget.Toast;
+
+public class MessageReceiver extends BroadcastReceiver{
+ public void onReceive(Context context, Intent intent) {
+ Account account = (Account) intent.getParcelableExtra("android.accounts.KEY_ACCOUNT");
+ Toast.makeText(context, "Account " + account.name + " received by Test App 1",
+ Toast.LENGTH_LONG).show();
+ }
+}
\ No newline at end of file
diff --git a/apps/PushApiTestAppTwo/Android.mk b/apps/PushApiTestAppTwo/Android.mk
new file mode 100644
index 000000000..a46f3f0a9
--- /dev/null
+++ b/apps/PushApiTestAppTwo/Android.mk
@@ -0,0 +1,18 @@
+LOCAL_PATH:= $(call my-dir)
+include $(CLEAR_VARS)
+
+LOCAL_MODULE_TAGS := tests
+
+# Only compile source java files in this apk.
+LOCAL_SRC_FILES := $(call all-java-files-under, src)
+
+LOCAL_PACKAGE_NAME := PushApiTestAppTwo
+
+LOCAL_SDK_VERSION := current
+
+LOCAL_DEX_PREOPT := false
+
+include $(BUILD_PACKAGE)
+
+# Use the following include to make our test apk.
+include $(call all-makefiles-under,$(LOCAL_PATH))
diff --git a/apps/PushApiTestAppTwo/AndroidManifest.xml b/apps/PushApiTestAppTwo/AndroidManifest.xml
new file mode 100644
index 000000000..7f1d000cf
--- /dev/null
+++ b/apps/PushApiTestAppTwo/AndroidManifest.xml
@@ -0,0 +1,37 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/apps/PushApiTestAppTwo/res/drawable/push.png b/apps/PushApiTestAppTwo/res/drawable/push.png
new file mode 100644
index 000000000..d34e3360c
Binary files /dev/null and b/apps/PushApiTestAppTwo/res/drawable/push.png differ
diff --git a/apps/PushApiTestAppTwo/res/layout/activity_main.xml b/apps/PushApiTestAppTwo/res/layout/activity_main.xml
new file mode 100644
index 000000000..23d3fe848
--- /dev/null
+++ b/apps/PushApiTestAppTwo/res/layout/activity_main.xml
@@ -0,0 +1,106 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/apps/PushApiTestAppTwo/src/com/example/android/pushapithirdpartytwo/MainActivity.java b/apps/PushApiTestAppTwo/src/com/example/android/pushapithirdpartytwo/MainActivity.java
new file mode 100644
index 000000000..2288d851b
--- /dev/null
+++ b/apps/PushApiTestAppTwo/src/com/example/android/pushapithirdpartytwo/MainActivity.java
@@ -0,0 +1,116 @@
+/*
+ * Copyright (C) 2016 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 com.example.android.pushapithirdpartytwo;
+
+import android.accounts.Account;
+import android.accounts.AccountManager;
+import android.accounts.AccountManagerCallback;
+import android.accounts.AccountManagerFuture;
+import android.accounts.AuthenticatorDescription;
+import android.app.Activity;
+import android.app.AlertDialog;
+import android.content.Context;
+import android.content.DialogInterface;
+import android.content.Intent;
+import android.content.pm.ApplicationInfo;
+import android.content.pm.PackageManager;
+import android.os.Bundle;
+import android.util.Log;
+import android.view.View;
+import android.view.WindowManager;
+import android.widget.Button;
+import android.widget.CompoundButton;
+import android.widget.TextView;
+import android.widget.Toast;
+import android.widget.ToggleButton;
+
+/**
+ * A minimal "Hello, World!" application.
+ */
+public class MainActivity extends Activity {
+ /**
+ * Called with the activity is first created.
+ */
+ private static AccountManager am;
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_main);
+ am = AccountManager.get(getApplicationContext());
+ final TextView loginTypesRegistered = (TextView) findViewById(R.id.logintypesregistered2);
+ final TextView visibleAccounts = (TextView) findViewById(R.id.visibleaccounts2);
+ final Button getVisibleAccounts = (Button) findViewById(R.id.getvisibleaccounts2);
+ final Toast notifOn = Toast.makeText(getApplicationContext(), "Notifs Turned On!",
+ Toast.LENGTH_SHORT);
+ final Toast notifOff = Toast.makeText(getApplicationContext(), "Notifs Turned Off!",
+ Toast.LENGTH_SHORT);
+ AlertDialog.Builder builder = new AlertDialog.Builder(this);
+ builder.setMessage("Welcome to Test App 1.\nPlease make sure you have:\n\n1. Test App 1\n"
+ + "\n2. Auth App \n\ninstalled for the demo. These applications together provide" +
+ " tests, use cases, and proof of concept of Push API!\n")
+ .setTitle("WELCOME")
+ .setPositiveButton("Okay", new DialogInterface.OnClickListener() {
+ @Override
+ public void onClick(DialogInterface dialogInterface, int i) {
+ //do nothing
+ }
+ });
+ AlertDialog dialog = builder.create();
+ dialog.show();
+ String supportedPackages = "";
+ try{
+ ApplicationInfo ai = getPackageManager().getApplicationInfo(getPackageName(),
+ PackageManager.GET_META_DATA);
+ Bundle bundle = ai.metaData;
+ supportedPackages = bundle.getString("android.accounts.SupportedLoginTypes");
+ } catch (PackageManager.NameNotFoundException e) {
+ Log.e("PushApiTestAppTwo", "Failed to load meta-data, NameNotFound: "
+ + e.getMessage());
+ } catch (NullPointerException e) {
+ Log.e("PushApiTestAppTwo", "Failed to load meta-data, NullPointer: " + e.getMessage());
+ }
+ String[] manifestSupportedAccountTypes = supportedPackages.split(";");
+ final StringBuilder masterString = new StringBuilder();
+ for (int i = 0 ; i < manifestSupportedAccountTypes.length ; i++) {
+ masterString.append(manifestSupportedAccountTypes[i] + "\n");
+ }
+ if (masterString.length() > 0) {
+ loginTypesRegistered.setText(masterString);
+ }
+ else {
+ loginTypesRegistered.setText("----");
+ }
+ getVisibleAccounts.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View view) {
+ Account[] accountsAccessedByAuthApp = am.getAccounts();
+ StringBuilder masterString = new StringBuilder();
+ for (int i = 0 ; i < accountsAccessedByAuthApp.length ; i++) {
+ masterString.append(accountsAccessedByAuthApp[i].name + ", " +
+ accountsAccessedByAuthApp[i].type + "\n");
+ }
+ if (masterString.length() > 0) {
+ visibleAccounts.setText(masterString);
+ }
+ else {
+ visibleAccounts.setText("----");
+ }
+ }
+ });
+ }
+}
\ No newline at end of file
diff --git a/apps/PushApiTestAppTwo/src/com/example/android/pushapithirdpartytwo/MessageReceiver.java b/apps/PushApiTestAppTwo/src/com/example/android/pushapithirdpartytwo/MessageReceiver.java
new file mode 100644
index 000000000..496df1be9
--- /dev/null
+++ b/apps/PushApiTestAppTwo/src/com/example/android/pushapithirdpartytwo/MessageReceiver.java
@@ -0,0 +1,31 @@
+/*
+ * Copyright (C) 2016 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 com.example.android.pushapithirdpartytwo;
+
+import android.accounts.Account;
+import android.content.BroadcastReceiver;
+import android.content.Context;
+import android.content.Intent;
+import android.widget.Toast;
+
+public class MessageReceiver extends BroadcastReceiver{
+ public void onReceive(Context context, Intent intent) {
+ Account account = (Account) intent.getParcelableExtra("android.accounts.KEY_ACCOUNT");
+ Toast.makeText(context, "Account " + account.name + " received by Test App 2",
+ Toast.LENGTH_LONG).show();
+ }
+}
\ No newline at end of file