Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@

package org.microg.gms.phenotype;

import static org.microg.gms.phenotype.PhenotypeServiceKt.getCONFIGURATION_OPTIONS;

import android.content.ContentProvider;
import android.content.ContentValues;
import android.database.Cursor;
Expand All @@ -26,8 +28,11 @@
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import com.google.android.gms.phenotype.Flag;

public class ConfigurationProvider extends ContentProvider {
private static final String TAG = "GmsPhenotypeCfgProvider";

@Override
public boolean onCreate() {
Log.d(TAG, "unimplemented Method: onCreate");
Expand All @@ -39,7 +44,14 @@ public boolean onCreate() {
public Cursor query(@NonNull Uri uri, @Nullable String[] projection, @Nullable String selection, @Nullable String[] selectionArgs, @Nullable String sortOrder) {
selection = Uri.decode(uri.getLastPathSegment());
if (selection == null) return null;
return new MatrixCursor(new String[]{"key", "value"});
MatrixCursor cursor = new MatrixCursor(new String[]{"key", "value"});

Flag[] flags = getCONFIGURATION_OPTIONS().get(selection);
if (flags == null) return cursor;
for (Flag flag : flags) {
cursor.addRow(new Object[]{flag.name, flag.getValueString()});
}
return cursor;
}

@Nullable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class PhenotypeService : BaseService(TAG, GmsService.PHENOTYPE) {
}
}

private val CONFIGURATION_OPTIONS = mapOf(
val CONFIGURATION_OPTIONS = mapOf(
"com.google.android.apps.search.assistant.mobile.user#com.google.android.googlequicksearchbox" to arrayOf(
// Enable Gemini voice input for all devices
Flag("45477527", true, 0),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@

package com.google.android.gms.phenotype;

import android.util.Base64;

import org.microg.gms.common.Hide;
import org.microg.safeparcel.AutoSafeParcelable;

Expand Down Expand Up @@ -95,6 +97,23 @@ public byte[] getBytes() {
throw new IllegalArgumentException("Not a bytes type");
}

public String getValueString() {
switch (dataType) {
case DATA_TYPE_LONG:
return Long.toString(longValue);
case DATA_TYPE_BOOL:
return boolValue ? "true" : "false";
case DATA_TYPE_DOUBLE:
return Double.toString(doubleValue);
case DATA_TYPE_STRING:
return stringValue;
case DATA_TYPE_BYTES:
return Base64.encodeToString(bytesValue, Base64.NO_WRAP | Base64.URL_SAFE);
default:
return null;
}
}

public static final int DATA_TYPE_LONG = 1;
public static final int DATA_TYPE_BOOL = 2;
public static final int DATA_TYPE_DOUBLE = 3;
Expand Down