Merge "Start deep link page synchronously in SettingsActivity" into sc-v2-dev
This commit is contained in:
@@ -144,12 +144,30 @@
|
|||||||
android:value="true" />
|
android:value="true" />
|
||||||
</activity>
|
</activity>
|
||||||
|
|
||||||
|
<!-- Activity for launching deep link page in 2-pane. -->
|
||||||
|
<activity android:name=".homepage.DeepLinkHomepageActivity"
|
||||||
|
android:label="@string/settings_label_launcher"
|
||||||
|
android:theme="@style/Theme.Settings.Home"
|
||||||
|
android:taskAffinity=""
|
||||||
|
android:launchMode="singleTask"
|
||||||
|
android:exported="true"
|
||||||
|
android:configChanges="orientation|keyboard|keyboardHidden|screenSize|screenLayout"
|
||||||
|
android:permission="android.permission.LAUNCH_MULTI_PANE_SETTINGS_DEEP_LINK">
|
||||||
|
<intent-filter>
|
||||||
|
<action android:name="android.settings.SETTINGS_EMBED_DEEP_LINK_ACTIVITY" />
|
||||||
|
<category android:name="android.intent.category.DEFAULT" />
|
||||||
|
</intent-filter>
|
||||||
|
<meta-data android:name="com.android.settings.PRIMARY_PROFILE_CONTROLLED"
|
||||||
|
android:value="true" />
|
||||||
|
</activity>
|
||||||
|
|
||||||
<activity android:name=".homepage.SliceDeepLinkHomepageActivity"
|
<activity android:name=".homepage.SliceDeepLinkHomepageActivity"
|
||||||
android:label="@string/settings_label_launcher"
|
android:label="@string/settings_label_launcher"
|
||||||
android:theme="@style/Theme.Settings.Home"
|
android:theme="@style/Theme.Settings.Home"
|
||||||
android:taskAffinity=""
|
android:taskAffinity=""
|
||||||
android:launchMode="singleTask"
|
android:launchMode="singleTask"
|
||||||
android:exported="false"
|
android:exported="false"
|
||||||
|
android:excludeFromRecents="true"
|
||||||
android:configChanges="orientation|keyboard|keyboardHidden|screenSize|screenLayout">
|
android:configChanges="orientation|keyboard|keyboardHidden|screenSize|screenLayout">
|
||||||
<meta-data android:name="com.android.settings.PRIMARY_PROFILE_CONTROLLED"
|
<meta-data android:name="com.android.settings.PRIMARY_PROFILE_CONTROLLED"
|
||||||
android:value="true" />
|
android:value="true" />
|
||||||
@@ -170,18 +188,6 @@
|
|||||||
<meta-data android:name="android.app.shortcuts" android:resource="@xml/shortcuts"/>
|
<meta-data android:name="android.app.shortcuts" android:resource="@xml/shortcuts"/>
|
||||||
</activity-alias>
|
</activity-alias>
|
||||||
|
|
||||||
<!-- Alias for SettingsHomepageActivity which works for deep link page in 2-panel. -->
|
|
||||||
<activity-alias android:name="DeepLinkHomepageActivity"
|
|
||||||
android:label="@string/settings_label_launcher"
|
|
||||||
android:exported="true"
|
|
||||||
android:permission="android.permission.LAUNCH_MULTI_PANE_SETTINGS_DEEP_LINK"
|
|
||||||
android:targetActivity=".homepage.SettingsHomepageActivity">
|
|
||||||
<intent-filter>
|
|
||||||
<action android:name="android.settings.SETTINGS_EMBED_DEEP_LINK_ACTIVITY" />
|
|
||||||
<category android:name="android.intent.category.DEFAULT" />
|
|
||||||
</intent-filter>
|
|
||||||
</activity-alias>
|
|
||||||
|
|
||||||
<receiver android:name=".SettingsInitialize"
|
<receiver android:name=".SettingsInitialize"
|
||||||
android:exported="true">
|
android:exported="true">
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
@@ -4032,11 +4038,6 @@
|
|||||||
</intent-filter>
|
</intent-filter>
|
||||||
</provider>
|
</provider>
|
||||||
|
|
||||||
<provider
|
|
||||||
android:name=".activityembedding.ActivityEmbeddingProvider"
|
|
||||||
android:authorities="com.android.settings.activityembedding"
|
|
||||||
android:exported="true"/>
|
|
||||||
|
|
||||||
<activity
|
<activity
|
||||||
android:name=".wifi.dpp.WifiDppConfiguratorActivity"
|
android:name=".wifi.dpp.WifiDppConfiguratorActivity"
|
||||||
android:exported="true">
|
android:exported="true">
|
||||||
|
@@ -58,7 +58,6 @@ import androidx.preference.PreferenceManager;
|
|||||||
import com.android.internal.util.ArrayUtils;
|
import com.android.internal.util.ArrayUtils;
|
||||||
import com.android.settings.Settings.WifiSettingsActivity;
|
import com.android.settings.Settings.WifiSettingsActivity;
|
||||||
import com.android.settings.activityembedding.ActivityEmbeddingUtils;
|
import com.android.settings.activityembedding.ActivityEmbeddingUtils;
|
||||||
import com.android.settings.activityembedding.SplitStateObserver;
|
|
||||||
import com.android.settings.applications.manageapplications.ManageApplications;
|
import com.android.settings.applications.manageapplications.ManageApplications;
|
||||||
import com.android.settings.core.OnActivityResultListener;
|
import com.android.settings.core.OnActivityResultListener;
|
||||||
import com.android.settings.core.SettingsBaseActivity;
|
import com.android.settings.core.SettingsBaseActivity;
|
||||||
@@ -248,16 +247,21 @@ public class SettingsActivity extends SettingsBaseActivity
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedState) {
|
protected void onCreate(Bundle savedState) {
|
||||||
super.onCreate(savedState);
|
|
||||||
Log.d(LOG_TAG, "Starting onCreate");
|
|
||||||
|
|
||||||
long startTime = System.currentTimeMillis();
|
|
||||||
|
|
||||||
// Should happen before any call to getIntent()
|
// Should happen before any call to getIntent()
|
||||||
getMetaData();
|
getMetaData();
|
||||||
final Intent intent = getIntent();
|
final Intent intent = getIntent();
|
||||||
|
|
||||||
registerSplitStateObserverForTwoPaneDeepLink();
|
if (shouldShowTwoPaneDeepLink(intent)) {
|
||||||
|
launchHomepageForTwoPaneDeepLink(intent);
|
||||||
|
finishAndRemoveTask();
|
||||||
|
super.onCreate(savedState);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
super.onCreate(savedState);
|
||||||
|
Log.d(LOG_TAG, "Starting onCreate");
|
||||||
|
|
||||||
|
long startTime = System.currentTimeMillis();
|
||||||
|
|
||||||
final FeatureFactory factory = FeatureFactory.getFactory(this);
|
final FeatureFactory factory = FeatureFactory.getFactory(this);
|
||||||
mDashboardFeatureProvider = factory.getDashboardFeatureProvider(this);
|
mDashboardFeatureProvider = factory.getDashboardFeatureProvider(this);
|
||||||
@@ -362,30 +366,6 @@ public class SettingsActivity extends SettingsBaseActivity
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void registerSplitStateObserverForTwoPaneDeepLink() {
|
|
||||||
if (!ActivityEmbeddingUtils.isEmbeddingActivityEnabled(this)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
final SplitStateObserver splitStateObserver = new SplitStateObserver(this /* activity*/,
|
|
||||||
true /* listenOnce */,
|
|
||||||
splitInfos -> {
|
|
||||||
if (!splitInfos.isEmpty() || !SettingsActivity.this.isTaskRoot()) {
|
|
||||||
// It's already in 2-pane or in a non-empty task, there is no need to go
|
|
||||||
// 2-pane deep link flow.
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (shouldShowTwoPaneDeepLink(getIntent())) {
|
|
||||||
launchHomepageForTwoPaneDeepLink(getIntent());
|
|
||||||
finishAndRemoveTask();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
);
|
|
||||||
getLifecycle().addObserver(splitStateObserver);
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean isSubSettings(Intent intent) {
|
private boolean isSubSettings(Intent intent) {
|
||||||
return this instanceof SubSettings ||
|
return this instanceof SubSettings ||
|
||||||
intent.getBooleanExtra(EXTRA_SHOW_FRAGMENT_AS_SUBSETTING, false);
|
intent.getBooleanExtra(EXTRA_SHOW_FRAGMENT_AS_SUBSETTING, false);
|
||||||
@@ -435,6 +415,15 @@ public class SettingsActivity extends SettingsBaseActivity
|
|||||||
}
|
}
|
||||||
|
|
||||||
private boolean shouldShowTwoPaneDeepLink(Intent intent) {
|
private boolean shouldShowTwoPaneDeepLink(Intent intent) {
|
||||||
|
if (!ActivityEmbeddingUtils.isEmbeddingActivityEnabled(this)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// If the activity is not the task root, it should not start trampoline for deep links.
|
||||||
|
if (!isTaskRoot()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
// Only starts trampoline for deep links. Should return false for all the cases that
|
// Only starts trampoline for deep links. Should return false for all the cases that
|
||||||
// Settings app starts SettingsActivity or SubSetting by itself.
|
// Settings app starts SettingsActivity or SubSetting by itself.
|
||||||
if (intent.getAction() == null) {
|
if (intent.getAction() == null) {
|
||||||
|
@@ -40,7 +40,7 @@ import androidx.annotation.VisibleForTesting;
|
|||||||
import androidx.window.embedding.SplitController;
|
import androidx.window.embedding.SplitController;
|
||||||
|
|
||||||
import com.android.settings.Settings.CreateShortcutActivity;
|
import com.android.settings.Settings.CreateShortcutActivity;
|
||||||
import com.android.settings.homepage.SettingsHomepageActivity;
|
import com.android.settings.homepage.DeepLinkHomepageActivity;
|
||||||
import com.android.settings.search.SearchStateReceiver;
|
import com.android.settings.search.SearchStateReceiver;
|
||||||
import com.android.settingslib.utils.ThreadUtils;
|
import com.android.settingslib.utils.ThreadUtils;
|
||||||
|
|
||||||
@@ -150,8 +150,8 @@ public class SettingsInitialize extends BroadcastReceiver {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void enableTwoPaneDeepLinkActivityIfNecessary(PackageManager pm, Context context) {
|
private void enableTwoPaneDeepLinkActivityIfNecessary(PackageManager pm, Context context) {
|
||||||
final ComponentName deepLinkHome = new ComponentName(Utils.SETTINGS_PACKAGE_NAME,
|
final ComponentName deepLinkHome = new ComponentName(context,
|
||||||
SettingsHomepageActivity.ALIAS_DEEP_LINK);
|
DeepLinkHomepageActivity.class);
|
||||||
final ComponentName searchStateReceiver = new ComponentName(context,
|
final ComponentName searchStateReceiver = new ComponentName(context,
|
||||||
SearchStateReceiver.class);
|
SearchStateReceiver.class);
|
||||||
final int enableState = SplitController.getInstance().isSplitSupported()
|
final int enableState = SplitController.getInstance().isSplitSupported()
|
||||||
|
@@ -1,88 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (C) 2021 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.settings.activityembedding;
|
|
||||||
|
|
||||||
import android.app.Activity;
|
|
||||||
import android.content.ContentProvider;
|
|
||||||
import android.content.ContentValues;
|
|
||||||
import android.database.Cursor;
|
|
||||||
import android.net.Uri;
|
|
||||||
import android.os.Bundle;
|
|
||||||
import android.text.TextUtils;
|
|
||||||
|
|
||||||
import com.android.settings.SettingsApplication;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* A content provider for querying the state of activity embedding feature
|
|
||||||
*/
|
|
||||||
public class ActivityEmbeddingProvider extends ContentProvider {
|
|
||||||
|
|
||||||
private static final String METHOD_IS_EMBEDDING_ACTIVITY_ENABLED = "isEmbeddingActivityEnabled";
|
|
||||||
private static final String METHOD_IS_IN_SETTINGS_TWO_PANE = "isInSettingsTwoPane";
|
|
||||||
private static final String EXTRA_ENABLED_STATE = "enabled_state";
|
|
||||||
private static final String EXTRA_TWO_PANE_STATE = "two_pane_state";
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean onCreate() {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Bundle call(String method, String arg, Bundle extras) {
|
|
||||||
if (TextUtils.equals(method, METHOD_IS_EMBEDDING_ACTIVITY_ENABLED)) {
|
|
||||||
final Bundle bundle = new Bundle();
|
|
||||||
bundle.putBoolean(EXTRA_ENABLED_STATE,
|
|
||||||
ActivityEmbeddingUtils.isEmbeddingActivityEnabled(getContext()));
|
|
||||||
return bundle;
|
|
||||||
} else if (TextUtils.equals(method, METHOD_IS_IN_SETTINGS_TWO_PANE)) {
|
|
||||||
final Activity homeActivity =
|
|
||||||
((SettingsApplication) getContext().getApplicationContext()).getHomeActivity();
|
|
||||||
final Bundle bundle = new Bundle();
|
|
||||||
bundle.putBoolean(EXTRA_TWO_PANE_STATE,
|
|
||||||
homeActivity == null ? false
|
|
||||||
: ActivityEmbeddingUtils.isTwoPaneResolution(homeActivity));
|
|
||||||
return bundle;
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Cursor query(Uri uri, String[] projection, String selection, String[] selectionArgs,
|
|
||||||
String sortOrder) {
|
|
||||||
throw new UnsupportedOperationException();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getType(Uri uri) {
|
|
||||||
throw new UnsupportedOperationException();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Uri insert(Uri uri, ContentValues values) {
|
|
||||||
throw new UnsupportedOperationException();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int delete(Uri uri, String selection, String[] selectionArgs) {
|
|
||||||
throw new UnsupportedOperationException();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int update(Uri uri, ContentValues values, String selection, String[] selectionArgs) {
|
|
||||||
throw new UnsupportedOperationException();
|
|
||||||
}
|
|
||||||
}
|
|
@@ -33,7 +33,7 @@ import androidx.window.embedding.SplitRule;
|
|||||||
|
|
||||||
import com.android.settings.Settings;
|
import com.android.settings.Settings;
|
||||||
import com.android.settings.SubSettings;
|
import com.android.settings.SubSettings;
|
||||||
import com.android.settings.Utils;
|
import com.android.settings.homepage.DeepLinkHomepageActivity;
|
||||||
import com.android.settings.homepage.SettingsHomepageActivity;
|
import com.android.settings.homepage.SettingsHomepageActivity;
|
||||||
import com.android.settings.homepage.SliceDeepLinkHomepageActivity;
|
import com.android.settings.homepage.SliceDeepLinkHomepageActivity;
|
||||||
|
|
||||||
@@ -101,7 +101,6 @@ public class ActivityEmbeddingRulesController {
|
|||||||
ComponentName secondaryComponent,
|
ComponentName secondaryComponent,
|
||||||
String secondaryIntentAction,
|
String secondaryIntentAction,
|
||||||
boolean clearTop) {
|
boolean clearTop) {
|
||||||
|
|
||||||
registerTwoPanePairRule(
|
registerTwoPanePairRule(
|
||||||
context,
|
context,
|
||||||
getComponentName(context, Settings.class),
|
getComponentName(context, Settings.class),
|
||||||
@@ -113,8 +112,7 @@ public class ActivityEmbeddingRulesController {
|
|||||||
|
|
||||||
registerTwoPanePairRule(
|
registerTwoPanePairRule(
|
||||||
context,
|
context,
|
||||||
new ComponentName(Utils.SETTINGS_PACKAGE_NAME,
|
new ComponentName(context, DeepLinkHomepageActivity.class),
|
||||||
SettingsHomepageActivity.ALIAS_DEEP_LINK),
|
|
||||||
secondaryComponent,
|
secondaryComponent,
|
||||||
secondaryIntentAction,
|
secondaryIntentAction,
|
||||||
true /* finishPrimaryWithSecondary */,
|
true /* finishPrimaryWithSecondary */,
|
||||||
@@ -156,9 +154,9 @@ public class ActivityEmbeddingRulesController {
|
|||||||
private void registerHomepagePlaceholderRule() {
|
private void registerHomepagePlaceholderRule() {
|
||||||
final Set<ActivityFilter> activityFilters = new HashSet<>();
|
final Set<ActivityFilter> activityFilters = new HashSet<>();
|
||||||
addActivityFilter(activityFilters, SettingsHomepageActivity.class);
|
addActivityFilter(activityFilters, SettingsHomepageActivity.class);
|
||||||
|
addActivityFilter(activityFilters, DeepLinkHomepageActivity.class);
|
||||||
|
addActivityFilter(activityFilters, SliceDeepLinkHomepageActivity.class);
|
||||||
addActivityFilter(activityFilters, Settings.class);
|
addActivityFilter(activityFilters, Settings.class);
|
||||||
addActivityFilter(activityFilters, new ComponentName(Utils.SETTINGS_PACKAGE_NAME,
|
|
||||||
SettingsHomepageActivity.ALIAS_DEEP_LINK));
|
|
||||||
|
|
||||||
final Intent intent = new Intent();
|
final Intent intent = new Intent();
|
||||||
intent.setComponent(getComponentName(Settings.NetworkDashboardActivity.class));
|
intent.setComponent(getComponentName(Settings.NetworkDashboardActivity.class));
|
||||||
|
@@ -1,81 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (C) 2021 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.settings.activityembedding;
|
|
||||||
|
|
||||||
import static androidx.lifecycle.Lifecycle.Event.ON_START;
|
|
||||||
import static androidx.lifecycle.Lifecycle.Event.ON_STOP;
|
|
||||||
|
|
||||||
import android.app.Activity;
|
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
|
||||||
import androidx.core.content.ContextCompat;
|
|
||||||
import androidx.core.util.Consumer;
|
|
||||||
import androidx.lifecycle.LifecycleObserver;
|
|
||||||
import androidx.lifecycle.OnLifecycleEvent;
|
|
||||||
import androidx.window.embedding.SplitController;
|
|
||||||
import androidx.window.embedding.SplitInfo;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/** A lifecycle-aware observer listens to active split state. */
|
|
||||||
public class SplitStateObserver implements LifecycleObserver, Consumer<List<SplitInfo>> {
|
|
||||||
|
|
||||||
private final Activity mActivity;
|
|
||||||
private final boolean mListenOnce;
|
|
||||||
private final SplitStateListener mListener;
|
|
||||||
private final SplitController mSplitController;
|
|
||||||
|
|
||||||
public SplitStateObserver(@NonNull Activity activity, boolean listenOnce,
|
|
||||||
@NonNull SplitStateListener listener) {
|
|
||||||
mActivity = activity;
|
|
||||||
mListenOnce = listenOnce;
|
|
||||||
mListener = listener;
|
|
||||||
mSplitController = SplitController.getInstance();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Start lifecycle event.
|
|
||||||
*/
|
|
||||||
@OnLifecycleEvent(ON_START)
|
|
||||||
public void onStart() {
|
|
||||||
mSplitController.addSplitListener(mActivity, ContextCompat.getMainExecutor(mActivity),
|
|
||||||
this);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Stop lifecycle event.
|
|
||||||
*/
|
|
||||||
@OnLifecycleEvent(ON_STOP)
|
|
||||||
public void onStop() {
|
|
||||||
mSplitController.removeSplitListener(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void accept(List<SplitInfo> splitInfos) {
|
|
||||||
if (mListenOnce) {
|
|
||||||
mSplitController.removeSplitListener(this);
|
|
||||||
}
|
|
||||||
mListener.onSplitInfoChanged(splitInfos);
|
|
||||||
}
|
|
||||||
|
|
||||||
/** This interface makes as class that it wants to listen to {@link SplitInfo} changes. */
|
|
||||||
public interface SplitStateListener {
|
|
||||||
|
|
||||||
/** Receive a set of split info change */
|
|
||||||
void onSplitInfoChanged(List<SplitInfo> splitInfos);
|
|
||||||
}
|
|
||||||
}
|
|
@@ -74,6 +74,9 @@ public class SettingsBaseActivity extends FragmentActivity implements CategoryHa
|
|||||||
@Override
|
@Override
|
||||||
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
if (isFinishing()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (isLockTaskModePinned() && !isSettingsRunOnTop()) {
|
if (isLockTaskModePinned() && !isSettingsRunOnTop()) {
|
||||||
Log.w(TAG, "Devices lock task mode pinned.");
|
Log.w(TAG, "Devices lock task mode pinned.");
|
||||||
finish();
|
finish();
|
||||||
|
@@ -0,0 +1,21 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2021 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.settings.homepage;
|
||||||
|
|
||||||
|
/** Activity for other apps to launch Settings deep link page */
|
||||||
|
public class DeepLinkHomepageActivity extends SettingsHomepageActivity {
|
||||||
|
}
|
@@ -44,7 +44,6 @@ import com.android.settings.R;
|
|||||||
import com.android.settings.Settings;
|
import com.android.settings.Settings;
|
||||||
import com.android.settings.SettingsActivity;
|
import com.android.settings.SettingsActivity;
|
||||||
import com.android.settings.SettingsApplication;
|
import com.android.settings.SettingsApplication;
|
||||||
import com.android.settings.Utils;
|
|
||||||
import com.android.settings.accounts.AvatarViewMixin;
|
import com.android.settings.accounts.AvatarViewMixin;
|
||||||
import com.android.settings.activityembedding.ActivityEmbeddingRulesController;
|
import com.android.settings.activityembedding.ActivityEmbeddingRulesController;
|
||||||
import com.android.settings.activityembedding.ActivityEmbeddingUtils;
|
import com.android.settings.activityembedding.ActivityEmbeddingUtils;
|
||||||
@@ -72,9 +71,6 @@ public class SettingsHomepageActivity extends FragmentActivity implements
|
|||||||
public static final String EXTRA_SETTINGS_LARGE_SCREEN_DEEP_LINK_INTENT_DATA =
|
public static final String EXTRA_SETTINGS_LARGE_SCREEN_DEEP_LINK_INTENT_DATA =
|
||||||
"settings_large_screen_deep_link_intent_data";
|
"settings_large_screen_deep_link_intent_data";
|
||||||
|
|
||||||
// An alias class name of SettingsHomepageActivity.
|
|
||||||
public static final String ALIAS_DEEP_LINK = "com.android.settings.DeepLinkHomepageActivity";
|
|
||||||
|
|
||||||
private static final int DEFAULT_HIGHLIGHT_MENU_KEY = R.string.menu_key_network;
|
private static final int DEFAULT_HIGHLIGHT_MENU_KEY = R.string.menu_key_network;
|
||||||
private static final long HOMEPAGE_LOADING_TIMEOUT_MS = 300;
|
private static final long HOMEPAGE_LOADING_TIMEOUT_MS = 300;
|
||||||
|
|
||||||
@@ -91,12 +87,12 @@ public class SettingsHomepageActivity extends FragmentActivity implements
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Try to register a {@link HomepageLoadedListener}. If homepage is already loaded, the
|
* Try to add a {@link HomepageLoadedListener}. If homepage is already loaded, the listener
|
||||||
* listener will not be notified.
|
* will not be notified.
|
||||||
*
|
*
|
||||||
* @return Whether the listener should be registered.
|
* @return Whether the listener is added.
|
||||||
*/
|
*/
|
||||||
public boolean registerHomepageLoadedListenerIfNeeded(HomepageLoadedListener listener) {
|
public boolean addHomepageLoadedListener(HomepageLoadedListener listener) {
|
||||||
if (mHomepageView == null) {
|
if (mHomepageView == null) {
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
@@ -245,6 +241,13 @@ public class SettingsHomepageActivity extends FragmentActivity implements
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!(this instanceof DeepLinkHomepageActivity
|
||||||
|
|| this instanceof SliceDeepLinkHomepageActivity)) {
|
||||||
|
Log.e(TAG, "Not a deep link component");
|
||||||
|
finish();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
final String intentUriString = intent.getStringExtra(
|
final String intentUriString = intent.getStringExtra(
|
||||||
EXTRA_SETTINGS_EMBEDDED_DEEP_LINK_INTENT_URI);
|
EXTRA_SETTINGS_EMBEDDED_DEEP_LINK_INTENT_URI);
|
||||||
if (TextUtils.isEmpty(intentUriString)) {
|
if (TextUtils.isEmpty(intentUriString)) {
|
||||||
@@ -287,7 +290,7 @@ public class SettingsHomepageActivity extends FragmentActivity implements
|
|||||||
|
|
||||||
// Set 2-pane pair rule for the deep link page.
|
// Set 2-pane pair rule for the deep link page.
|
||||||
ActivityEmbeddingRulesController.registerTwoPanePairRule(this,
|
ActivityEmbeddingRulesController.registerTwoPanePairRule(this,
|
||||||
getDeepLinkComponent(),
|
new ComponentName(getApplicationContext(), getClass()),
|
||||||
targetComponentName,
|
targetComponentName,
|
||||||
targetIntent.getAction(),
|
targetIntent.getAction(),
|
||||||
true /* finishPrimaryWithSecondary */,
|
true /* finishPrimaryWithSecondary */,
|
||||||
@@ -303,10 +306,6 @@ public class SettingsHomepageActivity extends FragmentActivity implements
|
|||||||
startActivity(targetIntent);
|
startActivity(targetIntent);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected ComponentName getDeepLinkComponent() {
|
|
||||||
return new ComponentName(Utils.SETTINGS_PACKAGE_NAME, ALIAS_DEEP_LINK);
|
|
||||||
}
|
|
||||||
|
|
||||||
private String getHighlightMenuKey() {
|
private String getHighlightMenuKey() {
|
||||||
final Intent intent = getIntent();
|
final Intent intent = getIntent();
|
||||||
if (intent != null && TextUtils.equals(intent.getAction(),
|
if (intent != null && TextUtils.equals(intent.getAction(),
|
||||||
|
@@ -16,12 +16,6 @@
|
|||||||
|
|
||||||
package com.android.settings.homepage;
|
package com.android.settings.homepage;
|
||||||
|
|
||||||
import android.content.ComponentName;
|
|
||||||
|
|
||||||
/** Activity for Slices to launch Settings deep link page */
|
/** Activity for Slices to launch Settings deep link page */
|
||||||
public class SliceDeepLinkHomepageActivity extends SettingsHomepageActivity {
|
public class SliceDeepLinkHomepageActivity extends SettingsHomepageActivity {
|
||||||
@Override
|
|
||||||
protected ComponentName getDeepLinkComponent() {
|
|
||||||
return new ComponentName(getApplicationContext(), getClass());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@@ -203,7 +203,7 @@ public class HighlightableTopLevelPreferenceAdapter extends PreferenceGroupAdapt
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mHomepageActivity.registerHomepageLoadedListenerIfNeeded(this)) {
|
if (mHomepageActivity.addHomepageLoadedListener(this)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user