summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAaron Kling <webgeek1234@gmail.com>2018-06-18 13:49:01 -0500
committerAaron Kling <webgeek1234@gmail.com>2018-07-20 21:11:15 -0500
commit8907bcdbc9227d6bbb676521d4fb3192609ae231 (patch)
tree5654df29d0ccab66c45702ef51decfc7ede7263b
parentbd7bd0465dece4332c0860a8021ba83056ef0fa2 (diff)
downloadandroid_packages_apps_LineageCustomizer-lineage-15.1.tar.gz
android_packages_apps_LineageCustomizer-lineage-15.1.tar.bz2
android_packages_apps_LineageCustomizer-lineage-15.1.zip
Initial bringup to tvlauncher config stylelineage-15.1
Most configurations can be overridden per device by overlaying res/raw/configuration.xml Change-Id: Ibc2917ea2a63941ff94e99a670ef5628751c4a29
-rw-r--r--AndroidManifest.xml20
-rw-r--r--res/drawable-xhdpi/ic_title_custom.pngbin1151 -> 0 bytes
-rw-r--r--res/raw/configuration.xml77
-rw-r--r--res/values/colors.xml4
-rw-r--r--res/values/config.xml28
-rw-r--r--res/values/strings.xml8
-rw-r--r--src/org/lineageos/partnercustomizer/PartnerReceiver.java132
-rw-r--r--src/org/lineageos/partnercustomizer/TestActivity.java7
-rw-r--r--src/org/lineageos/tvcustomizer/ConfigurationProvider.java103
-rw-r--r--src/org/lineageos/tvcustomizer/StubReceiver.java12
10 files changed, 201 insertions, 190 deletions
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index d4bdecc..8745316 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -1,27 +1,25 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
- package="org.lineageos.partnercustomizer">
+ package="org.lineageos.tvcustomizer">
<uses-sdk
- android:minSdkVersion="21"
- android:targetSdkVersion="25" />
+ android:minSdkVersion="26"
+ android:targetSdkVersion="27" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-permission android:name="android.permission.INTERNET" />
+ <uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
<application android:label="@string/app_label">
+ <provider android:name=".ConfigurationProvider" android:enabled="true" android:exported="true" android:authorities="tvlauncher.config" />
- <receiver android:name=".PartnerReceiver">
+ <receiver android:name=".StubReceiver">
<intent-filter>
- <action android:name="com.google.android.leanbacklauncher.action.PARTNER_CUSTOMIZATION" />
+ <action android:name="com.google.android.tvsetup.action.PARTNER_CUSTOMIZATION" />
+ <action android:name="com.google.android.tvlauncher.action.PARTNER_CONFIGURATION" />
+ <action android:name="com.google.android.launcher3.action.PARTNER_CUSTOMIZATION" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
-
- <intent-filter>
- <action android:name="android.intent.action.PACKAGE_ADDED" />
- <action android:name="android.intent.action.PACKAGE_REMOVED" />
- <data android:scheme="package"/>
- </intent-filter>
</receiver>
</application>
diff --git a/res/drawable-xhdpi/ic_title_custom.png b/res/drawable-xhdpi/ic_title_custom.png
deleted file mode 100644
index 882579e..0000000
--- a/res/drawable-xhdpi/ic_title_custom.png
+++ /dev/null
Binary files differ
diff --git a/res/raw/configuration.xml b/res/raw/configuration.xml
new file mode 100644
index 0000000..6a1bcfc
--- /dev/null
+++ b/res/raw/configuration.xml
@@ -0,0 +1,77 @@
+<configuration>
+ <!-- Home Screen search icon -->
+
+ <!-- OEMs can define which apps will show up in the favorite apps row out of
+ box in the Home Screen by providing a list of apps (name and package
+ name). This list should be up to 8 apps and the system will use the first
+ 8 apps on this list of more than 8 are provided.
+ The list should comply with the GTVS app placement requirements
+ (see: requirements page)
+ -->
+ <partner-favorite-apps-out-of-box-order>
+ <app name="AppDrawer" package_name="org.lineageos.appdrawer"/>
+ <app name="Youtube" package_name="com.google.android.youtube.tv"/>
+ <app name="Google Movies" package_name="com.google.android.videos"/>
+ </partner-favorite-apps-out-of-box-order>
+
+ <!-- OEMs can customize the initial order of apps in the apps row of the Apps
+ View by providing a list of up to 20 apps (name and package name). All
+ other games will be sorted alphabetically.
+ The list should comply with the GTVS app placement requirements
+ (see: requirements page)
+ -->
+ <partner-all-apps-out-of-box-order>
+ <app name="Youtube" package_name="com.google.android.youtube.tv"/>
+ <app name="Google Movies" package_name="com.google.android.videos"/>
+ </partner-all-apps-out-of-box-order>
+
+ <!-- OEMs can customize the initial order of apps in the games row of the Apps
+ View by providing a list of up to 10 apps (name and package name). All
+ other games will be sorted alphabetically.
+ -->
+ <partner-games-out-of-box-order>
+ </partner-games-out-of-box-order>
+
+ <!-- By default channels are added to the UI in the order that they are added
+ by apps. A channel will be added to the bottom of the list of channel
+ when it is added by an app. OEMs can customize the initial order by
+ providing a list of package names. When one of the packages in the list
+ inserts a channel the system will insert it in the position indicated in
+ list. If while the channels are being inserted, the user changed to order
+ of the channels manually, the system will make the best effort to respect
+ the initial order while still preserving the user's channels order setup.
+ The initial order is limited to one channel per app, duplicates will be
+ ignored.
+ The list should comply with the GTVS app placement requirements
+ (see: requirements page)
+ -->
+ <partner-channels-out-of-box-order>
+ <package-name>com.google.android.youtube.tv</package-name>
+ <package-name>com.google.android.videos</package-name>
+ <package-name>com.google.android.music</package-name>
+ </partner-channels-out-of-box-order>
+
+ <!-- Android TV supports a limited set of system notifications. The system
+ filters all notifications and shows notifications only from a limited list
+ of whitelisted packages. The list is controlled by the system and already
+ includes Google's packages. OEMs can whitelist more packages by adding
+ them to the notification whitelist.
+ This list should only be used to whitelist system apps that want to show
+ important notifications that the user must handle (examples are: no
+ network, low battery on the remote, low storage etc…). It should NOT be
+ used by apps to promote content or features.
+ -->
+ <partner-package-notification-whitelist>
+ </partner-package-notification-whitelist>
+
+ <!-- By default, each app gets to show one channel in the UI without user's
+ approval. OEMs can change the number of channels allowed without user's
+ approval by providing a list of apps and and the number of pre-approved
+ channels (quota) for each app.
+ -->
+ <partner-app-channel-quota>
+ <app package_name="com.google.android.youtube.tv" quota="8"/>
+ <app package_name="com.google.android.videos" quota="8"/>
+ <app package_name="com.google.android.music" quota="8"/>
+ </partner-app-channel-quota>
+</configuration>
diff --git a/res/values/colors.xml b/res/values/colors.xml
deleted file mode 100644
index 810e40e..0000000
--- a/res/values/colors.xml
+++ /dev/null
@@ -1,4 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<resources>
- <color name="partner_color">#FFFF00FF</color>
-</resources>
diff --git a/res/values/config.xml b/res/values/config.xml
deleted file mode 100644
index 7179bf4..0000000
--- a/res/values/config.xml
+++ /dev/null
@@ -1,28 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<resources>
- <!-- DO NOT TRANSLATE -->
- <string name="partner_app_sorting_mode" translatable="false">fixed</string>
- <!-- DO NOT TRANSLATE -->
- <string name="partner_wallpaper" translatable="false">lineage_wallpaper</string>
- <!-- DO NOT TRANSLATE -->
- <string name="partner_widget_provider_component_name" translatable="false">
- com.cyanogenmod.lockclock/.ClockWidgetProvider
- </string>
-
- <!-- DO NOT TRANSLATE -->
- <string-array name="home_screen_row_ordering" translatable="false">
- <item>partner_row</item>
- <item>games_row</item>
- <item>apps_row</item>
- <item>inputs_row</item>
- <item>settings_row</item>
- </string-array>
-
- <item type="drawable" name="partner_row_icon">@drawable/ic_title_custom</item>
-
- <!-- DO NOT TRANSLATE -->
- <string name="partner_font" translatable="false">sans-serif-bold</string>
-
- <!-- DO NOT TRANSLATE -->
- <string name="launcher_category" translatable="false">android.intent.category.LEANBACK_LAUNCHER</string>
-</resources>
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 930f32f..32682e0 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -1,11 +1,3 @@
<resources>
-
<string name="app_label">LineageCustomizer</string>
-
- <string name="partner_row_title">Lineage Apps</string>
- <string name="apps_row_title">Apps</string>
- <string name="games_row_title">Games</string>
- <string name="inputs_row_title">Inputs</string>
- <string name="settings_row_title">Settings</string>
-
</resources>
diff --git a/src/org/lineageos/partnercustomizer/PartnerReceiver.java b/src/org/lineageos/partnercustomizer/PartnerReceiver.java
deleted file mode 100644
index 6328957..0000000
--- a/src/org/lineageos/partnercustomizer/PartnerReceiver.java
+++ /dev/null
@@ -1,132 +0,0 @@
-/*
- * Copyright (C) 2014 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 org.lineageos.partnercustomizer;
-
-import android.app.Notification;
-import android.app.NotificationManager;
-import android.app.PendingIntent;
-import android.content.BroadcastReceiver;
-import android.content.Context;
-import android.content.Intent;
-import android.content.pm.PackageManager;
-import android.graphics.BitmapFactory;
-import android.net.Uri;
-import android.os.Bundle;
-import android.os.Handler;
-
-/**
- * This class posts notifications that are used to populate the Partner Row of the Leanback Launcher
- * It also allows the system/launcher to find the correct partner customization
- * package.
- *
- * Packages using this broadcast receiver must also be a system app to be used for
- * partner customization.
- */
-public class PartnerReceiver extends BroadcastReceiver {
- private static final String ACTION_PARTNER_CUSTOMIZATION =
- "com.google.android.leanbacklauncher.action.PARTNER_CUSTOMIZATION";
-
- private static final String EXTRA_ROW_WRAPPING_CUTOFF =
- "com.google.android.leanbacklauncher.extra.ROW_WRAPPING_CUTOFF";
-
- private static final String PARTNER_GROUP = "partner_row_entry";
- private static final String BLACKLIST_PACKAGE = "com.google.android.leanbacklauncher.replacespackage";
-
- private Context mContext;
- private NotificationManager mNotifMan;
- private PackageManager mPkgMan;
-
- // Cutoff value for when the Launcher displays the Partner row as a single
- // row, or a two row grid. Can be used for correctly positioning the partner
- // app entries.
- private int mRowCutoff = 0;
-
- @Override
- public void onReceive(Context context, Intent intent) {
- if (mContext == null) {
- mContext = context;
- mNotifMan = (NotificationManager)
- mContext.getSystemService(Context.NOTIFICATION_SERVICE);
- mPkgMan = mContext.getPackageManager();
- }
-
- String action = intent.getAction();
- if (Intent.ACTION_PACKAGE_ADDED.equals(action)||
- Intent.ACTION_PACKAGE_REMOVED.equals(action)) {
- postNotification(getPackageName(intent));
- } else if (ACTION_PARTNER_CUSTOMIZATION.equals(action)) {
- mRowCutoff = intent.getIntExtra(EXTRA_ROW_WRAPPING_CUTOFF, 0);
- }
- }
-
- private void postNotification(String pkgName) {
- int sort;
- int resId;
- int backupResId;
- int titleId;
- int backupTitleId;
-
- switch (pkgName) {
- default:
- return;
- }
-
- postNotification(sort, resId, backupResId, titleId, backupTitleId, pkgName);
- }
-
- private void postNotification(int sort, int resId, int backupResId,
- int titleId, int backupTitleId, String pkgName) {
- int id = resId;
- Intent intent = mPkgMan.getLeanbackLaunchIntentForPackage(pkgName);
-
- if (intent == null) {
- titleId = backupTitleId;
- resId = backupResId;
- intent = getBackupIntent(pkgName);
- }
-
- Notification.Builder bob = new Notification.Builder(mContext);
- Bundle extras = new Bundle();
- extras.putString(BLACKLIST_PACKAGE, pkgName);
-
- bob.setContentTitle(mContext.getString(titleId))
- .setSmallIcon(R.drawable.ic_launcher)
- .setLargeIcon(BitmapFactory.decodeResource(mContext.getResources(), resId))
- .setContentIntent(PendingIntent.getActivity(mContext, 0, intent, 0))
- .setCategory(Notification.CATEGORY_RECOMMENDATION)
- .setGroup(PARTNER_GROUP)
- .setSortKey(sort+"")
- .setColor(mContext.getResources().getColor(R.color.partner_color))
- .setExtras(extras);
-
- mNotifMan.notify(id, bob.build());
- }
-
- private Intent getBackupIntent(String pkgName) {
- Intent intent = new Intent(Intent.ACTION_VIEW);
- intent.setData(Uri.parse("market://details?id=" + pkgName));
-
- return intent;
- }
-
- private String getPackageName(Intent intent) {
- Uri uri = intent.getData();
- String pkg = uri != null ? uri.getSchemeSpecificPart() : null;
- return pkg;
- }
-
-}
diff --git a/src/org/lineageos/partnercustomizer/TestActivity.java b/src/org/lineageos/partnercustomizer/TestActivity.java
deleted file mode 100644
index 52fa721..0000000
--- a/src/org/lineageos/partnercustomizer/TestActivity.java
+++ /dev/null
@@ -1,7 +0,0 @@
-package org.lineageos.partnercustomizer;
-
-import android.app.Activity;
-
-public class TestActivity extends Activity {
-
-}
diff --git a/src/org/lineageos/tvcustomizer/ConfigurationProvider.java b/src/org/lineageos/tvcustomizer/ConfigurationProvider.java
new file mode 100644
index 0000000..4753107
--- /dev/null
+++ b/src/org/lineageos/tvcustomizer/ConfigurationProvider.java
@@ -0,0 +1,103 @@
+package org.lineageos.tvcustomizer;
+
+import android.content.ContentProvider;
+import android.content.ContentProvider.PipeDataWriter;
+import android.content.ContentValues;
+import android.content.UriMatcher;
+import android.database.Cursor;
+import android.net.Uri;
+import android.os.Bundle;
+import android.os.ParcelFileDescriptor;
+import android.util.Log;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+
+public class ConfigurationProvider extends ContentProvider {
+ private static final UriMatcher sUriMatcher = new UriMatcher(UriMatcher.NO_MATCH);
+ private static final String TAG = "ConfigurationProvider";
+ private static final int TVLAUNCHER_CONFIG = 1;
+
+ static {
+ sUriMatcher.addURI("tvlauncher.config", "configuration", TVLAUNCHER_CONFIG);
+ }
+
+ public ParcelFileDescriptor openFile(Uri uri, String mode) throws FileNotFoundException {
+ InputStream stream;
+ Log.d(TAG, "openFile called: " + uri + " by: " + getCallingPackage());
+ if (sUriMatcher.match(uri) == TVLAUNCHER_CONFIG) {
+ stream = getContext().getResources().openRawResource(R.raw.configuration);
+ } else {
+ Log.d(TAG, "Invalid URI");
+ throw new UnsupportedOperationException("Unknown uri: " + uri);
+ }
+ return openPipeHelper(uri, "text/xml", null, null, new PipeDataWriter() {
+ public void writeDataToPipe(ParcelFileDescriptor output, Uri uri, String mimeType, Bundle opts, Object args) {
+ FileOutputStream out = new FileOutputStream(output.getFileDescriptor());
+ try {
+ int count;
+ byte[] buffer = new byte[8192];
+ while (true) {
+ count = stream.read(buffer);
+ if (count == -1) {
+ break;
+ }
+ Log.d(TAG, "Written: " + count + " bytes");
+ out.write(buffer, 0, count);
+ }
+ Log.d(TAG, "Written: " + count + " bytes");
+ } catch (IOException e) {
+ Log.e(TAG, "Failed to send file " + uri, e);
+ throw e;
+ } finally {
+ try {
+ if (out != null) {
+ out.close();
+ }
+ } catch (IOException e) {
+ Log.e(TAG, "Failed to close file " + uri, e);
+ }
+ return;
+ }
+ }
+ });
+ }
+
+ @Override
+ public boolean onCreate() {
+ Log.d(TAG, "onCreate called: " + getCallingPackage());
+ return true;
+ }
+
+ @Override
+ public Cursor query(Uri uri, String[] projection, String selection, String[] selectionArgs, String sortOrder) {
+ Log.d(TAG, "query called: " + uri);
+ sUriMatcher.match(uri);
+ throw new IllegalArgumentException("Unknown URI: " + uri);
+ }
+
+ @Override
+ public Uri insert(Uri uri, ContentValues values) {
+ Log.d(TAG, "insert called: " + uri);
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public int delete(Uri uri, String selection, String[] selectionArgs) {
+ Log.d(TAG, "delete called: " + uri);
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public int update(Uri uri, ContentValues values, String selection, String[] selectionArgs) {
+ Log.d(TAG, "update called: " + uri);
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public String getType(Uri uri) {
+ Log.d(TAG, "getType called: " + uri);
+ throw new UnsupportedOperationException();
+ }
+}
diff --git a/src/org/lineageos/tvcustomizer/StubReceiver.java b/src/org/lineageos/tvcustomizer/StubReceiver.java
new file mode 100644
index 0000000..12ea2da
--- /dev/null
+++ b/src/org/lineageos/tvcustomizer/StubReceiver.java
@@ -0,0 +1,12 @@
+package org.lineageos.tvcustomizer;
+
+import android.content.BroadcastReceiver;
+import android.content.Context;
+import android.content.Intent;
+import android.util.Log;
+
+public class StubReceiver extends BroadcastReceiver {
+ public void onReceive(Context context, Intent intent) {
+ Log.d("StubReceiver", "LineageCustomize.StubReceiver called");
+ }
+}