Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e0dde6a6 authored by Chandan Nath's avatar Chandan Nath Committed by Android (Google) Code Review
Browse files

Merge "[Multi-user] Change Backup Settings page to support multi-user."

parents 6d905451 0bfef638
Loading
Loading
Loading
Loading
+18 −8
Original line number Diff line number Diff line
@@ -2776,13 +2776,17 @@
                android:value="com.android.settings.webview.WebViewAppPicker" />
        </activity-alias>

        <activity android:name=".backup.BackupSettingsActivity"
        <provider
            android:name=".backup.BackupSettingsContentProvider"
            android:authorities="com.android.settings.backup.BackupSettingsContentProvider"
	    android:exported="true">
        </provider>

        <activity android:name=".backup.UserBackupSettingsActivity"
                  android:label="@string/privacy_settings_title"
                  android:icon="@drawable/ic_settings_backup"
                  android:parentActivityName="Settings">
                  android:icon="@drawable/ic_settings_backup">
            <intent-filter android:priority="1">
                <action android:name="android.settings.PRIVACY_SETTINGS" />
                <action android:name="android.settings.BACKUP_AND_RESET_SETTINGS" />
                <category android:name="android.intent.category.DEFAULT" />
            </intent-filter>
            <intent-filter>
@@ -2790,10 +2794,16 @@
                <category android:name="android.intent.category.DEFAULT" />
                <category android:name="android.intent.category.VOICE_LAUNCH" />
            </intent-filter>
            <meta-data android:name="com.android.settings.summary"
                       android:resource="@string/summary_empty"/>
            <meta-data android:name="com.android.settings.PRIMARY_PROFILE_CONTROLLED"
                       android:value="true" />
            <!-- Mark the activity as a dynamic setting -->
            <intent-filter>
                <action android:name="com.android.settings.action.IA_SETTINGS" />
            </intent-filter>
            <!-- Tell Settings app which category it belongs to -->
            <meta-data android:name="com.android.settings.category"
                       android:value="com.android.settings.category.ia.system" />
            <meta-data android:name="com.android.settings.summary_uri"
		       android:value="content://com.android.settings.backup.BackupSettingsContentProvider/summary" />
            <meta-data android:name="com.android.settings.order" android:value="-60"/>
        </activity>

        <activity
+0 −11
Original line number Diff line number Diff line
@@ -29,17 +29,6 @@
        android:fragment="com.android.settings.gestures.GestureSettings"
        settings:controller="com.android.settings.gestures.GesturesSettingPreferenceController"/>

    <!-- Backup -->
    <Preference
        android:key="backup_settings"
        android:title="@string/privacy_settings_title"
        android:summary="@string/summary_placeholder"
        android:icon="@drawable/ic_settings_backup"
        android:order="-60"
        settings:controller="com.android.settings.backup.BackupSettingsActivityPreferenceController">
        <intent android:action="android.settings.BACKUP_AND_RESET_SETTINGS" />
    </Preference>

    <Preference
        android:key="reset_dashboard"
        android:title="@string/reset_dashboard_title"
+0 −6
Original line number Diff line number Diff line
@@ -51,7 +51,6 @@ import androidx.preference.PreferenceManager;
import com.android.internal.util.ArrayUtils;
import com.android.settings.Settings.WifiSettingsActivity;
import com.android.settings.applications.manageapplications.ManageApplications;
import com.android.settings.backup.BackupSettingsActivity;
import com.android.settings.core.OnActivityResultListener;
import com.android.settings.core.SettingsBaseActivity;
import com.android.settings.core.SubSettingLauncher;
@@ -651,11 +650,6 @@ public class SettingsActivity extends SettingsBaseActivity
                showDev, isAdmin)
                || somethingChanged;

        // Enable/disable backup settings depending on whether the user is admin.
        somethingChanged = setTileEnabled(changedList, new ComponentName(packageName,
                BackupSettingsActivity.class.getName()), true, isAdmin)
                || somethingChanged;

        somethingChanged = setTileEnabled(changedList, new ComponentName(packageName,
                        Settings.WifiDisplaySettingsActivity.class.getName()),
                WifiDisplaySettings.isAvailable(this), isAdmin)
+0 −54
Original line number Diff line number Diff line
/*
 * Copyright (C) 2017 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.backup;

import android.app.backup.BackupManager;
import android.content.Context;
import android.os.UserManager;

import com.android.settings.R;
import com.android.settings.core.BasePreferenceController;

public class BackupSettingsActivityPreferenceController extends BasePreferenceController {
    private static final String TAG = "BackupSettingActivityPC";


    private final UserManager mUm;
    private final BackupManager mBackupManager;

    public BackupSettingsActivityPreferenceController(Context context, String key) {
        super(context, key);
        mUm = (UserManager) context.getSystemService(Context.USER_SERVICE);
        mBackupManager = new BackupManager(context);
    }

    @Override
    public int getAvailabilityStatus() {
        return mUm.isAdminUser()
                ? AVAILABLE_UNSEARCHABLE
                : UNSUPPORTED_ON_DEVICE;
    }

    @Override
    public CharSequence getSummary() {
        final boolean backupEnabled = mBackupManager.isBackupEnabled();

        return backupEnabled
                ? mContext.getText(R.string.backup_summary_state_on)
                : mContext.getText(R.string.backup_summary_state_off);
    }
}
 No newline at end of file
+78 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2019 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.backup;

import android.content.ContentProvider;
import android.content.ContentValues;
import android.content.UriMatcher;
import android.database.Cursor;
import android.net.Uri;
import android.os.Bundle;

import static com.android.settingslib.drawer.TileUtils.META_DATA_PREFERENCE_SUMMARY;

/** Provider stores and manages user interaction feedback for homepage contextual cards. */
public class BackupSettingsContentProvider extends ContentProvider {
    private static final String AUTHORITY =
        "com.android.settings.backup.BackupSettingsContentProvider";
    private static final String SUMMARY = "summary";
    private static final UriMatcher URI_MATCHER = new UriMatcher(UriMatcher.NO_MATCH);
    static {
        URI_MATCHER.addURI(AUTHORITY, SUMMARY, 1);
    }

    @Override
    public Bundle call(String method, String uri, Bundle extras) {
        if (!SUMMARY.equals(method)) {
            return null;
        }
        Bundle bundle = new Bundle();
        bundle.putString(META_DATA_PREFERENCE_SUMMARY,
            new BackupSettingsHelper(getContext()).getSummary());
        return bundle;
    }

    @Override
    public boolean onCreate() {
        return true;
    }

    @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();
    }
}
Loading