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

Commit 08482454 authored by Amith Yamasani's avatar Amith Yamasani Committed by Android (Google) Code Review
Browse files

Merge "Fix the user name for the owner." into jb-mr1-dev

parents 07ce0ca2 6f34b411
Loading
Loading
Loading
Loading
+1 −1
Original line number Original line Diff line number Diff line
@@ -585,7 +585,7 @@
    <string name="permdesc_writeDictionary" msgid="8185385716255065291">"Allows the app to write new words into the user dictionary."</string>
    <string name="permdesc_writeDictionary" msgid="8185385716255065291">"Allows the app to write new words into the user dictionary."</string>
    <string name="permlab_sdcardRead" product="nosdcard" msgid="8235341515605559677">"test access to protected storage"</string>
    <string name="permlab_sdcardRead" product="nosdcard" msgid="8235341515605559677">"test access to protected storage"</string>
    <string name="permlab_sdcardRead" product="default" msgid="8235341515605559677">"test access to protected storage"</string>
    <string name="permlab_sdcardRead" product="default" msgid="8235341515605559677">"test access to protected storage"</string>
    <string name="permdesc_sdcardRead" product="nosdcard" msgid="5791957130190763289">"Allows the app to test a permission for USB storage that will be availabe on future devices."</string>
    <string name="permdesc_sdcardRead" product="nosdcard" msgid="5791957130190763289">"Allows the app to test a permission for USB storage that will be available on future devices."</string>
    <string name="permdesc_sdcardRead" product="default" msgid="5914402684685848828">"Allows the app to test a permission for the SD card that will be available on future devices."</string>
    <string name="permdesc_sdcardRead" product="default" msgid="5914402684685848828">"Allows the app to test a permission for the SD card that will be available on future devices."</string>
    <string name="permlab_sdcardWrite" product="nosdcard" msgid="8485979062254666748">"modify or delete the contents of your USB storage"</string>
    <string name="permlab_sdcardWrite" product="nosdcard" msgid="8485979062254666748">"modify or delete the contents of your USB storage"</string>
    <string name="permlab_sdcardWrite" product="default" msgid="8805693630050458763">"modify or delete the contents of your SD card"</string>
    <string name="permlab_sdcardWrite" product="default" msgid="8805693630050458763">"modify or delete the contents of your SD card"</string>
+3 −1
Original line number Original line Diff line number Diff line
@@ -1721,7 +1721,7 @@
    <!-- Title of an application permission, listed so the user can choose whether they want to allow the application to do this. -->
    <!-- Title of an application permission, listed so the user can choose whether they want to allow the application to do this. -->
    <string name="permlab_sdcardRead" product="default">test access to protected storage</string>
    <string name="permlab_sdcardRead" product="default">test access to protected storage</string>
    <!-- Description of an application permission, listed so the user can choose whether they want to allow the application to do this. [CHAR LIMIT=30] -->
    <!-- Description of an application permission, listed so the user can choose whether they want to allow the application to do this. [CHAR LIMIT=30] -->
    <string name="permdesc_sdcardRead" product="nosdcard">Allows the app to test a permission for USB storage that will be availabe on future devices. </string>
    <string name="permdesc_sdcardRead" product="nosdcard">Allows the app to test a permission for USB storage that will be available on future devices. </string>
    <!-- Description of an application permission, listed so the user can choose whether they want to allow the application to do this. -->
    <!-- Description of an application permission, listed so the user can choose whether they want to allow the application to do this. -->
    <string name="permdesc_sdcardRead" product="default">Allows the app to test a permission for the SD card that will be available on future devices.</string>
    <string name="permdesc_sdcardRead" product="default">Allows the app to test a permission for the SD card that will be available on future devices.</string>


