summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWally Yau <wyau@google.com>2018-02-22 09:41:21 -0800
committerWally Yau <wyau@google.com>2018-02-22 17:08:25 -0800
commit068ba53441f6ff27ce3761c4b8ebb5f7b16fe0ee (patch)
tree578eeac3b5d7d65c055cff04bfcc9e4ed90707e4
parent96a9633a947d20dd70c35a1bb669a11b5e45f5c4 (diff)
downloaddevice_google_atv-068ba53441f6ff27ce3761c4b8ebb5f7b16fe0ee.tar.gz
device_google_atv-068ba53441f6ff27ce3761c4b8ebb5f7b16fe0ee.tar.bz2
device_google_atv-068ba53441f6ff27ce3761c4b8ebb5f7b16fe0ee.zip
A provisioning app for Android TV
This app can be used by AOSP devices which do not have SetupWraith to go through the normal user setup process. It marks the device as provisioned. Bug: b/70360161 Test: Includes this APK on the ATV GSI image and enable developer mode. Change-Id: I570e5ba17dafb03ca9b3f3176bb002b908b22cdd
-rw-r--r--TvProvision/Android.mk14
-rw-r--r--TvProvision/AndroidManifest.xml39
-rw-r--r--TvProvision/CleanSpec.mk49
-rw-r--r--TvProvision/MODULE_LICENSE_APACHE20
-rw-r--r--TvProvision/proguard.flags1
-rw-r--r--TvProvision/src/com/android/tv/provision/DefaultActivity.java61
6 files changed, 164 insertions, 0 deletions
diff --git a/TvProvision/Android.mk b/TvProvision/Android.mk
new file mode 100644
index 0000000..8655dd1
--- /dev/null
+++ b/TvProvision/Android.mk
@@ -0,0 +1,14 @@
+LOCAL_PATH:= $(call my-dir)
+include $(CLEAR_VARS)
+
+LOCAL_MODULE_TAGS := optional
+
+LOCAL_SRC_FILES := $(call all-subdir-java-files)
+
+LOCAL_PACKAGE_NAME := TvProvision
+LOCAL_CERTIFICATE := platform
+LOCAL_PRIVILEGED_MODULE := true
+
+LOCAL_PROGUARD_FLAG_FILES := proguard.flags
+
+include $(BUILD_PACKAGE)
diff --git a/TvProvision/AndroidManifest.xml b/TvProvision/AndroidManifest.xml
new file mode 100644
index 0000000..389939e
--- /dev/null
+++ b/TvProvision/AndroidManifest.xml
@@ -0,0 +1,39 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Copyright (C) 2018 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.
+ -->
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+ package="com.android.tv.provision">
+
+ <original-package android:name="com.android.tv.provision" />
+
+ <!-- For miscellaneous settings -->
+ <uses-permission android:name="android.permission.WRITE_SETTINGS" />
+ <uses-permission android:name="android.permission.WRITE_SECURE_SETTINGS" />
+ <uses-permission android:name="android.permission.MANAGE_USERS" />
+
+ <application>
+ <activity android:name="DefaultActivity"
+ android:excludeFromRecents="true">
+ <intent-filter android:priority="3">
+ <action android:name="android.intent.action.MAIN" />
+ <category android:name="android.intent.category.HOME" />
+ <category android:name="android.intent.category.DEFAULT" />
+ <category android:name="android.intent.category.SETUP_WIZARD" />
+ </intent-filter>
+ </activity>
+ </application>
+</manifest>
+
diff --git a/TvProvision/CleanSpec.mk b/TvProvision/CleanSpec.mk
new file mode 100644
index 0000000..d1b49d8
--- /dev/null
+++ b/TvProvision/CleanSpec.mk
@@ -0,0 +1,49 @@
+# Copyright (C) 2018 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.
+#
+
+# If you don't need to do a full clean build but would like to touch
+# a file or delete some intermediate files, add a clean step to the end
+# of the list. These steps will only be run once, if they haven't been
+# run before.
+#
+# E.g.:
+# $(call add-clean-step, touch -c external/sqlite/sqlite3.h)
+# $(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/STATIC_LIBRARIES/libz_intermediates)
+#
+# Always use "touch -c" and "rm -f" or "rm -rf" to gracefully deal with
+# files that are missing or have been moved.
+#
+# Use $(PRODUCT_OUT) to get to the "out/target/product/blah/" directory.
+# Use $(OUT_DIR) to refer to the "out" directory.
+#
+# If you need to re-do something that's already mentioned, just copy
+# the command and add it to the bottom of the list. E.g., if a change
+# that you made last week required touching a file and a change you
+# made today requires touching the same file, just copy the old
+# touch step and add it to the end of the list.
+#
+# ************************************************
+# NEWER CLEAN STEPS MUST BE AT THE END OF THE LIST
+# ************************************************
+
+# For example:
+#$(call add-clean-step, rm -rf $(OUT_DIR)/target/common/obj/APPS/AndroidTests_intermediates)
+#$(call add-clean-step, rm -rf $(OUT_DIR)/target/common/obj/JAVA_LIBRARIES/core_intermediates)
+#$(call add-clean-step, find $(OUT_DIR) -type f -name "IGTalkSession*" -print0 | xargs -0 rm -f)
+#$(call add-clean-step, rm -rf $(PRODUCT_OUT)/data/*)
+
+# ************************************************
+# NEWER CLEAN STEPS MUST BE AT THE END OF THE LIST
+# ************************************************
diff --git a/TvProvision/MODULE_LICENSE_APACHE2 b/TvProvision/MODULE_LICENSE_APACHE2
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/TvProvision/MODULE_LICENSE_APACHE2
diff --git a/TvProvision/proguard.flags b/TvProvision/proguard.flags
new file mode 100644
index 0000000..a934979
--- /dev/null
+++ b/TvProvision/proguard.flags
@@ -0,0 +1 @@
+-keep class * extends android.app.Activity
diff --git a/TvProvision/src/com/android/tv/provision/DefaultActivity.java b/TvProvision/src/com/android/tv/provision/DefaultActivity.java
new file mode 100644
index 0000000..97a7ff9
--- /dev/null
+++ b/TvProvision/src/com/android/tv/provision/DefaultActivity.java
@@ -0,0 +1,61 @@
+/*
+ * Copyright (C) 2018 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.android.tv.provision;
+
+import android.app.Activity;
+import android.content.ComponentName;
+import android.content.Context;
+import android.content.pm.PackageManager;
+import android.content.pm.UserInfo;
+import android.os.Bundle;
+import android.os.UserHandle;
+import android.os.UserManager;
+import android.provider.Settings;
+
+/**
+ * Application that sets the provisioned bit, like SetupWizard does.
+ */
+public class DefaultActivity extends Activity {
+
+ @Override
+ protected void onCreate(Bundle icicle) {
+ super.onCreate(icicle);
+
+ // Add a persistent setting to allow other apps to know the device has been provisioned.
+ if (!isRestrictedUser()) {
+ Settings.Global.putInt(getContentResolver(), Settings.Global.DEVICE_PROVISIONED, 1);
+ }
+ Settings.Secure.putInt(getContentResolver(), Settings.Secure.USER_SETUP_COMPLETE, 1);
+ Settings.Secure.putInt(getContentResolver(), Settings.Secure.TV_USER_SETUP_COMPLETE, 1);
+
+ // remove this activity from the package manager.
+ PackageManager pm = getPackageManager();
+ ComponentName name = new ComponentName(this, DefaultActivity.class);
+ pm.setComponentEnabledSetting(name, PackageManager.COMPONENT_ENABLED_STATE_DISABLED,
+ PackageManager.DONT_KILL_APP);
+
+ // terminate the activity.
+ finish();
+ }
+
+ private boolean isRestrictedUser() {
+ UserManager userManager = (UserManager) getSystemService(Context.USER_SERVICE);
+ UserInfo userInfo = userManager.getUserInfo(UserHandle.myUserId());
+ return userInfo.isRestricted();
+ }
+}
+