Update PushAPI authenticator to work with new Discovery API.
Add dummy certificates to PushApi authenticator and test apps to simplify their usage: Bug: 33046496 Test: manual tests. Change-Id: I94e5fa1ac430da77c0f74ed87bd12467a3ba76b8
This commit is contained in:
@@ -12,6 +12,8 @@ LOCAL_SDK_VERSION := current
|
||||
|
||||
LOCAL_DEX_PREOPT := false
|
||||
|
||||
LOCAL_CERTIFICATE := $(LOCAL_PATH)/cert
|
||||
|
||||
include $(BUILD_PACKAGE)
|
||||
|
||||
# Use the following include to make our test apk.
|
||||
|
||||
@@ -26,6 +26,12 @@
|
||||
<category android:name="android.intent.category.LAUNCHER"/>
|
||||
</intent-filter>
|
||||
</activity>
|
||||
<receiver android:name="com.example.android.pushapiauthenticator.MessageReceiver">
|
||||
<intent-filter>
|
||||
<action android:name="android.accounts.action.ACCOUNTS_LISTENER_PACKAGE_INSTALLED"/>
|
||||
</intent-filter>
|
||||
</receiver>
|
||||
|
||||
<service
|
||||
android:name=".MyAccountAuthenticatorService"
|
||||
android:exported="true">
|
||||
|
||||
BIN
apps/PushApiAuthenticator/cert.pk8
Normal file
BIN
apps/PushApiAuthenticator/cert.pk8
Normal file
Binary file not shown.
24
apps/PushApiAuthenticator/cert.x509.pem
Normal file
24
apps/PushApiAuthenticator/cert.x509.pem
Normal file
@@ -0,0 +1,24 @@
|
||||
-----BEGIN CERTIFICATE-----
|
||||
MIID/TCCAuWgAwIBAgIJAKRuYMXiytGmMA0GCSqGSIb3DQEBCwUAMIGUMQswCQYD
|
||||
VQQGEwJVUzETMBEGA1UECAwKQ2FsaWZvcm5pYTEWMBQGA1UEBwwNTW91bnRhaW4g
|
||||
VmlldzEQMA4GA1UECgwHQW5kcm9pZDEQMA4GA1UECwwHQW5kcm9pZDEQMA4GA1UE
|
||||
AwwHQW5kcm9pZDEiMCAGCSqGSIb3DQEJARYTYW5kcm9pZEBhbmRyb2lkLmNvbTAe
|
||||
Fw0xNzAxMDUyMTE1MDNaFw00NDA1MjMyMTE1MDNaMIGUMQswCQ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
tQ1L+vov9CIU+83bPLvpZJ+Rv1y4qMIF1eCgE8ea+0Jz+9KD3wHPmX9aUryFQQaC
|
||||
NJ70c2gKCJ8hi0pPlWQZ5Ec=
|
||||
-----END CERTIFICATE-----
|
||||
@@ -146,7 +146,7 @@
|
||||
|
||||
<RadioGroup
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="220dp"
|
||||
android:layout_height="280dp"
|
||||
android:id="@+id/optionsGroup"
|
||||
android:layout_below="@+id/textView11"
|
||||
android:layout_alignParentLeft="true">
|
||||
@@ -154,15 +154,22 @@
|
||||
<RadioButton
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="ADD VISIBILITY"
|
||||
android:id="@+id/addButton"
|
||||
android:text="SET VISIBLE (MANAGED)"
|
||||
android:id="@+id/visibleButton"
|
||||
android:checked="false" />
|
||||
|
||||
<RadioButton
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="REMOVE VISIBILITY"
|
||||
android:id="@+id/removeButton"
|
||||
android:text="SET NOT_VISIBLE (MANAGED)"
|
||||
android:id="@+id/notVisibleButton"
|
||||
android:checked="false" />
|
||||
|
||||
<RadioButton
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="SET NOT_VISIBLE"
|
||||
android:id="@+id/forcedNotVisibleButton"
|
||||
android:checked="false" />
|
||||
|
||||
<RadioButton
|
||||
@@ -186,6 +193,13 @@
|
||||
android:id="@+id/addAccountButtonWithUid"
|
||||
android:checked="false" />
|
||||
|
||||
<RadioButton
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="RENAME ACCOUNT"
|
||||
android:id="@+id/renameAccount"
|
||||
android:checked="false" />
|
||||
|
||||
<RadioButton
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
|
||||
@@ -1,17 +1,15 @@
|
||||
/*
|
||||
* 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
|
||||
* 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.
|
||||
* 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;
|
||||
@@ -36,6 +34,8 @@ import android.widget.RadioGroup;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
public class MainActivity extends Activity {
|
||||
|
||||
private static AccountManager am;
|
||||
@@ -67,14 +67,14 @@ public class MainActivity extends Activity {
|
||||
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 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();
|
||||
@@ -85,8 +85,8 @@ public class MainActivity extends Activity {
|
||||
|
||||
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")
|
||||
+ "\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
|
||||
@@ -101,16 +101,16 @@ public class MainActivity extends Activity {
|
||||
getAllRequestingApps.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
int[] allRequestedUids = am.getRequestingUidsForType(getApplicationContext()
|
||||
.getPackageName());
|
||||
int[] allRequestedUids = null;
|
||||
// TODO remove uid part
|
||||
// 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");
|
||||
packageMasterString.append(
|
||||
getPackageManager().getNameForUid(allRequestedUids[i]) + ",\n\n");
|
||||
}
|
||||
if (uidMasterString.length() > 0) {
|
||||
getAllRequesting3pUids.setText(uidMasterString);
|
||||
@@ -132,9 +132,7 @@ public class MainActivity extends Activity {
|
||||
selectOption.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
//TODO update Authenticator once AccountManager API is updated
|
||||
/*
|
||||
Account currentAccount = terraAccount;
|
||||
/*Account currentAccount = terraAccount;
|
||||
int checkedAccount = accountChooser.getCheckedRadioButtonId();
|
||||
int checkedOption = optionChooser.getCheckedRadioButtonId();
|
||||
if (uidChooser.getText().length() == 0) {
|
||||
@@ -154,53 +152,83 @@ public class MainActivity extends Activity {
|
||||
}
|
||||
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),
|
||||
if (checkedOption == R.id.visibleButton) {
|
||||
am.setAccountVisibility(currentAccount, uid,
|
||||
AccountManager.VISIBILITY_USER_MANAGED_VISIBLE);
|
||||
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),
|
||||
} else if (checkedOption == R.id.notVisibleButton) {
|
||||
am.setAccountVisibility(currentAccount, uid,
|
||||
AccountManager.VISIBILITY_USER_MANAGED_NOT_VISIBLE);
|
||||
Toast.makeText(getApplicationContext(),
|
||||
"Removing visibility of " + currentAccount.name + " to "
|
||||
+ getPackageManager().getNameForUid(uid),
|
||||
Toast.LENGTH_SHORT).show();
|
||||
} else if (checkedOption == R.id.forcedNotVisibleButton) {
|
||||
am.setAccountVisibility(currentAccount, uid,
|
||||
AccountManager.VISIBILITY_NOT_VISIBLE);
|
||||
Toast.makeText(getApplicationContext(),
|
||||
"Removing visibility (not managed) 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();
|
||||
Toast.makeText(getApplicationContext(),
|
||||
"Is " + currentAccount.name + " visible to "
|
||||
+ getPackageManager().getNameForUid(uid) + "?\n"
|
||||
+ am.getAccountVisibility(currentAccount, uid),
|
||||
Toast.LENGTH_SHORT).show();
|
||||
} else if (checkedOption == R.id.addAccountButton) {
|
||||
Toast.makeText(getApplicationContext(), "Adding account explicitly!"
|
||||
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)
|
||||
HashMap<Integer, Integer> uidsAndVisibility = new HashMap<>();
|
||||
uidsAndVisibility.put(uid, AccountManager.VISIBILITY_USER_MANAGED_VISIBLE);
|
||||
Toast.makeText(getApplicationContext(),
|
||||
"Adding account explicitly!"
|
||||
+ am.addAccountExplicitly(currentAccount, null, null,
|
||||
uidsAndVisibility)
|
||||
+ " TO: " + getPackageManager().getNameForUid(uid) + "!",
|
||||
Toast.LENGTH_SHORT).show();
|
||||
} else if (checkedOption == R.id.removeAccount) {
|
||||
Toast.makeText(getApplicationContext(), "Removing account explicitly!"
|
||||
Toast.makeText(getApplicationContext(),
|
||||
"Removing account explicitly!"
|
||||
+ am.removeAccountExplicitly(currentAccount),
|
||||
Toast.LENGTH_SHORT).show();
|
||||
} else if (checkedOption == R.id.renameAccount) {
|
||||
try {
|
||||
AccountManagerFuture<Account> accountRenameFuture = am.renameAccount(
|
||||
currentAccount, currentAccount.name + "1", null, null);
|
||||
Account renamedAccount = accountRenameFuture.getResult();
|
||||
Toast.makeText(getApplicationContext(),
|
||||
"New account name " + renamedAccount, Toast.LENGTH_SHORT)
|
||||
.show();
|
||||
} catch (Exception e) {
|
||||
Toast.makeText(getApplicationContext(),
|
||||
"Exception" + e, Toast.LENGTH_SHORT)
|
||||
.show();
|
||||
}
|
||||
}
|
||||
StringBuilder masterString = new StringBuilder();
|
||||
String uidMasterString = getAllRequesting3pUids.getText().toString();
|
||||
int[] allUids = am.getRequestingUidsForType(getApplicationContext().
|
||||
getPackageName());
|
||||
int[] allUids = null;
|
||||
//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])) {
|
||||
if (am.getAccountVisibility(terraAccount,
|
||||
allUids[i]) == AccountManager.VISIBILITY_USER_MANAGED_VISIBLE) {
|
||||
masterString.append(terraAccount.name + ",");
|
||||
}
|
||||
if (am.isAccountVisible(aquaAccount, allUids[i])) {
|
||||
if (am.getAccountVisibility(aquaAccount,
|
||||
allUids[i]) == AccountManager.VISIBILITY_USER_MANAGED_VISIBLE) {
|
||||
masterString.append(aquaAccount.name + ",");
|
||||
}
|
||||
if (am.isAccountVisible(ventusAccount, allUids[i])) {
|
||||
if (am.getAccountVisibility(ventusAccount,
|
||||
allUids[i]) == AccountManager.VISIBILITY_USER_MANAGED_VISIBLE) {
|
||||
masterString.append(ventusAccount.name);
|
||||
}
|
||||
masterString.append("\n");
|
||||
@@ -208,13 +236,10 @@ public class MainActivity extends Activity {
|
||||
}
|
||||
if (masterString.length() > 0) {
|
||||
authStatus.setText(masterString);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
authStatus.setText("----");
|
||||
}
|
||||
}
|
||||
*/
|
||||
}*/
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}}
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
* 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.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.util.Log;
|
||||
import android.widget.Toast;
|
||||
|
||||
public class MessageReceiver extends BroadcastReceiver {
|
||||
|
||||
private static final String TAG = "PushApiAuthenticator";
|
||||
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
if (intent.getAction()
|
||||
.equals("android.accounts.action.ACCOUNTS_LISTENER_PACKAGE_INSTALLED")) {
|
||||
String newPackage = intent.getStringExtra("android.intent.extra.PACKAGE_NAME");
|
||||
Log.i(TAG, "new app is installed " + newPackage);
|
||||
Toast.makeText(context, "new app is installed" + newPackage, Toast.LENGTH_LONG).show();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -12,6 +12,8 @@ LOCAL_SDK_VERSION := current
|
||||
|
||||
LOCAL_DEX_PREOPT := false
|
||||
|
||||
LOCAL_CERTIFICATE := $(LOCAL_PATH)/cert
|
||||
|
||||
include $(BUILD_PACKAGE)
|
||||
|
||||
# Use the following include to make our test apk.
|
||||
|
||||
@@ -18,6 +18,9 @@
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="com.example.android.pushapithirdpartyone">
|
||||
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
|
||||
<uses-sdk android:minSdkVersion="1"
|
||||
android:targetSdkVersion="10001"
|
||||
android:maxSdkVersion="11000" />
|
||||
<application android:label="3P App 1" android:icon="@drawable/push">
|
||||
<activity android:name="MainActivity">
|
||||
<intent-filter>
|
||||
@@ -27,7 +30,7 @@
|
||||
</activity>
|
||||
<receiver android:name="com.example.android.pushapithirdpartyone.MessageReceiver">
|
||||
<intent-filter>
|
||||
<action android:name="android.accounts.NEW_ACCOUNT_VISIBLE"/>
|
||||
<action android:name="android.accounts.action.VISIBLE_ACCOUNTS_CHANGED"/>
|
||||
</intent-filter>
|
||||
</receiver>
|
||||
<meta-data
|
||||
|
||||
BIN
apps/PushApiTestAppOne/cert.pk8
Normal file
BIN
apps/PushApiTestAppOne/cert.pk8
Normal file
Binary file not shown.
24
apps/PushApiTestAppOne/cert.x509.pem
Normal file
24
apps/PushApiTestAppOne/cert.x509.pem
Normal file
@@ -0,0 +1,24 @@
|
||||
-----BEGIN CERTIFICATE-----
|
||||
MIID/TCCAuWgAwIBAgIJAJQhygyzfNTkMA0GCSqGSIb3DQEBCwUAMIGUMQswCQYD
|
||||
VQQGEwJVUzETMBEGA1UECAwKQ2FsaWZvcm5pYTEWMBQGA1UEBwwNTW91bnRhaW4g
|
||||
VmlldzEQMA4GA1UECgwHQW5kcm9pZDEQMA4GA1UECwwHQW5kcm9pZDEQMA4GA1UE
|
||||
AwwHQW5kcm9pZDEiMCAGCSqGSIb3DQEJARYTYW5kcm9pZEBhbmRyb2lkLmNvb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0tL09EdgbYQ+3HXvjmVcNRQyZe0yFSDESBv19P1mKDFyjcp
|
||||
8KqTr+3eaDkRx0gaIjGO1rjB6rCncN5nlA1Xeeu/ECFZO39PYh2GfPyhIYOHKeDs
|
||||
8D6CT+FwXp7PxXqJEmwWjC0=
|
||||
-----END CERTIFICATE-----
|
||||
@@ -41,6 +41,7 @@ import android.widget.ToggleButton;
|
||||
public class MainActivity extends Activity {
|
||||
|
||||
private static AccountManager am;
|
||||
private static final int REQUEST_CODE_PICK_ACCOUNT = 0;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
@@ -50,15 +51,14 @@ public class MainActivity extends Activity {
|
||||
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);
|
||||
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")
|
||||
+ "\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) {
|
||||
@@ -74,8 +74,7 @@ public class MainActivity extends Activity {
|
||||
Bundle bundle = ai.metaData;
|
||||
supportedPackages = bundle.getString("android.accounts.SupportedAccountTypes");
|
||||
} catch (PackageManager.NameNotFoundException e) {
|
||||
Log.e("PushApiTestAppOne", "Failed to load meta-data, NameNotFound: "
|
||||
+ e.getMessage());
|
||||
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());
|
||||
}
|
||||
@@ -86,27 +85,48 @@ public class MainActivity extends Activity {
|
||||
}
|
||||
if (masterString.length() > 0) {
|
||||
loginTypesRegistered.setText(masterString);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
loginTypesRegistered.setText("----");
|
||||
}
|
||||
|
||||
getVisibleAccounts.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
//int result = ContextCompat.checkSelfPermission(this, Manifest.permission.GET_ACCOUNTS);
|
||||
//if (result != PackageManager.PERMISSION_GRANTED) {
|
||||
// ActivityCompat.requestPermissions(this,
|
||||
// new String[]{Manifest.permission.GET_ACCOUNTS}, 101);
|
||||
//}
|
||||
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");
|
||||
masterString.append(accountsAccessedByAuthApp[i].name + ", "
|
||||
+ accountsAccessedByAuthApp[i].type + "\n");
|
||||
}
|
||||
if (masterString.length() > 0) {
|
||||
visibleAccounts.setText(masterString);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
visibleAccounts.setText("----");
|
||||
}
|
||||
|
||||
Intent intent = AccountManager.newChooseAccountIntent(null, null, null, null, null,
|
||||
null, null); // Show all accounts
|
||||
startActivityForResult(intent, REQUEST_CODE_PICK_ACCOUNT);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||
if (requestCode == REQUEST_CODE_PICK_ACCOUNT) {
|
||||
// Receiving a result from the AccountPicker
|
||||
if (resultCode == RESULT_OK) {
|
||||
Toast.makeText(this, data.getStringExtra(AccountManager.KEY_ACCOUNT_TYPE),
|
||||
Toast.LENGTH_LONG).show();
|
||||
// data.getStringExtra(AccountManager.KEY_ACCOUNT_NAME);
|
||||
} else if (resultCode == RESULT_CANCELED) {
|
||||
Toast.makeText(this, "No account was chosen", Toast.LENGTH_LONG).show();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.example.android.pushapithirdpartytwo;
|
||||
package com.example.android.pushapithirdpartyone;
|
||||
|
||||
import android.accounts.Account;
|
||||
import android.content.BroadcastReceiver;
|
||||
@@ -27,8 +27,9 @@ public class MessageReceiver extends BroadcastReceiver{
|
||||
private static final String TAG = "PushApiTestAppOne";
|
||||
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
Toast.makeText(context, " android.accounts.VISIBLE_ACCOUNTS_CHANGED Broadcast received",
|
||||
Toast.makeText(context,
|
||||
"android.accounts.action.VISIBLE_ACCOUNTS_CHANGED Broadcast received",
|
||||
Toast.LENGTH_LONG).show();
|
||||
Log.i(TAG, "android.accounts.VISIBLE_ACCOUNTS_CHANGED Broadcast received");
|
||||
Log.i(TAG, "android.accounts.action.VISIBLE_ACCOUNTS_CHANGED Broadcast received");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,6 +12,8 @@ LOCAL_SDK_VERSION := current
|
||||
|
||||
LOCAL_DEX_PREOPT := false
|
||||
|
||||
LOCAL_CERTIFICATE := $(LOCAL_PATH)/cert
|
||||
|
||||
include $(BUILD_PACKAGE)
|
||||
|
||||
# Use the following include to make our test apk.
|
||||
|
||||
@@ -17,7 +17,10 @@
|
||||
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="com.example.android.pushapithirdpartytwo">
|
||||
<!-- <uses-permission android:name="android.permission.GET_ACCOUNTS"/> -->
|
||||
<uses-permission android:name="android.permission.GET_ACCOUNTS"/>
|
||||
<uses-sdk android:minSdkVersion="1"
|
||||
android:targetSdkVersion="1001"
|
||||
android:maxSdkVersion="11000" />
|
||||
<application android:label="3P App 2" android:icon="@drawable/push">
|
||||
<activity android:name="MainActivity">
|
||||
<intent-filter>
|
||||
@@ -27,7 +30,7 @@
|
||||
</activity>
|
||||
<receiver android:name="com.example.android.pushapithirdpartytwo.MessageReceiver">
|
||||
<intent-filter>
|
||||
<action android:name="android.accounts.VISIBLE_ACCOUNTS_CHANGED"/>
|
||||
<action android:name="android.accounts.action.VISIBLE_ACCOUNTS_CHANGED"/>
|
||||
</intent-filter>
|
||||
</receiver>
|
||||
<meta-data
|
||||
|
||||
BIN
apps/PushApiTestAppTwo/cert.pk8
Normal file
BIN
apps/PushApiTestAppTwo/cert.pk8
Normal file
Binary file not shown.
24
apps/PushApiTestAppTwo/cert.x509.pem
Normal file
24
apps/PushApiTestAppTwo/cert.x509.pem
Normal file
@@ -0,0 +1,24 @@
|
||||
-----BEGIN CERTIFICATE-----
|
||||
MIID/TCCAuWgAwIBAgIJAKmfnlOvpOpWMA0GCSqGSIb3DQEBCwUAMIGUMQswCQYD
|
||||
VQQGEwJVUzETMBEGA1UECAwKQ2FsaWZvcm5pYTEWMBQGA1UEBwwNTW91bnRhaW4g
|
||||
VmlldzEQMA4GA1UECgwHQW5kcm9pZDEQMA4GA1UECwwHQW5kcm9pZDEQMA4GA1UE
|
||||
AwwHQW5kcm9pZDEiMCAGCSqGSIb3DQEJARYTYW5kcm9pZEBhbmRyb2lkLmNvbTAe
|
||||
Fw0xNzAxMDUyMTE3MDZaFw00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eAeLBofSHotswgZAhXwpl6xP9
|
||||
y2kL0VV9pTlzNgGmmgxhNXW+6L+Ondcnsh8JNfCLuK4472Pazd8rvEkWPF0fTKeZ
|
||||
zL8zfCYYur8uYjQQJhIoiYo=
|
||||
-----END CERTIFICATE-----
|
||||
@@ -32,7 +32,7 @@
|
||||
android:layout_height="wrap_content"
|
||||
android:textAppearance="?android:attr/textAppearanceLarge"
|
||||
android:text="Test Application Two"
|
||||
android:id="@+id/testapptext"
|
||||
android:id="@+id/testapponetext"
|
||||
android:layout_alignParentTop="true"
|
||||
android:layout_centerHorizontal="true"
|
||||
android:layout_marginTop="27dp" />
|
||||
@@ -44,7 +44,7 @@
|
||||
android:text="Visible Accounts"
|
||||
android:id="@+id/visibleaccountstext"
|
||||
android:layout_marginTop="58dp"
|
||||
android:layout_below="@+id/testapptext"
|
||||
android:layout_below="@+id/testapponetext"
|
||||
android:layout_alignParentLeft="true"
|
||||
android:layout_alignParentStart="true" />
|
||||
|
||||
|
||||
@@ -46,6 +46,7 @@ public class MainActivity extends Activity {
|
||||
* Called with the activity is first created.
|
||||
*/
|
||||
private static AccountManager am;
|
||||
private static final int REQUEST_CODE_PICK_ACCOUNT = 0;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
@@ -55,15 +56,14 @@ public class MainActivity extends Activity {
|
||||
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);
|
||||
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")
|
||||
builder.setMessage("Welcome to Test App 2.\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) {
|
||||
@@ -79,8 +79,7 @@ public class MainActivity extends Activity {
|
||||
Bundle bundle = ai.metaData;
|
||||
supportedPackages = bundle.getString("android.accounts.SupportedAccountTypes");
|
||||
} catch (PackageManager.NameNotFoundException e) {
|
||||
Log.e("PushApiTestAppTwo", "Failed to load meta-data, NameNotFound: "
|
||||
+ e.getMessage());
|
||||
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());
|
||||
}
|
||||
@@ -91,8 +90,7 @@ public class MainActivity extends Activity {
|
||||
}
|
||||
if (masterString.length() > 0) {
|
||||
loginTypesRegistered.setText(masterString);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
loginTypesRegistered.setText("----");
|
||||
}
|
||||
getVisibleAccounts.setOnClickListener(new View.OnClickListener() {
|
||||
@@ -101,15 +99,18 @@ public class MainActivity extends Activity {
|
||||
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");
|
||||
masterString.append(accountsAccessedByAuthApp[i].name + ", "
|
||||
+ accountsAccessedByAuthApp[i].type + "\n");
|
||||
}
|
||||
if (masterString.length() > 0) {
|
||||
visibleAccounts.setText(masterString);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
visibleAccounts.setText("----");
|
||||
}
|
||||
|
||||
Intent intent = AccountManager.newChooseAccountIntent(null, null, null, null, null,
|
||||
null, null); // Show all accounts
|
||||
startActivityForResult(intent, REQUEST_CODE_PICK_ACCOUNT);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -27,8 +27,9 @@ public class MessageReceiver extends BroadcastReceiver{
|
||||
private static final String TAG = "PushApiTestAppTwo";
|
||||
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
Toast.makeText(context, " android.accounts.VISIBLE_ACCOUNTS_CHANGED Broadcast received",
|
||||
Toast.makeText(context,
|
||||
"android.accounts.action.VISIBLE_ACCOUNTS_CHANGED Broadcast received",
|
||||
Toast.LENGTH_LONG).show();
|
||||
Log.i(TAG, "android.accounts.VISIBLE_ACCOUNTS_CHANGED Broadcast received");
|
||||
Log.i(TAG, "android.accounts.action.VISIBLE_ACCOUNTS_CHANGED Broadcast received");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user