@@ -3950,5 +3950,7 @@
    <string name="enable_accessibility_canceled">Accessibility canceled.</string>
    <string name="enable_accessibility_canceled">Accessibility canceled.</string>
    <!-- Text spoken when the current user is switched if accessibility is enabled. [CHAR LIMIT=none] -->
    <!-- Text spoken when the current user is switched if accessibility is enabled. [CHAR LIMIT=none] -->
    <string name="user_switched">Current user <xliff:g id="name" example="Bob">%1$s</xliff:g>.</string>
    <string name="user_switched">Current user <xliff:g id="name" example="Bob">%1$s</xliff:g>.</string>
    <!-- Default name of the owner user [CHAR LIMIT=20] -->
    <string name="owner_name" msgid="3879126011135546571">Owner</string>


</resources>
</resources>
+1 −0
Original line number Original line Diff line number Diff line
@@ -842,6 +842,7 @@
  <java-symbol type="string" name="media_route_status_connecting" />
  <java-symbol type="string" name="media_route_status_connecting" />
  <java-symbol type="string" name="media_route_status_available" />
  <java-symbol type="string" name="media_route_status_available" />
  <java-symbol type="string" name="media_route_status_not_available" />
  <java-symbol type="string" name="media_route_status_not_available" />
  <java-symbol type="string" name="owner_name" />


  <java-symbol type="plurals" name="abbrev_in_num_days" />
  <java-symbol type="plurals" name="abbrev_in_num_days" />
  <java-symbol type="plurals" name="abbrev_in_num_hours" />
  <java-symbol type="plurals" name="abbrev_in_num_hours" />
