Start deep link page synchronously in SettingsActivity
- Use a synchronous API to make SettingsActivity start deep link intent in onCreate - Change SettingsHomepageActivity from an alias to a real activity - Clean up redundant codes Fix: 206585572 Test: Manual, robotest build pass Change-Id: Idf42c026f593bb5801a13cae250d1523030b7092
This commit is contained in:
@@ -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.SubSettings;
|
||||
import com.android.settings.Utils;
|
||||
import com.android.settings.homepage.DeepLinkHomepageActivity;
|
||||
import com.android.settings.homepage.SettingsHomepageActivity;
|
||||
import com.android.settings.homepage.SliceDeepLinkHomepageActivity;
|
||||
|
||||
@@ -101,7 +101,6 @@ public class ActivityEmbeddingRulesController {
|
||||
ComponentName secondaryComponent,
|
||||
String secondaryIntentAction,
|
||||
boolean clearTop) {
|
||||
|
||||
registerTwoPanePairRule(
|
||||
context,
|
||||
getComponentName(context, Settings.class),
|
||||
@@ -113,8 +112,7 @@ public class ActivityEmbeddingRulesController {
|
||||
|
||||
registerTwoPanePairRule(
|
||||
context,
|
||||
new ComponentName(Utils.SETTINGS_PACKAGE_NAME,
|
||||
SettingsHomepageActivity.ALIAS_DEEP_LINK),
|
||||
new ComponentName(context, DeepLinkHomepageActivity.class),
|
||||
secondaryComponent,
|
||||
secondaryIntentAction,
|
||||
true /* finishPrimaryWithSecondary */,
|
||||
@@ -156,9 +154,9 @@ public class ActivityEmbeddingRulesController {
|
||||
private void registerHomepagePlaceholderRule() {
|
||||
final Set<ActivityFilter> activityFilters = new HashSet<>();
|
||||
addActivityFilter(activityFilters, SettingsHomepageActivity.class);
|
||||
addActivityFilter(activityFilters, DeepLinkHomepageActivity.class);
|
||||
addActivityFilter(activityFilters, SliceDeepLinkHomepageActivity.class);
|
||||
addActivityFilter(activityFilters, Settings.class);
|
||||
addActivityFilter(activityFilters, new ComponentName(Utils.SETTINGS_PACKAGE_NAME,
|
||||
SettingsHomepageActivity.ALIAS_DEEP_LINK));
|
||||
|
||||
final Intent intent = new Intent();
|
||||
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);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user