diff --git a/build/sdk-android-x86.atree b/build/sdk-android-x86.atree index 46d05f52d..f8aeff09a 100644 --- a/build/sdk-android-x86.atree +++ b/build/sdk-android-x86.atree @@ -14,8 +14,8 @@ # limitations under the License. # -prebuilts/qemu-kernel/${TARGET_ARCH}/kernel-qemu system-images/${PLATFORM_NAME}/${TARGET_CPU_ABI}/kernel-qemu -prebuilts/qemu-kernel/${TARGET_ARCH}/ranchu/kernel-qemu system-images/${PLATFORM_NAME}/${TARGET_CPU_ABI}/kernel-ranchu +prebuilts/qemu-kernel/${TARGET_ARCH}/3.18/kernel-qemu2 system-images/${PLATFORM_NAME}/${TARGET_CPU_ABI}/kernel-ranchu +device/generic/goldfish/data/etc/encryptionkey.img system-images/${PLATFORM_NAME}/${TARGET_CPU_ABI}/encryptionkey.img # version files for the SDK updater, from development.git ${HOST_OUT}/development/sys-img-${TARGET_CPU_ABI}/images_${TARGET_ARCH}_source.properties system-images/${PLATFORM_NAME}/${TARGET_CPU_ABI}/source.properties diff --git a/build/sdk-android-x86_64.atree b/build/sdk-android-x86_64.atree index b9867d867..b1b534b1d 100644 --- a/build/sdk-android-x86_64.atree +++ b/build/sdk-android-x86_64.atree @@ -14,8 +14,8 @@ # limitations under the License. # -prebuilts/qemu-kernel/${TARGET_ARCH}/kernel-qemu system-images/${PLATFORM_NAME}/${TARGET_CPU_ABI}/kernel-qemu -prebuilts/qemu-kernel/${TARGET_ARCH}/ranchu/kernel-qemu system-images/${PLATFORM_NAME}/${TARGET_CPU_ABI}/kernel-ranchu +prebuilts/qemu-kernel/${TARGET_ARCH}/3.18/kernel-qemu2 system-images/${PLATFORM_NAME}/${TARGET_CPU_ABI}/kernel-ranchu +device/generic/goldfish/data/etc/encryptionkey.img system-images/${PLATFORM_NAME}/${TARGET_CPU_ABI}/encryptionkey.img # version files for the SDK updater, from development.git ${HOST_OUT}/development/sys-img-${TARGET_CPU_ABI}/images_${TARGET_ARCH}_source.properties system-images/${PLATFORM_NAME}/${TARGET_CPU_ABI}/source.properties diff --git a/cmds/monkey/src/com/android/commands/monkey/Monkey.java b/cmds/monkey/src/com/android/commands/monkey/Monkey.java index 440f71052..3b1e39b46 100644 --- a/cmds/monkey/src/com/android/commands/monkey/Monkey.java +++ b/cmds/monkey/src/com/android/commands/monkey/Monkey.java @@ -260,8 +260,7 @@ public class Monkey { */ private class ActivityController extends IActivityController.Stub { public boolean activityStarting(Intent intent, String pkg) { - boolean allow = MonkeyUtils.getPackageFilter().checkEnteringPackage(pkg) - || (DEBUG_ALLOW_ANY_STARTS != 0); + final boolean allow = isActivityStartingAllowed(intent, pkg); if (mVerbose > 0) { // StrictMode's disk checks end up catching this on // userdebug/eng builds due to PrintStream going to a @@ -279,6 +278,34 @@ public class Monkey { return allow; } + private boolean isActivityStartingAllowed(Intent intent, String pkg) { + if (MonkeyUtils.getPackageFilter().checkEnteringPackage(pkg)) { + return true; + } + if (DEBUG_ALLOW_ANY_STARTS != 0) { + return true; + } + // In case the activity is launching home and the default launcher + // package is disabled, allow anyway to prevent ANR (see b/38121026) + final Set categories = intent.getCategories(); + if (intent.getAction() == Intent.ACTION_MAIN + && categories != null + && categories.contains(Intent.CATEGORY_HOME)) { + try { + final ResolveInfo resolveInfo = + mPm.resolveIntent(intent, intent.getType(), 0, UserHandle.myUserId()); + final String launcherPackage = resolveInfo.activityInfo.packageName; + if (pkg.equals(launcherPackage)) { + return true; + } + } catch (RemoteException e) { + Logger.err.println("** Failed talking with package manager!"); + return false; + } + } + return false; + } + public boolean activityResuming(String pkg) { StrictMode.ThreadPolicy savedPolicy = StrictMode.allowThreadDiskWrites(); Logger.out.println(" // activityResuming(" + pkg + ")"); @@ -395,7 +422,7 @@ public class Monkey { } /** - * Run "cat /data/anr/traces.txt". Wait about 5 seconds first, to let the + * Dump the most recent ANR trace. Wait about 5 seconds first, to let the * asynchronous report writing complete. */ private void reportAnrTraces() { @@ -403,7 +430,25 @@ public class Monkey { Thread.sleep(5 * 1000); } catch (InterruptedException e) { } - commandLineReport("anr traces", "cat /data/anr/traces.txt"); + + // The /data/anr directory might have multiple files, dump the most + // recent of those files. + File[] recentTraces = new File("/data/anr/").listFiles(); + if (recentTraces != null) { + File mostRecent = null; + long mostRecentMtime = 0; + for (File trace : recentTraces) { + final long mtime = trace.lastModified(); + if (mtime > mostRecentMtime) { + mostRecentMtime = mtime; + mostRecent = trace; + } + } + + if (mostRecent != null) { + commandLineReport("anr traces", "cat " + mostRecent.getAbsolutePath()); + } + } } /** diff --git a/samples/BusinessCard/Android.mk b/samples/BusinessCard/Android.mk index 78eba5fa1..c2187d6c4 100644 --- a/samples/BusinessCard/Android.mk +++ b/samples/BusinessCard/Android.mk @@ -12,4 +12,6 @@ LOCAL_SDK_VERSION := current LOCAL_DEX_PREOPT := false +LOCAL_PROGUARD_ENABLED := disabled + include $(BUILD_PACKAGE) diff --git a/samples/DeviceAdminWhitelistedAccount/Android.mk b/samples/DeviceAdminWhitelistedAccount/Android.mk new file mode 100644 index 000000000..03d618c3e --- /dev/null +++ b/samples/DeviceAdminWhitelistedAccount/Android.mk @@ -0,0 +1,33 @@ +# +# Copyright (C) 2017 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. +# + +# We build two apps from the same source + +LOCAL_PATH:= $(call my-dir) + +include $(CLEAR_VARS) + +LOCAL_PACKAGE_NAME := DeviceAdminWhitelistedAccount + +LOCAL_MODULE_TAGS := samples tests + +LOCAL_SRC_FILES := $(call all-java-files-under, src) + +LOCAL_RESOURCE_DIR := $(LOCAL_PATH)/res + +LOCAL_SDK_VERSION := current + +include $(BUILD_PACKAGE) diff --git a/samples/DeviceAdminWhitelistedAccount/AndroidManifest.xml b/samples/DeviceAdminWhitelistedAccount/AndroidManifest.xml new file mode 100644 index 000000000..6ce9f8997 --- /dev/null +++ b/samples/DeviceAdminWhitelistedAccount/AndroidManifest.xml @@ -0,0 +1,53 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/samples/DeviceAdminWhitelistedAccount/README.md b/samples/DeviceAdminWhitelistedAccount/README.md new file mode 100644 index 000000000..bebb4f5df --- /dev/null +++ b/samples/DeviceAdminWhitelistedAccount/README.md @@ -0,0 +1,24 @@ +# DeviceAdmin Whitelisted Account + +This application creates an account that will *not* prevent test-only DO/PO from being activated. + +## Build and install: + +``` +croot +mmma -j development/samples/DeviceAdminWhitelistedAccount +adb install -r -g $OUT/data/app/DeviceAdminWhitelistedAccount/DeviceAdminWhitelistedAccount.apk +``` + + +## Create a whitelisted account + +- Launch the "DA Whitelisted Account" app from the launcher. + +## Remove a whitelisted account + +- Just uninstall the app. i.e. + +``` +adb uninstall com.example.android.app.admin.whitelistedaccount +``` diff --git a/samples/DeviceAdminWhitelistedAccount/res/mipmap-hdpi/ic_launcher.png b/samples/DeviceAdminWhitelistedAccount/res/mipmap-hdpi/ic_launcher.png new file mode 100644 index 000000000..1cb2a39b1 Binary files /dev/null and b/samples/DeviceAdminWhitelistedAccount/res/mipmap-hdpi/ic_launcher.png differ diff --git a/samples/DeviceAdminWhitelistedAccount/res/mipmap-mdpi/ic_launcher.png b/samples/DeviceAdminWhitelistedAccount/res/mipmap-mdpi/ic_launcher.png new file mode 100644 index 000000000..d29a23def Binary files /dev/null and b/samples/DeviceAdminWhitelistedAccount/res/mipmap-mdpi/ic_launcher.png differ diff --git a/samples/DeviceAdminWhitelistedAccount/res/mipmap-xhdpi/ic_launcher.png b/samples/DeviceAdminWhitelistedAccount/res/mipmap-xhdpi/ic_launcher.png new file mode 100644 index 000000000..41ffbcbf8 Binary files /dev/null and b/samples/DeviceAdminWhitelistedAccount/res/mipmap-xhdpi/ic_launcher.png differ diff --git a/samples/DeviceAdminWhitelistedAccount/res/mipmap-xxhdpi/ic_launcher.png b/samples/DeviceAdminWhitelistedAccount/res/mipmap-xxhdpi/ic_launcher.png new file mode 100644 index 000000000..0fee79da0 Binary files /dev/null and b/samples/DeviceAdminWhitelistedAccount/res/mipmap-xxhdpi/ic_launcher.png differ diff --git a/samples/DeviceAdminWhitelistedAccount/res/mipmap-xxxhdpi/ic_launcher.png b/samples/DeviceAdminWhitelistedAccount/res/mipmap-xxxhdpi/ic_launcher.png new file mode 100644 index 000000000..fd74afc75 Binary files /dev/null and b/samples/DeviceAdminWhitelistedAccount/res/mipmap-xxxhdpi/ic_launcher.png differ diff --git a/samples/DeviceAdminWhitelistedAccount/res/values/strings.xml b/samples/DeviceAdminWhitelistedAccount/res/values/strings.xml new file mode 100644 index 000000000..b79588eeb --- /dev/null +++ b/samples/DeviceAdminWhitelistedAccount/res/values/strings.xml @@ -0,0 +1,20 @@ + + + + + DA Whitelisted Account + DA Whitelisted Account + diff --git a/samples/DeviceAdminWhitelistedAccount/res/xml/authenticator.xml b/samples/DeviceAdminWhitelistedAccount/res/xml/authenticator.xml new file mode 100644 index 000000000..7fd89cd73 --- /dev/null +++ b/samples/DeviceAdminWhitelistedAccount/res/xml/authenticator.xml @@ -0,0 +1,18 @@ + + + + diff --git a/samples/DeviceAdminWhitelistedAccount/src/com/example/android/app/admin/whitelistedaccount/MyAuthenticator.java b/samples/DeviceAdminWhitelistedAccount/src/com/example/android/app/admin/whitelistedaccount/MyAuthenticator.java new file mode 100644 index 000000000..db88db390 --- /dev/null +++ b/samples/DeviceAdminWhitelistedAccount/src/com/example/android/app/admin/whitelistedaccount/MyAuthenticator.java @@ -0,0 +1,122 @@ +/* + * Copyright (C) 2017 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.app.admin.whitelistedaccount; + +import android.accounts.AbstractAccountAuthenticator; +import android.accounts.Account; +import android.accounts.AccountAuthenticatorResponse; +import android.accounts.AccountManager; +import android.accounts.NetworkErrorException; +import android.app.Service; +import android.content.Context; +import android.content.Intent; +import android.os.Bundle; +import android.os.IBinder; + +public class MyAuthenticator extends Service { + private static final String TAG = "TestAuthenticator"; + + private static final String ACCOUNT_TYPE = "com.example.android.app.admin.whitelistedaccount"; + + private static final String ACCOUNT_FEATURE_DEVICE_OR_PROFILE_OWNER_ALLOWED = + "android.account.DEVICE_OR_PROFILE_OWNER_ALLOWED"; + + private static Authenticator sInstance; + + @Override + public IBinder onBind(Intent intent) { + if (sInstance == null) { + sInstance = new Authenticator(getApplicationContext()); + + } + return sInstance.getIBinder(); + } + + public static boolean setUpAccount(Context context) { + final AccountManager am = AccountManager.get(context); + if (am.getAccountsByType(ACCOUNT_TYPE).length > 0) { + return false; // Already set up. + } + + // Add a new account. + final Account account = new Account( + context.getResources().getString(R.string.account_name), ACCOUNT_TYPE); + am.addAccountExplicitly(account, null, null); + return true; + } + + public static class Authenticator extends AbstractAccountAuthenticator { + + private final Context mContxet; + + public Authenticator(Context context) { + super(context); + mContxet = context; + } + + @Override + public Bundle addAccount(AccountAuthenticatorResponse response, String accountType, + String authTokenType, String[] requiredFeatures, Bundle options) + throws NetworkErrorException { + return new Bundle(); + } + + @Override + public Bundle editProperties(AccountAuthenticatorResponse response, String accountType) { + return new Bundle(); + } + + @Override + public Bundle updateCredentials(AccountAuthenticatorResponse response, Account account, + String authTokenType, Bundle options) throws NetworkErrorException { + return new Bundle(); + } + + @Override + public Bundle confirmCredentials(AccountAuthenticatorResponse response, Account account, + Bundle options) throws NetworkErrorException { + return new Bundle(); + } + + @Override + public Bundle getAuthToken(AccountAuthenticatorResponse response, Account account, + String authTokenType, Bundle options) throws NetworkErrorException { + return new Bundle(); + } + + @Override + public String getAuthTokenLabel(String authTokenType) { + return "token_label"; + } + + @Override + public Bundle hasFeatures(AccountAuthenticatorResponse response, Account account, + String[] features) throws NetworkErrorException { + + boolean hasAll = false; + + if ((features != null) && (features.length == 1) + && ACCOUNT_FEATURE_DEVICE_OR_PROFILE_OWNER_ALLOWED.equals(features[0])) { + hasAll = true; + } + + Bundle result = new Bundle(); + result.putBoolean(AccountManager.KEY_BOOLEAN_RESULT, hasAll); + return result; + } + } +} diff --git a/samples/DeviceAdminWhitelistedAccount/src/com/example/android/app/admin/whitelistedaccount/MyMain.java b/samples/DeviceAdminWhitelistedAccount/src/com/example/android/app/admin/whitelistedaccount/MyMain.java new file mode 100644 index 000000000..3f444899b --- /dev/null +++ b/samples/DeviceAdminWhitelistedAccount/src/com/example/android/app/admin/whitelistedaccount/MyMain.java @@ -0,0 +1,48 @@ +/* + * Copyright (C) 2017 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.app.admin.whitelistedaccount; + +import android.app.Activity; +import android.content.Context; +import android.os.AsyncTask; +import android.os.Bundle; +import android.widget.Toast; + +public class MyMain extends Activity { + @Override + public void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + + final Context context = getApplicationContext(); + + new AsyncTask() { + @Override + protected Boolean doInBackground(Void... voids) { + return MyAuthenticator.setUpAccount(context); + } + + @Override + protected void onPostExecute(Boolean ret) { + Toast.makeText(context, + (ret ? "Account created" : "Account already exists"), + Toast.LENGTH_SHORT).show(); + + } + }.execute(); + + finish(); + } +} diff --git a/samples/IntentPlayground/Android.mk b/samples/IntentPlayground/Android.mk new file mode 100644 index 000000000..7cd3b5a94 --- /dev/null +++ b/samples/IntentPlayground/Android.mk @@ -0,0 +1,19 @@ +LOCAL_PATH:= $(call my-dir) +include $(CLEAR_VARS) + +LOCAL_MODULE_TAGS := samples tests + +# Only compile source java files in this apk. +LOCAL_SRC_FILES := $(call all-java-files-under, src) + +LOCAL_STATIC_JAVA_LIBRARIES = android-support-v13 + +LOCAL_PACKAGE_NAME := IntentPlayground + +LOCAL_SDK_VERSION := current + + +include $(BUILD_PACKAGE) + +# Use the folloing include to make our test apk. +include $(call all-makefiles-under,$(LOCAL_PATH)) diff --git a/samples/IntentPlayground/AndroidManifest.xml b/samples/IntentPlayground/AndroidManifest.xml new file mode 100644 index 000000000..210df6692 --- /dev/null +++ b/samples/IntentPlayground/AndroidManifest.xml @@ -0,0 +1,78 @@ + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/samples/IntentPlayground/res/drawable/card_background.xml b/samples/IntentPlayground/res/drawable/card_background.xml new file mode 100644 index 000000000..001247aaa --- /dev/null +++ b/samples/IntentPlayground/res/drawable/card_background.xml @@ -0,0 +1,20 @@ + + + + + + + \ No newline at end of file diff --git a/samples/IntentPlayground/res/drawable/divider.xml b/samples/IntentPlayground/res/drawable/divider.xml new file mode 100644 index 000000000..0a0dec325 --- /dev/null +++ b/samples/IntentPlayground/res/drawable/divider.xml @@ -0,0 +1,19 @@ + + + + + + \ No newline at end of file diff --git a/samples/IntentPlayground/res/drawable/expand_less_mtrl.xml b/samples/IntentPlayground/res/drawable/expand_less_mtrl.xml new file mode 100644 index 000000000..ee5cddf1c --- /dev/null +++ b/samples/IntentPlayground/res/drawable/expand_less_mtrl.xml @@ -0,0 +1,24 @@ + + + + + diff --git a/samples/IntentPlayground/res/drawable/expand_more_mtrl.xml b/samples/IntentPlayground/res/drawable/expand_more_mtrl.xml new file mode 100644 index 000000000..55def3d1f --- /dev/null +++ b/samples/IntentPlayground/res/drawable/expand_more_mtrl.xml @@ -0,0 +1,24 @@ + + + + + diff --git a/samples/IntentPlayground/res/drawable/expander_group_material.xml b/samples/IntentPlayground/res/drawable/expander_group_material.xml new file mode 100644 index 000000000..1b497da64 --- /dev/null +++ b/samples/IntentPlayground/res/drawable/expander_group_material.xml @@ -0,0 +1,19 @@ + + + + + + diff --git a/samples/IntentPlayground/res/drawable/info_icon.xml b/samples/IntentPlayground/res/drawable/info_icon.xml new file mode 100644 index 000000000..77ef9f3cb --- /dev/null +++ b/samples/IntentPlayground/res/drawable/info_icon.xml @@ -0,0 +1,24 @@ + + + + + diff --git a/samples/IntentPlayground/res/drawable/success_card_background.xml b/samples/IntentPlayground/res/drawable/success_card_background.xml new file mode 100644 index 000000000..bc48008e6 --- /dev/null +++ b/samples/IntentPlayground/res/drawable/success_card_background.xml @@ -0,0 +1,20 @@ + + + + + + + \ No newline at end of file diff --git a/samples/IntentPlayground/res/layout/activity_main.xml b/samples/IntentPlayground/res/layout/activity_main.xml new file mode 100644 index 000000000..d74e44038 --- /dev/null +++ b/samples/IntentPlayground/res/layout/activity_main.xml @@ -0,0 +1,31 @@ + + + + + + + diff --git a/samples/IntentPlayground/res/layout/activity_node.xml b/samples/IntentPlayground/res/layout/activity_node.xml new file mode 100644 index 000000000..bd35d8f72 --- /dev/null +++ b/samples/IntentPlayground/res/layout/activity_node.xml @@ -0,0 +1,72 @@ + + + + + + + + + + + + + + + + diff --git a/samples/IntentPlayground/res/layout/activity_radio_list_item.xml b/samples/IntentPlayground/res/layout/activity_radio_list_item.xml new file mode 100644 index 000000000..18cccf025 --- /dev/null +++ b/samples/IntentPlayground/res/layout/activity_radio_list_item.xml @@ -0,0 +1,38 @@ + + + + + + + + diff --git a/samples/IntentPlayground/res/layout/checkbox_list_item.xml b/samples/IntentPlayground/res/layout/checkbox_list_item.xml new file mode 100644 index 000000000..9ffc93c6f --- /dev/null +++ b/samples/IntentPlayground/res/layout/checkbox_list_item.xml @@ -0,0 +1,23 @@ + + + diff --git a/samples/IntentPlayground/res/layout/dialog_list_item.xml b/samples/IntentPlayground/res/layout/dialog_list_item.xml new file mode 100644 index 000000000..6be9d74e3 --- /dev/null +++ b/samples/IntentPlayground/res/layout/dialog_list_item.xml @@ -0,0 +1,27 @@ + + + + + \ No newline at end of file diff --git a/samples/IntentPlayground/res/layout/fragment_build_intent.xml b/samples/IntentPlayground/res/layout/fragment_build_intent.xml new file mode 100644 index 000000000..5cc5f47e4 --- /dev/null +++ b/samples/IntentPlayground/res/layout/fragment_build_intent.xml @@ -0,0 +1,79 @@ + + + + + + + + + + + + + + + + +