+39 −1
Original line number Original line Diff line number Diff line
@@ -26,6 +26,7 @@ import android.app.IStopUserCallback;
import android.content.BroadcastReceiver;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Context;
import android.content.Intent;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.pm.PackageManager;
import android.content.pm.PackageManager;
import android.content.pm.UserInfo;
import android.content.pm.UserInfo;
import android.graphics.Bitmap;
import android.graphics.Bitmap;
@@ -75,6 +76,7 @@ public class UserManagerService extends IUserManager.Stub {
    private static final String ATTR_SERIAL_NO = "serialNumber";
    private static final String ATTR_SERIAL_NO = "serialNumber";
    private static final String ATTR_NEXT_SERIAL_NO = "nextSerialNumber";
    private static final String ATTR_NEXT_SERIAL_NO = "nextSerialNumber";
    private static final String ATTR_PARTIAL = "partial";
    private static final String ATTR_PARTIAL = "partial";
    private static final String ATTR_USER_VERSION = "version";
    private static final String TAG_USERS = "users";
    private static final String TAG_USERS = "users";
    private static final String TAG_USER = "user";
    private static final String TAG_USER = "user";


@@ -84,6 +86,8 @@ public class UserManagerService extends IUserManager.Stub {


    private static final int MIN_USER_ID = 10;
    private static final int MIN_USER_ID = 10;


    private static final int USER_VERSION = 1;

    private static final long EPOCH_PLUS_30_YEARS = 30L * 365 * 24 * 60 * 60 * 1000L; // ms
    private static final long EPOCH_PLUS_30_YEARS = 30L * 365 * 24 * 60 * 60 * 1000L; // ms


    private final Context mContext;
    private final Context mContext;
@@ -104,6 +108,7 @@ public class UserManagerService extends IUserManager.Stub {
    // This resets on a reboot. Otherwise it keeps incrementing so that user ids are
    // This resets on a reboot. Otherwise it keeps incrementing so that user ids are
    // not reused in quick succession
    // not reused in quick succession
    private int mNextUserId = MIN_USER_ID;
    private int mNextUserId = MIN_USER_ID;
    private int mUserVersion = 0;


    private static UserManagerService sInstance;
    private static UserManagerService sInstance;


@@ -432,12 +437,17 @@ public class UserManagerService extends IUserManager.Stub {
                if (lastSerialNumber != null) {
                if (lastSerialNumber != null) {
                    mNextSerialNumber = Integer.parseInt(lastSerialNumber);
                    mNextSerialNumber = Integer.parseInt(lastSerialNumber);
                }
                }
                String versionNumber = parser.getAttributeValue(null, ATTR_USER_VERSION);
                if (versionNumber != null) {
                    mUserVersion = Integer.parseInt(versionNumber);
                }
            }
            }


            while ((type = parser.next()) != XmlPullParser.END_DOCUMENT) {
            while ((type = parser.next()) != XmlPullParser.END_DOCUMENT) {
                if (type == XmlPullParser.START_TAG && parser.getName().equals(TAG_USER)) {
                if (type == XmlPullParser.START_TAG && parser.getName().equals(TAG_USER)) {
                    String id = parser.getAttributeValue(null, ATTR_ID);
                    String id = parser.getAttributeValue(null, ATTR_ID);
                    UserInfo user = readUser(Integer.parseInt(id));
                    UserInfo user = readUser(Integer.parseInt(id));

                    if (user != null) {
                    if (user != null) {
                        mUsers.put(user.id, user);
                        mUsers.put(user.id, user);
                        if (user.isGuest()) {
                        if (user.isGuest()) {
@@ -450,6 +460,7 @@ public class UserManagerService extends IUserManager.Stub {
                }
                }
            }
            }
            updateUserIdsLocked();
            updateUserIdsLocked();
            upgradeIfNecessary();
        } catch (IOException ioe) {
        } catch (IOException ioe) {
            fallbackToSingleUserLocked();
            fallbackToSingleUserLocked();
        } catch (XmlPullParserException pe) {
        } catch (XmlPullParserException pe) {
@@ -464,9 +475,35 @@ public class UserManagerService extends IUserManager.Stub {
        }
        }
    }
    }


    /**
     * This fixes an incorrect initialization of user name for the owner.
     * TODO: Remove in the next release.
     */
    private void upgradeIfNecessary() {
        int userVersion = mUserVersion;
        if (userVersion < 1) {
            // Assign a proper name for the owner, if not initialized correctly before
            UserInfo user = mUsers.get(UserHandle.USER_OWNER);
            if ("Primary".equals(user.name)) {
                user.name = mContext.getResources().getString(com.android.internal.R.string.owner_name);
                writeUserLocked(user);
            }
            userVersion = 1;
        }

        if (userVersion < USER_VERSION) {
            Slog.w(LOG_TAG, "User version " + mUserVersion + " didn't upgrade as expected to "
                    + USER_VERSION);
        } else {
            mUserVersion = userVersion;
            writeUserListLocked();
        }
    }

    private void fallbackToSingleUserLocked() {
    private void fallbackToSingleUserLocked() {
        // Create the primary user
        // Create the primary user
        UserInfo primary = new UserInfo(0, "Primary", null,
        UserInfo primary = new UserInfo(0, 
                mContext.getResources().getString(com.android.internal.R.string.owner_name), null,
                UserInfo.FLAG_ADMIN | UserInfo.FLAG_PRIMARY | UserInfo.FLAG_INITIALIZED);
                UserInfo.FLAG_ADMIN | UserInfo.FLAG_PRIMARY | UserInfo.FLAG_INITIALIZED);
        mUsers.put(0, primary);
        mUsers.put(0, primary);
        mNextSerialNumber = MIN_USER_ID;
        mNextSerialNumber = MIN_USER_ID;
@@ -547,6 +584,7 @@ public class UserManagerService extends IUserManager.Stub {


            serializer.startTag(null, TAG_USERS);
            serializer.startTag(null, TAG_USERS);
            serializer.attribute(null, ATTR_NEXT_SERIAL_NO, Integer.toString(mNextSerialNumber));
            serializer.attribute(null, ATTR_NEXT_SERIAL_NO, Integer.toString(mNextSerialNumber));
            serializer.attribute(null, ATTR_USER_VERSION, Integer.toString(mUserVersion));


            for (int i = 0; i < mUsers.size(); i++) {
            for (int i = 0; i < mUsers.size(); i++) {
                UserInfo user = mUsers.valueAt(i);
                UserInfo user = mUsers.valueAt(i);