Loading packages/CarrierDefaultApp/Android.bp +1 −0 Original line number Diff line number Diff line Loading @@ -10,6 +10,7 @@ package { android_app { name: "CarrierDefaultApp", srcs: ["src/**/*.java"], static_libs: ["SliceStore"], platform_apis: true, certificate: "platform", } packages/CarrierDefaultApp/AndroidManifest.xml +17 −0 Original line number Diff line number Diff line Loading @@ -71,5 +71,22 @@ <data android:host="*" /> </intent-filter> </activity-alias> <receiver android:name="com.android.carrierdefaultapp.SliceStoreBroadcastReceiver" android:exported="true"> <intent-filter> <action android:name="com.android.phone.slicestore.action.START_SLICE_STORE" /> <action android:name="com.android.phone.slicestore.action.SLICE_STORE_RESPONSE_TIMEOUT" /> <action android:name="com.android.phone.slicestore.action.NOTIFICATION_CANCELED" /> </intent-filter> </receiver> <activity android:name="com.android.carrierdefaultapp.SliceStoreActivity" android:label="@string/slice_store_label" android:exported="true" android:configChanges="keyboardHidden|orientation|screenSize"> <intent-filter> <category android:name="android.intent.category.DEFAULT"/> </intent-filter> </activity> </application> </manifest> packages/CarrierDefaultApp/res/drawable/ic_network_boost.xml 0 → 100644 +23 −0 Original line number Diff line number Diff line <!-- ~ Copyright (C) 2022 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. --> <vector xmlns:android="http://schemas.android.com/apk/res/android" android:width="24dp" android:height="24dp" android:viewportWidth="24" android:viewportHeight="24"> <path android:fillColor="@android:color/white" android:pathData="M3,17V15H8Q8,15 8,15Q8,15 8,15V13Q8,13 8,13Q8,13 8,13H3V7H10V9H5V11H8Q8.825,11 9.413,11.587Q10,12.175 10,13V15Q10,15.825 9.413,16.413Q8.825,17 8,17ZM21,11V15Q21,15.825 20.413,16.413Q19.825,17 19,17H14Q13.175,17 12.588,16.413Q12,15.825 12,15V9Q12,8.175 12.588,7.587Q13.175,7 14,7H19Q19.825,7 20.413,7.587Q21,8.175 21,9H14Q14,9 14,9Q14,9 14,9V15Q14,15 14,15Q14,15 14,15H19Q19,15 19,15Q19,15 19,15V13H16.5V11Z"/> </vector> No newline at end of file packages/CarrierDefaultApp/res/values/strings.xml +14 −0 Original line number Diff line number Diff line Loading @@ -13,4 +13,18 @@ <string name="ssl_error_warning">The network you’re trying to join has security issues.</string> <string name="ssl_error_example">For example, the login page may not belong to the organization shown.</string> <string name="ssl_error_continue">Continue anyway via browser</string> <!-- Telephony notification channel name for network boost notifications. --> <string name="network_boost_notification_channel">Network Boost</string> <!-- Notification title text for the network boost notification. --> <string name="network_boost_notification_title">%s recommends a data boost</string> <!-- Notification detail text for the network boost notification. --> <string name="network_boost_notification_detail">Buy a network boost for better performance</string> <!-- Notification button text to cancel the network boost notification. --> <string name="network_boost_notification_button_not_now">Not now</string> <!-- Notification button text to manage the network boost notification. --> <string name="network_boost_notification_button_manage">Manage</string> <!-- Label to display when the slice store opens. --> <string name="slice_store_label">Purchase a network boost.</string> </resources> packages/CarrierDefaultApp/src/com/android/carrierdefaultapp/SliceStoreActivity.java 0 → 100644 +122 −0 Original line number Diff line number Diff line /* * Copyright (C) 2022 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.carrierdefaultapp; import android.annotation.NonNull; import android.annotation.Nullable; import android.app.Activity; import android.app.NotificationManager; import android.content.Intent; import android.os.Bundle; import android.telephony.CarrierConfigManager; import android.telephony.SubscriptionManager; import android.telephony.TelephonyManager; import android.util.Log; import android.webkit.WebView; import com.android.phone.slicestore.SliceStore; import java.net.MalformedURLException; import java.net.URL; /** * Activity that launches when the user clicks on the network boost notification. */ public class SliceStoreActivity extends Activity { private static final String TAG = "SliceStoreActivity"; private URL mUrl; private WebView mWebView; private int mPhoneId; private int mSubId; private @TelephonyManager.PremiumCapability int mCapability; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Intent intent = getIntent(); mPhoneId = intent.getIntExtra(SliceStore.EXTRA_PHONE_ID, SubscriptionManager.INVALID_PHONE_INDEX); mSubId = intent.getIntExtra(SliceStore.EXTRA_SUB_ID, SubscriptionManager.INVALID_SUBSCRIPTION_ID); mCapability = intent.getIntExtra(SliceStore.EXTRA_PREMIUM_CAPABILITY, SliceStore.PREMIUM_CAPABILITY_INVALID); mUrl = getUrl(); logd("onCreate: mPhoneId=" + mPhoneId + ", mSubId=" + mSubId + ", mCapability=" + TelephonyManager.convertPremiumCapabilityToString(mCapability) + ", mUrl=" + mUrl); getApplicationContext().getSystemService(NotificationManager.class) .cancel(SliceStoreBroadcastReceiver.NETWORK_BOOST_NOTIFICATION_TAG, mCapability); if (!SliceStoreBroadcastReceiver.isIntentValid(intent)) { loge("Not starting SliceStoreActivity with an invalid Intent: " + intent); SliceStoreBroadcastReceiver.sendSliceStoreResponse( intent, SliceStore.EXTRA_INTENT_REQUEST_FAILED); finishAndRemoveTask(); return; } if (mUrl == null) { loge("Unable to create a URL from carrier configs."); SliceStoreBroadcastReceiver.sendSliceStoreResponse( intent, SliceStore.EXTRA_INTENT_CARRIER_ERROR); finishAndRemoveTask(); return; } if (mSubId != SubscriptionManager.getDefaultSubscriptionId()) { loge("Unable to start SliceStore on the non-default data subscription: " + mSubId); SliceStoreBroadcastReceiver.sendSliceStoreResponse( intent, SliceStore.EXTRA_INTENT_NOT_DEFAULT_DATA); finishAndRemoveTask(); return; } SliceStoreBroadcastReceiver.updateSliceStoreActivity(mCapability, this); mWebView = new WebView(getApplicationContext()); setContentView(mWebView); mWebView.loadUrl(mUrl.toString()); // TODO(b/245882601): Get back response from WebView } @Override protected void onDestroy() { logd("onDestroy: User canceled the purchase by closing the application."); SliceStoreBroadcastReceiver.sendSliceStoreResponse( getIntent(), SliceStore.EXTRA_INTENT_CANCELED); SliceStoreBroadcastReceiver.removeSliceStoreActivity(mCapability); super.onDestroy(); } private @Nullable URL getUrl() { String url = getApplicationContext().getSystemService(CarrierConfigManager.class) .getConfigForSubId(mSubId).getString( CarrierConfigManager.KEY_PREMIUM_CAPABILITY_PURCHASE_URL_STRING); try { return new URL(url); } catch (MalformedURLException e) { loge("Invalid URL: " + url); } return null; } private static void logd(@NonNull String s) { Log.d(TAG, s); } private static void loge(@NonNull String s) { Log.e(TAG, s); } } Loading
packages/CarrierDefaultApp/Android.bp +1 −0 Original line number Diff line number Diff line Loading @@ -10,6 +10,7 @@ package { android_app { name: "CarrierDefaultApp", srcs: ["src/**/*.java"], static_libs: ["SliceStore"], platform_apis: true, certificate: "platform", }
packages/CarrierDefaultApp/AndroidManifest.xml +17 −0 Original line number Diff line number Diff line Loading @@ -71,5 +71,22 @@ <data android:host="*" /> </intent-filter> </activity-alias> <receiver android:name="com.android.carrierdefaultapp.SliceStoreBroadcastReceiver" android:exported="true"> <intent-filter> <action android:name="com.android.phone.slicestore.action.START_SLICE_STORE" /> <action android:name="com.android.phone.slicestore.action.SLICE_STORE_RESPONSE_TIMEOUT" /> <action android:name="com.android.phone.slicestore.action.NOTIFICATION_CANCELED" /> </intent-filter> </receiver> <activity android:name="com.android.carrierdefaultapp.SliceStoreActivity" android:label="@string/slice_store_label" android:exported="true" android:configChanges="keyboardHidden|orientation|screenSize"> <intent-filter> <category android:name="android.intent.category.DEFAULT"/> </intent-filter> </activity> </application> </manifest>
packages/CarrierDefaultApp/res/drawable/ic_network_boost.xml 0 → 100644 +23 −0 Original line number Diff line number Diff line <!-- ~ Copyright (C) 2022 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. --> <vector xmlns:android="http://schemas.android.com/apk/res/android" android:width="24dp" android:height="24dp" android:viewportWidth="24" android:viewportHeight="24"> <path android:fillColor="@android:color/white" android:pathData="M3,17V15H8Q8,15 8,15Q8,15 8,15V13Q8,13 8,13Q8,13 8,13H3V7H10V9H5V11H8Q8.825,11 9.413,11.587Q10,12.175 10,13V15Q10,15.825 9.413,16.413Q8.825,17 8,17ZM21,11V15Q21,15.825 20.413,16.413Q19.825,17 19,17H14Q13.175,17 12.588,16.413Q12,15.825 12,15V9Q12,8.175 12.588,7.587Q13.175,7 14,7H19Q19.825,7 20.413,7.587Q21,8.175 21,9H14Q14,9 14,9Q14,9 14,9V15Q14,15 14,15Q14,15 14,15H19Q19,15 19,15Q19,15 19,15V13H16.5V11Z"/> </vector> No newline at end of file
packages/CarrierDefaultApp/res/values/strings.xml +14 −0 Original line number Diff line number Diff line Loading @@ -13,4 +13,18 @@ <string name="ssl_error_warning">The network you’re trying to join has security issues.</string> <string name="ssl_error_example">For example, the login page may not belong to the organization shown.</string> <string name="ssl_error_continue">Continue anyway via browser</string> <!-- Telephony notification channel name for network boost notifications. --> <string name="network_boost_notification_channel">Network Boost</string> <!-- Notification title text for the network boost notification. --> <string name="network_boost_notification_title">%s recommends a data boost</string> <!-- Notification detail text for the network boost notification. --> <string name="network_boost_notification_detail">Buy a network boost for better performance</string> <!-- Notification button text to cancel the network boost notification. --> <string name="network_boost_notification_button_not_now">Not now</string> <!-- Notification button text to manage the network boost notification. --> <string name="network_boost_notification_button_manage">Manage</string> <!-- Label to display when the slice store opens. --> <string name="slice_store_label">Purchase a network boost.</string> </resources>
packages/CarrierDefaultApp/src/com/android/carrierdefaultapp/SliceStoreActivity.java 0 → 100644 +122 −0 Original line number Diff line number Diff line /* * Copyright (C) 2022 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.carrierdefaultapp; import android.annotation.NonNull; import android.annotation.Nullable; import android.app.Activity; import android.app.NotificationManager; import android.content.Intent; import android.os.Bundle; import android.telephony.CarrierConfigManager; import android.telephony.SubscriptionManager; import android.telephony.TelephonyManager; import android.util.Log; import android.webkit.WebView; import com.android.phone.slicestore.SliceStore; import java.net.MalformedURLException; import java.net.URL; /** * Activity that launches when the user clicks on the network boost notification. */ public class SliceStoreActivity extends Activity { private static final String TAG = "SliceStoreActivity"; private URL mUrl; private WebView mWebView; private int mPhoneId; private int mSubId; private @TelephonyManager.PremiumCapability int mCapability; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Intent intent = getIntent(); mPhoneId = intent.getIntExtra(SliceStore.EXTRA_PHONE_ID, SubscriptionManager.INVALID_PHONE_INDEX); mSubId = intent.getIntExtra(SliceStore.EXTRA_SUB_ID, SubscriptionManager.INVALID_SUBSCRIPTION_ID); mCapability = intent.getIntExtra(SliceStore.EXTRA_PREMIUM_CAPABILITY, SliceStore.PREMIUM_CAPABILITY_INVALID); mUrl = getUrl(); logd("onCreate: mPhoneId=" + mPhoneId + ", mSubId=" + mSubId + ", mCapability=" + TelephonyManager.convertPremiumCapabilityToString(mCapability) + ", mUrl=" + mUrl); getApplicationContext().getSystemService(NotificationManager.class) .cancel(SliceStoreBroadcastReceiver.NETWORK_BOOST_NOTIFICATION_TAG, mCapability); if (!SliceStoreBroadcastReceiver.isIntentValid(intent)) { loge("Not starting SliceStoreActivity with an invalid Intent: " + intent); SliceStoreBroadcastReceiver.sendSliceStoreResponse( intent, SliceStore.EXTRA_INTENT_REQUEST_FAILED); finishAndRemoveTask(); return; } if (mUrl == null) { loge("Unable to create a URL from carrier configs."); SliceStoreBroadcastReceiver.sendSliceStoreResponse( intent, SliceStore.EXTRA_INTENT_CARRIER_ERROR); finishAndRemoveTask(); return; } if (mSubId != SubscriptionManager.getDefaultSubscriptionId()) { loge("Unable to start SliceStore on the non-default data subscription: " + mSubId); SliceStoreBroadcastReceiver.sendSliceStoreResponse( intent, SliceStore.EXTRA_INTENT_NOT_DEFAULT_DATA); finishAndRemoveTask(); return; } SliceStoreBroadcastReceiver.updateSliceStoreActivity(mCapability, this); mWebView = new WebView(getApplicationContext()); setContentView(mWebView); mWebView.loadUrl(mUrl.toString()); // TODO(b/245882601): Get back response from WebView } @Override protected void onDestroy() { logd("onDestroy: User canceled the purchase by closing the application."); SliceStoreBroadcastReceiver.sendSliceStoreResponse( getIntent(), SliceStore.EXTRA_INTENT_CANCELED); SliceStoreBroadcastReceiver.removeSliceStoreActivity(mCapability); super.onDestroy(); } private @Nullable URL getUrl() { String url = getApplicationContext().getSystemService(CarrierConfigManager.class) .getConfigForSubId(mSubId).getString( CarrierConfigManager.KEY_PREMIUM_CAPABILITY_PURCHASE_URL_STRING); try { return new URL(url); } catch (MalformedURLException e) { loge("Invalid URL: " + url); } return null; } private static void logd(@NonNull String s) { Log.d(TAG, s); } private static void loge(@NonNull String s) { Log.e(TAG, s); } }